# CODE_ROOT_PREFLIGHT — 설계·검증 결과 (production activation 전, 실행 0)

> 상태: **CODE_ROOT_PREFLIGHT_READY** (preflight 준비·검증만 / systemctl enable·ACTIVE=true·activation_epoch·real spawn 별도 회장 승인 전까지 금지)
> 작성: ANU 2026-06-07 / 코드 기준 origin/main `0ce319ca`(p0b chain 8 PR)
> 상위: `ACTIVATION_READINESS_CHAIN_AND_CODE_DATA_ALIGNMENT_MERGED_ACTIVE_FALSE`

## 1. CODE_ROOT clean main worktree
- 경로: **`${HOME}/p0b-pickup-main`** (canonical 외부 sibling, 영속·stable, 휘발성 아님).
- 생성: `git worktree add --detach ${HOME}/p0b-pickup-main origin/main`.
- 동기: `git -C ${HOME}/p0b-pickup-main fetch origin main && git -C ${HOME}/p0b-pickup-main checkout --detach origin/main` (enable 전·정기).
- canonical(/home/jay/workspace, task-2716 parked) 무손상 — 별도 worktree.

## 2. preflight 검증 결과 (12/12 PASS, read-only + isolated)
| # | 항목 | 결과 |
|---|----|----|
| 1 | CODE_ROOT path | `${HOME}/p0b-pickup-main` 존재 ✓ |
| 2 | git head / origin/main 최신성 | `0ce319ca` = origin/main, ancestor YES ✓ |
| 3 | #184/#186/#187/#188 포함 | wake_launcher·start_task_guard·finish-task·post186_audit·entrypoint·service·driver·runner 8/8 ✓ |
| 4 | driver import / entrypoint bash -n / service ExecStart / PYTHONPATH | import OK(CODE_ROOT) · bash -n PASS · ExecStart 실경로 존재 · PYTHONPATH=CODE_ROOT ✓ |
| 5 | systemd path unit canonical DATA watch | `PathExistsGlob=%h/workspace/memory/events/task-*.result.json` 유지 ✓ |
| 6 | DATA root = /home/jay/workspace | driver `CANONICAL_ROOT="/home/jay/workspace"` + entrypoint FLAG/LOCK=WORKSPACE ✓ |
| 7 | raw key 출력 0 | entrypoint argv key literal 0 ✓ |
| 8 | ACTIVE=false | p0b_driver_enabled ABSENT(DISABLED) ✓ |
| 9 | systemd enable 0 | anu-pickup.path/.service not-found(not-enabled) ✓ |
| 10 | activation_epoch absent | ABSENT ✓ |
| 11 | real spawn 0 | driver launcher_fn=None default(surface only) ✓ |
| 12 | canonical result.json 이동·삭제·quarantine 0 | events 140 무변동, HEAD task-2716 ✓ |

## 3. result.json 140 lineage + legacy NOOP isolated 재검증 (CODE_ROOT 코드)
- lineage: events/*.result.json **140** = scan 대상 `task-*.result.json` **128** + 비대상(`task-` 미시작) **12**(NOOP_NOT_TARGET).
- 방법: CODE_ROOT(0ce319ca) 코드 PYTHONPATH + canonical 140 basename·원본 mtime 보존 복제(원본 0 손상) temp DATA root + `flag=enabled` + `epoch=now` + `scan_once(legacy_cutoff=True)`(production main() 동일).
- 결과: `NOOP_LEGACY_SKIP 50`(pre_activation_epoch) + `NOOP_MAX_FILES_DEFER 1`(78 다음 cycle). **temp events 140 이동·삭제 0, quarantine 0, wake 0.** cycle 누적 시 128 전부 legacy skip·12 NOOP_NOT_TARGET, move 0.
- canonical 무손상(events 140, HEAD task-2716).
- 고정 조건: enable 직전 `p0b_activation_epoch=time.time()` 1회·불변 → 현재 140 전부 pre-epoch 영구 NOOP_LEGACY_SKIP.

## 4. dry_run=False real wake pilot 제안 (별도 단계, 미승인)
- 본 preflight 는 **CODE_ROOT 준비·검증까지**. real auto-wake 는 별도.
- 필요성: real spawn 발생 4조건((a)flag enabled (b)launcher_fn=launch_wake 주입 (c)dry_run=False (d)anu_key_verifier callable) 중 (b)(c)는 dry_run=True mock pilot(12/12)만 검증됨 — **실 spawn 미검증**. activation 전 dry_run=False 1회 controlled pilot 필요.
- 안전 조건(제안): ① isolated/canary result.json 1건 한정(production 140 legacy 영향 0, epoch 이후 canary) ② anu_key_verifier callable fail-closed 확인 ③ subprocess sabotage 재확인 ④ 단발(1 spawn)·관측 후 즉시 launcher_fn=None 환원 ⑤ 회장 별도 승인 ⑥ canonical legacy 140 무변동.
- **본 단계에서 실행 0.**

## 5. activation 전 잔여 precondition (회장 결정)
1. real-wake 정책 (가)감지+ledger only / (나)real auto-wake.
2. CODE_ROOT worktree = **생성·검증 완료(본 preflight)** → enable 시 동기 재확인만.
3. dry_run=False controlled pilot 1회(§4).
4. G4 counter reset 시점(STALE_RESIDUE, deferred).
5. systemd enable / activation_epoch 생성 / flag enabled = 회장 승인.

## 판정
**CODE_ROOT_PREFLIGHT_READY** — CODE_ROOT worktree 생성·12 검증 PASS·isolated legacy NOOP(이동 0) 완료. activation 실행은 §5 회장 결정 대기. **systemctl enable / ACTIVE=true / activation_epoch / real wake pilot 미실행. canonical·task-2716·result.json·G4 무손상.**
