Repository navigation
feat: Enforce daemon route declaration completeness with proven examples - #5189
Conversation
The four daemon RouteSpecs declared no completeness edges and either no
example or a summary-only one, so `devtools gate declaration-bindings`
ran the daemon-route registry with `include_structural=False`.
Each example is now derived from the live request contract -- the query
keys the handler actually reads (`limit`/`offset`/`cursor` plus
`_build_query_spec_params` for find, none for status,
`expression`/`limit`/`offset` for query-units, `view`/`format`/`limit`/
`offset` for read) -- and replayed against the production handler on a
seeded archive by `TestDeclaredRouteExamples`. The query-units
continuation shape is deliberately not declared: its token is opaque and
no static literal can stand for it.
Both completeness edges are hard failures, not documentation: the route
adapter is generated from the declaration and the OpenAPI renderer raises
when a declared method/path has no operation.
Anti-vacuity: renaming an example argument, giving it a value the handler
rejects (`view=unsupported`, `format=csv`), or declaring an unparseable
filter turns the replay test red while the structural gate alone stays
green; dropping an example or edge now turns the gate itself red.
Verification:
python -m devtools gate declaration-bindings -> daemon-route: OK, mcp: OK (exit 0)
python -m devtools test tests/unit/declarations/ tests/unit/daemon/test_route_contracts.py \
tests/unit/daemon/test_web_reader.py::TestDeclaredRouteExamples -> 134 passed
python -m devtools verify --quick -> exit 0
python -m devtools render all --check -> exit 0, no "out of sync"
python -m devtools schema closure polylogue/daemon/route_contracts.py -> out
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 30 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
## Summary The query, marker and maintenance families had **no** `polylogue.declarations` import at head. All three now build `DeclarationSpec` kernels, and the `declaration-bindings` gate enforces five registries instead of two. Delivers polylogue-o21.3. ## Per-family adoption | Family | New declaration site | Hand-maintained map removed / derived | |---|---|---| | **query** | `polylogue/archive/query/declarations.py` — 49 fields + 9 terminal units → `QUERY_KERNEL_REGISTRY` | `capability_catalog._declaration_rows()` no longer re-assembles `declaration_id`/payload; it serves `QUERY_CAPABILITY_DECLARATIONS`. Row output proved **byte-equal** to the pre-change projection (58 rows, `old == new` → True) | | **marker** | `polylogue/markers/declarations.py` — 14 kinds → `MARKER_KERNEL_REGISTRY` | No parallel map existed; the projection is *derived* from `MARKER_REGISTRY`, not transcribed | | **maintenance** | `polylogue/maintenance/declarations.py` — 30 commands → `MAINTENANCE_KERNEL_REGISTRY` | Deleted the `_COMMANDS` four-tuple table **and** `_NESTED_GROUP_COMMANDS` from `cli/commands/maintenance/__init__.py`; the Click group derives every field. `ops maintenance --help` diffed **byte-identical** before/after | `devtools/verify_declaration_bindings.py` enforces all five registries through a typed `_RegistryEntry`, with an optional domain hook so the query family's own `spec_attr`/`plan_attr`/`ArchiveStore` executor resolution runs inside the gate **without the generic gate learning query vocabulary**. Domain validation stays with the domain; only the reporting shape is shared. No new devtools root verb — the twelve-verb fold ratchet is untouched. ## Acceptance evidence - **A reference with no producer fails with an exact repair.** Four mutation tests — renamed `lower_markers`, renamed `ArchiveStore.query_messages`, deleted `archive_plan_command`, and a root with no source tree — each yields `unresolved_handler_symbol` / `unresolved_owner_path` carrying the declaration's own `repair_command`. - **Examples cross the real adapter, not a mock.** Marker examples are rendered in the live grammar, parsed by the production `parse_markers`, and lowered by the production `lower_markers` into a real `user.db` (asserting `assertions.kind`, `author_kind`, status). Unit examples parse through `parse_unit_source_expression`. Every maintenance example argv runs through the production Click tree. Declared MCP field parameters are checked against live `mcp_query_field_names()` with a non-vacuity assert. - **Adding a member needs only its family module**: `test_adding_a_kind_requires_only_the_typed_family_module` builds a registry with a synthetic kind and gets its kernel with no second edit; `test_every_live_field_and_terminal_unit_is_declared` pins field/unit set equality. ## Integration note This branch was written against `99eca30e8`, before #5189 landed. Both touched `verify_declaration_bindings.py`, and the rebase conflicted on `REGISTRIES`. Resolved by keeping this branch's five-entry `_RegistryEntry` structure while taking #5189's `daemon-route: structural=True`, and rewriting the `_RegistryEntry` docstring, which still described daemon-route as resolution-only. **All five registries are now structurally enforced.** Re-verified after the resolution rather than assumed: ``` devtools gate declaration-bindings → exit 0; daemon-route, maintenance, marker, mcp, query all OK devtools verify --quick → exit 0 devtools test tests/unit/markers tests/unit/declarations \ tests/unit/devtools/test_declaration_binding_registries.py \ tests/unit/daemon/test_web_reader.py tests/unit/cli/test_maintenance_registration.py → PASSED exit 0 (receipt 20260915T152903Z-…) devtools render all --check → exit 0, no "out of sync" ``` ## Schema-identity closure: no IN file touched All six changed non-test files are `out`. This was deliberate: `markers/registry.py`, `markers/models.py`, `archive/query/fields.py`, `archive/query/metadata.py`, `expression.py` and `declarations/validation.py` are all **IN**, and every projection went into a new sibling module that imports them but is imported by nothing in the closure. **No reconvergence is forced and no commit here needs to land before a rebuild.** ## Residuals - `gate consumer-reachability` reports (report-only, non-blocking) that no production entrypoint reaches `polylogue/markers/declarations.py`. Accurate and stated rather than hidden: the marker projection's consumer is the `declaration-bindings` gate, which does run and does enforce it. The query and maintenance declarations are not flagged, because `capability_catalog.py` and the maintenance Click group consume them on production paths. - A real check defect was found and fixed during the work, not a product bug: the first query domain check flagged `query.field.query_terms` `plan_attr='fts_terms'`, because `fts_terms` is a *property* on `SessionQueryPlan` rather than a dataclass field. The check now accepts both. - Pre-existing flake, untouched by this branch: one earlier run of the broad selection failed `test_maintenance_registration.py::test_blob_conservation_json_returns_failure_for_a_failed_census` with `sqlite3.OperationalError: unable to open database file` (its monkeypatch did not take). The identical selection passed on rerun, and the test's own docstring documents its ambient-archive-root order sensitivity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added comprehensive declarations for query capabilities, markers, and maintenance commands. - Expanded maintenance CLI coverage, including nested command groups and improved command help. - Added consistent examples and lookup support for query capabilities and marker types. - **Bug Fixes** - Improved validation and diagnostics for invalid or incomplete command, query, and marker bindings. - Ensured capability listings remain synchronized with available query fields and terminal units. - **Tests** - Added coverage for CLI behavior, query capabilities, marker processing, examples, and actionable error reporting. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…#5220) ## Summary Five daemon HTTP/status beads where the surface reported a value it had not measured, or refused nothing when it could do nothing. ## Problem and solution, per bead **gqdfx — readiness started from `True`.** `fts_ready` was initialized `True`, so an absent index tier probed ready. It is now the named `index_tier_missing` 503 with the path in the message, added to the probe's closed taxonomy. **peo7o — `reset` claimed mutations it never performed.** Every scope outside `RESET_SUPPORTED_SCOPES = {"session"}` now refuses `400 unsupported_scope` with `supported_scopes`; `session_id` is required; `Content-Length` parses defensively (400, not a 500 through `daemon_safe_handler`). The dead `{"ok": True}` branch is gone, so no `reset-all-all` event can be emitted for an unperformed mutation. `_sync_run` raises if a refused request ever reaches the writer. **8r4zq (HTTP half) — unbounded mutation wait.** `_sync_run`'s mutating branch carries `_MUTATION_WAIT_TIMEOUT_S = 60` (shortenable via `X-Polylogue-Deadline-Ms`, clamped) and raises `DaemonMutationIndeterminate` → `503 mutation_indeterminate` + `Retry-After`. Deliberately *indeterminate*, not cancelled: the submitted write may still land. **gmskd — two HTTP status lines in one SSE body.** A stray `@daemon_safe_handler` (left where a deleted section header had been) let `_send_json(503)` write a second status line into a `text/event-stream` body. `_stream_events` now ends the stream with an SSE `error` frame. Tests assert decorator depth is exactly 1 and validate the actual bytes: exactly one `HTTP/1.` line, every body line valid SSE framing. **31h8l — evidence summary had no outcome.** The route carries an `outcome` envelope via `decide_outcome`; an unreadable `session_links` yields `degraded`/`lineage_refs_unreadable` plus `lineage_refs_authoritative: false`. **xvwpi — fabricated zeros across the status surface.** `blob_dir_size_bytes` literal `0` → `None` in all three producers; `disk_free` 0-on-OSError → `None`; `metrics.py` `all({})` → no series plus `polylogue_probe_unmeasured{probe=...}`, same for failed `convergence_debt` and `hook_flow` probes; `build_info` `dirty` `false`-for-unread → `"unknown"`; `LiveCursorSummary` all-zero on `sqlite3.Error` → typed `available=false`/`unavailable_reason`; missing `progress_classification` → `unknown`, not `healthy`. The suppressed `_check_daemon_liveness` publishes `daemon_liveness_state` and folds `measured`/`unmeasured` into the ETag, so a 304 cannot hide a failed probe. ## Executed mutation Both restorations, on the fixed tree: ``` E assert <HTTPStatus.OK: 200> == <HTTPStatus.SERVICE_UNAVAILABLE: 503> E assert 'polylogue_f...ll_present 1' not in '# HELP poly...issing"} 0\n' FAILED tests/unit/daemon/test_health_contract.py::...::test_readiness_refuses_when_index_tier_is_absent FAILED tests/unit/daemon/test_unmeasured_observations.py::test_uninspected_fts_triggers_do_not_report_all_present ======================== 2 failed, 1 warning in 13.43s ========================= ``` Both reverted; files byte-identical to the committed versions. ## Verification - Focused run across all ten touched selectors — **313 passed**, exit 0 (receipt `20260916T015503Z-focused-test-1950537-34f34cca`) - `devtools test tests/unit/daemon/ tests/unit/operations/test_daemon_status.py` — 2281 passed after fixes; rerun of the affected set **299 passed**, exit 0 - `devtools verify --quick` — exit 0, 21 gates ok - `devtools render all --check` — exit 0, `grep -c "out of sync"` = 0 `devtools schema closure` reports **`out`** for every changed file — confirmed, not assumed. Nothing here is a rebuild-boundary hazard. ## Residuals, stated honestly - **q54dt is partial.** The honest-total half is done: a truncated page now publishes `total: null`, `total_is_exact: false`, `total_lower_bound: n` instead of its own page size. The performance half needs declared operations for `/api/paste-browser` and `/api/attachments`, outside this write scope. - **7mgx is not done.** The bypass is real and current — `envelope_paste_spans(text, has_paste)` ignores `has_paste` at all four call sites and durable `index.paste_spans` still has zero read sites. Consuming the canonical table needs a storage read surface. Landed here: `paste_span_localization(spans, has_paste)` returning `localized`/`none`/`unlocalized`, so the "stored evidence says paste, derivation cannot place it" case is nameable; the four `http.py` payloads do not yet publish it. - **xvwpi's `_status_ok`** returning `ok: true` with `include_archive_readiness=False` is untouched. Flipping it changes the operator-facing meaning of `ok` on the default compact path for every surface, and the payload already publishes `archive_readiness: {checked: false, reason: ...}`. Owner decision. - **8r4zq's non-HTTP unbounded waits** in `convergence.py`, `embedding_owner.py`, `write_coordinator.py` remain open. - **tar1n's route-generation half is not done and #5189 is not regressed.** `DAEMON_ROUTE_DECLARATIONS` holds 4 executable declarations against 76 metadata-only contracts; each promotion needs a declared `domain_operation` plus contract models in `operations/` and `surfaces/payloads.py`. No hand-written `/api` route was added. - `docs/plans/sqlite-degradation-baseline.json`: the live-cursor anchor digest moved (`0d9b797…` → `e935097…`) because its handler source changed. Same site, count unchanged at 243. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
The four daemon
RouteSpecdeclarations carried no real request shapes, so thedeclaration-bindingsgate enforced structural completeness only for MCP. All four now carry examples derived from the live request contract and proven against the production handler, and the registry is flipped to structural enforcement.Problem
polylogue-exphx, filed from polylogue-o21.2.
declaration-bindings(added in #5187) enforced binding resolution for both registries but raninclude_structural=Falsefordaemon-route, with the reason recorded in source: the route declarations had no usable examples or completeness edges.Correction to the bead's description: it states all four routes declare
examples=()andcompleteness_edges=(). At head only_FIND_DECLARATIONwas fully empty; the other three carried a summary-onlyExampleSpecwith noargumentsand a single routeCompletenessEdge. The bead was written against an earlier head. The substantive gap was identical either way — no example carried a real request shape.Solution
All four routes got examples derived from their handlers, not invented:
daemon.find.sessions— two:limit=20, andquery=origin:claude-code-session&limit=5._handle_list_sessionsreadslimit/offset/cursordirectly and routes the rest through_build_query_spec_params; thequeryvalue is a DSL origin clause the shared expression compiler lowers to a structured filter.daemon.status— parameterless._handle_statustakesparams: … | Noneand reads none of them, so a parameterless example is the faithful one rather than a placeholder.daemon.query.units—expression=messages where role:user&limit=2, from the handler's initial-request branch.daemon.read.session—view=messages&format=json&limit=50&offset=0, fromREAD_VIEW_HTTP_CAPABILITIESplus the messages branch.Two completeness edges per route via a
_consumer_edgeshelper, both backed by real hard failures:daemon-http(the route adapter is generated from the declaration, andvalidate_declared_route_reachabilityrefuses daemon startup on a mismatch) andopenapi-schema→docs/openapi/search.yaml(the renderer raisesRuntimeErrorwhen a declared method/path has no operation).One shape is deliberately not declared: the query-units follow-up request accepts only the opaque
continuationtoken from the previous page and rejects any other key, so no static literal can stand for it. Recorded as a comment in the declaration rather than faked.How the examples are proven
The gate only reads declarations, so a green structural gate over invented examples would be precisely the false guarantee this task had to avoid.
TestDeclaredRouteExamplesintests/unit/daemon/test_web_reader.pycloses that hole: it stands up the realDaemonAPIHTTPServeron a seeded archive, replays every declaredExampleSpecthrough the production handler, and requires HTTP 200 plus the response contract's marker field.That test earned its keep during development — the first marker guess for the read route was wrong, and the replay caught it: the envelope echoes
view, notmessages.Anti-vacuity, two layers. At the gate: deleting any example or completeness edge turns
declaration-bindingsred now thatinclude_structural=True. At the replay test, covering what the gate cannot see: renaming an example argument (view→mode), giving it a value the handler rejects (view=unsupported,format=csv), or declaring a filter the query grammar cannot parse turns the test red while the structural gate alone would stay green. Three parametrized cases assert the 400 path explicitly.Verification
No OpenAPI regeneration was needed: the renderer consumes route identity and transport fields, not examples.
Schema-identity closure: out.
devtools schema closure polylogue/daemon/route_contracts.py→out, likewisedevtools/verify_declaration_bindings.pyandtests/unit/daemon/test_web_reader.py. The derived identity does not move, so this carries no pre-rebuild landing-order constraint.Residuals
The query-units continuation example is an intentional, documented omission, not an oversight. Covering it needs a generated token rather than a declared literal, so it belongs to a future slice if wanted.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK