The signed review is per release candidate, so the merge gate could never pass. FE-GATE-009 now checks only the record format; the checked-in records are source-controlled evidence, not command output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.3 KiB
TypeScript
97 lines
3.3 KiB
TypeScript
import { mkdir, readFile } from "node:fs/promises";
|
|
|
|
import { manualA11yReportArtifactSchema } from "./contracts/release-artifacts.ts";
|
|
import {
|
|
MANUAL_A11Y_ROUTE_IDS,
|
|
validateManualA11yEvidence,
|
|
validateManualA11yRecordFormat,
|
|
} from "./lib/manual-a11y-evidence.ts";
|
|
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
|
|
|
|
type ManualA11yResult = Readonly<{
|
|
routeId: string;
|
|
path: string;
|
|
reviewer: string | null;
|
|
reviewedAt: string | null;
|
|
releaseId: string | null;
|
|
failures: readonly string[];
|
|
passed: boolean;
|
|
}>;
|
|
|
|
// 08-06: the signed review is a release-stage gate (FE-GATE-028). The merge
|
|
// stage (FE-GATE-009) runs `--format-only`: every route has a record in the
|
|
// template's shape, reviewed or not.
|
|
if (process.argv.includes("--format-only")) {
|
|
const failures: string[] = [];
|
|
for (const routeId of MANUAL_A11Y_ROUTE_IDS) {
|
|
const path = `artifacts/tests/a11y-manual/${routeId}.md`;
|
|
const record = await readFile(path, "utf8").catch(() => null);
|
|
const invalid = record === null ? ["missing record"] : validateManualA11yRecordFormat(record, routeId);
|
|
if (invalid.length > 0) failures.push(`${path}: ${invalid.join(", ")}`);
|
|
}
|
|
if (failures.length > 0) {
|
|
process.stderr.write(`Manual accessibility record format is invalid:\n${failures.join("\n")}\n`);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(
|
|
`Manual accessibility record format: PASS (${MANUAL_A11Y_ROUTE_IDS.length} routes; signed review runs in FE-GATE-028)\n`,
|
|
);
|
|
process.exit(0);
|
|
}
|
|
|
|
const results: ManualA11yResult[] = [];
|
|
for (const routeId of MANUAL_A11Y_ROUTE_IDS) {
|
|
const path = `artifacts/tests/a11y-manual/${routeId}.md`;
|
|
const evidence = await readFile(path, "utf8");
|
|
const validation = validateManualA11yEvidence(evidence);
|
|
const failures =
|
|
validation.fields["Route ID"] === routeId
|
|
? validation.failures
|
|
: Object.freeze([...validation.failures, "Route ID mismatch"]);
|
|
results.push({
|
|
routeId,
|
|
path,
|
|
reviewer: validation.fields.Reviewer ?? null,
|
|
reviewedAt: validation.fields["Reviewed at"] ?? null,
|
|
releaseId: validation.fields["Release ID"] ?? null,
|
|
failures,
|
|
passed: validation.passed && failures.length === 0,
|
|
});
|
|
}
|
|
const releaseIds = new Set(
|
|
results.map((result) => result.releaseId).filter((releaseId): releaseId is string => Boolean(releaseId)),
|
|
);
|
|
const coherentRelease =
|
|
releaseIds.size === 1 && results.every((result) => Boolean(result.releaseId));
|
|
const passed =
|
|
results.every((result) => result.passed) &&
|
|
coherentRelease;
|
|
|
|
await mkdir("artifacts/tests/a11y-manual", { recursive: true });
|
|
await writeValidatedJsonArtifact({
|
|
path: "artifacts/tests/a11y-manual/report.json",
|
|
schema: manualA11yReportArtifactSchema,
|
|
value: {
|
|
schemaVersion: 1,
|
|
generatedAt: new Date().toISOString(),
|
|
scope: MANUAL_A11Y_ROUTE_IDS,
|
|
results,
|
|
coherentRelease,
|
|
passed,
|
|
},
|
|
});
|
|
|
|
if (!passed) {
|
|
const failures = results
|
|
.filter((result) => !result.passed)
|
|
.map((result) => `${result.routeId}: ${result.failures.join(", ")}`);
|
|
if (!coherentRelease) failures.push("release IDs do not match");
|
|
process.stderr.write(
|
|
`Manual accessibility evidence is incomplete:\n${failures.join("\n")}\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(
|
|
`Manual accessibility evidence: PASS (${results.length} routes)\n`,
|
|
);
|