Repository navigation
perf(daemon): bound catch-up chunk convergence to the chunk's own input - #4694
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: d9ae9e0393
ℹ️ 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".
Partition inspection and publish selected a session's identity-ledger rows
with substr(block_id, 1, length(key) + 1) = key || ':', which plans as a
full scan of messages_fts_identity for every key on every pass. block_id is
session_id || ':' || ..., so the half-open range [key || ':', key || ';')
selects exactly the same rows through the block_id UNIQUE index (';' is the
code point after ':'). Measured on a 359-session archive: 10.5 ms -> 0.1 ms
per key.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
find_raw_authority_verdict_cache_work probed every logical_source_key with two point queries, so each daemon convergence check cost O(cohorts) statements. It now reads the cohort rows and the cached fingerprints in one pass each and applies the same staleness rule per key. write_raw_authority_verdict_cache deleted only the cohort's own rows; a raw already cached under a previous logical_source_key collided with the raw_id primary key (54 warmup failures in one rehearsal, each re-running the whole-archive check on the next chunk). Stale rows for the cohort's raw_ids are removed before the insert. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
The catch-up loop broke out of its priority groups on the first empty group, so a backlog with no file modified in the last hour was never planned: a fresh daemon over a quiet source tree logged "watching" and ingested nothing. An empty group is skipped; only a stop request ends the loop. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
… input Per-chunk convergence paid archive-wide costs on every chunk of a catch-up: the exact FTS readiness audit (whole-table aggregates, run twice per chunk: after FTS repair and after insights), the raw-authority verdict warmer (one probe per cohort), the Claude workflow and delegation graphs (rebuilt from every raw artifact), a scan of every hook sidecar journal (1.65 GB on the rehearsal spool: 4.5 s warm, 73 s once the page cache was evicted), and the periodic whole-archive FTS sweep interleaving with chunks. Stage check time was outside the ledger, so a 102 s chunk showed 2.5 s of stages. - ConvergenceStage.whole_archive marks stages whose work is a function of the archive; converge_batch(whole_archive=False) records them SKIPPED. The watcher runs every catch-up chunk but the last in that scope, so the archive-wide stages run once per catch-up. - The readiness audit is its own whole-archive stage (fts_readiness), run after fts and derived; partition-scoped FTS passes and insight rebuilds no longer publish it. The periodic whole-archive FTS sweep waits while a chunked catch-up is active. - Hook paste enrichment reads only the batch's sessions' sidecar journals (<provider>-<native_id>.jsonl). - The convergence ledger charges <stage>.check and hook_paste_enrichment. Scratch run, 400 files / 325 MB, 100 chunks, same host: convergence 200.4 s -> see PR body for the after figures. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
d9ae9e0 to
1a0ac23
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a0ac2368f
ℹ️ 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".
## Summary
Stop the daemon supervisor demoting a terminal service state to
`stopped`, and
repair six test scopes that were red on clean master — three
memorializing
deliberately changed behaviour, three broken fixtures.
## Problem
Clean master `3faacef23` fails these files. Splitting real defects from
stale
tests was the point of the exercise; the split came out 1 product bug, 3
stale tests, 3 broken fixtures.
**The product bug.** `halt()` sets `ServiceState.HALTED`, then cancels.
One loop
turn later the cancellation handler calls `_settle(spec, STOPPED, ...)`,
and
`_settle` had no terminal-state guard, so it overwrote `HALTED` and
republished
a *measured* `STOPPED`. Halt durability itself was never at risk —
`HaltRegistry`
still refuses the unit on restart — but a terminally refused service
appeared on
the status board as a clean `stopped`, which is the one thing an
operator reads
to decide nothing is wrong. Introduced whole in `b2ad5ef1b`; never green
on this
path.
## Solution
`TERMINAL_SERVICE_STATES = {HALTED, FAILED, ORPHANED}` as a general set
`_settle` never demotes, rather than a `HALTED` special case.
Cancellation is
the common ending for all three — a halt, a crash under `FAIL_DAEMON`,
and an
expired shutdown deadline each leave a child whose `CancelledError`
handler
settles `STOPPED` one turn later. No priority ordering is needed because
none of
the three is reachable from another, so first-writer-wins is the whole
rule.
`SKIPPED`/`UNAVAILABLE` are set through `_resolve` and have no task, so
they have
no demotion path.
Test repairs, each with its anti-vacuity condition:
- **Renamed service.** `raw_materialization_convergence` →
`raw_observation_convergence`
(`services.py:321-330`, wired at `cli.py:2752`). The service was renamed
by
`#4913`/`#5005`, not removed. The two sibling registry assertions
previously
asserted `not in` against a *nonexistent* name and so could not go red
at all;
now adding `RESIDENT_CORE` to the spec makes all three red.
- **Embedding readiness.** `_FakeCfg` replaced with a real
`PolylogueConfig`
after `embedding_status_settings_from_config` moved to nominal dispatch.
Reintroducing an attribute-only double makes all seven red.
- **WAL checkpoint.** The fixture closed its seeding connection in a
`finally:`,
and SQLite deletes the `-wal` on last close, so `checkpoint_wal`
returned at
its size gate with `mode='none'` before opening anything — every mode
read
`'none'` regardless of policy, so escalation was entirely unbound.
Seeding now
holds the connection open and asserts a non-empty `-wal` exists. The
busy-reader case closes the seeding writer once the reader holds its
snapshot,
so the reader is the sole WAL holder. **Proved empirically rather than
asserted:** temporarily dropping `TRUNCATE` from
`CHECKPOINT_ESCALATION_MODES["exclusive"]` turns the suite red with
`assert 'restart' == 'truncate'`, then reverted.
- **Orphan test** was a different defect than reported — its body
passed, but its
`uncancellable` child suppressed cancellation unconditionally, so
`asyncio.run`'s `_cancel_all_tasks` could never reap it and the test
died on
pytest-timeout at 120s. It now releases the child after the assertions
and
additionally asserts that reaping it leaves `ORPHANED` intact,
exercising the
new guard.
- **Per-stage timings.** `#4694` deliberately added
`parse.check`/`fts.check`/
`derived.check` sub-timings; the assertion now expects the six-key set.
Verified the consumer does not double-count:
`_per_stage_timings_from_attempts`
(`daemon_workload_probe.py:2150-2161`) keys per stage and summarises
each
independently, never summing across keys.
- **Audit tier v3.** The future version is now derived as
`ARCHIVE_VERSION_BY_TIER[AUDIT] + 1` instead of a literal, so audit 004
will
not break it again; the relocation clone fixture loops over the derived
chain
with no literal versions. Beyond the documented fields, the validator
also
binds `proof.restart_convergence.observed_user_version`
(`migration_runner.py:3610`).
## Verification
```
devtools test <all 7 touched files> 215 passed
receipt 20260913T185337Z-focused-test-1203290-0e0ce220
devtools verify --quick all 14 gates ok, exit 0
```
## Residuals
**Archive-root relocation is genuinely broken for one real class of
archives,
and this PR does not fix it** — the fixture repair here makes the test
green
without closing the product gap, so it is called out rather than hidden.
A durable tier below the runtime version is refused at open
(`bootstrap.py:593-596`), so an operator must run `migrate-tier` first,
and
`snapshot.user_version` is therefore always 3 at relocation time.
Migrating
writes only `audit-003.json`; it does not backfill `audit-002.json`. The
broken
class is any archive whose audit tier reached v2 *without* a v2 train
manifest —
pre-marker archives, `--adopt-established-audit`,
`--initialize-missing`. Those
end with manifests `{3}` against `expected_targets {2,3}` and hit the
raise. The
`validate_audit_adoption_receipt` bypass does not cover them: it is
gated on
`not manifests`, and `audit-003.json` exists by then. Archives that
walked 1→2
through the train route are fine, and the `.bootstrap` guard intercepts
fresh
archives first — into a hard refusal, not success.
Root cause: `archive_root_relocation.py:1194` uses the raw
`DURABLE_MIGRATION_ADOPTION_FLOORS[tier]` where every other chain check
uses
`_chain_floor()` (`durable_change_train.py:3179-3182`). Relocation's own
`.bootstrap` refusal made the two equal until a tier gained a migration
above a
version some archives reached without a train — which is exactly what
`003` did.
The same shape latently exists for SOURCE (floor 37, live 44), masked
because
real source archives carry the intermediate manifests.
Needs a separate owner, a `_chain_floor`-based fix, and a regression
test built
on a v2-era audit archive carrying only `audit-003.json`. Recorded in
the
`6c7513327` commit body so it is not lost.
**`embedding_readiness.py:62-68` needs no fix.** The seam is
unreachable:
`embedding_readiness_info` passes only
`SimpleNamespace(config=SimpleNamespace(db_path=...))`,
and `embedding_status_payload` calls `load_polylogue_config()` itself
(`status_payload.py:1307`) and passes *that* to the nominal dispatch
(`:1320`).
Broadening to `except Exception` would be actively wrong — it would
convert a
wrong-type programming error into `embedding_status="empty" /
retrieval_ready=False`,
indistinguishable from a fresh archive, which is the precise failure the
existing `polylogue-cpf.4` comment exists to prevent.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
Codex review threads on this PR whose cited code is gone (checked against master at 23f91a5):
Resolving these threads. |
|
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 0914f89):
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 bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
## Summary Fix all 25 confirmed Codex P1 findings of polylogue-ez5b9 (sources-live and sources-parsers) in one change. This PR now carries the coordinator's seven fixes plus everything from AgentCTL batch run `polylogue-20260929-115511-f46562fd` (workers ez5b9.1 parsers/artifacts/rendering, ez5b9.2 prepared acquisition, ez5b9.3 baseline/watcher). That run was abandoned once its content was carried here, so this is the only vehicle. The branch is rebased onto current `master`. ## Problem The findings (threads linked in the table) share one theme: intake decided an outcome from evidence other than the bytes it published. Examples: a vendor conversion was published against later protobuf bytes; provider detection sampled a different revision than the one sealed; a cursor was authorized from source evidence read before another writer ran. Others: whole cohorts ran past the writer budget; a torn JSONL record was skipped on the way to the frontier; growth hid behind the cursor; the baseline could not recognise retained growth or staged SQLite coordinates. Several parser shapes were also lost or mis-keyed before storage: project documents, ID-less tool steps, argument-less commands, relocated cwds, bare usage records, OTel identity. ## Solution | Finding | Thread | Fix | Production-route regression | | --- | --- | --- | --- | | 11.F006 | [#4330](#4330 (comment)) | The converter's verified SHA-256 is carried to capture (`AntigravityExportOutcome.source_sha256`). A capture that hashes differently is released and refused with `source_changed_after_conversion`. | `test_antigravity_conversation_acquisition.py::test_vendor_conversion_cannot_publish_a_later_protobuf_revision` | | 11.F007 | [#4330](#4330 (comment)) | One `admit_acquisition` item boundary covers ordinary files and each vendor conversion (`admit_path`). The vendor server starts only for an admitted item. | `::test_vendor_cohort_checks_the_pass_budget_between_conversations`, `::test_vendor_admission_refusal_happens_before_server_start` | | 11.F023 | [#4809](#4809 (comment)) | The same per-item checkpoint raises a typed `WriteHoldBudgetError` between conversions without poisoning items. | `::test_vendor_cohort_propagates_writer_budget_refusal_without_poisoning_items` | | 11.F016 | [#4663](#4663 (comment)) | The append cursor's observed size is bounded by the plan, including Claude's mutable-header delta, so unprobed growth stays visible. | `test_live_batch_support.py::test_append_publication_does_not_hide_growth_after_planning[codex,claude-code]` | | 11.F019 | [#4694](#4694 (comment)) | Hook publication queues `hook_paste_enrichment` debt for the affected old sessions before the hook rows are written, under the same lease. Re-matching is idempotent. | `test_hook_paste_enrichment.py::test_late_hook_publication_schedules_its_old_session_not_the_next_batch[debt_write_fails]`, `::test_replaying_paste_evidence_does_not_move_it_to_a_nearby_prompt` | | 11.F021 | [#4809](#4809 (comment)) | Append ingest checks the write-hold budget at start, per plan, parse, replay, materialize and completion. The typed refusal propagates, and the retained raw stays retryable. | `test_live_batch_support.py::test_append_budget_refusal_retains_retryable_raw_without_poisoning_source` | | 11.F030 | [#5428](#5428 (comment)) | Pinned source-tier evidence is read inside the cursor writer admission, not across the preceding await. | `test_live_sidecar_evidence_cost.py::test_cursor_evidence_is_pinned_after_writer_admission` | | 11.F033, 11.F036 | [#5546](#5546 (comment)), [#5557](#5557 (comment)) | The carrier names its decode failure (`DecodeFailure`). The writer re-raises `PreparedDecodeError`, and `classify_decode_failure` is the single classifier; `_is_json_stream_decode_error` is deleted. | `test_live_watcher_parse_stage_equivalence.py::test_path_worker_decode_failure_reaches_terminal_unknown_evidence` | | 11.F035 | [#5546](#5546 (comment)) | `source_snapshot` copies the source once. Sampling, frontier, parse and seal read that copy, and the seal carries its digest. | `::test_path_worker_binds_provider_parse_and_seal_to_one_snapshot` | | 11.F037 | [#5557](#5557 (comment)) | A stage-owned JSON document without a carrier for its captured bytes is released and deferred (`live.ingest.json_capture_deferred`). It is never decoded under the writer hold, even when preparation raised. | `::test_changed_json_after_preparation_defers_without_writer_decode[both]`, `::test_preparation_exception_does_not_restore_whole_json_writer_decode[discovery,preparation]` | | 11.F039 | [#5250](#5250 (comment)) | Live full intake (writer, prewarm, path worker) and append decode JSONL strictly for every provider. A malformed complete record is `terminal_corrupt_input`, with the raw retained. | `::test_known_provider_jsonl_with_a_malformed_middle_record_is_terminal[in-writer,worker]`, `test_live_batch_support.py::test_append_refuses_a_malformed_middle_record` | | 11.F051 | [#5546](#5546 (comment)) | A `BrokenProcessPool` at submit collects finished futures, replaces an idle broken pool once, and retries the submission. A second break leaves the path deferred. | `::test_a_pool_broken_while_idle_is_replaced_at_the_next_submission[pending_completion]` | | 11.F053 | [#5542](#5542 (comment)) | Every baseline decision uses `_retained_source_path`, which is the provenance sidecar's original path for a staged SQLite snapshot, the same coordinate acquisition retains. | `test_production_baseline.py::test_a_staged_sqlite_import_is_baselined_at_the_path_acquisition_retains` | | 11.F055 | [#5542](#5542 (comment)) | Retention of a grown file is proven by streaming and hashing the baselined prefix of a larger full capture, or of a byte-proven contiguous append chain rooted at one. A blob read fault is retryable. | `::test_a_revision_that_grew_before_intake_is_proven_by_the_larger_retained_capture`, `::test_baselined_and_earlier_accepted_revisions_are_proven_through_an_ordered_append_chain`, `::test_a_chain_that_does_not_reproduce_the_revision_leaves_it_unretained[5 defects]`, `::test_a_retained_blob_read_fault_is_retryable_not_unretained` | | 11.F065 | [#4801](#4801 (comment)) | Cursor reconciliation takes the newest of the newest materialized and the newest decided-unresolved raw, ordered by `(acquired_at_ms, raw_id)`. | `test_live_watcher.py::test_cursor_reconciliation_restores_the_newest_archived_outcome[3 cases]` | | 11.F069 | [#5020](#5020 (comment)) | `WatchSource.path_artifact_kinds` replaces `allow_path_scoped_artifacts`. `codex-state` admits exactly its `session_index` and `prompt_history_log` sidecars. | `test_production_baseline.py::test_the_default_codex_state_source_baselines_only_its_declared_jsonl_sidecars`, `test_ingest_worker_assembly.py::test_codex_retained_root_sidecar_titles_survive_without_a_live_tree` (now via `default_sources()`) | | 12.F001 | [#4883](#4883 (comment)) | An ID-less trajectory call gets the step-keyed id `<message id>:tool`. An ID-less result pairs only with a sole adjacent ID-less call whose declared name agrees. | `tests/unit/sources/parsers/test_antigravity.py::test_trajectory_id_less_tool_steps_persist_their_pairing_and_file_edit`, `::test_trajectory_id_less_result_pairs_only_an_unambiguous_adjacent_call[5]` | | 12.F011 | [#4803](#4803 (comment)) | An assistant text node with `metadata.command` and empty or absent args is a `TOOL_USE` with input `{}`. Its non-JSON text stays on the block. | `test_parsers_chatgpt.py::test_chatgpt_zero_argument_command_is_a_tool_call_its_result_pairs_with[empty,absent]` | | 12.F012 | [#4721](#4721 (comment)) | The project filename is stored as `metadata["name"]`, projected to the derived column `blocks.name`. Markdown, HTML and plaintext media renderers render the carried body (fenced or escaped). | `test_parsers_claude_ai_catalog.py::test_claude_project_documents_render_body_and_file_name_after_persistence` | | 12.F013 | [#4721](#4721 (comment)) | `looks_like_session_document` admits the parser's own project and account-memory detectors. | `test_ingest_shape_admission.py::test_claude_project_export_reaches_parse_project_through_ingest`, `::test_claude_account_memory_export_reaches_its_parser_through_ingest` | | 12.F014 | [#4717](#4717 (comment)) | Relocated cwds lead `working_directories`, latest first. Chunk merge applies the same rule from relocation events. | `test_claude_code_sidecar_evidence.py::test_resume_route_opens_the_relocated_cwd_after_persistence`, `::test_chunk_merge_keeps_the_relocated_cwd_first_across_revisions` | | 12.F018 | [#4870](#4870 (comment)) | An event counts as a replacement only when neither its message link nor a same-session message with its native id exists. The provider id is compared byte for byte. The evidence key is renamed `replacement_events`. | `test_corpus_fidelity.py::test_revision_gate_counts_only_events_that_replace_a_missing_message[4]` | | 12.F020 | [#4886](#4886 (comment)) | A bare `token_usage_record` stating a known counter joins either stream shape without marking it. | `test_ingest_shape_admission.py::test_codex_rollout_with_bare_token_usage_record_ingests_its_usage`, `::test_codex_bare_token_usage_record_needs_a_known_counter` | | 12.F026 | [#5530](#5530 (comment)) | Each OTel identity component escapes `%` and `:` before the join. | `test_otel_genai.py::test_session_identity_components_cannot_run_into_each_other` | The parser and membership changes alter values derived from bytes already observed, so both manual invalidation tokens are bumped: `_PARSER_FINGERPRINT` goes to `live-batched-v4` and `RAW_AUTHORITY_PARSER_FINGERPRINT` to `revision-membership-v5`. **Derived-identity closure.** `devtools schema closure` puts these changed files inside the closure: `archive/artifact_taxonomy/support.py`, `archive/hydration.py`, `archive/revision_authority.py`, `sources/dispatch.py`, `sources/live/{append_ingest,batch,hook_paste_enrichment,parse_prefetch,production_baseline,watcher}.py`, `sources/parsers/{antigravity,codex,otel_genai}.py`, `sources/parsers/claude/{ai_parser,code_parser}.py`, `sources/prepared_jsonl.py`, `sources/source_parsing.py`, `storage/runtime/archive/records.py`, `storage/sqlite/archive_tiers/{archive_tiers_specs,write}.py` and `storage/sqlite/queries/attachment_blocks.py`. This PR must land before a rebuild starts. The only schema change is additive-derived: the `blocks.name` index.db column. It has no durable-tier migration. ## Verification Candidate `4313bff197b1b0420ede997247d9843195c81e69`, on `master` 5d56c3a. - `agentctl job start polylogue pytest_focused --workspace <worktree> -- <64 affected files>` (the selection is every test file the diff touches, plus the route and sibling suites): job 3396: `8 failed, 2569 passed`. All 8 failures are inherited (listed below). An earlier attempt, job 3387, was OOM-killed by systemd-oomd under host memory pressure and was retried unchanged. - `agentctl job start polylogue verify_quick --workspace <worktree>`: job 3388: succeeded, all 12 gates passed. - Inherited failures, classified on a detached `master` worktree with `--on-default-branch` (jobs 3335 and 3356 on 749f608, job 3384 on c950478, job 3401 on 5d56c3a), fail identically on master. They are filed as polylogue-ouv5f: - `test_import_preflight.py::test_unidentified_trajectory_rows_keep_distinct_identities` - `test_retained_tool_output_convergence.py::test_gemini_full_tool_output_survives_the_loss_of_its_source_tree` - `test_artifact_taxonomy.py::test_antigravity_brain_metadata_sidecar_is_rejected_from_live_and_schema_routes` - `test_tool_result_unknown_reason_contract.py` (3 Antigravity cases) - `test_source_laws.py::test_parse_payload_dispatches_claude_code_messages_and_single_records` - `test_revision_replay.py::test_chain_replay_supersedes_equal_frontier_quarantined_membership_head` - All fixtures are synthetic. No operator archive was read or mutated. ## Self-review Checklists re-read: `docs/review/codex-review-guide.md` (including "Do not flag" and the `polylogue/sources/AGENTS.md` review rules) and the generic list in `orchestrate/references/worker-contract.md`. It took four passes over `git diff origin/master...HEAD`: - Pass 1 found the two manual invalidation tokens left unbumped, which the guide names as a finding. They are now bumped. - Pass 1 also found retained routes that still decoded JSONL leniently. Making them strict was tried; pass 2 showed it livelocked the parser census, so it was reverted and filed as polylogue-3p8p7. Pass 2 also found the canonical-ingest vendor stub missing master's `excised` keyword; it now accepts it. - Pass 3 was driven by a focused run, where `test_live_route_interpretation.py::test_a_later_index_revision_re_derives_the_titled_session` failed on the branch but passed on master. A per-file bisection in probe worktrees traced it to `revision_backfill.py`, which had been restored from a newer master than the branch base. Restoring it to the base fixed the failure; the file is now unchanged against master. - Pass 4, on the rebased head, found nothing new. Final pass: 1. ✓ **Siblings and owners.** The ordinary-file and vendor acquisition routes share one item-admission closure (`admit_acquisition`). `classify_decode_failure` is the only decode classifier: grep for `_is_json_stream_decode_error` finds 0 hits. Strict decode covers all four writer sites, both prewarm sites, the path worker and append. The retained replay sites stay lenient on purpose (see Residuals and polylogue-3p8p7), and the ingest-worker validation-mode contract (#1745) is unchanged. Relocated-cwd order has one owner, `order_working_directories`, which serves both the parser and chunk merge. Baseline coordinates have one owner, `_retained_source_path`, which delegates to acquisition's `original_sqlite_source_path`. 2. ✓ **The fix itself.** The new `AntigravitySourceMutationError` is caught per item in `iter_antigravity_language_server_sessions` and becomes a failed path. `WriteHoldBudgetError` is re-raised ahead of the broad `except Exception` in the append and vendor paths. `PreparedDecodeError` subclasses `ValueError`, so existing `ValueError` handlers keep working. The census livelock that strict replay would have introduced is not shipped. 3. ✓ **Memory and limits.** `source_snapshot` and `_prefix_digest` stream in 1 MiB chunks. The baseline prefix proof reads one path's raw rows only for revisions with no exact match. No cap or truncation was added. 4. ✓ **Cost per unit.** Pinned cursor evidence is still one batched read per page. Chain roots are memoized, and identical blob sequences are hashed once. Hook debt targets only the sessions in the carrier. 5. ✓ **Interruption.** Write-hold checkpoints cover every append stage and each vendor item. Paste debt commits before the hook rows under one lease. A refused capture is released and the raw stays retryable, as the budget-refusal tests show. 6. ✓ **Ordering and races.** The protobuf is bound by digest from conversion to capture, and the JSON carrier is bound to one snapshot's digest. Cursor evidence is read under the admitting writer. A growth test grows the file after planning. 7. ✓ **Failure classification.** Blob read faults in the baseline proof raise `ProductionBaselineReadUnavailableError`, which is retryable. Mutation after conversion is a retryable item failure. A deterministic append decode failure goes through `_record_failed_cursor` and its 5-failure exclusion cap, not an unbounded retry. 8. ✓ **Silent outcomes.** Unattempted vendor items carry `REFUSED_UNATTEMPTED_TIME_BUDGET`. A deferred JSON capture emits `live.ingest.json_capture_deferred` and records deferral debt. A malformed live record gets terminal raw evidence instead of a silent skip. 9. ✓ **Cleanup on failure.** A mismatched capture calls `release_refused_capture`. A deferred JSON capture calls `discard_pending_receipt` and discards its carrier. Budget exhaustion calls `blob_store.discard_pending()`. The snapshot directory is removed in `finally`. 10. ✓ **Identity and keys.** OTel components are escaped injectively, and plain spellings are unchanged. The ID-less Antigravity tool id is step-keyed (`<message id>:tool`), not positional. The corpus-fidelity anti-join compares raw provider ids byte for byte (the whitespace case is tested). The `pipeline/ids.py` hash partition is untouched. 11. ✓ **Lossless transforms.** Chunk merge keeps relocation order across revisions. Re-matching paste evidence does not move it to another prompt. The ChatGPT call block keeps its non-JSON text. 12. ✓ **Degenerate inputs.** An empty or fully refused vendor cohort starts no server. A bare usage record without a counter stays refused. A document without a body renders its header alone. 13. ✓ **Consumers.** `allow_path_scoped_artifacts`, `indexed_events` and `_is_json_stream_decode_error` have 0 remaining references (`grep -rn` across `polylogue`, `devtools`, `tests` and `docs`). Every stub of `iter_antigravity_language_server_sessions` and `_antigravity_raw_snapshot` matches the new signatures. `docs/daemon.md` and `docs/maintenance.md` describe the new behaviour. The layering baseline digest for `production_baseline.py` is re-anchored, with an unchanged site count. 14. ✓ **Tests and stubs.** Each finding has a test on its production route (table above), driving `LiveBatchProcessor`, `ingest_append_plans`, `ingest_record`, archive persistence and read-back, or the watcher reconciliation, not a helper. Removing the named fix turns the listed test red: for example, drop `admit_path` and the pass-budget test converts all three items. Clock-driven tests use `frozen_clock`. Stubs follow the changed signatures (item 13). 15. ✓ **Trust boundaries.** No secrets or operator data. The pre-commit secret-scan candidates are pre-existing spans in `revision_backfill.py` and `test_live_batch_support.py`, not lines of this diff. Generic list: (1) every criterion is met on the production path, per the table; (2) siblings are covered in item 1; (3) consumers are covered in item 13; (4) failures are typed, per items 7 and 8; (5) each new test fails without its fix (item 14); (6) the diff carries no private data. ## Residuals - Retained replay still decodes known-provider JSONL leniently, so a rebuild can publish a session without a malformed record that live intake refused. Strict replay decoding was tried in this branch and reverted: the parser census records the parse exception as a `failed` receipt, re-selects it on every pass, and replay planning then never completes. Filed as polylogue-3p8p7, which needs a typed terminal census outcome. - A JSONL record over SQLite's value bound fails as `terminal_corrupt_input`, not under a size-specific reason. - A stage-level preparation exception now defers the page's JSON documents instead of decoding them under the writer (F037). A prefetch that failed deterministically would keep them deferred, with visible debt. - `canonical_archive_ingest` builds its `WatchSource`s with every path rule admitted, as before this change. The `codex-state` sidecar boundary is a daemon-default property. - The Codex hosted review is usage-limited on this PR (its gate reports "not required"), so no hosted code review covered this head. 🤖 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
During a chunked catch-up every chunk paid archive-wide convergence costs, so per-chunk convergence grew with the archive. Whole-archive stages now run once per catch-up (on the last chunk), the archive-wide FTS readiness audit is its own deferred stage, hook-paste enrichment reads only the batch's sessions' sidecars, FTS partition inspection uses the
block_idindex instead of asubstrscan, the raw-authority warmer finds its work in two statements (itsraw_idcollision is fixed by #4693, on which this branch is rebased), the periodic whole-archive FTS sweep waits while catch-up is active, and the convergence ledger now attributes stagechecktime. A separate defect found on the way: a catch-up with no source file modified in the last hour ingested nothing.Problem
Rehearsal (fresh daemon, real sources,
/realm/tmp/work/rehearsal-4): chunk 1 parse 1.1 s / convergence 5.6 s; chunk 150 parse 23.6 s / convergence 62.9 s for 1.9 MB; average over 150 chunks parse 10.6 s, convergence 20.2 s, both growing with archive size (305 sessions, 45,657 messages). Chunk 149 held the writer 103.9 s while its stage ledger summed to 2.5 s.Profile (in-process sampler on a scratch daemon over 400 real files; SQL timed against a copy of the rehearsal's 359-session index):
enrich_paste_from_hooksafter every chunk scanned every sidecar journal inhooks/(371 files, 1.65 GB): 4.5 s warm, 72.9 s once the page cache was evicted. Untimed (outside the stage ledger); this is the size of chunk 149's unattributed time.fts_invariant_snapshot_sync(five whole-table aggregates overblocks/messages_fts_docsize/identity) ran twice per chunk, fromFtsConvergenceOwner._publish_readiness_projectionand_record_fts_freshness_after_insights: 0.6 s per call at 90k blocks, 49 % of scratch convergence time (98 s of 200 s).inspect/publishselected a session's identity rows withsubstr(block_id, 1, length(?)+1) = ? || ':':SCAN messages_fts_identityper key, 10.5 ms at 85k rows vs 0.1 ms for the index range.raw_authority_verdict_cache.check_manyprobed every cohort with two statements (532 cohorts at chunk 150), and its warmup failed 54 times withUNIQUE constraint failed: raw_authority_verdicts.raw_id, re-running the whole-archive check on every following chunk.claude_workflowanddelegation_work_evidencere-read every raw artifact / every delegation row per chunk.maintenance.fts_convergence(whole-archiveinspect_all) held the writer 1061 s across 40 runs (max 132 s); chunks waited 1977 s on the writer in total._catch_upbroke out of its (hot, cold) group loop on the first empty group, so a backlog with no file modified in the last hour was never planned. The after-run reproduced it (0 attempts, 0 cursors,catch_up_completeset after 40 s).Solution
ConvergenceStage.whole_archive;DaemonConverger.converge_batch(whole_archive=False)records such stagesSKIPPED(converged, no debt: their staleness is re-derived from content). The watcher runs every catch-up chunk but the last in that scope. Stages flagged:raw_authority_verdict_cache,claude_workflow,delegation_work_evidence, and the newfts_readiness.make_fts_readiness_stagepublishes the exact archive-wide FTS audit once per pass, afterftsandderived; partition-scoped FTS passes and insight rebuilds no longer publish it._periodic_convergence_checkskips the whole-archive FTS sweep whilewatcher.catch_up_active.enrich_paste_from_hooks(db, session_ids=...)reads only*-<native_id>.jsonlfor the batch's sessions (session_ids_by_pathon append,changed_session_idson full ingest).[key || ':', key || ';')range on theblock_idUNIQUE index ininspect(excess, duplicates) andpublish.find_raw_authority_verdict_cache_work: one pass overraw_sessionsand one overraw_authority_verdicts(master's fix(storage): a re-keyed raw replaces its stale verdict-cache row #4693 writer, which removes a re-keyed raw's stale row, is kept as is).<stage>.checkandhook_paste_enrichmenttimings.Verification
.venv/bin/python -m devtools verify --quick-> all 13 gatesok(format, lint, mypy, generated-surfaces, layering, patterns, doc-commands, schema-manifest, oracle-integrity, testmon-selection, consumer-reachability, timestamp-doctrine, schema-privacy)..venv/bin/python -m devtools test tests/unit/daemon/test_catch_up_chunk_cost.py tests/unit/daemon/test_daemon_convergence.py tests/unit/sources/test_hook_paste_enrichment.py tests/unit/storage/test_fts_derivation.py tests/unit/storage/test_raw_authority_verdict_cache.py tests/unit/daemon/test_convergence_stages.py tests/unit/daemon/test_fts_readiness_fallback.py tests/unit/daemon/test_fts_identity_convergence.py tests/unit/sources/test_live_batch_convergence.py tests/unit/pipeline/test_ingest_batch_fts_repair.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_hot_session_convergence.py tests/unit/daemon/test_daemon_cli.py->1 failed, 378 passed in 252.37son head 1a0ac23 (pueue 1655,.cache/verify/pytest-slot-1672251.log); the one failure,test_daemon_cli.py::test_spool_pending_check_ignores_terminal_cursor_states, is inherited at base 754553b and fixed by test: follow the merged runner rename, corpus width, and read-only cursor probe #4695 (the test lambda lacked**_kwargs)test_chunk_convergence_cost_does_not_grow_with_archive_size(real live-ingest route, archives of 2 and 14 sessions, one 2-file chunk: product SQL statements inside_converge_pathsequal, 2 sidecars read, 0 snapshot calls, no deferred stage in the ledger; reverting any deferral adds two statements per cohort / one per artifact row),test_final_catch_up_chunk_runs_the_whole_archive_stages, converger chunk-scope and check-ledger, sidecar scoping, FTSEXPLAIN QUERY PLANhas noSCANof the identity ledger, raw-authority rebinding and two-statement work finder, cold-backlog catch-up, last-chunkwhole_archive_convergenceflag.Scratch run (same host, same 400 files / 325 MB from
~/.claude/projectsand~/.codex/sessions, 100 catch-up chunks,polylogued runwith an in-process sampler):fts_invariant_snapshot_syncinside the chunk pathmessages/blocksinserts; a full-corpus pytest ran on the host during the after run and was OOM-killed, pueue 1636 exit 137)Per-chunk convergence no longer grows with the archive. End-to-end throughput on this scratch is parse-bound (0.61–0.80 MB/s parse-only), so the 2x-of-parse criterion from polylogue-t4iy5.11.1 still needs the rehearsal driver on a quiet host for its operational proof.
Residuals
_check_fts_readiness_medium) recomputes the exact archive-wide FTS audit on every status payload: 51 s of the after-run's profile, all from/api/statusand the status collector. The rehearsal driver probes status every 60 s; at 5M blocks each probe would take tens of seconds. It should read the freshness ledger thefts_readinessstage publishes.index_parsed_write;messages/blocksinserts with 18 secondary indexes) plus page-cache-miss stalls under host memory pressure; no whole-archive statement was found on the write path.claude_workflowanddelegation_work_evidencestill rebuild from the whole archive whenever they run (once per catch-up now, then per live batch).Beads: polylogue-t4iy5.11.1, polylogue-623q
🤖 Generated with Claude Code
https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid