This reverts commit411c9338c6. 문제: #55(b4895894)가 main run 376의 FE-GATE-030(browser file/storage 제거 드릴)을 깨서 411c9338(#64)로 통째로 되돌렸다. #55의 검사기 진단과 시험 빈틈 고침 12커밋이 main에 없다. 고른 방법: 되돌림을 되돌려 #55를 그대로 다시 넣고, 드릴을 깬 원인은 다음 커밋에서 따로 고친다. 리뷰어가 이 커밋이 #55와 같은지 트리로 볼 수 있다. 이 커밋의 트리는b4895894트리에 그 뒤 main에 들어온 #63·#65만 더한 것이다(git diffb4895894<이 커밋>: docs/ledger 두 파일, cross-context-invalidation adapter 한 파일과 시험 두 파일). 버린 대안: #55 커밋 12개 cherry-pick.71606ff1merge의 충돌 해소분을 다시 풀어야 하고 결과 트리를 b4895894와 대조하기 어렵다. 위험·한계: 이 커밋만으로는 main 단계의 FE-GATE-030이 run 376처럼 실패한다(같은 트리 내용). PR 단계 게이트는 돈다. 검증: 다음 커밋 본문에 적는다. 그 커밋의 새 단언을 이 커밋의 검사기에 돌리면 실패한다(RED). Refs: #55, #64
73 lines
3.3 KiB
TypeScript
73 lines
3.3 KiB
TypeScript
import path from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
checkRequestFanoutFixtures,
|
|
findRequestFanout,
|
|
formatFanoutViolation,
|
|
scanRequestFanout,
|
|
} from "../../scripts/check-request-fanout.ts";
|
|
|
|
describe("no per-row transport loop (frontend N+1 source gate)", () => {
|
|
it("finds no per-row dispatch in feature code or application use cases", async () => {
|
|
const result = await scanRequestFanout(path.resolve("."));
|
|
expect(result.files).toBeGreaterThan(0);
|
|
expect(result.violations).toEqual([]);
|
|
});
|
|
|
|
it("rejects every forbidden fixture and accepts the bulk-read fixture", async () => {
|
|
const root = path.resolve(".");
|
|
const forbidden = await scanRequestFanout(root, ["tests/fixtures/architecture/request-fanout/forbidden"]);
|
|
const allowed = await scanRequestFanout(root, ["tests/fixtures/architecture/request-fanout/allowed"]);
|
|
expect(new Set(forbidden.violations.map((violation) => violation.file)).size).toBe(forbidden.files);
|
|
expect(forbidden.files).toBe(3);
|
|
expect(allowed.violations).toEqual([]);
|
|
expect(allowed.reviewed).toEqual([
|
|
expect.objectContaining({
|
|
file: "tests/fixtures/architecture/request-fanout/allowed/reviewed-cursor-loop.ts",
|
|
call: "gateway.page()",
|
|
reason: "cursor pages, bounded by maxPages",
|
|
}),
|
|
]);
|
|
});
|
|
|
|
it("names the dispatch and the repeating construct", async () => {
|
|
const violations = await findRequestFanout(
|
|
"inline.ts",
|
|
"export const load = (api: { get(id: string): Promise<unknown> }, ids: string[]) =>\n Promise.all(ids.map((id) => api.get(id)));\n",
|
|
);
|
|
expect(violations).toEqual([
|
|
{ file: "inline.ts", line: 2, call: "api.get()", context: ".map() callback" },
|
|
]);
|
|
});
|
|
|
|
it("honours an explicit reviewed exception on the call line", async () => {
|
|
const violations = await findRequestFanout(
|
|
"reviewed.ts",
|
|
"export async function f(http: { execute(): Promise<void> }) {\n for (let i = 0; i < 2; i += 1) await http.execute(); // fanout-reviewed: bounded 2-step handshake\n}\n",
|
|
);
|
|
expect(violations).toEqual([]);
|
|
});
|
|
|
|
// 0929/12-01. The failure line named only the call, so a product team saw
|
|
// neither the cursor runtime nor the reviewed-exception comment, and the
|
|
// result line hid how many calls a comment let through.
|
|
it("tells the author both ways out on the failure line", async () => {
|
|
const [violation] = await findRequestFanout(
|
|
"inline.ts",
|
|
"export const load = (api: { get(id: string): Promise<unknown> }, ids: string[]) =>\n Promise.all(ids.map((id) => api.get(id)));\n",
|
|
);
|
|
const line = formatFanoutViolation(violation!);
|
|
expect(line).toMatch(/^FAIL inline\.ts:2 api\.get\(\) inside \.map\(\) callback: /u);
|
|
expect(line).toContain("createCursorPaginationRuntime (src/adapters/query-cache)");
|
|
expect(line).toContain("`// fanout-reviewed: <reason>` on the call's line");
|
|
});
|
|
|
|
it("counts and lists the reviewed exceptions in the fixture result line", async () => {
|
|
const result = await checkRequestFanoutFixtures(path.resolve("."));
|
|
expect(result.ok).toBe(true);
|
|
expect(result.line).toMatch(/allowed 0 violations and 1 reviewed exception \(tests\/fixtures\/architecture\/request-fanout\/allowed\/reviewed-cursor-loop\.ts:\d+ cursor pages, bounded by maxPages\) PASS/u);
|
|
});
|
|
});
|