Skip to content

Commit 7327ebc

Browse files
committed
test(calibration): invariant — live capture confidence VARIES with finding inputs (#8243 follow-up)
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).
1 parent 8e34212 commit 7327ebc

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/unit/configured-gate-blocker-signals.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,27 @@ describe("recordGateScoreSignals (#8223)", () => {
315315
).resolves.toBeUndefined();
316316
vi.restoreAllMocks();
317317
});
318+
319+
it("INVARIANT (#8243): recorded confidence VARIES with finding inputs — constant-confidence capture can never return silently", async () => {
320+
// The historical ledger's decision layer stamped 1.0 on every close while 38% reversed; the live
321+
// capture is the corpus the loops now act on, so this pins that its confidence axis is real: three
322+
// findings with three different confidences must record three different values, byte-for-byte.
323+
const env = createTestEnv();
324+
for (const [pr, confidence] of [[1, 0.55], [2, 0.72], [3, 0.97]] as const) {
325+
await recordConfiguredGateBlockerSignals(
326+
env,
327+
advisory([finding({ code: "ai_consensus_defect", confidence })]),
328+
blockAi,
329+
"acme/widgets",
330+
pr,
331+
{ aiReviewDiff: "diff --git a/x b/x" },
332+
);
333+
}
334+
const rows = await env.DB.prepare(
335+
"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",
336+
).all<{ target_key: string; c: number }>();
337+
const recorded = (rows.results ?? []).map((row) => row.c);
338+
expect(recorded).toEqual([0.55, 0.72, 0.97]);
339+
expect(new Set(recorded).size).toBe(3); // the axis varies — never a constant
340+
});
318341
});

0 commit comments

Comments
 (0)