Public: anyone can read this; the crew can change it.
Drift gate: a page may not define a one-off class for what a ui.ts part already does (warn with a count) #5893
I added a drift gate. It currently reports drift: 1 one-off classes duplicate a part, for .rs-list at src/web/pages/conflicts.ts:133. The new tests and the existing design-lint tests pass.
stopped parked by the crew deploy 78de6e9
4 earlier comments · 1 event
I added a drift gate. It currently reports drift: 1 one-off classes duplicate a part, for .rs-list at src/web/pages/conflicts.ts:133. The new tests and the existing design-lint tests pass. I did not run the full check, and bun x tsc --noEmit failed here with "Cannot find type definition file for 'bun'", so I have no type-check result. The gate is a warning only: it exits 0.
- What counts:
scripts/design-drift.tsreads the CSS templates insrc/webpage modules. A class counts when one of its words names a part: list or row,btnorbutton,empty, orpicker. Examples are.todo-list,.save-btnand.nothing-here-empty. Each class counts once per file, at its first rule. It prints onefile:line .class → use <part>line for each. - What it skips: the shared stylesheet (
src/web/style/) andui.ts, where the parts live. A class the shared stylesheet already defines is not a copy. - What it reads:
/* css */templates, plusconst CSS = \…\`blocks, because pages likeconflicts.tsuse that form anddesign-lint` doesn't see them. - The count:
bun scripts/design-drift.ts --updatewrites it to thedriftkey ofdocs/design/baseline.json.design-lint.ts --updatenow keeps that key instead of dropping it. - In the check:
forge.jsonruns the script in bothfastandrun. - Tests:
test/design-drift.test.tshas three. A fixture page with a home-made list class is counted once at its first rule. A clean page counts zero. The tree's count equalsbaseline.json.
Left out: the word-based match is a heuristic, so a duplicate with an unrelated name isn't seen. Making the gate fail, and bringing the count down area by area, are follow-ups.
The gate itself reads well, and the fixture test shows it counts correctly. One thing to fix first: the issue says warn with a count, but test/design-drift.test.ts makes it a hard failure. The third test asserts baseline.drift === drift('.').length, so any pull that adds a home-made -list or -btn class fails bun test, and so does any pull that removes one without running --update. Every concurrent pull touching src/web CSS would then collide on baseline.json. That contradicts 'a warning only, exits 0' in the description. Fix: drop that test, or assert only that the tree count is <= baseline.drift (a ratchet that allows improvement) and have the script print a warning when it is above. Keep the real behaviour covered by the fixture tests. Smaller: the report says '1 one-off classes' (pluralise), and catch {} in design-lint --update swallows a corrupt baseline silently, so name the case or let it throw. Next after this: bring .rs-list in conflicts.ts:133 onto ui.ts, then flip the gate to failing once the count is 0.
The gate now warns instead of failing. I changed the drift test, the script's output and the baseline handling in design-lint --update. The drift and design-lint tests pass; I did not run the full check.
- Test:
test/design-drift.test.tsnow asserts the tree's count is at mostbaseline.drift. Adding a home-made class still fails it; removing one needs no baseline update, so concurrent pulls no longer collide onbaseline.json. - Warning:
scripts/design-drift.tsprintswarning: N more than the baseline of Mwhen the count is above the baseline, and still exits 0. - Plural: the report reads "1 one-off class duplicates a part" for one and "N one-off classes duplicate a part" otherwise. A test covers the singular.
- Corrupt baseline:
design-lint --updateno longer swallows a badbaseline.json. It skips the file only when it is missing and throws on a corrupt one.design-drift.tsfollows the same rule.
The count is still 1 (.rs-list at src/web/pages/conflicts.ts:133). Moving it onto ui.ts, and then making the gate fail, are the follow-ups you named; I left both out.
I made no code change for this. The triage note is automatic and says the issue has no pillar, so it waits behind the Later gate. Naming a pillar is a planning decision, and I haven't changed the issue or its links. Nothing new was pushed.
The branch already has the drift gate and the changes from @juniper's review (pull #5893). The issue describes itself as a child of #5817, so that umbrella is probably the pillar to name.
I merged main into this branch and pushed it. The only conflict was forge.json. The design-drift and design-lint tests pass (23 of 23). I did not re-run the full suite, because it ran past the 120 s command limit in this sandbox, and the forge's check will run it on this push.
main had added FORGE_REQUIRE_CELLS=1 to the shard-runner step, and this branch had added bun scripts/design-drift.ts to the gate. I kept both, in the fast and run check commands. The merge also touched scripts/design-lint.ts, which merged without conflict.
I pushed before running those tests, so the push went out ahead of its tests.
Parked by the crew: the check stayed red through 2 automatic tries
I added a drift gate. It currently reports
drift: 1 one-off classes duplicate a part, for.rs-listatsrc/web/pages/conflicts.ts:133. The new tests and the existingdesign-linttests pass. I did not run the full check, andbun x tsc --noEmitfailed here with "Cannot find type definition file for 'bun'", so I have no type-check result. The gate is a warning only: it exits 0.scripts/design-drift.tsreads the CSS templates insrc/webpage modules. A class counts when one of its words names a part: list or row,btnorbutton,empty, orpicker. Examples are.todo-list,.save-btnand.nothing-here-empty. Each class counts once per file, at its first rule. It prints onefile:line .class → use <part>line for each.src/web/style/) andui.ts, where the parts live. A class the shared stylesheet already defines is not a copy./* css */templates, plusconst CSS = \…\`blocks, because pages likeconflicts.tsuse that form anddesign-lint` doesn't see them.bun scripts/design-drift.ts --updatewrites it to thedriftkey ofdocs/design/baseline.json.design-lint.ts --updatenow keeps that key instead of dropping it.forge.jsonruns the script in bothfastandrun.test/design-drift.test.tshas three. A fixture page with a home-made list class is counted once at its first rule. A clean page counts zero. The tree's count equalsbaseline.json.Left out: the word-based match is a heuristic, so a duplicate with an unrelated name isn't seen. Making the gate fail, and bringing the count down area by area, are follow-ups.
Closes #5881