Files
texrra-engine/docs/ROUTE_D_STATUS.md
T

237 lines
13 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Route-D status
Latest acceptance, 2026-11-03: [W3-S5b actual paragraph traces, canonical-zero
glue and owned ordinary side-script lists](NATIVE_PARAGRAPH_TRACE.md) passes
**1384 workspace tests /0**, CLI48, optimized 138 core +20 CLI and all retained/new
gates. Break traces observe the actual candidate/passive/selected path; real
glue specification identity and script h/v lists drive print and paint. The
8-job/32-page oracle has 24 exact reports /5436 pass-and-decision lines, zero
word/raster differences and identical native PDF bytes across trace controls.
All statistics/PK/PDF/device and 105-page object-stream gates remain accepted.
Original full entry and direct kernel now stop at latex.ltx:657:3 tracinggroups;
format_boot_passed=false. Full P2-M1 stays active/incomplete. Remaining real
tracing consumers/insertions, compound math fields, format/NFSS/native image/
article and sessions keep every original exit. No v1/source/template/font fallback.
Dated planning/pause notes below are historical; see [progress](P2_M1_PROGRESS.md).
Next complete stage planned, 2026-11-02: [P2-M1](NATIVE_FORMAT_ARTICLE_STAGE.md)
targets original pdfLaTeX format initialization/native image reload and
unmodified article corpus execution, with full-job session/dependency and
performance baselines. W0–W7 have explicit dependencies and exit gates.
New original-entry probes expose resource lookup at pdflatex.ini:4 and
pdfoutput at pdftexconfig.tex:6; latex.ltx:526 is the direct-kernel boundary.
Real reference TeX builds the format and one-page article; native does not.
This planning round changes no engine implementation or 1204-test baseline.
G1 stays paused; native format boot and safe incremental execution remain open.
Current P1-T1 acceptance, 2026-11-02: [native sfcode and sentence spacing](NATIVE_SFCODE.md)
passes **1204 workspace tests / 0 failed**, release, fmt/diff and all old native/
Math D gates. Three core tests cover **256 INITEX defaults/eight state reads**,
**132 exact factor/glue/hbox/paragraph lists** and **nine raw-slot/missing/timing
cases**. The new PDF has one page / 86 words, max word-box error 0.005581bp
under the unchanged 0.02bp gate. Eighteen CLI tests pass (12+6), including the
retained first-showbox/actual job-entry fix. Compound math diagnostic structure,
errorcontextlines/show/showthe and full interaction remain open; G1 is paused.
Untouched LaTeX remains at 526:1, errorcontextlines, full format startup false.
The governing product remains a complete portable realtime native LaTeX kernel;
Web is the frontend test interface. See [product roadmap](NATIVE_PRODUCT_GOAL.md).
Full font/page/format closure and safe incremental checkpoints are not implied
by this bounded state/paragraph slice. Evidence: /tmp/texrra-native-sfcode/.
Historical audit/plan before P1-T1, 2026-11-02: [short-term gaps and G1](NATIVE_SHORT_TERM_GOAL.md)
records 40 paired native/INITEX probes and six context-limit reference probes.
The first-showbox/no-prior-message case exposes a real extra blank line in TeX
that native output lacked at that point; the accepted five-show fixture did not
cover that initial channel state. Nested errors lack real input context.
G1 planned actual input frames, errorcontextlines, show/showthe and the channel
fix; that planning round made no engine change. The later P1-T1 acceptance above records the channel fix and latest full baseline;
remaining G1 work stays paused. Untouched LaTeX
was last verified to stop at 526:1,
errorcontextlines, full startup false. Diagnostics, general text/quantities,
font resources and native pagination have separate remaining exit criteria.
Prior accepted diagnostic slice, 2026-11-01: native recursive box/list diagnostics pass
**1200 workspace tests / 0 failed**, release, fmt/diff and all prior native/Math D
gates. Four new core tests contain **152 exact INITEX recursive-list cases**,
**24 paragraph lists** and **24 byte-printer cases**. Seventeen CLI tests pass
(native_execution 12, native_job_io 5). See [scope](NATIVE_BOX_DIAGNOSTICS.md).
Showboxbreadth/showboxdepth now consume actual scoped state and original native
nodes (62 typed parameters total). Nested boxes retain semantic views without
duplicating painted trees; selected paragraph lines retain real nodes/settings,
and vertical lists retain named glue. Dimensions, glue-set ratios, ligatures,
kerns, penalties, discretionaries, depth markers and per-level breadth follow
real TeX. No coordinate-derived fake list, inert flag, v1/string fallback,
template rule or font replacement was added.
Showbox is non-destructive and stops current character joining. Font display
names track the latest actual definition without changing physical font IDs;
restricted hbox hyphen construction and actual INITEX newlinechar=0 are fixed.
The real log/terminal pair uses shared newline transitions. Noninteractive show
commands continue PDF output and return status 1; fatal errors still protect an
existing PDF. Full interaction/history/recovery is not certified.
The new release diagnostic gate requires **five exact show bodies**, actual
channels, only intentional OK diagnostics and exits [1,1]. Native/reference
PDFs both have **one page / 19 words in identical order**, maximum word-box
error 0.005262bp (unchanged 0.02bp gate). Final raster inspected. Existing eight
word-box gates and delimiter/accent/128-slot ink gates remain unchanged and pass.
Prior delimiter/accent/slot, display/interline/box/paragraph/math/token/quantity,
filesystem and shipout-I/O oracles remain green. Math D remains three pages,
rule y error +0.1035625bp and identical 144dpi formula ink bounds.
Unchanged SHA-pinned LaTeX2e 2025-11-01 passes showboxbreadth/showboxdepth at
524/525 and stops at **526:1, missing errorcontextlines**. Actual auxiliary
time/date I/O and original directory checks execute; **full format startup
remains false**. Next preserve actual input/macro expansion contexts and consume
errorcontextlines in genuine error/context printing, with independent INITEX
oracles; no unused flag or fabricated backtrace.
Compound math box/glue diagnostics and showlists/showthe/show still require
owned structure/real execution; unsupported inspection fails explicitly.
Broader math/operator/alignment, mutable fontdimen, arbitrary fonts/VF/map/NFSS,
XeTeX shaping, native page/output/shipout/whatsits, full closure/dump/load and
realtime checkpoints remain open. HTTP/project routes remain transitional;
Nimbus/SFTT versus Liberation template font differences persist. Unicode-scalar
input does not certify pdfTeX UTF-8 byte conformance.
Final evidence/logs: /tmp/texrra-native-diagnostics/ (accepted-workspace.log,
accepted-release.log, accepted-core.log, accepted-cli.log, final PDF/raster/
audit JSON, format-probe-final.json and math-regression.json). Changes remain
local and uncommitted/unpushed. See [active plan](ROUTE_D_PLAN.md) and
[native core](NATIVE_EXECUTION_CORE.md). Recovery records below are historical.
Historical service snapshot below (2026-10-27); current native scope and local
uncommitted status are given above.
This page collects what route-D currently does, how to verify it, and the
limits that remain. It is the short companion to the long implementation log in
`ROUTE_D_PLAN.md` and the model notes in `TEX_CORE.md`.
## Verification
Run from the repository root:
```sh
cargo fmt --all -- --check
cargo test --workspace --offline
```
or run `./scripts/verify-route-d.sh`, which executes both.
The historical service snapshot passed **1094 tests**:
| Suite | Tests |
| --- | --- |
| route-D unit (engine) | 435 |
| engine binary unit | 434 |
| server integration | 67 |
| v1 integration | 71 |
| pdfLaTeX oracle | 42 |
| route-D integration | 10 |
| engine/core unit | 4 + 1 |
Latest full run (web trial increment): `./scripts/verify-route-d.sh` passes
with fmt clean and **1094 tests** green.
Latest live check (2026-10-27): the debug server served `examples/hello.tex`
from `target/debug/texrra serve`; `POST /preview` answered 200 with
`X-Preview-Engine: route-d`, one page and an empty warning list, and
`POST /api/route-d/pdf` answered 200 with `application/pdf` and a `%PDF-`
header.
The oracle suite compiles fixtures with `pdflatex`, extracts word boxes with
`pdftotext -bbox`/`pdftoppm`, and compares route-D page geometry; it skips
(saying so) when the TeX tools are absent. The server suite includes
`corpus_documents_preview_without_warnings`, which previews
`examples/hello.tex`, `examples/boxes.tex`, `examples/compat.tex` and
`fixtures/arxiv-template/template.tex` and asserts 200, the expected page count
(1/1/1/2) and an empty `warnings` array for each. A manual sweep of the same four
documents reports 0 warnings and under 1.5 s per preview.
## Service defaults
- Flat `POST /preview` and the project preview/PDF endpoints try route-D first
and fall back to v1 on error. The flat response carries
`X-Preview-Engine: route-d|v1`.
- `?engine=v1` or `TEXRRA_ENGINE=v1` forces the old pipeline; an explicit
`?engine=` wins over the environment.
- `/api/route-d/preview`, `/api/route-d/pdf` and `/api/route-d/edit/{unit}`
remain the explicit route-D surface.
- Geometry-less documents default to Letter (pdfLaTeX's default), not the old
v1 A4 default.
The web experiment matrix, contract findings and trial plan live in
`docs/WEB_ROUTE_D_EXPERIMENT.md`.
## Implemented areas
- **Paragraphs/pages**: Knuth-Plass breaking with prefix-sum candidates,
hyphenation, justification, `\parindent`/`\parskip`, baselineskip/`\lineskip`,
TeX badness page breaking with glue orders, `\topskip`/`\maxdepth`, insertion
classes, marks, floats, `\output` program, incremental page replay.
- **Macros**: textual expansion with group scopes (`{}`,
`\begingroup`), `\def`/`\gdef`/`\edef`/`\xdef`, delimited and undelimited
parameters, `\let`, `\chardef`, `\newif`, `\csname`, `\expandafter`,
`\futurelet`, `\aftergroup`, `\afterassignment`, `\scantokens`, token
registers, `\string`, `\meaning`, `\expanded`, `\unexpanded`,
`\detokenize`; `@` and `%` catcodes are applied.
- **Boxes**: `\sbox`/`\savebox` measured at definition (width/height/depth,
image bodies use decoded pixels), frozen dimensions, `\wd`/`\ht`/`\dp`,
unbreakable `\mbox`/`\usebox`, `\parbox` content, framed/colour boxes.
- **Tables**: `tabular`/`longtable`, `\multicolumn`, `\multirow`, `p{}`
wrapping, `\tabskip`/`\tabcolsep`, booktabs rules, row splitting, real nested
tabulars, and `\valign` transposed into a tabular.
- **Math**: CM metrics and Type1 faces, fractions/scripts/delimiters, aligned
environments, operators, and inline math scaled proportionally at any
paragraph size.
- **Fonts**: twelve CM text faces and four math faces, Liberation fallback per
glyph, Greek/Cyrillic/accents, Greek math commands, fontspec family aliases.
- **Service**: both preview paths default to route-D with v1 fallback, caches
and sessions, engine-labelled flat responses.
## Scope assessment
This handoff closes the programme's current scope: the archived round-150
commits are pushed, and each named gap area has an implementation with tests,
documentation and green evidence. In summary:
- The token/catcode engine is a text-level expander with scoped definitions,
parameters, conditionals, `\edef`-style freezing, token registers and the
common LaTeX internals; it is not a byte-for-byte TeX token stream.
- Measured saveboxes measure their content (including project images) before
placing it.
- The table path covers nested tables, `\valign`, booktabs rules, multicolumn,
multirow and scaled/table wrappers.
- NFSS and the bundled fonts cover the twelve Computer Modern faces, fontspec
aliases, `\usefont`, fallback glyphs and math alphabets.
- Both preview paths default to route-D with a v1 fallback, and a live smoke
test confirms the flat endpoint and PDF export.
The entries under Known limits are architectural extensions rather than
regressions: they do not affect the four corpus documents (empty warning lists
and pinned page counts), the pdfLaTeX oracle suite, or the default service
behaviour. Continuing the programme means picking one known limit, adding a
focused test, and repeating the verification/push cycle described below.
## Known limits
- Expansion is textual, not a token stream; the catcode table models only `@`
and `%` (other `\catcode` assignments are consumed but not applied).
- Complex-script shaping (Devanagari, Thai, emoji) has no fallback face; this is
outside pdfLaTeX's own scope and is reported rather than silently mis-set.
- A `\parbox` keeps its content unbreakable; its width argument does not wrap.
- Images inside a nested table are not merged into the outer display list.
- `\valign` cells are left-aligned; its preamble alignments/vertical rules are
ignored.
- `\unexpanded` freezes its tokens during an edef-style pass and they expand
at use time; the wider token-stream semantics of `\edef` remain textual.
## Continuing
1. Read `TEX_CORE.md` for the model and `ROUTE_D_PLAN.md` for the phase history.
2. Pick a limit above, add a route-D unit test (and a server/corpus test when
user-visible), update the relevant doc paragraph, and push to `main`.
3. Keep `cargo fmt --all -- --check` and the full workspace suite green before
every push; the oracle suite needs `pdflatex`, `pdftotext` and `pdftoppm`.