Repository navigation
compiler: only a unique closest match becomes an applicable fix (#277) - #444
Merged
Merged
Conversation
A did-you-mean suggestion is no longer only prose. `suggestion` and `help.replacement` are mechanical edits the editor applies on Tab without the author re-reading them, so the bar for producing one is higher than the bar for a hint. `suggest_command` picked the closest known command and broke ties by list order. Measured over every single-deletion and single-transposition typo the vocabulary can generate (11,781 that draw a suggestion), 9.6% had two or more equally close *distinct* candidates, and list order decided between them: `\igl` is one edit from both `\Bigl` and `\bigl`, `\lph` from both `\alph` and `\Alph`. Those pairs render differently, so applying either silently is wrong about half the time — worse than offering nothing, because Tab is instant and the author never reads it. `closest_commands` now settles the candidates in two rounds: minimal edit distance, then minimal difference in length. The second round encodes that an author who typed five characters far more often transposed one than typed a whole extra one, which is what separates `\alpah` → `\alpha` (same length) from `\alph` (shorter) — both one edit away, and the first is plainly meant. That leaves 5.8% ambiguous, and what remains is overwhelmingly case-only pairs, which cannot be separated by length and which no heuristic should pick between. 92.0% of all offered suggestions are now unique *and* recover the word the typo was generated from. Only a unique survivor sets `suggestion`/`help.replacement`. A tie keeps prose help naming every candidate and offers no edit, so the Problems panel and the CLI still help and the author chooses. `unambiguous_command_fix` is the one entry point anything mechanical should use; `suggest_command` keeps its old first-match meaning for prose. The vocabulary tables overlap, so candidates are de-duplicated — a name listed twice is one candidate, not a tie with itself, which would otherwise have suppressed a perfectly good fix. Also stops `unsupported_preamble` clobbering that fix: it used `with_help`, which overwrites help *and* drops any replacement already attached, so an unknown command in the preamble lost its did-you-mean and got advice to move a command that does not exist. `with_optional_help` keeps what `command_error` attached. This does not change what the Mac app receives. The app attaches `flashtex-render` by default (`ShellModel.locateDefaultProducer`), which builds against the pinned `render-pipeline/vendor/compiler`; that copy has no `DiagnosticHelp` type at all, and `display::Diagnostic` carries no `help` field. A vendor re-pin is a separate PR. Verified: cargo test --release --no-fail-fast -p flashtex-compiler, 584 passed / 0 failed. Implementation-Agent: Claude Opus 5 (lane quick-fix-tab, linux-primary) Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
Merged origin/main (2cf635b). #303 and #354 are on main; this lane no longer needs its stacked pipeline-diag-forward display.rs code. Conflict resolution: - crates/flashtex-cli/src/main.rs: kept --fix/--dry-run and main's version_string (#420), collapse_repeats, and watch screen-clear. The post-fix re-check also uses collapse_repeats. - crates/flashtex-cli/src/report.rs (add/add): kept main's structure (collapse_repeats) and ported this lane's `= help:` / `+` gutter suggestion rendering. Fold equality also compares suggestion. - crates/render-pipeline/src/display.rs: took main's file. #354 already forwards compiler `code` exactly and runtime-v1 `suggestion`. This lane's default_code re-derivation was dropped (CLI reads suggestion from the pipeline Diagnostic; it does not need that re-derivation). --fix still has no ambiguity policy. None existed; PR #444 is the unique-closest-match rule, so the CLI applies whatever suggestion the compiler emitted. compile.rs auto-merged: suggestion copy plus main's missing-include dedup. Tests in tests/cli.rs stayed at the end of the file. Ran: - CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix cargo test --manifest-path crates/flashtex-cli/Cargo.toml unittests: test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out tests/cli.rs: test result: ok. 20 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (multi_file_project_resolves_inputs_from_the_project_root now passes; #308 landed on main) - cargo test --manifest-path crates/render-pipeline/Cargo.toml --lib test result: ok. 110 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out Next: push this merge to origin/agent/daniel-parent/cli-fix. Open questions: none in-scope. Ambiguous suggestions are compiler-side (#444, still open). Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]>
This was referenced Sep 14, 2026
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
resolve_writable walked only the leaf and canonicalised the parent, so a directory symlink (root/link -> root/src, diagnostic link/main.tex) still took the temp+rename to src/main.tex. It now lstats every component from the project root to the file and returns Skip::Symlink if any is a symlink. `..` and absolute paths are still rejected before the walk. The atomic temp+rename stays in that verified real directory. apply_edits_back_to_front also refuses a span whose start or end is not a UTF-8 char boundary, even when the spliced bytes happen to be valid UTF-8. Ran: - CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix cargo test --manifest-path crates/flashtex-cli/Cargo.toml --bin flashtex -- a_symlinked_parent_directory_is_refused a_span_on_a_utf8_multibyte_boundary_is_refused a_symlink_target a_parent_escape crlf_bytes non_overlapping overlapping dry_run_creates json_omits a_file_changed test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 21 filtered out The two tests that failed on 83211e8 now pass. Next: git fetch origin && git merge origin/main, then an end-to-end test that an ambiguous typo (#444: igl/lph/igm) gets no suggestion and --fix writes nothing, while \\alpah is still fixed. Open questions: CLI links render-pipeline/vendor/compiler, not crates/compiler. If origin/main's #444 did not re-pin the vendor, the e2e test is a vendor-re-pin (out of scope) and will be reported. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]>
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
Adds check_fix_skips_an_ambiguous_typo_and_still_fixes_alpah using #444's inputs: `\igl` (tie between `\Bigl` and `\bigl`) must have no suggestion key and `--fix` must leave the file bytes unchanged; `\alpah` still rewrites to `\alpha`. This test FAILS on the current CLI: flashtex-cli links render-pipeline/vendor/compiler (PIN e44d591), which still uses list-order suggest_command. Observed JSON for `\igl`: "suggestion":"\\Bigl". crates/compiler on origin/main has #444 (closest_commands / unique match only), but a vendor re-pin is out of this lane's scope. Not done. Ran: - CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix cargo test --manifest-path crates/flashtex-cli/Cargo.toml unittests: test result: ok. 31 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out tests/cli.rs: test result: FAILED. 20 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (the one failure is check_fix_skips_an_ambiguous_typo_and_still_fixes_alpah) Next: stop. A vendor re-pin of compiler onto #444 is required before this e2e can pass; this lane must not do that re-pin. Open questions: who owns the vendor/compiler re-pin so `--fix` sees #444's unique-closest-match rule? Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]>
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
…#444 The CLI links vendor/compiler, which still picks list-order suggestions, so \\igl keeps a suggestion. The test is the contract for after the re-pin (#451 pins faa7d48, which predates #444). What was run: cargo test --manifest-path crates/flashtex-cli/Cargo.toml test result: ok. 31 passed; 0 failed; 0 ignored test result: ok. 20 passed; 0 failed; 1 ignored Implementation-Agent: daniel-parent (Claude Code, mac-m5pro-dq222) Commit-Executor: daniel-parent Lane-Owner: daniel-parent (mac-m5pro-dq222) Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
… CleverReference, default math-class-override (#477) The pin was 13 `crates/compiler` commits behind `main`, which left merged work inert in the pipeline. The one this was asked for is #474: `\paragraph` and `\subparagraph` are real compiler commands there, so `ps-calculus`'s four `\paragraph is not supported by this compiler version` errors are gone through the `render` producer. Nothing in the pipeline had to change for it -- the run-in head was already laid out by `adapter::run_in_heading_at`, which reads the command back from the source; the old pin's parser simply had no `"paragraph"` arm. Also now visible: #472 (mathtools colon relations), #473 (preamble `\setlength`/`\addtolength`), #455, #454, #456, #457, #460, #416, #424, #428, #444, #408. One new compiler API surfaced: `parser::Inline::CleverReference` (#460, cleveref). Three exhaustive matches in `adapter.rs` stopped building -- `inline_span`, the incremental paragraph-cache hash, and `items_from_inlines`. It is implemented, not dropped behind a wildcard: - `adapter::clever_reference_text` resolves `\cref`/`\Cref`/`\crefrange`/ `\cpageref`/`\labelcref` to text in `lower_inline`, exactly where `Reference` already was, so `items_from_inlines` keeps its `unreachable!` instead of gaining a swallow-everything arm. - `Labels` gains `kinds` (from `Inline::Label::kind`) and `cleveref` (from `Parsed::cleveref`) to feed it, and `Labels::needs_pages` now also answers true for a `\cpageref`, which otherwise had no page numbers to print. - The grouping, consecutive-number ranges, `and`/`, and` joining and parenthesised equation numbers mirror the compiler's private `layout::clever_reference_text`. The naming is *not* duplicated: `xref::cleveref_name`/`cleveref_kind` are public and are called, so `\crefname` and the `capitalise`/`noabbrev` options stay compiler-owned. - The one thing it cannot do is link. The compiler has no link backend, so `CleverReference::linked` is carried in the cache key and otherwise unused. `tests/cleveref.rs` was written against this and marked `#[ignore = "needs vendor re-pin past GH-CLEVEREF"]`. It is un-ignored and passes unchanged: `Section 2` and `eqs. (1) and (2)`. `math-class-override` becomes a default feature, as `amsmath-inline` and `par-leading` did once their preconditions were met: the re-pinned `math.rs` declares `pub class_override: Option<AtomClass>` and `pub enum AtomClass`. Without it #472 is merged but inert here, because `typeset::class_override_of` re-derives `\colon`'s class from source text that is identical with and without amsmath loaded. `class_override_of` stays as the no-default-features fallback. No other vendor directory had to move. `compiler`'s four path dependencies (`font-engine`, `tex-text-encoding`, `tex-boxes`, `tex-expansion`) are unchanged from the pin, and the three `tex-*` crates have had no commits at all since `87a513de`. `math-layout` *is* 8 commits behind `main` (#186, #229), but `compiler` does not depend on it, so that is a separate re-pin. The stale opening paragraph of VENDORING.md (which still named `ea4ee5c8` as the `compiler` pin and "~150 commits") is corrected. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: 365 passed / 0 failed (364 baseline + the un-ignored cleveref test). - amsmath oracle corpus: `TOTAL 59/59 within 0.5 bp`. - `tabular_oracle: 106/106 fixtures match pdflatex`. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf`, not by reading the harness summary -- 22/22 agree. Zero font-FAILURE diagnostics on either producer. HW1 and HW2: 3 pages, 0 errors. - The `packages::supersede_message` regression the last re-pin hit did not return: every `... are recognised but not implemented` line in the report is `render 0 / compiler N`, so none leak through the pipeline. Implementation-Agent: claude-opus-5 render-pipeline lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 render-pipeline lane, direct git (observed Cursor usage limit)
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
…ng skips, page-1 \@Texttop (#482) * render-pipeline: re-pin vendor/compiler faa7d48 -> 6a47ed4, implement CleverReference, default math-class-override The pin was 13 `crates/compiler` commits behind `main`, which left merged work inert in the pipeline. The one this was asked for is #474: `\paragraph` and `\subparagraph` are real compiler commands there, so `ps-calculus`'s four `\paragraph is not supported by this compiler version` errors are gone through the `render` producer. Nothing in the pipeline had to change for it -- the run-in head was already laid out by `adapter::run_in_heading_at`, which reads the command back from the source; the old pin's parser simply had no `"paragraph"` arm. Also now visible: #472 (mathtools colon relations), #473 (preamble `\setlength`/`\addtolength`), #455, #454, #456, #457, #460, #416, #424, #428, #444, #408. One new compiler API surfaced: `parser::Inline::CleverReference` (#460, cleveref). Three exhaustive matches in `adapter.rs` stopped building -- `inline_span`, the incremental paragraph-cache hash, and `items_from_inlines`. It is implemented, not dropped behind a wildcard: - `adapter::clever_reference_text` resolves `\cref`/`\Cref`/`\crefrange`/ `\cpageref`/`\labelcref` to text in `lower_inline`, exactly where `Reference` already was, so `items_from_inlines` keeps its `unreachable!` instead of gaining a swallow-everything arm. - `Labels` gains `kinds` (from `Inline::Label::kind`) and `cleveref` (from `Parsed::cleveref`) to feed it, and `Labels::needs_pages` now also answers true for a `\cpageref`, which otherwise had no page numbers to print. - The grouping, consecutive-number ranges, `and`/`, and` joining and parenthesised equation numbers mirror the compiler's private `layout::clever_reference_text`. The naming is *not* duplicated: `xref::cleveref_name`/`cleveref_kind` are public and are called, so `\crefname` and the `capitalise`/`noabbrev` options stay compiler-owned. - The one thing it cannot do is link. The compiler has no link backend, so `CleverReference::linked` is carried in the cache key and otherwise unused. `tests/cleveref.rs` was written against this and marked `#[ignore = "needs vendor re-pin past GH-CLEVEREF"]`. It is un-ignored and passes unchanged: `Section 2` and `eqs. (1) and (2)`. `math-class-override` becomes a default feature, as `amsmath-inline` and `par-leading` did once their preconditions were met: the re-pinned `math.rs` declares `pub class_override: Option<AtomClass>` and `pub enum AtomClass`. Without it #472 is merged but inert here, because `typeset::class_override_of` re-derives `\colon`'s class from source text that is identical with and without amsmath loaded. `class_override_of` stays as the no-default-features fallback. No other vendor directory had to move. `compiler`'s four path dependencies (`font-engine`, `tex-text-encoding`, `tex-boxes`, `tex-expansion`) are unchanged from the pin, and the three `tex-*` crates have had no commits at all since `87a513de`. `math-layout` *is* 8 commits behind `main` (#186, #229), but `compiler` does not depend on it, so that is a separate re-pin. The stale opening paragraph of VENDORING.md (which still named `ea4ee5c8` as the `compiler` pin and "~150 commits") is corrected. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: 365 passed / 0 failed (364 baseline + the un-ignored cleveref test). - amsmath oracle corpus: `TOTAL 59/59 within 0.5 bp`. - `tabular_oracle: 106/106 fixtures match pdflatex`. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf`, not by reading the harness summary -- 22/22 agree. Zero font-FAILURE diagnostics on either producer. HW1 and HW2: 3 pages, 0 errors. - The `packages::supersede_message` regression the last re-pin hit did not return: every `... are recognised but not implemented` line in the report is `render 0 / compiler N`, so none leak through the pipeline. Implementation-Agent: claude-opus-5 render-pipeline lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 render-pipeline lane, direct git (observed Cursor usage limit) Co-authored-by: GoKubar <[email protected]> * render-pipeline: re-pin vendor/compiler onto #316 so the pipeline can see CBlock::LetterBlock Stacked on #477 (the re-pin to `main`). **Blocked on #316 merging**, and deliberately so: this is a temporary pin to an unmerged branch, the second such row in `vendor/VENDORING.md` after `vector-graphics`. Why a pin to a branch at all: PR #316 adds `parser::Block::LetterBlock`, and `adapter::inlines_of` matches `CBlock` exhaustively with no catch-all, so the render-pipeline side of the `letter` class is a hard compile error against any vendored compiler that lacks the variant. It cannot be written first and pinned later. `engine/letter-class-compiler` is `main` + one commit (`15264d7b`, rebased and green: 664 passed / 0 failed on `crates/compiler`), and `vendor/compiler` here is a plain `git archive` of its `crates/compiler`. **When #316 merges, re-pin this row to `main`** — `git archive <main>:crates/compiler` and nothing else. The compiler row of `VENDORING.md` says so in the first sentence. Two exhaustive matches in `adapter.rs` needed the new variant: `inlines_of` and the unit-building block walk. Neither gained a wildcard. `LetterBlock` carries `Vec<Vec<Inline>>` rather than one flat slice, so it is lowered in `lower_blocks` alongside `Verbatim`/`TitleBlock`/`VFill`: each line becomes an ordinary paragraph in the nearest alignment the pipeline has today (`flushright` for `\opening`'s return address, `flushleft` for the recipient and the closing), with **one typed `unsupported_block` limitation per block** naming exactly what is not applied — the `\longindentation` offset, the class's own vertical skips, and the `\raggedleft` box whose lines share a left edge where `flushright` aligns their right ones. No line of an `\opening` or a `\closing` is dropped, and nothing about the class is silently approximated. The typesetting PR stacked on this one replaces that arm and spends the skips the compiler already resolved. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: 365 passed / 0 failed. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf` — 22/22 agree. Zero font-FAILURE diagnostics. - `letter` compiles through the `render` producer with **0 errors**, where the #477 pin still reported seven `unknown_command`s (`\signature`, `\address`, `\opening`, `\closing`, `\encl`, `\cc`, `\ps`). Implementation-Agent: claude-opus-5 render-pipeline/letter lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 direct git (observed Cursor usage limit) Co-authored-by: GoKubar <[email protected]> * render-pipeline: typeset letter.cls — class \parskip, \opening/\closing skips, page-1 \@Texttop Stacked on the re-pin that gives the pipeline `CBlock::LetterBlock`, which in turn is stacked on #477 and blocked on #316. This is the third and last link of the `letter` chain: #297 gave the class its page frame, #316 gave the compiler the class's commands, and this makes the pipeline put the result where pdfLaTeX puts it. `fixtures/real-world/letter` was **218 words at 0% vertical accuracy**, the worst whole-fixture failure in the corpus. Landing the compiler alone did not move it: the class's commands parsed, and the page was still 93 bp out with **0 of 227 aligned words within 0.5 bp on the vertical axis**. Four separate things were wrong, and they had to be fixed in this order because each one hid the next. ## 1. `\parskip` is a class length, and the pipeline never read it `Stylesheet::from_resolved` copied `\parindent`, `\topskip` and `\maxdepth` out of `flashtex-class-geometry` but not `\parskip`, so every document kept `Stylesheet::article`'s `0pt plus 1pt`. For article/report/book that is identical to what the class says, which is why nobody noticed. letter.cls line 91 sets `0.7em` — 7.66498pt rigid at 11pt — so **every paragraph gap in every letter was 7.6 bp short**, and the error accumulated down the page. This is a no-op for every other class: `class-geometry`'s article `\parskip` is `Glue::new("0pt", "1pt", "0pt")` and `document-style`'s `PARSKIP` is `Skip::new(0.0, 1.0, 0.0)`. A document's own `\setlength\parskip` (#473) is applied later in `adapt_cached` and still wins. Effect alone: vertical agreement after removing a rigid page shift, 26.4% → 85.0%; max |dy| 186.5 → 67.6 bp. ## 2. `\opening`'s blocks are one paragraph each, not one paragraph per line The compiler hands over `lines: Vec<Vec<Inline>>` with the class's own skips already resolved into `gap_before_pt`, `gap_after_pt` and `extra_gap_after_pt` — all multiples of that `\parskip`. `lower_blocks` now spends them instead of dropping them, and joins each run of lines with `Inline::LineBreak` into **one** paragraph. That distinction is the whole structure: a `\\` inside a paragraph costs `\baselineskip`, a new paragraph costs `\baselineskip` *plus* `\parskip`, and letter.cls sets the address and the recipient as single `\\`-separated groups (a `tabular{l@{}}` and a `{\raggedright ...\par}`). The one mid-block gap, `\\*[2\parskip]` between `\fromaddress` and `\@date`, does split the paragraph, so the `\vspace` carrying it has the next paragraph's own `\parskip` taken out of it. Effect: max |dy| 67.6 → 41.9 bp — by then a *rigid* offset, the whole page uniformly too high. ## 3. `{\raggedleft ...}` is a declaration, not a `flushright` environment The recipient and the closing are now plain paragraphs rather than `Styled` ones. `letter.cls` writes them as `\raggedright` *declarations*, which carry none of `\trivlist`'s `\topsep`/`\partopsep` (9pt + 3pt at 11pt); a `Styled` block does, and it put both blocks 12pt too low. They are short, unwrapped lines, where `\raggedright` and justification set identical text, so this is the right vertical answer and the same horizontal one. The return address must stay right-aligned, so it stays `Styled(FlushRight)`, and the `env_close` pass — which gives any non-`Plain` paragraph `\@endparenv`'s `\@topsepadd` on the assumption that it came from an environment — now skips the paragraphs `lower_blocks` made from a letter block. They are keyed by their first inline's span, not the block's, because `\address`'s text comes from the **preamble** and lies outside `\opening`'s own span entirely. ## 4. letter.cls's page-1 `\@texttop` Line 405: \def\@Texttop{\ifnum\c@page=1\vskip \z@ plus.00006fil\relax\fi} On page 1 only, a fil glue sits at the top of the text block. Line 404's `\raggedbottom` — unguarded, unlike article's `\if@twoside\else\raggedbottom\fi`, so a `[twoside]` letter gets it too, which `Stylesheet::from_resolved` now also models — puts `\@textbottom`'s `\vskip \z@ \@plus.0001fil` at the bottom. The page's leftover space is shared in the ratio of their stretch, so the top takes 3/8 of it and the first baseline moves down by that much. `crates/class-geometry`'s `letter_oracle` documents this exactly and is why it checks its frame model on page 2 and only bounds page 1: the shift is page building, not a frame length, so it belongs here. Without it every letter's page 1 rode 41.95 bp too high on this fixture — a rigid offset that held *0%* of the page's words outside 0.5 bp however exactly the spacing between them was set. Effect: max |dy| 41.9 → 4.3 bp. ## Where `letter` now is | | dx ≤ 0.5 bp | dy ≤ 0.5 bp | dy ≤ 0.5 after a rigid shift | max \|dy\| | |---|---|---|---|---| | before #316 | — | — | — | the page had no letter structure at all | | #316 + re-pin only | 93.39% | **0.00%** | 26.43% | 186.46 bp | | this PR | 93.39% | 3.96% | **89.43%** | **4.29 bp** | Measured with `tools/visual-oracle/rank.py` against the pinned `fixtures/real-world/letter/reference.pdf`. Line by line the address block is within 0.39 bp, the whole body (17 of the 26 lines) within 1.37 bp, and nothing is worse than 4.29 bp. ## What is still wrong, measured rather than hidden Three residuals, each diagnosed and none of them silent: * **2.92 bp** at the boundary into `\closing`. Its argument goes in a `\parbox` whose first line is a `\strut` and whose height drives the interline glue TeX chooses; the pipeline has no `\parbox` box model to hang that on. * **0.98 bp** at the boundary out of `\opening`'s return address, which pdfLaTeX sets in a `tabular` whose last row carries `\@arstrut`'s `0.3\baselineskip` depth where a text line carries its glyphs'. * Those two make our content 2.91 bp taller than the reference's between the first and last baseline, which feeds back through the `\@texttop` share above and leaves the whole page a uniform ~1.4 bp low. That is why `dy ≤ 0.5` is 3.96% and not ~100%: the structure is right and the total height is not. Fix either box model and the axis should snap. Horizontally, the one remaining item is `\longindentation`: the closing and signature sit at the left margin instead of 180pt in (max |dx| 179.328 bp is exactly that length). `Block::Paragraph` has no per-paragraph left offset or measure, so it cannot be expressed yet; it keeps its typed `unsupported_block` limitation naming the exact offset, as does the `\raggedleft` box whose lines share a *left* edge where `flushright` aligns their right ones. One more difference this PR does not fix and the new test records: this page carries a folio and the reference does not, because `\opening` runs `\thispagestyle{empty}` whenever `\fromaddress` is non-empty (letter.cls 170-176). That is a page-style event the compiler does not emit yet. `crates/render-pipeline/tests/letter_class_geometry.rs` pins all four fixes against the reference's own baselines, with a per-boundary tolerance that is the measured residual rather than a margin chosen to pass — tightening those numbers is the next lane's gate. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: **370 passed / 0 failed** (365 + the 5 new letter tests). - amsmath oracle corpus `TOTAL 59/59 within 0.5 bp`; `tabular_oracle: 106/106 fixtures match pdflatex`. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf` — **22/22** agree. Zero font-FAILURE diagnostics on either producer. HW1 and HW2: 3 pages, 0 errors. - Full `tools/visual-oracle/rank.py` sweep of the corpus in `docs/evidence/visual-oracle-letter-after/`: no fixture regressed, and the 21 non-letter fixtures are untouched by construction — the `\parskip` read is a no-op for their classes and the other two changes are gated on `ClassKind::Letter`. Implementation-Agent: claude-opus-5 render-pipeline/letter lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 direct git (observed Cursor usage limit) Co-authored-by: GoKubar <[email protected]> * vendor: re-pin compiler to main c95977d (now that #316's letter class has landed)
GoKubar
pushed a commit
that referenced
this pull request
Sep 15, 2026
…dry-run] with symlink-safe atomic writes (#362) * cli: rustc-style diagnostics with a source excerpt and carets (#277 part 2) `flashtex check`/`build`/`watch` print each diagnostic as a header, a `--> file:line:col` pointer, the source line(s) under a line-number gutter, carets under the byte span and a wrapped `= recovery:` line. - `--diagnostics=full|short|json`: full is the new form; short is the unchanged one-line `line_text`; json is `--json`. The default is full when stderr is a terminal and short otherwise, so piped output and scripts see exactly what they did before. - `--color=auto|always|never`; auto is on for a terminal unless NO_COLOR. - Uses only the fields a diagnostic already has (code, message, span, recovery). Structured labels/help from #277 part (1) can be added to the renderer without changing this path. - Spans: tabs expanded so carets line up, multi-byte text, empty spans and spans past the end of the text get one caret, spans longer than four lines show the first two and the last. Tests: 7 renderer unit tests, one end-to-end test for the flags. The pre-existing multi_file_project_resolves_inputs_from_the_project_root failure reproduces on unmodified main 9bd4b02 and is not touched here. Implementation-Agent: daniel-parent (mac-m5pro-dq222) Commit-Executor: git, direct Co-authored-by: d-q222 <[email protected]> * wip(#277): reproduce from_compiler dropping code and suggestion Add display::Diagnostic.suggestion (None at every constructor) and tests that expect unknown_command/\alpha and unsupported_feature. from_compiler still hardcodes code "compiler" and does not copy suggestion. Ran: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-diagfwd cargo test --manifest-path crates/render-pipeline/Cargo.toml --lib from_compiler_forwards Result: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 89 filtered out display::tests::from_compiler_forwards_code_and_suggestion: left "compiler" right "unknown_command" Next: forward compiler code (explicit, else default_code, else "compiler") and suggestion; emit suggestion only in runtime-v1 JSON; extend corpus owner_for; keep v2 diagnostics without a suggestion key. Open questions: none in-scope. vendor/, apps, protocol schema untouched. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * wip(#277): forward compiler diagnostic code and suggestion from_compiler copies the compiler's code (explicit, else default_code(message), else "compiler") and suggestion. runtime-v1 JSON emits suggestion only when set; display-list-v2 diagnostics are unchanged except the code value. owner_for accepts the compiler code set; tikz_pipeline rejects those codes too so a forwarded unknown_command cannot slip through as "not compiler". Ran (CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-diagfwd): - --lib from_compiler_forwards -- writer_matches_value_tree: test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 88 filtered out - --lib write_json_matches_the_value_tree: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 89 filtered out - --test compiler_diagnostic_forward: test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - --test tikz_pipeline: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - python3 -m unittest tools.real-world-corpus.test_run: Ran 6 tests in 0.008s OK Next: full cargo test --manifest-path crates/render-pipeline/Cargo.toml control-vs-after. Open questions: no in-scope golden embeds "code":"compiler" for a compiler diagnostic (vendor/pdf fixture and apps/mac display-list fixture are out of lane). docs/user/compiler.md still shows the old example. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * wip(#277): reproduce CLI dropping suggestion and lacking --fix Add six cli.rs tests that pin GH-277 acceptance: rustc-style help for \alpah, JSON suggestion, check --fix rewrite, --dry-run diff, suggestion in an \input file, and --help mentioning --fix/--dry-run. Overlap and hash-changed refusal will land with the apply module (need synthetic edits; the compiler does not emit overlapping spans for \alpah). Control (CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix, base 5b7a88b): - unittests: test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - --test cli: test result: FAILED. 12 passed; 1 failed (multi_file_project_resolves_inputs_from_the_project_root, fixture-dependent / PR #308) New tests (same target dir): - typo_alpah_full_output_has_a_help_block: FAILED (no "= help: did you mean `\alpha`?") - typo_alpah_json_includes_suggestion: FAILED (suggestion key absent, left None) - check_fix_rewrites_alpah_to_alpha / dry_run / input file: FAILED (exit 2, unknown option "--fix") - check_help_mentions_fix_and_dry_run: FAILED (--help has no --fix) Next: copy suggestion onto the CLI Diagnostic next to code.clone(), then render the help block / short parenthetical / JSON key, then check --fix. Open questions: none in-scope. Overlap/hash/symlink tests belong in the apply module; they cannot be driven from the compiler's \alpah diagnostic. Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * wip(#277): copy suggestion, render help, and check --fix CLI Diagnostic copies pipeline suggestion next to code.clone(). Full renderer prints `= help: did you mean \`\\alpha\`?` plus a `+` gutter over the replaced line; short appends `(did you mean \alpha?)`; JSON emits `suggestion` only when set. `check --fix [--dry-run]` applies non- overlapping back-to-front byte edits, refuses changed files (SHA-256), symlinks and paths outside the project root, writes atomically with mode preserved, then re-checks. Overlap/hash/symlink/mode covered by fix.rs unit tests (the compiler does not emit overlapping \alpah spans). Ran (CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix): - --bin flashtex: test result: ok. 21 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - full cargo test --manifest-path crates/flashtex-cli/Cargo.toml: unittests ok. 21 passed; --test cli FAILED. 18 passed; 1 failed (multi_file_project_resolves_inputs_from_the_project_root — same pre-existing control failure; all six new GH-277 tests passed) Next: no in-scope follow-up; lane is ready for daniel-parent review (no PR). Open questions: none. Known #308 fixture failure left untouched. Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * cli: --fix skips a suggestion without a full span instead of inserting it Review fix on the GH-277-cli-fix lane: collect_edits used `end_byte.unwrap_or(start)`, so a diagnostic with a start but no end (or an empty span) became an insertion at `start`. A compiler suggestion replaces its span, so both ends are now required and the span must be non-empty. cargo test -p flashtex-cli: bin 22/0 (+1: a_suggestion_without_a_full_span_is_not_turned_into_an_insertion); tests/cli 18 passed, 1 failed: multi_file_project_resolves_inputs_from_the_project_root, the same fixture-dependent failure as on the base 5b7a88b (replaced by #308). Implementation-Agent: Claude Code (daniel-parent, mac-m5pro-dq222) Commit-Executor: Claude Code (daniel-parent) Lane-Owner: daniel-parent (mac-m5pro-dq222) Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz * wip(#277): failing tests for symlink-parent writes and UTF-8 spans Adds the --fix safety matrix. Two tests fail on 6abfbec, as intended: - a_symlinked_parent_directory_is_refused: with root/link -> root/src and diagnostic path link/main.tex, apply reports issues=1, skipped=[], and rewrites src/main.tex. resolve_writable only lstats the leaf and canonicalises the parent, so the temp+rename follows the directory symlink. - a_span_on_a_utf8_multibyte_boundary_is_refused: start=1,end=3 on éé (c3 a9 c3 a9) with an empty replacement leaves a valid é; from_utf8 accepts it and the file is written. The rest of the matrix already passes: leaf symlink, ../ and absolute paths, CRLF preservation, back-to-front non-overlapping edits, overlapping skips, dry-run directory listing, JSON omitting the suggestion key (extracted diagnostic_json so the assertion is unconditional). Ran: - CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix cargo test --manifest-path crates/flashtex-cli/Cargo.toml --bin flashtex -- a_symlinked_parent_directory_is_refused a_span_on_a_utf8_multibyte_boundary_is_refused test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 29 filtered out - same binary filter for the other new tests test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 24 filtered out Next: walk every path component with symlink_metadata and refuse non-char-boundary spans before splicing. Open questions: none. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * wip(#277): refuse writes through any symlink component resolve_writable walked only the leaf and canonicalised the parent, so a directory symlink (root/link -> root/src, diagnostic link/main.tex) still took the temp+rename to src/main.tex. It now lstats every component from the project root to the file and returns Skip::Symlink if any is a symlink. `..` and absolute paths are still rejected before the walk. The atomic temp+rename stays in that verified real directory. apply_edits_back_to_front also refuses a span whose start or end is not a UTF-8 char boundary, even when the spliced bytes happen to be valid UTF-8. Ran: - CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix cargo test --manifest-path crates/flashtex-cli/Cargo.toml --bin flashtex -- a_symlinked_parent_directory_is_refused a_span_on_a_utf8_multibyte_boundary_is_refused a_symlink_target a_parent_escape crlf_bytes non_overlapping overlapping dry_run_creates json_omits a_file_changed test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 21 filtered out The two tests that failed on 83211e8 now pass. Next: git fetch origin && git merge origin/main, then an end-to-end test that an ambiguous typo (#444: igl/lph/igm) gets no suggestion and --fix writes nothing, while \\alpah is still fixed. Open questions: CLI links render-pipeline/vendor/compiler, not crates/compiler. If origin/main's #444 did not re-pin the vendor, the e2e test is a vendor-re-pin (out of scope) and will be reported. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * wip(#277): e2e that an ambiguous typo is not a --fix Adds check_fix_skips_an_ambiguous_typo_and_still_fixes_alpah using #444's inputs: `\igl` (tie between `\Bigl` and `\bigl`) must have no suggestion key and `--fix` must leave the file bytes unchanged; `\alpah` still rewrites to `\alpha`. This test FAILS on the current CLI: flashtex-cli links render-pipeline/vendor/compiler (PIN e44d591), which still uses list-order suggest_command. Observed JSON for `\igl`: "suggestion":"\\Bigl". crates/compiler on origin/main has #444 (closest_commands / unique match only), but a vendor re-pin is out of this lane's scope. Not done. Ran: - CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-clifix cargo test --manifest-path crates/flashtex-cli/Cargo.toml unittests: test result: ok. 31 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out tests/cli.rs: test result: FAILED. 20 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (the one failure is check_fix_skips_an_ambiguous_typo_and_still_fixes_alpah) Next: stop. A vendor re-pin of compiler onto #444 is required before this e2e can pass; this lane must not do that re-pin. Open questions: who owns the vendor/compiler re-pin so `--fix` sees #444's unique-closest-match rule? Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]> * wip(#277): ignore the #444 e2e until vendor/compiler is re-pinned past #444 The CLI links vendor/compiler, which still picks list-order suggestions, so \\igl keeps a suggestion. The test is the contract for after the re-pin (#451 pins faa7d48, which predates #444). What was run: cargo test --manifest-path crates/flashtex-cli/Cargo.toml test result: ok. 31 passed; 0 failed; 0 ignored test result: ok. 20 passed; 0 failed; 1 ignored Implementation-Agent: daniel-parent (Claude Code, mac-m5pro-dq222) Commit-Executor: daniel-parent Lane-Owner: daniel-parent (mac-m5pro-dq222) Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz --------- Co-authored-by: Cursor <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A did-you-mean suggestion stopped being only prose when
suggestion/help.replacementbecame mechanical edits the editor applies. The companion PRmakes Tab accept one at the caret, instantly, without the author re-reading
it. That raises the bar for producing one, and this PR raises it.
The measurement
Over every single-deletion and single-transposition typo this vocabulary can
generate (11,781 that draw a suggestion), with candidates de-duplicated across
the overlapping tables:
and after the change 92.0 % of all offered suggestions are unique and
recover the word the typo was generated from.
Ties were previously broken by list order.
\iglis one edit from both\Bigland
\bigl;\lphfrom both\alphand\Alph. Those render differently, soapplying either silently is wrong about half the time — worse than offering
nothing, because Tab is instant.
The rule
closest_commandssettles candidates in two rounds: minimal edit distance,then minimal difference in length. The second round encodes that an author who
typed five characters far more often transposed one than typed a whole extra
one. That is what separates
\alpah→\alpha(same length) from\alph(shorter), both one edit away — and the flagship case keeps its fix.
What survives both rounds is a genuine ambiguity, and it is overwhelmingly
case-only pairs, which cannot be separated by length and which no heuristic
should pick between. Only a unique survivor sets
suggestion/help.replacement; a tie keeps prose help naming every candidate and offers noedit, so the panel and the CLI still help and the author chooses.
unambiguous_command_fixis the one entry point anything mechanical shoulduse — including
flashtex check --fixin #362, so that stays one suggestionsource rather than a second copy.
Also
unsupported_preambleusedwith_help, which overwrites help and drops anyreplacement already attached, so an unknown command in the preamble lost its
did-you-mean and got advice to move a command that does not exist.
with_optional_helpkeeps whatcommand_errorattached.This changes nothing the app sees, yet
The app attaches
flashtex-renderby default(
ShellModel.locateDefaultProducerprefers it over the compiler), and thatbuilds against the pinned
render-pipeline/vendor/compiler, which has noDiagnosticHelptype at all —display::Diagnosticcarries nohelpfield.A vendor re-pin is a separate PR and is not done here.
Verified
cargo test --release --no-fail-fastoncrates/compiler: 591 passed, 0failed (rebased on
fd6af3cf).🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu