From cdb30e73a5a5fb76e2d3182943d26e7036d6f0fc Mon Sep 17 00:00:00 2001 From: rebuildup Date: Mon, 23 Nov 2026 18:30:48 +0900 Subject: [PATCH] feat(agent): record model and spec identity in review results (#231) The result JSON carried only the contract version, so a stored review could not be traced back to the model and criteria that produced it. Record the --model value (null for agy default) and the SHA-256 of the spec text on every result, including deferred/quota-exhausted paths and the Herdr inner run-file, which reconstructs spec and model from the materialized request. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- script/agent.agy-review.test.ts | 13 +++++++++++++ script/agent/agy-review.ts | 30 ++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/script/agent.agy-review.test.ts b/script/agent.agy-review.test.ts index 3bee8ea..de8dc85 100644 --- a/script/agent.agy-review.test.ts +++ b/script/agent.agy-review.test.ts @@ -279,6 +279,19 @@ describe("runLocal pipeline (stub agy)", () => { expect(existsSync(join(result.isolation.workdir, "inputs", "00-shot.png"))).toBe(true); }); + it("records model and spec identity for reproducible evidence (#231)", async () => { + const stub = makeStub("meta.sh", `cat <<'EOF'\n${VALID_ENVELOPE}\nEOF`); + const spec = "review this\nwith a newline"; + const result = await runAgyReview({ ...base(), spec, agyBin: stub, model: "claude-sonnet-5-5-high" }); + expect(result.model).toBe("claude-sonnet-5-5-high"); + const { createHash } = await import("node:crypto"); + expect(result.specSha256).toBe(createHash("sha256").update(spec, "utf8").digest("hex")); + + const noModel = await runAgyReview({ ...base(), agyBin: stub }); + expect(noModel.model).toBeNull(); + expect(noModel.specSha256).toBe(createHash("sha256").update("review this", "utf8").digest("hex")); + }); + it("recovers the verdict when the response duplicates the JSON object", async () => { // Observed with claude-sonnet-5-5-high: agy returns two complete verdict // objects concatenated; the last one is the final answer (#227). diff --git a/script/agent/agy-review.ts b/script/agent/agy-review.ts index 06f1991..70143c6 100644 --- a/script/agent/agy-review.ts +++ b/script/agent/agy-review.ts @@ -23,7 +23,7 @@ * the structured verdict. */ -import { randomUUID } from "node:crypto"; +import { createHash, randomUUID } from "node:crypto"; import { copyFileSync, existsSync, @@ -77,6 +77,10 @@ export type ReviewClassification = export interface AgyReviewResult { version: string; id: string; + /** Model id passed via --model, or null when agy picked the default. */ + model: string | null; + /** SHA-256 of the review spec text — the criteria version actually used. */ + specSha256: string; classification: ReviewClassification; /** True only when every verification layer passed and a valid verdict exists. */ verified: boolean; @@ -680,10 +684,24 @@ function emptyReadonly(protectedPath: string | null): AgyReviewResult["readonly" }; } -function baseResult(id: string, workdir: string, osSandbox: AgyReviewResult["isolation"]["osSandbox"], executor: "local" | "herdr", protectedPath: string | null): AgyReviewResult { +interface ReviewMeta { + model: string | null; + specSha256: string; +} + +function reviewMeta(opts: AgyReviewOptions, spec: string): ReviewMeta { + return { + model: opts.model ?? null, + specSha256: createHash("sha256").update(spec, "utf8").digest("hex"), + }; +} + +function baseResult(id: string, workdir: string, osSandbox: AgyReviewResult["isolation"]["osSandbox"], executor: "local" | "herdr", protectedPath: string | null, meta: ReviewMeta): AgyReviewResult { return { version: AGY_REVIEW_VERSION, id, + model: meta.model, + specSha256: meta.specSha256, classification: "executor-error", verified: false, verdict: null, @@ -781,7 +799,7 @@ export async function runAgyReview(opts: AgyReviewOptions): Promise { const workdir = prepareWorkdir(id); - const result = baseResult(id, workdir, "unsupported", "herdr", protectPath); + const result = baseResult(id, workdir, "unsupported", "herdr", protectPath, reviewMeta(opts, spec)); // Materialize inputs so the pane command only needs flags, not big payloads. const imagePaths: string[] = [];