Repository navigation
fix(sources): correct eleven reviewed acquisition and proof defects - #4587
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe7d0286e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
fe7d028 to
b1af5d3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1af5d351b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Addresses the verified Codex review findings across sources, daemon, and operations. Each fix is independent; grouped here because they share the live-acquisition and recoverability-proof surface. Claude append/frontier authority (findings 3 and 9) is the one coherent pair: both derived semantic authority from whatever bytes were on disk at planning time, so a rewrite preserving the prefix length inherited the previous observation's authority. Both now require the live prefix to reproduce the retained evidence before any frontier is promoted. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
Adds regression coverage for findings 2, 3, 4, 5, 6, 7, 8, 9, and 11, each naming the mutation that turns it red. Two existing expectations changed with the behaviour they described: legacy-chain promotion is now asserted to be pending after resynthesis rather than already committed (finding 7 moves that durable write behind a successful plan), and the full-file-read guard is scoped to the watched session file so it no longer trips on unrelated parser-source reads. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
…enance Finding 1: an append row whose retained blob is the whole observation, with the tail's offsets recorded alongside, is now proven through the full prefix. The companion window-shaped case pins that an ordinary tail append still proves through its window. Finding 10: a model turn with no provider id yields provenance completed from the stored message id rather than failing the session's write. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
An entry left behind would be read by a later planning pass as though it described that pass's observation. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
…nstant The reingest test simulated a fingerprint change with the literal "live-batched-v3", which is now the real value, so the monkeypatch became a no-op and the test asserted nothing. Deriving the sentinel keeps the behaviour under test and cannot collide with a future bump. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
b1af5d3 to
163466b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 163466ba98
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
#4594) ## Summary Fixes 20 of the 22 Codex review findings recorded for storage. One is refuted with evidence, one is confirmed only in part, and two are deferred with reasons. Five commits, one per seam: 1. `material-protocol` — semantics versioning and read gating 2. `storage` — derived schema identity, manifests, lifecycle admission 3. `storage` — writer provenance, tool verdicts, session kind 4. `storage` — vector counting and index attachment 5. `storage` — provider cost attribution on append Every finding was re-confirmed by behavior at this branch's base (`c1d2544f0`); the recorded line numbers were treated as hints, since they were captured against `cc58ef3e6`. ## Problem ### Semantics versioning (#4554, #4557) - **20** — `material_protocol/v1/constants.py:22`: `SEMANTICS_VERSION` was 3 while attachment records had gained `direction`, `producer_ref` and `caption`, so the encoder emitted bytes the declared version did not describe. `test_checked_in_bytes_match_a_fresh_encode` was red on master. Confirmed by decoding both sides: the fresh encode carries the three keys, the checked-in fixture does not. - **21** — `material_protocol/v1/verify.py:50-92`: `resolve_anchor` verified an anchor's digest, record id and seq but never the manifest's semantics version. Only `verify_revision` called `require_current_semantics`, so the single-record read path decoded records whose shape this reader may not implement. - **22** — `material_protocol/v1/manifest.py:194`: `int(payload["semantics_version"])` coerced before comparison, so a declared `3.9` truncated to a supported `3`. ### Schema identity, manifests, lifecycle (#4544, #4546, #4548, #4560, #4556) - **10** — `archive_tiers/index.py` appends `schema_identity` to `INDEX_DDL`, but `tests/infra/reindex_differential.py::compared_table_census` raises on any DDL table with no declared classification, so the rebuild differential raised on every current archive. - **11** — `schema_manifest.py`: `canonical_schema_manifest` executed the whole tier DDL into a fresh `:memory:` database on every call, and every read open asserts against it. - **12** — `schema.py:73`: `except (RuntimeError, sqlite3.Error)` reported `rebuild_index` for both, so a SQLite failure that never inspected the schema was indistinguishable from real drift — and told the operator to destroy a sound index. - **13** — `schema_manifest.py:33`: the projection filtered only `NOT LIKE 'sqlite_%'`, so FTS5 shadow tables were compared and an FTS5 build change would read as archive schema drift. - **15** — `archive_tiers/bootstrap.py`: `open_initialized_tier_connection` ran `initialize_archive_tier` before `assert_tier_schema_supported`. `_apply_archive_tier_convergence` rewrites `user_version` to the spec version (bootstrap.py:387-388), so the check validated a value the same call had just written: a tier at some other version was restamped into apparent currency and admitted. `initialize_archive_database` gets this right (it reads the stored version first, bootstrap.py:553); this route did not. - **16** — `stamp_derived_schema_identity` issues an `INSERT ... ON CONFLICT` and never commits. It runs *after* `_materialize_archive_tier`'s own commit, so it sits in its own open transaction and rolls back on close. Some callers committed afterwards; `open_initialized_tier_connection` and the OPS same-version reapply did not. - **17** — `connection_profile.py`: the post-materialization check read only `PRAGMA user_version` and never the derived identity — the one thing the stamp exists for, and the only one of the two that materialization has not just overwritten. - **18** — `raw_failure_lifecycle.py:111`: `validate_schema=False` on the admission path (callers `bulk_rebuild.py`, `archive_verification.py`). - **19** — `archive_readiness.py:269`: bare `sqlite3.connect(...mode=ro)` with no version check, reached from `readiness/capability.py`'s frontier source-selection. Its result is surfaced to users as `source_embedded_messages`. ### Writer (#4506, #4561) - **1** — `write.py`: `session_kind` is derived once at admission from `session.branch_type` alone. `_refresh_session_projection` later re-derives `branch_type` from resolved `session_links` — including hook-authoritative edges the parser never saw — but its `UPDATE`s never touched `session_kind`, so a subagent child discovered after admission stayed `PRIMARY` permanently. - **2** — `write.py::_coalesce_block_row`: `tool_outcome`, `tool_result_is_error`, `tool_result_exit_code` and `tool_result_outcome_unknown_reason` were each coalesced independently by `_coalesce_scalar`, so a merge could persist a fresh `success` beside a stale `is_error=1`/`exit_code=1` that contradicts it. - **4** — `write.py::_attachment_provenance`: with no `message_id` fallback, a model turn whose provider supplied no message id derived `("model_output", None)`, which the writer then rejects — failing the whole session write. **Superseded during this work**: #4587 landed the same fix with a better implementation (`resolved_message_id`, applied to the parser-declared path as well as the role-derived one). This branch drops its own version and keeps master's. Finding 5 is still fixed here, because #4587 did not touch the stale test. - **5** — `tests/.../test_archive_tiers_write.py`: `test_writer_refuses_attachment_without_derived_direction` still asserted the refusal contract #4561 replaced, and was red on master with `DID NOT RAISE`. ### Embeddings and vector search (#4538) - **7** — `sqlite_vec_runtime.py:98`: `ATTACH DATABASE ?` with no existence check. ATTACH creates the file, so a missing active index silently became an empty database and the projection reported an archive with no eligible messages. - **9** — `sqlite_vec_queries.py:277-293`: `count_session_embeddings` counted rows in `current_embedding_messages` — the *eligible-message* projection, which has no relation to `message_embeddings` — so a session mid materialization or with failed embeds reported vectors it did not have. The value reaches users through `repository_vectors.py` → `daemon/similarity.py` → `web_shell_similar.py` as "N embedded messages". ## Solution Semantics: bump `SEMANTICS_VERSION` to 4 and regenerate the checked-in cross-repo fixture; gate `resolve_anchor` on the version as `verify_revision` already was; read the declared version as an exact integer, rejecting `bool`, non-integral floats and strings. Schema identity: commit the stamp inside `initialize_archive_tier`, the single choke point every derived-tier materialization passes through; admit the stored version in `open_initialized_tier_connection` *before* materialization can restamp it; assert the derived identity in `assert_tier_schema_supported` alongside the version; split `assert_readable_archive_layout`'s handler so a SQLite failure reports a new `retry` lifecycle action instead of `rebuild_index`; cache the canonical manifest per declared schema, keyed on the DDL so a substituted schema cannot take a stale hit; exclude FTS5 shadow tables by exact suffix; route raw-failure admission and frontier source selection through the schema-enforcing open; classify `schema_identity` in the rebuild differential as comparable, since a rebuild producing a different identity is exactly what that differential is for. Writer: take all four tool-verdict columns from one row together; re-derive `session_kind` through `admitted_session_kind` wherever the projection writes `branch_type`; replace the stale attachment-direction refusal test with tests for the derivation #4587 introduced. Vectors: count distinct stored refs joined to vector metadata; refuse a missing active index instead of creating one. ## Half-refuted, half-fixed - **3** — "`_seed_session_model_usage_rows` never clears rows for a previous model, so `usage.py`'s `SUM(provider_cost_usd)` double-counts after a model switch." **Refuted for the full-replace path**, which is the mechanism as stated. Every full-replace write first calls `_clear_session_projection_rows`, whose table list includes `session_model_usage` (write.py:1217), so no stale row survives to be summed. Two existing tests cover exactly this and pass: `test_provider_usage_model_switch_on_reingest_does_not_double_count` and `test_provider_usage_model_vanishing_on_reingest_leaves_no_stale_rollup`. **Confirmed for merge-append**, which that clearing cascade does not cover. master already carries a test for the intended contract — `test_merge_append_replaces_prior_provider_total_on_model_switch`, added by #4505 — and it has been failing ever since, because nothing clears the prior model's `provider_cost_usd`. Verified by exercising the writer directly at master's `write.py` and at this branch's: both returned `[gpt-new 2.0, gpt-old 1.0]` where the test requires `gpt-old` to be `None`. The fifth commit clears the prior attribution, and that same probe now returns `[gpt-new 2.0, gpt-old None]`. ## Refuted, not fixed - **14** — "`SameVersionSchemaVariant` has no upper bound; the index tier is at v85 while the v78 SEMANTIC_REPARSE entry's variant is still unbounded." There is no v78 variant. `INDEX_SAME_VERSION_SCHEMA_VARIANTS` contains exactly one entry, `introduced_version=63` (`remove_fts_bulk_guard` on three trigram triggers), and always has. The named entity does not exist, so there is no concrete input with a wrong outcome. The open-ended applicability of that one entry is a deliberate property of a permanently retained benign trigger-body variant, not a defect. ## Deferred, with reasons Two findings are real and unfixed here because each is a design change rather than a review-sweep patch. Both warrant their own tracked work: - **6** — the embedding contract refresh commits data and metadata non-atomically, and both `writer_lock()` and `recover_interrupted()` call `_generations()`, which raises on the resulting mismatch with no path out. Confirmed still true. A fix means making `generation.json` publication crash-safe and giving recovery a way to re-derive the contract from the committed database; that is the embeddings lifecycle's durability contract, not a patch. - **8** — `sqlite_vec_runtime._get_connection` rebuilds the full `current_embedding_messages` projection — a whole-archive scan and join with a per-row hash — on every connection, and every query opens its own connection. Confirmed still true. A fix needs a cache keyed on index generation or a pooled connection, with the invalidation and concurrency design that implies. Also worth noting: there is no `devtools` command to regenerate the material-protocol golden fixture. It was regenerated here through `encode_session_revision` + `write_revision` and verified byte-for-byte against a fresh encode; a supported regeneration route would be a reasonable follow-up. ## Verification ``` devtools verify --quick devtools test tests/unit/storage/test_writer_verdict_and_kind_projection.py \ tests/unit/storage/test_derived_schema_identity_admission.py \ tests/unit/storage/test_archive_tiers_write.py \ tests/unit/storage/test_vec_session_seed.py \ tests/unit/material_protocol/v1/ \ tests/unit/storage/test_archive_readiness.py \ tests/unit/storage/test_derived_schema_identity.py \ tests/unit/storage/test_cost_queries.py -n 4 ``` All twelve static gates pass, including `schema-versioning`. Anti-vacuity was checked by mutation, not assumed. Reverting the `conn.commit()` in `initialize_archive_tier` turns `test_schema_identity_stamp_survives_the_connection_that_wrote_it` red; deleting the stored-version admission from `open_initialized_tier_connection` turns `test_a_skewed_tier_is_refused_before_materialisation_restamps_it` red. Both were run and observed. Every new test's docstring names the specific mutation that makes it fail. ## Residual risk - Asserting the derived identity in `assert_tier_schema_supported` refuses a tier at the current version whose stamp does not match this runtime. That is the intent, and `initialize_archive_database` already enforced the same check on its own route, so an archive in normal use is already stamped. The check is deliberately *not* on every `open_connection` — an earlier draft put it in `_assert_schema_supported`, which would have made every read open recompute `derived_schema_identity` (uncached, over three fingerprints) and would have refused any never-stamped archive on a read-only path. - `lifecycle_action="retry"` is a new value in that field. It is free-form and forwarded to MCP payloads; no closed vocabulary or dispatch consumes it. - The FTS5 shadow filter matches the five exact FTS5 suffixes rather than a name prefix. A prefix would have wrongly dropped `messages_fts_identity` and the three `messages_fts_a{i,d,u}` triggers, which are ours; the test asserts both halves. - Bumping `SEMANTICS_VERSION` to 4 makes this reader reject v3 bytes by contract. `constants.py` notes the fixture is checked in "in lockstep with the Sinex counterpart (sinex-4j2.1)"; that repo pins the same version and will need the corresponding bump. Nothing in this repo reads v3 bytes from disk outside the regenerated fixture. - `tests/unit/storage/test_archive_readiness.py` builds stub two-table index databases to exercise gap classification. Now that the probe reads through the schema-enforcing open, those fixtures stamp the precondition explicitly via a named helper rather than relying on the probe not checking. ## Inherited failure `tests/unit/storage/test_connection_profile.py::test_open_readonly_connection_uses_descriptor_bound_database` fails identically on clean `origin/master` (verified by stashing this branch's changes and rerunning). It is not touched or fixed here. `test_merge_append_replaces_prior_provider_total_on_model_switch` was also inherited-red, confirmed the same way; unlike the above it is fixed here, because it is the merge-append half of finding 3. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
Devtools half of the unaddressed-Codex-review sweep (26 findings verified against current master, 41 tests). Sibling PRs: #4580, #4582, #4583, #4587, #4594. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
…ping, wire-receipt cost (#4591) ## Summary Five red classes from the 2026-09-03 corpus run, each its own commit. Two are product defects; three are fixtures pinned to shapes the runtime has moved past. ## Problem and solution, per class ### The relink route never derived attachment provenance (6 tests) `attachment_refs.direction` is `NOT NULL`, and only the main write route derived it from the owning turn. Blob-reference closure relinked attachments straight from the parsed record: ``` sqlite3.IntegrityError: NOT NULL constraint failed: attachment_refs.direction ``` The relink path now goes through the same shared derivation, reading the owning turn from the index when the append payload's own message map does not carry it — an append whose owning message is already materialized. Two of the six failed inside the main route instead, on a model-output attachment whose turn carried no provider id; `#4587` fixed that while this branch was open, and this commit builds on it. ### One session total on two model rows (1 test) `sessions.reported_cost_usd` is one exact dollar total for a session, written onto a single `session_model_usage` row. A merge-append that switched models left the superseded row holding the previous total, so every sum over the session counted it twice. The direction-refusal test alongside it named a user turn, whose direction the derivation supplies; only a role outside the user/model pair leaves the column underivable, so that is what it names now. ### Hand-built index fixtures without a tier version (12 tests) `#4485`'s open-time tier check refuses a database named for an archive tier whose `user_version` is 0: ``` SchemaSkewError: index schema skew: expected 85, found 0 ``` - The deployment-smoke browser-capture probe fixtures declare the version the read profile expects, read from the tier table. - The embed-backfill fixtures build the tier through the production bootstrap rather than touching a bare SQLite file. - The WAL/journal pragma probes name their scratch databases for what they are. They test the pragmas the connection factories apply; the tier check fired only because the files were called `index.db` and `ops.db`. ### Hand-built `blocks` tables without `tool_outcome` (6 tests) The insight-status and readiness queries read `blocks.tool_outcome`, the canonical structural outcome since `#4539`. Two fixtures predate it. ### A killed waiter left its pytest slot task queued (host defect) The waiter blocks on a task it queued through pueue, and the task outlives it. The slot's parallelism is one, so a task left with no waiter starves every other checkout on the host until someone reads the queue and kills it by hand -- which is what happened during this branch's own runs. The waiter now reaps the task it added when it is signalled or unwound: kill, then remove, then drop the launch file, which carries a resolved environment and must not survive either. ### Full-catalog wire receipts on single-provider assertions `build_wire_support_receipt` runs the synthetic corpus and the production parser for every catalogued package element. Profiled: 27 s per full-catalog call in a quiet process, and the file's heaviest tests measured 106-110 s of call time under `-n 2` -- inside a 120 s timeout with no margin, which is what the corpus run recorded as nine timeouts. `#4412` added two providers and the margin went. Tests that assert about one provider's entry, or that a receipt *changed*, now name the providers they read; three catalog-wide tests still build the whole catalog. Memoizing the schema-annotation parsing the profile flagged was tried and reverted: 26.5 s against 27.4 s, which does not buy an identity-keyed cache in production code. ### Reader assertions pointed at the wrong route The interpolated shell answers on `/w/` and the paste routes; the root and `/s/` serve the typed WebUI. Eight reads across the visual suites and `test_web_shell_reader.py` now fetch `/w/stack`. This also restores `test_reader_search_shell_dom_evidence`, which `#4579` deleted -- the shell it tests is still served, just not at the root, so repointing it was the right move and deleting it was not. ## Verification `devtools test <file> -n 2`: | file | before | after | | --- | --- | --- | | `tests/unit/storage/test_archive_tiers_write.py` | 2 failed | **107 passed** | | `tests/unit/maintenance/test_blob_reference_closure.py` | 6 failed | **13 passed** | | `tests/unit/cli/test_embed_activation.py` | 7 failed | **35 passed** | | `tests/unit/devtools/test_deployment_smoke.py` | 7 failed | **24 passed** | | `tests/unit/storage/test_wal_journal_size_limit.py` | 5 failed | **8 passed** | | `tests/unit/storage/test_session_insight_status_descriptors.py` | 5 failed | **13 passed** | | `tests/unit/core/test_insight_readiness.py` | 1 failed | **passed** | | `tests/unit/devtools/test_pytest_slot.py` | 7 passed | **8 passed** | | `tests/unit/storage/test_session_profile_model_usage_consistency.py` + `tests/unit/insights` | — | **730 passed** (cost regression check) | `devtools verify --quick` green at this head. The attachment and cost measurements above predate the rebase onto `#4587`, which rewrote `_attachment_provenance` under this commit; the storage suites are re-running against the merged shape. The slot-reaping test drives a real SIGTERM into a child waiter with a fake `pueue` on PATH. Anti-vacuity: dropping the `_reaping` context leaves the recorded calls at `add`/`wait`, the starvation shape itself. The visual and wire-receipt commits are still queued behind the host's pytest slot at the time of writing; they are committed, not yet measured. ## Residual risk The provider-scoped wire receipts trade catalog breadth for time in tests that assert about one provider. If a future provider's route breaks only in a receipt those tests build, three catalog-wide tests still catch it, one test later. `tests/unit/infra/test_pathology_zoo.py` was red in the corpus run and is green at this head with no change here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
…route parse_one_source_path refused every non-session path-rule verdict before the decoded-session-evidence check, so a workflow journal that decodes as a session was never parsed there while the live batch route admitted it. A non-session verdict is now overridden only for a declared, parseable (not raw-only) path rule whose content proves a session. Tests: live-source fixtures use the current parser fingerprint (#4587) and return the cursor write result; Codex appended messages record no parent coordinate (#4510); the 804 proof's resume oracle is the sealed membership minus what the interrupted generation committed (#4285). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
## Summary Fixes the still-real parser findings from bead polylogue-1tyq5.27 (unhandled Codex P1 review threads on merged PRs). ## Problem - Admission accounting was fail-open: the production Claude Code multi-session stream, Codex streams and undecorated lowered routes produced sessions with no outer-record ledger (F695, F779), and a record without an unknown-type sentinel was counted as materialized even when the parser skipped it, e.g. a scalar record in a JSONL stream (F780). - OTel GenAI: every span re-emitted the full input history, duplicating earlier messages (F075); usage was kept only for `chat` operations (F077); unnamed resources collapsed onto one id and merged unrelated sessions (F079); ordinary HTTP/DB traces in a GenAI export became zero-message sessions (F080). - Drive: one event carried the whole citation list, so an appended citation changed that event's identity and revision membership read ordinary growth as ambiguous (F507). - Preflight refused a verified Antigravity trajectory schema whose steps produced no messages, so its typed empty/unsupported evidence could never be acquired (F350). ## Solution - `base_support.AdmissionObserver`: one classifier per session's outer records (materialized / typed unknown / typed refusal for non-object records). `parser_admission` uses it; the Claude Code stream keeps one observer per session group; the Codex stream route and `_parse_lowered_spec` apply it to single-session results that lack a parser ledger. - `otel_genai`: history-overlap suppression per conversation transcript, usage fallback for any operation, resource ids derived from the resource attribute set when `service.name` is absent, and a filter keeping only traces that contain a GenAI span. - `drive`: one `gemini_citation` event per citation with its ordinal. - `import_preflight`: a verified schema with trajectory rows is admissible, with caveats for no-message and degraded steps. Other findings in the group were already fixed on master or belong to other work: F319 (#4966/#4972), F351 (#5403), F419 (#5550), F505 (#4861), F647 (#4587), F850 (#4236); F029 is routed to the intake enrichment work (#5643). ## Verification - `devtools test` over the OTel, Drive contract, preflight, admission, Codex event-stream and `tests/unit/sources/parsers` selections: 1 failure in a new test (a missing `messages=[]`), fixed; that test passes alone. - New tests: history dedup, distinct unnamed resources, non-GenAI trace exclusion, non-chat usage, grown citation list, verified trajectory without messages, Claude Code stream admission, scalar-record refusal. ## Residuals - Hermes multi-session ATIF streams still lack per-session admission; noted on the bead. - `base_support.py` overlaps #5682's in-place event handling; a small rebase conflict is expected. - Schema closure: the parser files are in the derived identity closure, so this must land before the fresh build. ## Self-review I reviewed the whole diff at the final head, not only the last round. The findings are grouped by the invariant each one protects. **Admission conservation (every emitted session carries a closed proof)** - `admit_parsed_sessions` proves every session that lacks its parser's own ledger. The document is observed once and the closed proof is shared (`AdmissionObserver._closed_proof`), so an N-session document costs one scan. - Every origin's scanner reads only discriminators: - Claude: record `type` and block `type`. - Codex: envelope and payload `type`. - Hermes: `type`/`kind`/`record_type` and step kinds. - OTel: span `kind`, registered under the provider token the route passes (`opentelemetry`). - The default scan used by the other undecorated routes never descends into `arguments`/`input`/`output`/`result`/`attributes`, so a tool argument `{"type": "unknown"}` is data, not a wire type. - The streamed Hermes ATIF carrier that master added in #5776 now gets the same proof as the dispatch route over the same bytes. Each step's `type`/`kind` is observed as the parser consumes it, so no second decode is needed and a future step kind beyond the classifier's 64-step witness is still recorded as a typed unknown (`test_streamed_atif_trajectory_carries_the_dispatch_admission_proof`). I checked the other #5776 streaming routes. The Claude AI, AI Studio/Drive chunked and ChatGPT routes reach decorated parsers, and Grok admits through `grok.parse_conversation`. - Admission events are appended in place to a disk-backed sink, and any other non-list sequence is copied into a list first. This keeps master's #5643 contract through the merge. - A record the parser skips is a typed refusal, never `MATERIALIZED`: - a non-object; - a Claude record with no string type (`recognized=False`); - a known-kind ATOF record that `looks_like_atof_payload` rejects (`malformed=True`). **Identity stability (an export revision updates, never duplicates, a session)** - OTel resource ids depend only on the resource's own stable attributes. They exclude instance, version and cardinality, so adding a second resource keeps the first one's sessions. - Copies of one span coordinate that disagree on `gen_ai.conversation.id` choose none (trace-keyed). - A shared ancestor belongs to the conversation whose descendant started first, so it cannot move when a sibling conversation is appended. - Trace membership and parent links work across resources within a trace. A span keeps its own resource (`resource_id` in its evidence), and spans with equal ids under different resources stay distinct. - Antigravity: rowids are never identity. Several trajectories with no id are refused (`LogicalExportError`), and one anonymous trajectory keeps the path fallback. **Complexity**: the history overlap is a KMP pass, linear in both lengths. **Checked and left as is**: Drive chunk/citation handling after the master merge (a conflict was resolved by combining master's `event_rows`/`chunk_records()` with this PR's `_citation_events`), and the Claude event ordering (`order_session_events`). **Verification** (final head 85329da): - `devtools test tests/unit/sources/parsers/test_otel_genai.py tests/unit/sources/test_admission_payload.py tests/unit/sources/parsers/test_antigravity.py tests/unit/sources/test_prepared_hermes_atif_object.py tests/unit/sources/test_prepared_claude_ai_object.py tests/unit/sources/test_prepared_drive_chunked_object.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_parsers_base.py tests/unit/sources/test_parser_admission_packet.py tests/unit/sources/test_prepared_jsonl.py tests/unit/sources/test_first_future_type_duplicate_keys.py`: 352 passed, 0 failed. - `agentctl job start polylogue verify_quick`: succeeded (job 2117). **Residuals**: - polylogue-hlghl: ParseAccounting compresses unknown outcomes (pre-existing). - A Hermes duplicate event key is still counted as materialized: its evidence is carried by the first copy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
) ## Summary Lands the verified part of ChatGPT worker 9's pass over Codex review findings in `polylogue/sources` (beads polylogue-1tyq5.90, .91, .92; 75 findings). 13 fixes are kept, each with a regression test that fails on master. The other 62 are recorded below as fixed-already, stale, refuted or not reached. ## Problem The findings are Codex P2 review threads on earlier PRs. The kept ones reproduce on current master: - ChatGPT extracted-export asset acquisition follows leaf symlinks, so it archives bytes from outside the export. - Replay's bounded probe drops the Claude project keys, so a retained UNKNOWN project whose keys sit past the 8 KiB prefix stays UNKNOWN and is refused. - Drive-like lowering drops `source_path` when it reclassifies a Gemini CLI document, so a matching sidecar is skipped. - The Drive cache rejects valid `null` JSONL records and large integers, and leaks its temporary file when a write or close fails. - Import preflight reports SUPPORTED even when it records a degradation caveat. - A lost best-effort `cursor_update` leaves a completed attempt with `materialized_count=0`. - Source-only (acquire-only) intake still requires the Antigravity language server before it keeps `.pb` bytes. - The JSONL blank-line regex matches every newline-terminated payload, so the `bytes.count` fast path never runs. - The ops checkpoint holder looks for `-shm` beside a symlinked `ops.db` rather than beside its target. - A sealed, complete cold-build count loses its zero ETA once it stops advancing. - Hook paste enrichment checks the write lease against the index-generation directory instead of the archive root. ## Solution - `sources/assembly_chatgpt.py`: the walk admits only lstat-regular files. Each asset is opened with `O_NOFOLLOW|O_NONBLOCK`, checked with fstat, then streamed with `write_from_fileobj`. Asset refusals are emitted as one structured event, `sources.chatgpt.asset_refused`. - `sources/revision_backfill.py`: `docs`, `prompt_template` and `is_starter_project` added to the probe's retained root keys. - `sources/dispatch.py`: `_lower_drive_like_payload` forwards `source_path` through both recursive branches and the Gemini CLI spec. - `sources/drive/__init__.py`: a successful decode is enough to validate a cache, and ijson runs in its lossless number mode. One cleanup path covers temporary creation, write, close and replace. - `sources/import_preflight.py`: any caveat now reports DEGRADED, which is still admissible. The bounded-trajectory test expectation changes to match. - `sources/live/batch.py`: the completed progress update carries `materialized_count`. Source-only intake skips the language-server cohort, so `.pb` files take the ordinary raw snapshot. - `sources/live/batch_support.py`: the regex no longer treats the empty line after a final newline as blank. - `sources/live/cold_build.py`: the holder resolves `ops.db` before deriving `-shm`. A sealed count at or above its denominator returns ETA 0. - `sources/live/hook_paste_enrichment.py`: the lease check uses the configured archive root. Worker changes not landed: - `census_parse_stage.py` idle-wait fix: the module has no production instance and polylogue-rykzt retires it. The live `LiveParseStage` has no such event pair. - `parse_prefetch.py` cohort scoping: already on master through #5691 (`_prepare_existing_session_writes(paths=...)`). - Source-only ZIP provider stamp (92-01): it does not fix the reported case. The OTel GenAI spec declares a catch-all `.*\.json$` rule, so `declared_artifact_provider` returns None for every `.json` member, `tool-results/dump.json` included. - The worker's `docs(review)` commit: per-finding records belong in this body, not in tracked files. ## Verification - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w9 --wait` → job 2346: `verify: PASSED exit=0 ... head=edfab65f2749` - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w9 --wait -- tests/unit/sources/test_codex_debt_w9_regressions.py tests/unit/sources/test_import_preflight.py tests/unit/sources/test_drive_source_client.py tests/unit/sources/test_live_batch_support.py tests/unit/sources/test_cold_build_generation.py tests/unit/sources/test_cold_build_durability_policy.py tests/unit/sources/test_revision_backfill.py tests/unit/sources/test_dispatch_payloads.py` → job 2347: `passed 470, failed 1, total 471` at head edfab65. The one failure, `test_import_preflight.py::test_unidentified_trajectory_rows_keep_distinct_identities` (a `LogicalExportError` from `parse_trajectory_db`), fails the same way on unmodified master (jobs 2284 and 2348). - Proof that the tests fail without the fixes: the final `test_codex_debt_w9_regressions.py` was copied into a worktree at unmodified master and run as job 2348, with 17 failures (`17 failed in 21.74s`). That covers every kept finding's test. The 92-13 ETA test fails only on its complete-count case; its two control cases pass on both heads, as intended. ## Self-review - **Sibling sites.** The other asset reader is the ZIP branch, which reads members, not filesystem paths. `_lower_drive_like_payload` has one caller and `_enrich_archive_paste_from_hooks` has one. The cache-validator change covers both Drive routes (byte and streamed). Other `-shm`/`-wal` derivations elsewhere in the daemon are outside this finding and are listed as a residual. The 92-01 gap is shared by the ordinary live ZIP route and `retained_acquisition.py`, which is why the one-route stamp was dropped rather than landed. - **Cancellation and shutdown in loops.** No loop or wait was added. The asset loop keeps its per-file `continue` on `OSError`. - **Unbounded reads.** Assets still stream through `write_from_fileobj` under the existing `MAX_UNCOMPRESSED_SIZE` check. The Drive validators keep their streaming form. - **Fail-open fallbacks and compatibility shims.** None added. Source-only `.pb` intake retains raw bytes without parsing, and parsing still needs the language server once derived tiers return. There is no alias or dual path. - **Removed symbols.** None removed. Tests patch `local_agent`, `tempfile` and `time` directly rather than through attributes the source modules do not export. - **Tests prove the production route.** The tests drive `parse_payload`, `iter_drive_raw_data`, `preflight_import_source`, `LiveBatchProcessor.ingest_files` / `_ingest_full_paths_sync`, `jsonl_complete_prefix`, `_hold_ops_checkpoints`, `enrich_paste_from_hooks` and the retained-UNKNOWN detector `_detect_unknown_retained_provider`, which is the same private entry point `test_revision_backfill.py` already uses. The ETA test calls the `accepted_progress` property on a hand-set generation. ## Per-finding dispositions Counts: 13 fixed, 0 dropped as not real, 22 fixed-already, 3 stale, 2 refuted, 35 not reached. Per bead: .90 6 fixed / 6 fixed-already / 2 stale / 1 refuted / 10 not reached. .91 3 / 5 / 1 / 1 / 15. .92 4 / 11 / 0 / 0 / 10. | key | disposition | evidence | test | |---|---|---|---| | 90-01 (#4803) | fixed | `sources/assembly_chatgpt.py`: Regular-file lstat admission and no-follow/nonblocking opened-file validation prevent leaf-symlink and FIFO substitution from being acqu... | `test_w9_asset_acquisition_rejects_symlink_leaves` | | 90-02 (#4234) | stale | dead `census_parse_stage.py`, retired by polylogue-rykzt; live `LiveParseStage` has no such event pair | — | | 90-03 (#4928) | refuted | `sources/codex_state_evidence.py`: The requested reconciliation depends on upgrading an earlier archive. This batch explicitly targets fresh v1 and forbids migrations/... | — | | 90-04 (#4889) | not reached | `sources/codex_state_evidence.py`: Same-ID admission still needs an acquisition-state preservation proof; leave replay/storage reconciliation to follow-up. | — | | 90-05 (#4229) | stale | `sources/codex_state_evidence.py`: event_identity and its hook-event emission are gone; Codex thread state is now projected through codex_state_projection instead. | — | | 90-06 (#5626) | not reached | `sources/codex_state_evidence.py`: State snapshot chunks are processed within the same writer ownership; no bounded writer-handoff implementation supplied. | — | | 90-07 (#4622) | not reached | `sources/codex_state_evidence.py`: Backlog is fetched as a whole and consumed in one retained-receipt pass; replacing this needs end-to-end paging, not a cap. | — | | 90-08 (#5626) | not reached | `sources/codex_state_evidence.py`: Replaying a shorter logical state value does not reconcile removed trailing chunk observations. | — | | 90-09 (#5581) | not reached | `sources/codex_state_evidence.py`: The frame consumer still needs explicit cancelled/expired-read propagation instead of interpreting an empty projection as current. | — | | 90-10 (#4174) | not reached | `sources/cursor.py`: ZIP skip accounting counts every physical member, unlike the declaration-aware acquisition population. | — | | 90-11 (#4661) | fixed-already | `sources/decoder_zip.py`: Explicit suffix/predicate callers disable inferred declaration-path widening. | — | | 90-12 (#4661) | fixed-already | `sources/decoder_zip.py`: Only strong artifact declarations widen the inferred member admission route. | — | | 90-13 (#4661) | fixed-already | `sources/decoder_zip.py`: Unknown-inbox admission now uses cross-provider strong declarations; ordinary live ZIP acquisition retains their sidecars. | — | | 90-14 (#4661) | fixed-already | `sources/decoder_zip.py`: Source-only ZIP admission supplies is_declared_artifact_path, so declared non-JSON sidecars are retained. Provider stamping is a separate fin... | — | | 90-15 (#4721) | fixed | `sources/dispatch.py`: The bounded streaming document probe retains the three Claude project shape keys, without retaining their unbounded values. | `test_w9_retained_unknown_project_is_detected_beyond_prefix` | | 90-16 (#4720) | fixed | `sources/dispatch.py`: Drive lowering forwards source_path through recursive wrappers and the Gemini CLI document specification; all internal callers updated. | `test_w9_drive_lowering_preserves_gemini_source_path` | | 90-17 (#4184) | not reached | `sources/dispatch.py`: Current master adds chatgpt_rejected_mapping_candidates; consumer-to-durable-accounting trace remains incomplete, so no resolution claimed. | — | | 90-18 (#4652) | fixed-already | `sources/dispatch.py`: lower_chatgpt_documents now lowers shared decode records inside specs as well as the direct top-level case. | — | | 90-19 (#4188) | not reached | `sources/dispatch.py`: Codex-task conservation exclusion still needs population-level treatment, not simply returning an empty document list. | — | | 90-20 (#5584) | fixed-already | `sources/dispatch.py`: The production streamed generic caller normalizes ijson numbers before parse_generic_messages_stream; no additional dispatcher normalization is ... | — | | 90-21 (#4654) | not reached | `sources/dispatch.py`: Shared-decode conservation and parser identity precedence require a joint production-route fix. | — | | 90-22 (#4188) | not reached | `sources/dispatch.py`: DOM capture fallback IDs still require the same normalization as the production parser; old supported input is not automatically exempted by the... | — | | 90-23 (#4174) | fixed | `sources/drive/__init__.py`: Both cache-reading and streamed revision-proof routes accept syntactically valid null JSONL records. | `test_w9_drive_cache_accepts_null_jsonl` | | 90-24 (#4174) | fixed | `sources/drive/__init__.py`: The finally cleanup covers tempfile write and close failures as well as rename failure, preserving the previous destination. | `test_w9_drive_failed_cache_publication_removes_temporary` | | 90-25 (#5421) | fixed | `sources/drive/__init__.py`: Lossless ijson number parsing prevents repeated downloads of Python-JSON-readable large integers. | `test_w9_drive_unchanged_large_integer_cache_does_not_download` | | 91-01 (#5447) | not reached | `sources/hook_producer.py`: Alternate-producer/compaction quiescence needs a complete writer-protocol trace; no fix or dismissal claimed. | — | | 91-02 (#4269) | not reached | `sources/hooks.py`: Legacy-root source identifiers remain positional; no interface replacement/consumer update supplied. | — | | 91-03 (#4932) | fixed | `sources/import_preflight.py`: Supported inputs with degradation caveats report DEGRADED. The existing bounded-trajectory test expectation is updated to the same hones... | `test_w9_trajectory_preflight_reports_degraded_steps` | | 91-04 (#4275) | stale | `sources/live/admission.py`: The unreachable terminal branch cited by the review has been removed; current policy reacquires non-accepted receipts. | — | | 91-05 (#5263) | not reached | `sources/live/append_ingest.py`: Asserted hook-carrier baseline versus byte-proven resynthesis needs a coordinated authority-proof change. | — | | 91-06 (#5530) | not reached | `sources/live/append_ingest.py`: Success artifact observation still precedes single-session/chain-authority acceptance. | — | | 91-07 (#4683) | not reached | `sources/live/batch.py`: Offered/default queued population is computed after blocking filters. | — | | 91-08 (#5403) | not reached | `sources/live/batch.py`: Re-resolving historical blocked spellings can implicate a retargeted symlink destination; needs durable-identity handling. | — | | 91-09 (#4587) | not reached | `sources/live/batch.py`: Direct deferred resynthesis is preserved, but deferred flush still re-reads an absent ops cursor; full deferred-plan regression not supplied. | — | | 91-10 (#5015) | not reached | `sources/live/batch.py`: Deferred catch-up convergence still needs its own canonical receipt or duration attribution to the originating attempt. | — | | 91-11 (#4809) | fixed-already | `sources/live/batch.py`: ingest_files catches escaped failures and finalizes the attempt, including writer-hold budget failures. | — | | 91-12 (#4713) | not reached | `sources/live/batch.py`: Current byte accounting labels unattempted bytes, but that does not establish a per-file deferred/excluded disposition for an outer-loop time-... | — | | 91-13 (#4730) | not reached | `sources/live/batch.py`: A structural halt still marks subsequent unattempted source groups as failed rather than refused/unattempted. | — | | 91-14 (#4874) | not reached | `sources/live/batch.py`: Materialized sessions versus successfully parsed file units still needs all reader/telemetry consumers reviewed together. | — | | 91-15 (#4874) | fixed | `sources/live/batch.py`: The completed progress event repeats the already-computed unique materialized-session count after best-effort cursor_update loss. | `test_w9_completed_ingest_repeats_materialized_count` | | 91-16 (#5300) | not reached | `sources/live/batch.py`: Live metrics now expose deferred_file_count, but typed catch-up receipt/CLI propagation is not fully established here. | — | | 91-17 (#4330) | fixed | `sources/live/batch.py`: Source-only acquisition bypasses Antigravity language-server protobuf conversion and retains original bytes. | `test_w9_source_only_protobuf_does_not_invoke_converter` | | 91-18 (#5526) | refuted | `sources/live/batch.py`: This asks to migrate debts stored under predecessor subjects. Prior archive state is explicitly out of scope for fresh v1; current code emits ... | — | | 91-19 (#4175) | fixed-already | `sources/live/batch.py`: Full file-backed JSONL acquisition computes and carries complete_prefix_size rather than requiring an in-memory raw payload. | — | | 91-20 (#4229) | fixed-already | `sources/live/batch.py`: Boundary determination now checks the tail; an interior malformed line does not truncate the cursor before later accepted records. | — | | 91-21 (#4883) | not reached | `sources/live/batch.py`: Snapshot scope selection for a renamed Antigravity SQLite store needs further current policy tracing; no fix or refutation claimed. | — | | 91-22 (#5263) | not reached | `sources/live/batch.py`: Full hook-carrier raw bytes/frontier authority with a partial tail still needs coordinated baseline treatment. | — | | 91-23 (#4661) | fixed-already | `sources/live/batch.py`: ZIP safety admission now precedes provider sniffing on the ordinary live route. | — | | 91-24 (#4661) | fixed-already | `sources/live/batch.py`: Declaration-owned sidecars are excluded from ordinary ZIP provider sniffing. | — | | 91-25 (#4661) | not reached | `sources/live/batch.py`: --explain still sniffs the whole infolist and retains provider_hint when constructing member classification; route equivalence remains open. | — | | 92-01 (#4661) | not reached | worker fix dropped: OTel `.*\.json$` rule makes `declared_artifact_provider` ambiguous for every `.json` member | — | | 92-02 (#4549) | fixed-already | `sources/live/batch.py`: Legacy promotion is now a deferred thunk, not an eager write during initial reconstruction. No legacy upgrade code added. | — | | 92-03 (#4587) | not reached | `sources/live/batch.py`: Full-head reconstruction still requires the old full-file digest before composing a mutable-header Claude semantic frontier. | — | | 92-04 (#5568) | not reached | `sources/live/batch.py`: Equal-metadata measurement-only update handling needs an accepted-change regression; no new fix supplied. | — | | 92-05 (#4587) | not reached | worker refutation rejected: promotion thunk is live; no proof v1 never writes frontier-less appends | — | | 92-06 (#4660) | fixed-already | `sources/live/batch.py`: Cursor publication compares the post-proof file observation with the pre-proof observation. | — | | 92-07 (#4660) | fixed-already | `sources/live/batch.py`: Non-frontier prefix hashing charges cursor hash-read bytes. | — | | 92-08 (#4660) | fixed-already | `sources/live/batch.py`: Publication rebases the accepted body end against the current Claude header length. | — | | 92-09 (#4662) | fixed-already | `sources/live/batch.py`: The rebased publication_end is used for the cursor offset and corresponding file-length guard. | — | | 92-10 (#4662) | fixed-already | `sources/live/batch.py`: Claude frontier read bytes are charged before rejecting an unavailable/invalid proof. | — | | 92-11 (#5258) | fixed | `sources/live/batch_support.py`: The regex no longer treats the virtual empty EOF after a delimiter as a physical blank line; actual blank lines retain their existing ... | `test_w9_jsonl_boundary_keeps_newline_fast_path` | | 92-12 (#5389) | fixed | `sources/live/cold_build.py`: Checkpoint-holder attachment checks the SHM file beside the resolved physical SQLite filename. | `test_w9_ops_holder_accepts_symlinked_database` | | 92-13 (#5609) | fixed | `sources/live/cold_build.py`: A valid sealed complete count reports zero ETA after the advancement freshness window; incomplete and unsealed stale counts still report ... | `test_w9_completed_cold_build_eta_does_not_expire` | | 92-14 (#5609) | not reached | `sources/live/cold_build.py`: Projection refresh time, not receipt acceptance time, still renews the advancement clock. | — | | 92-15 (#5619) | fixed-already | `sources/live/cold_build.py`: refresh_faulted_baseline calls _reset_accepted_progress(merged), then refresh_accepted_progress; the denominator and weights no longer re... | — | | 92-16 (#4185) | not reached | `sources/live/cursor.py`: Completed-with-failures reader/metric label propagation needs all public consumers updated together. | — | | 92-17 (#4730) | not reached | `sources/live/dedup.py`: Structural failure installs a per-source halt; the test autouse fixture only clears the global degraded flag. | — | | 92-18 (#4795) | fixed | `sources/live/hook_paste_enrichment.py`: The enrichment route carries the configured archive root into its write-lease check instead of treating a generation index dir... | `test_w9_hook_paste_uses_archive_lease_for_generation_index` | | 92-19 (#4713) | fixed-already | `sources/live/metrics.py`: LiveBatchMetrics.to_payload serializes both excluded_file_count and excluded_reasons. | — | | 92-20 (#5546) | not reached | `sources/live/parse_prefetch.py`: Attempt cleanup exists, but retention of every unconsumed candidate/shard across warm cohorts is not fully resolved here. | — | | 92-21 (#5546) | not reached | `sources/live/parse_prefetch.py`: Hashless worker errors remain reusable across changed source content; freshness/deferred disposition needs a full route fix. | — | | 92-22 (#5568) | fixed-already | #5691: `_prepare_existing_session_writes(paths=...)` scoped to current candidates | — | | 92-23 (#5634) | not reached | `sources/live/parse_prefetch.py`: Per-path reconciliation opens concurrent read frames without establishing independent scan admission in this function. | — | | 92-24 (#5542) | fixed-already | `sources/live/production_baseline.py`: Baseline.verify delegates to unretained_source_decisions/open_readonly_connection; the manually interpolated SQLite URI is gone. | — | | 92-25 (#5640) | fixed-already | `sources/live/production_baseline.py`: Baseline emits its hashing phase before archive-member expansion and decomposition. | — | ## Derived-identity closure These changed files are members of `docs/plans/schema-closure-baseline.json`, so the derived schema identity moves: `sources/assembly_chatgpt.py`, `sources/dispatch.py`, `sources/drive/__init__.py`, `sources/live/batch.py`, `sources/live/batch_support.py`, `sources/live/cold_build.py`, `sources/live/hook_paste_enrichment.py`, `sources/revision_backfill.py`. `sources/import_preflight.py` is not a member. Membership was read from the committed baseline, not recomputed, because the bulk pool that runs `devtools schema closure` jobs was paused. No module was added to the closure. ## Residuals - 92-01 stays open: declaration lookup needs to prefer a unique raw-only/fact rule over broad session patterns, applied on all three ZIP routes. - 92-05: the worker's fresh-v1 refutation was rejected, because the legacy-append promotion thunk is live code and `ops.db` is disposable. The finding stays open. - Other `-shm`/`-wal` path derivations (`daemon/status.py`, `daemon/health.py`, `daemon/backup.py`, among others) do not resolve symlinks and were not reviewed here. - Preflight now reports DEGRADED for a bounded trajectory probe or a truncated directory walk, not only for parser flags. - `test_unidentified_trajectory_rows_keep_distinct_identities` already fails on master. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…#5798) ## Summary Lands the verified part of the ChatGPT fleet worker-10 output for the Codex P2 review debt in `polylogue-1tyq5.93`, `.94` and `.95` (polylogue/sources parts 4-6, 75 findings). The worker could not run anything; every kept fix here was re-read against the landing head, and every kept fix has a regression test that fails on the base. Per finding: 32 fixed, 9 fixed-already, 1 refuted, 1 dropped as not a defect, 32 not reached. Of the worker's 35 `fixed` claims, 32 land (two of them reworked and one narrowed); 2 are rejected, and 94-18 was withdrawn when this branch merged master (see below). Of its 10 `fixed-already` claims, 1 is rejected as still real. ## Problem The findings are Codex review comments on merged PRs. Each one names an input and a wrong outcome in parser, admission, discovery or derived-identity code. Examples: an Antigravity step with `occurred_at_ms` lost its time; a list-valued ChatGPT `aggregate_result` for a failed run was archived as a success; a directory symlink to an ancestor made `census_source()` loop forever; a Codex `usage` counter of `null` was stored as a measured zero; a source edited between signing and parsing could leave a fingerprint memo describing different code. The table below cites each finding and its evidence. ## Solution - **Antigravity trajectories.** `occurred_at_ms` is read as epoch milliseconds. Tool outcomes read the row's `exit_code`, treat a non-empty string, mapping or list `error` as a failure, and report `not_reported` when no outcome field is present (the origin spec declares that reason). camelCase edit fields are read. Unwrapping `payload` keeps the envelope's role and time. A step that fails typed validation becomes a MALFORMED refusal for that step only. Parent references resolve through the trajectory/cascade alias map before the ambiguity check. - **ChatGPT.** A list-valued `aggregate_result` decides the outcome (any failure fails, all success succeeds, otherwise unknown), and each run emits its own event with `output` and `exit_code`. Citation URLs of the `/g/g-p-…/c/<id>` form keep the conversation id. A non-string `content_type` is typed unknown at the message, media-part and part-accounting sites. A transcription that carries text is not marked `unavailable`. - **Browser capture and Claude web.** Typed `extracted_content` wins over `provider_meta`. A `claude-file:<uuid>` projection reconciles with the native row of that uuid without a byte witness. A cached cross-route match is re-validated before reuse. A conversation-level Claude attachment whose bytes conflict with its descriptor match stays a separate file. - **Counters and references.** Claude Code and Codex usage counters stay unknown unless they are non-negative integers. Codex `local_images` references go through the data-URL sanitizer. Codex state chunk coordinates drop the physical rowid. - **Admission.** `ParseAccounting.assert_conserved` refuses ordinals outside `[0, expected)`. A `tool_use` part with no name, id or input is refused as MALFORMED. Material origin is classified from the same TEXT projection as message type. - **Discovery, walk and identity.** Live discovery sorts entries before a linked directory claims its target. The source walk still follows directory links, but a link to a directory already entered is recorded as a non-regular entry and not entered. `_fingerprint_sources_compute` refuses (`FingerprintSourceChangedError`) when the bytes differ from their signature. Python call operands are no longer SQL-normalized (fingerprint algorithm 4 -> 5). `in_derived_identity_closure` and `devtools schema closure` resolve paths from the caller's directory and refuse missing ones. The Hermes streaming envelope keeps a container-valued marker. Observation contracts are emitted for every provider wire. The synthetic Codex oracle classifies through `classify_message_type`. Rejected worker changes: - 93-01: the empty-retained-scope change is not landed. It would make every Claude Code transcript build a disk-backed tool-result index and read its sibling subagent blobs, and it would still disagree with the acquisition-time resolver. The finding stays open. - 94-16: nested future-type detection was not removed, because it is the tested admission contract. - 93-25 is reworked: the worker's version stopped following directory links. - 94-18 is withdrawn. Master's `AdmissionObserver` (#5711, merged after this branch was cut) deliberately keeps one pending unknown-input event per wire type so memory stays bounded, and `test_admission_payload.py::test_repeated_unknown_records_keep_one_pending_event_per_type` holds that contract. A per-occurrence event list contradicts it, so the merge takes master's observer and drops this branch's version and its test. The finding stays open for a bounded fix. - 95-05 is completed: the worker's version left the accounting set lookup that the finding names unguarded. - 95-09 is narrowed: requiring equal bytes or a shared URL would drop the bytes of the documented metadata-only repeat. ## Merge with master (head `6fc0e31bf8`) Merge commit `6fc0e31bf8` brings in master `1beb2e516a` (including #5711, #5723, #5787 and #5804). No force-push. Conflicts were resolved by intent: - `base_support.py`: master's `AdmissionObserver` is kept as is. The branch's per-occurrence unknown-input events (94-18) are dropped with their test and fixture. See the 94-18 row. - `browser_capture.py`: `_claude_attachment_cross_route_match` compares inline bytes first, then master's content hashes, and only then takes the exact `claude-file:<uuid>` identity (94-24) when neither side has a byte witness. Conflicting hashes still refuse the match. - `antigravity.py`: both the alias-claimant map (94-13) and master's summary-key reservation are kept. They touch disjoint names. The other 32 kept fixes were re-read against master: each hunk is still absent there, and every helper they call (`_iter_mapping_items`, `iso_from_epoch_ms`, `unknown_reason`) exists on master. No kept fix became redundant. ## Verification Every check ran as an agentctl job. After the merge (head `6fc0e31bf8`): - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w10 --wait` (job 2471): `phase: succeeded`, `result: Success`. - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w10 --wait -- <the same 28 modules>` (job 2470): 943 passed, 12 failed. Ten of them are the inherited failures listed below. The other two are also inherited: job 2543 ran them on a master checkout, and both failed there too. They are `test_antigravity_conversation_acquisition.py::test_common_live_batch_retries_a_failed_vendor_conversion` and `test_artifact_taxonomy.py::test_antigravity_brain_metadata_sidecar_is_rejected_from_live_and_schema_routes`. Before the merge: - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w10 --wait` (job 2228, head `d768577f0b`): `verify: PASSED exit=0`. All static gates are ok, including mypy, lint, layering, schema-closure and schema-manifest. - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w10 --wait -- <28 test modules>` (job 2168, head `e8191c523f`, the parent of the rename-only follow-up commit): 908 passed, 10 failed. All 10 failures are inherited. Jobs 2166 and 2229 ran them on the base `915a1f357d` (this branch with every production file reset to the base), and all 10 failed there with the same errors (pre-merge, head `e8191c523f`): - `test_schema_closure.py::…::test_the_checked_in_baseline_matches_the_live_closure`: the baseline lists `polylogue/operations/durable_change_train.py`, which the live closure no longer contains. - `test_discovery_progress.py::test_cold_build_preparation_is_visible_before_the_first_intake_page`: `preparation_revision_count` is 0, expected 2. - `test_codex_state_bounds_and_excision.py::test_large_goal_export_last_row_is_reachable`: pytest-timeout (300s) inside `os.fsync` of the blob directory. - 7 tests in `test_browser_capture.py`: `IngestDaemonRequiredError`, because the API ingest route requires a running daemon. - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w10 --wait -- tests/unit/sources/test_antigravity_trajectory_steps.py tests/unit/sources/test_antigravity_source_acquisition.py` (job 2232, head `d768577f0b`): `devtools test: PASSED exit=0`, 22 passed. - Anti-vacuity: job 2097 ran the five new test modules on a checkout of this branch with every production file reset to the base: 82 of 93 failed. The 11 that passed are the positive controls and the parameters that already held on the base: real zero counters, `None` counters for Claude, `unknown_outcome`, the ambiguous-parent case, and the equal/absent byte relations. The 28 modules run in job 2168: `tests/unit/sources/`: test_antigravity_trajectory_steps, test_counter_and_coordinate_contracts, test_parser_admission_contracts, test_source_walk_and_fingerprint_contracts, test_web_parser_attachments_and_runs, test_admission_payload, test_admission, test_parser_admission_packet, test_antigravity_source_acquisition, test_browser_capture, test_parsers_chatgpt, test_claude_ai_conversation_level_attachments, test_codex_state_bounds_and_excision, test_origin_specs, test_prepared_claude_ai_object, test_prepared_drive_chunked_object, test_parsers_codex, test_nullable_message_usage, test_claude_code_unread_wire_fields, test_live_page_selection, test_source_root_admission, test_artifact_taxonomy, test_parsers_local_agent, test_agent_memory_documents; plus `tests/unit/devtools/test_schema_closure.py`, `tests/unit/core/test_synthetic_semantics.py`, `tests/unit/daemon/test_discovery_progress.py` and `tests/unit/daemon/test_antigravity_conversation_acquisition.py`. ## Self-review I read the full `git diff origin/master...HEAD` against the checklist in `docs/review/codex-review-guide.md`. 1. **Siblings and owners.** The same content_type guard now covers the message-level discriminator, the media-part branch and the part-accounting predicate. Live discovery and the source walk now pick a linked alias by the same name-order rule. Antigravity has one `_tool_outcome`, so the reason change has one site. Remaining divergence: the live walk refuses a link that escapes the root and the source walk follows it. That predates this change and is recorded under residuals. 2. **The fix itself.** `FingerprintSourceChangedError` is new and propagates uncaught. It fires only when a source changes between signing and parsing, and a refusal is safer than writing a wrong memo. The antigravity `ValidationError` catch wraps only the typed construction of one step. 3. **Memory and limits.** Discovery holds one directory's `DirEntry` list to sort it, which is no more than the children list it already builds. The walk's visited set is one entry per directory. No caps were added. 4. **Cost per unit.** Nothing new per row. The admission wrapper builds its per-type counter only when an unknown was observed. 5. **Interruption.** No new loops, waits or multi-step state. 6. **Ordering and races.** The fingerprint now hashes and parses the same bytes. That was the race the finding named. 7. **Failure classification.** A walk `stat` error keeps the directory in the descent, so `os.walk` reports it through `onerror` and it is not silently pruned. 8. **Silent outcomes.** A pruned directory link is still recorded as a non-regular census entry. A refused step or part carries a typed MALFORMED outcome and an event. 9. **Cleanup on failure.** Nothing is acquired before a refusal. 10. **Identity and keys.** Codex state chunk coordinates drop the physical rowid (see residuals for the durable effect). Attachment identity is unchanged. The fingerprint algorithm version moves because the normalization changed. 11. **Lossless transforms.** Unwrapping an Antigravity payload now keeps the envelope fields. Per-run ChatGPT events keep every field the single-run event kept. 12. **Degenerate inputs.** Covered: an empty list `aggregate_result` counts as absent; NaN, negative, bool and fractional counters are unknown; a missing closure path is refused; a missing walk base still walks nothing. 13. **Consumers.** `in_derived_identity_closure` has no production caller; the command and its tests follow it. `artifact_observation_contracts` has no consumer beyond its export. The existing packet test's expected message was updated for the earlier range check. 14. **Tests and stubs.** Every new test drives the production parser, walker, fingerprint or command, and job 2097 shows each one fails on the base. The worker's `ordered_scandir` helper returned a generator context manager that production cannot iterate; it now mimics `os.scandir`. The worker's large-file Hermes test called an API that no longer exists; it now drives `hermes_snapshot_envelope` against `looks_like_hermes`. 15. **Trust boundaries.** Data URLs in Codex references are now sanitized before they reach event payloads. No new secrets or files. 16. **Merge resolution.** The only new logic is the order in the cross-route match. Bytes and then hashes decide before the file-id shortcut, so a projection whose content contradicts the native row is never merged on identity alone. Dropping 94-18 removes a test, a fixture and the now-unused `parse_code` import. No other code referenced them. ## Per-finding dispositions Key `NN-MM` is bead `polylogue-1tyq5.NN`, finding MM. Tests are under `tests/unit/sources/`. "Not reached" rows keep the worker's triage evidence (in the handoff); they were not re-checked here. | key | disposition | evidence | test | |---|---|---|---| | 93-01 #4850 `sources/live/sidecar_resolution.py:141` | not reached (worker fix dropped) | Still real. The worker's fix (an available empty scope when the retained query returns no rows) was not landed: it gives every Claude Code transcript an available scope, so each streamed parse builds a disk-backed tool-result index and, for root transcripts, reads every sibling subagent blob, and it diverges from the acquisition-time resolver, which still reports a missing directory as unresolved. The fix needs both resolvers to agree and a cheap path when the transcript names no persisted output. Left open. | — | | 93-02 #4587 `sources/live/watcher.py:76` | not reached | worker triage; not re-checked | — | | 93-03 #4191 `sources/live/watcher.py:220` | not reached (worker 'fixed-already' rejected) | Still real at the landing head: `run_daemon_services` still runs `src.root.mkdir(parents=True, exist_ok=True)` for every configured source (`polylogue/daemon/cli.py:2395` on master `1beb2e516a`), and `default_watch_sources` includes the legacy-read-only hook carrier sources from `hook_carrier_watch_sources`. The watcher lines the worker cited do not cover daemon startup. Left open. | — | | 93-04 #4791 `sources/live/watcher.py:255` | fixed | Directory entries are sorted by name before a linked directory claims its target, so the retained alias does not depend on scandir order. | test_source_walk_and_fingerprint_contracts.py::test_alias_enumeration_has_one_stable_order | | 93-05 #5265 `sources/live/watcher.py:1215` | not reached | worker triage; not re-checked | — | | 93-06 #4730 `sources/live/watcher.py:1926` | not reached | worker triage; not re-checked | — | | 93-07 #4798 `sources/live/watcher.py:2143` | not reached | worker triage; not re-checked | — | | 93-08 #4587 `sources/origin_specs.py:194` | fixed | `_fingerprint_sources_compute` hashes the exact bytes it parses and refuses (`FingerprintSourceChangedError`) when they differ from the signature that keys the memo, so no memo is written for another implementation. | test_source_walk_and_fingerprint_contracts.py::test_changed_source_cannot_poison_fingerprint_memo | | 93-09 #4856 `sources/origin_specs.py:216` | fixed | String operands inside a Python call are no longer SQL-normalized; the fingerprint algorithm version moves 4 -> 5. | test_source_walk_and_fingerprint_contracts.py::test_sql_replacement_operands_move_fingerprint | | 93-10 #4729 `sources/origin_specs.py:250` | refuted | The closure memo holds a member's import graph fixed for the process lifetime by design: production sources cannot change under a running process, and source-mutating tools call `_invalidate_source_signatures` (polylogue/sources/origin_specs.py `_semantic_source_paths` docstring). | — | | 93-11 #4558 `sources/origin_specs.py:251` | fixed-already | `_source_signature` keys every source by its SHA-256 content digest, not stat metadata (polylogue/sources/origin_specs.py `_source_signature`). | — | | 93-12 #4936 `sources/origin_specs.py:470` | not reached | worker triage; not re-checked | — | | 93-13 #5627 `sources/origin_specs.py:823` | not reached | worker triage; not re-checked | — | | 93-14 #5627 `sources/origin_specs.py:823` | fixed | `hermes_snapshot_envelope` keeps an empty container witness for a container-valued root field, so the streaming recognizer used by prepared intake and provider detection agrees with `looks_like_hermes`. The size-gated probe this finding cited is gone (`recognize_source_class` now streams at every size), but the envelope still decides admission on those routes. | test_source_walk_and_fingerprint_contracts.py::test_streaming_hermes_envelope_keeps_container_presence | | 93-15 #5627 `sources/origin_specs.py:823` | not reached | worker triage; not re-checked | — | | 93-16 #4715 `sources/origin_specs.py:877` | fixed | `in_derived_identity_closure` and `devtools schema closure` resolve relative paths from the caller's directory and refuse a missing path instead of reporting it outside. | test_source_walk_and_fingerprint_contracts.py::test_closure_paths_are_relative_to_callers_cwd | | 93-17 #4661 `sources/origin_specs.py:1129` | not reached | worker triage; not re-checked | — | | 93-18 #4853 `sources/origin_specs.py:1457` | not reached | worker triage; not re-checked | — | | 93-19 #4406 `sources/origin_specs.py:1518` | fixed-already | docs/provider-origin-identity.md no longer carries a hand-maintained Origin token list; it points to the `Origin` enum and the generated table (lines 75-80). | — | | 93-20 #4705 `sources/origin_specs.py:1764` | fixed-already | `parse_sources_archive` hands local sources to `ingest_sources_archive`, the canonical acquisition owner; `_admit_non_session_origin_artifacts` no longer exists, and #5787 deleted `polylogue/pipeline/services/archive_ingest.py`. | — | | 93-21 #4969 `sources/origin_specs.py:2054` | not reached | worker triage; not re-checked | — | | 93-22 #4969 `sources/origin_specs.py:2055` | not reached | worker triage; not re-checked | — | | 93-23 #4914 `sources/origin_specs.py:2286` | fixed | `_tool_outcome` reports `not_reported` when no outcome field is present and `unsupported_construct` only for a present but unmapped one, and the Antigravity spec declares both. | test_antigravity_trajectory_steps.py::test_absent_outcome_is_not_reported | | 93-24 #4936 `sources/origin_specs.py:3370` | fixed | `artifact_observation_contracts` emits rows for every declared provider wire. | test_source_walk_and_fingerprint_contracts.py::test_observation_contracts_cover_every_provider_wire | | 93-25 #4448 `sources/parsers/antigravity.py:182` | fixed (reworked) | The source walk still follows directory links but records a link to an already-entered directory (an ancestor, or a tree a sorted-earlier link reached) as a non-regular entry instead of entering it. The worker's version stopped following links at all, which would have dropped linked export trees. | test_source_walk_and_fingerprint_contracts.py::test_census_records_directory_link_without_following_cycle<br>::test_source_walk_follows_a_linked_tree_and_stops_at_a_cycle | | 94-01 #4883 `sources/parsers/antigravity.py:513` | fixed | `occurred_at_ms` is converted as epoch milliseconds. | test_antigravity_trajectory_steps.py::test_millisecond_step_timestamp | | 94-02 #4883 `sources/parsers/antigravity.py:523` | fixed | The row's `exit_code`/`exitCode` column is read when the payload has none. | test_antigravity_trajectory_steps.py::test_structural_row_exit_code | | 94-03 #4883 `sources/parsers/antigravity.py:530` | fixed | A non-empty string, mapping or list `error` is a failure. | test_antigravity_trajectory_steps.py::test_nonempty_error_is_failure | | 94-04 #4883 `sources/parsers/antigravity.py:563` | fixed | Unwrapping `payload` merges the envelope fields under the nested ones. | test_antigravity_trajectory_steps.py::test_nested_payload_keeps_outer_role_and_clock | | 94-05 #4914 `sources/parsers/antigravity.py:579` | fixed | A step whose typed construction fails validation becomes a per-step MALFORMED refusal plus an `antigravity_unsupported_step` event; siblings still parse. | test_antigravity_trajectory_steps.py::test_bad_patch_refuses_only_its_step | | 94-06 #4914 `sources/parsers/antigravity.py:584` | fixed | camelCase edit fields gate and populate the file edit. | test_antigravity_trajectory_steps.py::test_camel_case_edit_evidence | | 94-07 #4914 `sources/parsers/antigravity.py:653` | not reached | worker triage; not re-checked | — | | 94-08 #4883 `sources/parsers/antigravity.py:655` | fixed-already | `parse_trajectory_db` refuses a step outside `_TRAJECTORY_SUPPORTED_STEP_TYPES`/`_FORMATS` as a typed unknown with an event before any text fallback. | — | | 94-09 #4883 `sources/parsers/antigravity.py:663` | fixed-already | Tool-result steps are already typed TOOL_RESULT at the landing base: `_trajectory_message(step_type="tool_result")` returns `MessageType.TOOL_RESULT` on origin/master 915a1f3 (probed), and tool-call steps are TOOL_USE. | — | | 94-10 #4883 `sources/parsers/antigravity.py:828` | fixed-already | The summary lookup tries both cascade_id and trajectory_id (`summary_key = next(...)` in `parse_trajectory_db`). | — | | 94-11 #4883 `sources/parsers/antigravity.py:844` | fixed-already | A single resolved parent reference populates `parent_session_provider_id` on the parsed session. | — | | 94-12 #4932 `sources/parsers/antigravity.py:855` | not reached | worker triage; not re-checked | — | | 94-13 #5403 `sources/parsers/antigravity.py:1043` | fixed | Parent references resolve through the trajectory/cascade alias map before the ambiguity check; two aliases of one parent are one parent, two parents stay ambiguous. | test_antigravity_trajectory_steps.py::test_parent_aliases_canonicalize_before_ambiguity | | 94-14 #4184 `sources/parsers/base_models.py:100` | fixed | `ParseAccounting.assert_conserved` refuses ranges and outcomes outside `[0, expected)`, so equal counts over the wrong ordinals no longer pass. | test_parser_admission_contracts.py::test_writer_refuses_out_of_denominator_ordinal | | 94-15 #4229 `sources/parsers/base_models.py:320` | fixed | Material origin is classified from the same TEXT-block projection as message type. | test_parser_admission_contracts.py::test_capture_thinking_is_not_runtime_context | | 94-16 #4271 `sources/parsers/base_support.py:112` | dropped: not a defect | Detecting a future-shaped discriminator anywhere in an outer record is the deliberate admission contract: `tests/unit/sources/test_prepared_claude_ai_object.py::test_claude_ai_object_future_wire_type_keeps_parser_admission` and the Drive chunked-prompt test assert that nested `metadata.kind`/chunk `type` values raise `<provider>_unknown_input`, and the streaming envelopes compute the same first future type over nested frames. Removing the recursion (the worker's fix) broke that parity. | — | | 94-17 #4184 `sources/parsers/base_support.py:125` | not reached | worker triage; not re-checked | — | | 94-18 #4271 `sources/parsers/base_support.py:149` | not reached (fix withdrawn) | The cited code was replaced by `AdmissionObserver` (#5711), which keeps one pending event per unknown wire type by design (bounded memory; `test_admission_payload.py::test_repeated_unknown_records_keep_one_pending_event_per_type`). Every occurrence has its own UNKNOWN ledger outcome, but the ledger is only asserted, not persisted. This branch's per-occurrence events contradicted the bounded contract and were dropped in the merge. Open for a bounded fix (e.g. an occurrence count on the per-type event). | — | | 94-19 #4271 `sources/parsers/base_support.py:159` | not reached | worker triage; not re-checked | — | | 94-20 #4184 `sources/parsers/base_support.py:278` | fixed | A `tool_use` part with no name, id or input is a MALFORMED refusal, not a materialized part that yields no block. | test_parser_admission_contracts.py::test_empty_tool_part_is_refused_beside_valid_content | | 94-21 #4802 `sources/parsers/base_support.py:720` | fixed-already | `attachment_identity_hash` (polylogue/pipeline/ids.py) keys attachment identity on message, name and MIME type only; size and bytes are excluded. | — | | 94-22 #4802 `sources/parsers/browser_capture.py:228` | fixed-already | `_merge_envelope_attachments` selects `candidate.inline_bytes if candidate.inline_bytes is not None else existing.inline_bytes`. | — | | 94-23 #4802 `sources/parsers/browser_capture.py:257` | fixed | Typed `extracted_content` is read before `provider_meta.extracted_content`. | test_web_parser_attachments_and_runs.py::test_typed_extracted_content_precedes_provider_metadata | | 94-24 #4986 `sources/parsers/browser_capture.py:318` | fixed | A `claude-file:<uuid>` projection whose uuid equals the native attachment id reconciles without a byte witness. | test_web_parser_attachments_and_runs.py::test_claude_file_projection_reconciles_without_bytes | | 94-25 #4999 `sources/parsers/browser_capture.py:379` | fixed | A cached cross-route match is reused only if it still passes `_claude_attachment_cross_route_match`. | test_web_parser_attachments_and_runs.py::test_projection_id_collision_revalidates_native_target | | 95-01 #4999 `sources/parsers/browser_capture.py:393` | not reached | worker triage; not re-checked | — | | 95-02 #4812 `sources/parsers/chatgpt.py:315` | fixed | List-valued `aggregate_result` is normalized before the outcome mapping: any failed run is an error, all successful is success, otherwise unknown. | test_web_parser_attachments_and_runs.py::test_list_aggregate_result_overrides_delivery_status | | 95-03 #4812 `sources/parsers/chatgpt.py:537` | fixed | The citation URL pattern accepts the `/g/g-p-<project>/c/<id>` form. | test_web_parser_attachments_and_runs.py::test_project_scoped_conversation_citation_keeps_native_identity | | 95-04 #4812 `sources/parsers/chatgpt.py:708` | fixed | Run events are emitted per run (list or single) and retain `output` and `exit_code`. | test_web_parser_attachments_and_runs.py::test_direct_run_outputs_are_retained | | 95-05 #4184 `sources/parsers/chatgpt.py:1066` | fixed (completed) | A non-string discriminator is typed unknown at the message level, the media-part branch and the part-accounting predicate the finding cited; the worker's version left that accounting set lookup unguarded. | test_web_parser_attachments_and_runs.py::test_unhashable_content_type_keeps_valid_message | | 95-06 #4886 `sources/parsers/chatgpt.py:1688` | not reached | worker triage; not re-checked | — | | 95-07 #4873 `sources/parsers/chatgpt.py:1690` | not reached | worker triage; not re-checked | — | | 95-08 #4940 `sources/parsers/chatgpt.py:1758` | fixed | A text-bearing `audio_transcription` construct is not marked unavailable. | test_web_parser_attachments_and_runs.py::test_text_only_audio_transcription_is_available | | 95-09 #4776 `sources/parsers/claude/ai_parser.py:805` | fixed in part | Two records whose bytes are both present and differ are no longer merged under one message identity. The descriptor-only case remains: the worker's stronger rule (require equal bytes or a shared source URL) would drop the bytes of the real export shape this function exists for, a metadata-only message record repeated at conversation level with extracted content (`tests/unit/sources/test_claude_ai_conversation_level_attachments.py`). | test_claude_ai_conversation_level_attachments.py<br>test_web_parser_attachments_and_runs.py::test_conflicting_bytes_keep_a_top_level_file_distinct | | 95-10 #4717 `sources/parsers/claude/code_parser.py:627` | not reached | worker triage; not re-checked | — | | 95-11 #5530 `sources/parsers/claude/code_parser.py:1314` | fixed | `_optional_safe_int` accepts only non-negative integral numbers; null, bool, NaN, negative, fractional and non-numeric values are unknown. | test_counter_and_coordinate_contracts.py::test_claude_invalid_counter_is_not_measured_zero<br>::test_claude_numeric_zero_remains_measured | | 95-12 #4674 `sources/parsers/claude/code_parser.py:1860` | not reached | worker triage; not re-checked | — | | 95-13 #4642 `sources/parsers/claude/code_parser.py:2002` | not reached | worker triage; not re-checked | — | | 95-14 #4808 `sources/parsers/claude/code_parser.py:2598` | not reached | worker triage; not re-checked | — | | 95-15 #5293 `sources/parsers/codex.py:524` | fixed | `_optional_int_field` keeps null and invalid counters unknown and preserves a real zero. | test_counter_and_coordinate_contracts.py::test_codex_sparse_counter_remains_unknown<br>::test_codex_numeric_zero_remains_measured | | 95-16 #4870 `sources/parsers/codex.py:576` | fixed | String and mapping `local_images` references pass through `_sanitize_codex_data_url`. | test_counter_and_coordinate_contracts.py::test_local_image_reference_cannot_copy_inline_bytes_to_events | | 95-17 #4870 `sources/parsers/codex.py:690` | not reached | worker triage; not re-checked | — | | 95-18 #4173 `sources/parsers/codex.py:2276` | fixed | The synthetic oracle classifies Codex nodes through `classify_message_type`, as production does. | test_counter_and_coordinate_contracts.py::test_codex_semantic_oracle_uses_protocol_precedence | | 95-19 #4184 `sources/parsers/codex.py:2828` | not reached | worker triage; not re-checked | — | | 95-20 #4236 `sources/parsers/codex.py:2831` | not reached | worker triage; not re-checked | — | | 95-21 #4184 `sources/parsers/codex.py:2896` | not reached | worker triage; not re-checked | — | | 95-22 #4933 `sources/parsers/codex.py:3558` | not reached | worker triage; not re-checked | — | | 95-23 #4933 `sources/parsers/codex.py:3563` | not reached | worker triage; not re-checked | — | | 95-24 #5626 `sources/parsers/codex_state.py:539` | not reached | worker triage; not re-checked | — | | 95-25 #5626 `sources/parsers/codex_state.py:582` | fixed | Codex state chunk coordinates are `item:field:offset`, without the physical rowid. | test_counter_and_coordinate_contracts.py::test_state_chunk_coordinates_ignore_physical_rowid | ## Derived-identity closure The checked-in baseline (`docs/plans/schema-closure-baseline.json`) lists these changed files: `polylogue/sources/decoder_json.py`, `polylogue/sources/live/discovery.py`, `polylogue/sources/origin_specs.py`, `polylogue/sources/parsers/antigravity.py`, `polylogue/sources/parsers/base_models.py`, `polylogue/sources/parsers/base_support.py`, `polylogue/sources/parsers/claude/ai_parser.py`, `polylogue/sources/parsers/claude/code_parser.py`, `polylogue/sources/parsers/codex.py` and `polylogue/sources/source_walk.py`. `_FINGERPRINT_ALGORITHM_VERSION` also moves (4 -> 5). This PR moves the derived schema identity and must not land during a rebuild. These changed files are outside the baseline: `browser_capture.py`, `chatgpt.py`, `codex_state.py`, `schemas/synthetic/wire_formats.py` and `devtools/schema_closure.py`. The `schema-closure` gate passed in job 2228. ## Residuals - **Codex state materials.** Chunk `source_uri`s change for chunked Codex goals and memories (`codex://state/<kind>-text/<thread>/<item:field:offset>`). This cannot duplicate sessions or messages. These materials are written only by `sources/codex_state_evidence.py` into `source.db` `material_observations`. Nothing lowers them into `index.db`. Their only readers are the `storage/materials.py` helpers (`list_materials`, `list_materials_page`, `get_material`), which no API, MCP, CLI or materializer calls, plus excision and blob liveness, which key on referrer and blob. The live archive holds no rows from the old coordinate: `SELECT count(*) FROM material_observations WHERE source_uri LIKE 'codex://state/%'` returns 0 on `/realm/state/polylogue/source.db` (fresh v1). No change or cleanup is needed. - **Still open from this bead set:** 93-01 (empty retained sidecar scope), 93-03 (daemon startup still runs `mkdir` on legacy-read-only roots), 94-18 (repeated unknown occurrences, withdrawn at the merge), 95-09's descriptor-only case, and the 28 other findings the worker did not reach. - **Fingerprint refusal.** `FingerprintSourceChangedError` repeats until the signature cache is invalidated or the process restarts. That is deliberate, but a long-lived dev process on an edited checkout will keep refusing. - **Link policy.** The source walk follows a directory link that escapes the root; the live walk refuses it. This predates this PR. - **Inherited failures.** The 10 inherited failures listed under Verification are not addressed 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]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at c950478):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 5ebcfe5):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Fixes the eleven verified Codex review findings in the sources / daemon /
operations sweep. Each was re-confirmed at this branch's base before being
changed; none were taken on faith from the sweep file.
Findings and what changed
daemon/backup.py_source_recoverability_proofs[0, end)when the window does not prove the bloboperations/append_acquisition_replay.pyhandle.readline()during replaysources/live/deferred_cursor.pysources/origin_specs.pyinheritance_branch_pointfrommapping.parent/mapping.childrensources/live/source_selection.pysources/live/watcher.pylive-batched-v2->live-batched-v3sources/live/batch.pysources/sqlite_snapshot.pysqlite_sequenceexcluded, so insert-then-delete on AUTOINCREMENT yields no digest changesources/live/batch.pyparsers/base_support.py-> write boundary("model_output", None)and the write rejects the whole sessionsources/origin_specs.py(path, mtime, size)None were refuted. Master moved while this work ran;
git diffover alleleven files across that range is empty, so every cited line still described
current code.
Finding 1: live exposure remains unconfirmed
The code-level defect is real and now covered by a test. Its live
reachability is not established: every current production caller of
admit_raw_observation(revision_governance.py:825,3995,4126) passesprior_head=None, which never reaches the append arm that writes thefull-payload-with-tail-offsets shape. This fixes the defect without claiming
it was reachable in production.
Finding 6: schema-regime classification
Classified as none of the schema-regime classes -- it is not a schema
change. There is no DDL edit and no derived-tier version bump, so no
DerivedDeltaClassdeclaration instorage/sqlite/lifecycle.pyapplies; thattable is keyed on index-schema version pairs.
It is a parser-semantic change, whose declared route is the fingerprint bump
itself.
base_support.pyis already inside the origin-spec parser-semanticclosure (verified:
_semantic_source_pathsfor a parser resolves it), so theorigin-scoped fingerprint recomputed on its own with #4539. The gap was only
the live watcher's hand-written literal. Bumping it marks every existing live
cursor as stale, and the watcher routes those sources back through parse on
its next pass -- the production convergence route. Nothing forces a rebuild by
hand.
Operational consequence: the first daemon pass after this lands re-ingests
every live-watched source once. That is the intended cost of the correction,
but it is a real one.
Finding 10: fixed at the write boundary, not the parser
The sweep points at
base_support.py:633-635. The parser genuinely cannot fixthis:
attachment_from_metatakesmessage_id: str | Noneand there is noidentity to name when it is
None. The stored message id exists only at thewrite boundary, which is where the producer is now supplied -- covering both
the parser-declared and role-derived paths. The fallback completes missing
provenance and never overwrites parser-supplied evidence.
Findings 3 and 9 are one fix
Both derived Claude authority from bytes on disk at planning time rather than
from retained evidence, so a rewrite preserving the prefix length inherited
the previous observation's authority. Finding 3 (deferred cursor) compares the
recomposed frontier's body digest against the recorded one; finding 9
(full-head resynthesis) requires the live prefix to hash to the retained blob.
The reconstructed-chain branch already proved its prefix byte by byte and is
left alone.
Finding 3's check is deliberately on the body, not the whole frontier
token:
ClaudeSemanticFrontieris "replaceable header plus stable body", andan equality check on the token broke
test_deferred_claude_cursor_rebases_frontier_after_header_rewrite, whichprotects legitimate rebasing onto a rewritten header.
Verification
Anti-vacuity was verified mechanically, not asserted: with all ten source
files reverted to master and the new tests kept, every new test fails.
The 15 are the 13 new tests plus the 2 existing expectations this change
updates.
test_backup_still_proves_a_window_shaped_append_rowpasses onmaster -- it is the control proving finding 1's fix did not over-generalize
into "always read the full prefix".
With the fixes restored, the same selection is green:
Collateral selection over the consumers of the changed modules (live watcher,
source snapshot, source differential, catchup planning, codex state, and the
four attachment suites):
After the fixture fix below, the one affected file was re-run on its own:
The other eight files were green in the combined run and are untouched by
that fixture change; no combined re-run was made, so the "219" total is not
claimed as an observed number.
The single failure was
test_parser_fingerprint_change_triggers_reingest,caused by this branch and not inherited. It simulated a fingerprint change by
monkeypatching
_PARSER_FINGERPRINTto the literal"live-batched-v3",which finding 6 makes the real value -- so the patch became a no-op, no change
was simulated, and no reingest fired.
The bump is not miswired; the fixture collided with it. The sentinel now
derives from the real constant (
f"{_PARSER_FINGERPRINT}-changed"), so thetest asserts the same behaviour and cannot silently no-op on a future bump.
Finding 6's own test (
test_superseded_parser_fingerprint_refuses_append_ planning) independently proves alive-batched-v2cursor refuses appendplanning, and went red when the constant was reverted.
Selected scope only: this proves the selected files, not the corpus.
Residual risk
the next daemon pass.
sqlite_logical_revisionfor every AUTOINCREMENTdatabase, so previously recorded identities differ once and those sources
re-acquire on next observation. Self-healing, but not free.
reported case: a
.dbunder~/.codex/sessions/now resolves tocodex-staterather thancodex, because onlycodex-stateaccepts it.That looks correct, but it is a behaviour change the finding did not name.
is applied. Closing that gap needs a larger refactor of the ingest stage.
digest cache keyed on full inode identity including
st_ctime_ns(whichos.utimecannot restore) keeps this correct and measurably faster thanbefore: 0.818 ms/call warm vs 1.343 ms/call for the previous stat-keyed
signature, over a 449-file / 9 MB closure.
(
test_archive_tiers_api_session_costs_read_index_tier,test_existing_same_version_ops_database_receives_additive_call_log,test_record_context_delivery_requires_initialized_user_tier). None are infiles this branch touches and none were in the selections run here.