Files

182 lines
11 KiB
Markdown

# Native boxes and vertical packing — 2026-10-31
2026-11-03: [W3-S2 native vertical splitting and marks](NATIVE_SPLITTING.md) is accepted.
Original nodes drive real vert_break/vsplit, depth limits, remaining-list pruning,
exact/natural vpack and actual per-class split marks. 447 box pairs and 252 DVI
pages match independent INITEX. Workspace1330/0; native page/output/shipout
and PDF configuration remain unfinished. Kernel530 maxdepth/full-entry pdfoutput
and format_boot_passed=false remain; earlier evidence below is historical.
2026-11-03 follow-up: [W3-S1 original lists and rules](NATIVE_LISTS.md) is accepted:
1318 workspace tests / 0 failed. Paragraph vlist lines own actual raw NativeBox lists;
running rules, overfull markers, contextual shifts, unboxing and inner lastbox use
the same pack/diagnostic/geometry consumers. Math boxes also suspend/restore
actual math/display frames. Real vsplit/page/output/shipout remain unfinished.
Unmodified kernel now stops at 530:1 maxdepth; full pdflatex.ini still pdfoutput.
Format boot is false. All older counts and boundaries below are historical.
Subsequent font-slot acceptance (2026-11-01): [native font diagnostics](NATIVE_FONT_DIAGNOSTICS.md)
now consumes tracinglostchars/tracingonline using actual TFM/Type1 slots, with
real font predicates, log/terminal delivery and fatal PDF protection. Full
workspace: 1187 passed / 0 failed; prior slice gates remain green. Unchanged
LaTeX now stops at defaultskewchar (522:1), so earlier boundaries/counts on
this page are historical. Full format startup remains false.
Current follow-up (2026-11-01): [native display math](NATIVE_DISPLAY_MATH.md)
is accepted: 1182 workspace tests, 58 vlist / 36 page / 24 quantity-mode-pack
cases and a three-page PDF gate. Unchanged LaTeX now stops at tracinglostchars
(508:1). Earlier counts/boundaries below describe their original slices.
Current follow-up (2026-11-01): [native interline penalties](NATIVE_INTERLINE_PENALTIES.md)
are accepted: 1176 workspace tests, 100 vlist and 64 actual page-ownership cases;
unchanged LaTeX now stops at displaywidowpenalty (502:1). Earlier acceptance
counts/boundaries below describe their original slices, not current startup.
Current follow-up (2026-11-01): [native inline math](NATIVE_MATH_EXECUTION.md)
is accepted: 1171 workspace tests; unchanged LaTeX now stops at clubpenalty
(500:1). This document retains its original slice's evidence and limits;
current math/family coverage is defined by the linked follow-up.
Route-D now executes hbox/vbox/vtop, builds owned nested lists, stores/moves/
copies boxes, and packages their actual contents. vbadness has a real vpack
consumer; no version marker, inert parameter, string frontend, v1 dispatch or
runtime TeX subprocess is involved. Independent tests invoke pdfTeX as an oracle.
## Owned execution and state
execution/boxes.rs contains NativeBox, BoxContent, NativeVerticalNode,
VerticalBuilder, integer packing and the measured-geometry display conversion.
engine/boxes.rs owns constructor scanning, mode nesting, grouping, register
operations, append-to-vlist and diagnostics. The additions are:
- hbox, vbox and vtop with natural size, to and spread specifications; native
restricted-horizontal/internal-vertical modes and nested boxes.
- setbox, box (move/void), copy, scoped/global/globaldefs register assignments,
extended register indices, wd/ht/dp reads and actual dimension mutation.
Dimension mutation does not create a void box or invent a group save.
- Real ifvoid/ifhbox/ifvbox evaluation; ifinner and currentgrouptype reflect
hbox/adjusted-hbox/vbox/vtop groups. Paragraphs inside a vbox use ordinary
horizontal mode; an internal vertical list has its own previous depth.
- vskip, vertical kern/penalty, vfil/vfill/vss, hrule, prevdepth and read-only
badness. Glue/kern leave append-to-vlist previous depth intact; rules reset
it to the TeX ignore-depth value. prevdepth is mode state, not a scoped
dimension register.
- Scoped vbadness/vfuzz/boxmaxdepth and hfuzz have actual packing/diagnostic
consumers. All four have INITEX zero defaults. Existing paragraph parameters
now build real vertical material at execution time.
A constructor establishes its save level before scan_left_brace expands input;
relax and brace aliases are supported. At closing, paragraphs finish first,
inner boxmaxdepth is captured, the save stack restores the outer environment,
and hpack/vpackage then read the restored diagnostic parameters. This order is
covered by real TeX probes. Box registers and contents survive trusted execution
JSON snapshots; this is still not a versioned native fmt or safe cache format.
## Actual packing and diagnostics
vpack walks child boxes/line boxes/rules, accumulates height and trailing depth,
resets the accumulated depth at glue/kern, and collects all four glue orders.
boxmaxdepth moves excess trailing depth into height. Natural/to/spread determine
the target height and glue ratio. vtop then inherits its height from its first
box/line/rule, or zero for another first node. It preserves the packed extent.
hpack measures glyphs, nested boxes, kerns and glue without line breaking.
Common font ligatures use the real embedded CMR10 metrics, as in the accepted
paragraph slice. Both packers retain rational glue setting and actual contents.
The renderer consumes packed geometry and never reparses source text.
badness is the result of the most recent actual package: integer TeX badness for
finite flexibility, zero for infinite flexibility/exact/empty packs, and
**1,000,000 for an overfull package**. This differs from the paragraph search's
10001 sentinel and from page-break cost. Paragraph line packages now keep their
physical pack badness/excess separately from break-search badness, including
emergency-stretch cases.
Underfull/loose/tight diagnostics compare real finite pack badness with the
appropriate threshold. Overfull diagnostics use actual unabsorbed excess and
fuzz, with TeX's threshold-below-100 exception. Exact, empty and infinite-order
packs do not emit false messages under negative thresholds. Diagnostics use
native labels and explicit numeric badness/excess; exact TeX log formatting and
showbox output are not implemented.
Paragraph-start glue and actual append-to-vlist baselines are now generated
while tokens execute. VerticalMaterial events preserve the resulting root list;
Execution.document exports those batches. BuiltParagraph/Character events are
traces, including stored/discarded box material, and cannot cause it to paint.
Later state does not restyle an already measured box. Nested box content remains
in TeX sp until one 800/803 conversion at the display boundary. Internal running
rules use their containing box width.
## Accepted evidence
- Four native box integration tests include **205 real pdfTeX INITEX cases**.
Width/height/depth and badness match exactly in integer sp; diagnostic label
counts match. Cases cover natural/to/spread, empty/exact/overfull/tight/loose,
finite and infinite stretch/shrink, vtop references, depth caps, nested boxes,
rule/glue/kern behavior, paragraph lists, prevdepth, group timing, thresholds/
fuzz, brace aliases, register moves/scopes/globaldefs and extended indices.
- Other checks cover actual box-mode queries, dimension mutation and voiding,
JSON round trips, source dependencies, nesting limits, unsupported input and
deferred I/O rejection. Existing **119 paragraph**, **90 token**, **101 quantity**,
**12 filesystem** comparisons and selected/discarded shipout oracle remain.
- The boxes.tex native and real pdfTeX PDFs both contain one page and 30 words
in identical order. Maximum word-box errors: xMin 0.005131, xMax 0.011388,
yMin 0.000278, yMax 0.000078bp, all below the 0.02bp gate. The existing 89-word
paragraph fixture remains below 0.02bp as well. Both use actual embedded CMR10.
- Full workspace: **1164 passed / 0 failed**, including twelve CLI tests
(native_execution 9, native_job_io 3). Release, fmt/diff, the actual format
audit and the unchanged math D position/ink gate are also required.
~~~sh
cargo test -p texrra-tex-core --offline --test execution_boxes -- --nocapture
cargo test --workspace --offline -- --test-threads=1
cargo build --release --offline
python scripts/check-native-paragraphs.py --binary target/release/texrra \
--fixture examples/native-bootstrap/boxes.tex \
--output-dir /tmp/texrra-native-vpack/boxes \
--json /tmp/texrra-native-vpack/boxes/pdf-oracle.json
python scripts/probe-native-format.py --binary target/release/texrra \
--texmf /usr/share/texlive/texmf-dist \
--json /tmp/texrra-native-vpack/format-probe-final.json
~~~
Current evidence: /tmp/texrra-native-vpack/ (box and paragraph PDFs/rasters,
word-box audits, format-probe-final.json, arxiv-regression.pdf and
math-regression.json). Final logs: /tmp/texrra-vpack-workspace.log,
/tmp/texrra-vpack-release.log and /tmp/texrra-vpack-accepted-core.log.
## Real format boundary and remaining work
The same unchanged SHA-pinned LaTeX2e 2025-11-01 entry now proceeds from
vbadness at 494:1 through linepenalty/hyphenpenalty/exhyphenpenalty to
**498:1, missing binoppenalty**. Actual time/date auxiliary writing, reading and
source directory checks still pass. format_boot_passed remains false.
Next implement native math token/noad/list execution and the actual placement
of binop/rel penalties when math lists become horizontal material. Connect the
accepted math geometry through that path. Registering math parameters without
consumers would not implement it. General paragraph interline/club/widow/broken
penalties and display transitions also need real native list consumers.
This slice is not complete TeX box/page execution. Negative glue flexibility,
vrule/shift/leaders, unboxing, vsplit, inserts, marks, everyhbox/everyvbox,
output routines and TeX shipout syntax remain unsupported. Packing explicitly
rejects negative flexibility. Deferred I/O inside boxes errors until real
whatsit traversal/selection is implemented; immediate I/O still executes
through the real host. Root deferred I/O retains the existing explicit API and
is rejected by PDF export, never flushed at EOF.
Outer running-width rules require native page packaging and fail explicitly;
explicit-width outer rules and internal running rules are implemented. Topskip,
page size/goal/maxdepth remain declared host canvas policy rather than new
native page primitives. Box nesting is capped at 32 (or lower input depth),
with a cumulative node capacity; this is not full TeX capacity.
CMR10 10pt remains the only implemented native text font resource/size. Full
TFM/VF/encoding/map/fontdimen/NFSS and XeTeX shaping remain open. Pin the complete
format/config/font closure, implement native dump/load and execute an unchanged
minimal article before claiming full format compatibility. HTTP/project routes
still use the transitional frontend and have no automatic fallback from native
execution. Incremental reuse/checkpoints and realtime performance remain future
product gates.