문제: 코드 주석 87곳(74파일, .dependency-cruiser.json 포함)이 "Spec §N" 처럼 문서 이름 없이 절 번호만 적는다(대문자 83, 소문자 "spec §" 4). 가리키는 설계서는 README가 복사 뒤 지워도 된다고 한 docs/reviews/ 안에 있었다. 지울 수 있는 기록 검사는 경로 문자열만 찾아 이 참조를 잡지 못했다. 현재 계약 문서도 지울 수 있는 파일로 링크한다: docs/reviews/adapters/INVENTORY.md 145행이 옆의 adapter 리뷰로, docs/operations/adapter-remediation-ledger.md가 adapter 리뷰와 docs/superpowers/plans의 계획으로. 고른 방법: - 주석의 "Spec §"/"spec §"를 "scale-architecture.md §"로 바꾼다(앞 커밋이 옮긴 docs/architecture/scale-architecture.md). 설명 문장과 절 번호는 그대로다. 절 번호가 없는 "Spec §"는 없었다. - tests/unit/deletable-history-documents.test.ts에 "spec" + 선택 공백 + "§"(대소문자 무시)를 거부하는 검사를 더하고, 검사 대상에 .dependency-cruiser.json을 넣는다. - README "Files you can delete after copying"에서 INVENTORY.md 한 파일 대신 docs/reviews/adapters/ 폴더를 남기게 하고 이유(INVENTORY 행과 ledger가 그 리뷰로 링크한다)를 적는다. docs/README.md §3도 같게 고친다. INVENTORY의 행 구조는 바꾸지 않는다. - 남긴 adapter 리뷰와 ledger가 docs/superpowers/plans로 거는 링크 5곳은 링크를 풀고 "작업 이력 계획, 복사본은 지울 수 있다"로 적는다. 버린 대안: INVENTORY 145칸의 링크를 그룹 이름으로 바꾸기. 템플릿에서도 상세 리뷰로 가는 길이 없어지고 수정이 145곳이다. 계획 3개도 지우기 목록에서 빼기. 지울 수 있는 폴더 안에 예외가 흩어지고, 계획이 다시 다른 이력을 가리키면 남길 목록이 계속 커진다. 위험·한계: 검사는 "HTML spec §4"처럼 다른 명세를 "spec §"로 부르는 주석도 거부한다. 그때는 "HTML Standard §4"처럼 이름을 쓴다. src/contracts/storage-keys.ts:79의 "release-coherence plan Task 6"처럼 이름 없는 계획 참조는 이 검사가 잡지 않는다. 복사한 프로젝트가 이미 docs/reviews/adapters/를 지웠다면 링크는 계속 끊겨 있다. CHANGELOG.md의 이력 언급 4곳(:15 두 경로, :75 PRODUCT.md, :93)은 고치지 않았다. check:remediation-ledger는 이 변경 전후 같은 4줄로 실패한다(이미 있던 실패, 게이트 밖). tests/unit/telemetry.test.ts의 describe 이름 하나가 바뀐다. 검증: - RED: 치환 전 새 검사가 87줄을 들어 실패(1 failed | 1 passed). - GREEN: 같은 테스트 2 passed. 변이 "// Spec §4. budgets live here"를 src/platform/errors/app-error.ts에 넣으면 그 한 줄로 실패, 되돌림. - 치환 diff: 바뀐 87줄 쌍이 토큰 외에 같음(스크립트 대조, 불일치 0). - 삭제 실험(작업 트리 복사본에서 README 목록대로 지움): 끊긴 링크 148→0, 끊긴 경로 언급 10→4(남은 4는 CHANGELOG.md), 이름 없는 설계 참조 87→0, scale-architecture.md §N 87곳 중 없는 절 0. 같은 복사본에서 verify-documentation-readiness PASS_SCOPED, 지울 수 있는 기록 테스트 2 passed. - node scripts/verify-documentation-readiness.ts: PASS_SCOPED - node scripts/check-adapter-inventory.ts: PASS - node scripts/run-vitest.ts run tests/unit/deletable-history-documents.test.ts tests/unit/documentation-readiness.test.ts tests/unit/telemetry.test.ts: 50 passed. tests/architecture: 39 passed. - npx tsc --noEmit (app·node·test): 모두 통과. 바꾼 TS 74파일 eslint 통과. .dependency-cruiser.json JSON 파싱 통과. - 미실행: check:architecture(pnpm 필요).
196 lines
7.0 KiB
TypeScript
196 lines
7.0 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
/**
|
|
* scale-architecture.md §47. Execution tiers for the scale/chaos/soak program.
|
|
*
|
|
* pr architecture and traffic invariants, S0-S2 composition growth
|
|
* main pr + TypeScript diagnostics and the stored baseline regression
|
|
* gate (config/scale/benchmark-baseline.json)
|
|
* nightly main + S3/S4 topology, telemetry storm, session cycles, browser soak
|
|
* release release-coherence matrix + the stable main/nightly subset
|
|
*
|
|
* Only `pr` runs in CI (merge gate FE-GATE-005, 11-03). Its checks are counts,
|
|
* bounds and growth shape, so they hold on any CPU; the composition timings it
|
|
* writes are advisory. `main`, `nightly` and `release` include
|
|
* `baseline-regression`, which compares timings only on the CPU model that
|
|
* recorded config/scale/benchmark-baseline.json and is `incomplete` elsewhere,
|
|
* so no CI job runs them; they are local commands for that machine.
|
|
*
|
|
* Every step's output goes to artifacts/scale/<tier>/<step>.log and the tier
|
|
* writes one machine-readable summary.json. A step that could not run (e.g. a
|
|
* browser soak without a build or browser) is `skipped`, and a tier with any
|
|
* skipped step is `incomplete`: it is never reported as passed and exits
|
|
* non-zero. `SCALE_ALLOW_INCOMPLETE=1` keeps the exit code zero for local runs,
|
|
* but the summary still says `incomplete`.
|
|
*/
|
|
export type ScaleTier = "pr" | "main" | "nightly" | "release";
|
|
|
|
type Step = Readonly<{
|
|
id: string;
|
|
command: readonly string[];
|
|
/** A step that may legitimately report `skipped` in its own artifact. */
|
|
optional?: boolean;
|
|
}>;
|
|
|
|
const VITEST = ["scripts/run-vitest.ts", "run", "--reporter=default"];
|
|
|
|
const PR_STEPS: readonly Step[] = [
|
|
{
|
|
id: "architecture-topology",
|
|
command: [...VITEST, "tests/architecture", "tests/platform/cardinality", "tests/platform/routing"],
|
|
},
|
|
{
|
|
id: "traffic-budgets",
|
|
command: [...VITEST, "tests/platform/execution", "tests/platform/traffic", "tests/platform/resilience"],
|
|
},
|
|
{
|
|
id: "scale-units",
|
|
command: [
|
|
...VITEST,
|
|
"tests/scale/growth-regression.test.ts",
|
|
"tests/scale/benchmark.test.ts",
|
|
"tests/scale/synthetic-topology.test.ts",
|
|
"tests/scale/scale-baseline.test.ts",
|
|
"tests/scale/traffic",
|
|
],
|
|
},
|
|
// 11-03: S2 is included because below it every workload stays under the
|
|
// noise floor, so a quadratic accumulation passed S0/S1 unnoticed.
|
|
{
|
|
id: "composition-s0-s2",
|
|
command: ["scripts/scale/run-composition-scale.ts", "--profiles=S0,S1,S2"],
|
|
},
|
|
];
|
|
|
|
const MAIN_STEPS: readonly Step[] = [
|
|
...PR_STEPS,
|
|
{
|
|
id: "composition-scale-suite",
|
|
command: [...VITEST, "tests/scale/composition-scale.test.ts", "tests/scale/tsc-diagnostics-parser.test.ts"],
|
|
},
|
|
{
|
|
id: "typescript-diagnostics",
|
|
command: ["scripts/scale/collect-tsc-diagnostics.ts", "--local-sizes=25,100,400"],
|
|
},
|
|
{
|
|
id: "baseline-regression",
|
|
command: ["scripts/scale/check-scale-baseline.ts"],
|
|
},
|
|
];
|
|
|
|
const NIGHTLY_STEPS: readonly Step[] = [
|
|
...MAIN_STEPS,
|
|
{
|
|
id: "topology-s3-s4",
|
|
command: [...VITEST, "tests/scale/global-local-independence.test.ts", "tests/platform/cardinality/extreme-scale-registry.test.ts"],
|
|
},
|
|
{
|
|
id: "telemetry-storm",
|
|
command: [...VITEST, "tests/scale/telemetry", "tests/platform/telemetry"],
|
|
},
|
|
{ id: "session-cycles", command: [...VITEST, "tests/scale/session"] },
|
|
{
|
|
id: "browser-soak",
|
|
command: ["scripts/scale/browser-soak.ts", "--duration-ms=120000", "--interval-ms=5000", "--warmup-ms=30000"],
|
|
optional: true,
|
|
},
|
|
];
|
|
|
|
const RELEASE_STEPS: readonly Step[] = [
|
|
{
|
|
id: "release-coherence",
|
|
command: [...VITEST, "tests/platform/release", "tests/release"],
|
|
},
|
|
...MAIN_STEPS,
|
|
{
|
|
id: "topology-s3-s4",
|
|
command: [...VITEST, "tests/scale/global-local-independence.test.ts"],
|
|
},
|
|
{
|
|
id: "telemetry-storm",
|
|
command: [...VITEST, "tests/scale/telemetry"],
|
|
},
|
|
];
|
|
|
|
export const SCALE_TIERS: Readonly<Record<ScaleTier, readonly Step[]>> = Object.freeze({
|
|
pr: PR_STEPS,
|
|
main: MAIN_STEPS,
|
|
nightly: NIGHTLY_STEPS,
|
|
release: RELEASE_STEPS,
|
|
});
|
|
|
|
function withArtifact(step: Step, directory: string): readonly string[] {
|
|
const script = step.command[0] ?? "";
|
|
if (
|
|
script.endsWith("run-composition-scale.ts") ||
|
|
script.endsWith("collect-tsc-diagnostics.ts") ||
|
|
script.endsWith("browser-soak.ts") ||
|
|
script.endsWith("check-scale-baseline.ts")
|
|
) {
|
|
return [...step.command, `--artifact=${path.join(directory, `${step.id}.json`)}`];
|
|
}
|
|
return step.command;
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
const tier = process.argv[2] as ScaleTier | undefined;
|
|
if (!tier || !(tier in SCALE_TIERS)) {
|
|
process.stderr.write(`usage: run-scale-profile.ts <${Object.keys(SCALE_TIERS).join("|")}>\n`);
|
|
process.exit(2);
|
|
}
|
|
const directory = path.resolve("artifacts/scale", tier);
|
|
await mkdir(directory, { recursive: true });
|
|
const results: { id: string; status: "passed" | "failed" | "skipped"; durationMs: number; log: string }[] = [];
|
|
for (const step of SCALE_TIERS[tier]) {
|
|
const startedAt = Date.now();
|
|
const run = spawnSync(process.execPath, [...withArtifact(step, directory)], {
|
|
encoding: "utf8",
|
|
maxBuffer: 64 * 1024 * 1024,
|
|
env: { ...process.env, SCALE_ARTIFACT_DIR: path.join(directory, "metrics") },
|
|
});
|
|
const log = path.join(directory, `${step.id}.log`);
|
|
await writeFile(log, `${run.stdout ?? ""}${run.stderr ?? ""}`);
|
|
const skipped = step.optional === true && /: skipped/u.test(run.stdout ?? "");
|
|
const status = run.status === 0 ? (skipped ? "skipped" : "passed") : "failed";
|
|
results.push({ id: step.id, status, durationMs: Date.now() - startedAt, log: path.relative(process.cwd(), log) });
|
|
process.stdout.write(`${status.toUpperCase()} ${tier}:${step.id} (${Date.now() - startedAt}ms)\n`);
|
|
}
|
|
const failed = results.some((result) => result.status === "failed");
|
|
const skipped = results.filter((result) => result.status === "skipped").map((result) => result.id);
|
|
const status = failed ? "failed" : skipped.length > 0 ? "incomplete" : "passed";
|
|
await writeFile(
|
|
path.join(directory, "summary.json"),
|
|
`${JSON.stringify(
|
|
{
|
|
schemaVersion: 1,
|
|
tier,
|
|
generatedAt: new Date().toISOString(),
|
|
node: process.version,
|
|
environment: {
|
|
node: process.version,
|
|
nodeMajor: Number(process.versions.node.split(".")[0]),
|
|
platform: process.platform,
|
|
arch: process.arch,
|
|
},
|
|
status,
|
|
passed: status === "passed",
|
|
skipped,
|
|
steps: results,
|
|
},
|
|
null,
|
|
2,
|
|
)}\n`,
|
|
);
|
|
process.stdout.write(
|
|
`scale tier ${tier}: ${status.toUpperCase()}${skipped.length > 0 ? ` (skipped: ${skipped.join(", ")})` : ""} (artifacts/scale/${tier}/summary.json)\n`,
|
|
);
|
|
if (status === "failed") process.exitCode = 1;
|
|
else if (status === "incomplete" && process.env["SCALE_ALLOW_INCOMPLETE"] !== "1") process.exitCode = 1;
|
|
}
|
|
|
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
await main();
|
|
}
|