Files
OmniRoute/tests/unit/release-acceptance-schema.test.ts
Bob.Hou 70e311703e ci(acceptance): emit a shadow release-acceptance report next to release-green (#13701) (#14066)
Adds a shadow release-acceptance report alongside release-green: an inventory/reduce/oracle pipeline under `scripts/quality/release-acceptance/` with a JSON schema, fixtures and a workflow that uploads the report as an artifact.

Contained by design, which is why it merges as-is: it runs only on push to `release/v*` and on manual dispatch (never on pull requests), the step is `continue-on-error`, `permissions: contents: read`, `persist-credentials: false`, and it consumes no secrets. Nothing in the product changes; the report is advisory until we decide to promote it.

Validated as a combined board first (this PR merged with the 11 siblings of the same batch on the release tip): eslint on every changed file with the suppressions file, typecheck:core, check:open-sse-typecheck, complexity, cognitive-complexity, changelog-integrity, i18n new-key coverage, docs-sync, migration-numbering, provider-consistency and a duplicate-identifier audit all green, plus 275 passing / 0 failing focused node:test cases across the 28 test files the batch touches. Then re-validated alone on the fresh tip before this merge: conflicts re-resolved, file sizes rebaselined for this PR's own growth, eslint and this PR's focused tests re-run.

Thanks @HouMinXi!

Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
2026-09-18 10:21:59 -03:00

113 lines
3.4 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import Ajv from "ajv";
const schema = JSON.parse(
readFileSync(
new URL("../../config/quality/release-acceptance.schema.json", import.meta.url),
"utf8"
)
);
function compile() {
const ajv = new Ajv({ allErrors: true, strict: false });
return ajv.compile(schema);
}
test("version 1 requires cause when status is classified by a prerequisite", () => {
const validate = compile();
const missingCause = JSON.parse(
readFileSync(
new URL("../fixtures/release-acceptance/failed-pack-boot.json", import.meta.url),
"utf8"
)
);
delete missingCause.gates[1].cause;
assert.equal(validate(missingCause), false);
});
test("unknown top-level gate field is invalid in version 1", () => {
const validate = compile();
const extra = JSON.parse(
readFileSync(
new URL("../fixtures/release-acceptance/verified.json", import.meta.url),
"utf8"
)
);
extra.gates[0].unexpected = true;
assert.equal(validate(extra), false);
});
test("evidence member rejects parent traversal", () => {
const validate = compile();
const report = JSON.parse(
readFileSync(new URL("../fixtures/release-acceptance/verified.json", import.meta.url), "utf8")
);
report.gates[0].evidence[0].member = "foo/../../etc/passwd";
assert.equal(validate(report), false);
report.gates[0].evidence[0].member = "..";
assert.equal(validate(report), false);
report.gates[0].evidence[0].member = "foo/..";
assert.equal(validate(report), false);
report.gates[0].evidence[0].member = String.raw`foo\..\x`;
assert.equal(validate(report), false);
});
test("empty required_gates cannot be VERIFIED", () => {
const validate = compile();
const report = JSON.parse(
readFileSync(new URL("../fixtures/release-acceptance/verified.json", import.meta.url), "utf8")
);
report.required_gates = [];
report.gates = [];
report.evidence_errors = [];
report.verdict = "VERIFIED";
assert.equal(validate(report), false);
});
test("empty required_gates is valid when UNVERIFIED", () => {
const validate = compile();
const report = JSON.parse(
readFileSync(new URL("../fixtures/release-acceptance/verified.json", import.meta.url), "utf8")
);
report.required_gates = [];
report.gates = [];
report.evidence_errors = [
{
code: "empty_required_set",
gate: { gate_id: "schema", suite_id: null, shard_index: null, shard_total: null },
detail: "required_gates is empty",
},
];
report.verdict = "UNVERIFIED";
assert.equal(validate(report), true, JSON.stringify(validate.errors));
});
test("unknown extensions field is invalid in version 1", () => {
const validate = compile();
const extra = JSON.parse(
readFileSync(
new URL("../fixtures/release-acceptance/verified.json", import.meta.url),
"utf8"
)
);
extra.gates[0].extensions = { unexpected: true };
assert.equal(validate(extra), false);
});
test("known-answer fixtures validate", () => {
const validate = compile();
for (const name of [
"verified.json",
"failed-pack-boot.json",
"unverified-required-skipped.json",
"infra-pack-boot.json",
]) {
const report = JSON.parse(
readFileSync(new URL(`../fixtures/release-acceptance/${name}`, import.meta.url), "utf8")
);
assert.equal(validate(report), true, `${name}: ${JSON.stringify(validate.errors)}`);
}
});