Skip to content

Commit 9794a4a

Browse files
authored
fix(release): bind reusable evidence verifier source (#123115)
1 parent 8d46e23 commit 9794a4a

2 files changed

Lines changed: 68 additions & 10 deletions

File tree

‎scripts/github/find-reusable-release-validation.sh‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,27 @@ for ((index = 0; index < run_count; index += 1)); do
191191
--validate-run "$run_id" \
192192
--repo "$REPO" \
193193
--trusted-workflow-ref main \
194+
--verifier-source-sha "$VERIFIER_WORKFLOW_SHA" \
195+
--verifier-source-file "$VALIDATOR" \
194196
--json
195197
)"; then
196-
echo "[evidence-reuse] run ${run_id}: shared evidence validator rejected the run; skipping" >&2
198+
validator_error="$(
199+
jq -r '
200+
if (.error | type) == "string" then
201+
.error
202+
| gsub("[\\r\\n\\t ]+"; " ")
203+
| gsub("^ +| +$"; "")
204+
| if length > 500 then .[0:497] + "..." else . end
205+
else
206+
empty
207+
end
208+
' <<< "$validation_record" 2>/dev/null || true
209+
)"
210+
if [[ -n "$validator_error" ]]; then
211+
echo "[evidence-reuse] run ${run_id}: shared evidence validator rejected the run: ${validator_error}; skipping" >&2
212+
else
213+
echo "[evidence-reuse] run ${run_id}: shared evidence validator rejected the run; skipping" >&2
214+
fi
197215
continue
198216
fi
199217
if ! jq -e \

‎test/scripts/find-reusable-release-validation.test.ts‎

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ interface NormalizedEvidence {
112112
}
113113

114114
interface RunFixture {
115+
error?: string;
115116
exitCode?: number;
117+
rawOutput?: string;
116118
record?: NormalizedEvidence;
117119
runId: string;
118120
}
@@ -402,12 +404,19 @@ import { join } from "node:path";
402404
const runIndex = process.argv.indexOf("--validate-run");
403405
const repoIndex = process.argv.indexOf("--repo");
404406
const trustedRefIndex = process.argv.indexOf("--trusted-workflow-ref");
407+
const verifierShaIndex = process.argv.indexOf("--verifier-source-sha");
408+
const verifierFileIndex = process.argv.indexOf("--verifier-source-file");
405409
if (
406410
runIndex < 0 ||
407411
repoIndex < 0 ||
408412
trustedRefIndex < 0 ||
413+
verifierShaIndex < 0 ||
414+
verifierFileIndex < 0 ||
409415
process.argv[repoIndex + 1] !== "openclaw/openclaw" ||
410-
process.argv[trustedRefIndex + 1] !== "main"
416+
process.argv[trustedRefIndex + 1] !== "main" ||
417+
process.argv[verifierShaIndex + 1] !== process.env.FAKE_VERIFIER_SHA ||
418+
process.argv[verifierFileIndex + 1] !== process.argv[1] ||
419+
!process.argv.includes("--json")
411420
) {
412421
console.error("validator invocation contract mismatch");
413422
process.exit(2);
@@ -416,7 +425,13 @@ const fixture = JSON.parse(
416425
readFileSync(join(process.env.FAKE_VALIDATOR_FIXTURES, \`\${process.argv[runIndex + 1]}.json\`), "utf8"),
417426
);
418427
if (fixture.exitCode) {
419-
console.error("fixture validator rejection");
428+
process.stdout.write(
429+
\`\${fixture.rawOutput ?? JSON.stringify({
430+
error: fixture.error ?? "fixture validator rejection",
431+
schema: "openclaw.release-validation-evidence/v3",
432+
valid: false,
433+
})}\\n\`,
434+
);
420435
process.exit(fixture.exitCode);
421436
}
422437
process.stdout.write(\`\${JSON.stringify(fixture.record)}\\n\`);
@@ -449,10 +464,7 @@ function setUpFixtures(runs: RunFixture[]): {
449464
JSON.stringify({ workflow_runs: runs.map(({ runId }) => ({ id: Number(runId) })) }),
450465
);
451466
for (const run of runs) {
452-
writeFileSync(
453-
join(fixtures, `${run.runId}.json`),
454-
JSON.stringify({ exitCode: run.exitCode ?? 0, record: run.record }),
455-
);
467+
writeFileSync(join(fixtures, `${run.runId}.json`), JSON.stringify(run));
456468
}
457469
return { binDir, fixtures, validatorPath };
458470
}
@@ -531,6 +543,7 @@ function runResolver(args: {
531543
...process.env,
532544
FAKE_GH_FIXTURES: args.fixtures,
533545
FAKE_VALIDATOR_FIXTURES: args.fixtures,
546+
FAKE_VERIFIER_SHA: verifierSha,
534547
GITHUB_OUTPUT: "",
535548
OPENCLAW_RELEASE_CI_SUMMARY_VALIDATOR: args.validatorPath,
536549
PATH: `${args.binDir}:${process.env.PATH}`,
@@ -714,11 +727,12 @@ describe("scripts/github/find-reusable-release-validation.sh", () => {
714727
expect(parseOutput(result.stdout)).toMatchObject({ reuse: "true" });
715728
});
716729

717-
it("skips validator rejection and selects the next strict record", () => {
730+
it("surfaces bounded validator rejection and selects the next strict record", () => {
718731
const { clone, priorSha } = getSharedRepo();
719732
const record = normalizedEvidence({ runId: "111", targetSha: priorSha });
733+
const validatorError = `evidence source mismatch\n${"x".repeat(600)}`;
720734
const { binDir, fixtures, validatorPath } = setUpFixtures([
721-
{ exitCode: 1, runId: "222" },
735+
{ error: validatorError, exitCode: 1, runId: "222" },
722736
{ record, runId: "111" },
723737
]);
724738

@@ -732,7 +746,33 @@ describe("scripts/github/find-reusable-release-validation.sh", () => {
732746

733747
expect(result.status).toBe(0);
734748
expect(parseOutput(result.stdout)).toMatchObject({ evidence_run_id: "111", reuse: "true" });
735-
expect(result.stderr).toContain("run 222: shared evidence validator rejected the run");
749+
expect(result.stderr).toContain(
750+
`run 222: shared evidence validator rejected the run: evidence source mismatch ${"x".repeat(472)}...; skipping`,
751+
);
752+
expect(result.stderr).not.toContain("\nxxxxxxxx");
753+
});
754+
755+
it("uses the generic rejection diagnostic when validator output is malformed", () => {
756+
const { clone, priorSha } = getSharedRepo();
757+
const record = normalizedEvidence({ runId: "111", targetSha: priorSha });
758+
const { binDir, fixtures, validatorPath } = setUpFixtures([
759+
{ exitCode: 1, rawOutput: "not-json", runId: "222" },
760+
{ record, runId: "111" },
761+
]);
762+
763+
const result = runResolver({
764+
binDir,
765+
fixtures,
766+
repoDir: clone,
767+
targetSha: priorSha,
768+
validatorPath,
769+
});
770+
771+
expect(result.status).toBe(0);
772+
expect(parseOutput(result.stdout)).toMatchObject({ evidence_run_id: "111", reuse: "true" });
773+
expect(result.stderr).toContain(
774+
"run 222: shared evidence validator rejected the run; skipping",
775+
);
736776
});
737777

738778
it.each([

0 commit comments

Comments
 (0)