From 3b675a0996d17c6ad6c7457eb4ef6e524598d0ec Mon Sep 17 00:00:00 2001 From: Simon Altit PA Date: Sat, 11 Jul 2026 15:20:48 +0100 Subject: [PATCH] feat: reuse verified delivery evidence when landing --- land-and-deploy/SKILL.md.tmpl | 25 ++++++++++++++++++- .../land-and-deploy-delivery-evidence.test.ts | 18 +++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/land-and-deploy-delivery-evidence.test.ts diff --git a/land-and-deploy/SKILL.md.tmpl b/land-and-deploy/SKILL.md.tmpl index 98976ad02..763246398 100644 --- a/land-and-deploy/SKILL.md.tmpl +++ b/land-and-deploy/SKILL.md.tmpl @@ -449,7 +449,30 @@ and tell the user: "I found and fixed a few issues during the review. The fixes ### 3.5b: Test results -**Free tests — run them now:** +**Delivery evidence hook — check before free tests:** + +If the repository root `package.json` defines `scripts.delivery:verify-landing`, +run the opt-in verifier using the PR number identified in Step 1: + +```bash +HOOK_OUTPUT=$(pnpm delivery:verify-landing -- --pr "$PR_NUMBER" --output json 2>&1) +HOOK_EXIT=$? +HOOK_JSON=$(printf '%s\n' "$HOOK_OUTPUT" | sed -n '/^{/p' | tail -1) +HOOK_STATUS=$(printf '%s' "$HOOK_JSON" | jq -r '.status // empty' 2>/dev/null) +``` + +- If the command exits successfully and its only decision is + `{"status":"reusable"}`, report the evidence code and skip the normal local + test command. The current Process Guard evidence already proves the exact PR + head/base/merge and validation check. +- If the command is missing, preserve legacy test behavior and run the normal + test command below. +- If the command exits non-zero, emits invalid JSON, or emits any other status, + **BLOCKER `DELIVERY_EVIDENCE_HOOK_FAILED`:** report the returned code/output + and recovery guidance. Do not fall back to the normal test command, because a malformed or stale proof must + never become an implicit test bypass. + +**Free tests — run them now when the evidence hook is absent:** Read CLAUDE.md to find the project's test command. If not specified, use `bun test`. Run the test command and capture the exit code and output. diff --git a/test/land-and-deploy-delivery-evidence.test.ts b/test/land-and-deploy-delivery-evidence.test.ts new file mode 100644 index 000000000..92a2b8496 --- /dev/null +++ b/test/land-and-deploy-delivery-evidence.test.ts @@ -0,0 +1,18 @@ +import { expect, test } from "bun:test"; +import fs from "node:fs"; +import path from "node:path"; + +const ROOT = path.resolve(import.meta.dir, ".."); +const TEMPLATE = path.join(ROOT, "land-and-deploy", "SKILL.md.tmpl"); + +test("land-and-deploy reuses only explicit reusable delivery evidence", () => { + const content = fs.readFileSync(TEMPLATE, "utf8"); + + expect(content).toContain("delivery:verify-landing"); + expect(content).toContain('"status":"reusable"'); + expect(content).toContain("--pr"); + expect(content).toContain("--output json"); + expect(content).toContain("DELIVERY_EVIDENCE_HOOK_FAILED"); + expect(content).toContain("Do not fall back to the normal test command"); + expect(content).toContain("legacy test behavior"); +});