# task-2729+5 — P0-B ANU-owned pickup runner 감지경로 audit-first 재검증 + controlled pilot 설계

## 레벨
Lv.3 (시스템 검증/설계 — 코드 신규 구현 없음, audit-first + 설계 산출)

## 한 줄 목표
ANU-owned pickup runner가 `result.json`을 감지하는 경로(systemd-path → entrypoint → driver `scan_once` → pickup_once)를 **audit-first(read-only)** 로 재검증하고, **dry-run / mock fixture 기반 decision-only 검증** + **controlled pilot 설계 문서**를 산출한다. **production ACTIVE 전환·systemctl enable·자동 wake 활성화는 일절 하지 않는다.**

## 배경 (단일 소스)
- P0-A 완료: `P0A_COMPLETED_WITH_AUTHORITATIVE_COMPLETION_AND_POST_MERGE_SMOKE_PASS` (PR#174 merge 5b86e168).
- pickup chain 현 상태: `IMPLEMENTED / WIRED candidate / ACTIVE=false`. 정본 origin/main:
  - `deploy/systemd/anu-pickup.path` · `deploy/systemd/anu-pickup.service`
  - `scripts/anu_pickup_entrypoint.sh`
  - `dispatch/anu_pickup_driver.py` (blob 8b2174a5) · `dispatch/anu_result_pickup_runner.py` (blob 54ffe22d)
  - `tests/regression/test_anu_pickup_driver_2721.py` · `tests/regression/test_anu_result_pickup_runner_2720.py`
- 선행 증거: 회귀 46/46 PASS, preflight CAVEAT(systemd 미설치/safety PASS/dry-run guard PASS), `ANU_PICKUP_PILOT_PASS`(1회성 격리 pilot).
- 미해결 wake-gap: result.json 생기는데 ANU 자동 wake 0 → dead-man/manual 의존. P0-B가 **재검증**할 대상.

## 🔒 LOCK 조건 (11) — 위반 시 즉시 HOLD_FOR_CHAIR
1. **expected_files 명시** (아래 EXPECTED FILES 외 수정 0)
2. **forbidden paths 명시** (아래 FORBIDDEN 수정/write 0)
3. **ACTIVE=false 고정** — 어떤 산출물도 capability를 active로 만들지 않는다
4. **`systemctl enable --now` 실행 금지**
5. **production pickup activation 금지** (`memory/state/p0b_driver_enabled` 생성/`enabled` write 금지)
6. **ANU key raw 출력 금지** (.env.keys 실키·`--key`·16hex literal 노출 0)
7. **merge / push / PR comment 자동 실행 금지**
8. **duplicate pickup 방지 조건 필수** (dedupe ledger + done/acked marker 검증)
9. **terminal marker 존재 시 no-op 필수** (`{task_id}.pickup.done`/`.acked` → SKIP)
10. **runaway guard 필수** (activation flag default DISABLED + flock single-flight + scan 상한 검토)
11. **★ audit / dry-run / pilot 은 isolated temp root 에서만 수행** (OWNER_TRIGGER_DRY_RUN_LEDGER_CONTAMINATION 재발 방지):
    - canonical `memory/events` 수정 금지
    - canonical ledger 수정 금지 (`owner-trigger-audit.jsonl`, `callback_4tuple_index.jsonl` 등)
    - canonical `memory/state` 수정 금지
    - systemd user unit 수정 금지
    - production path 직접 write 금지
    - dry-run 이 POSTED/DEDUPED 등 production 상태를 남기는 것 금지
    - canonical root 에 영향이 필요한 경우 **HOLD_FOR_CHAIR 로 중단**

## 목표 (5)
1. ANU-owned pickup runner의 result.json 감지 경로를 **audit-first(read-only)** 로 재검증한다.
2. **dry-run / mock fixture 기반 decision-only 검증** — `scan_once`/`process_one`/`pickup_once`를 isolated temp root + 주입형 인자(pickup_fn/verify_fn/probe/clock/flag_reader)로 호출, 실 발사 0.
3. **controlled pilot 설계 문서** 작성 (절차·성공기준·중단조건·격리 root 강제).
4. pilot 후에도 ACTIVE=false 유지.
5. ACTIVE=true 전환은 별도 회장 승인 대기.

## audit-first 재검증 항목 (read-only, 6조건 + 감지경로)
1. 감지 트리거: `anu-pickup.path` `PathExistsGlob=%h/workspace/memory/events/task-*.result.json` → `anu-pickup.service` oneshot → `anu_pickup_entrypoint.sh`. **현재 미설치(systemd not-found) 재확인**.
2. entrypoint: activation flag default DISABLED(`p0b_driver_enabled`!=`enabled` → exit 0), flock single-flight, XDG_RUNTIME_DIR lock, symlink 거부, **ANU key argv 0**.
3. driver `scan_once`: flag 재확인 → disabled면 `[NOOP_DISABLED]` + pickup 미호출. enabled면 glob → `process_one`.
4. `process_one` 6조건: target(`task-*.result.json`) → readiness grace → size>0 → JSON parse(null-byte 방어) → schema(task_id 경로탐색 방어) → owner proof(`verify_collector_authoritative`) → dedupe/done/acked.
5. `pickup_once`: terminal no-op(step3) → dedupe(step4) → collector verify(step5) → sealed-key(step6, `.env.keys` `COKACDIR_KEY_ANU`만) → argv build(`anu_runner_pickup_and_fire`, 실 cron 0) → ledger/done marker.
6. **driver 는 argv 실행 안 함** (P0-a dry_run, 실 wake 0) 재확인.

## CAVEAT 반영 (활성화 전 보완 — 설계 input, 본 task 에서 코드 구현 X)
- C1. `scan_once` MAX_FILES 상한 (무제한 result pickup 방지)
- C2. ledger/marker 쓰기 실패 처리 (현재 fail-safe pass → 명시적 실패 처리/관측)
- C3. raw_key_exposure 수동확인 (preflight 286건 = pickup 스택 밖 venv hex 확정)
- ★ ledger-safety 묶음: C2 + owner_gemini_trigger dry-run ledger 격리 → **task-2717 Phase2 / task-2729+5 설계 input** 으로 통합 검토

## allowed_resources (본 task capability — scope guard)

```yaml
allowed_resources:
  paths:
    - "memory/reports/task-2729+5-p0b-audit-first.md"
    - "memory/plans/p0b-pickup/**"
    - "scripts/harness/v36/anu_pickup_p0b_audit_decision_check.py"
    - "tests/regression/test_anu_pickup_p0b_audit_decision_check.py"
    - "memory/events/task-2729+5.*"
    - "memory/tasks/task-2729+5-p0b-audit-first.md"
  read_only_reference:
    - "dispatch/anu_result_pickup_runner.py (★ audit 대상 — read only)"
    - "dispatch/anu_pickup_driver.py (★ audit 대상 — read only)"
    - "scripts/anu_pickup_entrypoint.sh (★ audit 대상 — read only)"
    - "deploy/systemd/anu-pickup.path (★ audit 대상 — read only)"
    - "deploy/systemd/anu-pickup.service (★ audit 대상 — read only)"
    - "tests/regression/test_anu_result_pickup_runner_2720.py"
    - "tests/regression/test_anu_pickup_driver_2721.py"
    - "scripts/harness/v36/anu_pickup_preflight_check.py"
  forbidden_paths:
    - "dispatch/anu_result_pickup_runner.py"
    - "dispatch/anu_pickup_driver.py"
    - "dispatch/**"
    - "scripts/anu_pickup_entrypoint.sh"
    - "deploy/systemd/**"
    - "memory/state/**"
    - "memory/p0b_state/**"
    - "memory/events/owner-trigger-audit.jsonl"
    - "memory/events/callback_4tuple_index.jsonl"
    - "scripts/ci_watch_handoff_runner.py"
    - "utils/**"
    - "scripts/finish-task.sh"
    - "dispatch.py"
    - ".github/**"
    - "hooks/**"
    - "/home/jay/.claude/**"
    - "/home/jay/.config/systemd/**"
    - "/usr/local/bin/cokacdir"
```

> ★ scope 주: 봇 산출은 위 `paths`(보고서/pilot설계/audit스크립트+회귀/자기 task 마커)만. pickup 런타임·systemd·canonical ledger/state 는 `read_only_reference`(audit 대상)이되 `forbidden_paths`로 write 차단. 모든 audit/dry-run/pilot 은 **/tmp isolated root**에서 수행하고 요약만 `memory/reports`에 기록(lock 11).

## EXPECTED FILES (산출, audit-first — 코드 신규 구현 0)
- `memory/reports/task-2729+5-p0b-audit-first.md` (audit 재검증 결과)
- `memory/plans/p0b-pickup/controlled_pilot_design_260605.md` (pilot 설계: 절차/성공기준/중단조건/격리 root)
- `scripts/harness/v36/anu_pickup_p0b_audit_decision_check.py` (read-only decision-only 검증 스크립트, isolated temp root 강제 — 신규 audit 도구, 런타임 pickup 코드 무수정)
- `tests/regression/test_anu_pickup_p0b_audit_decision_check.py` (위 스크립트 회귀)

## FORBIDDEN (수정/write 0)
- `dispatch/anu_result_pickup_runner.py` · `dispatch/anu_pickup_driver.py` (런타임 코드 — audit-first, 무수정)
- `scripts/anu_pickup_entrypoint.sh` · `deploy/systemd/anu-pickup.path` · `deploy/systemd/anu-pickup.service`
- `memory/state/p0b_driver_enabled` (생성/write 금지)
- canonical `memory/events/*` · canonical ledger(`owner-trigger-audit.jsonl`, `callback_4tuple_index.jsonl`) · `memory/p0b_state/*`
- systemd user unit (`~/.config/systemd/user/*`) — install/enable 금지
- P0-A 4파일 · PR#174 후속 코드 변경 금지

## 금지 (9)
1. production ACTIVE 전환  2. systemd enable  3. canonical ledger 오염  4. canonical memory/events 오염  5. result.json 중복 처리  6. real ANU spawn  7. 실제 PR merge/push/comment  8. P0-A 또는 PR#174 후속 코드 변경  9. ACTIVE=true 선언

## 산출 판정
- 본 task = audit + 설계 + decision-only 검증까지. 실제 OS wiring 구현/ACTIVE 전환은 **별도 task + 회장 승인**.
- 최종 보고: **DISPATCH_READY_FOR_CONTROLLED_PILOT**(audit PASS + pilot 설계 완료, 실제 pilot 실행은 회장 승인 대기) 또는 **HOLD_FOR_CHAIR**(canonical 영향/미해결 결정 필요).

---

## ★ 회장 verbatim 조건 (2026-06-05 dispatch 승인) — paraphrase 금지

### 범위 (13)
1. 구현 dispatch 아님 — audit-first / dry-run / pilot 설계 검증. 2. production ACTIVE 전환 금지. 3. systemctl enable --now 금지. 4. 실제 systemd unit 설치/수정 금지. 5. canonical memory/events 수정 금지. 6. canonical ledger 수정 금지. 7. canonical memory/state 수정 금지. 8. production path 직접 write 금지. 9. real ANU spawn 금지. 10. 실제 PR merge/push/comment 금지. 11. dry-run이 POSTED/DEDUPED 같은 production 상태를 남기는 것 금지. 12. 모든 audit/dry-run/pilot은 isolated temp root에서만 수행. 13. canonical root 영향이 필요하면 즉시 HOLD_FOR_CHAIR로 중단.

### 필수 검증 (10)
1. anu-pickup.path / service / entrypoint / driver / runner의 실제 경로와 버전 확인. 2. user systemd 설치/enable/active 상태 확인. 3. result.json 감지 경로 확인. 4. debounce / lock / idempotency 확인. 5. terminal marker 존재 시 no-op 확인. 6. duplicate pickup 방지 확인. 7. ANU key raw 노출 0 확인. 8. runaway guard 확인. 9. isolated temp root에서 mock result.json decision-only 검증. 10. production canonical ledger/events/state 영향 0 확인.

### pilot 설계 조건 (8)
1. 1회성 pilot만 설계. 2. noop fixture 또는 terminal marker가 이미 있는 안전 fixture 기준. 3. pickup runner 1회만 발사되는지 검증 기준 포함. 4. duplicate pickup 0 기준 포함. 5. terminal marker 존재 시 no-op 기준 포함. 6. 실제 merge/push/comment/spawn 0 기준 포함. 7. pilot 후에도 ACTIVE=false 유지. 8. ACTIVE=true 전환은 별도 회장 승인 대기.

### 중단 조건 (10) — 하나라도 해당 시 즉시 HOLD_FOR_CHAIR
1. canonical root write 필요. 2. production ledger/events/state write 필요. 3. systemd enable/install 필요. 4. ANU key raw 출력 위험. 5. duplicate pickup 방지 불명확. 6. runaway guard 불충분. 7. real ANU spawn 필요. 8. pickup runtime 파일 수정 필요. 9. expected_files 초과 필요. 10. ACTIVE=true 필요.

### 완료 산출 (5)
1. P0-B audit report. 2. controlled pilot design. 3. isolated temp root dry-run evidence. 4. capability delta report. 5. **DISPATCH_READY_FOR_CONTROLLED_PILOT 또는 HOLD_FOR_CHAIR 판정**.

### 최종 상태 고정
- 이번 dispatch 결과가 PASS여도 **production ACTIVE로 기록 금지**.
- 최종 상태 = **IMPLEMENTED / WIRED candidate / ACTIVE=false** 유지.

## doctrine (필수 포함)
- 직접 코딩 금지(ANU)/봇 위임 / same-PR post-Gemini push 금지 / chain hard limit / long polling 금지 / cron PROMPT ≤2800자·≤3900 bytes / callback ANU key 독립 발사 / executor self-collector 금지.
