Skip to content

Spell-check element kinds and parameter group names#64

Merged
DavidSagan merged 1 commit into
mainfrom
name-spelling-checks
Jul 22, 2026
Merged

Spell-check element kinds and parameter group names#64
DavidSagan merged 1 commit into
mainfrom
name-spelling-checks

Conversation

@DavidSagan

Copy link
Copy Markdown
Member

A misspelling in a name PALS draws from a fixed vocabulary is invisible: kind: marker and a FlorP group are valid YAML and simply go unrecognised downstream, so the lattice quietly comes out wrong. Both are now checked and reported.

element 'm': unknown kind 'marker'; did you mean 'Marker'?
element 'q1': unknown parameter group 'FlorP'; did you mean 'FloorP'?
element 'x1': unknown kind 'Zzzyzx'

What is checked

New src/pals_check.cpp holds the two tables and walks the combined tree — where each definition appears exactly once as written, so a mistake is reported once, against the name the user typed rather than a copy expansion made of it.

  • Kinds: the 31 element kinds of lattice-element-kinds.md, plus BeamLine and Lattice, plus the definition kinds constant (fundamentals.md), variable (pals#240) and Controller (pals#237).
  • Groups: the 23 groups under source/parameters, plus ForkFromP (pals#272).

Group names are recognised by shape — strict CamelCase ending in P, the one part of an element written that way. Letters only, so a vendor name like L20_BLW_P reads as outside the standard rather than misspelled. Plain lower-case parameters (length, to_line) are not checked; they are not drawn from a fixed vocabulary.

Suggestions

A name differing only in case wins outright — that is the mistake the CamelCase convention invites. Otherwise the nearest name within a couple of edits (and never more than a third of the name's length), and nothing at all when two candidates are equally close.

Extensions

Exempt, as the standard requires (extensions.md, s:extension-syntax): a dictionary holding an extension key, and any name registered under PALS: extension_labels — matched in full, by prefix, or by suffix — including one used as an enum value such as kind: Rotator.

What it finds in this repo's own lattice files

Not fixed here, since they are inputs rather than code:

File Finding
bta.pals.yaml kind: SBend ×2 (Bmad's name for Bend); BmadP ×3
convert.pals.yaml kind: Aperture ×2; kind: SBend
include.pals.yaml kind: SBend; kind: Beamline; BmadP

The BmadP groups are genuine extension data and would go quiet once registered under extension_labels. Beamline also appears as a typo in the standard, at lattice-construction.md:198.

Tests

New tests/test_check.cpp: five cases covering a misspelled kind, a misspelled group, a clean file reporting nothing, extension exemption in all four forms, and a name too far gone to guess at. 152/152 ctest pass; the PALSJulia suite passes against the rebuilt library.

🤖 Generated with Claude Code

A misspelling in a name PALS draws from a fixed vocabulary is invisible:
`kind: marker` and a `FlorP` group are valid YAML and simply go
unrecognised downstream, so the lattice quietly comes out wrong. Check both
against the vocabulary and report what does not belong.

The new pals_check.cpp holds the two tables -- every element kind from
lattice-element-kinds.md plus the structural and definition kinds, and every
parameter group from source/parameters -- and walks the combined tree, where
each definition appears exactly once as written, so a mistake is reported
once and against the name the user typed rather than a copy expansion made.

Group names are recognised by shape: strict CamelCase ending in `P`, which
is the one part of an element written that way. Letters only, so a vendor
name like `L20_BLW_P` reads as outside the standard rather than misspelled.

Where a near match exists it is offered. A name differing only in case wins
outright, that being the mistake the CamelCase convention invites; otherwise
the nearest name within a couple of edits, and nothing when two are equally
close.

Extension data is exempt, as the standard requires: a dictionary holding an
`extension` key, and any name registered under `PALS: extension_labels` --
by full name, prefix, or suffix -- including one used as an enum value such
as `kind: Rotator`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DavidSagan
DavidSagan merged commit 480d91a into main Jul 22, 2026
2 checks passed
@DavidSagan
DavidSagan deleted the name-spelling-checks branch July 22, 2026 18:11
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