Skip to content

fix(api): restore liveness routing and enforce public docstrings - #498

Merged
seonghobae merged 7 commits into
worktree-fix-frontend-build-breakfrom
fix/docstring-coverage-and-healthz-routing
Aug 23, 2026
Merged

fix(api): restore liveness routing and enforce public docstrings#498
seonghobae merged 7 commits into
worktree-fix-frontend-build-breakfrom
fix/docstring-coverage-and-healthz-routing

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Buyer problem

The Compose liveness probe called /healthz, but a stray decorator routed that path to authenticated tenant settings while the real liveness handler had no route. A fresh deployment could therefore report unhealthy even when the process was running. Public production definitions also lacked a repository-wide docstring contract, leaving beginners without stable API intent.

Unique scope

  • Route /healthz to the public process-only handler and keep /api/settings authenticated.
  • Add the missing public production docstrings across lineageweave/ and backend/app/.
  • Enforce the contract with an AST-based repository scan.
  • Cover both the all-documented path and a synthetic missing-definition edge case that reports the exact repair location.

The inherited OIDC/Admin source and frontend-test changes are owned by parent PR #426 and are absent from this effective diff.

Exact composition

After #426 lands on protected main, retarget this PR to main, refetch exact head/base, and require fresh terminal checks plus an independent exact-head approval. Then revalidate child #429 against this PR's protected-main form. Do not transfer stacked-base evidence.

Exact validation

  • uv run pytest -q: 839 passed, 17 skipped, 4 dependency warnings.
  • Focused health/docstring gate: 3 passed, 112 deselected.
  • Diff coverage: 28/28 changed executable lines (100%), including the missing-docstring failure branch.
  • git diff --check: passed.
  • Effective frontend diff versus fix: repair frontend build and publish ontology Pages #426: empty.

All scanner fixtures are synthetic and remain outside production artifacts.

A stray decorator had stacked GET /healthz onto read_tenant_settings,
so the liveness probe silently required auth and hit Postgres instead
of returning {"status": "ok"}; the real healthz() handler had no route
at all. Restored the decorator to the correct handler and added a
regression test.

Also closed the repository-wide docstring-coverage gap: an AST audit
of lineageweave/ and backend/app/ found 35 public functions/classes
missing docstrings (excluding private/dunder names, __init__.py, and
tests). Added them all, plus two leftover "buyer" wording references
from before the terminology rename.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011EP69xAyLaJxa6oaF6D9eq
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e0a517a-ac4a-447f-9c8f-d23730907b74

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

seonghobae added a commit that referenced this pull request Aug 23, 2026
35 missing production docstrings found by an independent AST re-audit
were written in PR #498, with the full Python suite still green.
Coverage-enforcement (pytest coverage gate, Vitest coverage provider)
remains open and is called out separately now.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011EP69xAyLaJxa6oaF6D9eq
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Note: #429 (opened 2026-08-22) already fixes this exact /healthz decorator bug, plus a related tenant_settings migration-fixture gap this PR doesn't touch. Found independently while cross-checking the open-PR list this checkpoint. Both PRs move the same decorator to the same place, so whichever merges first should make the other a clean no-op on that hunk; this PR's unique contribution is the 35 missing docstrings + the new tests/test_public_docstrings.py enforcement gate (added by a concurrent push on this branch).

Copy link
Copy Markdown
Contributor Author

@opencode-agent @cwl-noema-review exact-head independent review for 35823d889c5360ebf2152ed5679d7c22d6832545.

/healthz routing + public docstring coverage. Overlaps #429; preserve only unique value after #429/#426 protected order. Auto-merge may be armed when independent APPROVE lands. This identity cannot self-approve. Checks are not blockers. Strix provider infrastructure fails are non-findings.

…k' into agent-pr498-compose-20260824

# Conflicts:
#	CHANGELOG.md
#	frontend/src/App.test.tsx
@seonghobae seonghobae changed the title fix: restore /healthz routing and close the docstring-coverage gap fix(api): restore liveness routing and enforce public docstrings Aug 23, 2026
@seonghobae
seonghobae changed the base branch from main to worktree-fix-frontend-build-break August 23, 2026 19:10
* fix(api): route /healthz to the actual liveness probe, not settings

Two @app.get decorators were stacked before read_tenant_settings:

    @app.get("/healthz")

    @app.get("/api/settings", response_model=dict)
    async def read_tenant_settings(...):

Both bound to the same handler -- "/healthz" required authentication
(read_tenant_settings depends on get_current_account) and the real
healthz() function below had no route decorator at all, so it was
dead code never reachable by any request. docker-compose.yml's own
backend healthcheck hits "/healthz" with a plain unauthenticated
urllib.request.urlopen call; against this bug it would receive
401/403, fail the healthcheck, and mark the container unhealthy on
every fresh deployment.

Move the decorator onto healthz() where it belongs.

Also add migration 0103_tenant_settings.sql to backend/tests/test_api.py's
seeded_db fixture -- it was never added when the migration shipped, so
the tenant_settings table (and therefore the /api/settings GET/PATCH
endpoints, both previously untested) didn't exist in the test schema
at all.

Tests: test_healthz_is_reachable_without_a_token (the regression this
bug needed) plus three new /api/settings tests (GET returns the seeded
brand name, PATCH requires post_admin, PATCH as admin actually changes
it). uv run --frozen python -m pytest -q: 757 passed, 17 skipped.

* fix(frontend): use OIDC return-url helpers and guard AdminPanel render

Same shared-ancestor bug as #418/#415/#426/#427: the login button built
an unsanitized returnUrl inline instead of returnUrlFromLocation()/
rememberOidcReturnUrl(), and AdminPanel's accessToken (string, required)
was rendered from a string | undefined at both call sites.

* fix(frontend): drop redundant accessToken guard on AdminPanel render

An earlier `if (!accessToken) return` a few hundred lines up already
narrows accessToken to string for the rest of the authenticated render
tree -- confirmed with a clean tsc build without the guard.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +19 to +26
for node in ast.walk(tree):
if (
isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef))
and not node.name.startswith("_")
and ast.get_docstring(node) is None
):
missing.append(f"{path.relative_to(root)}:{node.lineno}:{node.name}")
return missing

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Docstring gate is strict and nesting-blind

The gate in test_public_docstrings.py walks all nodes with ast.walk, so it requires docstrings on public-named definitions even when nested inside private classes or functions. It passes now (0 missing), but future contributors face this broad, non-obvious requirement.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

… merge

The base branch (worktree-fix-frontend-build-break) had already merged
this PR's own docstring addition into fuse_rankings(), but the earlier
conflict resolution on this branch's side had dropped the
'active_weights = weights or DEFAULT_CHANNEL_WEIGHTS' line entirely
while keeping only the docstring — a NameError waiting to happen at
the next line, which reads active_weights. Kept both. Verified: 846
Python tests pass (15/15 in rankweave-specific tests).
@seonghobae
seonghobae merged commit 2ef7afa into worktree-fix-frontend-build-break Aug 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant