Skip to content

fix: settle corrupt replay input; one owner for retained blob sources - #5846

Merged
Sinity merged 1 commit into
masterfrom
fix/cold-build-correctness
Sep 29, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/cold-build-correctness

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Summary

The fresh build must never keep the wrong input or report a file it did not admit. This change covers seven reindex-2026 beads, grouped by mechanism.

Group Bead Outcome
Admission outcomes polylogue-3p8p7 Retained replay decodes JSONL strictly, over the same complete-record prefix the live path worker parses. A decode refusal settles as terminal corrupt input with a complete census receipt.
Admission outcomes polylogue-xf8qp Corrupt and truncated captures are settled exclusions (corrupt_input), not admissions. The batch metrics, the intake adapter, canonical ingest and the attempt disposition all agree.
ZIP/blob ownership polylogue-ihq32 One function, retained_blob_source_candidates, decides which source window proves a retained blob. Backup recoverability and raw-derivation restoration both call it.
ZIP/blob ownership polylogue-0y17g Raw derivation restores an absent ZIP-member blob from its container, through acquisition's ZIP admission.
ZIP/blob ownership polylogue-zrb9y A <container>:<member> path is split only at a real ZIP container, in blob integrity, archive debt, ZIP reacquisition and backup.
ZIP/blob ownership polylogue-ltj6c One ZIP member refusal-debt record, <zip>:#<ordinal>:<member> with a typed reason, for both content-identity and foreign-origin refusals.
Limits polylogue-qlvyu The 512-per-message in-memory sandbox attachment cap is removed. So is its sibling, the directory-asset size refusal on the ChatGPT route.

polylogue-5hcbg and polylogue-8j9rh were already delivered by #5834 (c950478). This PR does not touch them.

Problem

  • 3p8p7. Replay decoded known-provider JSONL leniently (_parse_one_raw, _parse_stream_raw, and prepare_retained_jsonl_artifact without strict_jsonl_records). A rebuild therefore published a session missing a malformed record that live intake had refused. Strict decoding alone livelocked the census: a census worker's error crossed the thread boundary as a string and was rebuilt as RuntimeError, which recorded a failed receipt, and uncensused_historical_revision_raw_ids re-selects failed receipts on every pass.
  • xf8qp. The truncated-not-growing branch of _ingest_full_records_archive records TERMINAL_CORRUPT_INPUT but left the path in the succeeded set. The in-writer terminal decode branch did the same. The intake outcome was therefore ADMITTED, and the batch counted the bytes as ingested. A Claude Code capture with a malformed record also failed claude_semantic_frontier_for_prefix, and its cursor write went stale every pass. That made the page RETRYABLE forever, reproduced by the new adapter test.
  • ihq32 / 0y17g. Backup (_source_recoverability_proofs) and raw derivation (direct_source_windows) decided windows separately. Raw derivation read no legacy-append window and no ZIP member (it refused with container_member). Backup's direct-file proof read only a whole unchanged file, capped at MAX_UNCOMPRESSED_SIZE (source_too_large).
  • zrb9y. blob_integrity._path_is_container_member was ":" in path, and _source_path_availability, archive_debt._source_artifact_exists and zip_reacquisition_payload all fell back to a first-colon split. As a result, a deleted loose file whose name holds a colon, with an existing directory prefix, reported its source as available.
  • ltj6c. Content-identity refusals were debt on the ZIP path (_settle_zip_member_refusals), while foreign-origin refusals were per-member debt. That is two authorities for one concern.
  • qlvyu. The in-memory ChatGPT route kept 512 sandbox attachments per message and reported the rest as degraded, although that route already holds the whole message in memory.

Solution

  • prepared_jsonl.terminal_decode_evidence is now the single rule for which decode failures are terminal, shared by live intake and replay. batch_support.jsonl_parse_prefix_size is the single rule for which prefix a strict parse reads. It leaves out only an unterminated tail, and live preparation now reads it too. Replay reads the tail without scanning the whole blob (jsonl_parse_prefix_size_of_handle).
  • RetainedParseFailure carries the decode kind across the census worker boundary, and PreparedRetainedInput.parser_decode_failure carries it for prepared inputs. _settle_terminal_decode_refusal records the failure evidence, the parse-failed state and a complete receipt. The failure artifact is not session-parsable, so raw_membership_census_rows reports the raw as terminal on later passes. The dead prepare_retained_jsonl_carrier, which had no caller and carried a string error, is deleted.
  • _ArchiveFullWriteResult.settled_exclusions, _FullIngestResult.settled_exclusions and LiveBatchMetrics.settled_exclusion_paths replace the no_session* fields, and each exclusion carries a reason from SETTLED_EXCLUSION_REASONS. A settled Claude capture with no semantic frontier keeps its byte-prefix cursor, because its failure evidence already forces a full replay.
  • storage/source_blob_restoration.py owns retained_blob_source_candidates and the window kinds. The kinds are the backup proof tokens: file prefix, grown-file snapshot prefix, append window or its observed [0, end) prefix, legacy append window, and ZIP member. Backup now hashes and recovers windows by streaming. Raw derivation stages them by streaming, and stages ZIP members through zip_reacquisition_payload, keeping only byte-identical values. blob_integrity._current_raw_payload_bytes and its helpers lost their last caller and are deleted, together with their tests and the acquisition_boundary allowlist entry.
  • split_zip_member_text refuses a literal existing path. Every split site goes through it or through zip_member_coordinate.
  • _record_zip_member_refusal(..., reason=, error=) is the one debt writer. _reconcile_zip_member_refusals clears stale member debt after every completed scan, not only for bound providers.

Derived-identity closure

These closure members change, so this PR must land before any rebuild starts (devtools schema closure): core/raw_coordinates.py, sources/assembly_chatgpt.py, sources/live/batch.py, sources/live/batch_support.py, sources/live/metrics.py, sources/live/parse_prefetch.py, sources/prepared_jsonl.py, sources/revision_backfill.py and storage/blob_integrity.py. The closure baseline does not grow: the schema-closure gate is ok. No DDL changes.

Verification

  • agentctl job start --workspace <wt> polylogue verify_quick, job 3553 on dea458fcba: verify: PASSED exit=0 (all static gates, including mypy, layering and schema-closure). The pre-push devtools verify --quick passed on 992dcd6, which is dea458fcba rebased onto master c0dda6f. The rebase overlap is one non-conflicting archive_debt.py label hunk.
  • agentctl job start --workspace <wt> polylogue pytest_focused -- <32 files>, job 3554 on dea458fcba: 1435 passed, 9 failed. The 32 files are the new and changed tests, plus every test file of the changed modules' routes: revision backfill, live batch and watcher, parse stage, backup, blob integrity and conservation, raw derivation, revision replay, ZIP addressing, ChatGPT parser and assembly, intake, canonical ingest, and archive debt.
  • The 9 failures are inherited. pytest_focused -- --on-default-branch <the 9 ids> in a detached master worktree at b384edc (job 3501) fails the same 9: test_archive_debt x2 (SchemaSkew), test_raw_observation_derivation x4, test_retained_tool_output_convergence::test_gemini_full_tool_output_survives_the_loss_of_its_source_tree, test_revision_replay::test_chain_replay_supersedes_equal_frontier_quarantined_membership_head and test_silent_ingest_loss::test_mid_stream_non_json_failure_raises_the_same_partial_decode_error. They belong to master-green.

Self-review

Final pass (pass 3) over git diff origin/master...HEAD, against docs/review/codex-review-guide.md and the orchestrate worker-contract list. Pass 1 found three things, fixed before pass 2: the backup proof must name the hashed window (the #5838 invariant my rewrite first dropped for [0, end)), backup read windows into memory, and the replay prefix scan read every blob twice. Pass 2 found the Claude stale-cursor livelock and the directory-asset cap. Pass 3 found nothing new.

  1. ✓ Siblings and owners. Decode terminality has one owner (terminal_decode_evidence; grep _terminal_decode_evidence polylogue finds 0). The strict-prefix rule has one owner, jsonl_parse_prefix_size, read by the live path worker and all three replay decode sites; grep "_iter_json_stream(" sources/revision_backfill.py shows only strict calls. Window choice has one owner, used by backup and raw derivation. A grep for first-colon splits in blob_integrity, archive_debt, zip replay and backup finds 0. ZIP member refusal debt has one writer. ChatGPT caps: the directory-asset refusal was a sibling and is removed. The ZIP route keeps acquisition's ZIP admission, which is policy shared with acquisition.
  2. ✓ The fix itself. _settle_terminal_decode_refusal runs inside the census batch transaction (manage_transaction=not batched). RetainedParseFailure is a frozen dataclass with a StrEnum field, so it is picklable. jsonl_parse_prefix_size_of_handle was checked against jsonl_complete_prefix over 111,972 generated payloads and chunk sizes, and agrees on every one up to trailing whitespace (probe script, not committed).
  3. ✓ Memory and limits. The sandbox cap and the directory-asset size cap are gone. Backup windows are hashed and recovered by streaming, which removes the source_too_large cap on direct files. The tail read holds only the final line plus one chunk, and trailing whitespace is dropped as it is read. No cap or timeout was added.
  4. ✓ Cost per unit. Replay's prefix decision reads only the file tail, not a second full pass. The legacy-append predecessor lookup runs only for legacy rows and uses idx_raw_sessions_source_path.
  5. ✓ Interruption. Raw-derivation staging still polls compute_cancel_requested, and a cancelled stage discards its staged blobs, as before. Census settlement commits at the existing unit boundary.
  6. ✓ Ordering and races. A source that changes between the window hash and backup recovery fails stage_exact_blob's digest check and becomes inexact_payload. Raw restoration stages only exact digests, and the writer publishes them.
  7. ✓ Failure classification. Only JSONL_RECORD failures (and any decode failure of an unknown provider) are terminal, matching live intake. A known-provider JSON document decode failure keeps its former failed receipt (residual below). Read faults stay OSError and remain retryable.
  8. ✓ Silent outcomes. Every settled path is excluded with a typed reason, and the attempt disposition is corrupt_input or unsupported_shape, never success. An empty candidate list is no_source_window in raw derivation, and no_replay_candidate or legacy_append_window_missing in backup.
  9. ✓ Cleanup on failure. Staged blobs are discarded on every refusal path: stage_exact_blob discards a mismatch, and _stage_absent_blob_restorations discards on exceptions.
  10. ✓ Identity and keys. No hash, ID formula or receipt key changed. Member debt subjects keep <zip>:#<ordinal>:<member>.
  11. ✓ Lossless transforms. Replay keeps every complete record and drops only an unterminated tail, as live does. ZIP restoration keeps only byte-identical values.
  12. ✓ Degenerate inputs. An empty or whitespace-only payload parses whole. A lone unterminated line gives prefix 0 and no records. A zero-byte window stages an empty blob. A missing, non-ZIP or directory container prefix yields container_coordinate_missing or source_missing.
  13. ✓ Consumers. Every reader of the renamed fields is updated: intake adapter (admitted paths too), canonical ingest, and tests (grep no_session_paths finds 0). The recover callback signature changes in its only caller. _RECOVERABILITY_FAILURE_KINDS drops the two kinds that are no longer produced. docs/archive-backup.md names the owner.
  14. ✓ Tests and stubs. Each new test drives the production route and names what turns it red:
    • test_retained_replay_refuses_a_malformed_middle_record_with_a_terminal_census goes red under lenient decode (a session is published) or a failed receipt (the raw is re-selected).
    • test_retained_replay_parses_the_complete_prefix_before_an_unterminated_tail[bytes,stream] goes red under whole-payload strict decode, or when a terminated malformed line is excluded.
    • test_a_worker_decode_refusal_keeps_its_kind_across_the_worker_boundary.
    • test_a_corrupt_capture_is_excluded_as_corrupt_input goes red on the former ADMITTED or the stale-cursor RETRYABLE.
    • test_both_routes_prove_and_restore_the_same_window[6 kinds] and test_both_routes_refuse_a_source_that_no_longer_holds_the_bytes[6].
    • test_an_absent_zip_member_blob_is_restored_and_materialized, which drives converge.
    • test_a_colon_path_names_a_container_only_when_its_prefix_is_a_real_zip.
    • The updated ZIP refusal debt test.
    • test_in_memory_sandbox_links_are_all_recorded and test_an_asset_larger_than_the_zip_member_bound_is_acquired_from_a_directory.
  15. ✓ Trust boundaries. Fixtures are synthetic, and nothing is logged beyond the existing events.

Generic list: (1) each criterion is met on the production route, as listed above; the unmet parts are in the residuals. (2) Sibling greps are in item 1. (3) Predecessors are deleted: _terminal_decode_evidence, prepare_retained_jsonl_carrier, _settle_zip_member_refusals, direct_source_windows, stage_exact_direct_source_blob, _current_raw_payload_bytes and helpers, and the backup window helpers; a grep for all of them finds 0 outside test names. (4) Failure paths are typed (items 7 and 8). (5) Red conditions are in item 14. (6) No secrets or private data are in the diff.

Residuals

  • xf8qp: a truncated capture that is still stable (unchanged since capture) is a deferral that parses its complete prefix, not an exclusion. Only the not-stable and not-hot-proven branch is terminal. That branch is tested on the batch route (test_captured_incomplete_jsonl_is_rejected_after_source_disappears); an intake-adapter test would need a source that changes mid-pass.
  • A known-provider JSON document (not JSONL) that does not decode is still a retryable failed census receipt, as in live intake. Making it terminal is a live-intake policy change.
  • Raw derivation restores from the recorded path. Backup also re-anchors a relocated archive root (_resolved_source_path), so a ZIP moved with the archive root is recoverable by backup only.
  • The in-memory ChatGPT route's memory is linear in its input, like every list it already holds. The scratch-spilled prepared route is the bounded one.
  • Legacy-append predecessor choice still orders by acquired_at_ms (noted in fix(backup): name the proven full-prefix window in append proofs #5838).

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Retained replay decodes JSONL strictly over the complete-record prefix
and settles a decode refusal as terminal corrupt input with a complete
census receipt (polylogue-3p8p7). Corrupt and truncated captures are
settled exclusions, not admissions (polylogue-xf8qp). One owner decides
which source window proves a retained blob, for backup and for raw
derivation, which now restores absent ZIP-member blobs (polylogue-ihq32,
polylogue-0y17g). ZIP coordinates split only at a real container
(polylogue-zrb9y); ZIP member refusals share one debt record
(polylogue-ltj6c); the ChatGPT sandbox attachment cap is removed
(polylogue-qlvyu).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: 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.

@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 19:31
@Sinity
Sinity merged commit 8e6234c into master Sep 29, 2026
3 checks passed
@Sinity
Sinity deleted the fix/cold-build-correctness branch September 29, 2026 19:34
@chatgpt-codex-connector

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-29T19:40:46.314246Z 992dcd6 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
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 added a commit that referenced this pull request Sep 29, 2026
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 added a commit that referenced this pull request Sep 29, 2026
## 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](#4439 (comment))
| 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](#4208 (comment))
| 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](#4208 (comment))
| 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](#4188 (comment))
| 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](#4941 (comment))
| 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](#4941 (comment))
| 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](#5480 (comment))
| 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](#4810 (comment))
| 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](#4249 (comment))
| 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](#4060 (comment))
| 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](#4853 (comment))
| 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](#4982 (comment))
| 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](#5395 (comment))
| 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](#5557 (comment))
| 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](#4923 (comment))
| 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](#4936 (comment))
| 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](#4951 (comment))
| 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](#4365 (comment))
| 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](#4275 (comment))
| 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](#4853 (comment))
| 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](#4850 (comment))
| **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](#5546 (comment))
| 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](#5546 (comment))
| **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 (#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 #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.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