Skip to main content

Module boundary

Module boundary 

Source
Expand description

Page boundary signatures (issue #70; design note docs/incremental-dependencies.md §4.5, §6, §7).

Reflow and fixpoint work (manifest §33) needs to detect where pagination changed between two layout runs without re-diffing whole pages or serializing PDF output. A PageBoundarySignature is a compact, stable digest of one laid-out Page’s break-defining content; a PageGraphSignature is the ordered per-page list, so the first index where two graphs disagree is exactly where the page breaks diverged.

This is the §4.5 PageOutputHash (“did the laid-out page actually change?”) reduced to the layout primitives that exist today (text runs and image placements). It is identity/comparison only: no DepNode graph, no CacheKey wiring, no reflow loop; those consume these signatures later.

§What feeds a signature

Per page, in order: the page number, the quantized page box, then each text run (quantized position + size, a backend-neutral font identity, text) and each image placement (intrinsic pixel dimensions + quantized rectangle). Run and image counts are folded too, so adding or removing one shifts the digest.

Deliberately excluded, per the determinism rules (§5) and the §4.2/§4.3 carve-outs:

  • Shaped glyphs on a run: derived from text + font + shaper, so folding them would bind the signature to a transcoder version it should not care about. The authored text and font identity stand in for them.
  • The PDF resource name of a font (F1..): a backend emitter slot; layout must not depend on it, so a backend-neutral font identity is folded instead (see font_identity).
  • Decoded image pixels (rgb8): an asset-content concern (§4.3), addressed by the asset’s own hash, not the page boundary.
  • resolved_path on an image handle: an absolute filesystem path, which §5 rule 1 forbids from any hash.
  • handle.id: assigned in image-encounter order, so folding it would churn unrelated pages’ signatures when an image is added earlier; the intrinsic pixel dimensions identify the asset’s footprint instead.

§Quantization

Every f32 dimension is snapped to the 1/64-pt grid (§6) before folding, so two layouts that reach the same length through slightly different arithmetic agree. The design note specifies an i32 count of 1/64 pt; we snap to the same grid and fold the canonical bit pattern of the integral count instead (see quantize_units), which is equivalent for hashing and avoids a lint-denied float-to-int cast. The §9.5 quantization newtype can later adopt the i32 form without changing this boundary’s observable behavior.

Structs§

PageBoundarySignature
A compact, deterministic digest of one laid-out Page’s break-defining content (design note §4.5).
PageGraphSignature
The ordered per-page boundary signatures of a whole PageGraph.

Constants§

PAGE_DOMAIN 🔒
Domain tag separating this boundary from every other H(...) (§4).

Functions§

fold_count 🔒
The number of items folded as a count, saturating so an absurd length cannot silently wrap.
fold_image 🔒
fold_run 🔒
font_identity 🔒
A backend-neutral, stable identity for a font face.
quantize_units 🔒
Snap a point measurement to the 1/64-pt grid (§6) and return the canonical bit pattern of that integral count.