Repository navigation
Conversation
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: 4aeac21551
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04fcc4b585
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4dbf016e3
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 552781ae9b
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b63536b00a
ℹ️ 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".
`qbit-prism-server` had no way to see or finish a block candidate: a native-era row that keeps failing was retried forever, and the only way to inspect or stop it was editing rows by hand. `candidates list` is an inventory. It opens the read-only pool shape `fatal-state show` uses, so "takes no claim" is enforced by PostgreSQL rather than by review, and it keeps working while the cluster is halted. Neither payload column is projected: the height is extracted to a scalar server-side, guarded by a digit pattern so a row an unknown writer left behind reports an unknown height instead of failing the inventory. Rows print in the oldest-due claim lane's own ordering, so the row a server works next comes first and parked rows sort last. An empty inventory is a success, because that is what a cutover runbook waits for. `candidates abandon` applies to `pending` only, which is the one unfinished state from which no `submitblock` can yet have been made. The whole safety property is the statement's `WHERE`: `pending`, no live claim, and no landed block. It is a predicate and never a preceding `SELECT`, because a row can move between a check and a write; the diagnosis that produces the operator's message runs read-only after it, and gates nothing. The column set is the epoch-supersession path's, verbatim, with the operator's reason taking `last_error`'s place, and `next_attempt_at` deliberately untouched so a parked row keeps that evidence. Each refusal has its own exit status, so a runbook can tell a row that was never there from one already abandoned, and both from the two refusals that protect the invariant: a block that may already have been offered, and a block whose accounting has landed. Both commands read PRISM_DATABASE_URL and nothing else. Neither builds a node client, reads a signing key, loads `Config` or starts a listener, so "never calls submitblock" holds structurally. Co-Authored-By: Claude Opus 5 <[email protected]>
Six gated tests drive the real binary against a recorder in front of the fake node and assert it made no RPC call at all, `submitblock` included, and registered no instance. The child is given a database URL and a node URL and nothing else, so a command that loaded `Config` or started a listener could not have succeeded. `list` is asserted not to claim three ways: it runs to completion while the cluster is halted, which every write path refuses; every row is byte-identical afterwards, with `claim_token`, `claim_instance_id`, `claim_expires_at`, `attempt_count` and the dispatch sequence compared explicitly; and the statement it issues is described by PostgreSQL, so the assertion that neither payload column is projected reads the result columns rather than the SQL text. `abandon` is asserted to leave an `offer_reserved`, `offered` or `reconciliation` row byte-identical, to refuse a live foreign claim and then succeed once that claim has expired, to refuse an already-terminal row and a pending row whose block has landed, and to refuse while the cluster is halted or a legacy writer lease is live. On the one row it does take, the resulting row is compared field by field with a row the epoch-supersession statement abandoned. Co-Authored-By: Claude Opus 5 <[email protected]>
`prism-ledger-ops.md` gains a `Candidate commands` subsection three lines below the state table it explains: the two command lines, a real `list` output block, what each column means, the parked-versus-retrying distinction, the refusal table with its exit codes, and the two fences `abandon` inherits from the ordinary ledger write path — a halted cluster and a live legacy Python writer lease, which is what stops an operator abandon racing the 2.x.x writer during a cutover. `prism-rust-migration.md` gains the native counterpart to the legacy drain, and says plainly that they are not the same drain. The legacy instruction is unchanged: every 2.x.x candidate is still drained with the pinned legacy image before migrating, and the migrator still refuses while any remains. The native commands act on native-era rows only, and running them neither satisfies nor bypasses that check. `prism-deleted-test-map.md` keeps the pending-block-recovery row partial and its open-gap link intact, adds the six new tests where they genuinely cover a case, and fills in the per-case mapping the row promised. The recovery command's plan ordering, fail-closed selection across a plan and apply idempotence stay open; the cooperative-JSON codec cases stay retired. Co-Authored-By: Claude Opus 5 <[email protected]>
The state predicate is the abandon statement's version guard, so two operator abandons completing out of order are safe without any lock on top. Prove it end to end: after the successful abandon, a second one with a different reason exits 4, says the row is already abandoned, and leaves it byte-identical, so the reason the first operator recorded survives. Co-Authored-By: Claude Opus 5 <[email protected]>
`abandon` writes an ordinary ledger row, so it belongs in the same bucket as `import-audits`, `backfill-ctv`, `broadcast-ctv` and `self-check`, not with recovery and migration: `Registration::Tool` refuses a halted cluster at connect, exactly as a frontend would, instead of getting as far as the write guard. The write guard call stays, because it is what refuses a live legacy Python writer lease, which the connection does not cover. `list` keeps the read-only pool. It opens no ledger and writes nothing, `default_transaction_read_only=on` is a stronger guarantee than a tool connection would give, and a tool connection would refuse a halted cluster — which is exactly when an operator needs to inspect candidates. A new gated test gives `abandon` the four properties a one-shot tool owes: a generated instance ID leaves no row on success or on a refusal, a live frontend's row and session-owner token are untouched when the command runs under that frontend's ID, the halt guard holds and the halted run changes nothing, and once the real frontend stops no row is left that the recovery command's instance gate would refuse. Substituting the registering connection for the tool connection fails all five abandon tests. Co-Authored-By: Claude Opus 5 <[email protected]>
home of the unfinished recover work would become dead ends. Row 84's "not covered" clause and every plan-level case in the per-case table now link #418 instead. Row 84 stays partial, and the #285 and #270 links are untouched. The per-case table also says which revision it enumerates. The file has seventeen cases at 504846c, the `origin/2.x.x` commit this document pins throughout; three of them arrived with #258, so a reader who checks v2.0.1 instead sees fourteen and none of those three. Saying so stops the next reader concluding the extra rows are invented. Co-Authored-By: Claude Opus 5 <[email protected]>
8739ee8 to
c78b5c3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c78b5c30b2
ℹ️ 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".
|
Closing as superseded by #439, which was stacked on this branch and carried every commit here (identical trees, verified by patch-id against the squash commit 32e0db4 on 3.x.x). The one open Codex thread (treat |
Closes #268.
Adds
qbit-prism-server candidates listandcandidates abandon— the twooperator commands the native server was missing — plus the cutover runbook step
that separates the legacy drain from the native one, and the #259 test-case
mapping.
Per #268's 2026-09-10 scope update this is the trimmed slice:
list,abandonand the runbook step only. The "Proposed change" section's
candidates recover --block-hash ... [--apply]predates that update and is notbuilt here; it is filed as #418 (P2,
3.x.x: GA), and every plan-level link inthe deleted-test map now points there.
@Anatolie —
crates/qbit-prism-server/src/tools.rsanddocs/are yours. Thisadds one
Candidatessubcommand group, itsCandidatesCommandenum and onehandler function; no other subcommand's code, help text or error path is touched,
and the only changed existing line is the
bailimport. Flagging it because #290'sfatal-stateshares the file.Why
abandonispending-onlyThe one outcome this must never produce is a
submitblockthat happened and aledger that no longer records it.
Since migration 011 (#266),
pendingis the only unfinished state from which nosubmitblockcan yet have been made —ledger/candidates.rscalls it "the onlystate that may still be abandoned",
ledger/blocks.rsandmigrations/011_offer_before_landing.sqlsay the same. So the safety property isthe statement's
WHERE, not a check in the CLI, because a row can move between acheck and a write:
The
SETlist isledger/policy_transition.rs's supersession abandon verbatim,with one substitution: the operator's
--reasontakeslast_error's place.next_attempt_atis deliberately untouched there and here, so aninfinityleftin it stays as the evidence that the row had been parked.
The
qbit_pool_blockspredicate mirrors the refusalpolicy_transition.rsalready makes — "never alter existing accounting to discard it" — and is the one
remaining way an operator could discard landed accounting.
When the statement changes no row, a read-only follow-up
SELECTin the sametransaction classifies why, for the message and exit status alone. It gates no
write; the refusal is already decided. Ordering it the other way round is the
race this design exists to prevent.
Exit statuses
qbit_pool_blocks3 and 6 are the two that protect the invariant. 4 is separate from 2 so re-running
a successful abandon reads as "nothing to do" rather than a lost row.
listOpens a read-only pool in the shape
Ledger::inspect_fatal_stateuses(
default_transaction_read_only=on). That makes "takes no claim" a propertyPostgreSQL enforces rather than one a reviewer checks, and it keeps
listworkingwhile the cluster is halted — precisely when an operator wants it.
abandon, bycontrast, writes an ordinary ledger row, so it connects through
Ledger::connect_tool(#412): no heartbeat, and a halted cluster refused atconnect like any other one-shot writer.
Neither command builds a node client, reads a signing key or starts a listener.
The outbox has no height column, and
qbit_pool_blocks.block_heightis writtenonly at landing, so an unfinished candidate has none. Height is extracted
server-side as a scalar from the document — eight bytes on the wire — and the
candidateandblock_bytescolumns are never in the projection. A row whoseheight is unreadable prints
-, never0.Against a seeded database:
Ordering is the oldest-due claim lane's own, so the row a server works next prints
first and parked rows sort last. A parked row (
next_attempt_at='infinity', #387)is shown as
parkedrather than as a due time — it is quarantined, not retrying.The last row is #285's parked unknown-
storage_versioncase.An empty list exits zero and prints
no unfinished candidates: nothing-pendingis the cutover step's success case, and a nonzero status would abort a
set -erunbook on exactly the outcome it is waiting for.
--jsonemitsqbit.prism.candidates.list.v1with every unknown asnull.Docs
docs/prism-ledger-ops.mdgains aCandidate commandssubsection inside"Durable block candidates", beside the state table it depends on.
docs/prism-rust-migration.mdkeeps the legacy drain instruction unchangedand gains a native-era counterpart: every
2.x.xcandidate must still bedrained with the pinned legacy image before migrating, and the native commands
act on native-era rows only — they cannot read a chunked v2 body or a
pre-migration v1 document, and running them neither satisfies nor bypasses the
migrator's drain check. A pre-migration row that reaches a native frontend is
parked and shows up in
list, but the answer is still the legacy drain.docs/prism-deleted-test-map.md: thetest_prism_pending_block_recovery.pyrowstays
partialand its five recover behaviours now point at 3.x.x: Native candidate recover --apply for already-accepted pending blocks #418. Theper-case mapping below it enumerates the file at
504846c, the revision thedocument pins, and says so explicitly — that file gained three chunked-body and
storage-version cases in v2.0.2 fix: bound candidate replay and audit finalization #258, so a reader checking the v2.0.1 commit that
3.x.x: Candidate list and abandon commands, and the legacy-drain runbook step #268's own reference link uses will find only fourteen.
Tests
Seven gated PostgreSQL tests in
crates/qbit-prism-server/tests/support/candidates_cli.rs, each driving the realbinary against a seeded database.
list_shows_every_unfinished_state_without_claiming_or_loading_payloadsstorage_versionlist_separates_parked_rows_from_retrying_rows_and_shows_unknown_storage_versionsabandon_terminalizes_a_pending_row_exactly_as_supersession_doesabandon_refuses_every_offered_state_and_leaves_the_row_byte_identicalabandon_refuses_a_live_foreign_claim_and_succeeds_once_it_expiresabandon_refuses_a_terminal_row_and_a_pending_row_whose_block_landedabandon_registers_no_heartbeat_and_keeps_the_halt_guardEvery test asserts the process made no RPC of any kind —
submitblockincluded — against a counting proxy in front of the fake node, and that no
instance row was registered. "Exactly as supersession does" runs the real
policy_transitionUPDATE on a twin row and compares whole rows. "Byte-identical"is
to_jsonb(o)before and after. The no-payload assertion reads the projectionthrough
pool.describe()on the statement the command actually runs, so it cannotdrift from the SQL.
Verified locally against PostgreSQL 16: serial
ledger_postgres139 passed, 0failed (132 on the base, so +7); fmt and clippy
-D warningsclean; the gatecorrectly fails rather than skips under
GITHUB_JOB=prism-native-postgreswithout a database; the seven manifest ids match the gate's own
executedlines.Six adversarial mutations were each caught by a named test: dropping
state='pending'; dropping the live-claim fence; addingcandidateto theprojection; dropping the operator reason; making
listtake the claim it reports;and swapping
connect_toolforconnect.offer_lifecyclefails under parallel load on this machine, but it fails the sameway on the base commit without these changes — it is one of the binaries #410 did
not convert to a per-fixture database. Serial it is 18 passed, 0 failed.
Scope
No schema migration, no new candidate state, no new column. The claim lane, the
backoff schedule and the retry contract are untouched, as are
coordinator.rs,ledger/blocks.rs,ledger/policy_transition.rs,ledger/connect.rsandmigrations/.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.