Repository navigation
fix: Codex P2 review debt: polylogue/cli part 1 (25 findings) - #5722
Conversation
…lylogue-20260928-071920-228a6f5a/integration
…lylogue-20260928-071920-228a6f5a/integration
…lylogue-20260928-071920-228a6f5a/integration
…5.77' into batch/polylogue-20260928-071920-228a6f5a/integration
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1aacd09576
ℹ️ 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".
Resolves 55 mypy errors, two pattern-gate violations, and stale generated-docs sync introduced by this batch's own worker commits, all confirmed via git log against the pre-batch base. Fixes are real type-correctness corrections (proper NewType/enum construction, narrowed unions, explicit casts at test boundaries) matching existing idioms; no blanket type: ignore. Also merges origin/master (one commit, clean auto-merge, no verify.py overlap) to keep the branch current. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8f71c24e8
ℹ️ 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".
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg # Conflicts: # devtools/patterns/baselines/legacy-prose-logging.txt # devtools/patterns/baselines/replace-without-parent-fsync.txt # devtools/patterns/baselines/sqlite-error-default.txt # devtools/verify_patterns.py # tests/unit/devtools/test_verify_patterns.py
#5729 moved one sqlite handler in production_baseline.py and added the retryable read-fault handler in live/batch.py. Both are classified by retryable_read_fault on purpose, so the layering baseline is re-anchored to them. #5722 removed the query_verbs.py site the cli-nonzero-click-exit pattern baseline still named, so that stale anchor is pruned. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
## Summary Realigns the master tests whose failures are stale tests rather than code defects: 16 test ids, 12 from the coordinator's list plus the pinned read-only store test. Each one asserted a contract that a later PR changed on purpose. The fixes below are grouped by the PR that broke them. ## Problem and fix, by breaking PR | Breaking PR | Tests | Why they fail | Fix | | --- | --- | --- | --- | | #5564 (0723a95) | `test_pinned_read_only_store_blocks_all_archive_tier_mutations`, `test_convergence_one_shot_readers_cannot_mutate` | The read profile's authorizer rejects writes at prepare time with `DatabaseError: not authorized`, before SQLite's own `OperationalError: readonly` is reached. | Expect `sqlite3.DatabaseError` matching `not authorized\|readonly`. The existing checks that nothing changed stay. | | #5550 (da5346d) | Seven `test_store_ops` tag tests | Facade writes now belong to the daemon: `add_tag` and `remove_tag` raise `FacadeDaemonRequiredError` when no daemon is running. | The three parametrized tests run the resident writer on the archive's own socket, through a new `tests/infra/daemon_operations.daemon_serving_archive`; the MCP helper now reuses it. The Hypothesis tag law calls `ArchiveStore.add_user_tags`, the primitive the daemon's actuator applies. It clears `open_connection`'s per-path cache between examples, because otherwise each new example archive keeps about 11 descriptors and trips the fd-leak guard. | | #5700 (f2562c3) | `test_daemon_required_envelope_preserves_resolved_archive_root` | #5700 made a daemon-absent machine refusal exit with `FAILED_READ_EXIT_CODE` (1). The test, added in #5722, asserted 2. | Assert `FAILED_READ_EXIT_CODE`. | | #5727 (ee567d0) | `test_recent_attempts_report_the_file_count_not_the_session_count` | Read-only opens now check derived schema identity, so a hand-built `ops.db` is refused and the probe returns no attempts. | Seed a real ops tier with `initialize_archive_database` and a valid status. | | #5727 | `test_compare_reports_archive_derived_readiness_deltas` | `compare` is now not ok when either side's convergence-debt ledger is unavailable, and a missing `ops.db` counts as unavailable. | Initialize `ops.db`. | | #5727 | `test_unavailable_debt_is_rendered_unknown_and_cli_fails_closed` | The test was added in #5727 and never passed: `"0 failed" not in output` also matched the attempt-count line (`0 running, 0 failed`), which has existed since #4010. | Check only the convergence-debt line. | | #5551 (aa19052) | `test_daemon_workload_probe_does_not_claim_derived_ready_on_schema_mismatch` | Under the fresh format every tier starts at `user_version = 1`, so writing 1 no longer produces a mismatch. | Set `user_version = 2`. | Not in this PR: - `test_raw_existence_journal_is_declared_as_content_free_bookkeeping` was a real duplicate declaration and is fixed in #5767. - polylogue-njwky (sqlite-vec on async attaches) was confirmed real and is fixed in #5765. ## Verification - `devtools test tests/unit/security/test_excision_carrier_reach.py tests/unit/security/test_excision.py tests/unit/storage/test_archive_tiers_archive.py tests/unit/daemon/test_maintenance_read_profiles.py tests/unit/cli/test_machine_main.py tests/unit/sources/test_refused_state_is_reported.py tests/unit/operations/test_daemon_workload_probe.py tests/unit/storage/test_store_ops.py tests/unit/mcp/test_mcp_writer_boundary.py`: `PASSED exit=0` (run with #5767's change applied) 🤖 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]>
polylogue-2mw8c. - Work events: a retained agent-work-event raw is written event-only. write_parsed_session_to_archive recognizes the raw identity, keeps every stored session-owned header column, skips identity claims, active-leaf moves and header side tables, and appends instead of replacing, so live appends and replay of already-retained events keep the reconstructed session. The live producer no longer copies the header itself. - Continuations: a narrower limit keeps the token's offset and selection. - Configuration evidence: an unmapped invocation matches by its own name; history follows each commit's historical path across renames and never emits an inverted same-second interval. - Truncated orchestration topology keeps unresolved edges of retained children. - Status: only the bare-invocation probe bounds a custom endpoint's latency. - session.read exposes decoded tool_input objects. - MCP: a cancelled daemon submission waits for its transport thread and cancels the same request id before re-raising. - Manual continuations refuse an edge that would close a cycle. - Search authority counters match the API builder (matched = total, analyzed = returned window). - Stale tests fixed forward: same-second history, manual continuation route, work-event raw lookup. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
polylogue-2mw8c. - Work events: a retained agent-work-event raw is written event-only. write_parsed_session_to_archive recognizes the raw identity, keeps every stored session-owned header column, skips identity claims, active-leaf moves and header side tables, and appends instead of replacing, so live appends and replay of already-retained events keep the reconstructed session. The live producer no longer copies the header itself. - Continuations: a narrower limit keeps the token's offset and selection. - Configuration evidence: an unmapped invocation matches by its own name; history follows each commit's historical path across renames and never emits an inverted same-second interval. - Truncated orchestration topology keeps unresolved edges of retained children. - Status: only the bare-invocation probe bounds a custom endpoint's latency. - session.read exposes decoded tool_input objects. - MCP: a cancelled daemon submission waits for its transport thread and cancels the same request id before re-raising. - Manual continuations refuse an edge that would close a cycle. - Search authority counters match the API builder (matched = total, analyzed = returned window). - Stale tests fixed forward: same-second history, manual continuation route, work-event raw lookup. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
## Summary Closes the ten Codex findings from the #5722 landing tracked in polylogue-2mw8c. That includes the open P1: replaying a retained `agent-work-event:` raw overwrote the reconstructed session's metadata. ## Problem Each finding reproduced on master: - **Work-event replay (P1).** Replay built a skeletal `ParsedSession` with default header fields, and the session upsert took those as incoming values. A same-raw full replay could also replace the transcript. The live producer avoided this only by copying header fields by hand, and replay had no equivalent. - A continuation resumed with a smaller `limit` fell back to offset 0 and lost its expression and filters. - An unmapped declaration name matched every artifact of its kind. - Rename history read pre-rename blobs under the final path, and a same-second history could produce an inverted interval. - Topology truncation dropped unresolved edges. - Custom status reads were cut off at 0.5 s. - `session.read` exposed `tool_input` as JSON text instead of an object. - A cancelled MCP maintenance call abandoned its transport thread. - Manual continuations bypassed the resolver's cycle guard. - The search authority counters were swapped between the operation route and the API route. ## Solution - **Event-only writes (P1).** `write_parsed_session_to_archive` recognizes a work-event raw (`WORK_EVENT_RAW_ID_PREFIX`) that carries no messages or attachments for an existing session. It then: - forces an append; - restores the stored session-owned header columns; - leaves identity claims, active-leaf flags, working directories, refs and repo edges untouched. Because the rule keys on the retained raw identity, events retained before this change replay the same way. `append_work_event` no longer copies the header itself. - `_transaction` rebuilds the request from the continuation token and changes only `limit`. - Name matching falls back to the invocation name. - Configuration history reads each followed commit under its `--name-only -z` path and skips non-positive tail intervals. - Unresolved edges of retained children survive truncation. - `_status_operation_result` has no timeout. Only `show_fast_status` passes the 0.5 s probe bound. - `tool_input` goes through `archive_block_to_domain`. - On cancellation, `_daemon_operation` waits for the submission thread, sends `operation.cancel` for the same pre-minted request id, and then re-raises. - `record_manual_continuation_product` runs `_would_create_cycle` before writing the resolved edge and refuses a cycle. - Operation-route search now reports `matched=total, analyzed=len(hits)`, the same as the API builder. ## Verification - `agentctl job start polylogue pytest_focused --workspace <wt> -- tests/unit/operations/test_session_read_parity.py tests/unit/context/test_configuration_evidence.py tests/unit/mcp/test_session_orchestration.py tests/unit/cli/test_status.py tests/unit/cli/commands/test_status.py tests/unit/operations/test_daemon_reads.py tests/unit/api/test_search_envelope_builder.py tests/unit/mcp/test_privileged_tools.py tests/unit/api/test_manual_continuation_link.py tests/unit/mcp/test_work_event_tools.py tests/unit/storage/test_revision_replay.py tests/unit/sources/test_revision_backfill.py tests/unit/sources/test_live_batch_support.py` (job 1585): everything passed except two status tests. Those two (`test_sinex_status_reads_the_active_archive_file_set`, `test_configured_override_url_is_not_refused`) fail identically on `origin/master` (baseline job 1546). - Anti-vacuity: with event-only detection disabled, both replay parametrizations and the idempotency test fail. - `verify_quick`: succeeded (job 1582). ## Residuals - `write.py`, `archive.py` and `revision_backfill.py` are in the derived schema-identity closure, so this moves the derived identity. Land it before the next rebuild starts. - An event-only write still sets `sessions.raw_id` and `content_hash` to the event raw's values, as the live route already did. 🤖 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]>
#5727 made a root-bound writer lease refuse any write that omits its archive identity. #5769 fixed the lifecycle and several daemon ops writers; the routes below still refused or wrote to a re-resolved root. - Pass archive_root at the remaining daemon, schema, security and storage write opens. - Daemon-emitted lifecycle and live-batch events name the daemon's archive instead of re-resolving the ambient root. - Nested write_lease re-entry checks the held lease's own identity; it raised "omitted archive identity" under any root-bound lease. - SQLiteBackend over an established archive admits it through the read-only format-marker proof when the caller holds no lease, so the live batch probing Polylogue.backend is not refused (#5727 made the constructor run the lease-gated active-root bootstrap every time). - A process-wide arming no longer saves and restores the thread-local flag, which left a thread armed after out-of-order exits (#5722). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
…#5782) ## Summary `tests/unit/daemon/test_daemon_cli.py` failed on master because of a production defect, not the dependency bump. #5727 made a root-bound writer lease refuse any write that omits its archive identity, but it left callers that open without one. On fddc7a1 the daemon could not start: `DaemonLifecycle.start` opened `ops.db` unnamed under `polylogued`'s root-bound lease. #5769 has since fixed the lifecycle and several daemon ops writers. This PR fixes the routes that were still refused and realigns three tests with contracts that later PRs changed. ## Problem (evidence) - `devtools test tests/unit/daemon/test_daemon_cli.py` on plain origin/master 4cbf83b, with no lockfile bump: `29 failed`, the same set as the bumped run. That rules out starlette, uvicorn, watchfiles, ruff, hypothesis and networkx. - 28 of the 29 were `UnleasedWriteError: open_daemon_connection(.../ops.db) omitted archive identity for writer daemon.lifecycle.start`, raised while the daemon started. The tests' own `watch stopped`, `server stopped` and `shutdown marker failed` expectations never ran. The 29th was the #5727 pidfile message change. - With the lifecycle fixed, nine more failures appeared. The same tests pass on 841bbb3, the commit before #5727. Traced causes: - `SQLiteBackend.__init__` now runs the lease-gated `initialize_active_archive_root` on every construction, even for an established archive. The live batch reads `Polylogue.backend` outside the lease, so each intake item came back `retryable: UnleasedWriteError: active archive bootstrap requires the daemon write lease`. - Nested `write_lease(actor)` re-entry called `require_write_lease` without a root, so any derivation publish under a root-bound lease raised "omitted archive identity". - Daemon-emitted events re-resolved the ambient archive root instead of the daemon's own. - On master tip 14a63dc, the three touched test files still fail 14 tests: `devtools test --on-default-branch tests/unit/daemon/test_daemon_cli.py tests/unit/daemon/test_daemon_lifecycle.py tests/unit/storage/test_write_lease.py` gives `151 passed, 14 failed`. ## Solution Production (`fix(daemon)` commit): - Pass `archive_root` at the write opens that still omitted it. These are the FTS automerge, judgment automation, daemon assertion mutation, schema drift sampling, schema sampling and verification, secret scan, blob GC history, sqlite-vec runtime, the non-daemon branch of `open_initialized_tier_connection`, and `connection_context`, which gains the parameter. - Daemon lifecycle, parked-loop and live-batch events name `archive_root_path`. - Nested `write_lease` re-entry checks the held lease's own identity. It no longer checks an absent one. - `initialize_backend_state` runs the active-root bootstrap only when the caller may write: the bootstrap is needed, a lease is held, or enforcement is off. A daemon-armed caller without a lease gets the read-only `assert_archive_format_lineage` proof. An established archive therefore still has to prove its lineage marker, as #5727 intended. - `arm_write_lease_enforcement(process_wide=True)` no longer saves and restores the thread-local flag. #5722's overlapping-arming test exits out of order, which restored a stale `armed=True` and left the pytest thread armed for every later test in `test_write_lease.py`. Tests, each disposition against the PR that changed the contract: | Test(s) | Cause | Disposition | | --- | --- | --- | | 14 `UnleasedWriteError` plus 13 `watch/server stopped` and `shutdown marker failed` | lifecycle start under the root-bound lease (#5727) | production bug. #5769 fixed the lifecycle, and this PR fixes the remaining writers | | `test_pidfile_remains_locked_until_admitted_writers_are_drained` | #5727 widened the refusal wording | superseded contract. #5769 already realigned it | | `test_an_orphaned_service_retains_archive_ownership_on_the_production_route` (TimeoutError) | never reached `health_check` because the lifecycle start raised | production bug, same root cause | | `test_daemon_watcher_hints_wake_fair_intake_and_canonical_derivation` ×4 | backend bootstrap outside the lease (#5727) | production bug, fixed | | `test_cold_build_*` ×4, `test_daemon_startup_catch_up_and_restart_repair_session_profiles` | nested-lease re-entry, event root, and state leaked from the failing watcher test | production bug, fixed | | `test_run_daemon_services_waits_for_fts_startup_before_watcher` ×2 | #5727 reads `operation_runtime.embedding_convergence` | superseded test stub. The fake server declares the attribute | | `test_raw_owner_cancellation_settles_publication_and_fts` (fails on the current tip) | #5691 made a cancelled compute owner stop its retained preparation | superseded contract. Renamed to `..._stops_preparation_and_the_next_pass_publishes`: cancellation publishes nothing, and the next pass publishes the session and its FTS rows | | `test_archive_bound_lease_can_delegate_without_dropping_identity` | asserted `adopted is lease`, but adoption returns a per-thread view by design | the test was wrong when #5727 added it. It now asserts that the adopted view carries the archive identity and authorizes a write for that archive | New regression tests, each naming its anti-vacuity condition: nested re-entry inherits the outer archive identity; an unleased backend admits an established archive read-only and still refuses one without a marker; lifecycle start and the signal marker persist under a root-bound lease. ## Verification - `devtools test tests/unit/daemon/test_daemon_cli.py tests/unit/daemon/test_daemon_lifecycle.py tests/unit/storage/test_write_lease.py tests/unit/cli/test_cli_write_authority.py tests/unit/daemon/test_daemon_events_endpoint.py tests/unit/storage/test_write_guard.py tests/unit/daemon/test_write_coordinator.py tests/unit/daemon/test_judgment_automation.py tests/unit/daemon/test_secret_scan_sweep.py tests/unit/daemon/test_standing_queries.py tests/unit/daemon/test_standing_queries_default_evaluator.py tests/unit/daemon/test_standing_query_clock.py tests/unit/mcp/test_mcp_call_log.py tests/unit/pipeline/test_schema_drift_sentinel_ingest.py tests/unit/schemas/test_drift_sentinel.py tests/unit/schemas/test_drift_sentinel_sampling.py tests/unit/security/test_secret_scan.py` at 3a56a1e: `devtools test: PASSED`, `445 passed`. - `devtools verify --quick` at 3a56a1e: `verify: PASSED`. - The head was then rebased over #5778, which touches none of these files. ## Residuals - `devtools schema closure` reports these touched files as IN: `write_lease.py`, `async_sqlite.py`, `connection_profile.py`, `bootstrap.py`, `blob_gc.py`, `sqlite_vec_runtime.py` and `sampling_db.py`. The derived schema identity may move, so this must land before a fresh build starts. - Some writers outside the daemon still resolve the ambient root: the HTTP reset event, browser capture and judgment receipt events. In production that root equals the lease root. In tests it can differ when `polylogue.daemon.events` is first imported under a `patch("polylogue.paths.archive_root")`, which binds the mock into the module. - `open_profiled_connection` still has no `archive_root` for write profiles. Every current caller uses a read profile. - An `arm_write_lease_enforcement(armed=False, process_wide=True)` suppressor no longer clears a thread-local arming. Nothing calls that combination. 🤖 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]>
…#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]>
…#5811) ## Summary Resumed transcript windows now read the selection and page size the continuation was minted for, on both the typed session-owner route and the generic `session.read` operation. Two stale `prose_with_refs` compiler tests are realigned with the contracts that changed under them. Tracking: beads polylogue-zeolc and polylogue-6bhuy (the compiler and transcript-window items). ## Problem At origin/master 1beb2e5 (agentctl job 2441), four tests failed: - `test_session_owner_operations.py::test_search_read_timeline_and_mcp_use_owner`: MCP `query(projection="sessions")` sent the default page size with a continuation, and the owner refused that as widening the window. #5779 has since landed the same fix on master. This PR adds narrowing and widening assertions for that route. - `test_transcript_window_route.py::test_continuation_can_narrow_final_window_without_losing_snapshot_binding` ("dialect mismatch"): the test hand-built a token whose result identity did not match its request, and `frame_request` reported that as a dialect mismatch. Reading the code turned up a real bug underneath. On narrowing, `frame_request` returned the new request, whose default offset and filters replaced the token's. #5778 fixed the same bug in `session_reads._transaction` but not here. - `test_compiler.py`, both `prose_with_refs` tests: #5722 changed the contracts these tests assert (details under Solution). Checking the other surfaces that resume a continuation found three more places where the resumed request's defaults win over the token: - `message_transcript_window` filtered with the caller's request. A token-only `sessions.read` resume of a `message_role=("user",)` window served unfiltered rows at the filtered offset. - The generic `session.read` (transcript and messages kinds) dropped an explicit `limit` beside a continuation. The CLI's narrowed resume from #5785 (remaining bound, `result_too_large` halving) therefore read the token's full page in production. #5785's tests mock the dispatch, so they could not catch this. - The messages kind checked for filters on its own payload, not on the framed token, so it would resume a filtered owner token and serve unfiltered rows. ## Solution - `frame_request`: separate the dialect check from the result-identity check. On narrowing, keep the token's request and change only `limit`. - `message_transcript_window`: frame the request once to get the effective selection, then pass the submitted request to the bound route so epoch validation is unchanged. - `daemon_reads._session_window_request`: one builder for both kinds. With a continuation, a stated `limit` narrows the page (`frame_request` refuses a larger one) and a stated nonzero `offset` is conflict-checked. The messages kind checks filters on the framed selection. - `SessionReadRequest.limit` is now `int | None = None`. The operation transport forwards every declared field, so the old `limit=200` default would have read as a request to widen every token-only resume. That was the cause of the four failures in the first focused run (job 2563). Handlers still use the declared 200-row window for a fresh read. - Compiler tests: #5722 added an action `ObjectRef` assertion that contradicts `ObjectRef.parse`, which has read an action's trailing block index as a qualifier since #4329. The test is fixed; production is right. #5722 also made the budget a hard cap, so `max_tokens=80` now omits every row. The recap test now uses a budget where recapping, not omission, makes the page fit, and asserts the estimate stays within the prose budget. - `docs/session-operations.md` states the resume page-size and filter rules. None of the changed production files is in the derived-identity closure (`devtools schema closure`: all `out`). ## Verification - `agentctl job start polylogue pytest_focused --workspace … -- tests/unit/mcp/test_session_owner_operations.py tests/unit/operations/test_transcript_window_route.py tests/unit/context/test_compiler.py tests/unit/archive/query/test_continuation_surface_parity.py tests/unit/cli/test_session_window_continuation_bounds.py tests/integration/test_transcript_window_differential.py tests/unit/operations/test_transcript_window_resume_selection.py tests/unit/operations/test_daemon_reads.py tests/unit/operations/test_session_read_parity.py tests/unit/operations/test_session_owner_route_equivalence.py tests/unit/operations/test_http_session_reads.py tests/unit/cli/test_read_view_execution_routes.py tests/unit/operations/test_daemon_protocol.py`, job 2608: `passed 143, failed 0` (2 flaky on first attempt, below). - `agentctl job start polylogue verify_quick`, job 2609: succeeded. New regression tests in `tests/unit/operations/test_transcript_window_resume_selection.py`: - A token-only owner resume reads under the token's filters. - The generic messages kind refuses a filtered owner token. - Narrowing works identically on the owner route and both generic kinds; a token-only resume keeps the token's page size through the transport's declared request; widening is refused. ## Self-review - **Sibling sites.** Every `QueryContinuation.decode` and `frame_request` caller was checked. The evidence windows (`frame_evidence_window`) ignore `limit` on a continuation, and their only CLI caller sends none, so no wrong rows are served (residual below). `window_request`, used by the API, MCP `read` and HTTP messages routes, drops `limit` beside a continuation. The window is then fully decided by the token. No wrong rows, but an explicit narrowing is ignored there (residual). - **Contract change.** `SessionReadRequest.limit` is read only through `_non_negative_int(..., default=_SESSION_READ_WINDOW)`, which maps `None` to the 200-row default. No checked-in schema snapshot names it. - **Double framing.** `frame_request` is pure; calling it twice cannot diverge, and the bound route still validates the epoch. - **Compatibility and fail-open.** No shim; a larger limit is refused, not clamped. - **Tests on the production route.** The generic reads go through `SessionReadRequest` validation exactly as the transport does, which is what exposed the default-limit problem. ## Residuals - Evidence windows and the `window_request` routes silently ignore an explicit `limit` beside a continuation. They serve correct rows, but do not narrow. - The two first-attempt flakes in job 2608 were daemon start-up timeouts (`TimeoutError`, `DaemonWriterOwnerLoopStopped`) under host load. They are unrelated to window framing, and both passed on rerun. 🤖 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 Realigns 11 tests that fail on master. Each encodes a contract that a merged PR changed on purpose. Production code is unchanged. ## Problem These tests failed at master 1beb2e5 (baseline agentctl job 2441, `devtools test --on-default-branch`). Beads: polylogue-cp3z5 (lineage validation) and polylogue-bn8gg (facade `record_context_ledger`). The other items are in polylogue-6bhuy, which also lists items owned by sibling PRs. | Test | Contract change | | --- | --- | | `tests/unit/devtools/test_lineage_validation.py` (all 21) | The hand-built index lacks `messages.fields_digest` and the derived schema identity stamp. Every reader refuses an unstamped derived tier as `SchemaSkew` ("expected <digest>, found None"). | | `test_facade_contracts.py::test_no_undiscovered_async_methods` | `record_context_ledger` (#5722) and `get_session_summaries` are in no contract set. | | `test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits` | #5703 moved deduplication into the search-scope walk. The unscoped path yields each session once by construction, so the duplicate case is a search hit. | | `test_preamble.py::test_precompact_uses_scheduler_and_records_real_boundary_context` | The precompact path awaits `record_context_ledger` (#5722). The mock was a plain `MagicMock` attribute, and the other test in the file set it twice. | | `test_manual_contract.py::test_published_examples_use_live_operation_vocabularies_and_preconditions` | `read`'s `view` is now `Literal[...] \| None`. `typing.get_args` on the union yields the Literal and `NoneType`, not the members. | | `test_write_effects.py::test_deferred_insight_invalidation_follows_a_repointed_index` | #5727 moved profile invalidation into the admitted transaction, so no deferred reopen by path is left to follow. | | `test_mutation_actuators.py::...::test_production_tag_and_metadata_writes_use_user_overlay_policy` | #5727 made tag writes that change a row invalidate the search cache. | | `tests/unit/cli/test_status.py::...::test_sinex_status_reads_the_active_archive_file_set` | #5722: publication mode comes from the loaded config, and the file set from `resolve_runtime_config()`. | | `tests/unit/cli/commands/test_status.py::...::test_configured_override_url_is_not_refused` | #5722: a non-built-in daemon URL is read over HTTP `GET /api/status`. | ## Solution Each test now exercises the current contract and keeps its anti-vacuity condition: - **Lineage validation.** The fixture declares `fields_digest` and stamps the current identity with the production `stamp_derived_schema_identity`. - **Facade.** Both methods are classified. `get_session_summaries` gains coverage in `test_archive_tiers_api_reads_native_sessions`: requested ids key the result, and an unresolved id is omitted. The facet test drives two hits for one session through the search scope. - **Manual contract.** The vocabulary is read through unions, and the test asserts `"messages"` is in it, so an empty read cannot pass. - **Write effects.** The test now proves the invalidation commits and rolls back with the caller's transaction. An effect that opened its own connection would survive the rollback. - **Tag overlay.** Expects exactly one invalidation per changed tag write, and none for metadata writes or the no-op re-add. - **Status.** The URL-override test runs a real local HTTP server and asserts only `/api/status` was requested. ## Verification - `agentctl job start polylogue pytest_focused --workspace <wt> -- tests/unit/devtools/test_lineage_validation.py tests/unit/api/test_facade_contracts.py tests/unit/context/test_preamble.py tests/unit/agent_integration/test_manual_contract.py tests/unit/archive/test_write_effects.py tests/unit/operations/test_mutation_actuators.py tests/unit/cli/test_status.py tests/unit/cli/commands/test_status.py`: job 2632, `devtools test: PASSED exit=0`, 582 passed. Five tests passed only on rerun. Each failed first with `DaemonWriterOwnerLoopStopped ... daemon.operation_journals.startup` or a 5 s bridge `TimeoutError` in the test daemon stack; that race is fixed in #5810. - `agentctl job start polylogue verify_quick --workspace <wt>`: job 2633, succeeded. ## Self-review - **Production route.** Each rewritten test calls the production function (`stamp_derived_schema_identity`, `_invalidate_insights_effect` on a real connection, `_status_operation_result` against a real HTTP listener, `ArchiveStore` tag writes). None asserts a mock's own behaviour. - **Loosening.** No assertion was dropped. The facet and write-effects tests change input shape to match the current route, and each keeps a condition that fails if the named behaviour regresses. - **Scope.** Test-only; no derived-identity closure file changes. ## Residuals None known for these tests. The daemon-stack startup race behind the five reruns is addressed in #5810. 🤖 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 `polylogue facets` now sends every typed operation-kernel failure through `exit_for_read_failure`, the path every other read route already uses. ## Problem `_fetch_daemon_facets` caught only `OperationUnavailableError`. Any other `OperationKernelError` escaped the Click command as a raw exception: a dropped daemon connection (`daemon_transport_error`), a deadline, a cancellation, or an invalid request. The operator got no exit status for the failure class, no call id and no remedy. This residual came from the salvage ref `work/luna-x1`. Its other hunks are already on master. ## Solution The existing `OperationUnavailableError` → `DaemonRequiredError` conversion stays. A second `except OperationKernelError` hands every other typed failure to `exit_for_read_failure`. ## Verification - `devtools test tests/unit/cli/test_read_failure_exit_codes.py tests/unit/cli/test_machine_main.py` result: `33 passed`, `PASSED exit=0`. - The new test `test_the_facets_route_leaves_through_the_read_failure_terminal` drives the real `facets` CLI route for the transport, deadline, cancelled and invalid-request cases. It fails if the new branch is removed. - Master's quick gate was red on two stale baselines, and this PR fixes them forward in a second commit. First, the layering sqlite-degradation baseline is re-anchored to two handlers from #5729: the one it moved in `production_baseline.py` and the retryable read-fault handler it added in `live/batch.py`. Both are deliberately classified by `retryable_read_fault`. Second, the `query_verbs.py` anchor that #5722 made stale is pruned from `cli-nonzero-click-exit`. - `devtools verify --quick` result: `PASSED exit=0`, with all 12 gates ok. ## Residuals None known. 🤖 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]>
Batch
polylogue-20260928-071920-228a6f5aon base54b922e07250.polylogue-1tyq5.60 Codex P2 review debt: polylogue/cli part 1 (25 findings)
polylogue-1tyq5.61 Codex P2 review debt: polylogue/cli part 2 (25 findings)
polylogue-1tyq5.62 Codex P2 review debt: polylogue/cli part 3 (21 findings)
polylogue-1tyq5.77 Codex P2 review debt: polylogue/mcp part 1 (25 findings)
polylogue-1tyq5.78 Codex P2 review debt: polylogue/mcp part 2 (1 findings)
polylogue-1tyq5.55 Codex P2 review debt: polylogue/api part 1 (25 findings)
polylogue-1tyq5.56 Codex P2 review debt: polylogue/api part 2 (1 findings)
polylogue-1tyq5.54 Codex P2 review debt: polylogue/analysis (7 findings)
polylogue-1tyq5.53 Codex P2 review debt: polylogue/agent_integration (8 findings)
polylogue-1tyq5.63 Codex P2 review debt: polylogue/context (14 findings)
polylogue-1tyq5.39 Codex review debt: work events (3 findings)
polylogue-1tyq5.64 Codex P2 review debt: polylogue/coordination (1 findings)