From 7327ebcabbda3228801d4a8c6a70de73deafcc4e Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Thu, 23 Jul 2026 08:57:31 -0700 Subject: [PATCH] =?UTF-8?q?test(calibration):=20invariant=20=E2=80=94=20li?= =?UTF-8?q?ve=20capture=20confidence=20VARIES=20with=20finding=20inputs=20?= =?UTF-8?q?(#8243=20follow-up)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The historical ledger's decision layer stamped a constant 1.0 on every close while 38% reversed. The live capture writers are the corpus the armed loops now act on, so this pins that their confidence axis is real: three findings with three confidences must record three distinct values, byte-for-byte. A regression to constant-confidence capture — the exact failure mode #8243 documented — can no longer land silently. Honors the surviving requirement from #8243's reconciled scope (the gate review on its closing PR correctly noted the literal scope had been reframed; this is the piece that still applied, pointed at the live path). --- .../configured-gate-blocker-signals.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/unit/configured-gate-blocker-signals.test.ts b/test/unit/configured-gate-blocker-signals.test.ts index f050b0403..c88560930 100644 --- a/test/unit/configured-gate-blocker-signals.test.ts +++ b/test/unit/configured-gate-blocker-signals.test.ts @@ -315,4 +315,27 @@ describe("recordGateScoreSignals (#8223)", () => { ).resolves.toBeUndefined(); vi.restoreAllMocks(); }); + + it("INVARIANT (#8243): recorded confidence VARIES with finding inputs — constant-confidence capture can never return silently", async () => { + // The historical ledger's decision layer stamped 1.0 on every close while 38% reversed; the live + // capture is the corpus the loops now act on, so this pins that its confidence axis is real: three + // findings with three different confidences must record three different values, byte-for-byte. + const env = createTestEnv(); + for (const [pr, confidence] of [[1, 0.55], [2, 0.72], [3, 0.97]] as const) { + await recordConfiguredGateBlockerSignals( + env, + advisory([finding({ code: "ai_consensus_defect", confidence })]), + blockAi, + "acme/widgets", + pr, + { aiReviewDiff: "diff --git a/x b/x" }, + ); + } + const rows = await env.DB.prepare( + "SELECT target_key, json_extract(metadata_json, '$.confidence') AS c FROM audit_events WHERE event_type = 'signal.rule_fired:ai_consensus_defect' ORDER BY target_key", + ).all<{ target_key: string; c: number }>(); + const recorded = (rows.results ?? []).map((row) => row.c); + expect(recorded).toEqual([0.55, 0.72, 0.97]); + expect(new Set(recorded).size).toBe(3); // the axis varies — never a constant + }); });