frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Canceled after 0s
frontend-quality-gates / main / checker self-tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / static checks (pull_request) Canceled after 0s
frontend-quality-gates / merge / tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / browser tests (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Canceled after 0s
frontend-quality-gates / external-vulnerability-provider (pull_request) Canceled after 0s
frontend-quality-gates / external-provenance-provider (pull_request) Canceled after 0s
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Canceled after 0s
frontend-quality-gates / deploy-promoted-release (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Canceled after 0s
문제: json-schema 시험 「generates deterministic … detects drift」가 임시 폴더에 스키마 넷을 쓸 때 파일과 폴더를 fsync한다. 이 시험의 대부분이 fsync이고, 디스크가 바쁘면 시간이 크게 뛴다(desktop 89~1,075ms, CPU를 제한한 coverage 측정에서 7.4초). 이 시험은 생성한 바이트와 drift 판정을 보고, 내구성은 validated-json-artifact 시험이 본다. 기본 timeout 10초 아래라 자기 timeout도 없다. 고른 방법: `generateArtifactSchemas`가 writer를 받는다(기본은 지금의 `writeValidatedJsonArtifact`). 시험은 같은 검증·원자적 rename writer를 `createValidatedJsonArtifactWriter`로 만들고 sync만 뺀다. - 버린 대안: 시험에 timeout 선언. 시간을 줄이지 않고 흔들림을 덮는다. 위험·한계: 생성 명령과 check:artifact-schemas의 쓰기는 그대로다. 검증(desktop, 고치기 전·후 번갈아 3회, 부하 11~16): 89/1,075/98 → 36/48/35ms. coverage + CPU 소모 12개에서도 208~519 → 73~151ms. 시험 통과, check:artifact-schemas rc=0, check:types·eslint rc=0. 로그 /tmp/claude-gates/w2fe2-slow2·6/.
262 lines
8.2 KiB
TypeScript
262 lines
8.2 KiB
TypeScript
import { mkdtemp, open, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
import { generateArtifactSchemas } from "../../scripts/generate-artifact-schemas.ts";
|
|
import { assertMatchesJsonSchema } from "../../scripts/lib/json-schema.ts";
|
|
import { createValidatedJsonArtifactWriter } from "../../scripts/lib/validated-json-artifact.ts";
|
|
|
|
// The same validated, atomic-rename writer as the generator's default, without
|
|
// fsync. This suite checks generated bytes in a temporary root; durability is
|
|
// validated-json-artifact.test.ts's subject, and the fsync pairs were most of
|
|
// this test's time under the parallel suite's disk load.
|
|
const writeArtifactWithoutSync = createValidatedJsonArtifactWriter({
|
|
fileSystem: {
|
|
open: async (target, flags, mode) => {
|
|
const handle = await open(target, flags, mode);
|
|
return {
|
|
writeFile: async (data, encoding) => handle.writeFile(data, encoding),
|
|
sync: async () => undefined,
|
|
close: async () => handle.close(),
|
|
};
|
|
},
|
|
openDirectory: async () => ({
|
|
sync: async () => undefined,
|
|
close: async () => undefined,
|
|
}),
|
|
rename: async (source, destination) => rename(source, destination),
|
|
rm: async (target, options) => rm(target, options),
|
|
},
|
|
});
|
|
|
|
const temporaryDirectories: string[] = [];
|
|
|
|
async function temporaryDirectory(): Promise<string> {
|
|
const directory = await mkdtemp(path.join(tmpdir(), "artifact-schemas-"));
|
|
temporaryDirectories.push(directory);
|
|
return directory;
|
|
}
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(
|
|
temporaryDirectories.splice(0).map((directory) =>
|
|
rm(directory, { force: true, recursive: true }),
|
|
),
|
|
);
|
|
});
|
|
|
|
async function json(path: string): Promise<unknown> {
|
|
return JSON.parse(await readFile(path, "utf8")) as unknown;
|
|
}
|
|
|
|
describe("checked-in JSON Schema execution", () => {
|
|
it("accepts a build manifest and rejects undeclared output fields", async () => {
|
|
const schema = await json("config/schemas/artifacts/build-manifest.schema.json");
|
|
const manifest = {
|
|
schemaVersion: 1,
|
|
buildId: "build-1",
|
|
commitSha: "commit-1",
|
|
releaseId: "release-1",
|
|
moduleInventoryHash: "inventory-hash",
|
|
generatedAt: "2026-08-01T00:00:00.000Z",
|
|
buildContext: {
|
|
nodeVersion: "v24.11.0",
|
|
packageManagerVersion: "11.17.0",
|
|
runnerImage: "test-runner",
|
|
sourceDateEpoch: null,
|
|
},
|
|
outputs: {
|
|
directory: "dist",
|
|
viteManifest: "dist/.vite/manifest.json",
|
|
moduleInventory: "artifacts/quality/vite-module-inventory.json",
|
|
routeChunks: { home: "assets/home.js" },
|
|
runtimeConfigSchema: "dist/runtime-config.schema.json",
|
|
},
|
|
};
|
|
|
|
expect(() =>
|
|
assertMatchesJsonSchema(schema, manifest, "build manifest"),
|
|
).not.toThrow();
|
|
expect(() =>
|
|
assertMatchesJsonSchema(
|
|
schema,
|
|
{ ...manifest, undocumented: true },
|
|
"build manifest",
|
|
),
|
|
).toThrow(/checked-in JSON Schema/u);
|
|
});
|
|
|
|
it("resolves local schema definitions in the recipe catalog", async () => {
|
|
const [schema, catalog] = await Promise.all([
|
|
json("config/schemas/recipes/frontend-capability-recipes.schema.json"),
|
|
json("config/recipes/frontend-capability-recipes.json"),
|
|
]);
|
|
|
|
expect(() =>
|
|
assertMatchesJsonSchema(schema, catalog, "optional recipe catalog"),
|
|
).not.toThrow();
|
|
});
|
|
|
|
it("generates deterministic draft 2020-12 artifact schemas and detects drift", async () => {
|
|
const root = await temporaryDirectory();
|
|
await generateArtifactSchemas({ root, writeArtifact: writeArtifactWithoutSync });
|
|
const generatedPath = path.join(
|
|
root,
|
|
"config/schemas/artifacts/dependency-inventory.schema.json",
|
|
);
|
|
const generated = await readFile(generatedPath, "utf8");
|
|
expect(generated.endsWith("\n")).toBe(true);
|
|
expect(JSON.parse(generated)).toMatchObject({
|
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
type: "object",
|
|
additionalProperties: false,
|
|
});
|
|
|
|
await generateArtifactSchemas({ root, check: true });
|
|
await writeFile(generatedPath, `${generated.trimEnd()} \n`, "utf8");
|
|
|
|
await expect(
|
|
generateArtifactSchemas({ root, check: true }),
|
|
).rejects.toThrow(/dependency-inventory\.schema\.json/u);
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
name: "dependency inventory",
|
|
path: "config/schemas/artifacts/dependency-inventory.schema.json",
|
|
value: {
|
|
schemaVersion: 2,
|
|
packageManager: "pnpm@11.17.0",
|
|
lockfileSha256: "a".repeat(64),
|
|
dependencyCount: 1,
|
|
directDependencyCount: 1,
|
|
dependencies: [
|
|
{
|
|
name: "zod",
|
|
version: "4.4.3",
|
|
direct: true,
|
|
scope: "production",
|
|
optional: false,
|
|
license: "MIT",
|
|
integrity: `sha512-${"a".repeat(86)}`,
|
|
dependencies: [],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
name: "registry snapshot",
|
|
path: "config/schemas/artifacts/registry-snapshot.schema.json",
|
|
value: {
|
|
schemaVersion: 2,
|
|
generatedAt: "2026-08-01T00:00:00.000Z",
|
|
baselineDigest: "b".repeat(64),
|
|
currentDigest: "c".repeat(64),
|
|
compatibility: { impact: "none", changes: [] },
|
|
failures: [],
|
|
registries: Array.from({ length: 11 }, (_, index) => ({
|
|
registryId: `registry-${index}`,
|
|
owner: "platform",
|
|
source: `src/registry-${index}.ts`,
|
|
rowCount: 0,
|
|
contract: {},
|
|
rows: {},
|
|
})),
|
|
},
|
|
},
|
|
{
|
|
name: "supply-chain verification",
|
|
path: "config/schemas/artifacts/supply-chain-verification.schema.json",
|
|
value: {
|
|
schemaVersion: 1,
|
|
localStatus: "PASS",
|
|
promotionStatus: "FAIL_UNVERIFIED",
|
|
lockfileSha256: "d".repeat(64),
|
|
sourceSetSha256: "e".repeat(64),
|
|
distSha256: "f".repeat(64),
|
|
sbomSha256: "0".repeat(64),
|
|
dependencyDiff: {
|
|
added: [],
|
|
removed: [],
|
|
changed: [],
|
|
upgrades: [],
|
|
},
|
|
highRiskReview: [],
|
|
vulnerabilityStatus: "FAIL_UNVERIFIED",
|
|
provenanceAttestationStatus: "FAIL_UNVERIFIED",
|
|
failures: [],
|
|
},
|
|
},
|
|
])("accepts $name and rejects undeclared top-level fields", async (fixture) => {
|
|
const schema = await json(fixture.path);
|
|
|
|
expect(() =>
|
|
assertMatchesJsonSchema(schema, fixture.value, fixture.name),
|
|
).not.toThrow();
|
|
expect(() =>
|
|
assertMatchesJsonSchema(
|
|
schema,
|
|
{ ...fixture.value, undocumented: true },
|
|
fixture.name,
|
|
),
|
|
).toThrow(/checked-in JSON Schema/u);
|
|
if (fixture.name === "dependency inventory") {
|
|
const dependency = fixture.value.dependencies?.[0];
|
|
if (dependency === undefined) {
|
|
throw new TypeError("dependency inventory fixture is incomplete");
|
|
}
|
|
expect(() =>
|
|
assertMatchesJsonSchema(
|
|
schema,
|
|
{
|
|
...fixture.value,
|
|
dependencies: [
|
|
{
|
|
...dependency,
|
|
undocumented: true,
|
|
},
|
|
],
|
|
},
|
|
fixture.name,
|
|
),
|
|
).toThrow(/checked-in JSON Schema/u);
|
|
expect(() =>
|
|
assertMatchesJsonSchema(
|
|
schema,
|
|
{
|
|
...fixture.value,
|
|
dependencyCount: 0,
|
|
directDependencyCount: 0,
|
|
dependencies: [],
|
|
},
|
|
fixture.name,
|
|
),
|
|
).toThrow(/checked-in JSON Schema/u);
|
|
}
|
|
if (fixture.name === "registry snapshot") {
|
|
expect(() =>
|
|
assertMatchesJsonSchema(
|
|
schema,
|
|
{ ...fixture.value, failures: [], registries: [] },
|
|
fixture.name,
|
|
),
|
|
).toThrow(/checked-in JSON Schema/u);
|
|
expect(() =>
|
|
assertMatchesJsonSchema(
|
|
schema,
|
|
{
|
|
...fixture.value,
|
|
baselineDigest: null,
|
|
compatibility: { impact: "not-evaluated", changes: [] },
|
|
failures: ["missing registry source"],
|
|
registries: [],
|
|
},
|
|
fixture.name,
|
|
),
|
|
).not.toThrow();
|
|
}
|
|
});
|
|
});
|