Files
member-console/scripts
cgalo5758 abb438bc71 Check a form declaration through named rule groups
CheckInvariants ran every rule of a form declaration in one function
that gocognit scored 139. It now keeps its signature and its problem
recorder and calls checkKindAndFamily, checkFamilyScope (which calls
checkRowsScope), checkRoutes and checkWayOut, then the no-fields rule,
then per field the no-name rule, checkFieldOrder, checkFieldStructure
(which calls checkFieldPlacement and checkFieldWidth) and
checkFieldCopy (which calls checkEscapeHatch and checkFieldDashes), and
finally checkFormDashes. Each takes the recorder as addFunc. Every
message and condition is unchanged and the rules run in the order they
did; the two checkbox conditions became one, and the Select-or-Radio
test is one local. The exclusion rule for CheckInvariants is deleted.
Measured scores: CheckInvariants 5, checkFieldStructure 17,
checkFamilyScope 13, checkFieldCopy 13, checkWayOut 8, checkRowsScope 7,
checkRoutes 7, checkFieldDashes 6, checkKindAndFamily 5, checkFieldWidth
5, checkEscapeHatch 4, checkFieldOrder 3, checkFieldPlacement 3,
checkFormDashes 3.

Three things differ from the parent, none visible in a registered form:
- The two dash checks range over ordered slices. Their maps gave a
  field's problems in map order, so the slices' order is one of the
  orders the maps could give, and the registry test's failures now come
  out in a fixed order. Each test is still strings.Contains(value, "—").
- The escape hatch's keys are checked in sorted order. A field with two
  refused keys gave its two problems in map order; they now come out in
  key order. No registered form carries a refused key.
- ownedAttrs and its message "the field %q escape hatch carries %q,
  which the part owns" are deleted. A key reached that branch only after
  the data-/hx- prefix test, and no key of the map has either prefix, so
  no input reached it; the prefix rule already refuses all of them. The
  escape hatch's comment says why the hatch is narrow.

The "steps wider than a half" branch of the width rule stays; no control
reaches it today.

scripts/deadcode-testonly.txt gains 13 entries for the new helpers,
which only CheckInvariants calls and only tests call CheckInvariants.
TestInvariantsEscapeHatchProblemsComeInKeyOrder is new: it checks, 20
times, that a field whose escape hatch carries style and class gets two
problems with the class one first.

No output change. Shown so:
- go test over ./internal/forms, ./internal/server and
  ./internal/integrations/... gives 2144 test names and results at the
  parent, 2145 here; the only difference is the new test. None fail,
  one is skipped on each side. No golden file changed, so the message
  golden, the HTML goldens and the parse goldens read the same text.
- The new test fails at the parent in 3 of 3 runs, because a two-key map
  ranges from the key written first most of the time, and passes here in
  20 runs of 20 iterations each.
- invariants.go's string literals are equal apart from the 21 attribute
  names and the message of the deleted map, and the import paths "maps"
  and "slices".
- 20 break records (16 on the new side, 15 on the old; four dash and
  way-out records are written once per side because their text moved,
  and the sorted-keys record is new side only) are all caught by the
  existing message golden, and the sorted-keys one by the new test.
- go run . lint prints the same line (91 routes, 53 URL refs), the lint
  snapshot gains and loses nothing, and scripts/deadcode.sh is clean.

Not probed: the 46 messages' words beyond what the equal literal set
shows; the deleted branch, which no input reached.
2026-10-11 17:01:12 -05:00
..