Repository navigation
Conversation
New crate crates/tex-expansion implementing catcodes+tokenizer, def/edef/gdef/xdef/let/futurelet, expandafter/noexpand/csname, TeX and e-TeX conditionals (if/ifx/ifnum/ifdim/ifodd/ifcase/newif/unless), grouping with global/aftergroup, count/dimen/skip/toks registers with countdef family and numexpr/dimexpr, and a LaTeX layer (newcommand/renewcommand/provide, newenvironment, counters, @ifnextchar/@ifstar/@namedef/@nameuse). 45 unit tests passing. Implementation-Agent: Claude Fable 5.1 (subagent kabir-claude KC-101, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Fable 5.1 <[email protected]>
Why: every glyph's position depends on the class/geometry page frame; render-pipeline only models article + margin= in floating point. Behavior: - New standalone crate crates/class-geometry (zero deps). TeX integer arithmetic (round_decimals, xn_over_d, \divide, \@settopoint, print_scaled) so lengths match pdflatex to the scaled point. - article/report/book x 10/11/12pt x a4/a5/b5/letter/legal/executive, landscape, oneside/twoside, onecolumn/twocolumn, titlepage, openright/ openany, fleqn/leqno, draft (size1x.clo + bk1x.clo, cited by line). - geometry v6.0 macro-by-macro: keys, \Gm@detall cases 0-7, adjustbody/ adjustmp, includehead/foot/mp, ratios, scale, lines, heightrounded, bindingoffset, landscape/paper keys, sequential \geometry calls. - PageFrame: odd/even text left, head/foot/first baselines, columns, marginpar side, PDF MediaBox (engine default letter without geometry). - \@startsection specs, \chapter/\chapter*/\part, secnumdepth/tocdepth, page styles (empty/plain/headings/myheadings) and mark rules. - DocumentSetup::from_preamble scanner; CONTRACT.md proposes the render-pipeline integration (render-pipeline not edited). Oracle: oracle/generate.py (pdflatex 1.40.29, TeX Live 2026, oracle only) -> tests/data/oracle.txt, 96 fixtures; cargo test: 96/96 fixtures, 2881/2881 lengths exact, 2112/2112 \pdfsavepos positions exact (0sp). Validation: cargo test, cargo clippy --all-targets (0 warnings), cargo fmt. Excluded (other branches): \maketitle/title layout, page-control commands, list spacing. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-103, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
New crate crates/microtype (no dependencies, never runs TeX): - config: parses microtype.cfg / mt-cmr.cfg (bundled unmodified, LPPL) and resolves per NFSS font the \lpcode/\rpcode/\efcode tables and \pdffontexpand limits exactly as microtype v3.2d does (font sets, list lookup order with family aliases, load= chains, T1 inheritance, \MT@scale rounding). Verified slot-for-slot against pdfTeX dumps for 96 fonts. - pdftex: protrusion (char_pw), char/kern stretch and shrink, the try_break shortfall rule, hpack's cal_expand_ratio and per-glyph expansion, transcribed from pdftex.web 1.40.27 and utils.c. - arith: pdfTeX/e-TeX integer arithmetic. - tests/common: reference pdfTeX line_break + post_line_break + hpack. - tests/oracle: 32 pdflatex fixtures (EC and Latin Modern, 10/11/12pt, none/protrusion/expansion/both). All 32: identical breaks, identical per-glyph expansion, identical margin kerns, glyph x error <= 0.00018pt. MT_MUTATE switches show each pdfTeX rule is needed. - CONTRACT.md: proposed hooks for paragraph-layout and render-pipeline, and the HW1/HW2 with/without-microtype delta (HW1: no break changes; HW2: two paragraphs reflow, 80 -> 79 lines). Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-102, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…orpus
Fixes found via a 108-case oracle corpus run against real tex/etex/pdflatex:
bare grouping braces must not appear in the content-token stream (matches
real main-control semantics, not \write's scan_toks semantics); \the\dimen
must render via TeX's print_scaled algorithm, not raw sp; \numexpr division
rounds to nearest (ties away from zero); \ifcase must keep skipping on a
negative selector; \setcounter/\addtocounter values may contain expandable
constructs like \value{...}; \count's "..." hex parsing.
Adds tests/oracle/ (generator script + committed manifest.json + expected
fixtures, gitignored tmp/) and CONTRACT.md proposing the crates/compiler
adoption path, known deviations from real TeX, and what's done vs not.
47 unit tests + 108/108 oracle cases green.
Implementation-Agent: Claude Fable 5.1 (subagent kabir-claude KC-101, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Fable 5.1 <[email protected]>
… and space factor (KC-105) New crate modelling UTF-8 input (.dfu tables), OT1/T1/TS1/OMS/OML text commands and composites, NFSS cmr/lmr font selection and glyph names, exact TFM scaling, the TeX main-loop lig/kern algorithm, \accent positioning and LaTeX space factor. A pdflatex oracle (177 fixtures x 5 preambles = 885 cases) replays 885/885 in cargo test: exact node lists, kerns, glue and box dimensions in sp; glyph positions within 0.0049pt. CONTRACT.md holds the adoption proposal; no other crate is touched. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-105, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
… (KC-106) New crate crates/page-builder: append_to_vlist (§679), paragraph and display penalties (§890, §1203-1205), vert_break/vsplit (§967-979), the page builder with insertions and \tracingpages (§980-1028), \end (§1054), and LaTeX \pagebreak/\nopagebreak/\newpage/\clearpage/ \enlargethispage plus \@makecol/\@doclearpage (latex.ltx 2026, footnotes-floats-legacy plug). pdflatex oracle (oracle/gen.py, cargo tests never run TeX): 61 fixtures, 338 pages, 11718 lines replayed from captured main vertical lists; all \tracingpages lines, output penalties and box255 contents identical, max baseline deviation 0.00021pt. CONTRACT.md proposes adoption in render-pipeline. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-106, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
New crate crates/tex-boxes: scaled arithmetic and units (tex.web 99-109, 453-458), node model, badness/hpack/vpackage with exact over/underfull report text (108, 644-678), show_box/short_display (173-198), shipout positions with cur_g/cur_glue rounding and leaders (619-637), a primitive box engine (nest, save stack, box contexts, vtop, lastbox, unpackage, vcenter, single-line paragraph hook), and the latex.ltx box layer (makebox/framebox/fbox/raisebox/parbox/minipage/rule/hspace/vspace/ phantom/smash/laps/savebox/settodim/lrbox). Oracle generator, 151 fixtures and generated expected.txt; DSL-driven oracle test not yet run. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-107, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
- generate.py: expand nested <<N*...>> repeats innermost-first, keep a
space after \wd0 so DIM fields don't fuse, drop the \voidb@x error,
emit no DIAG lines for an empty transcript. pdflatex log now has no
TeX errors; axisheight regenerated (163840sp).
- DSL: nested repeats, simple {..} groups inside box bodies.
- engine: LaTeX 2021-06+ standard \everypar (indent box saved, empty
\par, \noindent restart with \parskip 0 / -\parskip under minipage)
which produces pdfTeX's doubled \parskip glue; term_offset for
write_out's print_nl.
- scaled: .3\baselineskip = 235932sp (round_decimals 19661).
Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-107 r2, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
… r2) write_out's print_nl breaks the line when the terminal is mid-line. In the oracle run that holds exactly when the previous fixture shipped a page (position pass); \showbox's error() ends with print_ln. Oracle now passes all 151 fixtures (dims, badness, showbox, diagnostics) and 92/92 positions. Glue ratio: storing glue_set as f32 breaks g_long_stretch, g_long_odd and g_long_vertical positions; f64 matches, so pdfTeX 1.40.29 uses double. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-107 r2, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]>
… r2) Documents oracle coverage (151 fixtures exact; 92 positions), the glue ratio (double) and LaTeX para-hook findings, adoption for render-pipeline / compiler, and plug-in points for KC-101 tex-expansion (main-control mapping, register ownership), KC-102 microtype (LineBreaker, margin kerns; expansion hook is a stub) and KC-106 page-builder (PageBuilder, module de-duplication). Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-107 r2, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]>
…' into agent/kabir-claude/engine-poc
… into agent/kabir-claude/engine-poc
… into agent/kabir-claude/engine-poc
…y' into agent/kabir-claude/engine-poc
…to agent/kabir-claude/engine-poc
…ents' into agent/kabir-claude/engine-poc
…builder/class-geometry (KC-110, paused) Not yet compiled: fonts (TFM + OT1 cmr NFSS), Knuth-Plass line_break port over tex-boxes nodes with Liang hyphenation, stomach (headings, emph/bf, accents, vspace, pagebreak), page building via page-builder LatexOutput, glyph JSON via tex-boxes ship_out. No oracle yet. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-110, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]>
GoKubar
added a commit
that referenced
this pull request
Sep 13, 2026
…sion Grouping braces (explicit and implicit \bgroup/\egroup) and \begingroup/\endgroup are now emitted in the output stream with their source spans (coordinator request from KC-110/PR #96); \aftergroup tokens follow the closing brace. API-compatible: is_group_token() added for consumers that want content only. Nested expansion (edef bodies, macro calls) now counts toward max_expansion_steps, fixing a hang found by the incremental random-edit test; finished token lists are popped before pushing so tail recursion does not grow the input stack. Tests: 52 unit, 3 incremental equivalence, 415/415 oracle. Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-101 r2, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 13, 2026
Merged
Contributor
Author
|
Closing as obsolete. This draft is a merge aggregation of #88, #93, #90, #85 and #86 plus an uncompiled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status: WIP, paused for usage (KC-110). Nothing has been compiled or oracle-checked in
crates/tex-engine-pocyet.Merges done (merge commits, no conflicts)
agent/kabir-claude/tex-expansion(tex-expansion: TeX/e-TeX/LaTeX macro expansion engine (KC-101) #88). Used tex-expansion: TeX/e-TeX/LaTeX macro expansion engine (KC-101) #88, not the r2 branch:tex-expansion-fable-r2only has a paused WIP commit.agent/kabir-claude/tex-boxes-r2(tex-boxes (KC-107) #93)agent/kabir-claude/page-builder(page-builder: TeX vertical lists, page builder and LaTeX output model (KC-106) #90)agent/kabir-claude/class-geometry(class-geometry: exact standard-class + geometry page frame (KC-103) #85)agent/kabir-claude/microtype(KC-102: pdfTeX microtype model (protrusion + font expansion) #86)agent/kabir-claude/encodings-accents(KC-105: tex-text-encoding — pdfTeX input/font encodings, text accents, symbols, space factor #89,tex-text-encoding)hyphenation-r1is already in origin/main (crates/paragraph-layout/src/liang.rs). It is used via a path dependency and nothing is copied.What exists (8d24313, not compiled)
src/fonts.rs: TFM loading. It uses tex-text-encodingScaledFont, looks in the committedtfm/copies first, then kpsewhich. It also has the OT1 cmr NFSS table from ot1cmr.fd and implements the tex-boxesCharMetricstrait.src/linebreak.rs: a port of tex.web line breaking in integer sp over tex-boxes nodes.line_breakwith delta offsets.post_line_break, packing lines with tex-boxeshpack.src/stomach.rs: the main control.lig_kern_run,sfcodeandmake_accent.\section/\subsection/\subsubsectionper latex.ltx\@startsection/\@sect/\@xsect/\@afterheading, with specs from class-geometry.\emph/\textbf/\textitwith\maybe@ic,\\,~,\vspace(*),\pagebreak[n],\newpage,\clearpage.VListBuilderfeedingPageBuilder+LatexOutput, then tex-boxesship_outfor glyph positions plus the plain page-number footer.src/bin/ftpoc.rs: prints glyph JSON;--benchtimes a cold run and a one-word-edit re-run.Verified so far
examples/dump_tokens.rsran).tex-text-encoding/tools/generate_oracle.pypage_glyphs).Seams found so far (proposals, no shared crate edited)
\vspace{12pt} Text) and{\bfseries ...}scopes are invisible to a stomach. Fix: emitBeginGroup/EndGrouptokens, or a callback. The PoC works around it with marker macros.LineBreakerdoes not receive\hangindent,\interlinepenalty,\clubpenaltyorprev_graf. Fix: addappend_nodeand pass a paragraph-parameters struct toLineBreaker.Node/BoxNode/GlueSpec(withGlueOrder) and page-builderNode/BoxNode{id}/GlueSpec(withOrder) duplicate scaled/pack/vpack. Fix: page-builder depends on tex-boxes, as the tex-boxes CONTRACT already proposes.Sp(i64)andGluewith no orders; the others usei32sp. tex-text-encoding has its ownsfcode::GlueSpecandlayout::Node. Fix: a sharedtex-unitscrate.line_breakover tex-boxes nodes.addvspace/addpenaltyand BoxEngine's LaTeX para hooks are both unverified by their own oracles and model the same kernel code twice.hpack, so microtype is not wired.Resume steps
export CARGO_BUILD_JOBS=3; cargo build --manifest-path crates/tex-engine-poc/Cargo.tomland fix compile errors.cargo run --bin ftpoc -- s1.texon a sample and compare it withpdflatex '\pdfcompresslevel=0\pdfobjcompresslevel=0\input{s1}'glyphs.tools/corpus.py: at least 25 documents (10/11/12pt, a4/letter, geometry, headings, emph, accents,\newcommand). Writetools/oracle.py: PDF glyph extraction toexpected/*.json.tests/oracle.rs: page count, per-line text, glyph x/y within 0.1pt; report pass counts without running TeX.ftpoc --bench; finalize SEAMS.md and README.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu