Audit the G1 milestones and refresh the plan status

This commit is contained in:
gloamxun committed 2026-10-24 00:42:22 +08:00
1 parent a93200cbfb
commit f980ed7f56
2 files changed
+69 -64

No files matched your search

+50 -19
View File
@@ -387,6 +387,30 @@ cargo run -p texrra-tex-core --example incremental_article
cargo run -p texrra-tex-core --example pdf_display > /tmp/route-d.pdf
```
### G1 audit (P0-P2)
The `G1` scope of [`ROUTE_D_PLAN.md`](ROUTE_D_PLAN.md) is implemented and
covered by the suite:
| Milestone | Evidence |
| --- | --- |
| P0 oracle harness | `crates/texrra-tex-core/tests/oracle.rs` runs pdfLaTeX/pdftoppm/pdftotext comparisons, skips when a tool is missing, and covers 35 paragraph/page fixtures: measure matrix 90-240pt, `\tolerance`/`\pretolerance`/`\emergencystretch`, `\hangindent`/`\parshape`, `\parfillskip`, glues, sentence spacing, narrow-measure pretolerance, page breaks, floats, insertions and `\newpage`. |
| P1 paragraphs | TeX passes and demerits (`\pretolerance`/`\tolerance`, adjacent fitness 0-3, line penalty, `\adjdemerits`, double/final hyphen demerits, `\emergencystretch`), hyphenation from flat/exception data, `\hangindent`/`\hangafter`/`\parshape`, `\looseness`, `\leftskip`/`\rightskip`/`\parfillskip` with `fil`, `\baselineskip`/`\lineskip`/`\lineskiplimit`, `\parskip` with plus/minus, `\spaceskip`/`\xspaceskip`, `\sfcode`/`\frenchspacing`, `\tolerance`-family registers, interword `fil`/`fill` glue, italic correction and TFM kerning/ligatures. |
| P2 page builder | TeX candidate-break cost and legal glue breaks, glue setting (`\raggedbottom`/`\flushbottom`, glue orders), `\vsize`/`\voffset`/`\topskip`/`\maxdepth`, paper size, marks (classed, carried to the next page), insertion classes (`\count<n>`/`\dimen<n>`/`\skip<n>`, splitting, held-over, dedicated held pages), and interpreted `\output` with `\shipout\box255`, conditionals, arithmetic, mark writes, register reads/assignments and page retargeting. Floats keep their top/bottom/in-text/float-page policies. |
Residual approximations, documented rather than special-cased:
- the content of `\box255` is not inspectable (its width/height/depth are);
- `\topmarks`/`\firstmarks`/`\botmarks` are not readable by the routine;
- an assigned `\vsize` cannot retarget a document that defers bottom floats;
- paged replay falls back to a full rebuild when an interpreted `\output`
routine or insertions are present;
- a narrow-measure `\tolerance=10000` break can differ from TeX's demerit
optimum because the model uses the simplified badness table;
- NFSS family switching and multi-face Computer Modern outlines are not
implemented (route-D embeds Liberation faces).
### Open milestones
The staged program that closes these milestones is described in
@@ -402,26 +426,33 @@ deliberately open rather than approximated:
interline glue, the default `\sfcode`/`\frenchspacing` sentence spacing,
explicit `\spaceskip`/`\xspaceskip`, stretch and shrink on the
inter-paragraph `\parskip` glue, and `\raggedright` (infinite `\rightskip` fil) are modelled.
- **M2**: `Engine::layout` keeps the scrolling builder as the non-paged
fallback, while route-D previews and PDFs run `Engine::layout_paged`;
`page::PageBuilder` implements TeX's candidate-breakpoint cost (badness + penalty, glue
stretch/shrink, `\topskip`, `\maxdepth`); a break at glue is only legal
when it follows a non-discardable item, so glue after glue is not a
breakpoint and the glue at a break is discarded and `Engine::layout_paged` runs it
for simple documents; `PageBuilder::ragged_bottom` selects `\raggedbottom`
(the default) or `\flushbottom`, which stretches `VerticalItem::StretchGlue`
in proportion to its stretch so the page body reaches the goal (only shrink
is clamped, as in TeX); glue of the highest TeX order with stretch (`\vfil`
and above) absorbs the whole setting, so a page that stops short of the goal
is free when fill glue is present; paged edits replay from the edited page, insertions
and an interpreted `\output` keep the full-rebuild fallback; paper margins
remain open, and
the `\output` interpreter only covers the shipout/ifdim/ifnum/ifodd/ifcase subset (explicit
`\hoffset`/`\voffset` offsets are applied by both the PDF writer and the
preview display list).
- **M2**: `Engine::layout` keeps the scrolling builder as the
non-paged fallback, while route-D previews and PDFs run `Engine::layout_paged`.
`page::PageBuilder` implements TeX's candidate-breakpoint cost (badness +
penalty, glue stretch/shrink, `\topskip`, `\maxdepth`), legal glue breaks
(glue after glue is not a breakpoint and the glue at a break is discarded),
`\raggedbottom`/`\flushbottom` and the `\vfil`/`\vfill`/`\vfilll` orders,
per-page `\vsize` and `\maxdepth`, top/bottom/in-text floats with
`\floatsep`/`\textfloatsep`/`\intextsep` and the fraction/count limits,
and insertion classes with `\count<n>`, `\dimen<n>` and `\skip<n>`,
splitting and held-over material. `Document::output_routine` is interpreted
after every paged page for `\shipout\box255`, `\relax`, `\message`,
`\mark`/`\marks<n>`, `\ifdim`, `\ifnum`, `\ifodd`, `\ifcase`,
`\advance`/`\multiply`/`\divide` and register assignments; the routine
reads `\pagegoal`, `\pagetotal`, `\pagedepth`, the page stretch registers,
`\vbadness`, `\insertpenalties`, `\ht255`/`\dp255`/`\wd255`, `\hsize`,
`\vsize`, `\topskip`, `\maxdepth`, `\outputpenalty`, `\pageno`,
`\deadcycles`, `\maxdeadcycles`, `\prevgraf` and the insertion registers,
and its `\vsize`, `\dimen<n>`, `\count<n>` and `\skip<n>` assignments
rebuild the pages it has not seen yet. Explicit `\hoffset`/`\voffset`
offsets are applied by the PDF writer and the preview display list.
- **M5**: `cmr10.tfm` is parsed at runtime with widths, glyph heights/depths and kern pairs. only used text faces embed Liberation Serif/Mono as Type0/Identity-H; each face is subset to the glyphs actually used (composite components included, glyph IDs retained); FontFile2 and ToUnicode streams use Flate compression; the ToUnicode CMap follows the used characters; ff/fi/fl/ffi/ffl ligatures come from TFM, and CMR10 italic corrections are applied at line ends; full NFSS family switching is not implemented.
- **M6**: `\output`, `\insert`, mark/float output policies, class-file execution and
math limit policies are only partially modeled; `OutputRoutine::wants_break` can force a page break between units, and insertion material is stacked by class from the page bottom; `Document::output_routine` is interpreted per page by `output::OutputProgram` for the shipout/ifdim/ifnum/ifodd/ifcase subset (with `\pageno`, `\outputpenalty`, `\deadcycles`), while `OutputRoutine` remains the Rust hook.
- **M6**: class-file execution and the parser side of `\output`/`\insert`
are still semantic: the source parser maps LaTeX constructs onto the
document model and `Document::output_routine` is the interpreted program.
`OutputRoutine::wants_break` remains a Rust hook for forcing a page break
between units, insertion material is stacked by class from the page bottom,
and the page box (`\box255`) exposes width/height/depth but not its content.
- Page hashes cover rendered items/insertions/marks/floats, not source-dependency
metadata, so replaying an earlier page cannot change its hash merely by
re-attaching source hashes.