Extract PRISM audit artifact ownership - #75
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dbbe0242a8
ℹ️ 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".
5f5ed20 to
e3b3e6d
Compare
dbbe024 to
a0f1f78
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0f1f78920
ℹ️ 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".
a0f1f78 to
290a444
Compare
e3b3e6d to
0cdd951
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 290a444. Configure here.
290a444 to
d077088
Compare
afedf8e to
aa0257e
Compare
4b5cd53 to
f12ac85
Compare
aa0257e to
efe2122
Compare
f12ac85 to
6426c85
Compare
efe2122 to
0438c70
Compare

Position in the stack
PR 3 of 9. Base:
prism-coordinator-core-owners. Depends on PR 74. Next: PR 76.Review this PR against its configured base. See the stack guide for the complete order.
Why this slice exists
Audit evidence needs one filesystem authority and one durable ordering authority. Process order, height, filename, and mtime cannot safely choose current evidence across restart, same-height replacement, replay, or reorg. This slice moves filesystem publication into
audit_artifactsand makes the PostgreSQL ledger assign the durable publication ordinal at block confirmation.What changes
audit_artifactsown descriptor-relative filesystem access, canonical verification, atomic publication, replay/repair, retention, and current-evidence selection.bundle_compilerand database authorization in the ledger.audit_publication_sequencetoqbit_pool_blocks, deterministic historical backfill, uniqueness/state constraints, and confirmation/reactivation semantics.Why the diff is large
GitHub reports about 17,000 additions, but most of that is the correctness proof around a sensitive persistence boundary:
This is not primarily coordinator line reduction. The additional code makes filesystem identity, cross-process publication, migration failure modes, and replay ordering explicit and testable. Review the SQL transition first, then the filesystem invariants, then coordinator/ledger wiring, and finally the process gates.
Behavior and risk
This is a high-risk durability and upgrade slice. The intentional behavior change is durable audit publication ordering. Confirmation allocates an ordinal; exact confirmation replay and later reactivation retain it. Audit sequence, not process timing or height, selects current evidence.
Required existing-database migration
Deployments with
PRISM_POSTGRES_INIT_SCHEMA=0must applycrates/qbit-prism/sql/001_share_ledger.sqlbefore starting the upgraded coordinator.The cumulative script is idempotent, but the migration is read- and write-impacting:
ALTER TABLEtakesACCESS EXCLUSIVE; a later serialized phase takes a transaction advisory lock plusSHARE ROW EXCLUSIVEonqbit_pool_blocks; and the unique index is built non-concurrently. Stop the old coordinator or use a reviewed maintenance window, take the normal backup, and apply withON_ERROR_STOPusing the PRISM database role and schema search path.Validation
qbit-prism: 182 passed on the final tree.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
High Risk
Changes block-confirmation persistence, live-database migration locking, and audit ordering invariants; upgrades need a maintenance window and correct schema application before rollout.
Overview
Introduces
audit_publication_sequenceonqbit_pool_blocksas the ledger-owned ordering key for audit evidence, allocated when a block moves prepared → confirmed vianextvalinqbit_confirm_pool_block. Inactive → confirmed reactivation keeps the existing ordinal; idempotent confirmation replay does not mint a new one.The cumulative SQL adds
qbit_audit_publication_sequence_seq, a large idempotent upgrade (advisory lock, backfill for confirmed/inactive rows byfound_at/block_hash, unique index, check that confirmed rows always have a positive sequence), and pinssearch_pathonqbit_confirm_pool_block/qbit_reactivate_pool_blockso sequence and table resolution cannot be hijacked.Rust
audit_clitests add a sharedcanonicalize_cli_valuehelper and assert theqbit-prism-audit-canonicalizeCLI matches librarycanonical_audit_bundle_bytesfor reordered JSON, explicit null optionals, Unicode miner IDs, and large testnet-scale bundles.Reviewed by Cursor Bugbot for commit 6426c85. Bugbot is set up for automated code reviews on this repo. Configure here.