Skip to content

compiler: accept \paragraph/\subparagraph instead of erroring on them (vendor re-pin required) - #407

Closed
GoKubar wants to merge 1 commit into
mainfrom
lane/nixos-gfxsec/compiler-paragraph
Closed

GoKubar wants to merge 1 commit into
mainfrom
lane/nixos-gfxsec/compiler-paragraph

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What

\paragraph and \subparagraph raised \paragraph is not supported by this compiler version. That diagnostic is stale: they are \@startsection with a negative after-skip (article.cls 406-414), and \@xsect's negative branch never sets the head as a block of its own — it arms \everypar, throws away the following paragraph's \parindent box and sets the head into that paragraph's first line instead. The render pipeline lays them out correctly from the source (#404), so the error reports a gap that no longer exists.

The right thing for this layer is to take the star and the optional short title and then get out of the way: the braced title falls through to the main token loop as ordinary body text, which is exactly the material LaTeX runs into the following paragraph, in the right place and with the right spans. flush_paragraph is deliberately not called, for the same reason — a run-in head does not start a new paragraph.

No geometry changes

Measured on the 22-document real-world corpus with the vendored compiler patched to this change (local only, never committed), against the same build without it:

without with
dx 85.17% 85.17%
dy 65.74% 65.74%
both 59.46% 59.46%
aligned words 14002 14002
page counts 20/22 20/22

Identical to the last word. What changes is that fixtures/real-world/ps-calculus no longer reports four unsupported_feature errors, and a probe of all three forms reports none at all.

Vendor re-pin required

crates/render-pipeline/vendor/compiler is a frozen snapshot (e44d5917) and is deliberately not touched here — git diff --name-only -- crates/render-pipeline/vendor is empty. For the rendered corpus and the Mac shell's Problems panel to see this, vendor/compiler must be re-pinned to a main that contains it, in its own PR.

The pipeline side (#404) needs no re-pin and does not depend on this one: it reads the command back from the source, so it produces correct geometry against the existing pin either way. The two can merge in either order — verified by building the merge of both branches with the vendored compiler patched: no diagnostics, and all 36 words of the three-form probe within 0.01 bp of pdflatex.

Scope note

\paragraph*[short]{...} is left alone. \@startsection's starred form takes no optional argument, and pdflatex itself typesets the brackets there — it sets [Short]Solution. — so there is no oracle behaviour to match. The test says so explicitly rather than pinning our own guess.

Inventory

Both commands move out of KNOWN_UNIMPLEMENTED_COMMANDS into BUILT_INS and the supported-LaTeX inventory. Generated artefacts regenerated with crates/compiler/scripts/render_supported_latex.sh:

  • docs/user/compiler.md
  • crates/compiler/supported/supported-latex.json
  • crates/compiler/supported/coverage.md

Gates

cargo test --release --no-fail-fast on crates/compiler: 583 passed, 0 failed, 4 ignored (was 577 — the new run_in_headings_are_accepted_and_keep_their_title_as_body_text test plus the two doc/inventory drift gates).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…them

`\paragraph` and `\subparagraph` raised `\paragraph is not supported by
this compiler version`. That diagnostic is stale: they are `\@startsection`
with a *negative* after-skip (article.cls 406-414), and `\@xsect`'s
negative branch never sets the head as a block of its own — it arms
`\everypar`, throws away the following paragraph's `\parindent` box and
sets the head into that paragraph's first line instead. The render pipeline
lays them out correctly from the source, so the error was reporting a gap
that no longer exists.

The right thing for this layer is therefore to take the star and the
optional short title and then get out of the way: the braced title falls
through to the main token loop as ordinary body text, which is exactly the
material LaTeX runs into the following paragraph, in the right place and
with the right spans. `flush_paragraph` is deliberately not called, for the
same reason — a run-in head does not start a new paragraph.

**No geometry changes.** Measured on the 22-document real-world corpus with
the vendored compiler patched to this change (local only; never committed):
dx 85.17%, dy 65.74%, both 59.46%, 14002 aligned words, page counts 20/22 —
identical to the same build without it, to the last word. What changes is
that `fixtures/real-world/ps-calculus` no longer reports four
`unsupported_feature` errors, and a probe of all three forms reports none.

`\paragraph*[short]{...}` is left alone: `\@startsection`'s starred form
takes no optional argument, and pdflatex itself typesets the brackets there
(`[Short]Solution.`), so there is no oracle behaviour to match.

Inventory: both commands move out of `KNOWN_UNIMPLEMENTED_COMMANDS` into
`BUILT_INS` and the supported-LaTeX inventory; the generated artefacts
(`docs/user/compiler.md`, `supported/supported-latex.json`,
`supported/coverage.md`) are regenerated with
`crates/compiler/scripts/render_supported_latex.sh`.

**A vendor re-pin is required** for the rendered corpus to see this:
`crates/render-pipeline/vendor/compiler` is a frozen snapshot (`e44d5917`)
and is deliberately not touched here. The pipeline side of this feature is
a separate PR and needs no re-pin — it reads the command back from the
source, so it works against the existing pin either way.

`cargo test --release --no-fail-fast` on crates/compiler: 583 passed, 0
failed, 4 ignored (was 577; the new `run_in_headings_are_accepted_...`
test plus the two doc/inventory gates).

Implementation-Agent: Claude Opus 5 (lane nixos-graphics-sectioning, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (e9b0e256); clean rebase, no conflicts — nothing merged since touches this. cargo test --release --no-fail-fast on crates/compiler: 583 passed, 0 failed, 4 ignored, unchanged.

Still no geometry effect, which is the whole point of it: it retires a stale unsupported_feature error, and the pipeline side (#404) is what lays the heads out. The vendor re-pin note in the body stands — crates/render-pipeline/vendor/compiler is untouched here (git diff --name-only -- crates/render-pipeline/vendor is empty), so the rendered corpus and the Mac Problems panel only stop seeing the error once vendor/compiler is re-pinned to a main containing this.

@GoKubar
GoKubar force-pushed the lane/nixos-gfxsec/compiler-paragraph branch from ac2f332 to 0c25485 Compare September 14, 2026 16:40
@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Confirming the re-pin point, since you asked: it is already in the PR body under "Vendor re-pin required", and it still holds on the rebased branch.

git diff --name-only origin/main...HEAD is exactly six files, none of them vendored:

crates/compiler/src/parser.rs
crates/compiler/src/supported.rs
crates/compiler/src/vocabulary.rs
crates/compiler/supported/coverage.md
crates/compiler/supported/supported-latex.json
docs/user/compiler.md

git diff --name-only origin/main...HEAD -- crates/render-pipeline/vendor is empty. vendor/compiler stays pinned at e44d5917; until it is re-pinned to a main containing this commit, neither the rendered corpus nor the Mac Problems panel stops seeing \paragraph is not supported by this compiler version. That re-pin is not mine to make here and I have not made it.

The only place I touched a vendored file was to measure — I patched vendor/compiler in the working tree, took the numbers, then git checkout -- reverted it. That is why the body says "local only, never committed"; the six files above are the whole commit.

For the record, the merge order is free: #404 reads the command back from the source, so it renders \paragraph correctly against the existing pin whether or not this has landed, and this one is a no-op for geometry either way.

@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #474, this branch rebased onto current main with two fixes.

  1. This PR's bundled inventory matches the compiler check was failing. It regenerated crates/compiler/supported/{supported-latex.json,coverage.md} and docs/user/compiler.md but not the Mac app's bundled copy, so merging it as-is would have turned that gate red on main. compiler: accept \paragraph/\subparagraph instead of erroring on them (rebase of #407, + inventory sync and duplicate-attribute fixes) #474 regenerates all four artefacts with crates/compiler/scripts/render_supported_latex.sh, which since compiler: sync Mac bundled inventory at the end of render_supported_latex.sh #408 also runs apps/mac/scripts/sync-supported-latex.sh.

  2. The new test in parser.rs carried a duplicated #[test] attribute — rustc accepts it with a duplicate_macro_attributes warning and runs the test twice. Removed.

On the title's re-pin note: still accurate. crates/render-pipeline/vendor/compiler/PIN is faa7d484 (main's #437, moved there by #451), which predates this change, so the render pipeline keeps erroring on \paragraph until a separate re-pin PR. Landing the compiler side on its own is still worth it — crates/compiler also feeds the flashtex-compiler binary and crates/bridge directly.

Measured on the compiler route, main vs #474: the error goes away, and the star and optional short title stop being typeset (\paragraph*{Solution.} was setting *Solution., \paragraph[Short]{Solution.} was setting [Short]Solution.). The title itself already fell through as body text before the change.

Branch lane/nixos-gfxsec/compiler-paragraph is left in place (not deleted).

@GoKubar GoKubar closed this Sep 14, 2026
GoKubar added a commit that referenced this pull request Sep 14, 2026
Rebase of #407 onto current main, with two fixes it needed.

1. #407 regenerated `crates/compiler/supported/{supported-latex.json,
   coverage.md}` and `docs/user/compiler.md` but not the Mac app's bundled
   copy, so its "bundled inventory matches the compiler" CI check failed and
   merging it as-is would have turned that gate red on main. All four
   artefacts are regenerated here with
   `crates/compiler/scripts/render_supported_latex.sh`, which since #408 also
   runs `apps/mac/scripts/sync-supported-latex.sh`.

2. The new test carried a duplicated `#[test]` attribute, which rustc accepts
   with a `duplicate_macro_attributes` warning and then runs the test twice.
   Removed.

Measured effect on the direct compiler route (`flashtex-compiler`, and
`crates/bridge`, both of which build against `crates/compiler` rather than
the vendor), main vs this branch:

  \paragraph{Solution.} Body text.
    main: recovered, 'Solution.Bodytext.',
          error/unsupported_feature: \paragraph is not supported by this
          compiler version
    this: ok,        'Solution.Bodytext.', no diagnostics

  \paragraph*{Solution.} Body text.
    main: recovered, '*Solution.Bodytext.'   <- the star was typeset
    this: ok,        'Solution.Bodytext.'

  \paragraph[Short]{Solution.} Body text.
    main: recovered, '[Short]Solution.Bodytext.'  <- the short title was typeset
    this: ok,        'Solution.Bodytext.'

So the title already fell through as body text before this change; what
changes is that the spurious error is retired and the star and the optional
short title are consumed as the command parameters they are instead of being
set on the page. `\section` is unaffected.

The vendor re-pin note in #407's title is still accurate:
`crates/render-pipeline/vendor/compiler/PIN` is `faa7d484`, which predates
this change, so the render pipeline keeps erroring on `\paragraph` until a
separate re-pin PR. The pipeline side is already in place on main —
`adapter.rs::run_in_heading_at` and `apply_run_in_heading` read the command
back from the source and give the head its weight, indent and `\hskip 1em`.
This change is the compiler-side prerequisite for that.

Verified on this Linux worktree with the font environment set
(FLASHTEX_FONT_DIRS + FLASHTEX_TFM_DIRS, without which ~110 tests silently
skip and report as passes):

  crates/compiler   644 passed, 0 failed, 5 ignored  (main: 643/0/5)
  crates/bridge     170 passed, 0 failed, 2 ignored  (unchanged)

Implementation-Agent: nixos-gfxsec lane (original PR #407)
Rebased-By: linux-primary integration lane (Claude Code agent af761de6)
Commit-Executor: Claude Code agent af761de6 on linux-primary (direct Git,
  Cursor usage limit fallback per AGENTS.md)
Co-authored-by: GoKubar <[email protected]>
GoKubar added a commit that referenced this pull request Sep 14, 2026
… (rebase of #407, + inventory sync and duplicate-attribute fixes) (#474)

* compiler: accept `\paragraph`/`\subparagraph` instead of erroring on them

`\paragraph` and `\subparagraph` raised `\paragraph is not supported by
this compiler version`. That diagnostic is stale: they are `\@startsection`
with a *negative* after-skip (article.cls 406-414), and `\@xsect`'s
negative branch never sets the head as a block of its own — it arms
`\everypar`, throws away the following paragraph's `\parindent` box and
sets the head into that paragraph's first line instead. The render pipeline
lays them out correctly from the source, so the error was reporting a gap
that no longer exists.

The right thing for this layer is therefore to take the star and the
optional short title and then get out of the way: the braced title falls
through to the main token loop as ordinary body text, which is exactly the
material LaTeX runs into the following paragraph, in the right place and
with the right spans. `flush_paragraph` is deliberately not called, for the
same reason — a run-in head does not start a new paragraph.

**No geometry changes.** Measured on the 22-document real-world corpus with
the vendored compiler patched to this change (local only; never committed):
dx 85.17%, dy 65.74%, both 59.46%, 14002 aligned words, page counts 20/22 —
identical to the same build without it, to the last word. What changes is
that `fixtures/real-world/ps-calculus` no longer reports four
`unsupported_feature` errors, and a probe of all three forms reports none.

`\paragraph*[short]{...}` is left alone: `\@startsection`'s starred form
takes no optional argument, and pdflatex itself typesets the brackets there
(`[Short]Solution.`), so there is no oracle behaviour to match.

Inventory: both commands move out of `KNOWN_UNIMPLEMENTED_COMMANDS` into
`BUILT_INS` and the supported-LaTeX inventory; the generated artefacts
(`docs/user/compiler.md`, `supported/supported-latex.json`,
`supported/coverage.md`) are regenerated with
`crates/compiler/scripts/render_supported_latex.sh`.

**A vendor re-pin is required** for the rendered corpus to see this:
`crates/render-pipeline/vendor/compiler` is a frozen snapshot (`e44d5917`)
and is deliberately not touched here. The pipeline side of this feature is
a separate PR and needs no re-pin — it reads the command back from the
source, so it works against the existing pin either way.

`cargo test --release --no-fail-fast` on crates/compiler: 583 passed, 0
failed, 4 ignored (was 577; the new `run_in_headings_are_accepted_...`
test plus the two doc/inventory gates).

Implementation-Agent: Claude Opus 5 (lane nixos-graphics-sectioning, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)

* compiler: preamble \setlength, \addtolength and TeX length assignments (rebase of #432 onto current main) (#473)

* compiler: preamble \setlength, \addtolength and TeX length assignments

The compiler half of lane #258, split from agent/daniel-parent/preamble-lengths
@ 695dfaa (20 reviewed WIP commits). The render-pipeline half is its own PR.

- \setlength and \addtolength are accepted in the preamble, along with direct
  TeX assignments (\parindent=10pt) to the page and paragraph lengths; plus/minus
  glue is parsed.
- Units use TeX's scan_dimen factors: bp is 1.00375pt (it was treated as pt),
  plus dd, cc and sp; ex uses the cmr x-height.
- An unresolved length reference, including a page length such as
  \setlength{\textwidth}{\paperwidth}, warns instead of being silently dropped.
- The inventory is regenerated; both supported-latex.json copies are byte-identical.

What was run (CARGO_TARGET_DIR=target-prelen): cargo test --manifest-path crates/compiler/Cargo.toml
test result: ok. 327 passed; 0 failed; 0 ignored  (lib)
test result: ok. 10 passed; 0 failed; 0 ignored   (preamble_lengths)
All other test binaries ok, 0 failed.

Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast (lane commits ae37132..695dfaa)
Commit-Executor: daniel-parent (split into compiler and pipeline PRs)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

* wip(#432): keep user-defined skip registers out of parser addtolength

HOST_PRELUDE no longer undefines \setlength/\addtolength. When the target
is already defined (\newlength skip), the kernel assignment/\advance runs
so \the can read it back. Undefined preamble lengths still pass through
as host commands mapped back to \setlength/\addtolength with the full
csname. \parindent TeX assignment and \addtolength are silent in the
preamble; \setlength{\parindent}{nonzero} still warns.

Ran: cargo test --manifest-path crates/compiler/Cargo.toml --test
kernel_untested_a addtolength
  before: FAILED 0 passed; 1 failed (Missing number; \addtolength{\\})
  after:  ok. 1 passed; 0 failed; 0 ignored; 0 measured; 20 filtered out
  cargo test --test preamble_lengths
  test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Next: full compiler crate tests and render-pipeline --lib.

Open questions: none.

Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast
Commit-Executor: cursor-agent (direct git commit)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Co-authored-by: Cursor <[email protected]>

* wip(#432): full compiler crate and render-pipeline lib green

ASCII-only wording in the HOST_PRELUDE comment. No behaviour change.

Ran: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-prelen
  cargo test --manifest-path crates/compiler/Cargo.toml
    every test result: ok (lib: 331 passed; 0 failed;
    kernel_untested_a: 20 passed; 0 failed; 1 ignored)
  cargo test --manifest-path crates/render-pipeline/Cargo.toml --lib
    test result: ok. 121 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out

Next: push this lane branch. No remaining acceptance gaps.

Open questions: none.

Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast
Commit-Executor: cursor-agent (direct git commit)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: d-q222 <[email protected]>
Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: d-q222 <[email protected]>
Co-authored-by: Cursor <[email protected]>
@GoKubar
GoKubar deleted the lane/nixos-gfxsec/compiler-paragraph 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