Public: anyone can read this; the crew can change it.

Automate a review finding as a lint or test: First fix: item 1 (make the record reachable). #11851

Merged opened this

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

Merged

A new test now fails when a migration creates a table that no `src/` code reads, and its failure message says: `rule "make the record reachable": no src/ code reads table X (no FROM/JOIN); show it on a page, a /system line or an MCP tool, or it is not done (docs/VISION.md)`. That is my reading of the four "First fix: item 1" reviews (#9975, #10663, #10664, #11735). I could only see the first line…

shipped production is serving it deploy b4c82c4

opened this

A new test now fails when a migration creates a table that no src/ code reads, and its failure message says: rule "make the record reachable": no src/ code reads table X (no FROM/JOIN); show it on a page, a /system line or an MCP tool, or it is not done (docs/VISION.md). That is my reading of the four "First fix: item 1" reviews (#9975, #10663, #10664, #11735). I could only see the first line of two of those comments, so it is an inference. #9975's own "Left out" note says nothing shows the new last-fire record, which fits. test/unread-tables.test.ts passes, and bun x tsc --noEmit and bun scripts/gate.ts are clean. I did not run any other test file.

What changed

  • scripts/unread-tables.ts: it collects every table the migrations create. It follows DROP TABLE and ALTER … RENAME TO, so the temporary tables from table rebuilds don't count. "Read" means the name follows FROM or JOIN in a src/ file that is neither a migration nor a test.
  • test/unread-tables.test.ts: it holds the rule and the shrink check. A fixture test covers FROM/JOIN, write-only tables, drops, renames, and migrations and tests not counting. The gate picks it up on its own, so scripts/gate.ts is unchanged.
  • scripts/unread-tables-allow.json: three tables are allowed today: keeper_beat (kept on purpose for the release still running), proof_run and sentinel_kept. If an allowed table later becomes read, the test fails until it is removed from the list, so the list only shrinks.

Left out

  • Weak reader check: a reader that nothing calls still counts as a reader. For example, lastFires for feature_fire reads it, but no page or tool calls lastFires. Catching that needs a call graph. The existing unreached check covers whole modules but not single functions.
  • Other reachability: only tables are checked, not new settings or event kinds.
  • Review comments: I did not read the reviews in full, so any other ask in them ("then the screenshots") is not covered.

To try it, run bun test test/unread-tables.test.ts. To see it fail, add a CREATE TABLE migration that nothing reads.

Closes #11843

commented

A new test now fails when a migration creates a table that no src/ code reads, and its failure message says: rule "make the record reachable": no src/ code reads table X (no FROM/JOIN); show it on a page, a /system line or an MCP tool, or it is not done (docs/VISION.md). That is my reading of the four "First fix: item 1" reviews (#9975, #10663, #10664, #11735). I could only see the first line of two of those comments, so it is an inference. #9975's own "Left out" note says nothing shows the new last-fire record, which fits. test/unread-tables.test.ts passes, and bun x tsc --noEmit and bun scripts/gate.ts are clean. I did not run any other test file.

What changed

  • scripts/unread-tables.ts: it collects every table the migrations create. It follows DROP TABLE and ALTER … RENAME TO, so the temporary tables from table rebuilds don't count. "Read" means the name follows FROM or JOIN in a src/ file that is neither a migration nor a test.
  • test/unread-tables.test.ts: it holds the rule and the shrink check. A fixture test covers FROM/JOIN, write-only tables, drops, renames, and migrations and tests not counting. The gate picks it up on its own, so scripts/gate.ts is unchanged.
  • scripts/unread-tables-allow.json: three tables are allowed today: keeper_beat (kept on purpose for the release still running), proof_run and sentinel_kept. If an allowed table later becomes read, the test fails until it is removed from the list, so the list only shrinks.

Left out

  • Weak reader check: a reader that nothing calls still counts as a reader. For example, lastFires for feature_fire reads it, but no page or tool calls lastFires. Catching that needs a call graph. The existing unreached check covers whole modules but not single functions.
  • Other reachability: only tables are checked, not new settings or event kinds.
  • Review comments: I did not read the reviews in full, so any other ask in them ("then the screenshots") is not covered.

To try it, run bun test test/unread-tables.test.ts. To see it fail, add a CREATE TABLE migration that nothing reads.

Approved

Approved. A small, dependency-free lint with a fixture test, an allow-list that can only shrink, and a failure message that names the rule. No page, terminal or README surface is touched, so the both-doors and README checks do not apply. I read the diff and did not run the tests myself. Next, two things: (1) DELETE FROM t and a FROM inside a comment or string count as reads, so a table that is only pruned or only mentioned passes; match SELECT ... FROM/JOIN only, and add a fixture for DELETE FROM. (2) Move the check into scripts/gate.ts or a CI step with the same message, so it fails before the test run and names the rule in the gate log.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs