Repository navigation
feat(surfaces): unify authority and structural tool outcomes - #4539
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78b0095607
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ures (#4563) ## Summary Three independent red classes, each landed as its own commit: 1. **`fix(devtools)`** — the index fast-forward tool reads the index it is about to carry forward without asserting that index is already at the runtime's version. 2. **`test`** — four hand-built fixtures pinned index shapes the runtime has moved past. 3. **`fix(surfaces)`** — the message-row envelope drops `identity_source`, which its own mask declares public. ## Problem and solution, per class ### Fast-forward reads `#4485`'s open-time tier check refused both pre-forward reads in a tool whose purpose is an index at a non-current version: ``` polylogue.core.errors.SchemaSkewError: index schema skew: expected 37, found 36 ``` `_inspect_clean_database` returns that version as its result and `_sample_manifest` samples the index being carried, so both read with `validate_schema=False`. The candidate-index read *after* the forward keeps the check: that index is at the target version and must be. ### Fixtures pinned to superseded shapes - `test_lineage_validation` stamped and asserted `user_version = 73`; both now derive from `INDEX_SCHEMA_VERSION`. - `test_reindex_canary_cli` stamped `43` on an index it had just seeded at the current version; the scenario is a title backfill and the version literal was incidental. - `test_envelope`'s hand-built `blocks` table predates `tool_outcome` (`#4539`), so the coordination evidence query failed with `no such column: r.tool_outcome`. - `test_web_reader` asserted an uppercase doctype; the renderer emits the lowercase HTML5 form. ### `identity_source` on the message row `_MESSAGE_MASK` declares the field public and the render envelope publishes it, but the row envelope's `field_order` omitted it. `message_row_envelope_from_domain` builds the row envelope by dumping the render envelope, so every paginated message read failed closed with `extra_forbidden`. The row envelope now lists the field where the mask puts it; the generated CLI-output schemas are regenerated to match. `_FakeApi` in the CLI message tests gains the `config` the read path builds its authority envelope from. ## Verification `devtools test <file> -p no:randomly -n 2`: | file | before | after | | --- | --- | --- | | `tests/unit/cli/test_messages.py` | 7 failed | **13 passed** | | `tests/unit/coordination/test_envelope.py` | 3 failed | 1 failed | | `tests/unit/devtools/test_lineage_validation.py` | 21 failed | 8 failed | | `tests/unit/devtools/test_index_fast_forward.py` | 25 `SchemaSkewError` | 0 `SchemaSkewError` | `devtools verify --quick` green. ## Residual risk `test_index_fast_forward.py` is still red on `ArchiveLocationError` from `#4411`'s symlink-farm discrimination, which refuses the two-root index-generation layout both that suite and `test_daemon_status.py` document as legitimate. `test_lineage_validation.py`'s remaining 8 come from the read envelope's behaviour on its hand-built partial index. Both are separate causes, not addressed here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
## Summary Nine unaddressed Codex review threads from merged PRs #4539, #4550 and #4552. Each was re-verified against current `origin/master` before being fixed; two were refuted and are recorded below rather than silently dropped. ## Problem Attribution for a read result was assembled inside `polylogue/surfaces/authority.py` from a bare archive root. That is the wrong layer and the wrong input: the surface re-resolved the active generation at serialization time, so a result could be attributed to a generation published after its rows were read. ## Solution **#4539 `polylogue/surfaces/authority.py:12` — move archive resolution out of the surface layer.** `surfaces/authority.py` now holds only the envelope and takes already-resolved facts. Resolution moved to `polylogue/operations/authority.py`. `docs/plans/layering.yaml` gains a `polylogue/surfaces` rule so the boundary is enforced rather than merely intended — it had no rule at all, so the import was unratcheted. Two pre-existing type-only row imports in `payloads.py` are baselined and ratchet like the other four surfaces. **#4539 `polylogue/archive/query/unit_results.py:728` — bind authority to the generation opened by the reader.** New `ArchiveIdentity.resolve_pinned_index` resolves durable tiers against the index a reader already holds open. `authority_for_reader` uses it. **#4539 `polylogue/api/search_envelope_builder.py:138` — resolve authority from the active archive root.** `authority_for_config` follows `active_archive_root(config)`, so an explicit `Config(db_path=...)` split-root override is attributed to the archive the read actually used. **#4539 `polylogue/surfaces/authority.py:65` — measure elapsed time at the operation boundary.** No production call site passed `started_at`, so `elapsed_ms` was structurally always 0. All eight now capture it at their operation boundary. **#4539 `polylogue/surfaces/payloads.py:3947` — include authority in daemon message responses.** `_do_get_messages` and `_do_archive_get_messages` emit `authority`, including on the not-found early return. **#4552 `polylogue/api/archive.py:1691` — preserve expiry filtering in the candidate queue.** `_archive_list_assertion_candidates` derived the actionable queue from the candidate-*review* read model, which pins `include_expired=True` deliberately so judged history is never erased. The queue now calls the canonical `list_assertion_candidates`, which excludes expired claims. **#4552 `polylogue/api/archive.py:3453` — preserve user-tier unavailability errors.** A missing or unreadable `user.db` was swallowed into `return []`, presenting a read failure as a judged-empty queue. Both candidate reads now go through one `_readable_user_tier` context manager that raises `ArchiveTierUnavailableError`, matching the sibling assertion read. **#4550 `polylogue/cli/click_command_registration.py:192` — limit the root alias.** Root `insights` registered the whole `ops insights` group a second time, contradicting `docs/insights.md:7`, and entered the tree as an unexplained hitchhiker in the #4550 squash (that PR was a corpus-manifest refactor). Removed; `docs/cli-reference.md` regenerated. ### Refuted **#4550 `click_command_registration.py:192` — "update the pinned root-help snapshots".** There is no pinned root-help snapshot. `tests/unit/cli/test_help_snapshots.py` does not exist, and `devtools render all --check` reports every generated surface in sync at the reviewed head. No change made. **#4526 `polylogue/operations/zip_acquisition_replay.py:122` — large JSON integer overflow.** The reviewed code never merged: `git log` shows the file untouched by #4526, whose merge commit records that the ZIP-replay work was descoped before merge. Nothing to fix. ## Verification `devtools test tests/unit/surfaces/test_authority.py tests/unit/api/test_assertion_candidate_queue_admission.py tests/unit/cli/test_help_contract.py -n 2` — **166 passed**. `devtools gate layering` — `violations 0, baselined 296, status passed` with the new `polylogue/surfaces` rule enforced. `devtools test tests/unit/api tests/unit/surfaces tests/unit/mcp -n 4` — 897 passed, 3 failed. All three failures reproduce identically on clean `origin/master` (`test_archive_tiers_api_session_costs_read_index_tier`, `test_existing_same_version_ops_database_receives_additive_call_log`, `test_record_context_delivery_requires_initialized_user_tier`) and are inherited, not introduced here. `devtools verify --quick` — all 12 gates ok (run by the pre-push hook). Each new test names its anti-vacuity condition in its docstring: dropping `started_at` pins `elapsed_ms` to 0; resolving from the root instead of the pinned index flips attribution to the newly published generation; reading `config.archive_root` instead of the active root returns the decoy archive; re-importing `archive_identity` into the surface module fails the boundary assertion; routing the queue back through the review read model resurfaces the expired claim; swallowing the tier error back into `return []` makes the refusal test pass silently. ## Residual risk The `polylogue/surfaces` layering rule is new, so its two baselined `payloads.py` entries are type-only imports that a future change could grow into runtime ones; the ratchet makes that visible in review rather than preventing it. `authority_for_reader` requires a reader exposing `archive_root` and `index_db_path` — the MCP and daemon archive paths satisfy this; config-based surfaces still resolve the active generation, which is correct for them because they have not opened a reader. Co-authored-by: Claude Fable 5.1 <[email protected]>
…4587) ## Summary Fixes the eleven verified Codex review findings in the sources / daemon / operations sweep. Each was re-confirmed at this branch's base before being changed; none were taken on faith from the sweep file. ## Findings and what changed | # | PR | Site | Claim | Action | | --- | --- | --- | --- | --- | | 1 | #4455 | `daemon/backup.py` `_source_recoverability_proofs` | a full-snapshot append row is hashed as a byte window | fixed: falls back to the full prefix `[0, end)` when the window does not prove the blob | | 2 | #4457 | `operations/append_acquisition_replay.py` | unbounded `handle.readline()` during replay | fixed: bounded at 1 MiB, matching live acquisition | | 3 | #4506 | `sources/live/deferred_cursor.py` | semantic frontier re-derived from current bytes with no comparison to retained evidence | fixed: recomposed frontier must reproduce the recorded **body** digest | | 4 | #4506 | `sources/origin_specs.py` | ChatGPT derives `inheritance_branch_point` from `mapping.parent`/`mapping.children` | fixed: declared structurally absent | | 5 | #4515 | `sources/live/source_selection.py` | no typed-vs-generic tiebreak, so a typed source loses ownership to a nested generic root | fixed: ownership resolved among sources that accept the path | | 6 | #4539 | `sources/live/watcher.py` | tool-outcome semantics changed without a parser-fingerprint bump | fixed: `live-batched-v2` -> `live-batched-v3` | | 7 | #4549 | `sources/live/batch.py` | legacy promotion commits durably before append planning succeeds; resynthesized cursor never returned | fixed: promotion deferred behind a successful plan; cursor handed back to the caller | | 8 | #4549 | `sources/sqlite_snapshot.py` | `sqlite_sequence` excluded, so insert-then-delete on AUTOINCREMENT yields no digest change | fixed: AUTOINCREMENT state included | | 9 | #4549 | `sources/live/batch.py` | full-head Claude authority computed from the live file | fixed: live prefix must reproduce the retained blob digest | | 10 | #4554 | `parsers/base_support.py` -> write boundary | idless model turn yields `("model_output", None)` and the write rejects the whole session | fixed at the write boundary (see note) | | 11 | #4558 | `sources/origin_specs.py` | fingerprint memo keyed on `(path, mtime, size)` | fixed: keyed by content digest | None were refuted. Master moved while this work ran; `git diff` over all eleven files across that range is empty, so every cited line still described current code. ### Finding 1: live exposure remains unconfirmed The code-level defect is real and now covered by a test. Its **live** reachability is not established: every current production caller of `admit_raw_observation` (`revision_governance.py:825,3995,4126`) passes `prior_head=None`, which never reaches the append arm that writes the full-payload-with-tail-offsets shape. This fixes the defect without claiming it was reachable in production. ### Finding 6: schema-regime classification Classified as **none of the schema-regime classes** -- it is not a schema change. There is no DDL edit and no derived-tier version bump, so no `DerivedDeltaClass` declaration in `storage/sqlite/lifecycle.py` applies; that table is keyed on index-schema version pairs. It is a *parser-semantic* change, whose declared route is the fingerprint bump itself. `base_support.py` is already inside the origin-spec parser-semantic closure (verified: `_semantic_source_paths` for a parser resolves it), so the origin-scoped fingerprint recomputed on its own with #4539. The gap was only the live watcher's hand-written literal. Bumping it marks every existing live cursor as stale, and the watcher routes those sources back through parse on its next pass -- the production convergence route. Nothing forces a rebuild by hand. **Operational consequence:** the first daemon pass after this lands re-ingests every live-watched source once. That is the intended cost of the correction, but it is a real one. ### Finding 10: fixed at the write boundary, not the parser The sweep points at `base_support.py:633-635`. The parser genuinely cannot fix this: `attachment_from_meta` takes `message_id: str | None` and there is no identity to name when it is `None`. The stored message id exists only at the write boundary, which is where the producer is now supplied -- covering both the parser-declared and role-derived paths. The fallback completes missing provenance and never overwrites parser-supplied evidence. ### Findings 3 and 9 are one fix Both derived Claude authority from bytes on disk at planning time rather than from retained evidence, so a rewrite preserving the prefix length inherited the previous observation's authority. Finding 3 (deferred cursor) compares the recomposed frontier's body digest against the recorded one; finding 9 (full-head resynthesis) requires the live prefix to hash to the retained blob. The reconstructed-chain branch already proved its prefix byte by byte and is left alone. Finding 3's check is deliberately on the **body**, not the whole frontier token: `ClaudeSemanticFrontier` is "replaceable header plus stable body", and an equality check on the token broke `test_deferred_claude_cursor_rebases_frontier_after_header_rewrite`, which protects legitimate rebasing onto a rewritten header. ## Verification Anti-vacuity was verified mechanically, not asserted: with all ten source files reverted to master and the new tests kept, every new test fails. ``` git checkout <master> -- <the ten source files> devtools test tests/unit/sources/test_reviewed_acquisition_defects.py \ tests/unit/storage/test_attachment_idless_model_turn.py \ tests/unit/sources/test_live_deferred_append_dedup.py \ tests/unit/sources/test_live_append_cursor_resynthesis.py \ tests/unit/daemon/test_backup.py -n 2 -> 15 failed, 79 passed ``` The 15 are the 13 new tests plus the 2 existing expectations this change updates. `test_backup_still_proves_a_window_shaped_append_row` **passes** on master -- it is the control proving finding 1's fix did not over-generalize into "always read the full prefix". With the fixes restored, the same selection is green: ``` devtools test tests/unit/sources/test_reviewed_acquisition_defects.py -n 2 -> 5 passed devtools test tests/unit/sources/test_live_deferred_append_dedup.py -n 2 -> 8 passed devtools test tests/unit/sources/test_live_append_cursor_resynthesis.py -n 2 -> 13 passed devtools test tests/unit/daemon/test_backup.py \ tests/unit/storage/test_attachment_idless_model_turn.py -n 2 -> 68 passed devtools verify --quick -> all 12 gates ok devtools render all --check -> exit 0, no "out of sync" ``` Collateral selection over the consumers of the changed modules (live watcher, source snapshot, source differential, catchup planning, codex state, and the four attachment suites): ``` devtools test tests/unit/sources/test_live_watcher.py \ tests/unit/sources/test_source_snapshot.py \ tests/unit/sources/test_source_differential.py \ tests/unit/sources/test_live_catchup_planning.py \ tests/unit/sources/parsers/test_codex_state.py \ tests/unit/storage/test_attachment_acquisition.py \ tests/unit/storage/test_attachment_first_class_ids.py \ tests/unit/storage/test_source_attachments.py \ tests/unit/storage/test_attachment_relink.py -n 2 -> 1 failed, 218 passed ``` After the fixture fix below, the one affected file was re-run on its own: ``` devtools test tests/unit/sources/test_live_watcher.py -n 2 -> 125 passed ``` The other eight files were green in the combined run and are untouched by that fixture change; no combined re-run was made, so the "219" total is not claimed as an observed number. The single failure was `test_parser_fingerprint_change_triggers_reingest`, caused by this branch and not inherited. It simulated a fingerprint change by monkeypatching `_PARSER_FINGERPRINT` to the *literal* `"live-batched-v3"`, which finding 6 makes the real value -- so the patch became a no-op, no change was simulated, and no reingest fired. The bump is not miswired; the fixture collided with it. The sentinel now derives from the real constant (`f"{_PARSER_FINGERPRINT}-changed"`), so the test asserts the same behaviour and cannot silently no-op on a future bump. Finding 6's own test (`test_superseded_parser_fingerprint_refuses_append_ planning`) independently proves a `live-batched-v2` cursor refuses append planning, and went red when the constant was reverted. Selected scope only: this proves the selected files, not the corpus. ## Residual risk - **Finding 6 forces a one-time live re-ingest** of every watched source on the next daemon pass. - **Finding 8 changes `sqlite_logical_revision`** for every AUTOINCREMENT database, so previously recorded identities differ once and those sources re-acquire on next observation. Self-healing, but not free. - **Finding 5 changes ownership for overlapping default roots** beyond the reported case: a `.db` under `~/.codex/sessions/` now resolves to `codex-state` rather than `codex`, because only `codex-state` accepts it. That looks correct, but it is a behaviour change the finding did not name. - **Finding 7** delays promotion until planning succeeds, not until the plan is *applied*. Closing that gap needs a larger refactor of the ingest stage. - **Finding 11** reads parser sources instead of stat-ing them. A per-process digest cache keyed on full inode identity including `st_ctime_ns` (which `os.utime` cannot restore) keeps this correct and measurably faster than before: 0.818 ms/call warm vs 1.343 ms/call for the previous stat-keyed signature, over a 449-file / 9 MB closure. - Three tests are reported red on master itself (`test_archive_tiers_api_session_costs_read_index_tier`, `test_existing_same_version_ops_database_receives_additive_call_log`, `test_record_context_delivery_requires_initialized_user_tier`). None are in files this branch touches and none were in the selections run here. --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
The insight-status and readiness queries read blocks.tool_outcome, which #4539 made the canonical structural outcome. Their hand-built index fixtures predate it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
The insight-status and readiness queries read blocks.tool_outcome, which #4539 made the canonical structural outcome. Their hand-built index fixtures predate it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
The insight-status and readiness queries read blocks.tool_outcome, which #4539 made the canonical structural outcome. Their hand-built index fixtures predate it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
…ping, wire-receipt cost (#4591) ## Summary Five red classes from the 2026-09-03 corpus run, each its own commit. Two are product defects; three are fixtures pinned to shapes the runtime has moved past. ## Problem and solution, per class ### The relink route never derived attachment provenance (6 tests) `attachment_refs.direction` is `NOT NULL`, and only the main write route derived it from the owning turn. Blob-reference closure relinked attachments straight from the parsed record: ``` sqlite3.IntegrityError: NOT NULL constraint failed: attachment_refs.direction ``` The relink path now goes through the same shared derivation, reading the owning turn from the index when the append payload's own message map does not carry it — an append whose owning message is already materialized. Two of the six failed inside the main route instead, on a model-output attachment whose turn carried no provider id; `#4587` fixed that while this branch was open, and this commit builds on it. ### One session total on two model rows (1 test) `sessions.reported_cost_usd` is one exact dollar total for a session, written onto a single `session_model_usage` row. A merge-append that switched models left the superseded row holding the previous total, so every sum over the session counted it twice. The direction-refusal test alongside it named a user turn, whose direction the derivation supplies; only a role outside the user/model pair leaves the column underivable, so that is what it names now. ### Hand-built index fixtures without a tier version (12 tests) `#4485`'s open-time tier check refuses a database named for an archive tier whose `user_version` is 0: ``` SchemaSkewError: index schema skew: expected 85, found 0 ``` - The deployment-smoke browser-capture probe fixtures declare the version the read profile expects, read from the tier table. - The embed-backfill fixtures build the tier through the production bootstrap rather than touching a bare SQLite file. - The WAL/journal pragma probes name their scratch databases for what they are. They test the pragmas the connection factories apply; the tier check fired only because the files were called `index.db` and `ops.db`. ### Hand-built `blocks` tables without `tool_outcome` (6 tests) The insight-status and readiness queries read `blocks.tool_outcome`, the canonical structural outcome since `#4539`. Two fixtures predate it. ### A killed waiter left its pytest slot task queued (host defect) The waiter blocks on a task it queued through pueue, and the task outlives it. The slot's parallelism is one, so a task left with no waiter starves every other checkout on the host until someone reads the queue and kills it by hand -- which is what happened during this branch's own runs. The waiter now reaps the task it added when it is signalled or unwound: kill, then remove, then drop the launch file, which carries a resolved environment and must not survive either. ### Full-catalog wire receipts on single-provider assertions `build_wire_support_receipt` runs the synthetic corpus and the production parser for every catalogued package element. Profiled: 27 s per full-catalog call in a quiet process, and the file's heaviest tests measured 106-110 s of call time under `-n 2` -- inside a 120 s timeout with no margin, which is what the corpus run recorded as nine timeouts. `#4412` added two providers and the margin went. Tests that assert about one provider's entry, or that a receipt *changed*, now name the providers they read; three catalog-wide tests still build the whole catalog. Memoizing the schema-annotation parsing the profile flagged was tried and reverted: 26.5 s against 27.4 s, which does not buy an identity-keyed cache in production code. ### Reader assertions pointed at the wrong route The interpolated shell answers on `/w/` and the paste routes; the root and `/s/` serve the typed WebUI. Eight reads across the visual suites and `test_web_shell_reader.py` now fetch `/w/stack`. This also restores `test_reader_search_shell_dom_evidence`, which `#4579` deleted -- the shell it tests is still served, just not at the root, so repointing it was the right move and deleting it was not. ## Verification `devtools test <file> -n 2`: | file | before | after | | --- | --- | --- | | `tests/unit/storage/test_archive_tiers_write.py` | 2 failed | **107 passed** | | `tests/unit/maintenance/test_blob_reference_closure.py` | 6 failed | **13 passed** | | `tests/unit/cli/test_embed_activation.py` | 7 failed | **35 passed** | | `tests/unit/devtools/test_deployment_smoke.py` | 7 failed | **24 passed** | | `tests/unit/storage/test_wal_journal_size_limit.py` | 5 failed | **8 passed** | | `tests/unit/storage/test_session_insight_status_descriptors.py` | 5 failed | **13 passed** | | `tests/unit/core/test_insight_readiness.py` | 1 failed | **passed** | | `tests/unit/devtools/test_pytest_slot.py` | 7 passed | **8 passed** | | `tests/unit/storage/test_session_profile_model_usage_consistency.py` + `tests/unit/insights` | — | **730 passed** (cost regression check) | `devtools verify --quick` green at this head. The attachment and cost measurements above predate the rebase onto `#4587`, which rewrote `_attachment_provenance` under this commit; the storage suites are re-running against the merged shape. The slot-reaping test drives a real SIGTERM into a child waiter with a fake `pueue` on PATH. Anti-vacuity: dropping the `_reaping` context leaves the recorded calls at `add`/`wait`, the starvation shape itself. The visual and wire-receipt commits are still queued behind the host's pytest slot at the time of writing; they are committed, not yet measured. ## Residual risk The provider-scoped wire receipts trade catalog breadth for time in tests that assert about one provider. If a future provider's route breaks only in a receipt those tests build, three catalog-wide tests still catch it, one test later. `tests/unit/infra/test_pathology_zoo.py` was red in the corpus run and is green at this head with no change here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
The upward walk that resolves a session's repository stopped at nothing, so with the managed temp trees inside the checkout every scratch path resolved to the checkout itself. The walk now stops before a listed ceiling, as git does, and the ceiling is part of the normalization cache key. Tests: tool results without structural evidence are admitted as unknown with not_reported (#4539) and the writer refusal is exercised on a block with no evidence at all; block payloads carry tool_outcome (#4502); a provider-reported cost rolls up as "exact" (#4493); the v61 replace-table keeps the surviving canonical columns; the bulk-delete canaries and the naive-join survivor use TEMP objects on the opened connection so the schema manifest check at open no longer refuses them (#4472, #4594). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
…#5785) ## Summary This PR salvages ChatGPT fleet worker 12's Codex-debt batch (beads `polylogue-1tyq5.55`, `.56`, `.60`, `.62`; 72 findings) and turns it into verified changes. Five fixes land with regression tests that fail on master. The worker's sixth fix (a negative completion cache) was dropped, and its health-check fix was replaced with a stricter version. ## Problem - **55.05** `health_check()` raises `SchemaSkew` when a tier is on another version. The tier probe opened the file with schema admission but caught only `sqlite3.Error`, so the probe crashed instead of reporting an error check. - **55.10** `list_assertion_candidate_reviews(limit=10)` computed `total` with a second, unbounded review read. That read ran the per-candidate judgment lookup (N+1) across the whole candidate history. - **60.01** `--stream --limit N` followed continuations with no limit. The final page could therefore fetch rows past N, and the resulting `result_too_large` refusal was re-raised for continuations instead of narrowing the page. - **60.20** `raw-authority-frontier` printed the all-state `plan_count` as `obligations=`, including terminal `superseded` plans. - **62.01** Named `analyze postmortem|portfolio|cost-outlook` computed the inherited root format but rendered from the local `None` format, so they printed text when JSON was requested. ## Solution - `_archive_tier_readiness_check` keeps admission, passes `tier=`, and reports any `SchemaRefusalError` as an ERROR check. The worker's `validate_schema=False` version was replaced because it compared only `user_version`, so a derived tier with a stale identity at the right version was reported OK. `test_health_check_reports_derived_identity_skew` fails on the worker's version. - `_archive_list_assertion_candidate_reviews` returns `(page, count)` from one read transaction. The count comes from `count_assertion_claims`, which now accepts `target_ref` and `statuses=None`. The count includes expired claims, matching the review read model. - `_read_session_windows` sends the remaining bound with every continuation. An oversized resumed page halves in place, and later pages keep the narrowed bound, because `session.read` refuses a continuation that widens its window. - The plain frontier line says `plans=` (the neutral label the finding offered). - `analyze_verb` renders every branch from the effective format: the local format if given, otherwise the root format, normalized with `normalize_output_dialect`. An explicit local `--format` still wins. - **62.16 dropped.** The deleted-candidate case was already fixed on master in 8cb1133 (#5722): each successful answer, empty or not, removes the cached matches for the refreshed prefix. The worker added a cache of empty answers that offline completion would treat as authoritative. Nothing invalidated it except a later contradicting daemon answer or the 24h TTL, and an offline reader cannot tell whether the archive changed without opening it. The cold-cache message on a miss is displayed rather than inserted, and it is accurate. - Two stale tests in `test_archive_query.py` expected `_emit_stats` to exit 0 over a converging archive. #5700 made that outcome degraded with a nonzero exit, so the tests now expect that. They failed on master before this PR. ## Verification - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w12 --wait` → job 2374: `verify: PASSED exit=0` (head 331a204ddd, pre-rebase; the rebase onto 4501f13 touched none of these files). Earlier job 2368 failed on format and mypy in the worker's commit; commit 3561647 fixes both. - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w12 --wait -- tests/unit/api/test_archive_health_tier_skew.py tests/unit/api/test_assertion_candidate_review_count.py tests/unit/cli/test_analyze_named_projection_format.py tests/unit/cli/test_raw_authority_frontier_output.py tests/unit/cli/test_session_window_continuation_bounds.py tests/unit/cli/test_analyze_projections.py tests/unit/cli/test_archive_query.py tests/unit/cli/test_completion_daemon_boundary.py tests/unit/api/test_assertion_candidate_queue_health.py` → job 2405 at head 3561647: `devtools test: PASSED exit=0 diagnosis=pytest_passed`, 168 passed. - Anti-vacuity: the new tests were run on an origin/master checkout (job 2351). Every fix test failed there (11 failures, plus the 2 stale stats tests). The one exception is `test_named_analysis_local_format_overrides_inherited_json`, a precedence guard that should pass on both. Job 2355 ran the health tests against the worker's `validate_schema=False` variant, and the derived-identity case failed (status OK instead of ERROR). - Inherited, not addressed here: `tests/unit/api/test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits` and `::test_no_undiscovered_async_methods` fail identically on master 4501f13 (job 2401). ## Self-review - **Sibling sites.** The review count had one caller, and `judge.py` consumes the facade's `total`. The daemon health endpoint has its own tier checks and is out of scope. The other `validate_schema=False` opens are reset, paths and export tools, not health reporting. - **Cancellation and loops.** The window retry loop is bounded by halving to 1 and then re-raising. No new loop reads without a bound. - **Unbounded reads.** This PR removes one, the unbounded review read, and adds none. - **Fail-open fallbacks.** The health probe now reports refusals instead of hiding them. The dropped completion change would have turned a cache miss into an authoritative empty answer. - **Compatibility shims.** None. `count_assertion_claims` gained optional parameters, and its existing `annotations/join.py` callers are unchanged. - **Removed symbols.** No production symbol was removed. The `test_codex_debt_w12.py` files were renamed by behaviour. - **Production route.** The API tests go through `Polylogue.health_check` and `list_assertion_candidate_reviews` on bootstrapped archives. The CLI tests go through `cli` or the real command with a mocked transport (`dispatch_read`) and the real `lower_session_read`. ## Derived-identity closure `polylogue/storage/sqlite/archive_tiers/user_write.py` is a member of `docs/plans/schema-closure-baseline.json`, so this PR moves the candidate derived identity. Closure membership does not grow (the `schema-closure` gate passed). No other changed production file is a member. ## Per-finding dispositions Counts: 5 fixed, 60 fixed-already, 2 stale, 1 refuted, 4 not reached. The not-reached findings (55.18, 55.22, 60.12, 62.08) stay open on their beads. | key | disposition | evidence | test | | --- | --- | --- | --- | | 55.01 #4326 `polylogue/api/__init__.py:51` | refuted | `polylogue/api/parity.py:472–491`: The explicit context-pack exclusion includes topic_pack; composed builders do not own a separate operation identity under this contract. | — | | 55.02 #5381 `polylogue/api/archive.py:410` | fixed-already | `polylogue/api/archive.py::_read_session_transcript_page`: The normalized offset is used for both the read and returned page coordinates. | — | | 55.03 #4287 `polylogue/api/archive.py:818` | fixed-already | `polylogue/api/archive.py::_archive_list_summaries_with_post_filters`: Effective specification pagination is restored after content filtering. | — | | 55.04 #4295 `polylogue/api/archive.py:871` | fixed-already | `polylogue/api/archive.py::_archive_aggregate_facet_families / keyed`: Repeated facet bucket counts are added across chunks rather than overwritten. | — | | 55.05 #4871 `polylogue/api/archive.py:1114` | fixed | `_archive_tier_readiness_check` keeps admission and reports `SchemaRefusalError` as ERROR | `api/test_archive_health_tier_skew.py` | | 55.06 #4192 `polylogue/api/archive.py:1152` | fixed-already | `polylogue/api/archive.py::_archive_list_assertion_claims`: Uses _readable_user_tier rather than an index-backed query runner. | — | | 55.07 #4794 `polylogue/api/archive.py:1546` | fixed-already | `polylogue/storage/sqlite/connection_profile.py::_install_progress_handler`: Read frames install an expiry/cancellation-aware SQLite progress handler, including work using the bound connection. | — | | 55.08 #4552 `polylogue/api/archive.py:1691` | fixed-already | `polylogue/api/archive.py::_archive_list_assertion_candidates`: Calls the canonical actionable queue reader rather than the expiry-retaining review reader. | — | | 55.09 #4295 `polylogue/api/archive.py:3066` | fixed-already | `polylogue/api/archive.py::pathology_report`: replace(spec, limit=None, offset=0) removes query pagination from the scope denominator. | — | | 55.10 #4295 `polylogue/api/archive.py:3448` | fixed | one read transaction; scalar `count_assertion_claims` replaces the second unbounded review read | `api/test_assertion_candidate_review_count.py` | | 55.11 #4552 `polylogue/api/archive.py:3453` | fixed-already | `polylogue/api/archive.py::_readable_user_tier`: Missing/non-file and unreadable durable-tier failures retain typed unavailability rather than returning an empty list. | — | | 55.12 #4295 `polylogue/api/archive.py:3503` | fixed-already | `polylogue/cli/commands/judge.py::judge_command`: Preserves authoritative review totals; additional client-side time filtering reads the complete selection before recounting. | — | | 55.13 #5302 `polylogue/api/archive.py:4021` | fixed-already | `polylogue/operations/facade_writers.py::record_manual_continuation_product`: Invokes _resolve_session_graph before committing the manual link, refreshing topology projections. | — | | 55.14 #5302 `polylogue/api/archive.py:4021` | fixed-already | `polylogue/operations/facade_writers.py::record_manual_continuation_product`: Invokes the canonical cycle/quarantine pass instead of leaving the direct insert unchecked. | — | | 55.15 #4180 `polylogue/api/archive.py:5081` | fixed-already | `polylogue/api/archive.py::search_session_hits`: Passes unresolved spec.to_plan() to failure-classifying search_hits_for_plan. | — | | 55.16 #4180 `polylogue/api/archive.py:5512` | fixed-already | `polylogue/api/archive.py::filter`: Constructs SessionFilter without vector-provider initialization. | — | | 55.17 #5362 `polylogue/api/archive.py:5557` | fixed-already | `polylogue/api/archive.py::query_sessions`: Includes title_is_synthesized from display_label_source. | — | | 55.18 #5370 `polylogue/api/archive.py:5561` | not reached | `polylogue/api/archive.py::read_transcript_window`: Anchor lookup and transcript-window reading still have separate read lifetimes. Single-snapshot implementation remains necessary; no fix written. | — | | 55.19 #5370 `polylogue/api/archive.py:5563` | fixed-already | `polylogue/api/archive.py::read_transcript_window`: Explicitly rejects around combined with transcript filters. | — | | 55.20 #4357 `polylogue/api/archive.py:6330` | fixed-already | `polylogue/api/archive.py::get_effective_context`: Canonical ID resolution plus read_summary replaces full transcript hydration for the existence check. | — | | 55.21 #4261 `polylogue/api/insights.py:753` | fixed-already | `polylogue/api/insights.py::cost_outlook`: Restricts the cost query to the selected cycle's since/until rather than the whole archive. | — | | 55.22 #5007 `polylogue/api/insights.py:916` | not reached | `polylogue/api/insights.py::get_ancestors/get_descendants/get_siblings/get_thread/get_logical_session`: Exhaustive relationship helpers still consume the default topology page without exhaustion. No implementation written. | — | | 55.23 #5007 `polylogue/api/insights.py:927` | fixed-already | `polylogue/api/insights.py::_resolve_for_topology`: Uses canonical archive resolve_session_id, preserving native-ID resolution. | — | | 55.24 #4799 `polylogue/api/insights.py:1030` | fixed-already | `polylogue/api/insights.py::compact_lineage`: Both public page defaults use DEFAULT_LINEAGE_PAGE_LIMIT. | — | | 55.25 #4539 `polylogue/api/search_envelope_builder.py:138` | fixed-already | `polylogue/api/search_envelope_builder.py::build_search_envelope_for_spec; polylogue/operations/authority.py::authority_for_config`: The envelope delegates authority resolution to the owner that resolves the active archive root. | — | | 56.01 #4603 `polylogue/api/search_envelope_builder.py:148` | fixed-already | `polylogue/api/search_envelope_builder.py::build_search_envelope_for_spec`: Reports matched=total and analyzed=len(hits). | — | | 60.01 #5337 `polylogue/cli/archive_query.py:360` | fixed | continuations carry the remaining bound; resumed pages halve in place, never widen | `cli/test_session_window_continuation_bounds.py` | | 60.02 #4402 `polylogue/cli/archive_query.py:390` | fixed-already | `polylogue/surfaces/cursor_identity.py::search_cursor_request_identity`: Presentation-only parameters are excluded from cursor identity. | — | | 60.03 #4987 `polylogue/cli/archive_query.py:1913` | fixed-already | `polylogue/cli/render/rows.py::project_payload`: Outcome is preserved independently of selected result fields. | — | | 60.04 #5249 `polylogue/cli/click_app.py:479` | fixed-already | `polylogue/cli/query_contracts.py::QueryOutputSpec.from_params`: Explicit file destination and path retain typed FILE identity even for reserved-looking filenames. | — | | 60.05 #4337 `polylogue/cli/click_app.py:554` | fixed-already | `polylogue/cli/query_group.py::_asks_for_query_workflow_help`: The advertised find help route is handled while respecting option arity. | — | | 60.06 #4340 `polylogue/cli/click_app.py:628` | fixed-already | `polylogue/cli/click_app.py::main`: Runtime checks run inside guarded_entry passed to run_machine_entry. | — | | 60.07 #4651 `polylogue/cli/click_command_registration.py:192` | fixed-already | `polylogue/cli/commands/insights_alias.py`: The existing root group exposes only Fable, not the entire operational group. No alias is introduced by this batch. | — | | 60.08 #4580 `polylogue/cli/click_command_registration.py:192` | fixed-already | `polylogue/cli/commands/insights_alias.py`: The existing narrow route preserves the promised Fable-packet command. No alias is introduced by this batch. | — | | 60.09 #4550 `polylogue/cli/click_command_registration.py:192` | fixed-already | `polylogue/cli/commands/insights_alias.py::_register_fable_packet`: Registers only the intended Fable command rather than the entire operational group. | — | | 60.10 #4698 `polylogue/cli/commands/check.py:41` | fixed-already | `polylogue/scenarios/operational_surfaces.py`: Authored doctor scenarios use current routes without the retired repair flags. | — | | 60.11 #5349 `polylogue/cli/commands/diagnostics.py:992` | fixed-already | `polylogue/cli/commands/diagnostics.py::latency_command`: The empty-bucket branch still renders incomplete-drop accounting. | — | | 60.12 #5639 `polylogue/cli/commands/import_command.py:117` | not reached | `polylogue/cli/commands/import_command.py::_wait_for_demo_ingest`: Owner completion accounting improved, but a degraded receipt still causes immediate failure instead of waiting through the remaining convergence budget. No implementation written. | — | | 60.13 #5314 `polylogue/cli/commands/insights.py:147` | fixed-already | `polylogue/scenarios/insight_surfaces.py; tests/unit/cli/test_stdout_stderr_split.py`: Inventories use current rather than retired commands. | — | | 60.14 #4678 `polylogue/cli/commands/insights.py:224` | fixed-already | `polylogue/cli/commands/insights.py::_render_status_plain`: Plain output includes degraded counts and fallback reasons. | — | | 60.15 #4292 `polylogue/cli/commands/insights.py:450` | fixed-already | `polylogue/cli/commands/insights.py::_packet_json_document`: Dataclass tuples are lowered to JSON-native arrays. | — | | 60.16 #5311 `polylogue/cli/commands/judge.py:417` | fixed-already | `polylogue/cli/commands/judge.py::judge_command`: Interactive approval forwards the evidence digest and checks failed counts before printing success. | — | | 60.17 #4133 `polylogue/cli/commands/maintenance/_blob_gc.py:81` | fixed-already | `polylogue/cli/commands/maintenance/_blob_gc.py::blob_gc_command`: Blocked previews set ok=false and exit nonzero in both formats. | — | | 60.18 #4955 `polylogue/cli/commands/maintenance/_blob_gc.py:211` | stale | `polylogue/cli/commands/maintenance/_blob_gc.py`: gc_recover_command is gone; the remaining command is preview-only. | — | | 60.19 #5345 `polylogue/cli/commands/maintenance/_blob_integrity.py:52` | stale | `polylogue/cli/commands/maintenance/_blob_integrity.py`: _submit_replace_from_source and its cited relative-output forwarding route are gone. | — | | 60.20 #5350 `polylogue/cli/commands/maintenance/_raw_identity.py:47` | fixed | plain line labels the all-state count `plans=` | `cli/test_raw_authority_frontier_output.py` | | 60.21 #5301 `polylogue/cli/commands/maintenance/_raw_identity.py:59` | fixed-already | `polylogue/cli/commands/maintenance/_raw_identity.py::raw_authority_blockers_command`: Paginated public blocker inspection exposes expected/observed evidence. | — | | 60.22 #4955 `polylogue/cli/commands/maintenance/_raw_identity.py:247` | fixed-already | `polylogue/cli/commands/maintenance/_raw_identity.py::raw_authority_blocker_resolve_command`: Checks the affected count rather than presenting no-op resolution as an applied mutation. | — | | 60.23 #4824 `polylogue/cli/commands/maintenance/_verify_archive.py:85` | fixed-already | `polylogue/cli/commands/maintenance/_verify_archive.py::verify_archive_command`: Source-frontier construction is conditional on selected source-conservation work. | — | | 60.24 #5491 `polylogue/cli/commands/paths.py:75` | fixed-already | `polylogue/cli/commands/paths.py::_raw_materialization_readiness`: Propagates the selected index path through archive_debt_list(index_db_path=...). | — | | 60.25 #5353 `polylogue/cli/commands/status.py:342` | fixed-already | `polylogue/operations/daemon_status.py::produce_operation_status`: Merges runtime collection metadata into pinned readiness components. | — | | 62.01 #5422 `polylogue/cli/query_verbs.py:2434` | fixed | `analyze_verb` renders from the effective (normalized, inherited) format | `cli/test_analyze_named_projection_format.py` | | 62.02 #5007 `polylogue/cli/read_views/lineage.py:78` | fixed-already | `polylogue/cli/read_views/lineage.py`: The replacement operation-backed route uses the resolved target; the old _run path is gone. | — | | 62.03 #5407 `polylogue/cli/read_views/messages.py:226` | fixed-already | `polylogue/cli/read_views/messages.py::_write_messages_file`: Resolves symlink output before choosing the staging sibling. | — | | 62.04 #5407 `polylogue/cli/read_views/messages.py:227` | fixed-already | `polylogue/cli/read_views/messages.py::_write_messages_file`: Flushes and fsyncs the staged descriptor before replacement and synchronizes the directory. | — | | 62.05 #4291 `polylogue/cli/read_views/query_set.py:196` | fixed-already | `polylogue/cli/read_views/correlation.py::run_read_correlation`: Renders a string and delivers it through deliver_content instead of an uncaptured console-only renderer. | — | | 62.06 #5374 `polylogue/cli/read_views/session_evidence.py:180` | fixed-already | `polylogue/cli/read_views/session_evidence.py::_read_evidence_window`: Projection body coordinates take precedence before operation lowering. | — | | 62.07 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already | `polylogue/cli/query_output.py::deliver_query_output`: File delivery retains secret-candidate scanning. | — | | 62.08 #5520 `polylogue/cli/read_views/standard.py:99` | not reached | `polylogue/cli/read_views/standard.py::run_read_summary_or_transcript; polylogue/cli/archive_query.py::_read_session_windows`: The standard file path still accumulates the transcript and buffers its rendered document. End-to-end operation-backed streaming is not implemented. | — | | 62.09 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already | `polylogue/cli/read_views/standard.py::run_read_summary_or_transcript`: Forwards a typed FILE QueryDeliveryTarget, preserving reserved-looking filenames. | — | | 62.10 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already | `polylogue/operations/daemon_reads.py::_session_identity_projection; polylogue/cli/archive_query.py::_session_message_text`: The operation preserves tool_input; rendering includes structured tool input and omits reasoning blocks. | — | | 62.11 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already | `polylogue/cli/archive_query.py::_read_session_windows`: Initial oversized pages already halve their bound at the inspected base. This batch additionally fixes resumed-page narrowing under 60.01. | — | | 62.12 #5266 `polylogue/cli/session_rows.py:141` | fixed-already | `polylogue/cli/session_rows.py::_query_page_with_authority`: Synthetic missing-session selections explicitly include next_offset=None. | — | | 62.13 #5426 `polylogue/cli/shared/machine_errors.py:233` | fixed-already | `polylogue/cli/shared/machine_errors.py::error_archive_writer_ownership`: Undecidable ownership has a separate remedy that does not assert an observed resident daemon. | — | | 62.14 #5426 `polylogue/cli/shared/machine_errors.py:285` | fixed-already | `polylogue/cli/shared/machine_errors.py::extract_command`: Recognizes --output-format as a value-bearing option. | — | | 62.15 #5545 `polylogue/cli/shell_completion_values.py:117` | fixed-already | `polylogue/cli/shell_completion_values.py::_cached_value_matches`: Session IDs match native-ID and title substrings. | — | | 62.16 #5545 `polylogue/cli/shell_completion_values.py:135` | fixed-already | deleted-candidate case fixed by 8cb1133 (#5722): every successful answer prunes the refreshed prefix; negative-answer cache declined (see Solution) | — | | 62.17 #5545 `polylogue/cli/shell_completion_values.py:145` | fixed-already | `polylogue/cli/shell_completion_values.py::_remember_completion_values`: A per-archive map retains more than the most recent archive. | — | | 62.18 #5545 `polylogue/cli/shell_completion_values.py:157` | fixed-already | `polylogue/cli/shell_completion_values.py::_remember_completion_values`: Removes an existing value before reinsertion at the retention tail. | — | | 62.19 #5545 `polylogue/cli/shell_completion_values.py:178` | fixed-already | `polylogue/cli/shell_completion_values.py::_remember_completion_values`: Global serialized-byte eviction precedes publication. This batch includes new empty observations in that accounting. | — | | 62.20 #5545 `polylogue/cli/shell_completion_values.py:181` | fixed-already | `polylogue/cli/shell_completion_values.py::_remember_completion_values`: flock serializes the full cache read-modify-write sequence. | — | | 62.21 #5382 `polylogue/cli/write_authority.py:104` | fixed-already | `polylogue/storage/sqlite/write_lease.py::arm_write_lease_enforcement`: Locked process-wide user/suppressor counts make arming overlap-safe. | — | ## Residuals - The four not-reached findings remain open. - Changing `user_write.py` moves the derived identity, so this PR has to land before a rebuild starts. - The two `test_facade_contracts.py` failures are inherited from master. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
## Summary This lands the worker-13 batch on current master. The batch covers beads polylogue-1tyq5.77, .110, .63, .53, .54 and .88. I checked each of the worker's 24 proposed fixes against master and kept 22. CTX-07 was dropped because #5778 already fixed it, and SURF-03 was dropped after master merged #5793, which fixes it the same way. Of the 74 findings, 22 are fixed here, 39 were already fixed on master, and 13 were not reached. ## Problem All 22 kept defects still reproduce on master (re-checked after merging master at 1beb2e5): - MCP search resumed from a continuation alone reported `query: ""` and lost `sort`. It also sent the default limit, which the continuation guard refuses as widening. - Personal-state pages that exceeded the response budget came back with no continuation. - Reference pipelines, list read views and completions ignored `offset`. - `read(view="messages")` for a missing session returned `internal_error`. - Discovery did not advertise the `messages` view, the `precompact` intent, the `clear_corrections` confirmation or the single-candidate evidence digest. - Compaction had three defects: - it invented a text-only hash when the archive gave none; - `pack_ref` hashed only the kept anchor refs; - the Markdown rendering showed only the aggregate drop counts. - Read overrides used `bool("false")`, so `"false"` meant true. JSON-only views also defaulted to Markdown. - Windows working-directory paths were not shortened on POSIX hosts. - Envelopes built from domain sessions had no relative time. - Orchestration `children` could point at nodes removed by topology truncation. - Excision had three defects: - marker tombstones used an `excision-marker:` ref, which fails ObjectRef validation; - excising a watch baseline left its watch enabled; - `INSERT OR IGNORE` hid ledger CHECK failures, and the content was deleted anyway. ## Solution The worker's commit is cherry-picked, with these corrections: - The compaction identity is moved into #5758's fixed-point budget loop. A fixed-width placeholder means filling in `pack_ref` does not change the measured size. - `message_transcript_window` already raises the typed `SessionNotFoundError` on master (#5728), so `read(view="messages")` maps it to `not_found`. The now-dead string-matching translation in `get_messages_paginated` is removed. - The query-excision ledger keeps only `ON CONFLICT(ledger_id) DO NOTHING`. The schema CHECKs already refuse bad rows, so the worker's extra checks before and after the insert are removed. - Repo basenames now split on both path separators, the same as working directories. - A list view's outcome now counts the whole collection, not only the returned page. - After #5793 made orchestration children a streamed section, the truncation filter narrows `children.rows`, and its test uses the new builder signature. - The worker's tests are corrected: - the relative-time and tombstone tests could not pass as written and are fixed; - the test file is renamed; - tests that only checked prose are narrowed. ## Verification After merging master at 1beb2e5 (merge commit 88afebc): - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w13` (job 2474): `verify: PASSED exit=0 ... head=88afebc6e16e`. - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w13 -- tests/unit/mcp/test_capability_pointer_routes.py tests/unit/mcp/test_privileged_tools.py tests/unit/mcp/test_session_orchestration.py tests/unit/mcp/test_session_projection_table.py tests/unit/mcp/test_tool_discovery_contracts.py tests/unit/security/test_excision.py tests/unit/security/test_query_excision_scope.py tests/unit/surfaces/test_compaction.py tests/unit/surfaces/test_read_contract.py tests/unit/surfaces/test_session_envelope_derivation.py tests/unit/operations/test_read_view_compact.py tests/unit/agent_integration` (job 2475): after the isolated rerun, `1 failed, 7 passed`. The one failure, `test_published_examples_use_live_operation_vocabularies_and_preconditions`, fails the same way on origin/master 1beb2e5 (job 2530: `1 failed`). Before the merge, on 967e01e: - verify_quick (job 2071) passed; pytest_focused (job 2070) had 4 failures that also failed on the base (job 2056). - Anti-vacuity (job 2028): with every production file in this PR reverted to the base and the new tests kept, `36 failed`. Every new test case failed without its fix. The merge changes only the orchestration filter's target (`children.rows`), and that test still checks the same condition. ## Self-review - **Sibling sites:** the repo basename had the same separator bug as the working directory and is fixed too. The MCP `not_found` relies on the typed error master's transcript-window owner now raises (#5728). The `get` list projections are still unpaged, but no finding covers them. - **Cancellation and loops:** no new loops. In the compaction loop, only the identity assigned at return changes. - **Unbounded reads:** list views, reference members and completions now page. The facade calls behind them still load whole lists (see Residuals). - **Fail-open:** boolean overrides with an unknown spelling are refused, and a ledger CHECK failure now raises before any deletion. - **Compatibility shims:** none added. The `ValueError` string-match translation is removed. - **Removed symbols:** `_PERSONAL_STATE_PROJECTIONS` moved to `query_contracts.PERSONAL_STATE_PROJECTIONS`, with every reference updated. `session_list_projection_names` is still used elsewhere. - **Production route:** the MCP tests call the registered tools, and the excision and compaction tests call the real functions. ## Findings | key | disposition | evidence | test | |---|---|---|---| | MCP-01 / #4580:polylogue/mcp/archive_support.py:436 | fixed-already | polylogue/mcp/archive_support.py:439-483 | — | | MCP-02 / #4353:polylogue/mcp/declarations/registry.py:178 | fixed-already | polylogue/mcp/declarations/registry.py:208-233 | — | | MCP-03 / #4698:polylogue/mcp/declarations/registry.py:236 | fixed-already | polylogue/mcp/declarations/registry.py:270-285; polylogue/agent_integration/spec.py:683-710 | — | | MCP-04 / #4786:polylogue/mcp/query_contracts.py:154 | fixed-already | polylogue/mcp/server_cutover.py:325-391 | — | | MCP-05 / #5480:polylogue/mcp/server_cutover.py:87 | fixed-already | polylogue/mcp/server_cutover.py:90-92 | — | | MCP-06 / #5480:polylogue/mcp/server_cutover.py:95 | fixed-already | polylogue/mcp/server_cutover.py:100-108 | — | | MCP-07 / #4996:polylogue/mcp/server_cutover.py:326 | fixed | this PR | `tests/unit/mcp/test_privileged_tools.py::test_search_continuation_preserves_query_sort_and_omitted_limit` | | MCP-08 / #4410:polylogue/mcp/server_cutover.py:583 | not reached | polylogue/mcp/server_cutover.py:839-979 | — | | MCP-09 / #4295:polylogue/mcp/server_cutover.py:770 | fixed | this PR | `tests/unit/mcp/test_tool_discovery_contracts.py::test_personal_state_byte_budget_continuation_advances_from_nonzero_offset` | | MCP-10 / #4777:polylogue/mcp/server_cutover.py:830 | fixed | this PR | `tests/unit/mcp/test_privileged_tools.py::test_reference_relation_query_advances_requested_offset` | | MCP-11 / #4297:polylogue/mcp/server_cutover.py:856 | not reached | polylogue/mcp/server_cutover.py:1402-1404 | — | | MCP-12 / #4424:polylogue/mcp/server_cutover.py:879 | fixed | this PR | `tests/unit/mcp/test_capability_pointer_routes.py::test_capability_discovery_includes_messages` | | MCP-13 / #4424:polylogue/mcp/server_cutover.py:885 | fixed-already | polylogue/mcp/server_cutover.py:1317-1390 | — | | MCP-14 / #4424:polylogue/mcp/server_cutover.py:885 | fixed | this PR | `tests/unit/mcp/test_privileged_tools.py::test_missing_messages_session_is_not_found` | | MCP-15 / #4190:polylogue/mcp/server_cutover.py:926 | fixed-already | polylogue/agent_integration/spec.py:453-475 | — | | MCP-16 / #4190:polylogue/mcp/server_cutover.py:959 | not reached | polylogue/mcp/server_cutover.py:1585 | — | | MCP-17 / #4190:polylogue/mcp/server_cutover.py:959 | not reached | polylogue/mcp/server_cutover.py:1585 | — | | MCP-18 / #4256:polylogue/mcp/server_cutover.py:1035 | fixed | this PR | `tests/unit/mcp/test_tool_discovery_contracts.py::test_precompact_is_in_the_published_context_contract` | | MCP-19 / #4256:polylogue/mcp/server_cutover.py:1036 | fixed-already | polylogue/mcp/server_cutover.py:1680; polylogue/mcp/server_cutover.py:1007 | — | | MCP-20 / #4419:polylogue/mcp/server_cutover.py:1119 | not reached | polylogue/mcp/server_cutover.py:1702-1711 | — | | MCP-21 / #4362:polylogue/mcp/server_cutover.py:1251 | not reached | polylogue/mcp/server_cutover.py:1830-1867; polylogue/config.py:79-175 | — | | MCP-22 / #5248:polylogue/mcp/server_cutover.py:1273 | fixed | this PR | `tests/unit/mcp/test_session_projection_table.py::test_read_list_views_honor_limit_offset_and_next_page` | | MCP-23 / #5355:polylogue/mcp/server_cutover.py:1467 | fixed | this PR | `tests/unit/mcp/test_capability_pointer_routes.py::test_completions_page_against_shared_owner` | | MCP-24 / #4213:polylogue/mcp/server_cutover.py:2219 | fixed | this PR | `tests/unit/mcp/test_tool_discovery_contracts.py::test_clear_corrections_confirmation_is_discoverable_and_enforced` | | MCP-25 / #5311:polylogue/mcp/server_cutover.py:2811 | fixed | this PR | `tests/unit/mcp/test_privileged_tools.py::TestJudgeTool::test_single_candidate_shorthand_builds_a_one_item_bulk_call` | | SURF-01 / #4539:polylogue/surfaces/authority.py:65 | not reached | polylogue/surfaces/authority.py:65; polylogue/mcp/server_cutover.py:1382-1385 | — | | SURF-02 / #4197:polylogue/surfaces/compaction.py:150 | fixed | this PR | `tests/unit/surfaces/test_compaction.py::test_compaction_does_not_invent_canonical_content_hashes` | | SURF-03 / #4197:polylogue/surfaces/compaction.py:223 | fixed-already | #5793 (d1abc18): polylogue/surfaces/compaction.py:273-275; covered by tests/unit/operations/test_read_view_compact.py | — | | SURF-04 / #4197:polylogue/surfaces/compaction.py:263 | not reached | polylogue/surfaces/compaction.py:271-331 | — | | SURF-05 / #4197:polylogue/surfaces/compaction.py:276 | not reached | polylogue/surfaces/compaction.py:276-299 | — | | SURF-06 / #4197:polylogue/surfaces/compaction.py:292 | fixed | this PR | `tests/unit/surfaces/test_compaction.py::test_compaction_identity_commits_to_content_projection_and_provenance` | | SURF-07 / #4197:polylogue/surfaces/compaction.py:331 | fixed | this PR | `tests/unit/surfaces/test_compaction.py::test_compaction_markdown_preserves_fidelity_manifest_and_omission_anchors` | | SURF-08 / #4201:polylogue/surfaces/payloads.py:1064 | not reached | polylogue/surfaces/payloads.py:1172-1176 | — | | SURF-09 / #4201:polylogue/surfaces/payloads.py:1196 | fixed | this PR | `tests/unit/surfaces/test_session_envelope_derivation.py::test_domain_session_rows_keep_relative_time` | | SURF-10 / #4539:polylogue/surfaces/payloads.py:3947 | fixed-already | polylogue/daemon/http.py:4805-4807 | — | | SURF-11 / #4201:polylogue/surfaces/query_rows.py:106 | fixed | this PR | `tests/unit/surfaces/test_session_envelope_derivation.py::test_session_row_shortens_windows_and_posix_working_directories` | | SURF-12 / #4321:polylogue/surfaces/read_contract.py:65 | fixed | this PR | `tests/unit/surfaces/test_read_contract.py::test_read_boolean_false_overrides_are_not_truthy_strings` | | SURF-13 / #5515:polylogue/surfaces/read_contract.py:78 | fixed | this PR | `tests/unit/surfaces/test_read_contract.py::test_read_github_correlation_false_stays_disabled` | | SURF-14 / #4321:polylogue/surfaces/read_contract.py:100 | fixed | this PR | `tests/unit/surfaces/test_read_contract.py::test_default_read_formats_belong_to_their_profile` | | SURF-15 / #4321:polylogue/surfaces/read_contract.py:156 | not reached | polylogue/surfaces/read_contract.py:100-117; polylogue/surfaces/read_contract.py:159-170 | — | | CTX-01 / #4329:polylogue/context/compiler.py:263 | fixed-already | polylogue/context/compiler.py:265-284 | — | | CTX-02 / #4329:polylogue/context/compiler.py:272 | fixed-already | polylogue/context/compiler.py:292-295 | — | | CTX-03 / #4385:polylogue/context/configuration_evidence.py:84 | fixed-already | polylogue/context/configuration_evidence.py:94-96 | — | | CTX-04 / #4385:polylogue/context/configuration_evidence.py:132 | fixed-already | polylogue/context/configuration_evidence.py:137 | — | | CTX-05 / #4385:polylogue/context/configuration_evidence.py:141 | fixed-already | polylogue/context/configuration_evidence.py:144-176 | — | | CTX-06 / #4385:polylogue/context/configuration_evidence.py:159 | fixed-already | polylogue/context/configuration_evidence.py:171 | — | | CTX-07 / #4385:polylogue/context/configuration_evidence.py:180 | fixed-already | #5778 (3e9ec3d): declared-name mapping with own-name fallback; worker change dropped | — | | CTX-08 / #4385:polylogue/context/configuration_evidence.py:204 | fixed-already | polylogue/context/configuration_evidence.py:216-266 | — | | CTX-09 / #4385:polylogue/context/configuration_evidence.py:234 | fixed-already | polylogue/context/configuration_evidence.py:248-261 | — | | CTX-10 / #4256:polylogue/context/preamble.py:80 | fixed-already | polylogue/context/preamble.py:74-87; polylogue/api/archive.py:3429-3441 | — | | CTX-11 / #4634:polylogue/context/preamble.py:83 | fixed-already | polylogue/operations/facade_writers.py:415-427 | — | | CTX-12 / #4799:polylogue/context/preamble.py:371 | fixed-already | polylogue/context/preamble.py:588-601 | — | | CTX-13 / #4256:polylogue/context/scheduler.py:240 | fixed-already | polylogue/context/scheduler.py:349 | — | | CTX-14 / #4256:polylogue/context/scheduler.py:289 | fixed-already | polylogue/context/scheduler.py:425-437 | — | | AGENT-01 / #4266:polylogue/agent_integration/data/tool-contracts.json:132 | fixed-already | polylogue/agent_integration/spec.py:378-392 | — | | AGENT-02 / #4266:polylogue/agent_integration/data/tool-contracts.json:189 | fixed-already | polylogue/agent_integration/spec.py:416-421 | — | | AGENT-03 / #4266:polylogue/agent_integration/data/tool-contracts.json:288 | fixed-already | polylogue/agent_integration/spec.py:453-475 | — | | AGENT-04 / #4266:polylogue/agent_integration/data/tool-contracts.json:382 | fixed-already | polylogue/agent_integration/spec.py:511-516 | — | | AGENT-05 / #4266:polylogue/agent_integration/data/tool-contracts.json:502 | fixed-already | polylogue/agent_integration/data/tool-contracts.json | — | | AGENT-06 / #4266:polylogue/agent_integration/data/tool-contracts.json:631 | fixed-already | polylogue/agent_integration/spec.py:663-675 | — | | AGENT-07 / #5449:polylogue/agent_integration/spec.py:411 | fixed-already | polylogue/agent_integration/spec.py:410 | — | | AGENT-08 / #5449:polylogue/agent_integration/spec.py:411 | fixed-already | polylogue/agent_integration/spec.py:410 | — | | ANALYSIS-01 / #5314:polylogue/analysis/archive_models.py:109 | fixed-already | polylogue/analysis/archive_models.py:12 | — | | ANALYSIS-02 / #5608:polylogue/analysis/delegation_work_evidence_materializer.py:48 | fixed-already | polylogue/analysis/delegation_work_evidence_materializer.py:79-90 | — | | ANALYSIS-03 / #5608:polylogue/analysis/delegation_work_evidence_materializer.py:106 | fixed-already | polylogue/analysis/delegation_work_evidence_materializer.py:97-114 | — | | ANALYSIS-04 / #4678:polylogue/analysis/export_bundles.py:77 | fixed-already | polylogue/analysis/export_bundles.py:28 | — | | ANALYSIS-05 / #4864:polylogue/analysis/orchestration_evidence.py:362 | fixed | this PR | `tests/unit/mcp/test_session_orchestration.py::test_truncated_orchestration_children_belong_to_retained_topology` | | ANALYSIS-06 / #4985:polylogue/analysis/pathology.py:192 | fixed-already | polylogue/analysis/pathology.py:51 | — | | ANALYSIS-07 / #4678:polylogue/analysis/readiness.py:45 | fixed-already | polylogue/analysis/readiness.py:43 | — | | SEC-01 / #4320:polylogue/security/excision.py:574 | not reached | polylogue/security/excision.py:1091-1092; polylogue/security/excision.py:1382-1426 | — | | SEC-02 / #5452:polylogue/security/excision.py:1281 | fixed | this PR | `tests/unit/security/test_excision.py::TestApplySessionExcision::test_apply_tombstones_marker_assertions_without_retaining_content` | | SEC-03 / #4200:polylogue/security/query_excision.py:170 | fixed | this PR | `tests/unit/security/test_query_excision_scope.py::test_relation_excision_disables_only_watches_whose_baseline_was_removed` | | SEC-04 / #4200:polylogue/security/query_excision.py:176 | not reached | polylogue/security/query_excision.py:227-235 | — | | SEC-05 / #4200:polylogue/security/query_excision.py:176 | fixed | this PR | `tests/unit/security/test_query_excision_scope.py::test_a_refused_tombstone_aborts_before_any_deletion` | ## Derived-identity closure `devtools schema closure` (scratch job 1963) reports three changed files inside the closure: - `polylogue/security/query_excision.py` - `polylogue/surfaces/payloads.py` - `polylogue/surfaces/query_rows.py` All other changed production files are outside it. Land this before the next rebuild starts. ## Residuals - 13 findings were not reached: MCP-08, 11, 16, 17, 20, 21; SURF-01, 04, 05, 08, 15; SEC-01, 04. - Compaction `pack_ref` values change. - The facade list methods behind the paged MCP views still load the full list before slicing it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 749f608):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 8e6234c):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Centralize archive authority metadata in the typed surface envelope and carry it through query, search, and message responses for CLI, MCP, Python, and daemon HTTP routes. Normalize explicit tool-result exit codes as structural outcomes.
Problem
Surface adapters omitted or independently assembled run authority, archive identity, generation, schema, and degraded state. Provider-shaped results carrying an exit code without
is_errorremained unknown.Solution
The shared authority builder snapshots archive identity and schema versions once, marks direct execution as degraded when the daemon is unavailable, and is reused by the affected adapters. Parsed tool-result validation derives
is_errorfrom an explicit integer exit code and retains an unknown reason only when no structural outcome exists. Generated schemas were refreshed.Verification
devtools test tests/unit/sources/test_tool_result_structural_outcome.py tests/unit/mcp/test_server_surfaces.py: 16 passed.devtools test tests/unit/sources tests/unit/storage tests/unit/archive -k 'tool_result or outcome_unknown or result_state': 57 passed, 1 inherited fast-forward fixture failure (schema_identitymissing).devtools render all --check: initial run identified the two expected generated artifacts; regenerated artifacts are included.devtools verify --quick: rerun after formatting.Residual risk
The listed daemon web-reader suite has inherited failures, and plain verification may refuse if no compatible testmon graph is available. The broad tool-result census remains a verification obligation outside synthetic unit coverage.
Receipt: harvest-99f41a26ea7ff2d9626448a931151543