Repository navigation
Reduce PRISM accepted-block payout gate locking - #50
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac87aa5b22
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…ocking # Conflicts: # lab/prism/prism_coordinator.py # tests/test_prism_coordinator_vardiff.py
…ocking # Conflicts: # lab/prism/prism_coordinator.py # tests/test_prism_coordinator_job_cache.py
…ocking # Conflicts: # crates/qbit-prism/src/bin/qbit-prism-build-audit-bundle.rs # lab/prism/prism_coordinator.py
…ocking # Conflicts: # lab/prism/prism_coordinator.py
|
@codex review |
|
@codex review |
|
@codex review |
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 19d6700. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19d6700b7c
ℹ️ 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".
Codex review: the independent-pool job snapshot no longer orders after in-flight share appends, so a stamped share committing after the MVCC read with accepted_at <= anchor would be durable yet missing from the issued window, breaking qbit_audit_share_window reproducibility at the declared anchor. Track every stamped-but-undurable share (group-commit queue, in-flight batch, block-candidate credit linked after landing) and clamp job and payout-artifact snapshot anchors strictly below the oldest one, releasing entries on commit, miner-facing rejection, or terminal candidate abandonment. Payout artifacts now record their own snapshot anchor and bundles built from an artifact declare it, since a fresher job-issue anchor could cover shares the artifact predates. Cursor review: once persist and confirm are durable, a lost forced payout publication no longer aborts the candidate into outbox retry churn. The candidate finalizes (outbox submitted, evidence and counts recorded) while delivery stays fenced until the scheduled tip refresh publishes the newest source. Co-Authored-By: Claude Fable 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…ocking Reconciles the bounded build-supersession machinery (#57) with this branch's prospective payout publication and snapshot anchor floor: - job snapshot anchors clamp below pending share commits at the frozen per-generation issued time in _new_job_build_request, which also makes the frozen anchor's window byte-reproducible across rebuilds - bundles built from a reused payout ledger artifact declare the artifact's own snapshot anchor - child builds wait for a pending accepted-parent preview before acquiring any confirmed payout input, so no stale confirmed read is taken or cached into the published payout state artifact while the parent lands - an accepted-block preview publication installs its preview balances as the published payout state artifact instead of reading the ledger, whose durable state only catches up after persistence - accepted blocks cancel obsolete job builds before preview publication, preserving the #57 refresh handoff Co-Authored-By: Claude Fable 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…tion share rates (#102) * Switch PRISM payout-ledger-artifact validity to anchor-scoped semantics Production telemetry (2026-07-29) showed zero artifacts ever publish under ~35 accepted shares/s: the background build aborted at its pending-commit anchor clamp or its accepted_before != accepted_after fence, and the exact-count reuse fence rejected any artifact the moment one more share became durable. The #99 spool + serve daemon sat idle while every tip-refresh build kept paying ~3.5s ledger_snapshot + ~1.2s serialization_copy. An artifact's window is already exact at its own clean snapshot anchor: _job_snapshot_anchor_ms keeps the anchor strictly below every pending commit, so every covered share is durable and shares stamped above the anchor deterministically belong to the next window (the reproducibility contract documented at PayoutLedgerArtifact.snapshot_anchor_ms, which reused bundles declare as anchor_job_issued_at_ms). Operationalize that contract instead of fencing on global counts: - Background build: the pending-commit clamp is anchor SELECTION (build at the clamped floor) rather than an abort; the before/after count fence is gone. The only abort left is a floor so old the artifact would arm past the staleness bound (wedged writer), which keeps the re-arm backoff meaningful. accepted_share_count is recorded as diagnostics only. - _usable_payout_ledger_artifact: exact-count comparison replaced by a bounded anchor-staleness check (PRISM_PAYOUT_ARTIFACT_MAX_ANCHOR_AGE_SECONDS, default 10s) alongside the unchanged generation/difficulty checks and the untouched prior_balances sha256 fence. In-flight builds re-validate with ignore_anchor_age so queue delay past the bound cannot scrap a reuse that was fresh at selection into the full snapshot it was armed to avoid. - Synchronous seeding: the anchor-count bracket capture and mid-read count fences are gone; ready builds always seed their anchored window, with a single informational count read. - _install_payout_ledger_artifact orders snapshots by anchor (counts are unfenced reads now); a same-window rebuild at a fresher anchor keeps the armed generation but advances the staleness clock in place so quiet streams do not cycle identical rebuilds forever. Tests updated from count-fence to anchor semantics, plus new coverage: clamped-floor builds publish, pathological floors refuse before the window walk, reuse survives commits landing after the anchor, the staleness bound retires and re-arms, and a reused-anchor bundle produces byte-identical payout-preview output to a fresh build at the same anchor driven through the #50 issued-vs-verified preview guard (with a divergent-anchor negative proving the guard discriminates). Metric names are unchanged. Full unittest suite: failure set byte-identical to base 59a3d9d in this environment (20 pre-existing sandbox failures, zero regressions). cargo test -p qbit-prism: 182 passed. Co-Authored-By: Claude Fable 5 <[email protected]> * Harden anchor selection and reuse identity per PR #102 review Codex P1 + Bugbot (clamp-to-snapshot race): a share stamped right after _job_snapshot_anchor_ms returns can land in the same millisecond as the clamp instant, unprotected by the pending floor; an anchor equal to that instant would cover it on replay (the window predicate is anchor-inclusive) while the snapshot never contained it. Select anchors strictly below the clamp-time millisecond -- min(now - 1, floor - 1) -- so every stamp assigned after selection sits above the anchor on both sides of the replay. This also hardens the job-issue anchor freeze, which shared the same tie under the old count fences. Bugbot (in-place advance breaks reuse identity): the same-window anchor refresh swaps the armed instance, so the in-build re-validation now compares artifact identity fields (payout generation, artifact generation -- the re-key authority -- and window sha) instead of object identity; an in-flight build holding the pre-refresh instance completes its reuse instead of being scrapped into the full snapshot it was armed to avoid. Bugbot (retarget guard misses fresher anchors): the live-difficulty retention guard now applies whether the delayed pre-retarget build's anchor ties or leads; a wrong-difficulty install would fail every reuse probe on the difficulty check, which never re-arms. Tests: anchor selection strictly below the clamp instant (bare and floor-clamped); in-flight build survives a same-window anchor refresh; fresher-anchor pre-retarget install refused; vardiff clamp expectations updated for the strict-below-now bound. Co-Authored-By: Claude Fable 5 <[email protected]> * Enforce the anchor-age bound on cached ready bundles Codex round-2 P2: the staleness bound retired only the armed artifact. A cached ready bundle could keep serving past the bound whenever the bundle cache TTL outlives it, and a same-window re-anchor keeps the artifact generation while older-anchored bundles sit cache-usable, so issued jobs could keep declaring a window anchor older than PRISM_PAYOUT_ARTIFACT_MAX_ANCHOR_AGE_SECONDS. _job_bundle_entry_usable -- the single re-validation choke point for cache probes, subscribed results, and lookups -- now rejects a ready bundle whose declared anchor_job_issued_at_ms has aged past the bound; collection bundles carry no payout window and are unaffected. With the default TTL equal to the default bound this is behavior-neutral; it closes the operator-mismatch corner and makes the invariant total: no served job declares an anchor older than the configured limit. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>

Summary
Why
Accepted-block finalization performs canonicalization, deep copies, audit-body writes, verification, and a bulk database transaction. Holding
_payout_state_delivery_gateacross that work blocks replacement jobs and correlates with memory spikes, refresh cancellations, and stale-share bursts.Simply releasing the gate during persistence is insufficient: an H+1 job built from pre-confirmation database balances can be delivered and solved, then rejected as stale after H confirms. The coordinator now publishes the carry state already committed by H's immutable issued bundle before the expensive finalization work begins. H+1 work therefore uses the state that durable confirmation is required to produce.
Correctness model
_payout_balance_mutation_lockserializes accepted-block and reorg balance transitions without excluding ordinary job delivery.Impact
Replacement jobs can reach miners throughout accepted-block audit and persistence work without being based on stale payout state. Reconciliation remains excluded from the landing-to-confirmation interval, startup replay preserves parent-before-child ordering, and Postgres job snapshots no longer queue behind the fenced writer connection.
Validation
python3 -m unittest discover -s tests -p 'test_*.py'— 939 tests passedpython3 -m unittest tests.test_prism_coordinator_job_cache tests.test_prism_coordinator_vardiff tests.test_prism_share_ledger— 386 tests passedpython3 -m py_compileon the changed coordinator, ledger, and test modulesgit diff --checkNeed help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
High Risk
Large changes to accepted-block payout publication, concurrency, and ledger confirmation invariants—errors could deliver wrong carry-forward state or race reconciliation.
Overview
Accepted blocks no longer hold the payout delivery gate across audit rebuild, verification, and ledger persistence. The coordinator publishes prospective carry-forward balances from the issued job’s
payout_policy_manifestat a short boundary (new payout generation + compact preview), so child/descendant jobs can build on the post-accept state while slow finalization continues.Coordinator behavior:
_payout_balance_mutation_lockserializes durable balance work without blocking ordinary job delivery; landed transitions block reconciliation; children wait (bounded) for parent previews or fail closed on withdrawal/reorg tombstones. Block finalization moves into_land_and_confirm_block_candidatewith early preview from cachedprospective_prior_balances, verified-bundle checks, andprior_balances_after_pool_blockequivalence before clearing the override. Share snapshots clampanchor_job_issued_at_msbelow in-flight commits via_pending_share_commit_floor; candidate retry keeps the lowest-height parent first and avoids double-counting accepted hashes.Supporting changes: job-summary audit CLI output adds
payout_policy_manifest; Postgres job snapshots use the read pool; ledger gainspool_block_stateand as-of-block balance queries. Tests cover preview wait, idempotent publication, artifact patching, and anchor floors.Reviewed by Cursor Bugbot for commit 12b7532. Bugbot is set up for automated code reviews on this repo. Configure here.