Skip to content

WIP: tex-boxes (KC-107, paused) - #92

Merged
jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/tex-boxes
Sep 13, 2026
Merged

jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/tex-boxes

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

KC-107 is paused to save plan usage. Everything is in the new crate crates/tex-boxes; nothing outside it was changed.

Done (commit 4afd56f)

  • scaled.rs: scaled-point arithmetic from tex.web §§99–109 (round_decimals, print_scaled, xn_over_d, nx_plus_y) and unit conversion (§§453–458).
  • node.rs: the node model. Covers char/ligature (opaque metrics trait), boxes, rules with running dimensions, glue at all four orders with zero_glue tracking, kerns, margin kerns, penalties, math, disc, whatsit, mark, insert and adjust nodes.
  • pack.rs: badness (§108), hpack and vpackage (§§649–678). Over/underfull/tight/loose reports reproduce TeX's transcript text, including the overfull rule and adjust_tail.
  • display.rs: show_box and short_display (§§173–198), with a printer that tracks file_offset so line breaks in the log come out the same.
  • shipout.rs: positions from hlist_out/vlist_out (§§619–637), including the accumulated cur_g/cur_glue rounding and a/c/x leaders.
  • engine.rs: a primitive-level box engine. It has TeX's nest, save stack, eq_define/geq_define for box and other registers, box contexts (setbox, shift, shipout, leaders), \vtop (§1087), \boxmaxdepth, \lastbox, un-box commands, \unskip/\unkern/\unpenalty, \wd/\ht/\dp, append_to_vlist, \vadjust, a minimal \vcenter, a LineBreaker hook (single-line default) and a PageBuilder hook.
  • latex.rs: the box commands as defined in latex.ltx (line numbers cited). Covers mbox, makebox, framebox, fbox, raisebox, parbox, minipage, rule, hspace(), vspace(), strut, the phantoms, smash, llap/rlap/clap, centering/raggedright/raggedleft, sbox/savebox/usebox, settowidth/height/depth and lrbox.
  • Oracle files in tests/oracle/:
    • generate.py runs pdflatex and captures \showbox, log diagnostics and \pdfsavepos positions.
    • fixtures.txt has 151 fixtures, 92 of them with position markers.
    • expected.txt is generated output.
  • Test harness: tests/oracle.rs plus the DSL interpreter in tests/dsl/mod.rs.

Oracle status

  • Not compared yet. The oracle test has never been compiled or run.
  • The lib compiles. Its unit tests (print_scaled, units, badness, strut factor) were re-run after the fix but the result was not seen; one strut value (550500sp) was already confirmed by pdfTeX.
  • Parameters confirmed from the oracle run: strut 550500/235932sp, baselineskip 12pt, fboxsep 3pt, fboxrule 0.4pt, hfuzz 6554sp.
  • axisheight in expected.txt is 0, because math fonts weren't loaded when it was written. generate.py is already fixed but was not re-run.
  • About 19 fixtures hit ! Missing } inserted. in pdflatex. Their expected data is not trustworthy. Likely causes: \vspace*/\hrule in horizontal mode, or a \vtop/\vbox fixture body; start from log lines around 3024–4249.
  • Whether pdfTeX stores the glue ratio as a double is still unconfirmed; the long-glue fixtures (g_*) will show it.

Next steps to resume

  1. cd crates/tex-boxes && CARGO_BUILD_JOBS=2 cargo test and fix compile errors in tests/dsl/mod.rs and tests/oracle.rs.
  2. python3 tests/oracle/generate.py --keep, then grep -n '^! ' <kept dir>/oracle.log | grep -v OK. Fix or remove fixtures that raise TeX errors until the log has none, then regenerate.
  3. Work through mismatches by category: dims, badness, showbox, diagnostics (also check the LaTeX warning layout against the log), positions.
  4. Write CONTRACT.md: how compiler/render-pipeline adopt the crate, how KC-101 drives BoxEngine, how KC-106 plugs in via PageBuilder, and how KC-102 plugs in via LineBreaker and the expansion hook.
  5. Post a checkpoint comment on issue FT-003: dispatch to mac-claude-a — acknowledgement required #2 and mark the PR ready once it's green.

🤖 Generated with Claude Code

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
@GoKubar GoKubar mentioned this pull request Sep 13, 2026
@GoKubar

GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #93 (branch agent/kabir-claude/tex-boxes-r2 @ e68100a). The oracle log now has no TeX errors. All 151 fixtures match pdflatex on dims, badness, showbox and diagnostics, and all 92 position fixtures match to the sp. CONTRACT.md is added. Leaving this PR open for reference.

@jay3332
jay3332 merged commit 4afd56f into main Sep 13, 2026
14 of 18 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/tex-boxes branch September 13, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants