Extract PRISM vardiff and block finalization - #78
Open
kiwidream wants to merge 1 commit into
Open
Conversation
This comment has been minimized.
This comment has been minimized.
kiwidream
force-pushed
the
prism-share-submission
branch
from
July 20, 2026 14:42
cdf110a to
3eafe82
Compare
kiwidream
force-pushed
the
prism-vardiff-finalization
branch
2 times, most recently
from
July 20, 2026 15:28
03498a8 to
941972e
Compare
kiwidream
force-pushed
the
prism-share-submission
branch
from
July 20, 2026 15:28
3eafe82 to
4b369f0
Compare
kiwidream
force-pushed
the
prism-vardiff-finalization
branch
from
July 20, 2026 15:34
941972e to
d3392da
Compare
kiwidream
force-pushed
the
prism-share-submission
branch
from
July 20, 2026 15:34
4b369f0 to
44e43cc
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 d3392da. Configure here.
kiwidream
force-pushed
the
prism-share-submission
branch
from
July 20, 2026 16:02
44e43cc to
af51efe
Compare
kiwidream
force-pushed
the
prism-vardiff-finalization
branch
from
July 20, 2026 16:02
d3392da to
270fcc4
Compare
kiwidream
force-pushed
the
prism-share-submission
branch
from
July 20, 2026 16:58
af51efe to
60b212e
Compare
kiwidream
force-pushed
the
prism-vardiff-finalization
branch
from
July 20, 2026 16:58
270fcc4 to
18d2bc5
Compare
This was referenced Jul 20, 2026
kiwidream
force-pushed
the
prism-share-submission
branch
from
July 22, 2026 13:50
60b212e to
a87052f
Compare
kiwidream
force-pushed
the
prism-vardiff-finalization
branch
from
July 22, 2026 13:50
18d2bc5 to
3e285ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Position in the stack
PR 6 of 9. Base:
prism-share-submission. Depends on PR 77. Next: PR 79.Review this PR against its configured base. See the stack guide for the complete order.
Why this slice exists
Vardiff and accepted-block finalization are separate state machines with strict rollback, durability, payout, audit, and notification ordering. Both were embedded in the coordinator. This slice gives each an explicit owner and names the finalization phases so failures and latency can be observed at the correct boundary.
What changes
vardiff_service.block_finalizationas six replay-safe named phases.Why the diff is sizeable
The roughly 2,480 additions and 1,580 deletions represent two large coordinator state machines moving into owner modules: about 1,040 lines for finalization and 910 for vardiff, while nearly 1,600 lines leave the coordinator. New direct owner tests and the B3 decision record account for most of the remaining additions.
Review vardiff speculative-state restoration first, then the six finalization phases and their ports, and finally verify the coordinator methods are only construction or delegation.
B3 decision
A second finalization lane is intentionally omitted. Available timing evidence does not show valid-candidate delay, while another lane would require a new durable handoff plus additional parent, admission, and shutdown ordering. The new metrics define evidence that can justify revisiting the decision later.
Validation
git diff --checkpassed.Operator impact
No migration or required configuration change is introduced by this slice.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Medium Risk
Large refactor of payout, audit, and ledger-confirmation ordering on the block-submitter path; behavior is intended to be preserved but the moved finalization logic is security- and durability-sensitive.
Overview
Extracts vardiff and accepted-block finalization from
PrismCoordinatorinto dedicated owner modules, leaving the coordinator as lazy construction plus thin delegates.vardiff_servicenow owns share-window retargeting, idle sweeps, bounded idle workers, speculative difficulty rollback, and Prometheus idle metrics. Coordinator vardiff APIs delegate through_ensure_vardiff_service()and compatibility descriptors that migrate existing embedder state.block_finalizationintroducesBlockFinalizationServicewith six ordered, replay-safe phases (admission → land/confirm → CTV/credit → evidence → audit publish → accounting). The former monolithicsubmit_block_candidate/_land_and_confirm_block_candidatebodies move here, with phase timing and candidate interarrival metrics exposed on the metrics endpoint.docs/prism-coordinator-refactor/b3-decision.mdrecords the decision to omit a second finalization lane, using the new metrics as evidence to revisit later.Adds focused unit tests for finalization phase ordering and vardiff service boundaries.
Reviewed by Cursor Bugbot for commit 3e285ff. Bugbot is set up for automated code reviews on this repo. Configure here.