fix(inventory): abort ratchet에 여유를 두지 않고 지운 선택 그룹을 건너뛴다

문제: 손수 짠 abort 배선 상한이 13인데 실제는 12다. http/client.ts를 지울 때 상수를 내리지 않아 래칫이 한 번은 막지 못한다. 머리 주석은 지금은 커널을 쓰는 두 파일을 사본이라 적고 23개라 한다(1112/02-04). 필수 abort 소비자 넷은 선택 그룹 browser-transfer 파일이라, 제품이 그 그룹을 지우면 원인 없이 실패한다(0929/01-04).

고른 방법: 상한을 12로 내리고 개수가 상한과 다르면 줄어도 실패하게 한다(어느 상수를 몇으로 내리라고 말한다). 낡은 주석을 고친다. 없는 필수 소비자는 건너뛴다. 남은 파일이 공용 primitive를 안 쓰는 것만 막는다.

위험·한계: release-artifacts.ts가 레시피 ID를 말하게 하는 0929/01-04 둘째 반은 그룹 C가 고치는 파일이라 이 커밋에 없다.

검증: desktop 결과는 PR 본문.

Refs: 1112/02-04, 0929/01-04
This commit is contained in:
DongHyeonka
2026-11-13 20:17:04 +09:00
parent c1a98e9743
commit d3e4ab7ab4
+36 -14
View File
@@ -1,5 +1,5 @@
import { readFile } from "node:fs/promises";
import { readFileSync } from "node:fs";
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";
@@ -132,11 +132,13 @@ async function main(): Promise<void> {
// Resumable kept their own diverging copies of the same mechanics — which is
// exactly how the four hand-written versions drifted apart in the first place.
//
// 이 목록은 재검토가 이름으로 지목한 네 파일만 덮는다. 같은 두 그룹의
// `image-cdn-runtime.ts`와 `resumable-upload-runtime.ts`는 여기 없고 지금도
// 자기 abort 사본을 들고 있다. 어댑터 전체로는 23개 파일이 그렇다. 그 전수
// 이행은 abort 의미론을 바꾸는 별도 작업이라 이 목록으로 강제하지 않고,
// 아래 래칫이 개수가 늘어나는 것만 막는다.
// 이 목록은 재검토가 이름으로 지목한 네 파일만 덮는다. 나머지 어댑터의
// 손수 짠 abort 배선은 아래 래칫이 센다.
//
// 0929/01-04. 넷 다 선택 adapter 그룹(`browser-transfer`) 파일이다. 제품이
// 그 그룹을 통째로 지우면 소비자가 없는 것이 맞으니 건너뛴다. 그룹이
// 남았는데 목록의 파일이 없으면(이름을 바꿨다) 목록을 고치라고 실패한다.
// 그렇지 않으면 바뀐 이름의 파일이 검사에서 조용히 빠진다.
const REQUIRED_ABORT_CONSUMERS: readonly string[] = [
"src/adapters/browser-transfer/presigned/presigned-capability-http-provider.ts",
"src/adapters/browser-transfer/presigned/presigned-transfer-executor.ts",
@@ -156,8 +158,16 @@ async function main(): Promise<void> {
.filter((file) => !file.endsWith("platform/abortable-operation.ts"))
.sort();
const importerSet = new Set(importers);
const missingConsumers = REQUIRED_ABORT_CONSUMERS.filter(
(consumer) => !importerSet.has(consumer),
const transferGroupRemoved = !existsSync("src/adapters/browser-transfer");
const presentConsumers = transferGroupRemoved ? [] : REQUIRED_ABORT_CONSUMERS;
const renamedConsumers = presentConsumers.filter((consumer) => !existsSync(consumer));
if (renamedConsumers.length > 0) {
problems.push(
`abortable-operation: REQUIRED_ABORT_CONSUMERS in scripts/check-adapter-inventory.ts names files that do not exist while src/adapters/browser-transfer does: ${renamedConsumers.join(", ")}. Point it at the renamed files.`,
);
}
const missingConsumers = presentConsumers.filter(
(consumer) => existsSync(consumer) && !importerSet.has(consumer),
);
if (missingConsumers.length > 0) {
problems.push(
@@ -172,7 +182,7 @@ async function main(): Promise<void> {
"src/adapters/platform/abortable-operation.ts",
);
const PRIMITIVE_SPECIFIER = "platform/abortable-operation.ts";
for (const consumer of REQUIRED_ABORT_CONSUMERS) {
for (const consumer of presentConsumers) {
if (!importerSet.has(consumer)) continue;
const source = readFileSync(consumer, "utf8");
const specifiers = [
@@ -191,10 +201,11 @@ async function main(): Promise<void> {
// 손수 짠 abort 배선은 줄어들기만 해야 한다.
//
// 커널 `platform/abortable-operation.ts`가 있는데도 어댑터 23개 파일이
// `addEventListener("abort")`로 같은 race/cleanup을 각자 짠다. 그 전수 이행은
// 동작이 바뀌는 큰 작업이라 한 번에 하지 않는다. 대신 개수를 여기 고정해
// 되돌아가지 못하게 한다. 이행으로 숫자가 내려가면 이 상수도 같이 내린다.
// 커널 `platform/abortable-operation.ts`가 있는데도 일부 어댑터 파일이
// `addEventListener("abort")`로 같은 race/cleanup을 각자 짠다(개수는 아래
// 상수). 그 전수 이행은 동작이 바뀌는 큰 작업이라 한 번에 하지 않는다. 대신
// 개수를 여기 고정해 되돌아가지 못하게 한다. 이행으로 숫자가 내려가면 이
// 상수도 같이 내려야 검사가 통과한다.
// `platform/`은 커널 자신이므로 세지 않는다.
//
// 24 → 23: `browser-transfer/resumable-upload/indexeddb-checkpoint-store.ts`가
@@ -213,7 +224,10 @@ async function main(): Promise<void> {
// 15 → 13: `storage/opfs/opfs-worker-client.ts`가 커널 abort primitive를 쓰고,
// `storage/indexeddb/indexeddb-governance.ts`의 binding 검증이 커널
// 트랜잭션으로 옮겨갔다(05-07, 05-12).
const HAND_ROLLED_ABORT_CEILING = 13;
// 13 → 12: V2 HTTP 경로 `http/client.ts`를 지웠다(2026-11-03). 그때 상수를
// 내리지 않아 래칫이 한 번은 막지 못했다(1112/02-04). 그래서 이제는 개수가
// 상수와 다르면 줄어도 실패한다.
const HAND_ROLLED_ABORT_CEILING = 12;
const handRolledScan = spawnSync(
"git",
["grep", "-l", 'addEventListener("abort"', "--", "src/adapters"],
@@ -235,6 +249,14 @@ async function main(): Promise<void> {
`Current offenders (the new one is whichever this change added): ` +
`${handRolledFiles.join(", ")}`,
);
} else if (handRolledFiles.length < HAND_ROLLED_ABORT_CEILING) {
problems.push(
`abortable-operation: hand-rolled abort wiring fell to ` +
`${handRolledFiles.length} files: lower HAND_ROLLED_ABORT_CEILING ` +
`(${HAND_ROLLED_ABORT_CEILING}) in scripts/check-adapter-inventory.ts to ` +
`${handRolledFiles.length} with a line saying which file moved, so the ` +
`ratchet keeps no slack. Files: ${handRolledFiles.join(", ")}`,
);
}
if (problems.length > 0) {