Skip to content

fix(ingest): admit prepared rows against the parse-bound digest - #5694

Merged
Sinity merged 1 commit into
masterfrom
claude/perf-sealed-digest
Sep 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
claude/perf-sealed-digest

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Summary

The revision replay admits a worker's prepared rows against the session's parse-bound digest. The writer then copies rows it used to rebuild, and a prepared session stores the same sessions.content_hash as the inline route.

Problem (evidence)

Numbers come from devtools bench fresh-build (#5678). Each run cold-builds a sealed 144-file (276 MiB) private sample of Claude Code, Codex and Gemini sources through polylogued run --cold-build-index on a shared host (load 18-35). Only aggregate numbers are quoted. Wall times move with host load; writer holds, stage timers and CPU seconds move less.

The writer's prepared-row dispositions recorded content_hash_mismatch for 126 of 148 sessions. A worker lowers a prepared session's sink in place (derived tool outcomes, active-path normalization). The inline route applies the same lowering only while building rows. Both bind the digest of the parsed content, but apply_raw_revision_replay re-hashed the lowered sink. Every session with a tool call therefore disagreed with its shard. The writer rebuilt rows and identities itself and stored a digest the inline route never produces. Probe over 12 Codex and 12 Claude Code files from the sample, same bytes through both routes:

route prepared rows used content_hash equal to inline
master, prepared 1/12 Codex, 3/13 Claude 1/12, 2/13
this PR, prepared 12/12, 13/13 12/12, 13/13

Solution

_carried_session_content_hash resolves the replay's aggregate digest, and the ungoverned already-applied check, through bound_session_content_hash when one is carried. The projection and the other replay entry already do this.

Verification

  • devtools test tests/unit/sources/test_prepared_jsonl.py tests/unit/sources/test_live_watcher_parse_stage_equivalence.py tests/unit/storage/test_prepared_row_dispositions.py tests/unit/storage/test_session_shards.py: PASSED.
  • New test test_prepared_session_with_lowered_sink_keeps_identity_and_rows: a Codex tool call ingested inline and through the parse stage. On master it is red: the writer copies 0 shard sessions, and sessions.content_hash differs.
  • Benchmark output fingerprint against the previous candidate: every table is identical except sessions, raw_revision_heads, session_profiles and session_usage_rollup_bindings. Those four carry the session digest. In sessions, 126 rows differ in content_hash, and the code fingerprints differ as expected. Index plus materialize stage time fell from 71.6 s to 41.1 s.

Residuals

  • revision_governance.py is IN the derived schema-identity closure. Stored digests for prepared multi-tool sessions change to the inline-route value, so the change must land before the fresh build starts.
  • Streamed multi-chunk merges (prepared_merge) hash the merged session built from already-lowered chunk sinks, so they may still differ from the inline route. The sample did not exercise that path, and it is not verified.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

A prepared session's sink is lowered in place on the worker (derived tool
outcomes, active-path normalization); the inline route applies the same
lowering only while building rows, and both bind the digest of the parsed
content. The revision replay re-hashed the lowered sink instead, so for
any session with a tool call the writer's digest disagreed with the
shard's: it declined the worker's prepared rows as content_hash_mismatch,
rebuilt rows and identities itself, and stored a sessions.content_hash
the inline route never produces for the same bytes.

Resolve the replay's aggregate digest (and the ungoverned already-applied
check) through the carried digest, as the projection and the other replay
entry already do.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 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-27T22:25:56.319469Z b4fb372 PR opened
ℹ️ About Codex in GitHub

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

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

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

@Sinity
Sinity enabled auto-merge (squash) September 27, 2026 22:39
@Sinity
Sinity merged commit 03c543d into master Sep 27, 2026
3 checks passed
@Sinity
Sinity deleted the claude/perf-sealed-digest branch September 27, 2026 22:39
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