fix: a deployment that records nothing stops reporting zeros - #188
Merged
Conversation
Production ran the whole observability chain with no Analytics Engine binding and every signal said healthy. Twenty documents at views: 0, a successful sync of nothing, zero days of history at risk, a green heartbeat. Every surface agreed with every other, which is what made it convincing. statsFor already refused to collapse three answers — no sync yet, published since the sync, measured and never opened — because a 0 that means "not measured" reads as fact at the moment it is not one. It was missing the fourth: this deployment cannot measure. So the case the function exists to prevent walked in through a door nobody guarded. The staleness alarm made it worse rather than catching it. Coverage is trivially current when there is nothing to capture, so the thing built to detect silent data loss reported ok on a deployment structurally incapable of collecting data. Asked of the binding, never inferred from an empty summary: "recorded nothing" and "cannot record" produce identical data and mean opposite things. It is the same condition recordView already branches on, so there is one source of truth rather than a second inferred one. Stored history survives. Turning tracking off does not make what was already measured untrue — it stops it accruing — and dropping it would destroy real data to fix a display bug. The parameter is required rather than defaulted. A default of true would reintroduce this exact bug the next time someone adds a reader, and the compiler found all six existing call sites in one pass. Verified against a live deployment with the binding removed, which is the production shape: health says tracking is off and names the fix, a never-viewed document reports nothing where it used to report 0, and a document with real history still reports it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: a deployment that records nothing stops reporting zeros
Closes: #185
Overview
Production ran the whole observability chain this morning with no Analytics Engine binding, and
every signal said healthy:
read_document/list_documentsviews: 0on 20 documentssync-viewsviewsRisk(#165)ok, 0 days at riskEvery surface agreed with every other, which is what made it convincing.
statsForalready refuses to collapse three answers — no sync yet, published since the sync,measured and never opened — because a
0that means "not measured" reads as fact at the moment itis not one. It was missing the fourth: this deployment cannot measure. So the exact failure that
function exists to prevent walked in through a door nobody guarded.
The staleness alarm made it worse rather than catching it: coverage is trivially current when there
is nothing to capture, so the thing built to detect silent data loss reported
okon a deploymentstructurally incapable of collecting data.
Summary of Changes
Asked of the binding, never inferred from an empty summary.
analyticsEnabled(env)is the samecondition
recordViewalready branches on, so there is one source of truth rather than a secondinferred one — "recorded nothing" and "cannot record" produce identical data and mean opposite
things.
statsForgains its fourth answer. A document with no history on a non-recording deploymentreturns
null, not zeros.syncRiskgains anoffstate that outranks every other, includinglosing. Reportingokwith zero days at risk is technically true and completely misleading.
healthsays it out loud. Previously the only place this appeared was one line of a deploy log:Stored history survives. Turning tracking off does not make what was already measured untrue —
it stops it accruing. Dropping it would destroy real data to fix a display bug.
The parameter is required, not defaulted. A default of
truewould reintroduce this exact bugthe next time someone adds a reader. The compiler found all six existing call sites in one pass,
which is the point.
Testing
Verified against a live deployment with the binding removed — the production shape, not a mock.
I deployed test with
analytics: false, confirmed the fix, and restored it:healthviews: 0views: 3views: 3— unchanged, it was measuredThat middle row is the incident in one line.
Not covered: nothing asserts the deploy path sets the binding correctly — that is #187.
Files Changed
worker/src/env.ts—analyticsEnabled()worker/src/views.ts— the fourth answer, theoffstateworker/src/api.ts·worker/src/mcp.ts— six call sitescli/lib/ops/health.mjs·worker/test/views.test.ts·CHANGELOG.mdDeployment Instructions
Deploy and upgrade. No state change — this is a read-path fix.
It does not turn view tracking on anywhere. It makes the "off" state visible instead of
disguising it as zeros. Turning production on is the manual work in #187.
Next Steps
0.35.1analyticstofalsewhen the intent filedoes not carry it, so CI has been turning production's tracking off on every deploy
productionenvironment's reviewer gate will block the 03:17 scheduled sync