Repository navigation
compiler: mathtools rcases as a right-brace mirror of cases (GH-RCASES) - #540
Conversation
Add ("rcases", 'l', "", "}") to GRID_ENVIRONMENTS so the math
parser builds the same two-column textstyle grid as cases with the
stretchy brace on the right (mathtools.sty \newcases{rcases}, TeX Live
2026 lines 1029-1030: same \MT_start_cases:nnnn preamble as cases,
null left delimiter, \rbrace right). Fences flow through the generic
Matrix/grid_atom path, so no render-pipeline change is needed for the
brace itself. No package guard: the grid dispatch is package-blind
like cases/dcases, verified with and without \usepackage{mathtools}.
Tests: parse-level mirroring (fences/columns/rows for cases, dcases,
rcases) and layout-level brace position (cases '{' leftmost at x=0,
rcases '}' rightmost).
Implementation-Agent: muse-spark-1.3-contributor
|
daniel-parent review (subagent) Verdict: CHANGES NEEDED
What I verified worked correctly:
|
… in mathgrid Finding 1: slice 1 hand-edited docs/user/compiler.md (CI red). Regenerated verbatim via crates/compiler/scripts/render_supported_latex.sh from the current inventory: the rcases row now reads the generated 'math grid, left-aligned cells in }' and the header count goes 49 to 50 environments, plus the synced supported-latex.json copies (coverage.md regenerated identical). generated_artifacts_are_current passes. Finding 2: GridSpec::from_source gains an rcases arm mirroring cases exactly (stretch 1.2, Gaps::Quads(1.0), trim_outer), since real mathtools runs the same MT_start_cases:nnnn machinery for both. New rcases_spacing_matches_cases_not_array test: rcases == cases and both differ from the generic array defaults. vendor/ untouched. Implementation-Agent: muse-spark-1.3-contributor
|
Fix pushed (`d87a7a7f`) addressing both findings.
Independently verified: `cargo test --test supported_latex` 8/8 pass (incl. `generated_artifacts_are_current`), new `rcases_spacing_matches_cases_not_array` pipeline test passes. Mutation check (fresh `CARGO_TARGET_DIR`): disabled the new `mathgrid.rs` arm → the spacing test FAILED exactly as expected (`left: 1.0, right: 1.2`, i.e. fell back to array defaults); restored → passes. Full suites in both `crates/compiler` (57/57) and `crates/render-pipeline` (38/38, the one failing target — `letter_class_geometry`, 5 failures — reproduces identically with this change stashed, confirmed pre-existing and unrelated) are clean, 0 new failures. |
|
daniel-parent review (subagent) Verdict: CHANGES NEEDED Re-review of
What I independently re-verified as correct:
Net: 1 of 4 prior findings (mathgrid spacing) is genuinely fixed and well-tested. Finding 1 is CI-green but not actually fixed (the generator bug ships a malformed string). Findings 2 and 4 are untouched, and finding 2 gained a fresh instance in the new code. Please: (a) fix the |
…mment, stale vocabulary entries
- supported.rs: the environment-description generator's (left, right)
match fell through to the two-sided "in {l} {r}" arm for a right-only
fence (rcases: left="", right="}"), producing the malformed "...cells
in }". Add the missing ("", r) arm.
- mathgrid.rs: the rcases comment claimed it shares mathtools' cases
macro path; real source shows cases is amsmath's \env@cases (\array,
\arraystretch=1.2) while rcases is mathtools' \newcases/
\MT_start_cases:nnnn (\ialign, \spread@equation) -- different macros
that coincidentally produce the same spacing. Corrected.
- vocabulary.rs: KNOWN_UNIMPLEMENTED_ENVIRONMENTS still listed "rcases"
and "dcases", both already implemented via GRID_ENVIRONMENTS.
Removed.
- Regenerated supported-latex.json (x2) and docs/user/compiler.md.
Implementation-Agent: muse-spark-1.3-contributor
…ded with main's inventory growth docs/user/compiler.md (generated) conflicted where main's new entries and this branch's rcases environment row both changed the Supported LaTeX section. Took main's copy and regenerated via crates/compiler/scripts/render_supported_latex.sh (50 environments, both sides present); Mac bundled supported-latex.json synced, --check clean. Implementation-Agent: fable-rebase-a Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…NMENTS; regenerate docs; fix main's VSpace pattern break crates/compiler/src/vocabulary.rs conflicted because this branch removed dcases/rcases (now implemented here) while main removed samepage/sloppypar (implemented by #568); kept both removals (the intersection). docs/user/compiler.md and the supported artefacts were regenerated via render_supported_latex.sh; Mac bundled copy sync --check clean. Also carries the one-line semantic fix current main needs: #606 added stretch_pt/shrink_pt to Block::VSpace but tests/kernel_untested_b.rs:251 still matched 'Block::VSpace { pt }' (E0027); widened to '{ pt, .. }'. Implementation-Agent: fable-rebase-a Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
Implementation-Agent: fable-rebase-e Commit-Executor: fable-rebase-e (direct; Cursor usage limit)
Implementation-Agent: fable-rebase-e Commit-Executor: fable-rebase-e (direct; Cursor usage limit)
Implementation-Agent: fable-rebase-e Commit-Executor: fable-rebase-e (direct; Cursor usage limit)
… landed docs/user/compiler.md (generated) conflicted once more after #540 merged; took main's copy and regenerated via render_supported_latex.sh, sync --check clean. Implementation-Agent: fable-rebase-a Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
… landed docs/user/compiler.md (generated) conflicted once more after #540 merged; took main's copy and regenerated via render_supported_latex.sh, sync --check clean. Implementation-Agent: fable-rebase-a Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
… landed docs/user/compiler.md (generated) conflicted once more after #540 merged; took main's copy and regenerated via render_supported_latex.sh, sync --check clean. Implementation-Agent: fable-rebase-a Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
Scope
rcases(mathtools, right-brace mirror ofcases) now parses and lays out via a one-row addition toGRID_ENVIRONMENTS(("rcases", 'l', "", "}")), reusing the existingcases/dcasesgrid-parsing/layout path. Verified against realmathtools.sty(TeX Live 2026,\newcases{rcases}{\quad}{$\m@th##$\hfil}{$\m@th##$\hfil}{.}{\rbrace}— same two-column textstyle preamble ascases, null left delimiter,\rbraceright). No render-pipeline change needed for the brace itself (flows through the genericMatrix→grid_atompath).mathgrid.rs'sGridSpec::from_sourcealso has a dedicatedrcasesspacing arm (stretch=1.2, quad gaps), added in a follow-up commit — see the Update section below.Overlap check
coord.py claims— no other claim onrcases. No other in-flight branch/PR. Confirmed via merge-base diff this branch touches onlycrates/compiler/src/math.rsanddocs/user/compiler.md— nothing undercrates/render-pipeline/.Test results
Focused run (
cargo test --lib rcases):Independent mutation check (supervisor-run, fresh
CARGO_TARGET_DIR): removed theGRID_ENVIRONMENTSrow → both tests FAILED with\begin{rcases} is not supported in math modeplus cascadingmisplaced alignment taberrors (the exact original symptom); restored → both pass.Entry-point repro (per the corrected CLI-gate rule —
flashtex-clilinks the frozenvendor/compilerpin, so a scratch-swap build hit unrelated pre-existing vendor-drift compile errors; used the same real protocol entry point instead,flashtex_compiler::protocol::handle_line, the runtime-v1 JSON path the CLI itself calls): compiling\[f(x)=\begin{rcases}1 & x>0\\0&\text{else}\end{rcases}\]throughhandle_linereturns"diagnostics":[]and"status":"ok", with the closing}glyph laid out at the rightmost x-position among the atom's items — confirming both zero-diagnostic compilation and right-side brace placement through the real path, not an internal parser helper.Not done
Follow-ups, not in this PR's scope:
\usepackage{mathtools}package-level warning (pre-existing, shared withdcases),crates/bridge/src/caret.rsmath-environment list sync, and the starred/display variants (rcases*/drcases/cases*) — out of scope as assigned.Update (review fix)
daniel-parent's re-review found 3 remaining issues past the spacing arm (already fixed in the prior commit); all fixed here, independently verified (full
cargo testincrates/compiler, 0 failures):supported.rs's environment-description generator had no match arm for a right-only fence (left="", right="}",rcases's exact shape), so it fell through to the two-sided"in {l} {r}"arm and produced"...cells in }"(empty{l}, stray double space). Added the missing("", r) => " with a right {r}"arm; regenerateddocs/user/compiler.md/supported-latex.jsonnow read"math grid, left-aligned cells with a right }". New testa_right_only_fence_describes_only_the_right_delimiter, mutation-checked (revert reproduces the exact malformed string).mathgrid.rs'srcasesarm claimed it "runs the same\MT_start_cases:nnnnmachinery ascases". Checked real TeX Live 2026 source:casesis amsmath.sty's own\env@cases(\arraystretch=1.2,\array{@{}l@{\quad}l@{}}, line 1121);rcasesis mathtools.sty's\newcases/\MT_start_cases:nnnn(\ialign+\spread@equation, line 995) — a genuinely different macro that happens to produce the same numeric spacing. Comment corrected.vocabulary.rs'sKNOWN_UNIMPLEMENTED_ENVIRONMENTSstill listed bothrcasesanddcases, though both are implemented viaGRID_ENVIRONMENTS. Removed both.🤖 Generated with Claude Code