Skip to content

3.x.x: list the legacy audit rows import-audits refuses for 2.x's window-proof parts digest, and write their sidecars in shards (#731) - #732

Merged
RobertClarke merged 4 commits into
3.x.xfrom
RobertClarke/legacy-parts-digest-check
Oct 6, 2026
Merged

RobertClarke merged 4 commits into
3.x.xfrom
RobertClarke/legacy-parts-digest-check

Conversation

@RobertClarke

@RobertClarke RobertClarke commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Why

The cutover drill's import-audits stopped with invalid audit body ref: window proof share_parts_digest_hex mismatch.

The bodies are intact. The cutover path is canonical sidecars, proven and written by scripts/prism_legacy_range_sidecars.py (#715). #731 tracks the runtime fix for after the cutover.

This PR pins the two scripts the drill uses tonight. They are byte-for-byte the copies the drill runs:

Script sha256
scripts/prism_legacy_parts_digest_check.py bb517f29ef2a2d8c4e57bb7fa239b8f037d5e12433767be6da8898b3434f7fa5
scripts/prism_legacy_range_sidecars_sharded.sh 7c24c260ee0a2eae0ca85ccb31528ae07e5908aea3709328123d9a3a7e3a3205

What

  • scripts/prism_legacy_parts_digest_check.py lists the rows import would refuse, without reading any slot.
    • It follows import's order: a row whose sidecar is in --sidecar-dir (import's --root) is has-sidecar, and its body isn't read.
    • For a v2 body it recomputes the digest in 2.x's form and in the form 3.x recomputes: the parsed fields, keys sorted, raw UTF-8.
    • --affected-csv writes the refused rows (2x-order-only, matches-neither) in the sidecar tool's --rows format.
    • --jobs N parses bodies in parallel.
    • It exits 0 only when no row would be refused and every body is readable and holds the row's digest.
  • scripts/prism_legacy_range_sidecars_sharded.sh runs the sidecar tool with --write over N disjoint shards.
    • Each shard has its own CSV (a round-robin split that keeps the header), its own work directory and its own report. The tool's report otherwise defaults to one file in the current directory.
    • It exits 0 only when every shard exits 0 and no temporary file is left in the import root.
    • It refuses an output directory inside the import root, or one that isn't empty.
    • A rerun verifies existing sidecars (sidecar-ok) instead of rewriting them.
  • tests/fixtures/prism-legacy-v2-audit-body/ is a v2 body and its two slots, written by 2.x.x's own writer (AuditArtifactStore.prepare_external_audit_body at 50e208ca) for a bundle built by qbit-prism-build-audit-bundle. Its README records exactly how it was made. 2.x's v2 writer only emits segment_range parts, so the fixture has no inline part.
  • tests/test_prism_legacy_parts_digest_check.py:
    • every status, the URI mapping, the CSV contract with the sidecar tool, and --jobs parity;
    • the sharded runner over a stub canonicalizer that refuses 2.x's parts digest as 3.x does, with its guards and a failing shard;
    • with PRISM_AUDIT_CANONICALIZE_BIN, the fixture against the real canonicalizer:
      • the checker's 2.x digest reproduces the one 2.x stored;
      • the canonicalizer refuses the body exactly when the checker lists it;
      • it accepts the body once the digest is in the checker's 3.x form, with the canonical sha256 equal to the committed digest;
      • the sharded runner turns copies of the fixture into proven sidecars, and a rerun verifies them.
  • CI's real-canonicalizer step and make test-prism-legacy-range-sidecars run the new module. docs/prism-rust-migration.md documents the procedure next to 3.x.x: legacy audit segment range digests use Python's ASCII-escaped JSON; also accept that form so 1.x/2.x bodies with non-ASCII worker names verify without sidecars #709's.

Test evidence (local)

  • python3 -m unittest tests.test_prism_legacy_parts_digest_check: 18 tests, OK (2 skipped without the binary).
  • With PRISM_AUDIT_CANONICALIZE_BIN=target/debug/qbit-prism-audit-canonicalize, tests.test_prism_legacy_range_sidecars plus the new module: 38 tests, OK. The new module also passed three repeat runs.
  • check_gate_env_reads.py, check_prism_settings.py, check_deleted_test_map.py, check_toolchain_pin.py, tests.test_docs_lab_prism_references, tests.test_check_prism_settings, tests.test_check_gate_env_reads and tests.test_makefile_lifecycle all pass.

Refs #731

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…dow-proof parts digest, and write their sidecars in shards (#731)

2.x wrote an audit-bundle.v2 body's share_parts_digest_hex over its share
parts in insertion order, and 3.x recomputes it with serde_json's sorted
keys. So import-audits refuses every such body whose canonical sidecar is
missing from its root (#731); on the cutover drill's restored tree that was
9,531 rows. The bodies are intact, and the cutover path is the canonical
sidecars that prism_legacy_range_sidecars.py (#715) proves and writes.

scripts/prism_legacy_parts_digest_check.py lists those rows without reading
any slot. It follows import's order: a row whose sidecar is in the import
root is not checked further. For a v2 body it recomputes the digest in 2.x's
form and in the form 3.x recomputes, writes the refused rows in the sidecar
tool's --rows format, runs in parallel with --jobs, and exits 0 only when no
row would be refused.

scripts/prism_legacy_range_sidecars_sharded.sh runs the sidecar tool with
--write over N disjoint shards, each with its own CSV, work directory and
report; the tool's report would otherwise be one shared file. It exits 0
only when every shard does and no temporary file is left in the import
root, and refuses an output directory inside the import root or one that
is not empty.

A fixture written by 2.x.x's own writer pins both forms. The checker's 2.x
digest reproduces the one 2.x stored, and the real canonicalizer refuses the
body exactly when the checker lists it, then accepts it, with the canonical
bytes' sha256 equal to the committed digest, once the digest is in the
checker's 3.x form. The tests also run the sharded runner with the real
canonicalizer and check its guards. CI's real-canonicalizer step and make
test-prism-legacy-range-sidecars run the new module, and
docs/prism-rust-migration.md documents the procedure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 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-10-06T20:13:28.800197Z 4924efb New commits
ℹ️ 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.

@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: af7c13ddbe

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

…r cover

has-sidecar means only that the sidecar file is there, and import verifies
its bytes; the checker's exit 0 covers this digest, missing or unreadable
bodies and v2 bodies for another digest, not the other ways import can
refuse a row, such as #709's escaped range digests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: 4bd8c036a3

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

RobertClarke and others added 2 commits October 6, 2026 16:08
…er's edge cases as 3.x does

ShellCheck refused the runner's `ls shard-*.csv | wc -l` (SC2012). It now
keeps the shards in an array, accepts 1 to 99 shards (the two-digit split
suffix), and succeeds only when every shard has left an exit status.

The checker now treats an empty share_parts_digest_hex as 3.x does: as a
value it compares and refuses, not as a missing digest. It reports a
body-ref that commits to another audit digest as body-digest-differs, and
a body that raises while being classified is reported as body-unreadable
instead of ending the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2026-08-24 have no canonical sidecar

The guide said 2.x wrote a sidecar beside every v2 body. It writes one beside
each new body only since #173 was deployed. On union, the bodies from before
2026-08-24, about 9,500 of them, have none, so most legacy v2 rows reach the
parts-digest check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RobertClarke
RobertClarke merged commit a5c0afc into 3.x.x Oct 6, 2026
40 checks passed
@RobertClarke
RobertClarke deleted the RobertClarke/legacy-parts-digest-check branch October 6, 2026 20:35
RobertClarke added a commit that referenced this pull request Oct 8, 2026
Set VERSION and [workspace.package].version to 3.0.0-rc.5: rc.4 plus
#737's fixes in #742 (fatal-state clear accepts a tip that only grew,
takes --timeout-seconds, and runs the integrity report under its own
statement timeout) and #744 (migration 026: the report computes each
set once); the deferred share-hash backfill in #743 and #746 (migrate
--defer-share-hashes, then the throttled backfill-share-hashes after
go-live); #745 (migrate --offline-indexes, which composes with
--defer-share-hashes); the cutover tooling merged after rc.4's tag
(#728, #732, #736, #740); and #747, a test-only fix for #724. Both
Cargo.lock files move only their workspace-member entries.

doc/release-notes-3.0.0-rc.5.md, dated 2026-10-08, covers:
- the changes, with the report's estimated 57 to 29 s since 026, the
  migrate --defer-share-hashes command measured on the pair at
  5 min 06 s (539d6c9, before #745), backfill-share-hashes' throttle,
  record of 2 and safe rerun, the evidence scripts' changes, and the
  offline index builds' estimated gain;
- upgrading: migrate is needed again (a binary-only upgrade refuses
  "missing migration(s) 26", and this export refuses a database without
  026), the cutover's migrate step with both flags, and finishing the
  backfill after go-live under #738's snapshot rule, with self-check
  only at low share rates. Rolling back to rc.4 at fence 2 goes only by
  finishing the backfill first or from the pre-migrate backup or
  physical copy, and each rc.4 refusal is quoted where it applies: a
  start meets the cursor first and says to run migrate, which rc.4's
  migrate refuses. The rules still in force: #737's statement timeout
  for rc.4's tools, 026 or not, #738's snapshot rule, and fatal-state
  clear --timeout-seconds, whose bound ends before the commit;
- the same evidence set as rc.4's, with each PR's merge SHA, the pair's
  serving evidence carried, and the rehearsal's full measurements left
  to the cutover's go/no-go record;
- the known issues: rc.4's, minus #737's F1, F2, F4 and F5, plus
  #737's open part, #738 (its fix planned for rc.6), #739, #741, #731
  and #734, with #582 closed and #712 and #724 updated.

docs/prism-rust-migration.md now says how earlier candidates refuse a
database at fence 2: a start with the backfill's own refusal, whose
advice to run migrate holds only for this release, and their migrate,
or a start with PRISM_POSTGRES_INIT_SCHEMA=1, with the fence. The
development-line notes name 3.0.0-rc.5, and they and the 3.0.0 notes
link all five candidates' notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant