Files
texrra-engine/docs/NATIVE_DELIMITERS.md
T

170 lines
10 KiB
Markdown

# Native delimiter fields, sizing and construction — 2026-11-01
Subsequent box/list diagnostic acceptance (2026-11-01): [native inspection](NATIVE_BOX_DIAGNOSTICS.md)
consumes actual showboxbreadth/showboxdepth and original nodes/settings in real
log/terminal output. Full workspace: 1200 passed / 0 failed; 152 exact recursive
lists, 24 paragraph lists, 24 byte-printer cases, 17 CLI tests and five-show/
19-word PDF gate pass. Unchanged LaTeX stops at errorcontextlines (526:1), full
startup false. Compound math/glue inspection and full interaction remain open.
Earlier counts/boundaries below are historical; no font/template fidelity claim.
The strict Route-D executor now consumes delimiterfactor and delimitershortfall
in actual left/right construction. Delcode is a scoped native code table;
delimiter executes as a real math character or supplies a full delimiter field
when scanned by left/right. No font substitution, template rule, v1/string
fallback or runtime TeX subprocess was added.
## Tokens, fields and scope
Delcode defaults to -1 for every byte except period, whose actual INITEX default
is zero. Assignments accept byte indices and integer values <=0xFFFFFF,
including negative values. The code table supports local/global/globaldefs,
internal integer/the/number/ifnum reads, save-stack restoration, dependencies
and trusted JSON snapshots. Code tables are not arithmetic registers: illegal
advance/multiply/divide targets report a native error, including the existing
mathcode/catcode targets that previously reached an internal unreachable arm.
Delimiterfactor is an integer parameter and delimitershortfall a dimension
parameter; both have genuine INITEX zero defaults and real consumers (60 typed
parameters total). Examples explicitly configure format-like values.
Left/right scans expanded nonblank/non-relax input, accepting an actual letter/
Other character's current delcode, character aliases, or delimiter's genuine
27-bit numeric operand. A chardef is not silently treated as a delimiter token.
The full delimiter field retains actual small/large family and byte slots;
class bits are ignored only in delimiter-scanning context. Standalone delimiter
uses the small field as a math character with its actual class/fam rule.
Malformed fields, negative delcodes and mismatches fail strictly; automatic
interactive error recovery and inserted period delimiters are not claimed.
Left opens an owned MathLeft group (actual currentgrouptype 16); right closes
it and produces an Inner noad containing explicit opening/closing delimiter
nodes. Codes are frozen when scanned. Local assignments are restored before
outer math conversion, while global assignments retain their usual behavior.
Fractions inside a pair keep the left/right nodes outside numerator and
denominator. Scripts attach to the resulting Inner noad. Nested pairs, native
math fields, ordinary groups and semisimple groups retain distinct scopes.
## Two-pass sizing and actual fonts
Conversion first measures the enclosed list, excluding delimiter placeholders.
Both delimiters use the original entering style and the full list's maximum
height/depth, even if style nodes occur inside. Selection consumes actual axis
height and TeX's integer formula:
~~~text
distance = max(max_height - axis, max_depth + axis)
target = max((distance / 500) * delimiterfactor,
2 * distance - delimitershortfall)
~~~
For each of the small and large fields, search the actual declared math-family
master from the current style toward text size. Skip null fonts and absent TFM
slots, follow actual next-larger tags, retain the tallest candidate, and stop
on a sufficient candidate or an actual extensible recipe. TFM presence uses
nonzero width_index, including zero-advance slots, not Unicode labels or width
values. Type1 encoding is checked for selected glyphs/components. There is no
font-name guess or replacement of a requested font with an unrelated resource.
An extensible delimiter uses actual top/middle/bottom/repeat parts. Repeat count
comes from actual TFM heights/depths; recipes with a middle add repeats in pairs.
The constructed box width is the repeat component's advance plus italic
correction, its height the first component's height and its depth the total
extent minus that height. Component baseline positions follow real stacked
character boxes. The final box is centered on the actual math axis. If no
candidate exists, the real null delimiter uses nulldelimiterspace and axis
shift; failed probes do not emit ordinary missing-character warnings.
Delimiter component allocation is bounded by the native job's token capacity,
shared across the entire conversion. Unrepresentable delimiter dimensions or
component counts error before unbounded expansion; no size is silently clamped.
Raw font/slot positions are frozen for paragraph/display layout, boxes, SVG and
PDF. Type1 glyph names now provide delimiter-variant/component Unicode metadata;
this does not establish complete symbol/extension text extraction equivalence.
The new exact DVI cases also exposed a general fraction rounding defect. TeX's
two vertical kerns both subtract half(rule thickness), so an odd-sp rule moves
the actual denominator baseline up 1sp while the declared box depth stays the
same. The shared fraction helper now preserves that distinction, and reboxing
centers odd width differences with TeX's upward half rounding. This fixes a
2sp nested-fraction accumulation without offsets or tolerance changes.
## Acceptance
Four new integration tests in execution_delimiters.rs pass:
- **256 actual INITEX default-code queries plus nine composite state queries**:
defaults, local/global/globaldefs, negative values, bounds, internal integer
scans, parameter arithmetic, dependency tracking and JSON restoration.
- **452 actual INITEX cases** compare all box dimensions, raw font/slot choices
and every glyph/rule DVI position within **1sp**. They cover normal/large/
extensible and null candidates, single/double arrows, brace middle pieces,
missing small-family fallback, three-size searches, four styles, factor/
shortfall combinations, nested fractions/pairs, scripts, late assignments,
standalone delimiter and fam selection. The independent DVI reader uses
reference TFM data and imports no native geometry.
- **Seven composite mode/group/scanner readbacks** compare actual INITEX output,
including raw display, MathLeft scope, nested/semisimple groups and frozen
left/right fields. Invalid groups, code ranges, missing fields/resources and
geometric capacity are explicit errors.
Complete frozen workspace: **1195 passed / 0 failed**, including the existing
16 CLI tests. Release, fmt/diff and all prior native/Math D gates pass.
Native/reference delimiter-text PDFs both have **one page / 61 words in
identical order**, with max errors xMin 0.005237, xMax 0.005340,
yMin 0.000278 and yMax 0.000078bp, under the unchanged 0.02bp gate.
The full delimiters.tex includes actual extensible braces and arrows, wide
variants and display depth/continuation. Its absolute 144dpi ink comparison has
identical bounds [144,149,663,608], **91/9743 reference ink pixels different
(0.934%, below the unchanged 1% bound)** and zero unmatched pixels beyond the
one-pixel coverage radius in either direction. No offset is fitted; pixel
identity and extension-font extraction equality are not claimed. Final text
and full-delimiter rasters were inspected.
Prior 438 accent DVI /28 mutable hyphen, 2816 slot predicates +4 font queries,
61 tracing /267 raw-slot, 58 display vlist /36 page /24 state, 100 interline
vlist /64 page, 205 box, 119 paragraph, 117 math list /88 break, 90 token,
101 quantity, 12 filesystem and actual shipout-I/O/pack-state comparisons remain
green. Eight native word-box PDF gates, the accent and 128-slot ink gates pass.
Math D remains three pages, rule y error +0.1035625bp and identical 144dpi ink
bounds. Earlier failed nested-fraction and stale-development-binary probes are
retained separately; none is used as final acceptance evidence.
~~~sh
cargo test -p texrra-tex-core --offline --test execution_delimiters -- --nocapture
cargo test --workspace --offline -- --test-threads=1
cargo build --release --offline
python3 scripts/check-native-paragraphs.py --binary target/release/texrra \
--fixture examples/native-bootstrap/delimiter-text.tex \
--output-dir /tmp/texrra-native-delimiters/delimiter-text \
--json /tmp/texrra-native-delimiters/delimiter-text/pdf-oracle.json
python3 scripts/check-native-accents.py --binary target/release/texrra \
--fixture examples/native-bootstrap/delimiters.tex \
--output-dir /tmp/texrra-native-delimiters/delimiters \
--json /tmp/texrra-native-delimiters/delimiters/audit.json
~~~
Final evidence: /tmp/texrra-native-delimiters/ contains accepted-workspace.log,
accepted-release.log, accepted-cli.log, accepted-delimiter-core.log, core-tests.log,
final PDFs/raster/audit JSON, format-probe-final.json and math-regression.json.
The ink script's optional fixture input preserves all previous defaults and
tolerances; the original word-box gate is unchanged.
## Actual format boundary and next work
The unchanged entry-SHA-pinned LaTeX2e 2025-11-01 now passes delimiterfactor
at 523 and stops at **latex.ltx:524:1, missing showboxbreadth**. Actual auxiliary
time/date I/O and original directory checks still run; format_boot_passed=false.
No format source, capability guard or version constant was altered.
Next connect showboxbreadth/showboxdepth to real recursive box/list diagnostics,
actual scoped state, transcript/terminal output and observable showbox/list
consumers. Do not register inert tracing values. Middle, radicals, generalized
fraction delimiter primitives, complete math ligature/reboxing, operator
variants/limits, numbered displays/alignments, mutable fontdimen, arbitrary
font/NFSS/Unicode shaping and full input closure remain open. Page parameters,
output/shipout/whatsits, dump/load and realtime checkpoints still gate product
replacement. HTTP/project routes remain transitional and the Nimbus/SFTT versus
Liberation template font gap persists. The Unicode-scalar mouth still does not
certify pdfTeX UTF-8 byte-input conformance.