Skip to content

feat(sync): apply in pages, one frame and one rebase each (T13193 R-4c) - #1923

Merged
kryptobaseddev merged 5 commits into
mainfrom
feat/T13193-pages
Oct 7, 2026
Merged

kryptobaseddev merged 5 commits into
mainfrom
feat/T13193-pages

Conversation

@kryptobaseddev

Copy link
Copy Markdown
Owner

Task: T13193

Second part of the fourth slice of the scoped rebase (journal spec §3.5 Rule 3, R6-4). Stacked on #1922 (T13273). Also closes T13274, #1921's LOW.

What changes

  • Pages.
    • applyStagedTxns now groups staged txns into pages with takePage: up to REBASE_PAGE_OPS (2,000) ops, with pageOps/pageMs overrides.
    • A page breaks only between txns. A split txn is one staged unit, so its part-set stays whole. A page also breaks on an actor change, because one apply frame records one actor. A txn larger than a page is a page alone (the declared exemption).
    • The time bound (REBASE_PAGE_MS, 50 ms) stops a page from taking more txns; whatever is left starts the next page.
  • One frame per page. Each page is one apply frame:
    1. planPageRebase builds the scope over the page's foreign footprints and its own echoes that fail the fast path, to a fixed point;
    2. one rewind;
    3. applyInPage runs per txn: pre-checks, planning, clock, ops in their own Gate C savepoint, post-apply checks, sequencing, inbox mark;
    4. one replay of the rewound locals whose echo the page did not decide.
  • Own echoes. A rewound local txn whose echo is in the page applies at its stream position and is sequenced there (outcome applied or void). A refused one stays rewound, since the rollback is per txn. An in-place echo voided by Gate C still gets its own rewind (planOwnRebase, which leaves out what the page already rewound).
  • Fast path judged once per page. echoInPlace reuses the page's unsequencedLocalTxns, and the verdict is reused at sequencing. That covers review-hotfix's O(backlog) LOW from feat(sync): scoped rebase frame - rewind, apply, replay (T13193 R-2) #1916.
  • Natural twins (D2). A local insert the stream also made is rewound to the stream's row, from its replay snapshot, instead of deleted. Before, a later stream U of that row waited forever.
  • T13274. A U setting part of a composite UNIQUE key fills the rest from the current row, as wire values with refs as uids.
  • Nit from fix(sync): apply finds natural-key rows whose uid was never filled (T13273) #1922. Added a comment on adoptNaturalRow's === 1.

Tests

  • Page tests (new, real replicas):
    • one txn per page (pageOps: 1) converges with one page, checked through applied_frame;
    • a Gate C void inside a page rolls back only that txn, its sibling applies in the same frame, and the replicas converge;
    • the time bound ends a page between txns;
    • an actor change breaks a page, and a 2-op txn under pageOps: 1 applies whole.
  • Natural twin: a relation both replicas inserted, then a stream update of it, converges.
  • T13274 unit tests: a partial key U, a ref part converted to a uid, and an unmoved key that adds nothing.
  • Existing tests updated to page semantics:
    • the LOW-1 test now expects rebased: 2 (B's insert and A's echo share one rebased page);
    • one sequencing test's foreign touch now targets a row the stream knows, instead of an unsequenced local insert.
  • Mutation checks: page ops bound, actor break, time bound, the replay excluding decided echoes, the per-page fast-path verdict, the twin rewind, and all three T13274 pieces. All killed.

Locally green:

  • 264 targeted tests (apply/, repair, sealer, apply-intent, trigger-suspend, identity-fill, legacy-groups, show);
  • tsc;
  • biome on every file changed vs main;
  • gates 3, 4, 28, 36, 37, 38 (--base origin/fix/T13273-natural-key-apply) and 40.

Not here: the R6-4 7-day backlog benchmark on a cleocode scratch copy (heavy; waiting on team-lead's call on a separate task).

🤖 Generated with Claude Code

…c, T13274)

Journal spec §3.5 Rule 3 (R6-4):
- staged txns apply in pages (REBASE_PAGE_OPS 2000 / REBASE_PAGE_MS 50,
  overridable): one apply frame, one rewind, each txn in its own Gate C
  savepoint, one replay. Pages break between txns only, on an actor
  change, and an oversize txn is a page alone.
- a rewound local txn whose echo is in the page is decided at its stream
  position; the rest are replayed at page end; the fast path is judged
  once per page (planPageRebase).
- a natural twin insert is rewound to the stream's row, not deleted (D2).
- T13274: a U setting part of a composite UNIQUE key fills the rest from
  the current row for its pseudo-row.
- nit from #1922: comment why adoptNaturalRow checks === 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from fix/T13273-natural-key-apply to main October 7, 2026 02:40
@kryptobaseddev

Copy link
Copy Markdown
Owner Author

Merging at the approved head 021c582 (review-hotfix APPROVE merge-only 021c582 (clean main merge over 0e8c3eb); CI: 105 checks, all green).

@kryptobaseddev
kryptobaseddev merged commit 36d0c80 into main Oct 7, 2026
110 of 201 checks passed
@kryptobaseddev
kryptobaseddev deleted the feat/T13193-pages branch October 7, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant