frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / merge / static checks (pull_request) Successful in 1m9s
frontend-quality-gates / merge / tests (pull_request) Successful in 10m55s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 5m11s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
This reverts commitb489589403, reversing changes made to9e1cfd5975. 문제: main run 376(b4895894)의 `main / self-tests and removal drills` job에서 FE-GATE-030이 실패한다. browser-file-storage 제거 드릴 사본에서 tests/unit/test-evidence-source-rules.test.ts 6건이 모두 같은 이유로 떨어진다. scripts/check-test-evidence.ts의 missingForbidOnly가 playwright.capabilities.config.ts를 읽다 ENOENT로 죽는다. #55가 forbidOnly 검사를 전체 검사에서 fixture 모드까지 모든 모드로 옮겼다. 드릴은 그 설정 파일을 지우지만 config/repository-layout.json의 playwright-configs 목록에는 그대로 남는다. 이 job은 main 단계에만 있어 PR run에서는 돌지 않았다. 고른 방법: CI 매뉴얼 9.3대로 main을 먼저 초록으로 돌리려고 #55 병합 커밋을 통째로 되돌린다(git revert -m 1b4895894). 되돌린 트리는9e1cfd59트리(9b3237dd)와 같다. 버린 대안: 그 자리에서 고치기(없는 설정을 건너뛰거나, 드릴이 목록에서도 빼기)는 어느 쪽이 맞는지 판단과 검증이 필요해 main 빨강이 길어진다. 고침은 #55를 다시 올리는 PR에서 한다. 위험·한계: #55의 고침 12커밋(검사기 진단과 시험 빈틈)이 main에서 빠진다. 다시 올릴 때 이 드릴(FE-GATE-030, main 단계)을 PR 쪽에서 따로 돌리지 않으면 같은 일이 다시 난다. 검증: desktop 공유 잠금 아래 test:browser-file-storage-removal.b4895894트리(7536337a) 3회 모두 rc=1(64·69·53초). 3회차 로그에서 6건 실패, 6건 모두 run 376과 같은 ENOENT(playwright.capabilities.config.ts).9e1cfd59트리(9b3237dd, 이 커밋의 트리) 1회 rc=0(92초). 로그 desktop /tmp/claude-gates/fe-run376-b489-removal/, fe-run376-9e1c-removal/.
201 lines
8.1 KiB
TypeScript
201 lines
8.1 KiB
TypeScript
import { constants } from "node:fs";
|
|
import { access, readFile } from "node:fs/promises";
|
|
import { spawnSync } from "node:child_process";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { PROVIDER_SANDBOX_NAMESPACE_ARGUMENTS } from "./lib/provider-sandbox-namespaces.ts";
|
|
|
|
/** What the check reads from the host; a test passes a fake. */
|
|
export type SystemTestHost = Readonly<{
|
|
/** Resolves when `target` is executable, rejects otherwise. */
|
|
access(target: string): Promise<void>;
|
|
readFile(target: string): Promise<string>;
|
|
spawn(
|
|
command: string,
|
|
args: readonly string[],
|
|
timeoutMs: number,
|
|
): Readonly<{ status: number | null; stderr: string; error?: Error | undefined }>;
|
|
}>;
|
|
|
|
export const nodeSystemTestHost: SystemTestHost = Object.freeze({
|
|
access: async (target: string) => access(target, constants.X_OK),
|
|
readFile: async (target: string) => readFile(target, "utf8"),
|
|
spawn: (command: string, args: readonly string[], timeoutMs: number) => {
|
|
const result = spawnSync(command, [...args], { encoding: "utf8", timeout: timeoutMs });
|
|
return { status: result.status, stderr: result.stderr ?? "", error: result.error };
|
|
},
|
|
});
|
|
|
|
const BWRAP = "/usr/bin/bwrap";
|
|
const SYSTEMCTL = "/usr/bin/systemctl";
|
|
|
|
/**
|
|
* 1105/12-01. The provider sandbox's own namespace options on /bin/true. The
|
|
* check used to see only that /usr/bin/bwrap was executable, so a host that
|
|
* refuses unprivileged user namespaces passed it and then failed 18 provider
|
|
* tests with `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted`.
|
|
*/
|
|
export const NAMESPACE_PROBE_ARGUMENTS: readonly string[] = Object.freeze([
|
|
...PROVIDER_SANDBOX_NAMESPACE_ARGUMENTS,
|
|
"--ro-bind", "/", "/",
|
|
"--", "/bin/true",
|
|
]);
|
|
|
|
/** Host settings that decide whether an unprivileged process may create user namespaces. */
|
|
const USER_NAMESPACE_SETTINGS = Object.freeze([
|
|
["kernel.apparmor_restrict_unprivileged_userns", "/proc/sys/kernel/apparmor_restrict_unprivileged_userns"],
|
|
["kernel.unprivileged_userns_clone", "/proc/sys/kernel/unprivileged_userns_clone"],
|
|
["user.max_user_namespaces", "/proc/sys/user/max_user_namespaces"],
|
|
] as const);
|
|
|
|
const PROBE_TIMEOUT_MS = 5_000;
|
|
const MAX_REPORTED_STDERR_LINES = 4;
|
|
|
|
export async function findSystemTestPrerequisiteFailures(
|
|
host: SystemTestHost = nodeSystemTestHost,
|
|
): Promise<string[]> {
|
|
const failures: string[] = [];
|
|
const executable = new Map<string, boolean>();
|
|
for (const [target, label] of [
|
|
[BWRAP, "bubblewrap"],
|
|
[SYSTEMCTL, "systemctl"],
|
|
["/usr/bin/tar", "tar"],
|
|
] as const) {
|
|
try {
|
|
await host.access(target);
|
|
executable.set(target, true);
|
|
} catch {
|
|
executable.set(target, false);
|
|
failures.push(`${label} is required at ${target}`);
|
|
}
|
|
}
|
|
|
|
let cgroupV2 = false;
|
|
try {
|
|
const controllers = await host.readFile("/sys/fs/cgroup/cgroup.controllers");
|
|
if (controllers.trim().length === 0) {
|
|
failures.push("cgroup v2 controllers are unavailable");
|
|
} else {
|
|
cgroupV2 = true;
|
|
}
|
|
} catch {
|
|
failures.push("cgroup v2 is required at /sys/fs/cgroup/cgroup.controllers");
|
|
}
|
|
|
|
if (executable.get(SYSTEMCTL)) {
|
|
const probe = host.spawn(SYSTEMCTL, ["show-environment"], 3_000);
|
|
if (probe.error || probe.status !== 0) {
|
|
failures.push("a reachable systemd manager bus is required");
|
|
}
|
|
}
|
|
|
|
// The user manager's cgroup path below is a cgroup v2 path; without v2 it would name the wrong cause.
|
|
const controllerFailure = cgroupV2 ? await findProviderScopeControllerFailure(host) : undefined;
|
|
if (controllerFailure !== undefined) failures.push(controllerFailure);
|
|
|
|
if (executable.get(BWRAP)) {
|
|
const failure = await findProviderSandboxNamespaceFailure(host);
|
|
if (failure !== undefined) failures.push(failure);
|
|
}
|
|
return failures;
|
|
}
|
|
|
|
/**
|
|
* 1101/13-03. Whether this host lets the provider sandbox create its
|
|
* namespaces, and if not, why and what to do. The release provider jobs run
|
|
* it before the provider (scripts/run-and-validate-provider.ts).
|
|
*/
|
|
export async function findProviderSandboxNamespaceFailure(
|
|
host: SystemTestHost = nodeSystemTestHost,
|
|
): Promise<string | undefined> {
|
|
const probe = host.spawn(BWRAP, NAMESPACE_PROBE_ARGUMENTS, PROBE_TIMEOUT_MS);
|
|
return probe.error || probe.status !== 0 ? namespaceFailure(host, probe) : undefined;
|
|
}
|
|
|
|
async function namespaceFailure(
|
|
host: SystemTestHost,
|
|
probe: ReturnType<SystemTestHost["spawn"]>,
|
|
): Promise<string> {
|
|
const settings: string[] = [];
|
|
for (const [name, file] of USER_NAMESPACE_SETTINGS) {
|
|
try {
|
|
settings.push(`${name} = ${(await host.readFile(file)).trim()}`);
|
|
} catch {
|
|
// Absent on this kernel; the others still say what the host allows.
|
|
}
|
|
}
|
|
const stderr = probe.stderr
|
|
.split("\n")
|
|
.map((line) => line.trim())
|
|
.filter((line) => line.length > 0)
|
|
.slice(0, MAX_REPORTED_STDERR_LINES);
|
|
const outcome = probe.error
|
|
? `did not finish: ${probe.error.message}`
|
|
: `exited ${String(probe.status)}`;
|
|
return [
|
|
"this host does not allow unprivileged user and network namespaces, which the provider " +
|
|
`sandbox needs (bwrap ${PROVIDER_SANDBOX_NAMESPACE_ARGUMENTS.join(" ")}).`,
|
|
` probe: ${BWRAP} ${NAMESPACE_PROBE_ARGUMENTS.join(" ")} ${outcome}`,
|
|
...(stderr.length > 0 ? stderr.map((line) => ` bwrap stderr: ${line}`) : [" bwrap stderr: (empty)"]),
|
|
...(settings.length > 0 ? [` host settings: ${settings.join(", ")}`] : []),
|
|
" To fix, do one of these:",
|
|
" - give /usr/bin/bwrap an AppArmor profile that allows `userns` (Ubuntu 23.10 and later),",
|
|
" - on a host you own, set sysctl kernel.apparmor_restrict_unprivileged_userns=0",
|
|
" (or kernel.unprivileged_userns_clone=1 where that setting exists),",
|
|
" - run FE-GATE-013 on another runner that allows them.",
|
|
" Runner requirements: docs/operations/ci-quality-gates.md.",
|
|
].join("\n");
|
|
}
|
|
|
|
/** The controllers every provider scope is limited by (scripts/lib/provider-cgroup.ts). */
|
|
const PROVIDER_SCOPE_CONTROLLERS = Object.freeze(["cpu", "memory", "pids"] as const);
|
|
|
|
/**
|
|
* Whether the systemd user manager that provider scopes run under was handed
|
|
* the cgroup controllers their limits need. A manager without them passed
|
|
* every check above, and then each provider stopped with `provider cgroup
|
|
* enforcement failed: cannot read memory.max` (2026-11-14: a `docker exec`
|
|
* sat in the system container's root cgroup while systemd started, so systemd
|
|
* delegated nothing).
|
|
*/
|
|
async function findProviderScopeControllerFailure(host: SystemTestHost): Promise<string | undefined> {
|
|
const status = await host.readFile("/proc/self/status").catch(() => "");
|
|
const uid = /^Uid:\s+(\d+)\s/mu.exec(status)?.[1];
|
|
if (uid === undefined) return "this process's uid is unreadable at /proc/self/status";
|
|
const manager = `/sys/fs/cgroup/user.slice/user-${uid}.slice/user@${uid}.service`;
|
|
let delegated: string[];
|
|
try {
|
|
delegated = (await host.readFile(`${manager}/cgroup.controllers`)).trim().split(/\s+/u);
|
|
} catch {
|
|
return `a systemd user manager is required at ${manager}`;
|
|
}
|
|
const missing = PROVIDER_SCOPE_CONTROLLERS.filter((controller) => !delegated.includes(controller));
|
|
return missing.length === 0
|
|
? undefined
|
|
: `the systemd user manager at ${manager} has no ${missing.join(", ")} cgroup controller ` +
|
|
`for provider scopes (it has: ${delegated.join(" ") || "none"})`;
|
|
}
|
|
|
|
export function formatSystemTestPrerequisiteReport(failures: readonly string[]): string {
|
|
return [
|
|
"System/CI-runner test prerequisites are unavailable:",
|
|
...failures.map((failure) => ` - ${failure}`),
|
|
"",
|
|
"Run test:unit/test:contract/test:component/test:integration for the",
|
|
"developer loop. test:system is intentionally reserved for a compatible",
|
|
"Linux CI-runner host.",
|
|
"",
|
|
].join("\n");
|
|
}
|
|
|
|
const isCli = process.argv[1] !== undefined && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
if (isCli) {
|
|
const failures = await findSystemTestPrerequisiteFailures();
|
|
if (failures.length > 0) {
|
|
process.stderr.write(formatSystemTestPrerequisiteReport(failures));
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write("System test prerequisites: PASS\n");
|
|
}
|