# Axis 3 Destructive Commands — Finalized (Phase 0)

- task_id: task-2652
- chair_authorization_id: `CHAIR-AUTH-AXIS-3-PHASE0-20260524-JJONGS-PRETOOLUSE-AUDIT-001`
- ts: 2026-05-24 KST
- status: **FINALIZED_FOR_CHAIR_SIGNATURE** (★ 실 적용은 별도 live activation chair signature 후)

## 1. task-2643 hook 5 그룹 (★ 그대로 유지)

PR #146 head 33c51992 `hooks/pre_tool_use_anu_guard.py` 정독 결과 5 그룹은 그대로 유지하고 확장 destructive 5 entry만 신규 추가한다.

### Group 1 — BACKGROUND_GH_PR_POLL
- 조건: `run_in_background == True` AND 다음 중 1개 이상 match
  - `\bgh\s+pr\s+(view|checks)\b` (IGNORECASE)
  - `statusCheckRollup` (IGNORECASE)
- action: DENY (reason=ANU_DIRECT_CI_POLLING_FORBIDDEN)

### Group 2 — LOOP_SLEEP_GH_PR_POLL
- 조건: `\b(while|until|for)\b` AND `\bsleep\s+(\d+\.?\d*|\.\d+)[smhd]?` AND `\bgh\s+(pr|run|api)\b` (IGNORECASE) 모두 충족
- action: DENY

### Group 3 — GH_RUN_WATCH_POLL
- 조건: `\bgh\s+run\s+watch\b` 또는 `\bgh\s+run\s+list\b` (IGNORECASE)
- action: DENY

### Group 4 — SEMANTIC_CI_GEMINI_WAIT
- 조건: `\b(wait\w*|until|poll\w*|monitor\w*|nudge_wait|gemini[\w\s.]*review\w*|ci[\w\s.]*complete\w*)\b` (IGNORECASE) AND (`\bgh\s+` 또는 `api.github.com` 또는 `statuscheckrollup` 포함)
- action: DENY

### Group 5 — EXPLICIT_FORBIDDEN_ACTION (모두 IGNORECASE)
- `admin[\s_-]*override` / `BOT_GITHUB_TOKEN` / `BOT_APP_TOKEN` / `chair_authorization` / `auto[\s_-]*merge.*activat`
- `\bPR\s*#?141\b.*pilot`
- `\bgh\b[^|;&]*--admin\b` / `\bpr\s+merge\b[^|;&]*--admin\b`
- action: DENY

## 2. 신규 destructive 5 entry (chair packet field_07 + 본 Phase 0 확장)

| # | pattern | category | action |
|---|---|---|---|
| 6 | `\brm\s+-rf\s+/(?:\s|$)` · `\brm\s+-rf\s+/home/jay(\s|/|$)` · `\brm\s+-rf\s+\*\s*$` | filesystem wipe | DENY |
| 7 | `\bgit\s+push\s+(--force|-f)\b.*\b(origin\s+)?main\b` · `\bgit\s+push\s+.*\b\+main\b` | force push to origin/main | DENY |
| 8 | `\bgit\s+reset\s+--hard\s+(?!HEAD\b)` · `\bgit\s+checkout\s+--\s+.*\.py$` (수정 중인 파일 강제 폐기) | uncommitted work destruction | DENY (WARN으로도 운영 가능 — chair 결정 대상) |
| 9 | `\bgit\s+branch\s+-D\s+(main|master)\b` | protected branch deletion | DENY |
| 10 | `\bcokacdir(\s|/usr/local/bin/cokacdir)\s+--cron-remove\b` (단 본인 schedule_id 제외 — `--key c119085addb0f8b7` 매칭 시 allow) | arbitrary schedule destruction | WARN (★ ANU 자기 callback 정리는 정당 사용 — 조건부 BLOCK) |

## 3. action enum

- `DENY` — claude-code 가 tool call 차단 (현재 hook 의 deny return)
- `WARN` — tool call 허용 + audit log + 봇 telemetry (★ live activation 시 wiring 필요 · 현재 hook은 WARN 미지원)
- `AUDIT_ONLY` — tool call 허용 + audit log only

★ 현재 hook은 DENY/ALLOW 이분법. WARN/AUDIT_ONLY 도입 결정은 live activation chair signature 시 별도 합의.

## 4. allowed_alternative (DENY 시 반환 필드)

- 현재 hook return: `"allowed_alternative": "delegated_watcher_contract"`
- 신규 destructive 6-10 entry에는 alternative 가 다를 수 있음:
  - rm -rf → "정확한 path 지정 후 다시 시도하세요. /home/jay/* 절대 경로 사용 금지."
  - git push --force → "git push --force-with-lease 사용 + PR 절차 준수"
  - git reset --hard → "git stash 또는 새 branch 분기 후 작업"
  - git branch -D main → "protected branch 보호. 회장 verbatim signature 후 별도 task"
  - cokacdir --cron-remove → "본인 schedule ID 확인 후 chair-owned key 시 정당 사용"

## 5. WARN doctrine 도입 검토 (★ live activation 결정 대상)

| 후보 | DENY 옹호 근거 | WARN 옹호 근거 | 권장 |
|---|---|---|---|
| Group 6 rm -rf / | filesystem wipe 회복 불가능 | 거의 발생 안 함 | DENY |
| Group 7 force push main | main 보호 critical | rebase 정상 워크플로우 충돌 | DENY (origin/main만 · feature branch 허용) |
| Group 8 git reset --hard | 작업 손실 위험 | 정상 reset 빈도 높음 | WARN |
| Group 9 branch -D main | main 삭제 critical | 의도 미사용 | DENY |
| Group 10 cron-remove | ANU owned schedule 자기 정리 정당 | 무관 schedule 임의 삭제 risk | WARN (key 매칭 시 allow) |

## 6. forbidden_action_count = 0

본 spec 작성 단계에서 실제 destructive command 실행 0. 모든 pattern 은 정적 spec 화 단계.

## 7. 후속 검증 항목 (★ live activation task)

- [ ] 신규 5 entry × deny/allow fixture (각 3 case)
- [ ] WARN doctrine 도입 시 hook return schema 확장
- [ ] cokacdir --cron-remove의 key=c119085addb0f8b7 매칭 시 allow 분기 검증
- [ ] git reset --hard / git stash 정상 워크플로우 false positive 0 확인
- [ ] chair signature manual bypass ENV 시 force push main 허용 여부 결정

끝
