Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(frontend): fold the destructure rule, and say what it reserves

zchpeter616cb30701e3
diff --git a/docs/design/timestamp-display.md b/docs/design/timestamp-display.md
index 8891e45f46..6e547f00b3 100644
--- a/docs/design/timestamp-display.md
+++ b/docs/design/timestamp-display.md
@@ -285,10 +285,14 @@ no seconds per D5. Relative age may accompany it in the tooltip.
none of them reachable through the hook. What the hook cannot prevent is a display reaching
past it: a reading's `read` is public so readings can compose, and the hook's parameter is
structurally typed. A Biome plugin narrows that line rather than closing it: outside the
- modules that define the readings, it rejects every mention of `read` or `nextChangeAt` as a
- member or a destructured binding — under an alias, through a local, through a table, through
- `.call`, passed as a callback, optionally chained, or keyed by a literal. What it cannot see
- is a key held in a variable, which is not a spelling anyone reaches for by accident. The rule
+ modules that define the readings, it rejects `read` and `nextChangeAt` reached as a member —
+ under an alias, through a local, through a table, through `.call`, passed as a callback,
+ optionally chained, or keyed by a literal — destructured one member at a time, and defined
+ on an object, which is what keeps a display from assembling a reading of its own. Two
+ spellings get past it, both measured: a key held in a variable, and a destructure taking both
+ members at once. Neither is what anyone writes by accident. Test files are excluded, since a
+ test builds a reading and reads it directly, and matching the member reserves both names
+ across the app — a permission object spelled `{ read: true }` would be reported too. The rule
is the convention; the plugin is what makes drifting off it loud.
- **The shared clock accepts any instant.** Deadlines are wall-clock instants but timers skip time
the machine sleeps, so the clock re-checks at least once a minute: a display is at most a
diff --git a/frontend/biome-plugins/time-reading-through-hook.grit b/frontend/biome-plugins/time-reading-through-hook.grit
index 3939cf47d8..747ed21f78 100644
--- a/frontend/biome-plugins/time-reading-through-hook.grit
+++ b/frontend/biome-plugins/time-reading-through-hook.grit
@@ -6,11 +6,29 @@
// The rule is about the member, not the name it is reached through, so this
// matches `read` and `nextChangeAt` wherever they are named: under an alias,
// through a local or a table, via `.call`, passed as a callback, optionally
-// chained, keyed by a literal, or destructured. A key held in a variable is
-// the one spelling left, and nobody reaches for it by accident.
+// chained, keyed by a literal, or destructured one member at a time. It also
+// rejects an object that defines those members, which is what keeps readings
+// in the modules below rather than assembled at a display.
+//
+// Two spellings escape it, both measured rather than assumed: a key held in a
+// variable, and a destructure taking both members at once, which Grit's object
+// snippets match by exact arity. Neither is a spelling anyone reaches for by
+// accident, and the member match catches every ordinary one.
+//
+// `$object?.read` cannot be written as `$object?.$member` -- that snippet
+// matches nothing here, so the two literal forms stay.
//
// The modules that define readings compose and build them, so biome.json
-// excludes utils/datetime.ts, utils/accessGrant.ts, and the hook itself.
+// excludes utils/datetime.ts, utils/accessGrant.ts, and the hook itself. It
+// excludes every test file too, which is the larger hole: a test builds a
+// reading and reads it directly, since that is how it checks one at all.
+//
+// Matching the member rather than the receiver reserves these two names across
+// src/: a permission object spelled `{ read: true }`, or a stream reader's
+// `.read()`, would be reported although neither has anything to do with time.
+// Neither exists in src/ today. If one arrives, rename it or exclude the file
+// in biome.json -- the rule cannot tell them apart, and that is the price of
+// catching the spellings a name-based rule missed.
language js
pattern reached_past_the_hook() {
@@ -18,8 +36,9 @@ pattern reached_past_the_hook() {
js"$object.$member" where { or { $member <: `read`, $member <: `nextChangeAt` } },
js"$object?.read",
js"$object?.nextChangeAt",
- js"{ read: $binding }",
- js"{ nextChangeAt: $binding }",
+ js"{ $member: $binding }" where {
+ or { $member <: `read`, $member <: `nextChangeAt` }
+ },
js"{ $properties }" where { $properties <: contains or { `read`, `nextChangeAt` } },
js"$object[$key]" where { or { $key <: `"read"`, $key <: `"nextChangeAt"` } }
}