Repository navigation
3.1 dual-writer (2/5): per-node window cuts and audit cut field - #768
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. |
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: a07a594dfe
ℹ️ 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".
A build request's window_cut, added for PRISM 3.1's dual-writer windows, changes what the daemon signs. A protocol 2 daemon ignores the field and signs a reward manifest without the cut, and the build summary cannot show that. The handshake now announces 3, so a client that checks the version exactly refuses a pre-cut daemon instead of distributing work that does not commit to the cut it asked for. The native server builds in process and never starts the daemon. The doc comment now says so, and that the client which checked the version was the retired Python coordinator. A new test sends the dual-writer fixture's window, with its cut, through --serve. The daemon's job summary must equal a one-shot build's with the cut, and that differs from the build without it. The serve tests that pin the handshake, and the deleted-test map, now say 3. From Codex's review of #768. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Reply to the review thread Bump the serve protocol for cut-aware requests. The token cannot reply in the thread itself. Fixed in 2b4e819. A new test, For context: the native server builds in process and never starts the daemon, and the client that checked this version was the retired Python coordinator. So this guards future clients; no deployed path is affected. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b4e819c21
ℹ️ 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".
… every mode The issued-job saves check that a prepared row's payload agrees with its typed columns. In dual-writer mode the payload's window was compared without its cut, which the columns never carry. A single writer issued 3.0's whole-window comparison. A single writer started under D-12's downgrade would therefore refuse every live prepared row a dual-writer frontend wrote, though the work is valid and lands under its stored cut. The comparison now drops the cut key in every mode. On a 3.0 payload, which has no cut, that changes nothing. The window must be an object, and a cut in it an object too, so a malformed payload is a mismatch, as 3.0 reported it, and never a statement error. It is the statement's one difference from 3.0's text: the second deliberate single-writer exception, beside audit reconstruction's read of the cut columns, and for the same D-12 reason. A unit test pins the statement to 3.0's digest once that one expression is swapped back. A gated test writes a dual-writer prepared row and checks it on a ledger with no dual-writer identity. The row matches its columns there, and 3.0's whole-window comparison refuses it. Another key, a null or scalar cut, a scalar window or a changed column still fails. From Codex's review of #768. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Reply to the review thread Preserve cut-aware prepared jobs during downgrade. The token cannot reply in the thread itself. Fixed in 72572fe, taking the second option: the dependency statement compares the payload's window without its The window must be an object, and a cut in it an object too, so a malformed payload reads as a mismatch, as 3.0 reported it, and never raises "cannot delete from scalar". Tests:
This is the second single-writer text exception, beside audit reconstruction's read of the cut columns, and for the same D-12 reason. The PR body lists both. |
|
Local full-suite results, as the PR body promised. The suite ran CI's shard commands as one shard, without
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22abcd9601
ℹ️ 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".
… pending its anchor Codex on #768 (PRRT_kwDOS9jIOc6rEtvE): a peer row at or below the mark but stamped after the window's anchor, by a peer clock running ahead, joins a later anchor's window with no new row and no move of the mark. The reuse rule compared only the mark and the accepted cutoff, so a new template could keep the old window, and leave that share out of the work, until the reanchor interval ran out. The peer-cut statement now also returns the peer's newest accepted row under the same bounds, whatever its stamps, by the same index walk on 031's index, which stops there. When that row is above the peer's entry, the snapshot reports a peer row pending (PeerCut::pending, carried on SnapshotCapture and RefreshWindow), and RefreshWindow::reusable refuses the window, so the next template reads a fresh one. Same-template work keeps 3.0's cadence, as before. Tests: the gated clock-skew test asserts the flag while the rows wait, its clearing once this node's clock passes them, and that a rejected row above the entry is never pending. A unit test covers reusable, and a coordinator test shows new templates at an unchanged revision reading a snapshot while a row is pending and reusing the window once none is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re the P2 at
Tests:
The plan-shape guard still pins both cut reads to 031's index, with no filtered rows. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6bf65fea7f
ℹ️ 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".
|
Re the P1 at
|
Codex on #768 (PRRT_kwDOS9jIOc6tByaz): the audit-body-ref.v1 and audit-bundle.v2 envelopes check that their shares form one contiguous share_seq run, which a dual-writer window with a cut need not be (a late peer row outside the cut leaves a gap), so such an envelope failed as non-contiguous. These envelopes are 2.x storage artifacts: the cutover import, the read-model API's legacy bodies and the verify and canonicalize CLIs read them, no 3.x writer produces them, and 2.x never wrote a cut. Both resolvers now refuse a bundle whose reward manifest has a cut, by name and before any reconstruction, rather than half-checking it; such a bundle is valid only as a flat logical bundle, which every 3.x path stores and serves. A test wraps the gapped cut fixture in each envelope and checks the named refusal, and that the flat bundle still parses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A new WindowCut type ({"0": share_seq|null, "1": share_seq|null}) names
the highest share_seq of each node's rows a dual-writer window may include.
The reward manifest and its stored header carry it as `cut`, absent when
None, so every existing bundle, fixture and vector keeps its bytes. The
coinbase commits the cut through the reward-manifest leaf.
The builders take the cut as an input, and the verifier rebuilds a manifest
under its own cut. Every window share must be at or below the cut's highest
entry (ShareOutsideWindowCut). Dropping, adding or altering a cut fails at
the commitment leaf. The build-audit-bundle binary accepts `window_cut`.
Adds a dual-writer fixture: both nodes' share_seq parities, pre-3.1
history, a gap, late node-1 rows outside the cut, and a partially counted
crossing share. Also adds the window_cut_bundles tests (library and binary
build, verify and canonicalize; tampering; parallel equals serial; a
randomized two-node reproduction model) and pinned golden digests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…are_id from both nodes The CTV-settlement build of the dual-writer fixture is pinned beside the coinbase-options build: the reward manifest, cut included, also feeds every fan-out precommitment, and both builds commit to the same manifest. A window holding one share_id from both nodes is refused by the fold in the builder and every verifier, never credited twice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ation 028 In dual-writer mode every payout window records a per-node cut: the highest share_seq of each node's rows it may include. A row is eligible when it is eligible as in 3.0 (accepted, and accepted and issued at or before the anchor) and its share_seq is at most its node's entry. This node's entry is its newest own row, read under ORDER_LOCK in the cutoff's statement. The peer's entry is its newest row at or below the peer sync's safe mark (qbit_prism_peer_share_mark(), D-14) that is stamped at or before the anchor. A peer row that arrives late is above the peer's entry, so it is outside every window built before it and joins later ones. The anchor rule stays on every row (D-13). Each node's stamps rise with its share_seq, so the cut alone decides membership. Clock skew can only delay a peer's newest shares, never make a window irreproducible or a landing fail. Every path that selects, re-reads or proves a window applies the cut: the snapshot and full scan, read_window, verify_durable_range, the in-lock count, audit persistence and reconstruction, the #619 holding probe and the leaf witness. The incremental advance reads each node's new rows between the old and fresh cuts and merges the peer's late rows in share_seq order (advance_in_cut), proved by the existing leaf witness and eligible-row count. At a 200k-row window a merge of 1,000 late peer rows and 1,000 own appends takes about 92 ms, against 1.5 to 1.6 s for the full scan. The cut reads are shaped so only the (origin_node, share_seq) index can serve them. A plain max() with an equality filter was measured walking the primary key through the other node's whole run inside ORDER_LOCK. The index ships as D1's migration 031; until a ledger has a valid one, a dual-writer snapshot refuses before it takes any lock. The dual-writer test fixtures create the same index meanwhile. A cached window is not reused for a new template once the peer's mark has moved, since the peer's newer rows can all lie below this node's cutoff. The refresh probe reads the mark in dual-writer mode only. WindowRef carries the cut, absent when None, inside the digest-checked candidate document and prepared payload. Migration 028 adds cut_seq_0 and cut_seq_1 to qbit_prism_audit_snapshots. Bundles commit the cut in reward_manifest.cut, except a bootstrap window's. With dual-writer mode off nothing has a cut, and every eligibility, snapshot, probe and dependency statement is 3.0's. Tests: - a 512-case proptest of the merge against the full scan; - gated tests with both nodes' rows in one ledger: the model, late rows with a no-cut negative control, clock skew, reproduction on the other node's database, a seeded advance walk, single-writer parity, the plan shape, the refusal without the index, and the peer mark; - gated landings with late peer rows; - a measurement harness. Every version pin gains 28. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w's cut, so it lands The audit rebuild that every post-offer landing and every reconciliation retry runs (build_claim_parts) called the serial builders, which build without a cut. The coinbase was built by bundle_build with the window's cut. So every dual-writer block was accepted on chain, but its landing failed with "audit parts' window cut None differs from the candidate's window reference" and the row stayed in reconciliation. D6 found it in its S1 and S5 scenarios. The rebuild now applies the rule bundle_build applies. A dual-writer window's audit carries the reference's cut, whether or not the peer's entry is empty. A single writer's window, and the bootstrap window with its one synthetic share, carry none, so those bytes are 3.0's. A row the failed landing left in reconciliation lands on its next retry: it keeps every input, and the retry rebuilds the audit from them. Tests: - three coordinator tests through process_candidate (offer, rebuild, landing): an idle peer with no mark, under direct settlement; both nodes' rows, under CTV settlement; and a block whose first landing failed, which lands on its reconciliation retry without a second offer; - the ledger-level landing tests now land the rebuilt audit, check it is the one the coinbase committed to, and gain an idle-peer case. Without the fix, the three coordinator tests and both non-bootstrap ledger tests fail with D6's error. The window_switch fixture now builds coinbases with the snapshot's cut. That cut is None for every single-writer test, so their bytes are unchanged. The test fixtures' stand-in index takes migration 031's name, qbit_share_ledger_origin_seq_idx (CREATE INDEX IF NOT EXISTS). The plan-shape guard pins its cut reads to that index or its partitions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t 031's index, with a gauge Without migration 031's (origin_node, share_seq) index, a dual-writer snapshot refuses before it takes any lock, and the refresh loop logged that refusal on every tick and wake: 920 lines in three minutes per frontend in D6's integration run. The refusal is now typed (OriginIndexMissing). The refresh loop logs it as an ALERT at most once a minute, and again at once after a successful refresh. The snapshot sets a new gauge, qbit_prism_dual_writer_origin_index_missing: 1 while it refuses, 0 once it finds the index. A single writer declares the gauge without a sample. The metric census pins move with it. They also take in the peer sync's families, which the base had not counted. The refusal test checks the type, the gauge in both states, and only its own database's advisory locks; other tests share the cluster. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lding probe and bootstrap work Fixes from the second local review and the coordinator's review of a3e9854. The cut entries: - This node's entry is now its newest own row eligible at the anchor, so both entries are rows the window's predicate admits, and the higher one is the window's newest row. A rejected or future-stamped legacy row on top no longer stops the incremental advance. - The own-cut read inside ORDER_LOCK first probes at or above the retained window's entry, which reads only the newest partitions, as 3.0's cutoff does. The probe of every partition runs only for a first snapshot, or when that one finds nothing. - The index check requires a btree whose two columns share one direction. The #619 holding probe of a dual-writer window also checks this node's entry row, and that the peer sync's mark covers the peer's entry. A restore can lose each log's newest rows while the window's last row survives. Bootstrap work: empty-window work is replaced as soon as the peer mark moves, as a first share replaces it. The refresh trigger label and the work's equivalence check now see the cut. The incremental advance: - the delta bound counts the union of the nodes' ranges, not their sum; - the margin walk and the witness-and-count proof are shared with 3.0's advance, and its statements keep 3.0's text. Statements: - The refresh probe reads the peer mark in its revision statement. A single writer's statement is 3.0's. - compact_issued's two dependency statements are built at compile time from one text. A test pins the single writer's to 3.0's digest. Tests: - the holding probe under a rewound mark, a lost own entry and a pruned prefix; - the bounded own-cut read across four partitions; - the plan guards with the new parameters; - a BRIN index refused; - bootstrap work replaced when the mark moves, while full work keeps its cadence; - the union bound; - pinned statement texts. audit_completeness's hand-made snapshot table gains 028's columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s, one margin step, wording Fixes from the last local review before the PR: - The peer's entry is read in the second transaction, after ORDER_LOCK. It is now bounded by the mark read there as well as by the mark the cutoff's statement read, so a mark rewound in between never admits a peer row whose lower rows this database no longer holds. The cutoff still bounds every admitted row. - The dual-writer cutoff statement is planned with its values, as every bounded ledger read here is, so the retained entry prunes partitions in every plan. - Both merges carry one Margin, whose take step is the only copy of the saturating fold below the retained first row. The proptest uses it too. - read_range_paged says it applies 3.0's predicate with no cut. - The ops doc says a held window's last row matches the window's predicate, whichever node wrote it. It also says bootstrap work is replaced whenever the peer's mark moves until a window holds shares. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The base now carries migration 031, which creates qbit_share_ledger_origin_seq_idx on every fixture the tests migrate. The fixtures' own CREATE INDEX IF NOT EXISTS is gone. The refusal test, which drops the index, still restores it under 031's name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e readiness probe, evidence Fixes from the last local review before the PR: - The peer's entry is bounded by the mark now inside the peer-cut statement itself, beside the mark the cutoff's statement read, so a rewind between statements is covered too, with one round trip fewer. The statement also returns the mark the entry used, and the snapshot records that one for the refresh to compare. A rewound mark that comes back then rebuilds the window. - The dual-writer cutoff statement is cached again, as 3.0's cutoff is, so no plan is made under ORDER_LOCK. A generic plan prunes the leaves below the retained entry at executor start, which the bounded-probe guard checks. - The public read's schema-readiness probe requires 028's cut_seq_0 and cut_seq_1, which audit reconstruction selects. - The recovery-evidence tamper test also changes a snapshot's cut and expects the evidence to see it. - migration.rs and the migration guide say 028 is taken, and 29 and 30 stay reserved. - The measurement harness drops 031's index for its no-index case. The refusal test drops its BRIN index before it restores 031's. The plan-shape guard sets a peer mark, as a synced ledger has one, so the peer read's walk is bounded and planned on 031's index. The dual-writer ops paragraphs are rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three of this branch's checkout sites changed shape: - audit reconstruction's read_range call now passes the stored cut; - the snapshot's advance call now passes the cut; - verify_durable_range's newer-row probe is now two timed checkouts, one per branch, with only one running. The census entries are updated to match. The timed count goes from four to five, and the policies stay the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A build request's window_cut, added for PRISM 3.1's dual-writer windows, changes what the daemon signs. A protocol 2 daemon ignores the field and signs a reward manifest without the cut, and the build summary cannot show that. The handshake now announces 3, so a client that checks the version exactly refuses a pre-cut daemon instead of distributing work that does not commit to the cut it asked for. The native server builds in process and never starts the daemon. The doc comment now says so, and that the client which checked the version was the retired Python coordinator. A new test sends the dual-writer fixture's window, with its cut, through --serve. The daemon's job summary must equal a one-shot build's with the cut, and that differs from the build without it. The serve tests that pin the handshake, and the deleted-test map, now say 3. From Codex's review of #768. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… every mode The issued-job saves check that a prepared row's payload agrees with its typed columns. In dual-writer mode the payload's window was compared without its cut, which the columns never carry. A single writer issued 3.0's whole-window comparison. A single writer started under D-12's downgrade would therefore refuse every live prepared row a dual-writer frontend wrote, though the work is valid and lands under its stored cut. The comparison now drops the cut key in every mode. On a 3.0 payload, which has no cut, that changes nothing. The window must be an object, and a cut in it an object too, so a malformed payload is a mismatch, as 3.0 reported it, and never a statement error. It is the statement's one difference from 3.0's text: the second deliberate single-writer exception, beside audit reconstruction's read of the cut columns, and for the same D-12 reason. A unit test pins the statement to 3.0's digest once that one expression is swapped back. A gated test writes a dual-writer prepared row and checks it on a ledger with no dual-writer identity. The row matches its columns there, and 3.0's whole-window comparison refuses it. Another key, a null or scalar cut, a scalar window or a changed column still fails. From Codex's review of #768. Co-Authored-By: Claude Opus 5.5 <[email protected]>
D1's 7658fa2 made a cursor's ingested_through the highest peer row a pull refused as a conflict, quarantined for good, NULL while none was. The window-cut fixtures still set it to the mark, which now reads as a pull that refused every peer row through it, a state the peer's found-block wait would never confirm a block under. They now set only scanned_through, as a clean pull leaves the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d the quarantine in D-14's wording D1's the_sync_carries_every_column_the_inventory_does_not_keep_local pins every column the peer sync copies, and failed on the merge: 028 added cut_seq_0 and cut_seq_1 to qbit_prism_audit_snapshots. The sync carries that table whole, so a synced block's snapshot already brings its cut; both columns are now pinned. The snapshot conflict check still compares only the content-determined columns, as D1 wrote it for windows that share one share array. Since D1's 7658fa2 a peer row the sync refused as a conflict is quarantined for good, below a mark that moves past it. Windows taken here leave it out and stay whole, but one whose range spans it reproduces only on the node that took it. cut.rs and the ops doc said every peer row at or below the mark is committed here; they now name the exception. The window-cut integration helper's mark upsert also sets peer_node, as its twin in cut/dual_writer_tests does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… pending its anchor Codex on #768 (PRRT_kwDOS9jIOc6rEtvE): a peer row at or below the mark but stamped after the window's anchor, by a peer clock running ahead, joins a later anchor's window with no new row and no move of the mark. The reuse rule compared only the mark and the accepted cutoff, so a new template could keep the old window, and leave that share out of the work, until the reanchor interval ran out. The peer-cut statement now also returns the peer's newest accepted row under the same bounds, whatever its stamps, by the same index walk on 031's index, which stops there. When that row is above the peer's entry, the snapshot reports a peer row pending (PeerCut::pending, carried on SnapshotCapture and RefreshWindow), and RefreshWindow::reusable refuses the window, so the next template reads a fresh one. Same-template work keeps 3.0's cadence, as before. Tests: the gated clock-skew test asserts the flag while the rows wait, its clearing once this node's clock passes them, and that a rejected row above the entry is never pending. A unit test covers reusable, and a coordinator test shows new templates at an unchanged revision reading a snapshot while a row is pending and reusing the window once none is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex on #768 (PRRT_kwDOS9jIOc6tByaz): the audit-body-ref.v1 and audit-bundle.v2 envelopes check that their shares form one contiguous share_seq run, which a dual-writer window with a cut need not be (a late peer row outside the cut leaves a gap), so such an envelope failed as non-contiguous. These envelopes are 2.x storage artifacts: the cutover import, the read-model API's legacy bodies and the verify and canonicalize CLIs read them, no 3.x writer produces them, and 2.x never wrote a cut. Both resolvers now refuse a bundle whose reward manifest has a cut, by name and before any reconstruction, rather than half-checking it; such a bundle is valid only as a flat logical bundle, which every 3.x path stores and serves. A test wraps the gapped cut fixture in each envelope and checks the named refusal, and that the flat bundle still parses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b81f111 to
ddd3139
Compare
The notes cover everything since v3.0.0-rc.6: #770's import-audits fix (#765) and #760's idle-connection bound (#759), which would have shipped as rc.7, and the 3.1 dual writer (#766, #768, #767, #769, #763), off by default. They describe the new settings, migrations 027, 028 and 031 (029 and 030 reserved), the upgrade from rc.6 with the migrate run while rc.6 serves, the rollbacks, and the dual writer's known limits. The migration guide's import-audits paragraph names this candidate in place of the skipped rc.7. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* 3.x.x: version 3.1.0-rc.1 VERSION, the workspace version and both lockfiles move to 3.1.0-rc.1. The fuzz lockfile also picks up hyper and hyper-util, which #769 added to the server without refreshing it. The 3.0.0 and development-line notes point at the new candidate; its own notes follow in this pull request. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: 3.1.0-rc.1 release notes The notes cover everything since v3.0.0-rc.6: #770's import-audits fix (#765) and #760's idle-connection bound (#759), which would have shipped as rc.7, and the 3.1 dual writer (#766, #768, #767, #769, #763), off by default. They describe the new settings, migrations 027, 028 and 031 (029 and 030 reserved), the upgrade from rc.6 with the migrate run while rc.6 serves, the rollbacks, and the dual writer's known limits. The migration guide's import-audits paragraph names this candidate in place of the skipped rc.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: 3.1.0-rc.1 notes: #773's pre-migrate tests Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: 3.1.0-rc.1 notes: the rollback to one writer stops and syncs the peer first Codex on #774: DOWNGRADE fences nothing, so the peer must be stopped, and its tail pulled, before the single-writer start; declare the tail lost only for a peer that never returns with its own database. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Do not merge: part of the 3.1 stack, teed up for review.
Stack position 2/5: the base is D1's
RobertClarke/p31-identity-sync, with node identity and peer sync. D3's carry-owner branch builds on this one.What changed
In dual-writer mode (
PRISM_DUAL_WRITER=true), each node writes only to its own PostgreSQL and pulls the rows the peer originated. A peer's share can therefore reach a node after that node's own, higher-numbered shares. A payout window bounded only by its anchor timestamp would change when the late row arrived, and the landing proof would refuse a block found on it. Every window now records a per-node cut,{"0": <share_seq or null>, "1": <share_seq or null>}: the highestshare_seqof each node's rows it may include.Eligibility. A row is in a window when it is eligible as in 3.0 (accepted, and accepted and issued at or before the anchor), and its
share_seqis at most its own node's entry in the cut.ORDER_LOCKin the cutoff's statement, once the anchor is taken.qbit_prism_peer_share_mark()(D-14) that is stamped at or before the anchor. The mark the cutoff's statement read and the mark when the entry is read both bound it, so a mark rewound in between never admits a row whose lower rows are gone.The anchor rule and peer rows (CONTRACT D-13). The anchor rule stays on every row. The peer's entry stops below its first row stamped after the anchor, and each node's stamps rise with its
share_seq, so the cut alone decides membership and the anchor rule only confirms it.Every path uses the cut (
ledger/window/cut.rs):read_window, for rebuilds and recovery;build_claim_parts), which every landing, every reconciliation retry and D3's S8 adoption run, by the rule the refresh's build uses: a dual-writer window's audit carries the reference's cut, and the bootstrap window's, whose one share is synthetic, carries none;verify_durable_rangeand the landing's in-lock count;A late peer row is above the peer's entry, so it never makes a landed or offered block unverifiable. It joins later windows.
The #619 holding probe. A dual-writer node has no physical standby (D-19), so the rows it can lose are each log's newest, to a restore. A dual-writer window is held when three things hold:
share_seqorder;A rewound mark or a lost own entry is not held. Retention under the first row is still a pruned prefix.
Incremental advance. A refresh reads each node's rows between the retired window's cut and the fresh one, at or above the retired window's first row. It merges the peer's late rows into the retired window in
share_seqorder (advance_in_cut). The margin below the first row reads the fresh predicate, so nothing is read twice. The delta is bounded by the slots it reads, the union of the nodes' ranges, as the cutoff's difference bounds it in 3.0. The margin walk and the proof (the single-leaf witness and the eligible-row count, under the fresh cut) are now shared with 3.0'sadvance, with 3.0's statements. Anything else falls back to the full scan.The cut reads. Both are shaped so that only the
(origin_node, share_seq)index can serve them:origin_node BETWEEN $1 AND $1 … ORDER BY origin_node DESC, share_seq DESC LIMIT 1.max(share_seq) WHERE origin_node = Nwas measured walking the primary key through the other node's whole run (300,000 rows filtered), insideORDER_LOCK. That happens whenever a node's rows are a fair share of a partition but all lie under the peer's run, as after failback.ORDER_LOCKit reads the newest partitions, usually one, as 3.0's cutoff does. The probe of every partition runs only for a first snapshot, or when that one finds nothing.Uses D1's migration 031. The index is the base's migration 031 (CONTRACT D-14),
qbit_share_ledger_origin_seq_idx. Without a valid btree index on those columns, a dual-writer snapshot refuses before taking any lock, so it never scans the ledger insideORDER_LOCK. While it refuses, the frontend publishes no new work, and two things say why:ALERTat most once a minute;qbit_prism_dual_writer_origin_index_missingreads 1.Refresh. Published work keeps 3.0's same-template cadence. As in 3.0, empty-window (bootstrap) work is the exception: the first share replaces it at once, and so does any move of the peer's mark until a window holds shares, labelled
shares. A cached window is not reused for a new template once the peer's mark has moved (D-13), because the peer's newer rows can all lie below this node's cutoff. Nor is it reused while an accepted peer row at or below the mark waits for a later anchor (stamped ahead by a peer clock running ahead), so that row joins the next template's window instead of waiting for the reanchor. In dual-writer mode, the refresh probe reads the mark in the statement that already reads the revision and the writer timeline.Storage.
cut(absent whenNone) inside the candidate document and the prepared-job payload, both digest-checked.compact_issued's jsonb column check compares the payload's window without it in every mode, since the typed columns never carry it and a single writer started under D-12's downgrade must accept dual-era prepared rows.cut_seq_0andcut_seq_1toqbit_prism_audit_snapshots. Both areNULLwithout a cut,0means no row of that node, and aCHECKenforces the shape. It is additive, needs no capability or shutdown proof, and is registered after 027, before the online 031. The table inventory copies both columns as content, since the table has no local parts.Audit bundle (
crates/qbit-prism).reward_manifest.cutand the stored header carry the cut, absent whenNone. The coinbase commits it through the reward-manifest leaf.ShareOutsideWindowCut). A dropped, added or altered cut fails at the commitment leaf.qbit-prism-build-audit-bundleacceptswindow_cut, one-shot and over--serve, whose protocol goes to 3 so a client that sends a cut can refuse a daemon that would drop it.audit-verifyandaudit-canonicalizehandle both shapes.reorg-verifyreads only policy manifests and is unchanged. The--servedaemon's legacy window fold (window.rs) serves only the 2.x coordinator and is unchanged.Single-writer parity (CONTRACT §4.5). With dual-writer mode off, no window has a cut. Every eligibility, snapshot, probe and refresh statement is 3.0's text, and a unit test pins the predicate. Two statements differ in text only, both so a single writer started under D-12's downgrade handles the rows a dual-writer frontend wrote:
cut_seq_0andcut_seq_1, which are NULL on every single-writer row;cutkey, which a single writer's payloads do not have. A unit test pins it to 3.0's text with that one expression swapped back.Both give 3.0's results on a single writer's rows.
How it was tested
crates/qbit-prism/tests/window_cut_bundles.rs(14 tests):--serve;share_idacross nodes refused;snapshot_delta/cut_merge_tests.rs: a 512-case proptest of the merge, the margin and the assembly against a model of the full scan, plus the per-node refusals and the union bound.ledger::window::cut::dual_writer_tests):coordinator::window_switch_tests, throughprocess_candidate(the offer, then the rebuild and the landing): an idle peer with direct settlement, both nodes' rows with CTV, and a block whose first landing failed, which lands on its reconciliation retry without a second offer;tests/dual_writer_windows.rs: landings from the rebuilt audit, with late peer rows between snapshot, enqueue and landing, an idle peer, and a dual-writer bootstrap block; a bundle whose cut disagrees with its reference is refused.miner_tests::refresh: bootstrap work replaced when only the peer mark moves, full work keeping its cadence, and new templates not reusing a window while a peer row is pending.measure_dual_writer_refresh, ignored).undo_006undoes it, and the new gated tests are registered intest/prism-gated-tests.txt.qbitd):live_regtestand the release-modecompact_runtime_scale, which CI runs) is running ond04cdc46, this branch before the last review's fixes, on D1's193e7fd8. Its results follow in a comment.Docs: dual-writer window cuts, the 028 paragraph in prism-rust-migration.md, and the new gauge in prism-native-metrics.md.
🤖 Generated with Claude Code