Skip to content

perf(core): Memoize bootstrap validation and bound the codex replay spool - #5428

Merged
Sinity merged 6 commits into
masterfrom
work/wave-a
Sep 22, 2026
Merged

Sinity merged 6 commits into
masterfrom
work/wave-a

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Cold-build cost work across bootstrap, the codex parser and the live sidecar cursor, plus the prepared-rows disposition counter that makes the parallel-preparation claim falsifiable. Beads: polylogue-q53j4, polylogue-s8x8s, polylogue-fdzb3, polylogue-i07pw, polylogue-9m93s.

Problem

  • initialize_active_archive_root revalidated the six-tier bootstrap on every archive open: 12 validations for 12 repeat opens of one unchanged archive.
  • _skip_js_string_or_comment scanned per character, and every outer loop called it at every program position.
  • The cursor-commit loop opened a per-path connection for each sidecar: 16 raw-fingerprint connections for 16 sidecars.
  • The codex replay memory budget's negative control was red at base — it asserted at most four simultaneously-live records, contradicting the declared 8 MiB budget rather than bounding it.
  • Nobody could see why the writer rebuilt rows: the prepared=None fallback was invisible to anything but a profile.

Solution

  • Bootstrap validation memoizes against an _archive_generation_token, not a once-flag: the token moves on a replaced tier inode, an index promotion, a durable-train manifest change, a format/bootstrap/audit-adoption marker change, or a fork. require_write_lease stays outside the memo.
  • Literal bodies skip by str.find; outer loops jump via re.Pattern.search with three stop patterns, each a deliberate superset of its scanner's interesting set. Equivalence proved differentially against verbatim copies of the pre-change implementations: 40,000 random inputs, every start position, zero mismatches.
  • Cursor commit resolves the whole page under _pinned_source_tier_evidence; ROW_NUMBER() OVER (PARTITION BY source_path ...) reproduces the single-path LIMIT 1 tie-break exactly.
  • The replay control is replaced by a traced allocation peak, matching every other bound in the polylogue-ro922 family.
  • The writer records exactly one terminal reason per session write (prepared_write / prepared_rows / append_prepared_rows vs absent / content_hash_mismatch / prefix_sharing / append_frontier_stale / append_carrier_not_row_tuples / declined), reported in the live batch's full_archive_write_completed payload. Diagnostic only — nothing branches on it.

Verification

devtools verify --quick   ->  PASSED exit=0, 25/25
devtools test <6 storage+sources files>  ->  PASSED exit=0

Every anti-vacuity mutation was executed, not asserted:

  • memo removed -> assert 12 == 0; memo degraded to a once-flag -> DID NOT RAISE RuntimeError on a removed format marker
  • per-character scan restored -> inert scan cost grew by 264000 line events over 24000 added inert characters (bound < 1,200)
  • page pin removed -> cursor commit opened 16 raw-fingerprint and 0 history-sidecar connections for 16 sidecars
  • budget replaced by list(records) -> traced peak 170.1 MB (11.2 MB at head, identical at 10x fewer records)
  • disposition recording removed -> all 8 red; reasons collapsed to one token -> 4 red, proving the tests discriminate rather than merely count

Measured: codex replay 11.2 MB traced peak, flat across a 10x input range (137.6 MB unbounded).

Derived index identity moves (additive-derived). This must land before a fresh rebuild starts, never during one.

Residuals

  • Every throughput AC on operator data (the sealed 516-raw arm, the 419 MB codex whale, the 1.6 GB claude-code file) was not attempted — the lane is restricted to synthetic fixtures. None should be read as attempted-and-failed.
  • live_full_ingest_workers (config.py:636) is a declared public config knob that is inert on every production route. Its remedy is deleting it or collapsing it into the single worker policy polylogue-xecca/i07pw own.
  • storage/derived/raw.py:470-476 still refuses a raw observation component by size, which the 2026-09-16 ruling on polylogue-9m93s withdrew. Removing it needs that bead's bounded-RSS evidence in its place.
  • polylogue-i07pw's scalar shard manifest was deliberately not landed: it only helps if the dominant decline reason is absent, and the counters here are what will say.
  • polylogue-fdzb3 and polylogue-9m93s carry dead anchors (storage/sqlite/write.py:1225, storage/raw_observation_owner.py:78); the bead records need correcting, not implementing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

Summary by CodeRabbit

  • Performance

    • Improved source parsing speed, especially when scanning large JavaScript files and string literals.
    • Reduced memory growth during large streaming imports.
    • Reduced repeated archive validation work while preserving detection of archive changes and failures.
    • Improved full-ingest processing efficiency by reusing source evidence across batches.
  • Observability

    • Added reporting for prepared-row outcomes during archive writes and full-ingest completion.
  • Documentation

    • Updated technical documentation references to match the current implementation.

Sinity and others added 6 commits September 22, 2026 20:12
…ation

polylogue-q53j4 AC1 (bootstrap half). `initialize_active_archive_root` runs
on every index-tier sync write open and once per ingest batch, and its body
opens and validates all six tiers -- a fixed per-call cost a cold build
repeated for every chunk while learning nothing new.

Memoize it against an archive *generation* token rather than a once-flag, as
the 2026-09-16 acceptance addendum requires. The token is built from file
identities and marker presence only -- never content mtime or size -- because
the daemon writes into its own tiers constantly and a content-sensitive token
would identify a new generation on every batch and memoize nothing. It moves
on a replaced tier inode, an index promotion, a durable-train manifest
add/append, a bootstrap/format/audit-adoption marker change, or a fork.
`require_write_lease` stays outside the memo: it decides whether this caller
may bootstrap, which is a fact about the caller, not about the archive.

Verification: devtools test tests/unit/storage/test_archive_bootstrap_generation.py
-> 8 passed. Cost assertion, both mutations executed:
  memo removed        -> assert 12 == 0 (validations per 12 repeat opens)
  memo -> once-flag   -> DID NOT RAISE RuntimeError when the format marker
                         was removed from an already-bootstrapped archive,
                         plus three revalidation tests at assert 0 == 1.

bootstrap.py is IN the derived schema closure; this moves the identity.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…cursor reads

polylogue-s8x8s residuals (c) and (e).

(c) `_scan_code_mode_child_calls` walked a Codex `code` program one character
at a time, asking `_skip_js_string_or_comment` at every position, and that
function then looped once per character of every string literal it skipped.
Jump to the next position a scanner can care about with `re.Pattern.search`,
and skip a literal body with `str.find`. Each stop pattern is a superset of
its scanner's interesting set, so over-matching costs a no-op iteration and
nothing can be skipped. Equivalence checked differentially against the
pre-change implementations: 40,000 random JS-ish inputs, every start
position, zero mismatches.

(e) The cursor-commit loop asked source.db the same two questions about every
`tool-results/` sidecar it committed, and each answer opened its own
read-only connection. Resolve the page once under
`_pinned_source_tier_evidence`; `ROW_NUMBER` reproduces the single-path
`ORDER BY acquired_at_ms DESC, raw_id DESC LIMIT 1` tie-break exactly. A read
failure leaves the page unpinned and every path falls back to its own read,
so `_history_sidecar_retained`'s propagating-failure contract is unchanged.

Verification: devtools test over the two new files -> 12 passed; regression
run over test_live_sidecar_cursor_evidence, test_codex_whale_fixtures,
test_live_batch_support, test_codex_event_stream_contract, test_tool_aliases,
test_parser_admission_packet -> 241 passed, 1 failed
(test_stream_dispatch_does_not_retain_distinct_input_records, inherited).

Cost assertions, mutations executed:
  per-character scan restored -> 264,000 line events over 24,000 added inert
    characters (bound: < 1,200); string-literal loop restored -> 99,960 over
    19,992 (bound: < 200); escape-dense literal 50,312 for 10,107 characters.
  page pin removed -> "cursor commit opened 16 raw-fingerprint and 0
    history-sidecar connections for 16 sidecars", assert 16 == 0.
Equivalence tests stayed green under every cost mutation, which is what makes
them equivalence tests rather than more cost tests.

codex.py and batch.py are both IN the derived schema closure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…ive-object count

polylogue-s8x8s AC2. `test_stream_dispatch_does_not_retain_distinct_input_records`
asserted that at most four decoded input records are simultaneously live
during a stream parse. That condition contradicts the declared replay budget
rather than bounding it: `_CODEX_REPLAY_MEMORY_BUDGET_BYTES` exists precisely
so that a stream small enough to fit is retained in memory instead of being
serialized through pickle. The control was red at 9ef655c and at every head
since AC2 landed, and reverting AC2 is not the fix -- the spool it replaced is
what the bead set out to remove.

Replace it with the bound that is actually load-bearing, stated the way every
other bound in this polylogue-ro922 family is stated: a traced allocation
peak, with the number head measures when the fix is reverted.

Measured 2026-09-22 on a 120,000-record (~110 MB) stream:
  head                      11.2 MB traced peak, identical at 12,000 records
  budget -> list(records)  137.6 MB standalone / 170.1 MB under pytest
A second test pins the shape rather than the constant: ten times the input
must not move the peak.

Verification: devtools test tests/unit/sources/test_codex_whale_fixtures.py
-> 7 passed. Anti-vacuity executed (budget comparison forced true):
  "traced peak 170.1 MB", assert 178349482 < 41943040
  "traced peak grew 9.8x for 10x the records (17.4 MB -> 170.1 MB)"
The same mutation also reddens the two pre-existing budget controls
(test_codex_stream_spills_after_replay_memory_budget,
test_code_mode_item_lookahead_does_not_retain_whole_payload_items).

Inherited-red baseline: the same six-file selection at 9ef655c detached
gives 241 passed / 1 failed with exactly this test as the failure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…red rows

polylogue-i07pw AC1's own proof instrument, named by the 2026-09-16 design
note: "add a counted event on the prepared=None fallback naming the gate that
failed (session_row_existed / hash mismatch / slicing / no shard)".

Profiles of real ingest showed the writer building message and block rows and
`copy_shard_session_rows` never running -- the prefetch miss path was the
common path on real data -- but nothing recorded which gate declined, so "the
ordinary daemon path consumes prepared work" could be neither confirmed nor
refuted from a run. Configured worker or thread counts cannot answer it
either; AC2 says so explicitly.

The writer now records exactly one terminal reason per session write:
prepared_write / prepared_rows / append_prepared_rows when the prepared work
was consumed, and absent / content_hash_mismatch / prefix_sharing /
append_frontier_stale / append_carrier_not_row_tuples / declined when it was
not. The live batch reports the delta over each page in its
`full_archive_write_completed` stage payload, so the number reaches the
receipt a measurement already collects. Diagnostic only: nothing branches on
it.

This also covers the merge-append carrier split polylogue-fdzb3 AC1 depends
on, which no existing test reached: an append whose pinned frontier still
matches reuses the carrier without recomputing identities, and one whose
frontier moved recomputes and lands past the stored frontier.

Verification: devtools test over test_prepared_session_rows,
test_session_shards, test_ingest_governance and the new file -> 46 passed.
Anti-vacuity executed, both directions:
  recording removed              -> all 8 red, "assert {} == {'absent': 1}" etc.
  reasons collapsed to one token -> 4 red, "assert {'fallback': 1} ==
                                    {'prefix_sharing': 1}" etc., proving the
                                    tests discriminate rather than count.

write.py and batch.py are both IN the derived schema closure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
The page pin added a second, softer failure policy beside the one
`_source_tier_evidence_retained` already has, which `gate layering` counted
as a new sqlite degradation site (`sqlite_degradation_site_added`,
baselined_count 214).

Rather than restructure the handler to dodge the census, remove it. The
fallback it guarded bought nothing: on a genuine SQLite error the un-pinned
route raises too, because `_latest_archive_tiers_raw_fingerprint` resolves a
broken read to None and `_source_tier_evidence_retained` then reaches
`_history_sidecar_retained`, whose connection is unguarded and whose
docstring says a read failure must propagate so the pass can requeue. The one
case the handler did separate -- a source tier with no `raw_sessions` table --
is now answered from `sqlite_schema`, the same catalog probe
`_history_sidecar_retained` already makes, so it is a fact rather than a
swallowed error.

Also remap every docs/atlas citation into the four files this branch edits.
`gate atlas` blocked on three misaimed anchors into
archive_tiers/write.py; the citations were realigned by an exact base-to-head
line map, not by hand-counting. SCOPE: docs/atlas/ is outside this lane's
declared write scope; the edit is forced by a quick-set gate this branch's own
line shifts broke.

Verification:
  devtools gate layering            -> exit 0, violations [], count 0
  devtools gate atlas               -> exit 0, 0 misaimed (was 3)
  devtools verify --quick           -> exit 0, 25/25
  devtools render all --check       -> exit 0, "out of sync" count 0
  devtools test tests/unit/sources/test_live_sidecar_evidence_cost.py -> 5 passed

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…rvability payload

The two exact-payload assertions on `full_archive_write_completed` are what
makes the route's observability a contract rather than a log line, so the new
`prepared_row_dispositions` term belongs in them rather than being tolerated
by a subset match. Both routes hand the writer no prepared rows today, and
the recorded `{"absent": 1}` is exactly the finding polylogue-i07pw AC1 needs
to become falsifiable: the same assertion goes red the day the shard path
starts being consumed, which is the point.

Verification: devtools test tests/unit/sources/test_live_batch_support.py
-> 179 passed (was 177 passed / 2 failed against the un-updated expectation).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@Sinity
Sinity enabled auto-merge (squash) September 22, 2026 18:21
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T18:37:17.536451Z 71213b2 PR opened
🔒 Security Review ✅ Completed 2026-09-22T18:37:33.811252Z 71213b2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 4d7cef35-99db-4c2c-97ba-c88c834cb96a

📥 Commits

Reviewing files that changed from the base of the PR and between cba0480 and 71213b2.

📒 Files selected for processing (14)
  • docs/atlas/00-core.md
  • docs/atlas/query-read-path.md
  • docs/atlas/sources-parsers.md
  • docs/atlas/storage.md
  • polylogue/sources/live/batch.py
  • polylogue/sources/parsers/codex.py
  • polylogue/storage/sqlite/archive_tiers/bootstrap.py
  • polylogue/storage/sqlite/archive_tiers/write.py
  • tests/unit/sources/test_codex_js_scanner_cost.py
  • tests/unit/sources/test_codex_whale_fixtures.py
  • tests/unit/sources/test_live_batch_support.py
  • tests/unit/sources/test_live_sidecar_evidence_cost.py
  • tests/unit/storage/test_archive_bootstrap_generation.py
  • tests/unit/storage/test_prepared_row_dispositions.py
 ___________________________
< Goodbye, overlooked bugs. >
 ---------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 0ae92ff into master Sep 22, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the work/wave-a branch September 22, 2026 18:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71213b2848

ℹ️ 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".

Comment on lines +1993 to +1994
closing = source.find(quote, position)
escape = source.find("\\", position)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid rescanning the literal suffix for every escape

For a Code Mode string containing many escapes before its closing quote, each iteration searches the entire remaining suffix for the quote and then advances only to the next backslash, making this O(n²). For example, the new implementation takes about 4 seconds to skip a valid 1.5 MB literal containing 500,000 escape pairs, versus a linear scan previously; larger untrusted Codex programs can therefore stall ingestion. Find the next quote or escape in a single forward search so each character is scanned at most once.

Useful? React with 👍 / 👎.

Comment thread polylogue/sources/live/batch.py Resolved
Sinity added a commit that referenced this pull request Sep 22, 2026
…#5436)

## Summary

Repairs a regression this session introduced in **#5428**. Two
`tests/unit/demo/test_demo_seed_verify.py` failures on master, restored
to green.

## Problem

#5428 memoized six-tier bootstrap validation against an
`_archive_generation_token`. That token keys on file identity and marker
presence — deliberately, so an ordinary daemon write does not look like
a new generation.

Demo seeding is the one route that legitimately re-opens an archive root
whose **tier schema versions** may have moved since this process last
validated them. Self-healing stale tiers is its entire job, and
reseeding within one process is an ordinary operator sequence. An
in-place `PRAGMA user_version` change moves neither the inode nor a
marker, so the second seed skipped revalidation and the staleness
surfaced later as:

```
polylogue.core.errors.SchemaSkewError: index schema skew: expected 107, found 1
```

instead of the actionable refusal this path owns — `"... is not the
current index tier version 107; move it aside and rebuild the archive
root"`.

The safety property held throughout (nothing was moved aside,
`demo_only` stayed `False`), but the operator-facing failure mode
regressed from an instruction to a skew error.

## Solution

`seed_demo_archive` calls the existing
`invalidate_active_archive_bootstrap(archive_root)` before guarding and
reseeding. The memo keeps its full benefit everywhere else; only the
route that knowingly operates on possibly-stale tiers opts out.

## Verification

Bisected across today's merges to attribute it rather than guess:

| commit | result |
|---|---|
| `cba0480d7` (before #5428) | 15 passed, **1** failed |
| `0ae92ffd5` (#5428) | 13 passed, **3** failed |
| this branch | 15 passed, **1** failed |

The two `SchemaSkewError` failures appear exactly at #5428 and are gone
here. The single remaining failure
(`test_seed_demo_embedding_session_is_classified_fresh_not_pending`)
**pre-dates** #5428 and is untouched by this change — it is not mine and
is not fixed here.

```
devtools verify --quick  ->  PASSED exit=0
```

Anti-vacuity: removing the `invalidate_active_archive_bootstrap` call
reproduces `SchemaSkewError: index schema skew: expected 107, found 1`
on
`test_seed_demo_archive_never_self_heals_a_root_that_held_real_content`.
That edit also cascaded unrelated fixture errors in the same file, so
the clean attribution evidence is the bisect above rather than the
mutation alone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Demo archive reseeding now revalidates tier schema versions within the
same process, preventing stale bootstrap state from affecting subsequent
reseeds.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

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.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

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.

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

Fix all 25 confirmed Codex P1 findings of polylogue-ez5b9 (sources-live
and sources-parsers) in one change. This PR now carries the
coordinator's seven fixes plus everything from AgentCTL batch run
`polylogue-20260929-115511-f46562fd` (workers ez5b9.1
parsers/artifacts/rendering, ez5b9.2 prepared acquisition, ez5b9.3
baseline/watcher). That run was abandoned once its content was carried
here, so this is the only vehicle. The branch is rebased onto current
`master`.

## Problem

The findings (threads linked in the table) share one theme: intake
decided an outcome from evidence other than the bytes it published.
Examples: a vendor conversion was published against later protobuf
bytes; provider detection sampled a different revision than the one
sealed; a cursor was authorized from source evidence read before another
writer ran. Others: whole cohorts ran past the writer budget; a torn
JSONL record was skipped on the way to the frontier; growth hid behind
the cursor; the baseline could not recognise retained growth or staged
SQLite coordinates. Several parser shapes were also lost or mis-keyed
before storage: project documents, ID-less tool steps, argument-less
commands, relocated cwds, bare usage records, OTel identity.

## Solution

| Finding | Thread | Fix | Production-route regression |
| --- | --- | --- | --- |
| 11.F006 |
[#4330](#4330 (comment))
| The converter's verified SHA-256 is carried to capture
(`AntigravityExportOutcome.source_sha256`). A capture that hashes
differently is released and refused with
`source_changed_after_conversion`. |
`test_antigravity_conversation_acquisition.py::test_vendor_conversion_cannot_publish_a_later_protobuf_revision`
|
| 11.F007 |
[#4330](#4330 (comment))
| One `admit_acquisition` item boundary covers ordinary files and each
vendor conversion (`admit_path`). The vendor server starts only for an
admitted item. |
`::test_vendor_cohort_checks_the_pass_budget_between_conversations`,
`::test_vendor_admission_refusal_happens_before_server_start` |
| 11.F023 |
[#4809](#4809 (comment))
| The same per-item checkpoint raises a typed `WriteHoldBudgetError`
between conversions without poisoning items. |
`::test_vendor_cohort_propagates_writer_budget_refusal_without_poisoning_items`
|
| 11.F016 |
[#4663](#4663 (comment))
| The append cursor's observed size is bounded by the plan, including
Claude's mutable-header delta, so unprobed growth stays visible. |
`test_live_batch_support.py::test_append_publication_does_not_hide_growth_after_planning[codex,claude-code]`
|
| 11.F019 |
[#4694](#4694 (comment))
| Hook publication queues `hook_paste_enrichment` debt for the affected
old sessions before the hook rows are written, under the same lease.
Re-matching is idempotent. |
`test_hook_paste_enrichment.py::test_late_hook_publication_schedules_its_old_session_not_the_next_batch[debt_write_fails]`,
`::test_replaying_paste_evidence_does_not_move_it_to_a_nearby_prompt` |
| 11.F021 |
[#4809](#4809 (comment))
| Append ingest checks the write-hold budget at start, per plan, parse,
replay, materialize and completion. The typed refusal propagates, and
the retained raw stays retryable. |
`test_live_batch_support.py::test_append_budget_refusal_retains_retryable_raw_without_poisoning_source`
|
| 11.F030 |
[#5428](#5428 (comment))
| Pinned source-tier evidence is read inside the cursor writer
admission, not across the preceding await. |
`test_live_sidecar_evidence_cost.py::test_cursor_evidence_is_pinned_after_writer_admission`
|
| 11.F033, 11.F036 |
[#5546](#5546 (comment)),
[#5557](#5557 (comment))
| The carrier names its decode failure (`DecodeFailure`). The writer
re-raises `PreparedDecodeError`, and `classify_decode_failure` is the
single classifier; `_is_json_stream_decode_error` is deleted. |
`test_live_watcher_parse_stage_equivalence.py::test_path_worker_decode_failure_reaches_terminal_unknown_evidence`
|
| 11.F035 |
[#5546](#5546 (comment))
| `source_snapshot` copies the source once. Sampling, frontier, parse
and seal read that copy, and the seal carries its digest. |
`::test_path_worker_binds_provider_parse_and_seal_to_one_snapshot` |
| 11.F037 |
[#5557](#5557 (comment))
| A stage-owned JSON document without a carrier for its captured bytes
is released and deferred (`live.ingest.json_capture_deferred`). It is
never decoded under the writer hold, even when preparation raised. |
`::test_changed_json_after_preparation_defers_without_writer_decode[both]`,
`::test_preparation_exception_does_not_restore_whole_json_writer_decode[discovery,preparation]`
|
| 11.F039 |
[#5250](#5250 (comment))
| Live full intake (writer, prewarm, path worker) and append decode
JSONL strictly for every provider. A malformed complete record is
`terminal_corrupt_input`, with the raw retained. |
`::test_known_provider_jsonl_with_a_malformed_middle_record_is_terminal[in-writer,worker]`,
`test_live_batch_support.py::test_append_refuses_a_malformed_middle_record`
|
| 11.F051 |
[#5546](#5546 (comment))
| A `BrokenProcessPool` at submit collects finished futures, replaces an
idle broken pool once, and retries the submission. A second break leaves
the path deferred. |
`::test_a_pool_broken_while_idle_is_replaced_at_the_next_submission[pending_completion]`
|
| 11.F053 |
[#5542](#5542 (comment))
| Every baseline decision uses `_retained_source_path`, which is the
provenance sidecar's original path for a staged SQLite snapshot, the
same coordinate acquisition retains. |
`test_production_baseline.py::test_a_staged_sqlite_import_is_baselined_at_the_path_acquisition_retains`
|
| 11.F055 |
[#5542](#5542 (comment))
| Retention of a grown file is proven by streaming and hashing the
baselined prefix of a larger full capture, or of a byte-proven
contiguous append chain rooted at one. A blob read fault is retryable. |
`::test_a_revision_that_grew_before_intake_is_proven_by_the_larger_retained_capture`,
`::test_baselined_and_earlier_accepted_revisions_are_proven_through_an_ordered_append_chain`,
`::test_a_chain_that_does_not_reproduce_the_revision_leaves_it_unretained[5
defects]`,
`::test_a_retained_blob_read_fault_is_retryable_not_unretained` |
| 11.F065 |
[#4801](#4801 (comment))
| Cursor reconciliation takes the newest of the newest materialized and
the newest decided-unresolved raw, ordered by `(acquired_at_ms,
raw_id)`. |
`test_live_watcher.py::test_cursor_reconciliation_restores_the_newest_archived_outcome[3
cases]` |
| 11.F069 |
[#5020](#5020 (comment))
| `WatchSource.path_artifact_kinds` replaces
`allow_path_scoped_artifacts`. `codex-state` admits exactly its
`session_index` and `prompt_history_log` sidecars. |
`test_production_baseline.py::test_the_default_codex_state_source_baselines_only_its_declared_jsonl_sidecars`,
`test_ingest_worker_assembly.py::test_codex_retained_root_sidecar_titles_survive_without_a_live_tree`
(now via `default_sources()`) |
| 12.F001 |
[#4883](#4883 (comment))
| An ID-less trajectory call gets the step-keyed id `<message id>:tool`.
An ID-less result pairs only with a sole adjacent ID-less call whose
declared name agrees. |
`tests/unit/sources/parsers/test_antigravity.py::test_trajectory_id_less_tool_steps_persist_their_pairing_and_file_edit`,
`::test_trajectory_id_less_result_pairs_only_an_unambiguous_adjacent_call[5]`
|
| 12.F011 |
[#4803](#4803 (comment))
| An assistant text node with `metadata.command` and empty or absent
args is a `TOOL_USE` with input `{}`. Its non-JSON text stays on the
block. |
`test_parsers_chatgpt.py::test_chatgpt_zero_argument_command_is_a_tool_call_its_result_pairs_with[empty,absent]`
|
| 12.F012 |
[#4721](#4721 (comment))
| The project filename is stored as `metadata["name"]`, projected to the
derived column `blocks.name`. Markdown, HTML and plaintext media
renderers render the carried body (fenced or escaped). |
`test_parsers_claude_ai_catalog.py::test_claude_project_documents_render_body_and_file_name_after_persistence`
|
| 12.F013 |
[#4721](#4721 (comment))
| `looks_like_session_document` admits the parser's own project and
account-memory detectors. |
`test_ingest_shape_admission.py::test_claude_project_export_reaches_parse_project_through_ingest`,
`::test_claude_account_memory_export_reaches_its_parser_through_ingest`
|
| 12.F014 |
[#4717](#4717 (comment))
| Relocated cwds lead `working_directories`, latest first. Chunk merge
applies the same rule from relocation events. |
`test_claude_code_sidecar_evidence.py::test_resume_route_opens_the_relocated_cwd_after_persistence`,
`::test_chunk_merge_keeps_the_relocated_cwd_first_across_revisions` |
| 12.F018 |
[#4870](#4870 (comment))
| An event counts as a replacement only when neither its message link
nor a same-session message with its native id exists. The provider id is
compared byte for byte. The evidence key is renamed
`replacement_events`. |
`test_corpus_fidelity.py::test_revision_gate_counts_only_events_that_replace_a_missing_message[4]`
|
| 12.F020 |
[#4886](#4886 (comment))
| A bare `token_usage_record` stating a known counter joins either
stream shape without marking it. |
`test_ingest_shape_admission.py::test_codex_rollout_with_bare_token_usage_record_ingests_its_usage`,
`::test_codex_bare_token_usage_record_needs_a_known_counter` |
| 12.F026 |
[#5530](#5530 (comment))
| Each OTel identity component escapes `%` and `:` before the join. |
`test_otel_genai.py::test_session_identity_components_cannot_run_into_each_other`
|

The parser and membership changes alter values derived from bytes
already observed, so both manual invalidation tokens are bumped:
`_PARSER_FINGERPRINT` goes to `live-batched-v4` and
`RAW_AUTHORITY_PARSER_FINGERPRINT` to `revision-membership-v5`.

**Derived-identity closure.** `devtools schema closure` puts these
changed files inside the closure:
`archive/artifact_taxonomy/support.py`, `archive/hydration.py`,
`archive/revision_authority.py`, `sources/dispatch.py`,
`sources/live/{append_ingest,batch,hook_paste_enrichment,parse_prefetch,production_baseline,watcher}.py`,
`sources/parsers/{antigravity,codex,otel_genai}.py`,
`sources/parsers/claude/{ai_parser,code_parser}.py`,
`sources/prepared_jsonl.py`, `sources/source_parsing.py`,
`storage/runtime/archive/records.py`,
`storage/sqlite/archive_tiers/{archive_tiers_specs,write}.py` and
`storage/sqlite/queries/attachment_blocks.py`. This PR must land before
a rebuild starts. The only schema change is additive-derived: the
`blocks.name` index.db column. It has no durable-tier migration.

## Verification

Candidate `4313bff197b1b0420ede997247d9843195c81e69`, on `master`
5d56c3a.

- `agentctl job start polylogue pytest_focused --workspace <worktree> --
<64 affected files>` (the selection is every test file the diff touches,
plus the route and sibling suites): job 3396: `8 failed, 2569 passed`.
All 8 failures are inherited (listed below). An earlier attempt, job
3387, was OOM-killed by systemd-oomd under host memory pressure and was
retried unchanged.
- `agentctl job start polylogue verify_quick --workspace <worktree>`:
job 3388: succeeded, all 12 gates passed.
- Inherited failures, classified on a detached `master` worktree with
`--on-default-branch` (jobs 3335 and 3356 on 749f608, job 3384 on
c950478, job 3401 on 5d56c3a), fail identically on master. They
are filed as polylogue-ouv5f:
-
`test_import_preflight.py::test_unidentified_trajectory_rows_keep_distinct_identities`
-
`test_retained_tool_output_convergence.py::test_gemini_full_tool_output_survives_the_loss_of_its_source_tree`
-
`test_artifact_taxonomy.py::test_antigravity_brain_metadata_sidecar_is_rejected_from_live_and_schema_routes`
  - `test_tool_result_unknown_reason_contract.py` (3 Antigravity cases)
-
`test_source_laws.py::test_parse_payload_dispatches_claude_code_messages_and_single_records`
-
`test_revision_replay.py::test_chain_replay_supersedes_equal_frontier_quarantined_membership_head`
- All fixtures are synthetic. No operator archive was read or mutated.

## Self-review

Checklists re-read: `docs/review/codex-review-guide.md` (including "Do
not flag" and the `polylogue/sources/AGENTS.md` review rules) and the
generic list in `orchestrate/references/worker-contract.md`. It took
four passes over `git diff origin/master...HEAD`:
- Pass 1 found the two manual invalidation tokens left unbumped, which
the guide names as a finding. They are now bumped.
- Pass 1 also found retained routes that still decoded JSONL leniently.
Making them strict was tried; pass 2 showed it livelocked the parser
census, so it was reverted and filed as polylogue-3p8p7. Pass 2 also
found the canonical-ingest vendor stub missing master's `excised`
keyword; it now accepts it.
- Pass 3 was driven by a focused run, where
`test_live_route_interpretation.py::test_a_later_index_revision_re_derives_the_titled_session`
failed on the branch but passed on master. A per-file bisection in probe
worktrees traced it to `revision_backfill.py`, which had been restored
from a newer master than the branch base. Restoring it to the base fixed
the failure; the file is now unchanged against master.
- Pass 4, on the rebased head, found nothing new.

Final pass:

1. ✓ **Siblings and owners.** The ordinary-file and vendor acquisition
routes share one item-admission closure (`admit_acquisition`).
`classify_decode_failure` is the only decode classifier: grep for
`_is_json_stream_decode_error` finds 0 hits. Strict decode covers all
four writer sites, both prewarm sites, the path worker and append. The
retained replay sites stay lenient on purpose (see Residuals and
polylogue-3p8p7), and the ingest-worker validation-mode contract (#1745)
is unchanged. Relocated-cwd order has one owner,
`order_working_directories`, which serves both the parser and chunk
merge. Baseline coordinates have one owner, `_retained_source_path`,
which delegates to acquisition's `original_sqlite_source_path`.
2. ✓ **The fix itself.** The new `AntigravitySourceMutationError` is
caught per item in `iter_antigravity_language_server_sessions` and
becomes a failed path. `WriteHoldBudgetError` is re-raised ahead of the
broad `except Exception` in the append and vendor paths.
`PreparedDecodeError` subclasses `ValueError`, so existing `ValueError`
handlers keep working. The census livelock that strict replay would have
introduced is not shipped.
3. ✓ **Memory and limits.** `source_snapshot` and `_prefix_digest`
stream in 1 MiB chunks. The baseline prefix proof reads one path's raw
rows only for revisions with no exact match. No cap or truncation was
added.
4. ✓ **Cost per unit.** Pinned cursor evidence is still one batched read
per page. Chain roots are memoized, and identical blob sequences are
hashed once. Hook debt targets only the sessions in the carrier.
5. ✓ **Interruption.** Write-hold checkpoints cover every append stage
and each vendor item. Paste debt commits before the hook rows under one
lease. A refused capture is released and the raw stays retryable, as the
budget-refusal tests show.
6. ✓ **Ordering and races.** The protobuf is bound by digest from
conversion to capture, and the JSON carrier is bound to one snapshot's
digest. Cursor evidence is read under the admitting writer. A growth
test grows the file after planning.
7. ✓ **Failure classification.** Blob read faults in the baseline proof
raise `ProductionBaselineReadUnavailableError`, which is retryable.
Mutation after conversion is a retryable item failure. A deterministic
append decode failure goes through `_record_failed_cursor` and its
5-failure exclusion cap, not an unbounded retry.
8. ✓ **Silent outcomes.** Unattempted vendor items carry
`REFUSED_UNATTEMPTED_TIME_BUDGET`. A deferred JSON capture emits
`live.ingest.json_capture_deferred` and records deferral debt. A
malformed live record gets terminal raw evidence instead of a silent
skip.
9. ✓ **Cleanup on failure.** A mismatched capture calls
`release_refused_capture`. A deferred JSON capture calls
`discard_pending_receipt` and discards its carrier. Budget exhaustion
calls `blob_store.discard_pending()`. The snapshot directory is removed
in `finally`.
10. ✓ **Identity and keys.** OTel components are escaped injectively,
and plain spellings are unchanged. The ID-less Antigravity tool id is
step-keyed (`<message id>:tool`), not positional. The corpus-fidelity
anti-join compares raw provider ids byte for byte (the whitespace case
is tested). The `pipeline/ids.py` hash partition is untouched.
11. ✓ **Lossless transforms.** Chunk merge keeps relocation order across
revisions. Re-matching paste evidence does not move it to another
prompt. The ChatGPT call block keeps its non-JSON text.
12. ✓ **Degenerate inputs.** An empty or fully refused vendor cohort
starts no server. A bare usage record without a counter stays refused. A
document without a body renders its header alone.
13. ✓ **Consumers.** `allow_path_scoped_artifacts`, `indexed_events` and
`_is_json_stream_decode_error` have 0 remaining references (`grep -rn`
across `polylogue`, `devtools`, `tests` and `docs`). Every stub of
`iter_antigravity_language_server_sessions` and
`_antigravity_raw_snapshot` matches the new signatures. `docs/daemon.md`
and `docs/maintenance.md` describe the new behaviour. The layering
baseline digest for `production_baseline.py` is re-anchored, with an
unchanged site count.
14. ✓ **Tests and stubs.** Each finding has a test on its production
route (table above), driving `LiveBatchProcessor`,
`ingest_append_plans`, `ingest_record`, archive persistence and
read-back, or the watcher reconciliation, not a helper. Removing the
named fix turns the listed test red: for example, drop `admit_path` and
the pass-budget test converts all three items. Clock-driven tests use
`frozen_clock`. Stubs follow the changed signatures (item 13).
15. ✓ **Trust boundaries.** No secrets or operator data. The pre-commit
secret-scan candidates are pre-existing spans in `revision_backfill.py`
and `test_live_batch_support.py`, not lines of this diff.

Generic list: (1) every criterion is met on the production path, per the
table; (2) siblings are covered in item 1; (3) consumers are covered in
item 13; (4) failures are typed, per items 7 and 8; (5) each new test
fails without its fix (item 14); (6) the diff carries no private data.

## Residuals

- Retained replay still decodes known-provider JSONL leniently, so a
rebuild can publish a session without a malformed record that live
intake refused. Strict replay decoding was tried in this branch and
reverted: the parser census records the parse exception as a `failed`
receipt, re-selects it on every pass, and replay planning then never
completes. Filed as polylogue-3p8p7, which needs a typed terminal census
outcome.
- A JSONL record over SQLite's value bound fails as
`terminal_corrupt_input`, not under a size-specific reason.
- A stage-level preparation exception now defers the page's JSON
documents instead of decoding them under the writer (F037). A prefetch
that failed deterministically would keep them deferred, with visible
debt.
- `canonical_archive_ingest` builds its `WatchSource`s with every path
rule admitted, as before this change. The `codex-state` sidecar boundary
is a daemon-default property.
- The Codex hosted review is usage-limited on this PR (its gate reports
"not required"), so no hosted code review covered this head.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 29, 2026
…5850)

## Summary

Makes master's focused suites green again. The baseline run on master
`633ec18ffc` (job 3431, 30 files) had 41 failures and 1 error, and every
other PR was running into them. They come from 20-odd separate causes.
Where production was wrong, this PR fixes production and uses the
failing test as the regression. Where a merged PR had deliberately
changed the contract, it updates the test to the new contract and cites
that PR. Two failures remain, each with a bead and the evidence below.

Beads: polylogue-ouv5f (all eight tests fixed), polylogue-0e6m3,
polylogue-h9da0 and polylogue-wple (audited and noted; their open
criteria are listed under Residuals).

## Problem

Job 3431 (`pytest_focused --on-default-branch`, 30 files, 1539 tests)
reported `passed 1497, failed 41, error 1`. Its failed-test rerun also
crashed: the rerun passed `…::test_x@web-reader[param-…]` back to
pytest, and pytest answered `ERROR: not found`.

## Solution: production defects fixed

| Failure | Cause | Fix |
|---|---|---|
| `test_raw_observation_derivation` ×4,
`test_retained_tool_output_convergence` (Gemini) | For providers with no
assembly spec, `enrichment_dependency_digest` skipped the evidence
digest that every retained seal computes. Every prepared artifact of
those providers therefore read as stale, and `publish` returned False
forever, so Hermes, Antigravity, ChatGPT and Gemini retained raws never
converged. | Every provider digests its evidence, empty or not
(`sources/revision_backfill.py`). |
| `test_observation_runtime::test_structured_raw_only_sidecar…` | An
artifact-scoped identity hashed to the same `{"source": path}` value
that `_old_path_fallback` refuses, so new sidecar evidence never reached
the cache. | The artifact-scoped identity gets its own namespace
(`schemas/source_inference.py`). |
| `test_verification_evidence_lane` |
`reconcile_and_record_abandoned_verify_runs` compared `cache.parent`
(that is, `.cache`) to the checkout, so the test was never true. The
checkout's reconciled runs went to cache-local history, and cache-local
evidence too (#5720), instead of the durable lane. | Compare the
checkout root, `runs_root.parents[2]`. The checkout uses the XDG history
and `verification_evidence_path()`; a relocated cache keeps local files.
|
| `test_web_reader::test_archive_filter_kwargs…` | #5795 gave
`iter_search_summaries` an `actions_only` lane parameter. The count
route still counted every FTS hit for `retrieval_lane="actions"`. |
`count_search_sessions(actions_only=…)` and the count route pass the
lane. New regression:
`test_actions_lane_count_counts_only_sessions_its_search_returns`. |
| `test_command_catalog::test_tool_outcome_help…` | A Click-level
required option refused `--help` before argparse could print it (#5720).
| argparse owns requiredness, and the metavar is `PATH`. |
| idempotence properties (found while fixing the harness) |
`refresh_session_repos*` stamped `repos`, `repo_checkouts` and
`session_repos` with the wall clock, so no rebuild could reproduce them.
| Stamp them with the session's own time, as `_write_repo_edges` does.
New test: `test_refresh_stamps_the_session_time_not_the_wall_clock`. |
| `test_daemon_http_security` | The daemon client that carries the
credential was chained into the receipt call, so the token scan flagged
the receipt. | Bind the client first (`browser_capture/server.py`). No
allowlist entry was added. |
| failed-test rerun | `report_nodeid_to_selector` did not handle
`name@group[param-…]`, the shape that shortened ids take under
loadgroup, and the long-id map stored uncollectible `@group` ids. |
Handle that shape, and record both map sides in selector form
(`devtools/pytest_rerun.py`, `tests/conftest.py`). |
| `test_session_partition_convergence` (fd leak) | The per-thread
connection cache kept every archive a test built until the descriptor
check ran. | The autouse fixture clears the cache at teardown. |
| `test_session_partition_convergence` (`fields_digest`) | #5799's
column was neither projected nor excluded. | Exclude it, with the reason
(`derived/session/input_binding.py`). |

## Solution: tests updated to contracts that merged PRs changed

- `test_import_preflight`: several unidentified trajectories are refused
(#5711); the old test expected ids minted from row position.
- `test_artifact_taxonomy`: a brain sidecar is observed as
`agent_sidecar_meta` schema evidence (#5781), never as a session.
- `test_tool_result_unknown_reason_contract` ×3: a step with no verdict
field is `not_reported` (#5798). A new route covers
`unsupported_construct` with an unmapped status.
- `test_source_laws`: the stand-in parser accounts for its outer records
(#5816).
- `test_revision_replay`: the direct replay binds Codex enrichment
evidence as the retained writer does (#5643).
- `test_retained_tool_output_convergence` (Gemini): the fixture sidecar
is longer than the 40,000 characters the envelope advertises (the #5643
partial-write guard).
- `test_schema_policy_contracts`: FTS triggers are matched by whole
table name (`messages_fts_readiness_binding` is not FTS-backing); the
restart test clears the bootstrap memo as a restart does (#5428).
Deleted `test_every_prior_index_schema_version…`: at fresh v1,
`SCHEMA_VERSION - 1` is 0, which is the "interrupted create" state that
is re-created by design. No prior version exists.
- `test_durable_migrations`: an archive two slots behind gets the typed
refusal from #5806, and the tier is untouched. The docstring of
`apply_declared_durable_migrations` is corrected. Filed as
polylogue-7yq3f.
- `test_schema_validation`: the member schema names `id` (#4856 reports
unnamed fields), and the keys are plain names, so the marker is what
suppresses them.
- `test_synthetic_wire_support::test_chatgpt_witness…`: the part text
also survives on the tool block, so the test drops it there too.
- `test_archive_ingest_shared_raw`: a ZIP member with a malformed record
is `terminal_corrupt_input` (#5823 F039); a census runs once per raw.
- `test_plain_cli_snapshots`: empty is exit 2 and degraded is exit 1
(`surfaces/outcome.py`).
- `test_cross_surface_agreement`, `test_query_composition_laws`: the CLI
reads through a real daemon (#5805). The naive-join mutant lifts the
read authorizer (#5642) the way `attach_readonly_database` does.
- `test_resource_pilot` ×2: parser scratch SQLite (`:memory:` and temp
files) is allowed; any database file or tier is not.
- `test_codex_debt_w1` and the convergence properties: the harness bound
each session's own evidence to message 0 and stamped replayed messages
with the child's values. Since #5826 shares only an identical prefix, no
lineage prefix was shared at all, and the append-prefix laws were
vacuous. A fork now replays its parent's parsed prefix exactly, and its
own evidence moves to the first message it authored. The mutation test's
`_resolve_session_graph` mutant returns `set()` to match the current
signature.
- `test_query_exec_laws` ×4: stub the convergence probe in fake-store
stats tests (#5700), add the `tool_input` projection field, and expect a
second window sized to the remaining limit.
- devtools: `test_verify` stubs the executor,
`test_pytest_suite_cost_plugin` builds the recorder before patching RSS,
`test_verification_terminal_receipts` updates the sizing stub signature,
and `test_verification_result` adds the #5720 `flaky` field.
`test_http_bounded_mutations` adds the #5723 summary read to its test
double.

Derived-identity closure (`devtools schema closure`): these files are
IN: `archive/query/archive_execution.py`, `schemas/source_inference.py`,
`sources/revision_backfill.py`,
`storage/derived/session/input_binding.py`,
`storage/derived/session/repo_observations.py`,
`storage/sqlite/archive_tiers/archive.py`. The rest are out.

## Verification

- Baseline, master `633ec18ffc`, job 3431: `passed 1497, failed 41,
error 1`.
- `agentctl job start --workspace
/realm/worktrees/polylogue-master-green polylogue pytest_focused -- <61
files>`, job 3578, head `a7f4465c56`: `passed 2336, failed 2` after the
in-slot rerun. The first attempt ran under host I/O contention, with
workers in D state. 25 of its 27 first-attempt failures were `Timeout
(>120.0s)`, and every one of those passed when rerun alone.
- `test_web_reader::…searches_from_archive_tiers`: a socket timeout
under the same load. It passed alone in job 3861 (`devtools test: PASSED
exit=0`).
-
`test_supported_routes_validate_selected_schema_and_parser_entry_point`:
inherited, see Residuals.
- Master baseline for the added files, job 3562: `test_query_exec_laws`
×4, idempotence ×7 and mutations ×2 fail on master the same way. All of
them are fixed here.
- Harness consumers and count seams at head `1d3b3545c5`, job 3920 (24
files): `passed 589, failed 1` after the in-slot rerun. The one failure,
`test_inferred_corpus_loop::test_every_supported_inferred_element_reaches_convergence_and_red_twin`,
was a `Timeout (>120.0s)` inside `load_package_catalog` under the same
host load. It passed alone in job 3973 (`devtools test: PASSED exit=0`).
- `verify_quick` on head `1d3b3545c5`, job 3921: `verify: PASSED
exit=0`. The hosted `ci/circleci: quick-gate` passes.
- `verify_quick` on head `a7f4465c56`, job 3579: `verify: PASSED
exit=0`.

## Self-review

I did two passes over the full diff against `master`, using
`docs/review/codex-review-guide.md` and the generic worker-contract
list. Pass 1 found two defects, both fixed in `1d3b3545c5` and
`3ec0a5fa2f`. Pass 2 was clean.

1. ✓ **Siblings and owners.** The actions-lane count was also wrong in
two more places: the facade/daemon seam
`_archive_count_sessions_for_spec` and the daemon `count` mode
(`operations/daemon_reads.py`). Pass 1 found them with `grep -rn
count_search_sessions polylogue` (7 call sites); both are fixed and have
a regression test. The MCP route already reports `total=None` for
actions (`mcp/archive_support.py` `ranked_only`), and `sessions.search`
is lexical only. The enrichment digest has a single owner
(`enrichment_dependency_digest`) used by both the live and the retained
check. Every seal computes the evidence digest unconditionally, the live
enricher included. A search of `polylogue/storage/derived` for
wall-clock stamps found two others: the marker cursor `applied_at_ms`
(operational metadata) and `profiles.now_iso` (materialized-at). Neither
is a semantic column.
2. ✓ **The fix itself.** Pass 1 found that `_replayed_parent_prefix`
would recurse forever on a declared parent/child cycle
(`cycle_candidate=True`). It now tracks the lineage it walks, and picks
the parent revision the way `authoritative_sessions` does.
`count_search_sessions(actions_only=False)` defaults to today's
behaviour for every other caller.
3. ✓ **Memory and limits.** Nothing new grows with the input. The repo
stamp is one indexed `SELECT` per refreshed session. No caps or timeouts
were added.
4. ✓ **Cost per unit.** One predicate on the count query and one
primary-key read per repo refresh. `with_retained_assembly_evidence`
returns at once for providers without assembly evidence
(`sources/retained_assembly.py:470-479`).
5. N/A **Interruption.** No loops, waits or multi-step state changes
were added.
6. ✓ **Ordering and races.** The repo stamp is read inside the
materializer's own transaction, on the same connection that writes the
rows.
7. ✓ **Failure classification.** The reconciler's history and evidence
appends keep their existing `suppress(OSError, ValueError)`.
`verification_evidence_path()` now expands `~`, as the old inline
override did.
8. ✓ **Silent outcomes.** Actions-lane totals now count what the lane
can return. Exit codes follow outcomes (`surfaces/outcome.py`), and the
updated CLI tests assert exit 2 for empty and 1 for degraded.
9. N/A **Cleanup on failure.** Nothing new is acquired.
10. ✓ **Identity and keys.** Artifact-scoped source identity now lives
in its own `{"artifact": …}` namespace, so it can no longer collide with
the retired `{"source": path}` identity. Old cache rows under the path
identity are still refused by `_old_path_fallback`.
11. ✓ **Lossless transforms.** The rerun selector keeps the `[param-…]`
label, and the long-id map now stores both sides in collectible form.
The harness deep-copies the parent messages it replays.
12. ✓ **Degenerate inputs.** A missing session row stamps 0, the
writer's own default. A child with no own messages keeps position-0
evidence. A shared prefix of 0 replays nothing.
13. ✓ **Consumers.** `count_search_sessions` gained an optional keyword;
every test double takes `**kwargs`, and none asserts the exact kwargs
(checked at `test_query_exec_laws.py:1301,1385,2099` and
`tests/infra/archive_store_double.py:255`). The unused `now_iso`
parameters were removed, and `grep` finds no callers passing them.
14. ✓ **Tests and stubs.** Each production fix has a test that goes red
without it. The count tests go 2 → 3 without `actions_only`. The repo
test goes red if the rows are stamped with the wall clock. The
evidence-lane pair covers the checkout and the relocated cache.
`test_rerun_selector_strips_the_xdist_group_suffix` covers the new id
shape. The source-inference test goes red without the separate
namespace. Stubs follow the current signatures: the
`resolve_worker_argument` stub takes `**sizing`, the
`_resolve_session_graph` mutant returns `set()`, and the test double
implements `get_session_summaries`.
15. ✓ **Trust boundaries.** The capture handler binds the
credential-holding client apart from the receipt, and no token-scan
allowlist entry was added. The fixtures are synthetic.

Generic list: (1) criteria are met on production routes (probes and job
3578). The unmet ones name their blockers (4xyn9, 7yq3f, h9da0, 0e6m3,
wple). (2) Siblings: see item 1. (3) No predecessor is kept beside a
replacement. (4) No silent fallback was added. (5) Each new test names
the change that turns it red. (6) The diff, receipts and text carry no
secrets or private data; the paths are worktree scratch paths only.


## Residuals

- polylogue-4xyn9:
`test_supported_routes_validate_selected_schema_and_parser_entry_point`
still fails. The claude-ai v2 coverage witnesses combine mutually
exclusive groups, so 529 of 844 keywords are missing. It fails the same
way on every commit back to #5485 at least. Honoring the exclusions in
coverage mode alone still leaves 319 missing, so this needs a coverage
planner.
- polylogue-7yq3f: catch-up across more than one numbered slot is
refused, and a backup is taken before the refusal. Nothing breaks until
the second migration of a tier ships.
- polylogue-3p8p7 (owned elsewhere): a loose malformed workflow journal
still reads as `workflow_journal` through the lenient retained decode;
the ZIP route is strict.
- polylogue-h9da0: quick-pool xdist width is sized from the slice's
current headroom, not from a per-job share. Two jobs that start together
can both admit a full width. Left open.
- polylogue-0e6m3: the per-cache retention measurements need a scheduled
broad run. Left open.
- polylogue-wple: master already enforces the foreign-interpreter and
foreign-import checks. Detecting copied testmon or verify state is still
open.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant