Skip to content

refactor(engine): dedup the atomic-block page-admission guard#358

Merged
DemchaAV merged 1 commit into
2.0-devfrom
refactor/dedup-atomic-block-guard
Jul 11, 2026
Merged

refactor(engine): dedup the atomic-block page-admission guard#358
DemchaAV merged 1 commit into
2.0-devfrom
refactor/dedup-atomic-block-guard

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

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-bearing
pagination invariant are a drift risk: a future change to the admission rule has to land in
three places or they silently diverge.

What

  • Extracted the guard into a private admitAtomicBlock(outerHeight, path, state); the three
    compile paths now call it after computing their block height.
  • Byte-identical: same activeInnerHeight + CAPACITY_TOLERANCE reject, same
    remainingHeight + EPS new-page decision, same touchPage.

Tests

  • ./mvnw -f aggregator/pom.xml verify -pl :graph-compose-qa -am — full compile + javadoc
    gate + the qa visual/parity byte-identity suite (643): green. Pagination and the
    too-large throw (PageCapacityToleranceDemoTest) are unchanged.

admitAtomicBlock mutates the compiler cursor (newPage/touchPage), so it stays a
LayoutCompiler private exercised by the qa corpus — not a pure isolatable helper (same as
the pagination-cursor helpers already on CompilerState). The guards that genuinely differ —
compileComposite's keep-whole / start-reservation logic and compileSplittableLeaf's split
loop — are intentionally left alone.

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.
@DemchaAV DemchaAV merged commit de84c52 into 2.0-dev Jul 11, 2026
12 checks passed
@DemchaAV DemchaAV deleted the refactor/dedup-atomic-block-guard branch July 11, 2026 00:32
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