feat: reuse verified delivery evidence when landing

This commit is contained in:
Simon Altit PA 2026-07-11 15:20:48 +01:00
parent 11de390be1
commit 3b675a0996
2 changed files with 42 additions and 1 deletions

View File

@ -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.

View File

@ -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");
});