Skip to content

compiler: record class scope on inventory commands for completion gating - #867

Merged
d-q222 merged 3 commits into
mainfrom
muse/completion-class-scope
Sep 18, 2026
Merged

d-q222 merged 3 commits into
mainfrom
muse/completion-class-scope

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

The Rust half of the \fra→\frametitle regression found by CI on #855. This PR alone does not fix the user-visible symptom — see below.

The problem

Adding beamer commands to the inventory changed completion for every document. Typing \fra⇥ expands \frametitle{} instead of \frac{}{}; typing \a offers \alert ahead of \alpha, \aleph and \allowdisplaybreaks. The inventory descriptions already said "needs \documentclass{beamer}" — the data knew these commands were conditional and nothing consumed that.

This PR

  • Command in crates/compiler/src/supported.rs gains requires_class: Option<&'static str> (None = universal).
  • Gate rule offered_in_class: hide a scoped command only when the document class is known and different. An unknown class offers everything, so this cannot make completion worse for any document we can't classify — deliberately the conservative direction.
  • supported-latex.json regenerated with the built binary. Only the 14 letter entries gained the field; no entry moved, and coverage.md plus the docs/user/compiler.md section verified byte-identical. The Mac app's bundled copy is synced (CI enforces byte-identity).

crates/compiler: 86 suites ok, 0 failed (lib 460 passed).

⚠️ The user-visible fix needs a Swift change, which a Muse lane cannot make

apps/** is outside the sandbox scope. The lane reported this itself rather than declaring victory on the Rust side:

Completion.commandSuggestions offers text entries in table order ahead of math entries, ignoring the new field.

So \fra⇥ still gives \frametitle until the Swift consumer respects requires_class. A separate lane is on that and will reference this PR. The two Mac tests (CompletionTests.testBackslashTriggersCommandsAndPrefixFilters, SnippetTests.testTabMovesBetweenPlaceholdersAndEscLeaves) stay red until then — and their assertions are correct and must not be changed; they are what caught the regression.

Why this matters beyond beamer

The same problem recurs with every future class-scoped package. A flat global vocabulary has no way to express "this command exists only in this class", so the first class-specific package to land displaces universal commands for everyone. This gives the model a place to record that.

⚠️ Lands in crates/compiler — does not reach users until vendor/compiler is re-pinned (currently 23 commits behind).

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

🤖 Generated with Claude Code

The inventory knew beamer/letter commands are class-conditional only in
prose ("needs \\documentclass{beamer}"); ranking ignored it, so adding
beamer commands let \\frametitle outrank \\frac on \\fra and \\alert
outrank \\alpha on \\a in every document. Command gains requires_class
(None = universal), populated for the 14 letter.cls-gated commands and
emitted as "requires_class" in --supported json (schema stays
flashtex-supported-latex/1, which the Swift decoder asserts and the sync
script greps for). offered_in_class is the gate rule completion mirrors:
hide a scoped command only when the document class is known and different.
No entry moved, so table order and the docs/coverage artefacts are
byte-identical; only supported-latex.json changed.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor
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