Advance native LaTeX execution and preview

This commit is contained in:
gloamxun committed 2026-11-18 22:17:21 +08:00
1 parent 91f9d76b16
commit 2741546ca8
414 files changed
+99872 -933

No files matched your search

+211 -2
View File
@@ -1,5 +1,214 @@
# Route D: complete implementation plan
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).
Execution authorized, 2026-11-02: the user approved the complete
[P2-M1 stage](NATIVE_FORMAT_ARTICLE_STAGE.md), with **every original G1 exit
criterion mandatory in W1**. W0 implementation is under way; see
[live progress](P2_M1_PROGRESS.md). Earlier G1 pause/planning statements below
are historical. No stage completion or replacement of the 1204-test baseline
is claimed by this authorization or the current targeted work.
## Current product direction — 2026-11-02
The user reaffirmed the end product: a native LaTeX kernel with Typst-like
realtime incremental rendering and complete project portability. The Web app
is a frontend test surface. Primitive/diagnostic slices are subordinate to real
format, font, page and unmodified-project compatibility, together with correct
incremental execution. The governing roadmap and exit criteria are now in
[NATIVE_PRODUCT_GOAL.md](NATIVE_PRODUCT_GOAL.md). G1 remains paused at the user's
request. Its first-showbox component is now independently validated together
with P1-T1; its remaining input-context/diagnostic work is incomplete.
The next complete stage is [P2-M1: real format and unmodified article](NATIVE_FORMAT_ARTICLE_STAGE.md).
It plans actual pdflatex.ini/TEXMF/PDF initialization, execution/font/page
consumers, native format dump/load, five article corpus groups and full-job
session/revision/dependency/performance foundations. W0 fixes the reference
closure and general resource-resolution contract first. Fresh probes show
pdflatex.ini currently fails to find pdftexconfig.tex; the configuration itself
fails at pdfoutput, while direct latex.ltx still stops at errorcontextlines.
Actual reference TeX builds the format and a one-page minimal article. These
are planning/baseline results, not new native implementation acceptance.
G1 remains paused; incremental reuse and Web migration are separate exits.
Route-D is the sole future product engine and will completely replace v1.
The plan below this section is historical where it conflicts with these rules:
- Route-D owns input scanning, tokens, macro expansion, state, primitives,
modes, native horizontal/vertical/math lists, layout and export.
- Execute real LaTeX formats, `.cls` and `.sty` code. Replace string rewriting,
template detection and package simulation with native execution over time.
- Do not introduce v1 fallback or new template-specific placement rules.
Existing special cases are migration debt, not accepted general algorithms.
- Independent verified algorithms, metrics and font assets may be reused through
Route-D-owned interfaces; v1's semantic renderer and VM adapter are not the
new execution architecture. v1 is temporary comparison infrastructure only.
- pdfLaTeX and XeLaTeX compatibility are separate profiles on the same native
Route-D core. Pin format/package/font versions and test unmodified projects.
- Preview, PDF and source mapping consume the same measured page results.
Incremental reuse requires unchanged incoming engine state and dependencies.
Milestones and exit criteria:
1. Define native interfaces and strict capability/oracle accounting. Keep
original templates separate from patched layout-diagnostic fixtures.
2. Math C/D accepted for the current core atom slice (2026-10-31): retain styles and operator policies, store measured geometry,
paint it directly in display and inline math, embed raw CMEX slots and real
7pt/5pt optical masters. Validate actual PDF geometry against fresh TeX output.
3. First native bootstrap slice accepted (2026-10-31); continue native
primitive/profile and mode/list execution to replace textual expansion.
Keep token/state/list differential tests and safe dependency accounting.
4. Build the real font/page/output consumers required to boot the full native
LaTeX format and its input closure, implement native dump/load, and compile
an unmodified minimal article. Format startup depends on those consumers;
they cannot all be postponed until after initialization.
5. Grow complete native class/package/project portability through actual code
execution: fonts/NFSS/shaping, math, pagination/output, alignments/tables,
floats, graphics/PDF, references and multi-pass workflows. Validate original
source and resources, without font substitutions or package simulations.
6. Build stable state/dependency identities alongside core execution; validate
resumable checkpoints, correct invalidation/reuse, cancellation and page
patches against full compilation. Measure kernel cold/warm edit latency and
memory on pinned projects. Migrate all product endpoints and remove v1 and
its exclusive adapters/dependencies only after compatibility and realtime
replacement gates pass. Web changes are not a core-product milestone.
Accepted bounded P1-T1 (2026-11-02): [native sfcode and sentence spacing](NATIVE_SFCODE.md)
implements the scoped code table and actual factor/glue consumers. 256 default/
eight state, 132 exact list and nine raw-slot/timing cases, plus a real PDF gate,
pass. Full workspace: 1204 passed / 0 failed. G1 remains paused; full format
still stops at errorcontextlines (526:1), and realtime checkpoints remain open.
Short-term audit and next implementation goal (2026-11-02): see
[G1: native input contexts and basic diagnostics](NATIVE_SHORT_TERM_GOAL.md).
Forty paired INITEX probes retain three supported controls, 28 undefined-entry
findings, seven explicit unsupported-semantic findings, missing error context
and a new first-showbox blank-line mismatch. Six reference-only context probes
verify negative/zero/positive truncation rules. This audit changes no engine
implementation and does not increase the previous 1200-test acceptance count.
G1 closes real input frames/errorcontextlines, the first diagnostic channel
state, show and showthe, then re-probes untouched LaTeX beyond line 526. Other
short slices (macro scheduling/hooks, quantity expressions, OT1 punctuation/
sfcode, list primitives) and larger font/page goals have explicit dependencies
and separate acceptance. No unsupported feature is registered as a passed flag.
Current immediate work (2026-11-01): the native bootstrap and explicit partial
EtexBootstrap profile are accepted. In addition to owned lazy tokens, scoped
state, macros and typed output, the kernel implements protected definitions
with scanner-specific expansion, unexpanded/detokenize/expanded, numexpr,
extended count/toks registers, chardef, hash-brace macros and more conditional
evaluators. No source rewriting, v1 call or automatic fallback was added.
The job/I/O slice is accepted too: an actual host-local time snapshot, scoped
time/date parameters, real input/output streams, read/readline/ifeof, meaning,
live messages/logging and typed deferred output with an explicit shipout API.
The next quantity slice is accepted: typed mathchardef, real physical inputlineno,
dimen/skip/muskip registers, exact fixed-point units/glue orders/arithmetic,
printing and ifdim. Recursive scanners/expansion fail with bounded diagnostics.
Verification: **1204 tests / 0 failed**, **90 real pdfTeX INITEX token probes**,
**101 dimension/glue comparisons**, **119 paragraph INITEX comparisons**,
**205 box packing INITEX comparisons**, **117 math list/geometry and 88 math break comparisons**,
**12 filesystem byte comparisons**, a
selected/discarded shipout oracle, actual math pack-state oracle, **100 interline
vlist and 64 page-ownership cases**, **58 display vlist / 36 page / 24 quantity-mode-pack
cases**, **2816 font-slot predicates + four font-identifier queries**,
**61 diagnostic and 267 raw-slot/math/discretionary comparisons**, **438 accent
DVI geometry and 28 mutable-hyphen timing cases**, **452 delimiter DVI geometry
cases and 256 default-code/nine state/seven group readbacks**, and seventeen native CLI tests.
The paragraph slice now owns typed parameters, real glyph/glue/discretionary
nodes, integer line breaking, parameter timing and frozen line export. A real
CMR10 10pt PDF gate compares 89 words within 0.02bp; see
[native paragraph state and scope](NATIVE_PARAGRAPHS.md). The [native box slice](NATIVE_BOXES.md)
adds actual hpack/vpackage, modes, box registers and vertical append state, with
a 30-word nested-box PDF gate below 0.02bp. The [native inline math slice](NATIVE_MATH_EXECUTION.md)
now owns math tokens/noads, real family/font state, binary cancellation and actual
mu spacing/binop/rel penalties, including paragraph auto-breaking boundaries and
real internal hpack badness. Its 100-word PDF gate stays below 0.02bp. [Native interline penalties](NATIVE_INTERLINE_PENALTIES.md)
now sum actual interline/club/widow/broken state at par completion and feed the
strict native page consumer; a six-page/14-word gate verifies per-page ownership
and word boxes below 0.02bp. Saturated underfull page cost follows the actual
TeX deplorable rule. [Native display math](NATIVE_DISPLAY_MATH.md) now performs
real mode transitions, display-widow completion, pre/post penalties and normal/
short skips with actual pre-display size, shifted hpack, depth and continuation
state. A three-page/97-word PDF gate stays below 0.02bp. Native pages use actual
glue packaging; the generic builder fires at the first overfull legal/forced
point and chooses the best prior candidate. Math D remains passed: three pages,
y error +0.1035625bp and identical 144dpi formula ink bounds.
Real format startup remains open. The unchanged, SHA-pinned LaTeX2e 2025-11-01
entry passes its original e-TeX guard, writes actual time/date to texsys.aux,
reads it back and passes the source's own equality/directory test. It advances
from time at 168:8 through mathchardef/registers and paragraph parameters to
**526:1, missing errorcontextlines**. Version quantities identify
the explicit target interface; bootstrap coverage is not full conformance.
[Native font diagnostics](NATIVE_FONT_DIAGNOSTICS.md) now consumes tracinglostchars/
tracingonline in actual text, math fetch and discretionary construction, using
real TFM existence and Type1 slots/encodings. Actual iffontchar predicates,
transcript/terminal delivery, fatal PDF protection, all 128 CMR10 OT1 slot
rasters and a 25-word PDF gate pass. [Native font integer state and accents](NATIVE_FONT_STATE_ACCENTS.md)
now consume defaultskewchar on real first loads, mutable global skewchar in
actual mathaccent placement, and hyphenchar at real construction stages. Raw
font identity is independent of integers and repeated loads reuse state.
A 54-word PDF gate and full-accent ink gate pass. [Native delimiters](NATIVE_DELIMITERS.md)
now execute scoped delcodes, real delimiter/left/right fields and two-pass
delimiterfactor/delimitershortfall sizing, actual family searches, TFM variants
and extensible component assembly. A 61-word PDF gate and full-delimiter ink
gate pass; exact DVI cases also fix generic odd-sp fraction placement/reboxing.
[Native box/list diagnostics](NATIVE_BOX_DIAGNOSTICS.md) now retain original
horizontal nodes, selected paragraph material and named vertical glue, with
real breadth/depth traversal and log/terminal consumers. Four tests add 152
exact INITEX recursive-list cases, 24 paragraph lists and 24 byte-printer cases;
a CLI test verifies actual channels, show status 1 and continued PDF output.
The five-show fixture has one page / 19 words within the unchanged 0.02bp gate.
Compound math/glue diagnostic structure, showlists and full interaction/context
printing remain open; unsupported inspection errors explicitly.
Next preserve actual input/macro expansion context and consume
errorcontextlines in real error/context printing; no unused flag or fabricated
backtrace. Continue untouched format source after independent INITEX oracles.
Do not register unused parameters or substitute requested fonts. Ordinary interline penalties, inline
noads/binop-rel and unnumbered native display transitions are accepted slices;
equation numbers, alignments, display-style operator variants/limits and full
math/font/page conformance remain open. Parameter storage alone remains
insufficient for new coverage. Complete code tables, quantity expressions, font/magnification state,
remaining scanners, modes/lists with deferred shipout, and versioned dump/load.
Do not treat math character constants as painted text or supply demo em/ex/true
unit values. See [native quantity scope](NATIVE_QUANTITIES.md).
The demo CLI rejects pending output whatsits; it does not flush them at EOF.
See [job time and file-stream evidence](NATIVE_JOB_IO.md).
Only the entry file is pinned; the full input/config/font closure is still open.
Font/format fidelity is a separate required gate. The audited PDF text actually
uses Liberation Serif/Mono while the reference uses Nimbus Roman/SFTT1000;
strict native execution supports CMR10 10pt text and ten real CM mathematical
font masters/families. Latin math descriptor metrics use actual TFM masters.
Raw CMR10 OT1 slots now paint their real encoded glyphs; this does not
certify pdfTeX UTF-8 byte-input conformance. Arbitrary resources/sizes, full
encoding/map/VF closure and NFSS remain open. Implement
native font state, TFM/VF/encoding/map resolution and real format macros,
followed by the Unicode shaping profile. Do not extend font-name heuristics
or adjust template spacing to hide these differences. See
[the font/format gap audit](NATIVE_FONT_FORMAT_GAPS.md).
HTTP/project routes still use the transitional Route-D frontend; this slice
has not switched them. Do not stringify native output back into that frontend.
Native snapshots/read keys are not safe incremental reuse proofs by themselves;
input/mode checkpoints, dependency versions, cancellation and glyph source maps
remain required. See [NATIVE_EXECUTION_CORE.md](NATIVE_EXECUTION_CORE.md).
Math coverage and block/unit/display/float debts remain documented native
milestones in [MATH_ENGINE_TEX.md](MATH_ENGINE_TEX.md).
Status: active plan. Baseline commit `4414f27`, 2026-10-23.
Current status and verification evidence: `docs/ROUTE_D_STATUS.md`.
@@ -17,8 +226,8 @@ Build the typesetting engine the project actually needs:
- it stays **incremental in the Typst sense**: an edit replays from the nearest
page checkpoint and only the pages whose rendered content changed are
repainted;
- it is the **default engine** of the texrra web service, with the v1 semantic
pipeline kept as a fallback until the route-D corpus passes.
- it is the **sole target product engine** of the texrra web service; v1 is
retained only during migration for comparison and will be removed.
Explicit non-goals for the first complete release: