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) #16728

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The drift gate was already on this branch and already pushed, so I made no new changes. I re-ran what I could here: the gate script, the type check and test/design-drift.test.ts (4 pass). They are all green.

Notes

opened this

The drift gate was already on this branch and already pushed, so I made no new changes. I re-ran what I could here: the gate script, the type check and test/design-drift.test.ts (4 pass). They are all green. I did not run the forge's full check.

What the branch holds

  • scripts/design-drift.ts finds /* css */ templates and const …CSS = \…\` templates in src/web` page modules. It counts a class once per file when one of its words names a part:
    • list, lists, row or rows → .list/.row
    • btn, button or buttons → .btn
    • empty → .empty
    • picker → the search picker
  • It prints drift: N one-off classes duplicate a part with file:line for each class, and exits 0, so it only warns.
  • --update writes the count to the drift key of docs/design/baseline.json. The script prints an extra warning when the count rises above that baseline.
  • src/web/style/ and ui.ts are not scanned, and a class the shared stylesheet already defines is not counted.
  • forge.json runs the script in both the fast and run checks.
  • test/design-drift.test.ts proves a fixture page with a home-made list class is counted.
  • The baseline is 1: .rs-list at src/web/pages/conflicts.ts:133.

Why pull #5893 was parked The pull went red because FORGE_REQUIRE_CELLS made the check demand cells the check host cannot start. Main fixed that in b896efa64, and this branch has that commit.

Left out

  • The gate does not fail the check yet. The issue asked for a warning only.
  • Driving the count down is for follow-up issues, one area each.

Try it: run bun scripts/design-drift.ts.

Closes #5881

3 earlier comments
commented

The drift gate was already on this branch and already pushed, so I made no new changes. I re-ran what I could here: the gate script, the type check and test/design-drift.test.ts (4 pass). They are all green. I did not run the forge's full check.

What the branch holds

  • scripts/design-drift.ts finds /* css */ templates and const …CSS = \…\` templates in src/web` page modules. It counts a class once per file when one of its words names a part:
    • list, lists, row or rows → .list/.row
    • btn, button or buttons → .btn
    • empty → .empty
    • picker → the search picker
  • It prints drift: N one-off classes duplicate a part with file:line for each class, and exits 0, so it only warns.
  • --update writes the count to the drift key of docs/design/baseline.json. The script prints an extra warning when the count rises above that baseline.
  • src/web/style/ and ui.ts are not scanned, and a class the shared stylesheet already defines is not counted.
  • forge.json runs the script in both the fast and run checks.
  • test/design-drift.test.ts proves a fixture page with a home-made list class is counted.
  • The baseline is 1: .rs-list at src/web/pages/conflicts.ts:133.

Why pull #5893 was parked The pull went red because FORGE_REQUIRE_CELLS made the check demand cells the check host cannot start. Main fixed that in b896efa64, and this branch has that commit.

Left out

  • The gate does not fail the check yet. The issue asked for a warning only.
  • Driving the count down is for follow-up issues, one area each.

Try it: run bun scripts/design-drift.ts.

commented

I merged main into the branch, resolved the three conflicts, and pushed. The merge commit is 650af6e65. On the merged tree, the type check is clean and the drift and design-lint tests pass (57 tests). I did not run the forge's full check.

How I resolved the conflicts

  • forge.json: I took main's check commands and put bun scripts/design-drift.ts back into fast and run.
  • scripts/design-lint.ts: I took main's version. Its --update already keeps keys it doesn't own, so the drift key survives.
  • docs/design/baseline.json: I took main's layout block and added drift.

The baseline went from 1 to 10. Main now has nine more one-off duplicate classes, in build_info, home_flow_style, iterations, talk_client, pick and feed_style. The ratchet test in test/design-drift.test.ts fails if the baseline is below the real count, so I ran bun scripts/design-drift.ts --update.

The gate still prints a warning for the README. It says this pull adds "## Try it" and "## Learn more" sections to README.md. The diff of README.md against origin/main is empty, so the pull adds nothing there and this predates my change.

I also ran bun scripts/gate.ts --fix once, and it rewrapped comments in 1435 files. I discarded that rewrap and kept only the merge.

commented

The cause was in forge.json. A test requires the full check tier to start with the run command, and I had added the drift gate to run but not to full. I added it to full too, so forge.json now runs design-drift.ts in fast, run and full. test/gate-size-ceiling-merged.test.ts passes now, and I pushed as 5dfd0f437.

The other two failures, "at most three streams per token…" in test/forge-view-stream.test.ts and "a cause is one issue…" in test/sentinel-causes.test.ts, passed when I ran them here. I made no change for them, so I believe they are flaky shard failures. I haven't seen the forge's next check run.

commented

I removed the ratchet test from test/design-drift.test.ts, so a new duplicate class can no longer turn bun test red. I pushed that as 0c36359c9. The three fixture tests pass and tsc shows nothing for that file. I did not run the forge's full check.

The script still prints drift: N one-off classes duplicate a part with file:line for each class. It still warns when the count is above the drift value in docs/design/baseline.json (currently 10), and it exits 0. I also dropped the two imports the test no longer used.

I left the PARTS word list as it is, and did not add it to docs/design. If it is meant to stay, naming it there is a follow-up.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs