shipped · pattern — two gates rewritten window-relative in the same lane; no lint tool built yet
The parked-car rule in a procedural city engine I work on uses the number 0.35 twice. Once in a version of the rule that could never pass. Once in the version that ships today. Same numeral. Two different laws, because a threshold isn’t the number — it’s the number plus whatever it gets compared to, and that second half is where the bug lives.
The rule that could never pass
Here’s the first version, in spirit: no more than 35% of the parked vehicles adjacent to each other should share the same class. It reads like a sane density law. It’s checking against a citywide mix — 5,000 draws, where the dominant vehicle class holds 27% against its mix weight. That’s a real statistic, measured over the whole run. It’s just the wrong statistic for what the gate was actually looking at.
The gate never sees thousands of draws. It sees one block. One camera-sized window, holding somewhere between 1 and 11 vehicles. You cannot ask an 11-item sample to converge on a population proportion measured over 5,000 draws. It isn’t unlikely. It’s arithmetic. A local sample that small will drift wildly around any global mean by chance alone, every single time, and a rule built to reject that drift will reject it whether the city is well-formed or not. The gate wasn’t strict. It was unwinnable. It would have failed a perfect city and it would have failed a broken one, identically, because it was never measuring the thing in front of it.
The fix wasn’t a softer number. It was a different comparison, built from the same run:
old: adjacent same-class rate <= 0.35 (against a 5,000-draw global mix)
new: within a block, 1-11 vehicles, run<=3
adjacent-identical (class+paint) = 0
adjacent-same-class rate <= 0.35 (where n >= 5)
Read the two rules side by side and the numeral is a decoy. 0.35 didn’t get looser or tighter. It got re-anchored — from a population nobody in that block will ever see, to a window the block actually is. The n>=5 guard is doing real work too: below five adjacent vehicles, the rate is too noisy to mean anything, so the check declines to fire rather than fire on garbage. A gate that always has an opinion, even on samples too small to support one, is worse than a gate that sometimes abstains.
There’s a second bug hiding in the fix, and it’s not numeric — it’s textual. The old assertion printed like an absolute law: “adjacent same-class rate <= 0.35.” Nothing in the printed text said it was local. The rule was windowed by construction the whole time it was being misread as global, because nobody had written the word “window” into the string the person debugging the failure would actually read. The fix included rewriting the assertion text itself to name its own scope: within a block, camera-sized, not global. A threshold that doesn’t say what it’s measured against will get maintained as if it measures something it doesn’t.
The threshold that was true on the day it was written
The parked-car rule was broken from birth — unwinnable the day it shipped. The second case is the opposite shape, and it’s the more dangerous one because nothing was wrong when it was written.
The engine’s camera has a far-plane clip: geometry past a fixed distance stops rendering, for performance. It was set to 2400 meters. On the day someone set it, that was generous: the terrain that existed then didn’t reach anywhere near it.
Then the world grew. Later cities on ridge terrain — volcanic cone silhouettes, mountain arcs — generate terrain that extends out to 2.6-3.7 kilometers, well past the 2400-meter clip. Whether those arcs were ever supposed to read as visible from the coast is UNKNOWN to me now; the terrain code shipped without anyone writing that intent down anywhere I can point to, and I’m not going to invent a design rationale to make the paragraph read cleaner. Nobody touched the far-plane constant when that terrain code shipped, because the far-plane constant lives in a different file, owned by a different concern, and nothing connects the two at build time. The result: every ridge city built after that point had its terrain silently culled past 2400 meters. Not glitched — invisible. A tuff cone drawn correctly by the generator, erased by a camera setting nobody re-checked, in every city that needed it.
camera.far: 2400 m (set once, early)
terrain arc radius: 2.6-3.7 km (measured later, in cities that didn't exist yet)
sky dome radius: ~3.8 km
No gate caught this because there was no gate comparing camera.far to terrain radius at all — just two numbers living in separate files, each locally reasonable, never checked against each other in the same run. The fix: derive camera.far from the actual terrain-arc radius each city measures at generation time, censused alongside the skyline’s own far-plane, so the two can’t silently diverge again. Not a bigger constant. No constant.
Two ways for a threshold to lie
These are the same failure family wearing two faces. The parked-car rule was never satisfiable — wrong population, wrong day one. The far-plane clip was satisfiable and true, right up until a different part of the same system outgrew it without telling it. One was born wrong. One went stale. Neither one announced itself, because a hardcoded number doesn’t know what it used to mean, and a passing or failing gate built on it can’t distinguish “the world is fine” from “my comparison quantity stopped describing the world a while ago.”
The rule underneath both fixes, stated plainly: a gate law has to be relative to something measured in the same run, never to a constant captured when it was written. Not “avoid magic numbers” — that’s a style complaint. This is sharper: the constant is retroactively wrong the moment the thing it was calibrated against changes, and nothing detects that moment, because the gate keeps running and keeps printing an answer. It just stops being an answer to the question anyone thinks it’s answering.
This isn’t only a spatial-geometry problem. The same corpus runs a research program that builds falsifiable state machines for a simulated city’s public infrastructure — curb schedules, seismic recovery, air quality, power outages — sourced from official public data and re-triangulated as new deltas arrive. Two of those layers cap their confidence at 95% on purpose, as a stated ceiling rather than an aspiration to eventually hit 100%. That’s the other half of “relative to something measured”: when a number can’t be pinned to a same-run measurement at all, the honest move isn’t to invent one and call it done — it’s to declare the boundary of what you actually know, print it next to the number, and let it stay a boundary instead of quietly becoming a floor nobody re-checks.
A voice agent I run has a version of the same bug that shows the fix isn’t automatically window-relative just because someone measured something. Its filler threshold — how long to wait before saying “let me check” mid-turn — had been hardcoded well under the real median call latency, so it fired on nearly every turn. The old value was 2500 milliseconds against a measured p50 call latency of 3760, and the new one is 5500. Raising the threshold above the measured median fixed the immediate symptom — the filler went from firing on roughly 95% of turns to about 15%. But the new number is still a bare constant. It’s a better-calibrated one, pinned to a better day, not a threshold computed from the call’s own live latency window. The genuinely window-relative version would compare against a rolling measure of that specific call’s pace, not a millisecond figure fixed at deploy time. Measuring a threshold once and hardcoding the better number is progress. It isn’t the fix this piece is arguing for — it’s the same bug, caught one generation later.
Register drift shows the abstract version of this without any geometry at all. The same lane’s decision log has carried an eval-count fact across three different pages with three different numbers on them — I no longer know which of the three was ever right, and neither does the log — because “how many test cases pass” is itself a threshold-shaped claim, captured on the day someone counted, never re-derived against the actual suite as it grew. “Status: Done” on a task row is the same shape again: a judgment pinned to the day it was declared, read later as if it still describes the present.
A comparison that can’t fail isn’t a gate
Rewriting a threshold to be window-relative fixes the comparison. It doesn’t, by itself, prove the gate can ever print red. A windowed rule that happens to always pass is a more articulate version of always-green, and the corpus has a standing answer for that: every gate ships with a planted case that must fail, or the gate is unproven.
The same engine’s vegetation system is a clean instance. A tree-acceptance gate checks for scar and taper in the trunk, asymmetric crown shape, irregular frond length, the kind of imperfection real vegetation has and procedurally-generated vegetation defaults to skipping. Alongside the real check, three deliberately wrong trees run through the same gate every time: an eight-frond radial palm, a convex broccoli-shaped crown, a tree whose whole canopy sways as one rigid piece in the wind. All three must fail. If any one of them passes, the gate itself is thrown out as invalid, before anyone even looks at what it said about the real trees.
That’s the second half of the doctrine, and it has to travel with the first: a window-relative rewrite tells you what the gate is now comparing against. A planted failure case tells you the gate can still say no. Ship a threshold without one and you’ve only proven the number changed — not that anything downstream would ever notice if the world drifted out from under it again.
The audit worth running
Put the two rules together and you get something you can actually go look for in an afternoon, in any codebase, not just this one:
shaurya@sps ~ % grep -rn '<= 0\.\|>= 0\.\|<=[0-9]\|>=[0-9]' engine/*.js qa/*.mjs
StreetSection.js:142: if (sameClassRate <= 0.35) return PASS
ForecourtGrammar.js:31: const CANOPY_CLEARANCE_FT = 14
CameraRig.js:9: far: 2400
Three hits, one grep, three different verdicts once you ask what each is compared against. sameClassRate traces to a same-run measurement — good, once it’s windowed correctly. CANOPY_CLEARANCE_FT is a legal constant, a real building code, correctly absolute — nothing in the world should make 14 feet relative to anything measured that day. far: 2400 traces to nothing at all, no comparison, just a number that used to be generous. The grep can’t tell those three apart. It finds every bare numeral beside a comparison; a person still has to ask, for each one, whether it names a law of the world or a snapshot of a scene.
What I don’t know yet
I don’t know how to build the tool that finishes that last step mechanically. A linter can flag every bare numeric literal sitting next to a comparison operator inside an assertion — that part is cheap, near-trivial pattern matching. What it can’t do on its own is tell a legal constant like a 14-foot canopy clearance apart from a drifted one like a 2400-meter far-plane clip, because both look identical in the source: a number, a comparison, no citation. The honest fix probably needs a second signal — a comment convention marking a constant as “external law, not a measurement,” so the linter can trust the annotation instead of guessing from shape — but I haven’t built that convention, let alone enforced it, and until I have I don’t get to claim the audit is automatic.
I also don’t know where “the same run” should end. A per-block window worked for parked cars. A per-city measurement worked for the far-plane clip. Neither of those tells me the right window for a threshold that’s supposed to hold across a whole deploy, or across a whole training run, where “the same run” might mean minutes or might mean weeks. Until I’ve shipped a gate at that longer timescale and watched it either catch a real drift or miss one, that boundary stays UNKNOWN.
— Same Run or Never