Skip to content

proof: span the closing QED mark at \end instead of covering it (#852) - #862

Merged
d-q222 merged 3 commits into
mainfrom
muse/list-underspacing
Sep 18, 2026
Merged

d-q222 merged 3 commits into
mainfrom
muse/list-underspacing

Conversation

@d-q222

@d-q222 d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #852, and the root cause is not where the issue guessed.

Background

Re-pinning past the TAB catcode fix corrected four documents' page counts and pushed two others (set6, set9) one page short — they had been accidentally correct, with the old tab bug padding out a genuine under-spacing. #852 asked for the real boundary.

The actual cause — not list spacing at all

The lane measured per-boundary baseline gaps against live pdflatex rather than counting pages, as asked, and found:

the generated proof-closing QED mark carried the \end{proof} command span, so the source gap after a proof block no longer contained \end{proof}. The pipeline's vertical-mode scan (gap_has_trivlist_end) therefore missed it, and every list directly after a proof lost its \partopsep.

So this was never about \topsep/\itemsep tuning. A span boundary was swallowing the \end token that a downstream scan keys on.

The fix

crates/compiler/src/parser.rs: the QED Text is now spanned (empty) at the \end command start; the \hfill retains the \end span so edits there still overlap the block. Covers the other edge (head at \begin) and the empty-proof case.

Tests

Authentic pre-fix failure confirmed by stashing the fix: test result: FAILED. 0 passed; 1 failed. Post-fix: ok. 1 passed. Full crates/compiler suite: 86 binaries ok, 0 failed.

Oracle /Library/TeX/texbin/pdflatex, pdfTeX 1.40.29, TeX Live 2026; runs bounded with perl -e 'alarm N; exec @ARGV' (timeout does not exist on this machine); pages via pdfinfo, never mdls. amsthm confirmed loaded via proof \topsep traces rather than assumed.

Housekeeping

Merged origin/main (f189d339) before publishing — the lane branched earlier and its raw diff would have deleted 557 lines of the KOMA class-geometry work. The publish gate refused it automatically and named the files.

⚠️ Lands in crates/compiler, so it does not reach users until vendor/compiler is re-pinned (15 commits behind, per scripts/check-vendor-pins.sh).

Implemented by a sandboxed Muse lane; reviewed and published by the Commander.

🤖 Generated with Claude Code

The generated closing QED mark carried the \end{proof} command span,
so a proof block's last span ended past its \end. The render pipeline
reads the source gap after each block to tell whether a following
\begin{<list>} was read in vertical mode (which carries \partopsep at
the list open, kept for its close); the covered \end hid it, and every
list directly after a proof lost \partopsep at both boundaries
(~2bp at 10pt, ~3bp at 11pt, measured against live pdflatex).

The mark is now spanned (empty) at the \end command: the gap ahead
still holds \end{proof}, which the pipeline already recognises via
theorem_envs. The \hfill keeps the \end span, so edits there still
overlap the block. Adds a regression test pinning the QED span, the
head span at \begin (other edge), and the empty-proof case.

This fix lands compiler-side of the frozen render-pipeline/vendor
snapshots; it reaches output on the Commander's next re-pin. No
pipeline change is needed: the gap-scan consumer logic is already in
crates/render-pipeline/src/adapter.rs (gap_has_trivlist_end,
list_vmode_by_depth).

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor

@jay3332 jay3332 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mac-claude-a verification: Small, well-scoped diff: crates/compiler/src/parser.rs spans the generated QED mark at \end's start (empty span) instead of covering it, plus an 86-line new test. crates/compiler full suite: 0 failed across all binaries; amsthm.rs specifically: 32/32 passed including the new proof_qed_span_leaves_endproof_in_the_gap_after_the_block, which checks both edges (head still opens at \begin{proof}, \hfill still covers \end{proof}) plus the QED span ending at-or-before \end{proof} with only whitespace in the gap, for both a body proof and the empty-proof case. I did not independently re-verify the PR's "stashing the fix produces 0 passed; 1 failed" claim (would require editing the worktree), so that specific negative-control claim is taken on trust rather than reproduced.

Confirmed the PR's own stated caveat is real and current: crates/render-pipeline/vendor/compiler/PIN on main is 23 commits behind crates/compiler HEAD as of now (PR said 15 when written — vendor has drifted further since). So merging this PR alone does not change render-pipeline's behavior until a vendor re-pin lands; the fix is inert to users until then, exactly as the PR discloses.

Diff is minimal, touches no vendor files, adds no unwrap/expect, and doesn't change any pre-existing test's expected value (only adds a new test). No blockers found.

@jay3332

jay3332 commented Sep 18, 2026

Copy link
Copy Markdown
Member

mac-claude-a verification (comment only): at 67391592, cargo test --no-fail-fast in crates/compiler → 87 binaries ok, 1076 tests, 0 failed; --test amsthm 32/32 incl. the new proof_qed_span_leaves_endproof_in_the_gap_after_the_block. Diff is exactly as described (parser.rs:6976-6994, zero-width qed_span for the ∎, \hfill keeps the full \end span); no vendor files, no data-path unwraps, no changed expectations.

Reaches users: not until re-pin — render-pipeline/vendor/compiler/PIN = 4511166e is an ancestor of 4a77aede, so set6/set9 page counts can't be reproduced from this PR alone (matches the PR's own note). Consumer mechanism checks out: gap_has_trivlist_end (adapter.rs:5732) rfind_command(gap, "end") with proof in theorem_envs (adapter.rs:6405) will match the \end{proof} left in the gap. Only theoretical risk: an empty-text span at span.start is a new Inline::Text shape; nothing in the suite trips on it. No blockers.

@d-q222
d-q222 merged commit bbf358c into main Sep 18, 2026
20 of 22 checks passed
jay3332 added a commit that referenced this pull request Sep 18, 2026
…idth span

Since compiler 4a77aed the U+220E text after \end{proof} carries an
empty span at the \end's start while the fill keeps the whole \end
span, so the equal-span test no longer identified the pair and the
proof ended with a missing-glyph warning instead of \openbox's rules.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
jay3332 added a commit that referenced this pull request Sep 18, 2026
…idth span

Since compiler 4a77aed the U+220E text after \end{proof} carries an
empty span at the \end's start while the fill keeps the whole \end
span, so the equal-span test no longer identified the pair and the
proof ended with a missing-glyph warning instead of \openbox's rules.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
jay3332 added a commit that referenced this pull request Sep 18, 2026
…idth span

Since compiler 4a77aed the U+220E text after \end{proof} carries an
empty span at the \end's start while the fill keeps the whole \end
span, so the equal-span test no longer identified the pair and the
proof ended with a missing-glyph warning instead of \openbox's rules.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
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