refactor(engine): dedup the atomic-block page-admission guard#358
Merged
Conversation
The identical "reject a block taller than a page, advance to a new page when it doesn't fit in the remaining height, mark the landing page touched" guard was copied verbatim into compileHorizontalRow, compileStackedLayer and compileAtomicLeaf. Fold the three copies into one private admitAtomicBlock so the atomic-pagination contract has a single source of truth. Byte-identical.
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.
Why
The atomic-block page-admission guard — reject if taller than a full page, advance to a
new page when it doesn't fit in the remaining height, mark the landing page touched — was
duplicated verbatim across three
compile*methods (compileHorizontalRow,compileStackedLayer,compileAtomicLeaf). Three identical copies of a load-bearingpagination invariant are a drift risk: a future change to the admission rule has to land in
three places or they silently diverge.
What
admitAtomicBlock(outerHeight, path, state); the threecompile paths now call it after computing their block height.
activeInnerHeight+CAPACITY_TOLERANCEreject, sameremainingHeight+EPSnew-page decision, sametouchPage.Tests
./mvnw -f aggregator/pom.xml verify -pl :graph-compose-qa -am— full compile + javadocgate + the qa visual/parity byte-identity suite (643): green. Pagination and the
too-large throw (
PageCapacityToleranceDemoTest) are unchanged.admitAtomicBlockmutates the compiler cursor (newPage/touchPage), so it stays aLayoutCompilerprivate exercised by the qa corpus — not a pure isolatable helper (same asthe pagination-cursor helpers already on
CompilerState). The guards that genuinely differ —compileComposite's keep-whole / start-reservation logic andcompileSplittableLeaf's splitloop — are intentionally left alone.