Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: preserve absent per-check telemetry as null, not zero, to avoid false post-upgrade regressions (#1597)

[._.]/ Adam Eivy4a8726114bcb
diff --git a/client/src/lib/editorialHealth.js b/client/src/lib/editorialHealth.js
index 22b09907e8..0bd6297ba4 100644
--- a/client/src/lib/editorialHealth.js
+++ b/client/src/lib/editorialHealth.js
@@ -90,17 +90,21 @@ export function orderedChecks(openByCheck = {}, labelFor = (id) => id) {
/**
* Extract a single check's open-finding count across the trend points (#1597),
- * oldest→newest, as a plain number array. A point with no entry for the check
- * contributes 0 (the check found nothing that revision), so the series length
- * always matches the point count — the sparkline shows the check climbing from /
- * settling to zero rather than dropping points.
+ * oldest→newest, as a plain number array. Points with NO per-check telemetry
+ * (`openByCheck` is null/absent — a snapshot recorded before per-check tracking
+ * shipped) are OMITTED, not counted as 0: coercing them to zero would draw a
+ * false spike out of nowhere on the first post-upgrade run. Within a
+ * telemetry-bearing point, a check absent from the map legitimately contributes
+ * 0 (it found nothing that revision).
*/
export function checkCountSeries(points = [], checkId) {
const list = Array.isArray(points) ? points : [];
- return list.map((p) => {
- const c = p?.openByCheck?.[checkId];
- return Number.isFinite(c) ? c : 0;
- });
+ return list
+ .filter((p) => p?.openByCheck && typeof p.openByCheck === 'object')
+ .map((p) => {
+ const c = p.openByCheck[checkId];
+ return Number.isFinite(c) ? c : 0;
+ });
}
/**
diff --git a/client/src/lib/editorialHealth.test.js b/client/src/lib/editorialHealth.test.js
index e1a0593dbd..da456e8917 100644
--- a/client/src/lib/editorialHealth.test.js
+++ b/client/src/lib/editorialHealth.test.js
@@ -112,6 +112,15 @@ describe('checkCountSeries', () => {
expect(checkCountSeries(points, 'b')).toEqual([0, 2, 2]);
});
+ it('omits points with no per-check telemetry (null openByCheck) — no false zero-spike for pre-#1597 snapshots', () => {
+ const points = [
+ { openByCheck: null }, // pre-upgrade: unknown, omitted (not 0)
+ { openByCheck: { 'a': 2 } }, // telemetry-bearing
+ { openByCheck: { 'b': 1 } }, // 'a' absent here → legit 0
+ ];
+ expect(checkCountSeries(points, 'a')).toEqual([2, 0]);
+ });
+
it('returns empty for empty/absent points', () => {
expect(checkCountSeries([], 'a')).toEqual([]);
expect(checkCountSeries(undefined, 'a')).toEqual([]);
diff --git a/server/services/pipeline/editorialScore.js b/server/services/pipeline/editorialScore.js
index 74e4196b1f..7ffc313310 100644
--- a/server/services/pipeline/editorialScore.js
+++ b/server/services/pipeline/editorialScore.js
@@ -227,14 +227,21 @@ function sanitizeSnapshot(raw) {
const byCat = raw.openByCategory && typeof raw.openByCategory === 'object' ? raw.openByCategory : {};
const openByCategory = {};
for (const [k, v] of Object.entries(byCat)) if (Number.isFinite(v)) openByCategory[k] = v;
- // Per-check open counts (#1597). Additive + local-only telemetry: snapshots
- // recorded before this shipped simply lack the map (defaults to {}), so the
- // per-check trend starts accumulating from the first run after upgrade — no
- // schema bump needed (older readers ignore the field; this reader tolerates
- // its absence).
- const byCheck = raw.openByCheck && typeof raw.openByCheck === 'object' ? raw.openByCheck : {};
- const openByCheck = {};
- for (const [k, v] of Object.entries(byCheck)) if (Number.isFinite(v)) openByCheck[k] = v;
+ // Per-check open counts (#1597). Additive + local-only telemetry — no schema
+ // bump needed (older readers ignore the field; this reader tolerates its
+ // absence). CRITICAL: a snapshot recorded BEFORE this shipped has NO per-check
+ // map, which is NOT the same as "ran and found zero" ({}). Coercing absence to
+ // {} would make pre-upgrade points read as real zero counts — the first
+ // post-upgrade run would then draw a false 0→N spike and flag every currently
+ // open check as a 0→N regression. So we preserve absence as `null` ("no
+ // telemetry"); `computeTrend` skips per-check regressions across a null point
+ // and the client omits null points from the per-check sparkline.
+ const byCheck = raw.openByCheck && typeof raw.openByCheck === 'object' ? raw.openByCheck : null;
+ let openByCheck = null;
+ if (byCheck) {
+ openByCheck = {};
+ for (const [k, v] of Object.entries(byCheck)) if (Number.isFinite(v)) openByCheck[k] = v;
+ }
return {
runId: typeof raw.runId === 'string' ? raw.runId : null,
at,
@@ -370,7 +377,13 @@ export function computeTrend(snapshots) {
// Score delta between the two most recent revisions (positive = improving).
const delta = latest && previous ? latest.score - previous.score : 0;
const regressions = regressionsBetween(latest, previous, 'openByCategory', 'category');
- const checkRegressions = regressionsBetween(latest, previous, 'openByCheck', 'checkId');
+ // Per-check regressions only when BOTH compared revisions carry per-check
+ // telemetry (openByCheck is a map, not the `null` no-telemetry sentinel) —
+ // otherwise an absent prior point would falsely read as all-zeros and flag
+ // every currently-open check as a 0→N regression after upgrade (#1597).
+ const checkRegressions = latest?.openByCheck && previous?.openByCheck
+ ? regressionsBetween(latest, previous, 'openByCheck', 'checkId')
+ : [];
return { points, regressions, checkRegressions, latest, previous, delta };
}
diff --git a/server/services/pipeline/editorialScore.test.js b/server/services/pipeline/editorialScore.test.js
index 213b71374a..b5dd9ac313 100644
--- a/server/services/pipeline/editorialScore.test.js
+++ b/server/services/pipeline/editorialScore.test.js
@@ -226,6 +226,25 @@ describe('computeTrend', () => {
]);
expect(trend.checkRegressions).toEqual([{ checkId: 'comic.prose-sync', from: 0, to: 2 }]);
});
+
+ it('does NOT flag per-check regressions when the prior snapshot predates per-check telemetry (no false 0→N spike)', () => {
+ // A pre-#1597 snapshot has no openByCheck map (sanitizes to null); comparing
+ // against it must not read as all-zeros and flag every open check.
+ const preUpgrade = {
+ runId: 'run-old', at: '2026-06-01T00:00:00Z', score: 88, ready: false, open: 2,
+ openBySeverity: { high: 0, medium: 2, low: 0 }, openByCategory: { naming: 2 },
+ // openByCheck intentionally absent
+ };
+ const trend = computeTrend([
+ preUpgrade,
+ snapWithChecks('2026-06-02T00:00:00Z', { 'naming.dissimilar-names': 2 }),
+ ]);
+ expect(trend.checkRegressions).toEqual([]);
+ // The new point still carries its per-check map for the sparkline.
+ expect(trend.points[1].openByCheck).toEqual({ 'naming.dissimilar-names': 2 });
+ // The old point's per-check telemetry is the explicit "unknown" sentinel.
+ expect(trend.points[0].openByCheck).toBeNull();
+ });
});
describe('ledger sanitization', () => {
@@ -244,10 +263,17 @@ describe('ledger sanitization', () => {
expect(ledger.seriesId).toBe('ser-abc');
});
- it('defaults openByCheck to {} for a pre-#1597 snapshot that predates per-check tracking', () => {
+ it('preserves an absent openByCheck as null (not {}) so pre-#1597 snapshots read as "no telemetry", not "zero findings"', () => {
const ledger = __testing.sanitizeLedger({
snapshots: [{ at: '2026-05-01T00:00:00Z', score: 88, openBySeverity: { high: 0, medium: 1, low: 0 }, openByCategory: { naming: 1 } }],
}, 'ser-old');
+ expect(ledger.snapshots[0].openByCheck).toBeNull();
+ });
+
+ it('keeps a present-but-empty openByCheck as {} (a run that found zero per-check findings is real telemetry)', () => {
+ const ledger = __testing.sanitizeLedger({
+ snapshots: [{ at: '2026-06-01T00:00:00Z', score: 100, openBySeverity: { high: 0, medium: 0, low: 0 }, openByCategory: {}, openByCheck: {} }],
+ }, 'ser-clean');
expect(ledger.snapshots[0].openByCheck).toEqual({});
});
});