Repository navigation
fix: Land the small verified closure fixes in one batch - #5221
Conversation
Thirteen beads whose fix was already derived and verified against head,
each with one regression at its production seam:
- tgq71: migration discovery sorts by numeric version (999 before 1000).
- yfc4f: the live source.db continuity check no longer opens immutable=1,
so an uncheckpointed WAL is read instead of turning the check into a
silent pass.
- iaffn: message-axis revision comparison builds its per-identity content
index in one pass (was quadratic in shared identities).
- i60k5: the Claude.ai empty-conversation probe reuses the decoded
single-line export instead of reading and decoding the artifact twice.
- tcear: the priority gate never grants twice when a sibling waiter cancels
during the release handoff.
- o7d39: a durable tier newer than the runtime says "update the runtime";
it no longer prints `mv source.db source.db.stale` as the remedy.
- 54a31 (1): Drive parent chains sort by parsed instant, not by timestamp
text ('+02:00' after 'Z').
- 54a31 (3): hook transcript guard sums string content depth-capped in all
three copies (hook_producer, packaged CLI, contrib script), so a transcript
nested in a list or dict is refused.
- 54a31 (4): a Gemini CLI user turn with empty content but a typed
displayContent is kept.
- bzx7h: the Codex state-db acquisition branch requires the Codex fallback
provider; a foreign file merely named state_5.sqlite goes to detection.
- 877es: the deleted historical-continuity resource is dropped from
PACKAGE_RESOURCES; gate distribution passes again.
- 54erj: the three producer-less ScenarioProjectionSourceKind members go.
- 5jebf: docs/architecture.md stops advertising mutation/benchmark campaigns.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 26 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (26)
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. |
… declaration The test certified the deleted historical-continuity resource by name; with PACKAGE_RESOURCES empty it asserts the declared-resource refusal through a monkeypatched entry and that an empty declaration passes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
## Summary Six tests were red on master after the 2026-09-16 wave (polylogue-3t9ea); four were real product defects, two stale test premises. All six are green. ## Problem and solution, per test - Delegation stage check caught only `FileNotFoundError`, so a locked or skewed probe aborted the whole convergence pass. Now degrades to "assume work" with a `daemon.stage.check_failed` event, like the standing-queries stage. - `polylogue_vector_derivation_hash` takes a registered recipe hash since polylogue-crcst, but `sqlite_vec_runtime` still passed a model name, so every managed or pinned vector projection raised `SqliteVecError`. `EmbeddingRecipe` is threaded through the vector read binding (`open_operation_read(vector_recipe=...)`); this also fixes `test_vec.py::test_open_vector_read_snapshot_uses_only_the_explicit_pinned_paths`. - #5221 added `fallback_provider is Provider.CODEX` to the structural Codex state-db acquire arm; `canonical_acquisition_provider` aliases only the exact `codex-state`/`codex-memories` tokens, so watch sources named otherwise resolved to `unknown` and their `goals_1.sqlite` was silently excluded. Conjunct reverted on the structural arm; the source-only arm keeps it, and #5221's foreign `state_5.sqlite` guard still refuses via the structural check. - The MCP query-capability catalog had grown to 26,357 bytes against the 25,000-byte response budget, so `_json_payload` silently returned the generic over-budget envelope and MCP discovery exposed no query vocabulary at all. The resource now measures the serialized catalog and, only when over budget, applies one declared reduction (per-unit field names → `field_count` + explain route); 18,300 bytes now. - Embedding-readiness test seeded `embedding_status` into the anchor db while the payload reads `root/embeddings.db`; re-seeded into a real tier pair, contract kept, terminal/retryable split added. - Attachment-acquisition test's private id mirror still used NUL framing after `_hash_bytes` moved to length-prefixed framing; it now uses the production `_attachment_id`. ## Gate finding (not changed here) No required per-PR check runs pytest: `verify_quick` is static gates only, the CI `test` job is `workflow_dispatch` with `run_full_suite`, and the only broad pytest evidence is the nightly `verify_all`. Master going red on these was structurally invisible until the nightly. Adding a required pytest selection reverses an explicit operator policy, so it is surfaced on polylogue-3t9ea and polylogue-u9nmr for a ruling rather than changed. ## Closure `sources/live/batch.py` and `storage/search_providers/sqlite_vec_runtime.py` are IN the derived-schema closure; the identity moves. Lands before the rebuild. ## Verification - `agentctl ... verify_quick` → job VQ_PLACEHOLDER - `agentctl ... pytest_focused -- <the eight files + tests/unit/operations + tests/unit/mcp + daemon_execution>` → job PF_PLACEHOLDER - Worker: the eight files → 262 passed; ruff/mypy clean. ## Residuals - `vector_model` → `vector_recipe` keyword rename on `open_operation_read`: `daemon_execution.py` is the only production caller; the integration selection above covers tests/unit/operations and tests/unit/mcp. - The delegation check now swallows every exception into "assume work" with a warning event, matching the standing-queries precedent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…5409) ## Summary A real `polylogued run` ingests nothing. Four sites on its own ingest path open a write-mode archive connection with no lease held — or bound to the wrong archive root — and the armed single-writer boundary raises `UnleasedWriteError`, which refuses the whole intake page. Live ingest has been broken since 2026-09-16. ## Problem This was filed as a cluster of 16 failing tests with two candidate explanations. **Both are refuted**, and the defect is production-only. - *"Startup never converges"* — no. `daemon.started` fires, the watcher binds all 16 source roots, the API answers, and per-publication ops writes succeed under their own lease in the same log. - *"A writer lease is never released"* — no. Every `daemon.writer.released … status=success` line shows holds of 1–800 ms. The defect is a lease never **taken**. Reproduced outside pytest with the installed `polylogued` console script against a synthetic 3-session corpus — no fixture, no harness. The line that decides the diagnosis, from the real daemon's stderr at base: ``` daemon.intake.page_refused ... error_detail=open_connection(<root>/ops.db) requires the daemon write lease; open it inside write_lease(...) ... error_type=UnleasedWriteError files=3 outcome=degraded reason=page_admission_failed ``` Bisected on the real binary: `OK messages=50` at `342cf9e20` (#5221), `TIMEOUT last=0` at `1c1895098` (#5263) and every later point. The window opens at `d7d3ddae5` (#5224, 2026-09-16), which added `require_write_lease` to `CursorStore.ops_write_scope`; #5265 moved the raise site to `get_records` but did not introduce it. **#5382 is not the cause**, despite the differential that pointed there: the cluster was already failing in the 09-21 corpus run, and #5382 landed 09-22 02:54 UTC. The four sites, each proven by stack capture at the raise: | Site | Route | |---|---| | `sources/live/batch.py:963` | `get_records` → `_connect_ops` → `open_connection(ops.db)` on the event loop | | `daemon/cli.py` | `_drain_convergence_debt_once` → `CursorStore(db)` → `initialize_archive_database(ops.db)` | | `sources/live/batch.py:1515` | inline `self._event_emitter(...)` → `open_daemon_connection(ops.db)` | | `archive.py:1435` | `_ensure_source_conn` bound to the candidate generation dir, not the declared root | ## Verification Production route, the real binary, no pytest: | | base `0df0f6a00` | head | |---|---|---| | result | `TIMEOUT last=0` | **`OK messages=50`** | | `UnleasedWriteError` lines | 81 | **0** | | `convergence_debt.pass.error` | present | **0** | Re-run after rebasing onto current master `17566b048`: **`OK messages=50 after 27.3s`, 0 unleased errors** — the fix holds on the current tree, not only on the base it was written against. - `devtools verify --quick` → **21/25 gates green at time of writing, with the single failure being `gate atlas`, which is already red on master** (`docs/atlas/daemon.md`, hook-carrier anchor). Reproduced in a clean detached worktree at `17566b048` carrying none of these changes. PR #5408 fixes it. - `devtools render all --check` → exit 0, `grep -c 'out of sync'` = **0**. - `devtools test` over `test_daemon_resilience.py`, `test_schema_preflight.py`, `test_daemon_ops_lease_boundary.py`, `test_daemon_operation_route.py`, `test_inferred_corpus_loop.py` → **exit 0, 72 selected, 72 passed**. No timeout, mark or wait bound was changed anywhere, so the resilience tests reach their own `_wait_for_messages` assertions with real nonzero counts. - `test_daemon_cli.py` at head: 106/112. At base: 100/107. Delta is one test **fixed**; the remaining 6 are byte-identical inherited red. Baseline established by detaching at the base SHA and running the same selection. ### Anti-vacuity, executed Four production reverts, one at a time, each restored: - revert `_connect_ops_read` → `UnleasedWriteError: open_connection(…/ops.db) requires the daemon write lease`, from two independent tests - revert the `_run_sync` wrapper on the batch emitter → `UnleasedWriteError: live batch event ledger requires the daemon write lease` - revert `admit_stage_write` on the `CursorStore` construction → `UnleasedWriteError: open_connection(…/ops.db)` - revert `_ensure_source_conn` to `archive_root=self.archive_root` → `UnleasedWriteError: open_source_tier_write_connection(…/gen-1790055341112-6db616a2/source.db) is outside the archive bound to writer test.cold_build` Opposite direction pinned: `test_ops_tier_writes_still_require_the_write_lease` fails if `ops.db` is made lease-free wholesale. ## The cluster was three causes, not one - **12 of 16** are the production defect above. - **2** are a stale test contract: they assert `assert_scopes_balanced(at_least=N)` on the degraded short-circuit path, but #5265 retired the one-scope-per-batch contract and #5388 put the scope inside each admitted publication. A degraded batch returns synthetic skip metrics before `begin_ingest_attempt`, so it correctly performs zero ops writes and can never satisfy `at_least>=1`. Retargeted to `assert_no_ops_bookkeeping`. - **1** is a harness more restrictive than production — a phantom. `test_fresh_runtime_prepares_tier_journals…` died in its own `seed`: `SessionBuilder.save` writes through the thread-local cache in `storage/sqlite/connection.py`, whose `index.db` connection ATTACHes the sibling durable tiers and is never closed, so `PRAGMA journal_mode=DELETE` on `source.db` hit the seeding thread's own lock. Isolated proof: `source LOCKED database is locked` / `user ok` / `audit ok`. A fresh `polylogued` process has no such cached connection, so **production cannot exhibit this one at all**. - **1 more** was fixed by #5388 landing on master during the lane; it passes at base untouched. The harness was **under**-reporting, never over-reporting, for the real cause. ## Still red, handed back The 4 `test_daemon_watcher_hints_wake_fair_intake_and_canonical_derivation` params are a **fourth, distinct cause** that only became visible once the daemon started ingesting. They are no longer `CancelledError`; the fix carries them past ingest (`ingested_session_count=1`) into `test_daemon_cli.py:2747`, where `sum(report.done == 1 …) == expected_versions` sees `[(…, 0), (…, 2)]` — the canonical derivation kernel reported done=0 then done=2 instead of one per version. That is a derivation-batching question and needs its own bead. Confirmed inherited-red at base by the same nodeids. Two further inherited reds, failing identically at base and head: `test_raw_observation_publication_holds_writer_lease_through_replay` (`AttributeError: 'FakeArchive' object has no attribute 'archive_root'` — a test double that never gained an attribute production now reads) and `test_run_daemon_services_parks_operation_recovery_on_audit_schema_mismatch`. The 2 `test_inferred_corpus_loop.py` property tests pass at head, but **no code cause was established** for their corpus-run timeouts and they do not arm the write lease. The honest reading is host-load starvation, not a fix — do not credit them here. ## Behaviour change worth a reviewer's eye The 7 SELECT-only `CursorStore` readers now open read-only when no `ops_write_scope` connection is held. On a fresh archive with no `ops.db` they raise `sqlite3.OperationalError: unable to open database file` instead of silently bootstrapping it through a write-mode open. The daemon bootstraps the archive root before any of these run, and `cli.py:1584` already documents this exact `initialize=False` read-probe pattern — its `get_record` call was a fifth latent `UnleasedWriteError` site that this change also removes — so the typed failure is judged correct rather than adding an unexercised guard. ## Schema closure IN: `sources/live/batch.py`, `sources/live/cursor.py`, `archive_tiers/archive.py`. out: `daemon/cli.py` and all three test files. - `DerivedTier.index`: `8a971a53…` (base, measured in a detached worktree) → `abb040da…` - `DerivedTier.ops`: unchanged A closure move on ordinary code — no DDL, no lowering or materializer semantics, no durable migration. Needs reconvergence, and **must land before a fresh rebuild starts, never during one**. Re-measure at merge; other lanes are moving this value concurrently. ## Follow-ups, same defect class, left unlanded - `archive.py:5599` `ArchiveStore.delete_sessions` still binds `require_write_lease(archive_root=self.archive_root)` instead of `_write_lease_archive_root`, so a delete on a generation-rooted store fails exactly as `_ensure_source_conn` did. - `daemon/cli.py:487` `_mark_interrupted_live_ingest_attempts_on_shutdown` constructs `CursorStore(initialize=True)` on the shutdown path — an unleased ops write. Currently unreached because signal termination logs `daemon.shutdown.ingest_recovery_deferred`, but a non-signal graceful stop would hit it. Neither was fixed because neither could be exercised. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
Thirteen small beads from the reindex closure sweep, each fixed at its production seam with one regression test. Product code touched: migration_runner, durable_change_train, session_revision_membership, raw_materialization, write_coordinator, bootstrap, drive parser, local_agent parser, hook_producer (+ packaged and contrib copies), live batch, verify_distribution_surface, scenarios/projections, docs/architecture.md.
Problem (evidence, all verified at e56edbe)
sorted(files.iterdir(), key=name)orders1000_x.sqlbefore999_y.sql; the chain check then refuses every migration past 999._validate_audit_adoption_continuityopened the live source.db withimmutable=1, which ignores the WAL; after an unclean shutdown a committed v32 sits only in the WAL and the check returned silently._message_axis_relationrescanned every content key once per shared identity (O(n²) per comparison)._claude_ai_empty_conversationre-read and re-decoded a single-line export the leading-objects probe had already decoded._PriorityGate._wake_nextpopped an already-granted head and granted a second waiter when a sibling cancelled during handoff.mv <path> <path>.staleremedy.live/batch.pyrouted any file named like a Codex state db into Codex acquisition before generic detection.gate distributionwas red on master becausePACKAGE_RESOURCESnamed a resource whose module was deleted.Solution
One fix per bead as described in the commit; no behaviour widened, no size branch or second route added.
live/batch.pyis inside the derived schema closure; this lands before the fresh build starts, per the campaign rule.Verification
Residuals
_sort_instantordering, not a full parse of a two-offset chain.hook_producer.pyby hand as before.Beads: polylogue-tgq71 yfc4f iaffn i60k5 tcear o7d39 54a31 bzx7h 877es 54erj 5jebf
🤖 Generated with Claude Code
https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw