From 994e906a9f1fe3a00b8668bfc8aa6c5b349a022c Mon Sep 17 00:00:00 2001 From: Postil Maintainer Date: Wed, 12 Aug 2026 00:56:17 +0000 Subject: [PATCH] Guard benchmark baseline authority --- Cargo.lock | 2 +- Cargo.toml | 2 +- bench/baseline.json | 2 +- bench/src/compare-baseline.test.ts | 20 ++++++++++++++++++++ bench/src/live.ts | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 064f566..cbf060a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1104,7 +1104,7 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "postil-cli" -version = "0.8.9" +version = "0.8.10" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 1f1772b..7e54932 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "postil-cli" -version = "0.8.9" +version = "0.8.10" edition = "2024" description = "Postil: a low-noise AI review gate. Silent on clean PRs, hard gate on real risk." license = "Apache-2.0" diff --git a/bench/baseline.json b/bench/baseline.json index 9abd690..dfcaf7a 100644 --- a/bench/baseline.json +++ b/bench/baseline.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "corpus": { "fixtureCorpusSha256": "3c4f952f9411bf2c4e5f0a61b5975e47d203f7681a8235d53d717c743ea9cb54", - "evaluatorSha256": "64dd1975bd5743e15b073b8c6dbad91e37cef3388f793073b216d002de80d78a" + "evaluatorSha256": "b0d452b0c2f8d419ef6f4780791cde8cd760d318a82b439aa5746a226305e125" }, "profiles": { "z-ai/glm-5.2": { diff --git a/bench/src/compare-baseline.test.ts b/bench/src/compare-baseline.test.ts index 5ab4a32..9a7cf72 100644 --- a/bench/src/compare-baseline.test.ts +++ b/bench/src/compare-baseline.test.ts @@ -1,4 +1,8 @@ import { describe, expect, test } from "bun:test"; +import { createHash } from "node:crypto"; +import { readFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { cases } from "../fixtures/cases"; import { DETECTION_RATE_MAX_DROP_PP, FALSE_FINDINGS_MAX_INCREASE, @@ -12,6 +16,22 @@ import { type BaselineProfile, type LiveReportForComparison, } from "./compare-baseline"; +import { benchmarkCase } from "./harness"; +import { evaluatorSourceSha256 } from "./live"; + +test("committed baseline authority matches the current benchmark sources", async () => { + const baseline = JSON.parse( + await readFile(resolve(import.meta.dir, "..", "baseline.json"), "utf8"), + ) as { + corpus: { fixtureCorpusSha256: string; evaluatorSha256: string }; + }; + const fixtureCorpusSha256 = createHash("sha256") + .update(JSON.stringify(cases.map((input) => benchmarkCase.parse(input)))) + .digest("hex"); + + expect(baseline.corpus.fixtureCorpusSha256).toBe(fixtureCorpusSha256); + expect(baseline.corpus.evaluatorSha256).toBe(await evaluatorSourceSha256()); +}); function fakeReport(overrides: { falsePositives?: number; diff --git a/bench/src/live.ts b/bench/src/live.ts index 5437d78..c4a632c 100644 --- a/bench/src/live.ts +++ b/bench/src/live.ts @@ -380,7 +380,7 @@ async function screeningProfileMetadata(path: string): Promise<{ }; } -async function evaluatorSourceSha256(): Promise { +export async function evaluatorSourceSha256(): Promise { const benchRoot = resolve(fileURLToPath(import.meta.url), "..", ".."); const sources = [ "fixtures/cases.ts",