Skip to content

fix: close 20 Codex P1 findings in sources, backup, browser, MCP - #5835

Merged
Sinity merged 23 commits into
masterfrom
fix/rs02d-codex-p1
Sep 29, 2026
Merged

Sinity merged 23 commits into
masterfrom
fix/rs02d-codex-p1

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Resolves the 23 confirmed Codex P1 findings tracked in polylogue-rs02d: 20 are fixed here, 10.F016 was already fixed on master, and 10.F013 and 10.F017 move to polylogue-g4w5d: acquisition, backup, browser capture, Codex lineage, MCP, mutations, query origins, retained assembly, revision backfill, schemas, and live sources. The lanes of the previous owner were integrated onto current master; this PR adds the missing pieces and the fixes that the integration review found.

Problem

Each row below is a Codex review thread confirmed against master 64a9bd0 by triage run r4-other-sources. The reproductions are in the bead and in each linked thread.

Solution

Finding Thread Disposition Regression test
10.F039 Stream preserved ZIP payload proofs #4439 Fixed: backup replay goes through the streamed unit replay; a candidate holds digests and a reopener, and backup recovery plus raw derivation's blob restoration (#5846) stream the unit's bytes (operations/zip_acquisition_replay.py, operations/archive_backup.py, storage/derived/raw.py) tests/unit/sources/test_export_member_addressing.py, tests/unit/storage/test_blob_integrity.py
08.F016 Authenticate the loopback receiver before releasing its token #4208 Fixed: the native host challenges POST /v1/receiver/attest and releases the bearer only for the bearer-keyed HMAC over a fresh challenge tests/unit/browser_capture/test_native_host.py
08.F015 Bound native credential refresh to one retry #4208 Fixed: one native refresh per health check; a second 401 reports unauthorized browser-extension/tests/background.test.js
10.F006 Preserve fallback identity for ID-less ChatGPT fragments #4188 Fixed: the census keys a document by the id chatgpt.parse gives it, fallback included tests/unit/sources/test_parsers_chatgpt.py
10.F001 Scope parent lookup to the rollout's Codex root #4941 Fixed: the writer reads the parent in the install root of the raw's retained source path; unscoped reads answer only where every root agrees tests/unit/storage/test_agent_thread_state_graph.py, tests/unit/storage/test_topology_hook_authority_conflict.py
10.F003 Rebuild retained rows before rejecting older exports #4941 Fixed: an older export folds the objects it names in as superseded rows ranked by durable receipt order tests/unit/storage/test_agent_thread_state_graph.py, tests/unit/sources/test_codex_state_live_ingest.py
08.F045 Preserve indeterminate daemon submissions #5480 Fixed: MCP no longer swallows DaemonMutationIndeterminateError; the shared serializer returns code="indeterminate", retryable=false and the request id. Sibling: MCP also refused no non-completed envelope (cancelled, timed-out, degraded, disconnected-before-acceptance) and returned it as a result; it now refuses them as the CLI kernel does, and both read one DAEMON_INDETERMINATE_OUTCOMES tests/unit/mcp/test_rs02d_outcomes.py
08.F043 Cover postmortem and pathology MCP projections #4810 Fixed: postmortem_outcome and pathology_outcome in analysis/postmortem.py decide the outcome from coverage receipts; MCP attaches it. The CLI analyze routes carry the same pre-existing gap and are filed as polylogue-t4115 tests/unit/mcp/test_rs02d_outcomes.py
08.F022 Require callers to present the delete preview token #4249 Fixed: the facade delete authorizes only the caller's own mutation.session.delete.preview; API gains prepare_delete_session; MCP write gains prepare_delete_session and requires fields.preview_ref; POST /api/reset requires preview_ref; the self-authorizing delete_session_product is removed tests/unit/api/test_facade_contracts.py, tests/unit/operations/test_mutations.py, tests/unit/daemon/test_daemon_http.py, tests/unit/mcp/test_rs02d_outcomes.py
10.F009 Keep unknown-export available as a public origin filter #4060 Fixed: the unknown-export spec is a public filter origin tests/unit/sources/test_origin_specs.py, tests/unit/daemon/test_http_origin_validation.py
10.F023 Preserve ZIP member order when selecting retained sidecars #4853 Fixed in three parts. (1) Selection ranks the lowest member ordinal within one acquisition time. (2) The source-walk stream stamps one acquisition time per ZIP pass. (3) Retained lookup names a ZIP member by its own basename: it had taken PurePosixPath("<zip>:library_files.json").name, so replay recognized no zipped asset index or asset id at all tests/unit/pipeline/test_ingest_worker_assembly.py
10.F030 Move the exact FTS audit outside the component loop #4982 Fixed: raw-derivation publications pass exact_fts_audit=False; the fts_readiness_binding stage runs the one archive-wide inspection after block writes retire the binding tests/unit/storage/test_raw_observation_derivation.py
10.F034 Restore constant-time raw-to-key lookups #5395 Fixed: census keeps a raw-to-key reverse map tests/unit/sources/test_revision_backfill.py
10.F035 Validate enrichment with the resolved retained provider #5557 Fixed: publication validates under artifact.resolved_provider tests/unit/pipeline/test_codex_retained_state_title_production_route.py
08.F049 Include WAL state in the observation revision #4923 Fixed: a live SQLite member's revision is the digest of its logical export, and its structure comes from that export's header in the same read transaction tests/unit/schemas/test_source_inference.py
10.F015 Skip opaque JSON attachments before ZIP observation #4936 Fixed: opaque-non-applicable members are skipped by the ZIP walk and refused by schema-unit extraction tests/unit/schemas/test_observation_runtime.py, tests/unit/schemas/test_source_inference.py
08.F050 Preserve annotated Claude Code block content #4951 Fixed: conservation plants annotated content unless it repeats the typed body tests/unit/core/test_wire_conservation.py
10.F010 Route .jsonl.txt through JSONL recognition #4365 Fixed: recognition uses the shared is_jsonl_source_path. _PARSER_FINGERPRINT moves to live-batched-v5 so cursors excluded as unsupported under v4 are retried tests/unit/sources/test_origin_specs.py
10.F038 Persist terminal admission receipts before discarding state #4275 Fixed by removal: the AdmissionState machine had no production caller and persisted nothing; the durable accepted outcome is the raw row plus its raw_payload receipt. sources/live/admission.py and its tests are deleted tests/unit/pipeline/test_acquisition_persist_failure_cursor.py, tests/unit/architecture/test_one_intake_route.py
10.F040 Detect the ZIP provider before preserving raw-only members #4853 Fixed: zip_member_admission sniffs the provider before admission; the source walk, retained acquisition, production baseline and the daemon ZIP route all use it tests/unit/sources/test_assembly_chatgpt.py, tests/unit/sources/test_live_batch_support.py
10.F013 Reparse owners when a late sidecar is retained #4850 Not fixed here; tracked in polylogue-g4w5d. The lane's owner reparse failed its own production-route test (the owner reparses with the sidecar visible, but the published block keeps the preview), so it was withdrawn none (the failing test moves to the successor)
10.F016 Parse the same immutable snapshot that is hashed #5546 Already fixed on master by #5823 (633ec18ffc): parse_prefetch detects, bounds and parses one source_snapshot and seals its source_sha256. The lane's copy-based version was dropped in favour of it master's #5823 regressions
10.F017 Fence sidecar inputs with the prepared transcript #5546 Not fixed here; tracked in polylogue-g4w5d. The lane's fenced resolver sealed a digest, but a carrier prepared with an absent or older sidecar still published stale text in its own test, so it was withdrawn none (moves to the successor)

Derived-identity closure members changed (land before a rebuild starts): browser_capture/models.py, schemas/observation.py, schemas/observation_runtime.py, schemas/source_inference.py, sources/codex_state_projection.py, sources/dispatch.py, sources/live/batch.py, sources/live/production_baseline.py, sources/live/watcher.py, sources/origin_specs.py, sources/retained_assembly.py, sources/revision_backfill.py, sources/source_acquisition_components.py, storage/sqlite/agent_thread_state.py, storage/sqlite/archive_tiers/revision_governance.py, storage/sqlite/archive_tiers/write.py, surfaces/payloads.py (all under polylogue/). sources/live/admission.py leaves the closure. Manual token: _PARSER_FINGERPRINT moves to live-batched-v5 (master took v4 in #5823).

Verification

All runs used AgentCTL declared operations. Final head c2335d6116, on master 633ec18ffc.

  • verify_quick (job 3433 at 9e7b3aa4a7, plus the pre-push gate at c2335d6116): verify: PASSED exit=0. The hosted ci/circleci: quick-gate passes.
  • pytest_focused -- -n 4 <184 affected test files> (job 3434 at 9e7b3aa4a7) stopped at the operation's 2 h limit after 5053 passed and 52 failed; the pool ran it on one xdist worker. The 40 files it did not reach ran in job 3556: 745 passed, 24 failed. The fixture change since then was run in job 3566.
  • Every failure in those runs is inherited or load-dependent:
    • They fail identically on master in a detached worktree (pytest_focused -- <ids> --on-default-branch): jobs 3383, 3402, 3411 at 5d56c3a26f, and jobs 3517, 3555, 3560, 3569 at b384edcec9. Examples: test_repository_lifecycle_laws, test_marks_identity_preserving, test_browser_capture (daemon-required facade route), test_query_composition_laws, test_raw_observation_derivation SQLite cases, test_archive_ingest_shared_raw, test_observation_runtime::test_structured_raw_only_sidecar_is_observed_by_normal_source_inference, test_synthetic_wire_support, test_enums::test_origin_values_match_archive_issue_contract, test_tutorial, test_write_path_state_machine::test_cascade_excision_removes_rawless_inherited_child.
    • Or they pass alone on this branch: test_daemon_status FTS readiness (job 3530) and test_daemon_cli::test_daemon_watcher_hints_wake_fair_intake_and_canonical_derivation (job 3558).
  • Failures this branch caused were fixed here: the MCP delete test, the ZIP whole-blob-detection law, the F023 and F034 lane tests, the zip_reacquisition_payload rename, and the Codex contradiction fixture (test_parent_session_accounting, 7 passed in job 3566).

After rebasing onto master 5ebcfe59d2 (head 2707271fa5): #5842 moved currency to receipt order and #5846 moved backup and blob restoration, so the rebase merged those by hand and extended 10.F039 to raw derivation's ZIP blob restoration.

  • verify_quick job 3655 and the pre-push gate: verify: PASSED exit=0.
  • pytest_focused -- -n 4 <24 files covering backup, blob restoration, retained assembly, and Codex lineage> (job 3656): 703 passed, 11 failed. All 11 are inherited or load-dependent. The five test_live_batch_support cases and test_daemon_operation_route::test_cancelled_long_delete_retains_writer_until_blocked_apply_releases hit 120 s timeouts under the loaded pool and pass alone on this branch (jobs 3849, 3890) and on master (jobs 3774, 3889). test_archive_maintenance::test_bench_blob_gc_dry_run_candidate_scan fails on master too (job 3889). The rest were classified above.

Self-review

Checklists re-read: docs/review/codex-review-guide.md and the orchestrate worker contract. Four passes. Findings from passes 1 and 2 (including those the full test run surfaced) were fixed or withdrawn in this PR; the final pass over the rebased diff found nothing new.

Pass 1 findings (fixed): (a) 10.F023 was incomplete: the source-walk stream stamped each record with its own now(), so the ordinal rule never applied off the daemon route (acquisition_streams.py). (b) The daemon ZIP route kept its own copy of the provider sniff (live/batch.py). (c) MCP returned cancelled, timed-out, degraded, and disconnected-before-acceptance envelopes as results, and the CLI kernel and MCP each held their own literal indeterminate set. (d) MCP classified postmortem/pathology gaps inline instead of in one owner. (e) The WIP outcome tests asserted message wording. (f) agent_thread_state._write_rows executed caller-supplied SQL that the census cannot see. (g) _PARSER_FINGERPRINT was not bumped although excluded .jsonl.txt cursors could never revive.
Pass 2 findings (fixed): (h) Running the lane tests showed that 10.F013 and 10.F017 never passed, on the lane or here. They were withdrawn to polylogue-g4w5d rather than shipped. 10.F016 had meanwhile landed on master (#5823). (i) The rebase onto master's backup recover needed exact bytes, which the digest-only unit lacked; recovery now streams through open_replayed_zip_unit. (j) Master added a test on the removed zip_reacquisition_payload. (k) Retained ZIP member names were wrong (10.F023, above). (l) Two tests encoded the old contracts: the MCP delete without a preview, and a whole-blob-detection law that forbade the bounded sniff. (m) The F034 test counted the prefetcher's one per-phase snapshot as a per-member scan.

  1. ✓ Siblings and owners. ZIP admission: grep -rn "sniff_zip_provider(" polylogue shows the single call inside zip_member_admission; the source walk, retained acquisition, production baseline, and daemon ZIP route all use it. The source-only ZIP route deliberately interprets no bytes and keeps declared-path admission. Indeterminate outcomes: one DAEMON_INDETERMINATE_OUTCOMES, read by cli/operation_kernel.py and mcp/server_cutover.py. Insight outcomes: postmortem_outcome/pathology_outcome own the decision; the CLI analyze routes carry the same pre-existing gap, filed as polylogue-t4115. Delete consent: every delete_session_safe( caller passes preview_ref (grep: daemon/http.py, api/archive.py, mcp/server_cutover.py, tests).
  2. ✓ The fix itself. The new MCP refusal path returns typed error_json with the daemon's code; DaemonMutationIndeterminateError reaches _exception_to_error_json, which serializes it (test_shared_exception_boundary_preserves_identity_without_internal_paths). The opener's LookupError, OSError, BadZipFile, and ContentIdentityRefusal are caught at the one recover call and recorded as an unproven error:<type>, not an escape.
  3. ✓ Memory and limits. A container candidate holds digests and an opener, never bytes; recovery streams into stage_exact_blob (test_full_evidence_backup_streams_a_recovered_whole_zip_member refuses any unbounded ZipExtFile.read). No new cap or timeout on valid input; the native host's 5 s idle bound is per socket step, and a slow receiver is retried on the next health check.
  4. ✓ Cost per unit. 10.F034 replaces the per-member linear key scan with a dict. 10.F030 moves the archive-wide FTS audit out of the per-component loop. Residual: read_spawn_parents scans a scope's invoked edges twice per export write (scoped and unscoped); this is proportional to graph size, per export rather than per session, as before.
  5. ✓ Interruption. MCP cancellation still cancels the submitted request id; _daemon_operation's cancel loop is unchanged. The late-sidecar reparse (10.F013) is withdrawn, so this PR adds no new multi-step live state.
  6. ✓ Ordering and races. The acquisition time is one value per ZIP pass. 10.F016's single-snapshot parse is master's (fix(sources): close ez5b9 live-intake and parser P1 findings #5823). The 10.F017 sidecar race stays open in polylogue-g4w5d.
  7. ✓ Failure classification. A live SQLite export fault maps to decode_failed unreadable_source, the same classification an unreadable file already had. Receiver attestation separates receiver_unreachable (retry) from receiver_authentication_failed.
  8. ✓ Silent outcomes. Postmortem/pathology now carry empty/degraded with named gaps (match_cap_exceeded, session_profile_unavailable, session_digest_unavailable, longest_tool_gap_unavailable). An opaque ZIP attachment reports intentionally_excluded rather than vanishing.
  9. ✓ Cleanup on failure. The live snapshot scratch directory is removed in finally; the backup package staging root is removed as before; the ZIP opener closes its ZipFile on every exit.
  10. ✓ Identity and keys. The ChatGPT census key is the parser's own id rule (chatgpt.py:3104,3133). MemberCandidate.open_payload is compare=False, so candidate identity stays its digests. Codex parents are read in the rollout's install root; unscoped reads answer only where every root agrees.
  11. ✓ Lossless transforms. The older-export fold keeps the current export's rows and adds only superseded rows it names; ranking is by durable receipt order.
  12. ✓ Degenerate inputs. Absent and empty tool-results/ digest to the same population, which is also what the retained tier records. A ZIP with only opaque members is intentionally_excluded. A zero-finding complete pathology scope is empty.
  13. ✓ Consumers. Removed or renamed: replay_zip_entry_acquisition_payloads, zip_reacquisition_payload, delete_session_product, sources/live/admission.py, _write_rows; grep count 0 for each in polylogue/tests/devtools/docs. docs/api-parity.md was regenerated; the closure baseline dropped admission.py; docs/atlas/mcp.md, docs/daemon.md, and docs/browser-capture.md describe the new contracts.
  14. ✓ Tests and stubs. Monkeypatch targets follow the moved sniff (test_live_batch_support.py now patches source_acquisition_components.sniff_zip_provider). Each new test names the change that turns it red in its docstring (e.g. per-record clock in test_source_walk_stamps_one_acquisition_time_per_zip_pass, whole-member read() in the backup streaming test).
  15. ✓ Trust boundaries. The bearer never crosses the socket before the receiver proves possession (HMAC with a domain separator). The MCP indeterminate payload exposes only the request id, not the internal path (test_shared_exception_boundary_preserves_identity_without_internal_paths).

Generic list:

  1. ✓ Each of the 20 fixed findings has a named production-route regression in the table; 10.F038 is resolved by removing the unwired state machine, since its durable owner is the raw row plus the raw_payload receipt. 10.F016 cites master's fix(sources): close ez5b9 live-intake and parser P1 findings #5823. 10.F013 and 10.F017 are unmet here and stay open in polylogue-g4w5d, with the evidence from the withdrawn attempt.
  2. ✓ Sibling search, by grep: sniff_zip_provider(, one call site; DAEMON_INDETERMINATE_OUTCOMES, two readers; delete_session_safe(, three production callers, all passing preview_ref.
  3. ✓ Predecessors are deleted with their tests (tests/unit/sources/test_admission.py is removed).
  4. ✓ Failures are typed and visible: MCP errors carry codes; backup recovery records error:<type>/inexact_payload; outcomes carry named gaps.
  5. ✓ Each new test fails when its behavior is removed, as stated in its docstring.
  6. ✓ No secrets or private data: fixtures are synthetic (synthetic-* ids, tmp paths).

Residuals

  • 10.F013 and 10.F017 are not fixed. They are tracked in polylogue-g4w5d with the withdrawn attempt's evidence (bundle and patch in the finisher scratch, and the failing regression tests).
  • CLI analyze --postmortem/--portfolio still emit no terminal outcome (pre-existing): polylogue-t4115.
  • read_spawn_parents scans a scope's invoked edges twice per Codex export write. The cost is proportional to graph size, per export rather than per session.
  • sniff_zip_provider inspects at most _ZIP_SNIFF_MEMBER_LIMIT members. The limit is pre-existing, and the inbox routes now share it.
  • _PARSER_FINGERPRINT moves to live-batched-v5, so the next watcher pass re-examines every live file whose cursor carries v4.
  • Many tests in the affected selection fail identically on master (listed under Verification); they are outside this PR's scope and not fixed here.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-29T16:16:58.770957Z 2a42eb5 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sinity added a commit that referenced this pull request Sep 29, 2026
## Summary

Every latest-raw selection now ranks raws by durable receipt order: the
`rowid` of the raw's newest `raw_payload` receipt in `blob_refs`. It no
longer ranks by wall-clock stamps.

| Bead | Finding | Thread |
| --- | --- | --- |
| polylogue-wbv7k | 20.F008 Order currency by a monotonic receipt
sequence | PRRT_kwDOR7_N4c6hTfVT |

## Problem

Currency among raws of one source was decided by
`raw_sessions.acquired_at_ms`, or by a receipt's `acquired_at_ms`. Both
fail:

- `raw_sessions.acquired_at_ms` is when the bytes were first seen. A
live source that goes A -> B -> A reuses A's content-derived raw id, so
B stays "current".
- A receipt's wall-clock stamp reorders two observations when the clock
rolls back between them.

## Solution

- `raw_receipt_order_sql(alias)` in `archive/revision_authority.py` is
`MAX(blob_refs.rowid)` over the raw's `raw_payload` receipts.
`source_write` re-records the receipt on every observation (`INSERT OR
REPLACE`), and a new row always gets a rowid above every current row, so
this is a monotonic observation sequence. A raw with no receipt ranks
oldest.
- It is applied to every latest-raw selection: `codex_state_projection`,
`retained_assembly`, `sidecar_resolution` (2 queries),
`revision_governance.raw_revision_observation_order`,
`revision_backfill` (sort key and representative raw), the
`source_write` artifact-carrier compare, `raw_retention` (candidate
window and terminal-artifact window), `agent_thread_state`
(`read_provenance`, `incoming_key`, `_RECENCY`),
`claude_workflow_materializer`, `archive_verification` (2),
`source_conservation`, `sampling_db`, `watcher` (2), and `live/batch`
(2).
- `raw_revision_observation_order` and `latest_retained_state_exports`
fell back to `raw_sessions.rowid` for a raw with no receipt. That is a
different sequence from `blob_refs.rowid`. Both now rank such a raw
oldest (order 0), matching `raw_receipt_order_sql`.
- The unused compatibility helper `latest_retained_state_export` is
deleted.
- Docs: the design doc gains R5, and rows S4 and S7 are updated.
- Tests that seeded raws without receipts, or receipts out of
observation order, now record them as acquisition does. That includes
the re-recorded receipt of a returning revision
(`test_prepared_jsonl.py` x3, `TestLogicalHeadsOnly`, the topology
helper).

Derived-identity closure (`devtools schema closure`): these files are IN
and must land before a rebuild starts: `revision_authority.py`,
`sampling_db.py`, `codex_state_projection.py`, `live/batch.py`,
`live/sidecar_resolution.py`, `live/watcher.py`, `retained_assembly.py`,
`revision_backfill.py`, `raw_retention.py`, `agent_thread_state.py`,
`revision_governance.py`, `source_write.py`. These are OUT:
`claude_workflow_materializer.py`, `archive_verification.py`,
`source_conservation.py`.

## Verification

- `agentctl job start --workspace <wt> polylogue pytest_focused -- <61
files: the receipt-order readers' tests>` (job 3490, head 88c79ab,
rebased on 87450e4): 1827 passed, 6 failed.
- All 6 failures are inherited. They fail on master baseline job 3473
(`--on-default-branch`, detached master 87450e4):
`test_artifact_taxonomy::test_antigravity_brain_metadata_sidecar_is_rejected_from_live_and_schema_routes`,
`test_codex_debt_w1::test_convergence_plan_reads_its_declared_probe_set`,
`test_convergence_property_order_invariance::test_convergence_property_ingestion_order_invariance`,
`test_revision_replay::test_chain_replay_supersedes_equal_frontier_quarantined_membership_head`,
and
`test_convergence_property_mutations::test_late_parent_prefix_resolution_has_append_prefix_control`
(2 params). The master-green agent owns them.
- `agentctl job start --workspace <wt> polylogue verify_quick` (job
3491, head 88c79ab): `verify: PASSED exit=0`.

## Self-review

The final pass against `docs/review/codex-review-guide.md`, over the
whole diff against master:

1. Siblings and owners: ✓. `grep -rn 'acquired_at_ms DESC' polylogue`
still finds `archive.py` (raw listing for one raw_id),
`raw_failure_lifecycle.py` (failure samples) and `queries/raw_reads.py`
(list pages). These are display orderings, not currency decisions. Every
currency route uses `raw_receipt_order_sql` or
`raw_revision_observation_order`. The last pass found the two routes
that fell back to `raw_sessions.rowid`, and aligned them.
2. The fix itself: ✓. `write_thread_state_graph` now compares only
`(observation_order, raw_id, blob_hash)`. The wall-clock stamp is
reported, not ranked.
3. Memory and limits: ✓ N/A. The change adds one correlated `MAX` per
candidate row, over the `blob_refs` ref index.
4. Cost per unit: ✓. The correlated subquery is per candidate row inside
queries that already scan those rows.
5. Interruption: ✓ N/A. The change is read-side ordering.
6. Ordering and races: ✓. This is the point of the change: ranking uses
one monotonic sequence, not two clocks. The `rowid` dependency is
documented on `raw_receipt_order_sql`. The source tier is never
VACUUM-ed, and a migration that rebuilds `blob_refs` must copy `rowid`.
7. Failure classification: ✓ N/A.
8. Silent outcomes: ✓ N/A.
9. Cleanup on failure: ✓ N/A.
10. Identity and keys: ✓. Ties break on `raw_id`, and then on
`blob_hash` where one was present before.
11. Lossless transforms: ✓ N/A.
12. Degenerate inputs: ✓. A raw with no receipt ranks oldest on every
route.
13. Consumers: ✓. `latest_retained_state_export` had no callers (`grep
-rn` finds none) and is deleted with its `__all__` entry.
14. Tests and stubs: ✓. `test_receipt_order_currency.py` (state export
and artifact carrier across a clock rollback),
`test_a_later_receipt_wins_even_when_its_clock_rolled_back`, and
`test_snapshot_cleanup_keeps_the_raw_whose_receipt_is_newest_after_a_clock_rollback`
each go red under wall-clock ordering.
15. Trust boundaries: ✓ N/A.

## Residuals

- `rs02d` (`fix/rs02d-codex-p1`, PR #5835) also edits
`agent_thread_state.py`. This PR's hunk there is small, and whichever
lands second rebases.
- Inherited master failures above belong to master-green.

🤖 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]>
Sinity added a commit that referenced this pull request Sep 29, 2026
## Summary

Moves the last CLI writers of durable and derived tiers behind declared
daemon operations, deletes the hand-maintained CLI operation registry,
and fixes four smaller defects on the same surfaces:

- `ops maintenance raw-authority-frontier` now submits a new declared
operation, `maintenance.raw-authority-frontier`. Before this change it
wrote `raw_authority_blockers` rows into `source.db` from the CLI
process.
- `demo verify` and `ops maintenance gc-history` now open read-only
connections. Both used to open writable connections for a read.
- `polylogue/cli/operation_bindings.py` is deleted, together with its
registry test. The daemon-down matrix and the offline-writer test now
take their routes from the CLI source itself.
- `import --daemon-url` is deleted. The command accepted the value and
then discarded it.
- When a read finds no archive, the refusal now names commands that
exist. It used to name a `polylogue ingest` command and an
`--archive-root` option, and neither exists.
- The `session_profiles` writers have one insert shape. The column
probes and the payload serializer for the nonexistent `payload_json`
column are gone.
- `analyze portfolio` decides one terminal outcome in every output
format.

Beads: polylogue-5vps8, polylogue-re6s3, polylogue-l65ry,
polylogue-77tzg, polylogue-t4115 (portfolio half).

## Problem

- **Surviving writers.** I ran every CLI leaf command on a bootstrapped
root with no daemon, recording writable tier opens through the
production interception seam
(`maintenance.offline_guard.refuse_writable_tier_opens`). At 60c373b482
the sweep found:
- `ops maintenance raw-authority-frontier` opened `source.db` writable.
The census it runs publishes durable blockers, and the only guard was
the offline-maintenance residency check.
- `demo verify` opened `index.db`, `source.db` and `user.db` with plain
`sqlite3.connect`, which creates a tier file when it is missing.
  - `ops maintenance gc-history` opened `index.db` with a write profile.
- `status`, `ops status` and the `agents` views open `ops.db` for route
telemetry. That route is filed as polylogue-k5iaf, because it belongs to
the route-observability owner.
- **Registry drift.** `CLI_OPERATION_BINDINGS` was a hand-maintained
mirror that no production code read, yet it drove the daemon-down
matrix's coverage test. The matrix exempted
`maintenance.blob-publications.abandon` and
`mutation.raw-authority-blocker.resolve` on the stated grounds that they
need live ids. Both routes submit before they read anything.
- **Cold-agent error (l65ry AC7).** On a fresh root every read verb said
"run `polylogue ingest` to create the archive, or point --archive-root
at an existing one". Following that advice fails again with "No such
command 'ingest'".
- **Profile writes (77tzg).** Every write serialized a merged payload
for a `payload_json` column that the canonical DDL does not have, and
then discarded it. It also probed `PRAGMA table_info` through a cache
keyed by `id(conn)`, which can go stale when a connection id is reused.
- **Portfolio outcome (t4115).** `analyze portfolio` wrapped a truncated
or partly unprofiled scope in a bare success with exit 0, and an empty
scope also exited 0.

## Solution

- **Frontier census.** `maintenance.raw-authority-frontier` is a `WRITE`
operation with fallback `NEVER`. Its handler
`daemon_mutations.maintenance_raw_authority_frontier` runs
`inspect_raw_authority_frontier` under the daemon writer (`run_write`).
The CLI renders the census the daemon returns.
`maintenance.raw_authority.inspect_frontier`, the predecessor product
function, is deleted. The docs and the archive-debt action text now say
that running the command records the census.
- **Read-only views.** `demo/verify.py` and `demo/constructs.py` open
through `open_readonly_connection` and `attach_readonly_database`.
`read_gc_history` reads the GC ledger tier read-only and resolves that
tier the same way `run_blob_gc_report` does, through
`_gc_control_db_path`.
- **Registry deletion.**
- `test_cli_operation_authority.py` builds its coverage set from every
declared mutating operation name that appears as a literal in
`polylogue/cli`.
- The matrix gains rows for blob-publication abandonment, blocker
resolution, the frontier census and the `ops reset` tier branch
(terminal format only, since that branch has no JSON envelope).
- The only remaining exemptions are `maintenance.demo.augment`, which is
reachable only after a completed ingest, and the context-ledger receipt.
- The offline-writer test derives its rows from the demo commands that
call the guarded seeder.
- The lowering tests from the deleted registry test move to
`tests/unit/cli/test_cli_lowering.py`.
- **Layering.** The CLI mutation-authority rule now also disallows
`polylogue/api/facade_client` and `polylogue/api/ingest`, the facade's
write routes. The CLI baseline stays empty.
- **`import --daemon-url`.** The option, its default helper and every
test argv that passed it are gone. The integration test now asserts the
socket the command really uses.
- **First-run guidance.** `core/errors.py` holds one guidance constant,
`FIRST_RUN_INDEX_GUIDANCE`, used by both the storage open and the CLI
pre-check. It names `polylogue init`, `polylogued run`, `polylogue
import PATH` and `POLYLOGUE_ARCHIVE_ROOT`. A new test resolves each
suggested command against the real Click groups.
- **Profiles.** `SESSION_PROFILE_INSERT_COLUMNS` is the single insert
shape, used by the sync writers and the async bulk writer. The probes,
their caches, `_fallback_profile_payload_json`, `_compose_bindings` and
`_with_fallback_payload_column` are deleted. The round-trip test now
writes into the fresh canonical table.
- **Portfolio outcome.** `analysis.portfolio.portfolio_outcome` names
`match_cap_exceeded`, `session_profile_unavailable` and
`session_digest_unavailable`. The CLI attaches the outcome to the JSON
result, prints the outcome line in the other formats, and exits through
`outcome_exit_code`.
- **Tests on the production route.**
- A zero-match `find ... then delete --yes` against a real daemon
refuses with the empty-selection error and submits no delete operation.
  - `demo verify` and `gc-history` open no writable tier.

**Derived-identity closure.** These changed files are members according
to `docs/plans/schema-closure-baseline.json`, and the `schema-closure`
gate passes: `polylogue/core/errors.py`, `polylogue/storage/blob_gc.py`,
`polylogue/storage/derived/session/storage.py`,
`polylogue/storage/sqlite/archive_tiers/archive.py`,
`polylogue/storage/sqlite/queries/mappers_insight_profiles.py` and
`polylogue/storage/sqlite/queries/session_insight_profile_writes.py`.
This PR moves the derived identity, so it should land before a rebuild
starts.

**Deletion ledger (5vps8 AC12)**, from merge-base to head:

| Area | Added | Deleted | Net |
| --- | --- | --- | --- |
| Production | 185 | 573 | -388 |
| Tests | 402 | 215 | +187 |
| Docs | 16 | 4 | +12 |

- Deleted: `polylogue/cli/operation_bindings.py` (369 lines),
`tests/unit/operations/test_cli_operation_binding_registry.py`,
`maintenance.raw_authority.inspect_frontier`, `import --daemon-url`, two
column-probe helpers with their caches, and the fallback payload
serializer.
- CLI in-process writable-tier opens found by the sweep: 7 commands
before, 4 after. The 4 left are the `ops.db` telemetry route in
polylogue-k5iaf. The declared offline demo writers are excluded from
both counts.

## Verification

- `agentctl job start --workspace <wt> polylogue verify_quick` job 3522
on 6758e81: `succeeded`; every gate passed, including layering, mypy
and schema-closure.
- `agentctl job start --workspace <wt> polylogue pytest_focused -- <39
files>` job 3523 on 6758e81: 787 selected, 772 passed, 15 failed.
Every one of the 15 also fails on master: the baseline runs are job 3505
at 87450e4 and job 3551 at 9e1924a (the two facets snapshot
tests), and the dispatch names
`test_empty_terminal_query_unit_is_an_explicit_outcome` and
`test_every_verb_refuses_a_fresh_root_with_one_machine_envelope` as
inherited. The earlier run on this branch (job 3485) failed on the
GC-history ledger tier, the obsolete offline frontier refusal test and
my zero-match test's expected exit code; all three are fixed in
58fbc48. Its demo and daemon-route timeouts did not recur in 3523,
and `demo receipts` finishes in 10 s outside the pool.
- Anti-vacuity for re6s3 AC5, job 3487: a scratch tree at 60c373b482
with a local `user.db` write added to `submit_cli_mutation`'s refusal
branch turned 17 matrix rows red. This was an uncommitted experiment,
not a candidate.
- Master baseline, jobs 3505 and 3551 with `--on-default-branch`: these
failures reproduce on master and belong to master-green:
  - `test_profile_mutation_census_matches_the_declared_owners`
  - `test_archive_debt_*codex*` (2)
  - `test_storage_one_shot_readers_cannot_mutate` (2)
  - 5 `test_demo_command` receipt and tour tests
  - `test_empty_terminal_query_unit_is_an_explicit_outcome`
  - `test_every_verb_refuses_a_fresh_root_with_one_machine_envelope` (2)
  - `test_plain_cli_snapshots` facets tests (2)
- Writer sweep (every CLI leaf command, no daemon, recording writable
tier opens) on 6758e81: 4 commands still open a tier writable, all
for `ops.db` route telemetry (`status`, `ops status`, `agents status`,
`agents work-item`).

## Self-review

Last pass: pass 3, against `docs/review/codex-review-guide.md` and the
generic worker-contract list. Pass 1 found the GC-history ledger
regression and the obsolete offline-frontier test. Pass 2 found a
private scratch path in a filed bead and scrubbed it. Pass 3 found
nothing new.

Review-guide checklist:

1. **Siblings and owners.** ✓ I looked for each class of write on every
CLI command, not only on the routes the beads named. The writer sweep
ran every leaf command on a bootstrapped root and found 7 commands
opening a tier writable. This PR fixes 3 of them; the other 4 are the
`ops.db` telemetry route in polylogue-k5iaf. The first-run text now has
one owner, `FIRST_RUN_INDEX_GUIDANCE`, used by the storage open and the
CLI pre-check. The remaining `polylogue ingest` mentions in
`operations/import_*` docstrings are corrected. One remains in
`sources/live/watcher.py`, a closure file on the live intake route that
I left to its owner. The column-probe class outside profiles is filed as
polylogue-l91i8.
2. **The fix itself.** ✓ The new handler's exceptions become typed
operation failures, and `mutation_refusal` renders them.
`_gc_control_db_path` is shared with `run_blob_gc_report`, so the report
and the history view choose the same ledger tier; its probe uses the
existing read-only helper.
3. **Memory and limits.** ✓ No new buffers. The census result is the
existing bounded sample (`to_dict(sample_limit=100)`). The frontier
operation's 300 s client deadline matches the other maintenance
operations; when a census runs past it the client reports
`indeterminate` and the daemon finishes the census. It is never reported
as failure or rolled back.
4. **Cost per unit.** N/A: no paging, loop or query changes.
5. **Interruption.** ✓ The census runs inside `run_write` under the
daemon writer. A lost client cannot release writer ownership, and the
census transaction is the storage owner's, unchanged.
6. **Ordering and races.** ✓ Moving the census into the daemon removes
the CLI race against a daemon that starts during the census. The census
opens its own connection while the operation's pinned snapshot is only a
reader, which is fine under WAL.
7. **Failure classification.** ✓ `demo verify` now reports a missing
tier as `archive unreadable`, through its existing `sqlite3.Error`
branch, instead of creating an empty file. `read_gc_history` still
raises on a missing ledger.
8. **Silent outcomes.** ✓ Portfolio decides one outcome in every format
and maps exit codes through `outcome_exit_code`. Postmortem stays
undecided until #5835 provides its owner (see Residuals).
9. **Cleanup on failure.** N/A: nothing acquired.
10. **Identity and keys.** N/A: no hash, ID or continuation changes.
11. **Lossless transforms.** ✓ On the canonical table the profile insert
binds exactly the columns it bound before: `has_content_hash` was true
and `has_fallback_payload` false. The new test round-trips every payload
through `_row_to_session_profile_record`.
12. **Degenerate inputs.** ✓ An empty portfolio scope is `empty` with
exit 2 (test). A zero-match delete refuses and submits nothing (test
through a real daemon).
13. **Consumers.** ✓ Each removed name was grepped across the
repository: `operation_bindings` (2 test consumers moved),
`inspect_frontier` (1 test replaced), `--daemon-url` on import (5 test
argvs and the integration test), `session_profile_insert_columns` /
`table_has_column` (2 production and 2 test consumers). No generated
reference lists operations or import options (`docs/cli-reference.md`
covers only top-level help).
14. **Tests and stubs.** ✓ Every new test drives the Click CLI or the
daemon, and each docstring names the change that turns it red. re6s3 AC5
was run for real: job 3487, 17 rows red.
15. **Trust boundaries.** N/A: no auth, secrets or file-mode changes.

Generic list:

1. **Criteria on the production path.** ✓ Every satisfied criterion was
checked on the production route; the unmet ones are listed with their
blockers in Residuals.
2. **Each class at every site.** ✓ See items 1 and 13; the sweep and the
greps are the search.
3. **Consumers and predecessors.** ✓ See item 13.
4. **Typed, visible failures.** ✓ See items 7 and 8.
5. **Tests fail when the behaviour goes.** ✓ See item 14.
6. **No private data.** ✓ The diff, PR text and filed beads carry no
private path or personal data; the scratch path in polylogue-ctha5 was
removed in pass 2.

## Residuals

- polylogue-5vps8 AC3: a from-empty build still issues per-session point
deletes (polylogue-ctha5, with probe evidence). That fix belongs in the
shared session writer, which is in the closure.
- polylogue-5vps8 AC13: the isolated lifecycle rehearsal was not run.
- polylogue-77tzg AC4: the legacy fallback readers
(`mappers_insight_fallback` hydrators and the evidence/inference
fallback in `archive.py`) remain. About 18 test modules insert raw
`session_profiles` rows with `'{}'` payloads and rely on them, so
removing the readers needs its own fixture sweep. The same class at
other sites is filed as polylogue-l91i8.
- polylogue-t4115: the postmortem half waits on `postmortem_outcome`,
which PR #5835 adds; that PR was still open when this one was opened.
- polylogue-k5iaf: CLI route observations still write `ops.db`
in-process.
- The frontier census now runs with the daemon's 300 s client deadline.
Before this change it ran unbounded in the CLI process. On an archive
whose census takes longer, the command reports `indeterminate` while the
daemon finishes the census.
- `mutation.facade.context_ledger` stays a best-effort receipt whose
refusal the read views drop. It is exempt from the matrix, with the
reason recorded there.

🤖 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]>
@Sinity Sinity changed the title fix: close 23 Codex P1 findings in sources, backup, browser, MCP fix: close 20 Codex P1 findings in sources, backup, browser, MCP Sep 29, 2026
@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 19:37
Sinity and others added 19 commits September 29, 2026 23:10
Backup verification replayed a preserved ZIP member by reading it whole
and cached every replayed unit's bytes for the pass. Replay now goes
through the one streamed unit replay acquisition already uses: whole
members are hashed in chunks, split elements carry their digests, and a
cached candidate holds only its byte and value identities.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The source-walk acquisition admitted ZIP members under the provider its
source name spells, which is UNKNOWN for an import inbox; the member
validator then related no path to an artifact rule and dropped raw-only
export members such as a ChatGPT file-*.png asset. The provider is now
resolved before admission the way the daemon's inbox ZIP route resolves
it: sniffed from the safe JSON members, else declared artifact paths with
each member hinted by its own declaration.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Plain-file acquisition built an AdmissionState that published one OBSERVED
receipt into the diagnostic observation stream and was discarded; nothing
called finish(), nothing persisted a receipt or frontier, and continuation()
had no production caller, so it could only ever answer REACQUIRE. The
accepted outcome already has a durable owner: the raw row and its
raw_payload receipt committed by the source-tier write, which a restart
re-acquires against. The unwired state machine is removed; the retained
blob identity it carried moves to the acquisition components.

Retained acquisition resolves its ZIP provider through the same
zip_member_admission helper as the source walk.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Retained sidecar lookup ranked one path's observations by receipt order
alone, so a ChatGPT export ZIP with two library_files.json members bound
the later-received member on replay while live assembly binds the first
in central-directory order. Within one acquisition the lowest recorded
member ordinal now wins; a newer acquisition still supersedes an older
one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ports

The session writer asked for a Codex child's projected parent without a
scope, and the unscoped read took the most recently observed root's graph:
with two roots naming different parents for one thread, a rollout from
root A resolved root B's parent. The writer now reads the parent in the
install root of the published raw's retained source path, passed as
explicit data so a write that does not consult hook evidence still knows
the root. The revision-governed and batch writes supply it, a prepared
write pins the path it was prepared with, and a revised export re-derives
archived children in their own roots. A reader with no rollout path gets
a parent only where every root agrees.

The graph writer also dropped an export older than the current one, while
readers serve superseded rows retained from earlier exports, so a replay
visiting a newer export first lost titles and spawns that live order kept.
An older export now folds the objects it names in as superseded rows, each
holding the value of the newest export by durable receipt order that
names it, so the retained rows do not depend on arrival order.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The production baseline carried its own copy of the inbox ZIP provider
sniff and declared-path admission. It now uses zip_member_admission, the
decision the source walk and retained acquisition make, so the baseline
cannot drift from what acquisition admits.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Native bootstrap (08.F016): the native host now challenges the endpoint's
new POST /v1/receiver/attest and releases the bearer only when the answer is
the bearer-keyed HMAC over the receiver id and a fresh challenge, so a
process holding the loopback port while the daemon is stopped neither
receives nor can answer for the bearer. Unanswered endpoints report
receiver_unreachable; a fresh profile shows them as offline.

Extension refresh (08.F015): a 401 health probe asks the native host for
the current bearer at most once per health check; a second 401 is reported
as unauthorized instead of re-bootstrapping forever.

Session delete (08.F022): mutation.facade.delete_session requires the
caller's own mutation.session.delete.preview reference and authorizes that
exact preview for the authenticated principal, refusing unowned, foreign,
cancelled, consumed, expired, or stale previews before any effect. The API
gains prepare_delete_session; delete_session and delete_session_safe and
POST /api/reset require preview_ref. The dead self-authorizing
delete_session_product is removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rovider

- Raw-derivation publications skip the archive-wide exact FTS audit; each
  replayed session keeps its own proof and the fts_readiness_binding stage
  runs the one global inspection after the burst (10.F030).
- Census keeps a raw-to-key reverse map instead of scanning every key
  (10.F034).
- Prepared retained carriers are validated under the provider the worker
  resolved, so an unknown-export Codex raw can publish (10.F035).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
- source inference: a live SQLite member's revision is the digest of its
  whole-database logical export, so a WAL-only commit moves the revision
  and the cache; its structure is read from that export's header in the
  same read transaction (08.F049).
- ChatGPT export attachments declared opaque-non-applicable are never
  schema evidence: the ZIP member walk skips them and reports exclusion,
  and schema-unit extraction refuses declared opaque paths (10.F015).
- conservation plants a Claude Code text/thinking/tool-use block's
  annotated content unless it repeats the typed body; the synthetic
  generator makes that field an alias so witnesses stay conservable
  (08.F050).
- the ChatGPT census keys id-less documents by the parser's fallback
  session id (10.F006).
- unknown-export is a public filter origin (10.F009).
- Hermes source-class recognition reads .jsonl.txt as JSONL through the
  shared suffix rule (10.F010).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Thread-state graph rows are written by literal statements the durable-write
census can classify; the api-parity reference is regenerated; test helpers
are typed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
…envelopes

postmortem_outcome and pathology_outcome decide the terminal outcome from
the bundle's own coverage receipts, so MCP no longer classifies gaps inline.
MCP privileged operations now refuse every envelope that did not complete
(cancelled, timed-out, degraded, disconnected-before-acceptance) as the CLI
kernel does, and both read one DAEMON_INDETERMINATE_OUTCOMES set.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
…ission

Retained sidecar selection binds the lowest member ordinal within one
acquisition time, but the source walk stamped every record with its own
clock, so duplicate members of one export were still ordered by read time.
The source-walk stream now stamps one time per container pass, as the
daemon ZIP route already does. The daemon ZIP route resolves its provider
and member hints through zip_member_admission like every other route.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
…anges

Hermes .jsonl.txt traces are now JSONL, so a cursor excluded as an
unsupported source class under v3 would otherwise never be revived for an
unchanged file; transcripts published before their tool-results sidecar was
retained are reparsed against it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
…sniff

The MCP executor route test now prepares the delete it applies, as the
facade requires. The whole-blob detection law refuses whole-member bytes,
not the bounded prefix the inbox provider sniff reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Retained ChatGPT sidecar lookup took PurePosixPath(<zip>:<member>).name,
which is '<zip>:library_files.json' for a zipped export, so replay never
recognized a zipped asset index or an asset member's id and bound nothing
where live assembly binds the first member. The member's own name now
decides. The F034 census test counts per-member key scans, allowing the
prefetcher's one snapshot per phase.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity and others added 4 commits September 29, 2026 23:11
A Codex thread id names a thread only within its install root (10.F001), so
the contradiction fixture's graph must share the rollout's scope.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Raw derivation's blob restoration (#5846) read the whole replayed member
into memory, the same defect 10.F039 fixes for backup. It now stages the
resolved unit's bytes from its reopened member stream.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity
Sinity merged commit 017f9b4 into master Sep 29, 2026
3 checks passed
@Sinity
Sinity deleted the fix/rs02d-codex-p1 branch September 29, 2026 21:25
Sinity added a commit that referenced this pull request Sep 29, 2026
…#5844)

## Summary

Delete three predecessors of the one publication route and move message
FTS settlement into the publication that writes it.

- The daemon census parse stage is gone: `CensusParseStage`, the
`polylogue/daemon/parse_prefetch.py` shim, `RawParsePrefetchCache` and
every `prefetch_cache` parameter, the four `daemon_parse_stage_*`
settings, their docs and baseline entries (polylogue-rykzt, reusing
salvage commit bcfb374).
- The live watcher's byte-keyed prefetch cache is gone:
`LiveParseStage.warm`, `LiveParsePrefetchCache`, `LiveParseCandidate`,
`live_parse_worker`, `live_parse_and_shard_worker` and
`batch._live_parse_stage_candidates`.
- Revision replay and membership replay repair the FTS rows of the
session they write in the same transaction. Every ingest batch runs the
FTS repair effect before its commit. The caller-side deferral and
after-pass repairs are removed (6xcqj F07).

## Problem

- Nothing in `polylogue/` or `devtools/` constructed `CensusParseStage`
or `DaemonParseStage`. Every `RawObservationReplacement` was built with
`payload=None`, so the `RawParsePrefetchCache` plumbing never received a
cache. The live `warm()`/`LiveParsePrefetchCache` path had no production
caller either. The watcher prepares through
`warm_paths`/`prefetch_paths`, and the writer consumes sealed carriers
through `pop_path`. Only tests drove these paths, and one test
(`test_prefetch_cache_thread_safety.py`) stress-tested a cache that
production never filled.
- The live batch passed `defer_fts=True` to `apply_raw_revision_replay`
and `apply_raw_membership_classification` with
`manage_transaction=True`. Each write therefore committed its blocks
without FTS rows. The batch then repaired all session ids in a separate
transaction after its loop. A kill between those points left sessions
committed but unsearchable, with nothing recording the missing rows. The
Codex state branch (`archive.commit()` mid-loop) committed earlier
records in the same state.
- The ingest batch took a `repair_message_fts` switch. `parse_from_raw`
turned it off whenever there was no execution coordinator, then called
`repair_message_fts_bulk` once after all batches. Each batch commit in
between published sessions without FTS rows.
- `repair_message_fts_index_sync(record_exact_snapshot=...)` and
`suspend_fts_triggers_sync(mark_stale=...)` accepted parameters they
discarded (`del record_exact_snapshot`, `del mark_stale`), "retained for
caller compatibility".

## Solution

- Cherry-picked bcfb374 and resolved it against master. The salvage
branch still carried `daemon_parse_stage_warm_timeout_seconds` and
aar35's retired Drive/hook rows. Master's stall-report rename and aar35
deletions were kept. The remaining census-stage references in the
legacy-prose-logging baseline and in
`docs/design/convergence-simplification-inventory.md` were updated.
- Deleted the live cache classes and functions, the stage's `cache` and
`shard_build_failure_count`, and the tests that only drove them. The
equivalence tests that asserted `len(stage.cache) == 0` still run
through the path route, which they already used.
- `revision_governance.apply_raw_revision_replay` and
`apply_raw_membership_classification` now always call
`repair_message_fts_index_sync` for the written session (except under
`bulk_build`, which rebuilds FTS archive-wide at readiness).
`assert_session_fts_exact_sync` loses `allow_pending`. `defer_fts` is
removed from both functions, the two `ArchiveStore` wrappers,
`publish_ingest_cohort` (no caller passed it) and the live batch. The
batch's after-loop repair is deleted.
- `repair_message_fts` is removed from `process_ingest_batch`,
`_process_ingest_batch_sync`, `_commit_sync_ingest_side_effects`,
`ParsingService.parse_from_raw` and `parsing_workflow.parse_from_raw`.
`repair_message_fts_bulk`, `ParseResult.fts_repair_session_ids` and the
now-unused `_ConnectionBackendLike` protocol are deleted with them. The
write-effect payload key stays for its one remaining user: session
deletion, which clears FTS rows itself before the rows they index are
gone.
- The discarded `record_exact_snapshot` and `mark_stale` parameters are
removed along with their callers.

Derived-identity closure (`devtools schema closure`). These changed
production files are IN: `polylogue/archive/write_effects.py`,
`polylogue/config.py`, `polylogue/pipeline/parsed_tree_size.py`,
`polylogue/pipeline/services/ingest_batch/_models.py`,
`polylogue/sources/live/batch.py`,
`polylogue/sources/live/parse_prefetch.py`,
`polylogue/sources/live/watcher.py`,
`polylogue/sources/revision_backfill.py`,
`polylogue/storage/fts/fts_lifecycle.py`,
`polylogue/storage/sqlite/archive_tiers/archive.py`,
`polylogue/storage/sqlite/archive_tiers/revision_application.py` and
`polylogue/storage/sqlite/archive_tiers/revision_governance.py`. The
deleted `polylogue/sources/census_parse_stage.py` and
`polylogue/daemon/parse_prefetch.py` also leave it. This PR moves the
candidate derived schema identity, so it must land before any rebuild
starts.

## Verification

Final head 0a9e1f1 (rebased onto 5ebcfe5):

- `agentctl job start --workspace
/realm/worktrees/polylogue-publication-path polylogue verify_quick`: job
3702, `verify: PASSED exit=0` at head 0a9e1f1.
- `agentctl job start --workspace
/realm/worktrees/polylogue-publication-path polylogue pytest_focused --
<45 files>`: job 3703 at head 0a9e1f1. The full selection had 16
failures under a narrowed one-worker pool slot. devtools reran them
alone: `11 failed, 5 passed`. The files are every edited test file, plus
each test module that names a changed symbol
(`apply_raw_revision_replay`, `apply_raw_membership_classification`,
`publish_ingest_cohort`, `repair_message_fts_index_sync`,
`suspend_fts_triggers_sync`, `assert_session_fts_exact_sync`,
`parse_from_raw`, `LiveParseStage`, `write_effects`, the parse-stage
settings), plus `test_config.py`, `test_config_inventory.py`,
`test_live_ingest_kill_recovery.py`,
`test_incremental_retained_cold_route_characterization.py` and
`test_raw_observation_derivation.py`.
- All 11 remaining failures are inherited. The same 11 ids fail on
master 87450e4 in baseline job 3478 (`11 failed, 36 passed`), with
the same assertion lines:
`test_ingest_governance::test_membership_that_becomes_eligible_after_preparation_defers_publication`,
`test_bulk_build_lifecycle::test_fresh_shard_build_finishes_equivalent_to_retained_indexes`,
`test_config::test_flat_daemon_bind_keys_are_refused`,
`test_hermes_raw_identity::test_identical_hermes_profiles_persist_and_reprocess_independently`,
`test_revision_replay::test_chain_replay_supersedes_equal_frontier_quarantined_membership_head`,
`test_profile_writer_retirement::test_profile_mutation_census_matches_the_declared_owners`,
the four `test_raw_observation_derivation` publish tests and
`test_raw_materialization_parse_stage_equivalence::test_two_accepted_revisions_survive_one_periodic_profile_pass`.
They belong to master-green.
- Earlier heads timed out under pool load on other tests. In each case
the test passed alone on the unchanged tree: for example
`test_accepted_marker_inputs::test_deferred_raw_does_not_publish_marker_witness_or_pending_carrier`
took 16.42 s in job 3547, against 14.49 s on master in job 3542.
- The FTS postcondition is pinned on the production route.
`test_live_batch_support.py` drives `_ingest_full_paths_sync` and
asserts `messages_fts` rows exist with no caller repair. Removing the
replay's inline repair zeroes `indexed`.

## Self-review

Final pass: pass 3, against `docs/review/codex-review-guide.md`, the
nested `polylogue/sources/AGENTS.md` and `polylogue/storage/AGENTS.md`,
and the generic list in the orchestrate worker contract. Pass 1 found
four problems, and all four were fixed. Resolving the salvage branch's
conflict with "theirs" had restored
`live_watcher_parse_stage_warm_timeout_seconds` into
`_FLOAT_CONFIG_KEYS`; this was fixed in 176d9cf. A stall-field test
still imported the deleted `_completed_reporting_stalls`, which mypy
caught. A fake of `_process_ingest_batch_sync` still declared the
removed `repair_message_fts`. The focused run failed collection because
a benchmark conftest was registered twice, so the benchmark was taken
out of the selection. Pass 2 found that the stall assertion moved onto
`warm_paths` did not hold on that schedule, so it was reverted. Pass 3
found nothing new.

- [x] 1 Siblings and owners. The FTS rule is now "the replay repairs the
session it wrote". It covers both governance publishers
(`revision_governance.py`: `git grep -c
'repair_message_fts_index_sync(store._conn, \[session_id\])'` = 2) and
the ingest-batch write effect. Every `defer_fts=` caller was found by
grep (2 in `live/batch.py`, 0 elsewhere) and removed, along with the
pass-through in `publish_ingest_cohort`, which no caller set. The
session-delete path keeps `repair_message_fts: False` because it clears
the FTS rows itself before the delete (`archive.py`, delete path). It is
the only remaining user of the payload key.
- [x] 2 The fix itself. The inline repair runs inside the replay's own
transaction, before `store.commit()` (manage_transaction=True) or the
caller's batch commit. No new exception type was added.
`assert_session_fts_exact_sync` now always runs its parity check outside
`bulk_build`, so a missed repair raises there instead of passing as
"pending".
- [x] 3 Memory and limits. No new buffer. The deleted
`LiveParsePrefetchCache` and `RawParsePrefetchCache` were byte-budgeted
in-memory caches of parsed trees. Nothing replaces them, because
production never filled them.
- [x] 4 Cost per unit. FTS repair is per session in both the old and new
code (`replace_fts_partition_sync` per id). The live batch paid one
extra transaction per pass before and now pays none. A session written
twice in one pass is repaired twice, which is the same cost as every
non-deferring caller already had.
- [x] 5 Interruption. This is the point of the change. A kill after a
replay commit used to leave blocks without FTS rows until an after-loop
repair ran, and nothing recorded that. The rows now commit together.
`test_live_ingest_kill_recovery.py` is in the selection.
- [x] 6 Ordering and races. N/A for the deletions. For FTS, the repair
and the write share the writer connection and transaction, so no other
writer can interleave between them.
- [x] 7 Failure classification. A repair failure now propagates out of
the replay and rolls back the write through the existing `except` paths,
instead of failing after the commit.
- [x] 8 Silent outcomes. `ParseResult.fts_repair_session_ids` and
`repair_message_fts_bulk` are gone. No count or receipt reported them.
- [x] 9 Cleanup on failure. The shard and attempt cleanup in
`LiveParseStage._shutdown_locked` is unchanged apart from the removed
`cache.discard_all()`, whose cache no longer exists.
- [x] 10 Identity and keys. No hash or ID formula changed. The derived
schema identity moves, because twelve closure-IN files change (listed
above).
- [x] 11 Lossless transforms. N/A: no copy or replay path changes what
it carries.
- [x] 12 Degenerate inputs. `repair_message_fts_index_sync` still
returns early on an empty id list, and a replay always has exactly one
session id at that point (it raises before then otherwise).
- [x] 13 Consumers. Grep across `polylogue devtools tests` finds 0 hits
each for
`LiveParseCandidate|LiveParsePrefetchCache|live_parse_worker|DaemonParseStage|CensusParseStage|census_parse_stage|RawParsePrefetchCache|prefetch_cache=|repair_message_fts_bulk|defer_fts|allow_pending|record_exact_snapshot|mark_stale|repair_message_fts=|daemon_parse_stage_`.
Docs updated: configuration.md (keys and env rows), daemon.md
(parse-parallelism section), the historical design inventory (dated
note), the legacy-prose and layering baselines.
`docs/design/daemon-core.md` §9 still names
`_live_parse_stage_candidates`; it is a measurement record at pinned
commit `0f1d1cb09`, so it was left alone.
- [x] 14 Tests and stubs. Removed tests only drove deleted code: the
daemon stage suite, the cache thread-safety test, the byte-keyed warm
tests, the after-pass bulk-repair test, and the bulk-target merge test.
Every monkeypatched fake of a changed signature was updated
(`repair_message_fts_index_sync` fakes lost `**kwargs`, and the
`_process_ingest_batch_sync` fake lost `repair_message_fts`). The FTS
change is pinned on the production route by
`test_live_batch_support.py`: removing the inline repair zeroes
`indexed`.
- [x] 15 Trust boundaries. N/A: no secret, path or permission handling
changed.
- [x] Worker 1: criteria met on the production path. rykzt's deletion
and 6xcqj F07 are met on the production route. The unmet criteria are
named with their blockers under Residuals.
- [x] Worker 2: every site of the class. See items 1 and 13, and the
grep counts there.
- [x] Worker 3: predecessor deleted. Deleted: the census stage, its
shim, its config keys, docs and tests; the live cache and its tests; the
FTS deferral flags; the bulk repair; and the ignored parameters. No
alias remains.
- [x] Worker 4: failure paths typed and visible. See item 7.
- [x] Worker 5: tests go red without the behavior. See item 14.
- [x] Worker 6: no secrets or private paths. Fixtures are unchanged
synthetic data. The PR text cites only worktree paths and job ids.

## Residuals

- polylogue-9m93s INTAKE-PREP-1: `prepare_jsonl_blob`'s collected branch
(`parse_payload(provider, list(records))`) still holds every record of a
non-stream JSONL file, and of any `.json` shape no streaming branch
claims (including bundle providers when a `prepare_sessions` cohort
callback is set). Deleting it needs a bounded branch per remaining
shape; deleting it outright would refuse valid input.
- polylogue-i07pw AC1: the writer still parses records inline when they
have no path carrier (ZIP members, partial prefixes, browser captures,
the Hermes and Codex SQLite branches).
- polylogue-6xcqj: F33 (the positive-evidence rule is still applied per
caller on the in-process parse routes) and the AC3 inline-parse
remainder are still open.
- `RawObservationReplacement.payload` stays typed `None`, because the
kernel's `ReplacementLike` protocol requires the field.
- The sinnix overlay patch
`flake/overlay/package/polylogue-status-document.patch` still targets
aar35's removed spool plumbing (another repository; recorded on
polylogue-aar35).
- The open PR #5835 touches seven of these files. A trial merge (`git
merge-tree`) is clean.

🤖 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant