Skip to content

compiler: algorithm floats, algorithmic and algpseudocode statements - #159

Closed
GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/algorithmic-compiler
Closed

GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/algorithmic-compiler

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Pseudocode packages in the compiler: algorithm (float.sty float), algorithmic, and algpseudocode/algorithmicx.

What

  • New crate::algorithmic: a pure model read from the source bytes, citing package lines (TeX Live 2026 algorithmic.sty, algorithm.sty, algorithmicx.sty, algpseudocode.sty, float.sty).
    • setup(text) reads:
      • package options: plain/ruled/boxed, section resets, float name via \DeclareOption*, noend;
      • keyword renames: \renewcommand{\algorithmicrequire}{..}, \algnewcommand/\algrenewcommand;
      • \algorithmicindent, \alglinenumber, \algsetup{indent,linenodelimiter,linenosize}, \floatname{algorithm};
      • \item[..] label commands such as \algnewcommand\Input{\item[\textbf{Input:}]}.
    • scan(text, doc, setup) finds algorithm floats (placement, caption/label/size/algorithmic items, hmode) and bare algorithmic environments.
    • parse_algorithmic turns each statement into a Line:
      • item kind: numbered, \item[label], \Statex, or noend no-text;
      • line counter and printed-number flag for [n];
      • block depth;
      • algpseudocode's \hskip\ALG@tlm;
      • pieces: bold keywords (the bold space of \textbf{for all}), control spaces, and source spans for conditions, text and comments. Also \textproc/\Call small caps, algorithmic's \{..\} comments, algpseudocode's \hfill\(\triangleright\) comments, and \RETURN's two spaces.
    • Layout constants: \labelwidth 1.2em/0.5em, \labelsep, \topsep, and the ruled rules and kerns.
  • Parser (parser/algorithmic.rs, small hooks in parser.rs):
    • \begin{algorithmic} becomes one flush-left paragraph per statement (number or label, indent glue, pieces), for the compiler's own layout.
    • algorithm/algorithm* behave like figure, with Algorithm N captions (bold for ruled/boxed, N: for plain) and \label values.
    • \algnewcommand, \algrenewcommand, \algsetup and \floatname are consumed.
    • Package options are silent.
  • Expansion pass: the keyword macros are declared as host commands, so \renewcommand{\algorithmicrequire} is no longer "Command undefined". This is a three-line hook in configure.
  • Inventory: regenerated (supported-latex.json, docs/user/compiler.md). The drift test passes.

Tests

  • 5 unit tests for the package model, plus tests/algorithmic.rs: both dialects parse with no diagnostics, captions, label value, lines, bold keywords, footnotesize numbers, noend.
  • Full cargo test --release in crates/compiler is green, including the HW1/HW2 gates.

Notes

  • The render pipeline PR (draft, follows) lays these out from crate::algorithmic and needs vendor/compiler re-pinned to this PR. Please add both to the re-pin queue.
  • apps/mac's bundled supported-latex.json needs its usual re-sync. apps/ is outside this lane and was not touched.
  • Not modelled, and reported as warnings: \algdef and other custom blocks, algcompatible, and redefined \algorithmiccomment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

New crate::algorithmic reads the pseudocode packages from the source bytes
(algorithmic.sty, algorithm.sty, algorithmicx.sty, algpseudocode.sty and
float.sty lines cited): the preamble setup (package options, keyword
renames through \renewcommand/\algnewcommand/\algrenewcommand, \algsetup,
\floatname, \algorithmicindent, \alglinenumber, \item[..] label commands)
and one Line per statement: item kind (numbered, \item[label], \Statex,
noend no-text), line counter and printed-number flag for [n], block depth,
and pieces (bold keywords with \textbf{for all}'s bold space, control
spaces, source spans of conditions, text and comments, \textproc small
caps, \hfill\(\triangleright\) comments). algorithm floats are scanned into
caption, label, size and algorithmic items.

Parser: each statement of \begin{algorithmic} becomes a flush-left
paragraph (number or label, list indent glue, pieces); algorithm and
algorithm* behave like figure with "Algorithm N" captions and \label
values; the definition commands are consumed; package options are silent;
the expansion pass declares the keyword macros as host commands so
\renewcommand{\algorithmicrequire} is legal.

Inventory regenerated. Tests: 5 model unit tests and tests/algorithmic.rs;
the full compiler suite passes.

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
… inventory

The only conflict was the generated "Supported LaTeX" section of
docs/user/compiler.md: main's version was taken and
scripts/render_supported_latex.sh re-run. The full compiler suite passes
after the merge.

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
Conflicts: parser.rs modules (+ algorithmic), initialisers/fields (main's subequations + #159's algorithm_counter; equation/figure counters stay in xref::Counters per #155), preamble dispatch (hyperref/boxes/counter commands + algnewcommand/algrenewcommand/algsetup/floatname), \caption (algorithm branch before main's figure/table check), float \begin/\end (figure, table, algorithm, algorithm*; #159's stale theorem clause dropped), package matches (listings + algorithm packages); supported.rs TEXT_EXTRA_ARMS and caption/item descriptions (main's item [label]). Integration fix: parser/algorithmic.rs Block::Styled gains #147's lists/line_break_before. Generated docs took main.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, 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
…ession handoff)

Stage 1 partly done: #131, #137, #153 (incl. #142), #144, #147, #149, #150,
#155, #159, #163, #164 merged with conflicts and post-expansion fixes recorded
in docs/evidence/integration-2026-09-13b/merge-log.md. Remaining: #166, #169,
#148, #161, then the inventory regeneration and stages 2-4. The helper scripts
under tools/ hard-code the original worktree path.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, 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
…merges

Every stage 1 merge took main's side of the generated inventory and deferred
the regeneration to the end of the stage. Running
crates/compiler/scripts/render_supported_latex.sh picks up #131, #137, #144,
#147, #149, #150, #153, #155, #159, #163, #164, #166 and #169, so
supported_latex::generated_artifacts_are_current passes again.

The TeX Live-derived canonical denominator is deliberately untouched: this
machine has TeX Live 2025, not the MacTeX the committed file was pinned from.

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
No conflicts: #168 is an oracle and its fixtures, with no pipeline source
changes. The compiler side it needs (siunitx) came in with #159 in stage 1,
so the vendored compiler already satisfies it.

One change was needed. #168 carries a `PENDING` list of fixtures that must
*still* differ from pdfLaTeX, each naming the work it waits on, so the entry
is removed when that work lands. `39-heading.tex` waited on heading math --
"the pipeline sets a `$...$` formula in \section at the heading size but an
Inline::Math whose span starts at a command at the body size". That landed on
this branch with #151, so the fixture now matches and the test failed with
"39-heading.tex now matches: remove it from PENDING", exactly as designed.
Removed; the oracle passes.

siunitx is now 36/39 exact against the committed MacTeX references, up from
the 35/39 the PR reports. The three still pending are unrelated to siunitx
and name their own dependencies: 34-paragraph (math glue stretch in line
justification, PR #148), 37-ang-minutes (`\prime` drawn from Latin Modern
Math at 2.169pt where pdfLaTeX's cmsy7 prime is 2.306pt), 38-power-on-letter
(no upright fam0 Latin math character, so a power on a one-letter unit sits
0.78 bp high).

`cargo test --release` in render-pipeline: the same 11 known failures, no
more. Zero font diagnostics on every gate.

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

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: rebuilt as #194; 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-compiler 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