Commit Graph
4 Commits
Author SHA1 Message Date
DongHyeonka 6d6fd61ab9 fix(ci): provider 실패 메시지에 우리 단계가 쓴 125 이유를 남긴다
문제: provider를 띄우는 우리 단계(cgroup 강제 게이트, scope wrapper)는
provider 전에 exit 125로 멈추며 stderr에 이유를 쓴다. waitForProvider는
bwrap·prlimit·systemd-run·systemctl 접두 줄만 남기고 나머지를 provider
출력으로 보고 버린다. 그래서 FE-GATE-013의 exit=125 묶음
(ci-artifact-contract 671줄부터 18개)이 `exit=125, signal=none`만 남겨
원인을 볼 수 없었다. scope wrapper가 감독자 채널을 잃고 provider 전에
125로 끝나는 길은 아무 줄도 쓰지 않았다.

고른 방법: 줄 고르기를 scripts/lib/provider-sandbox-diagnostics.ts로
옮기고, 우리 단계가 쓰는 고정 문구를 접두가 아니라 끝까지 맞는 template
으로 받는다. cgroup 값은 max와 숫자만, 오류 코드는 errno·Node 오류
이름(E…, ERR_…)만 받고, 그 모양은 scope wrapper와 한 곳에서 정한다. 줄은 개행이 온 뒤에만 판정하고(조각난 줄이
잘린 채 남지 않게), 512자 넘는 줄은 나머지 조각까지 버리며, 8줄까지
둔다. scope wrapper는 provider 전에 멈출 때
`provider scope stopped before launch: <이유>`를 쓴다. 시험은 실제 gate
shell과 그 limit 확인 함수를 돌려 나온 줄이 남는지 본다. gate 문구를
바꾸면 시험이 실패한다.
버린 대안: 허용 접두를 `provider `로 넓히기는 provider가 같은 접두로
비밀을 쓰면 실패 메시지에 싣는다. 실패 때 stderr 전부를 남기기는
provider 출력의 자격 증명을 CI 로그에 싣는다.

위험·한계: 기존 도구 접두 네 개(bwrap: 등)는 전처럼 접두만 보고 그
뒤는 512자까지 자유 문구다. liveness 채널 줄도 우리 고정 접두 뒤에 Node
오류 문구를 싣는다(출력 가능한 ASCII 200자까지). provider가 그 접두나
우리 template과 똑같은 줄을 쓰면 남는다.

검증: 노트북 감싸개에서 새 시험이 옛 허용 목록으로 13개 실패(RED),
고친 뒤 provider-sandbox-diagnostics·task3-selective-integration·
test-timeout-declarations 통과. 변이 셋(끝 앵커 제거, 긴 줄 표시 제거,
gate printf 문구 변경)에 시험이 각각 5·1·1개 실패. check:types·lint
rc=0. desktop 시스템 컨테이너에서 이 파일 전체 4회 중 1회 125 묶음이
났고 메시지에 `sandbox reported: provider cgroup enforcement failed:
cannot read memory.max`가 남았다(11건).
2026-11-14 06:04:30 +09:00
DongHyeonka 0536891c05 feat(provider): 실행 단계가 자기 PID와 argv를 실행 기록에 남긴다 (11-01)
문제: tests/system의 cgroup 테스트는 provider 실행 중 /proc을 5 ms마다
표본으로 읽어 어떤 프로세스가 어떤 argv로 돌았는지 판정한다.
systemd-run --scope는 scope로 옮긴 뒤 같은 PID에서 sh 게이트와 scope
wrapper로 exec하고, 갓 fork된 자식은 exec 전까지 부모 argv를 보인다.
표본은 PID마다 처음 본 argv만 남겨 이 짧은 단계를 자주 놓친다. 운영
코드에는 테스트가 결정적으로 읽을 실행 증거가 없다.

고른 방법: scripts/lib/provider-process-trace.ts를 추가한다.
PROVIDER_PROCESS_TRACE_PATH가 있을 때만 각 단계가 JSON 한 줄을
덧붙인다.
- 자기 기록: supervisor와 scope wrapper가 /proc/self/cmdline과
  /proc/self/cgroup을 남긴다(커널이 본 값).
- 자식 기록: supervisor가 systemd-run, guardian client가 guardian,
  wrapper가 bwrap을 spawn에 넘긴 argv 배열 그대로 남긴다. spawn과 기록이
  같은 배열을 쓴다.
- 필드는 role, pid, ppid, argv, (자기 기록만) cgroup. 환경변수는 담지
  않는다. credential과 provider 명령이 지나가는 곳이기 때문이다.
- systemd-run 환경은 허용 목록으로 다시 만들어지므로
  providerProcessTraceEnvironment()로 기록 경로만 넘긴다. bwrap은
  --clearenv라 sandbox 안의 provider는 경로를 받지 않는다. guardian은
  빈 환경을 그대로 두고 client가 spawn 지점에서 기록한다.

테스트용 opt-in으로 두고 운영 감사 증거로 쓰지 않는다. 운영에서 켜면
argv가 두 번째로 남는 곳이 생긴다. 나중에 credential이나 provider
명령이 argv에 들어가는 회귀가 생기면, 지금은 /proc에 잠깐 보이는 값이
파일로 남아 CI 산출물이 될 수 있다. 감사 증거로 쓰려면 봉인 보고서와
같은 경로 안전·크기 상한·스키마·보존 정책이 필요하고 이번 범위가
아니다. CI 워크플로는 이 변수를 설정하지 않는다.

버린 대안:
- /proc 표본 보강(부모와 같은 argv 무시, PID별 argv 이력 보존): 리뷰
  README 13.1에서 시도하고 되돌렸다. 이력 보존은 prlimit -> sh로 바뀌는
  PID 이력에 provider 명령이 섞여 "인프라 argv에 명령 없음" 단언의
  뜻이 바뀐다.
- spawn 직후 /proc/<pid>/cmdline 읽기: libuv는 exec 뒤에 반환하지만
  systemd-run은 곧 wrapper로 다시 exec하므로 경쟁이 남는다.
- guardian 자기 기록: guardian이 빈 환경으로 뜨는 것이 보장이라 기록
  경로를 넘기지 않는다.

위험·한계:
- 기록은 각 단계가 스스로 남긴다. 새 spawn 지점이 기록을 빠뜨리면
  테스트에서 보이지 않는다. 모듈 주석에 적었다.
- 기록 실패는 run 결과를 바꾸지 않고 stderr에 한 줄 남긴다. wrapper의
  stderr는 provider 출력으로 버려지므로 빠진 줄은 기록을 읽는 쪽에서
  드러난다.
- 변수가 없으면 spawn 인자와 환경은 이전과 같다.

검증:
- node scripts/run-vitest.ts run tests/unit/provider-process-trace.test.ts
  2건 통과. 자식 기록에 env 필드를 넣는 변이를 넣으면 실패한다.
- 관련 테스트 6파일 44건 통과(provider-process-trace, task3-selective-
  integration, provider-output-limiter, security-provider-evidence,
  provider-guardian-transaction, provider-process-group).
- pnpm 없는 하네스(운영 encoder로 systemd-run -> sh -> wrapper -> bwrap
  -> prlimit -> provider 실행)에서 실행 기록 20회 중 20회 완전.
- tsc(tsconfig.node.json, tsconfig.test.json), eslint 통과.
2026-11-01 20:50:00 +09:00
DongHyeonkaandClaude Opus 5 dfb7734674 fix: run the provider sandbox and admit a release to a named environment
The provider sandbox never ran. bubblewrap 0.9.0 stops parsing an `--args`
file at the first non-option and never hands the remainder back, so the
command written into that file was silently dropped: bwrap printed its usage
text, exited 1, and the provider produced no evidence at all. The options
still travel in the args file — that is what keeps host paths and credentials
out of `/proc/<pid>/cmdline` — but the command now rides on real argv, and
`encodeProviderBwrapInput` refuses a `--` so the drop cannot come back.

The scope wrapper then could not exit. It read the supervisor's liveness pipe
through `fs`, which runs a blocking `read(2)` on a threadpool thread; the
supervisor holds that pipe open for the scope's whole life, so the read never
returned and closing the descriptor did not interrupt it. Once bubblewrap
finished the wrapper deadlocked in `process.exit`, the scope outlived the
provider, and a completed run was reported as a timeout kill. The channel is
now read through the event loop, so teardown is observable and terminal.

Creation modes were left to the ambient umask. `mkdir(mode)` and `open(mode)`
are requests the kernel subtracts the umask from, so a runner exporting a
restrictive umask produced directories it could not enter and handed `tar` a
file it could not re-open. Private modes are pinned instead of inherited.

Promotion cleanup deleted before it checked. Removals run through a pinned
descriptor, so a leaf substituted after validation had this promotion's exact
five destroyed first and the substitution reported afterwards, leaving a
half-emptied directory a retry could not tell from a completed one. The name
is re-bound to the inode before anything is removed, so the failure is total.

Separately, release coherence proved the artifacts agreed with each other but
never that they belonged where they were going: a build whose runtime document
said `APP_ENV: local`, `AUTH_MODE: demo` and a loopback API is coherent with
itself and passed every gate. `public/` is copied verbatim into `dist/`, so
that local document shipped with every build regardless of what the build was
for. Runtime configuration now comes from a declared profile, and FE-GATE-027
refuses to admit an artifact to an environment it does not match — including
refusing an undeclared destination, so nothing is admitted by omission.

`REQUEST_TIMEOUT_MS` and `VITE_ROUTER_BASE_PATH` were validated and then
dropped: the V3 executor ran every operation on its contract's own deadline,
and Vite emitted root-absolute assets for a sub-path deployment. The timeout is
now a ceiling that may tighten a contract but never loosen one, and one base
path feeds the router, the Service Worker scope and the asset base together.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 16:38:19 +09:00
DongHyeonka 4dc033cf33 refactor: adapter 구현중.. 2026-08-13 16:02:21 +09:00