fix(provider): guardian이 commit 전에 죽으면 EPIPE 대신 그 죽음을 말한다 #60
@@ -49,6 +49,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지
|
||||
| 위험 커버리지 모듈 목록이 `@babel/core`로 파싱하고 기본 fs를 동기로 쓴다. 판정과 검사 순서는 같다 | `scripts/lib/risk-coverage.ts` | `0bb1f0af` |
|
||||
| `generateArtifactSchemas`가 writer를 받는다. 스키마 생성 시험은 fsync 없는 writer로 임시 폴더에 쓴다 | `scripts/generate-artifact-schemas.ts`, `tests/unit/json-schema.test.ts` | `198e9856` |
|
||||
| HTTP 실행기의 deadline 분류 시험이 가짜 시계로 대기 지점에서 deadline을 낸다. 실제 30ms deadline이 부하에서 backoff 전에 지나 TIMEOUT 대신 전송 실패로 끝났다 | `tests/unit/http-execution-v3.test.ts` | `37a85004` |
|
||||
| provider guardian이 commit 전에 죽었는데 supervisor가 그 종료를 보기 전에 COMMIT을 써 `EPIPE`가 나도, commit 실패가 guardian 종료(`provider guardian failed: exit=…, signal=…`)를 말하고 쓰기 오류는 `cause`로 붙는다. 시스템 시험이 가끔 `write EPIPE`만 남겼다 | `scripts/lib/provider-guardian-client.ts`, `tests/integration/provider-guardian-transaction.test.ts`, `docs/operations/ci-quality-gates.md` | `f6300949` |
|
||||
| 위험 커버리지가 `"use strict"` 밖의 지시문(`"use client"` 등)을 문장으로 센다. V8 coverage가 그렇게 센다(`check:v8-coverage-counter-semantics` fixture에 지시문 모듈 둘) | `scripts/lib/risk-coverage.ts`, `scripts/lib/v8-coverage-counter-semantics.ts` | `0c3c9d33` |
|
||||
| e2e fixture build를 브라우저 project마다가 아니라 run에 한 번 만든다. global setup이 공유 폴더를 만들고 처음 닿은 worker만 build한다. 자기 spec에서 `prepareServiceWorkerBuilds`를 부르면 `key`를 준다 | `playwright.config.ts`, `tests/e2e/support/shared-fixture-builds.ts`, `tests/e2e/support/fixture-builds.ts`, `tests/e2e/support/service-worker-builds.ts` | `c6d7f43a` |
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
{"schema": 1, "kind": "actual", "task": "w2-fe-ci-perf", "recorded_at": "2026-11-12T22:25+09:00", "transcript": "00d79702-1dea-4e11-b79a-f021d0d9f4bb", "minutes": 1463, "active_minutes": 308, "calls": 447, "output_tokens": 413297, "cache_read_tokens": 246773496, "max_context": 943246, "within": "p30", "result": "partial", "commits": ["ddfcb6f6", "79a225b6", "0d8e4f5a", "b4210753", "66138440", "1d3eb901", "92abfd20", "1f09c1cc", "27876ffc", "35b60a04", "f90ffb6c", "f6e2560e", "ba72b865"], "why": "작업 중 시간은 p30 안이지만 일이 끝나지 않고 인계됐다(PR #19 Draft). 벽시계의 대부분은 runner 대기열(백엔드 정기 lane 뒤)과 desktop heavy 잠금 대기다. 남은 것: runner 초록 확인, concurrency, firefox 흔들림, coverage 경로, 느린 시험 둘. 세션 기록으로 다시 셌고 인계 절을 쓴 22:10 KST 뒤까지 들어 있다. 기록은 이어받은 세션이 남긴다"}
|
||||
{"schema": 1, "kind": "estimate", "task": "w2-fe2-takeover", "recorded_at": "2026-11-12T22:25+09:00", "transcript": "fa9a12aa-7abc-46ca-a5fd-ee00cab98618", "started_at": "2026-11-12T21:05+09:00", "base": "ba72b865", "task_kind": "improve+operate", "size": "large", "minutes": {"p30": 180, "p50": 300, "p80": 480}, "calls": {"p30": 250, "p50": 400, "p80": 650}, "output_tokens": {"p30": 150000, "p50": 250000, "p80": 400000}, "basis": "PR #19 이어받기(인계 절 2026-11-12 22:10). concurrency·coverage 경로·느린 시험 둘은 각 30~60분(작음, 선례 W2-BE concurrency). firefox 008 흔들림은 원인 미확정이라 1~4시간. runner 1대를 백엔드와 같이 써 PR run 하나가 대기 포함 1시간 이상(W2-BE 기록: PR run이 2~4시간 뒤로 밀림), 초록 3회와 실패-고침 1~2번을 p80에 넣었다. 첫 5분 뒤에 적었다(인계 대기 중 시작)"}
|
||||
{"schema": 1, "kind": "estimate", "task": "r9-fe-group-A", "recorded_at": "2026-11-13T18:50+09:00", "transcript": "66f9f89d-a13f-4cee-a2bf-c3c528c6bfb2", "started_at": "2026-11-13T17:57+09:00", "base": "ee95573f", "task_kind": "improve", "size": "large", "minutes": {"p30": 300, "p50": 420, "p80": 600}, "calls": {"p30": 350, "p50": 500, "p80": 750}, "output_tokens": {"p30": 200000, "p50": 300000, "p80": 450000}, "basis": "round9 그룹 A 발견 22건(화면·토큰·story·검사·접근성 기록)을 PR 셋으로. 바꿀 파일 약 60개, CSS 선언 118개 토큰화와 story 37개가 가장 크다. desktop heavy 잠금을 다른 세션 넷과 같이 써 실행마다 대기 10~30분, merge 단계 셋(각 약 21분)과 골든 갱신·변이 실험, runner run 셋(각 약 23분)을 p80에 넣었다. 선례 r9-fe F4a·F5(묶음당 2~4시간). 착수 약 50분 뒤 발견 원문을 다 읽고 PR1 고침을 쓰던 중에 적었다"}
|
||||
{"schema": 1, "kind": "estimate", "task": "fe-ci-fix4", "recorded_at": "2026-11-18T22:33+09:00", "transcript": "c8389cc8-12d4-49c4-a90a-3d4437168351", "started_at": "2026-11-14T07:10+09:00", "base": "e98d8ee9", "task_kind": "improve+operate", "size": "medium", "minutes": {"p30": 240, "p50": 360, "p80": 540}, "calls": {"p30": 250, "p50": 400, "p80": 600}, "output_tokens": {"p30": 120000, "p50": 200000, "p80": 320000}, "basis": "main 빨강 하나(기록 다시 재기와 첫 빨강 커밋 찾기 60~90분), 흔들림 둘(결정적 재현·고침·반복 실행 각 60~120분), 선택 하나와 PR 갱신 하나(각 30분). desktop heavy 잠금을 다른 세션과 같이 써 실행마다 10~30분 대기, PR runner run 하나 약 25분을 p80에 넣었다. 선례 fe-ci-fix3(exit=125 묶음, PR 하나). 착수 5분 안에 쓰지 못했다: 노트북이 11-14 08:09에 꺼져 11-18 20:50에 이어받았고, 이 줄은 이어받은 뒤 (g) PR을 낸 다음 적는다"}
|
||||
|
||||
@@ -9,3 +9,4 @@
|
||||
{"date": "2026-11-13", "test": "tests/browser-capabilities/local-draft-composition.spec.ts:10", "category": "resource-io", "first_run": "/tmp/claude-gates/ci-pr-gate-selection-merge/gate-artifacts/FE-GATE-008.txt", "verdict": "[firefox] desktop merge(트리 148e68f4, #47 없음)에서 30초 timeout 1회. 같은 게이트가 Firefox 프로필을 RAM에 둔 #47 트리에서는 69개 전부 통과. Firefox IndexedDB·OPFS가 프로필 디스크를 기다린 것으로 봄", "quarantined_until": "", "fixed_by": "프론트 #47"}
|
||||
{"date": "2026-11-13", "test": "tests/browser-capabilities/opfs-runtime.spec.ts:338", "category": "resource-io", "first_run": "/tmp/claude-gates/ci-pr-gate-selection-merge/gate-artifacts/FE-GATE-008.txt", "verdict": "[firefox] desktop merge(트리 148e68f4, #47 없음)에서 30초 timeout 1회. 같은 게이트가 Firefox 프로필을 RAM에 둔 #47 트리에서는 69개 전부 통과. Firefox IndexedDB·OPFS가 프로필 디스크를 기다린 것으로 봄", "quarantined_until": "", "fixed_by": "프론트 #47"}
|
||||
{"date": "2026-11-13", "test": "tests/system/ci-runner/provider-process-group.test.ts:11", "category": "fixed-time", "first_run": "309", "verdict": "runner run 309(#57 head, FE-GATE-013)에서 1회 실패(ENOENT descendant.pid). 시험이 runProviderProcess에 실제 250 ms 시한을 주고 그 안에 provider가 손자를 띄우고 pid를 쓴다고 가정했다. provider 시작을 400 ms 늦춘 탐침으로 결정적 재현(1/1 ENOENT), 고친 시험은 같은 탐침에서 통과. 고친 트리에서 desktop 시스템 컨테이너 20회 중 실패 0(부하 8.3~9.8, 12코어)", "quarantined_until": "", "fixed_by": "프론트 #61"}
|
||||
{"date": "2026-11-14", "test": "tests/system/ci-runner/ci-artifact-contract.test.ts:983", "category": "concurrency-order", "first_run": "/tmp/claude-gates/fe125-loop1-runs/run-1.log", "verdict": "원인 확정(2026-11-18). guardian이 SIGKILL로 죽은 뒤 supervisor가 그 종료를 처리하기 전에 COMMIT을 쓰면 EPIPE가 나고, scripts/lib/provider-guardian-client.ts의 commit()이 종료 결과보다 그 쓰기 오류를 먼저 던졌다(시험이 GITHUB_OUTPUT FIFO를 여는 때와 SIGCHLD 처리의 순서 경쟁). 같은 순서를 결정적으로 만든 통합 시험이 수정 전 1/1 실패(write EPIPE), 수정 뒤 통과. 고친 트리에서 desktop 시스템 컨테이너 그 시험 20회 중 실패 0(부하 8.7~17.2, 12코어)", "quarantined_until": "", "fixed_by": "프론트 #60"}
|
||||
|
||||
@@ -304,7 +304,9 @@ same-kind retry를 막지 않는다.
|
||||
Sealing/output I/O의 OS-level cancellation을 보장하지 않는다. Provider scope가 이미
|
||||
수집된 뒤 guardian이 종료되면 scope-active latch는 늦은 kill을 시작하지 않고 lifecycle
|
||||
error만 기록한다. 이후 publish/commit의 awaited failure가 identity가 고정된
|
||||
raw/temp/final fallback을 모두 정리하고 fail closed한다.
|
||||
raw/temp/final fallback을 모두 정리하고 fail closed한다. 그 실패는 guardian의
|
||||
종료(exit·signal)를 말한다. Supervisor가 그 종료를 보기 전에 COMMIT을 써
|
||||
`EPIPE`가 나도, 그 쓰기 오류는 던지는 오류가 아니라 그 오류의 `cause`로 붙는다.
|
||||
|
||||
Provider stdout/stderr는 credential을 포함할 수 있는 untrusted bytes이므로 CI log로
|
||||
재전송하거나 보관하지 않고, byte 수만 합산해 1 MiB 상한을 적용한다. Guardian의
|
||||
|
||||
@@ -293,14 +293,17 @@ export async function startProviderGuardian(
|
||||
return await cleanupFallbackCloseAndThrow(fallback, recovery, error);
|
||||
}
|
||||
state = "terminated";
|
||||
if (inputError) return await cleanupFallbackCloseAndThrow(fallback, recovery, inputError);
|
||||
// A guardian that died before reading COMMIT also fails the write (EPIPE)
|
||||
// when this process has not handled its exit yet. The death is the cause;
|
||||
// the write failure stays attached to it.
|
||||
if (result.error || result.code !== 0 || result.signal !== null) {
|
||||
return await cleanupFallbackCloseAndThrow(
|
||||
fallback,
|
||||
recovery,
|
||||
guardianCloseError(result, stderr),
|
||||
guardianCloseError(result, stderr, inputError),
|
||||
);
|
||||
}
|
||||
if (inputError) return await cleanupFallbackCloseAndThrow(fallback, recovery, inputError);
|
||||
await closeRecoveryAuthority(recovery);
|
||||
};
|
||||
|
||||
@@ -753,11 +756,12 @@ function hasErrorCode(error: unknown, code: string): boolean {
|
||||
return Boolean(error && typeof error === "object" && "code" in error && error.code === code);
|
||||
}
|
||||
|
||||
function guardianCloseError(result: GuardianResult, stderr: Buffer): Error {
|
||||
function guardianCloseError(result: GuardianResult, stderr: Buffer, cause?: Error): Error {
|
||||
if (result.error) return result.error;
|
||||
const detail = stderr.toString("utf8").trim();
|
||||
return new Error(
|
||||
`provider guardian failed: exit=${result.code ?? "none"}, signal=${result.signal ?? "none"}${detail ? `, output=${detail}` : ""}`,
|
||||
cause ? { cause } : undefined,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { closeSync, constants, fchmodSync, openSync, watch, writeFileSync } from "node:fs";
|
||||
import {
|
||||
closeSync,
|
||||
constants,
|
||||
fchmodSync,
|
||||
openSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
watch,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import {
|
||||
lstat,
|
||||
mkdir,
|
||||
@@ -23,7 +32,8 @@ import { childProcessTimeout } from "../helpers/child-process-timeout.ts";
|
||||
* Test watchdog only. This is not a provider protocol deadline. Child-process
|
||||
* scheduling can be delayed when the repository suite is under load, so the
|
||||
* watchdog must not encode a one-second protocol requirement that does not
|
||||
* exist in production. It also bounds the polls that wait for a child to start.
|
||||
* exist in production. It also bounds the polls that wait for a child to start,
|
||||
* and the wait for a killed child to release its descriptors.
|
||||
*/
|
||||
const PROCESS_HANDSHAKE_WATCHDOG_MS = 5_000;
|
||||
/** The extra pipe on which spawnGuardian's wrapper reports the guardian loaded. */
|
||||
@@ -540,6 +550,45 @@ describe("provider guardian transaction protocol", () => {
|
||||
await expect(lstat(lease.sealedPath)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
}, childProcessTimeout(380));
|
||||
|
||||
/**
|
||||
* 2026-11-14. The supervisor blocked on GITHUB_OUTPUT while the guardian was
|
||||
* killed, then committed before its event loop handled the guardian's exit.
|
||||
* The COMMIT write met a closed pipe and the supervisor reported
|
||||
* `write EPIPE` instead of the guardian's death (system test "fails closed
|
||||
* when the guardian dies after scope collection and before commit", 1 of 4
|
||||
* desktop runs). Here the kill, the wait for the dead guardian to release its
|
||||
* pipe and the commit share one synchronous turn, so the client cannot have
|
||||
* seen the exit and the write always meets the closed pipe.
|
||||
*/
|
||||
it("names the guardian's death when commit writes to a guardian that died unnoticed", async () => {
|
||||
const { startProviderGuardian } = await import(
|
||||
"../../scripts/lib/provider-guardian-client.ts"
|
||||
);
|
||||
const workspace = await createWorkspace("provider-guardian-commit-death-");
|
||||
const lease = await startProviderGuardian({
|
||||
kind: "vulnerability",
|
||||
workspaceRoot: workspace,
|
||||
leaseMs: LEASE_NOT_UNDER_TEST_MS,
|
||||
guardianScript: path.resolve("scripts/lib/provider-raw-guardian.ts"),
|
||||
});
|
||||
await lease.publish(Buffer.from('{"validated":"client"}\n'));
|
||||
|
||||
process.kill(lease.pid, "SIGKILL");
|
||||
waitForReleasedProcessSync(lease.pid);
|
||||
const failure = await lease.commit().then(
|
||||
() => { throw new Error("commit succeeded after the guardian died"); },
|
||||
(error: unknown) => error,
|
||||
);
|
||||
|
||||
expect(failure).toBeInstanceOf(Error);
|
||||
expect((failure as Error).message).toMatch(/^provider guardian failed: exit=none, signal=SIGKILL/u);
|
||||
// The commit did reach the closed pipe: the write failure is kept as the cause.
|
||||
expect((failure as Error).cause).toMatchObject({ code: "EPIPE" });
|
||||
await expect(lstat(lease.rawPath)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
await expect(lstat(lease.sealedTempPath)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
await expect(lstat(lease.sealedPath)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
}, childProcessTimeout(148));
|
||||
|
||||
it("cleans a linked raw inode when killed before READY and retries immediately", async () => {
|
||||
const { startProviderGuardian } = await import(
|
||||
"../../scripts/lib/provider-guardian-client.ts"
|
||||
@@ -1203,6 +1252,24 @@ async function waitForStoppedProcess(pid: number): Promise<void> {
|
||||
throw new Error("provider guardian child did not stop before bootstrap");
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the event loop until a killed child has released its descriptors: its
|
||||
* thread group leader is a zombie and no other thread is left, so every thread
|
||||
* has closed its files. The parent has not reaped it yet, so the child process
|
||||
* object still holds an open input stream whose peer is closed. Between polls
|
||||
* it sleeps 1 ms without returning to the event loop.
|
||||
*/
|
||||
function waitForReleasedProcessSync(pid: number): void {
|
||||
const pause = new Int32Array(new SharedArrayBuffer(4));
|
||||
const deadline = Date.now() + PROCESS_HANDSHAKE_WATCHDOG_MS;
|
||||
while (Date.now() <= deadline) {
|
||||
const state = /^State:\s+(\S)/mu.exec(readFileSync(`/proc/${pid}/status`, "utf8"))?.[1];
|
||||
if (state === "Z" && readdirSync(`/proc/${pid}/task`).length === 1) return;
|
||||
Atomics.wait(pause, 0, 0, 1);
|
||||
}
|
||||
throw new Error(`process ${pid} did not release its descriptors after SIGKILL`);
|
||||
}
|
||||
|
||||
function hasErrorCode(error: unknown, code: string): boolean {
|
||||
return Boolean(error && typeof error === "object" && "code" in error && error.code === code);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user