# Axis 3 Smoke Set SP1-SP7 — 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**
- pass_threshold: SP1-SP7 모두 PASS (7/7) · 1건이라도 fail 시 L1 rollback

## 1. chair signature packet field_05 verbatim 1:1

본 7 step은 chair signature packet (`memory/events/chair-signature-packet-axis-3-pretooluse-runtime-guard-260524.json`) field_05 verbatim 그대로 유지하고, 본 Phase 0 audit 결과를 반영해 fixture/검증 방법을 박제한다.

### SP1 — Normal Tool noop
- 회장 verbatim: "PreToolUse hook이 정상 tool 호출 시 noop (Read/Write/Bash 일반 호출 통과)"
- 검증 fixture (현재 PR #146 dry-run report 4 allow case 재사용):
  - `allow_git_status` — `git status --short` → allow ✓
  - `allow_python_pytest` — `python -m pytest tests/regression/ -x` → allow ✓
  - `allow_single_gh_pr_view_no_background` — `gh pr view 145 --json title` (run_in_background=False) → allow ✓
  - `allow_non_bash_tool` — `Read /tmp/foo.txt` → allow (reason=NOT_BASH_TOOL) ✓
- 추가 live smoke 후보 (★ live activation 시):
  - `ls /home/jay/workspace/`
  - `git log --oneline -5`
  - `python3 -m py_compile utils/callback_collector_helper_integration.py`
- PASS 기준: 위 7 case 모두 hook return `decision == "allow"`

### SP2 — Forbidden path BLOCK
- 회장 verbatim: "forbidden path 접근 시 BLOCK return (e.g. Read /home/jay/.env)"
- 검증 fixture (★ live activation task에서 신규 작성 — 본 hook은 현재 path-based check 미구현):
  - Read `/home/jay/.env` → BLOCK (reason=FORBIDDEN_PATH_ACCESS)
  - Read `/home/jay/.claude/settings.local.json` → BLOCK
  - Write `/usr/local/bin/cokacdir` → BLOCK
  - Read `/home/jay/.ssh/id_rsa` → BLOCK
- 정상 (negative) case:
  - Read `/home/jay/workspace/memory/tasks/task-2652.md` → allow
  - Write `/home/jay/workspace/memory/specs/axis_3_phase_0_audit_report_260524.md` → allow
- 현재 hook 구현 상태: **path-based check 미구현** (5 그룹 모두 Bash command pattern matching) → live activation 전에 `_matches_forbidden_path` 추가 필요
- spec 위치: `memory/specs/axis_3_forbidden_paths_finalized_260524.md`

### SP3 — Credential pattern BLOCK·WARN
- 회장 verbatim: "credential pattern (e.g. ghp_/ghs_/PEM/AWS key) 포함 Write 시 BLOCK 또는 WARN"
- pattern 후보:
  - `ghp_[A-Za-z0-9_]{36,}` / `ghs_[A-Za-z0-9_]{36,}` (GitHub PAT)
  - `-----BEGIN (RSA )?PRIVATE KEY-----` (PEM)
  - `AKIA[0-9A-Z]{16}` (AWS access key)
  - `BOT_GITHUB_TOKEN` · `BOT_APP_TOKEN` (이미 Group 5 cover)
- 현재 hook 구현 상태: Bash command 안의 `BOT_*_TOKEN` 만 Group 5 cover · Write content 검사 미구현
- 결정 권장: live activation 시 Write `tool_input.content` 정규식 매칭 추가 (BLOCK 우선, false positive 시 WARN downgrade)

### SP4 — Destructive command BLOCK·WARN
- 회장 verbatim: "destructive command (rm -rf · git push --force · git reset --hard) BLOCK 또는 WARN"
- 현재 hook 구현 상태: Group 5 EXPLICIT_FORBIDDEN_ACTION 가 `admin override` 등 일부 cover · `rm -rf` / `git push --force` / `git reset --hard` 미cover
- 검증 fixture (★ live activation task에서 신규):
  - `rm -rf /` → BLOCK
  - `git push --force origin main` → BLOCK
  - `git reset --hard origin/main` → WARN (현재 branch에서 강제 reset)
  - `git branch -D main` → BLOCK
  - `cokacdir --cron-remove abc123` → WARN (key 매칭 없으면)
- spec 위치: `memory/specs/axis_3_destructive_commands_finalized_260524.md`

### SP5 — Axis 1/2 충돌 0
- 회장 verbatim: "Axis 1/2 hook과 충돌 0 (SessionStart/Stop/UserPromptSubmit 동작 변화 0)"
- 검증 방법:
  - `~/.claude/settings.json` 의 hooks.SessionStart / hooks.Stop / hooks.UserPromptSubmit 항목 unchanged 확인
  - Axis 1 helper (utils/callback_registration · authority_validator · source_cross_checker) 동작 변화 0 검증 — sample dispatch cycle 1회 실행 후 `memory/system/.callback_ledger.jsonl` 신규 entry 정합 확인
  - Axis 2 v2 utils (callback_collector_helper_integration / adjudicator_v2 / next_action_runner_v2 / source_attribution_guard_v2) regression baseline 유지 확인 (예: 1576+ test PASS · PR #145 merge 후 기준)
- import collision 분석: `memory/specs/axis_3_axis_1_2_import_collision_analysis_260524.md` (★ 본 Phase 0 산출물)

### SP6 — dispatch.py 정상 통과
- 회장 verbatim: "dispatch.py 호출 시 PreToolUse가 dispatch 자체를 차단하지 않음 (★ 일반 dispatch cycle 통과)"
- 검증 fixture:
  - `python3 /home/jay/workspace/dispatch.py --task-id <task_id> --level 2 ...` → allow
  - `python3 -c "from dispatch import normal_fallback_callback_helper; ..."` → allow
  - bash로 `gh pr view <num> --json title` (run_in_background=False · single shot) → allow
- 위험: Group 4 SEMANTIC_CI_GEMINI_WAIT가 dispatch 호출에 우연 match 가능 → false positive 점검 필수
- 결정: dispatch.py 호출 자체는 `python3` 시작이므로 `\bgh\b` 와 충돌 0 ✓

### SP7 — hook crash fail-safe
- 회장 verbatim: "hook crash 시 봇 process 자체 멈추지 않음 (★ fail-safe: hook crash → tool 호출 허용 · audit log)"
- ★ **doctrine 충돌 주의**: 현재 hook의 fail-closed 설계 (`HOOK_FAIL_CLOSED` → DENY)와 SP7의 fail-safe (allow) 가 정면 충돌
- 해석:
  - task-2643 spec ANCHOR-5: "fail-closed (hook timeout/parse error/config missing → DENY · allow fallback 금지)"
  - SP7 chair packet: hook crash → tool 허용
- 권장 해결: 
  - **hook 정상 동작 시 fail-closed** (DENY) 유지
  - **claude-code 가 hook 자체를 spawn 실패** (timeout > 5s, FileNotFoundError 등 process-level) 시 claude-code 차원에서 fail-safe (tool 허용) — 이건 hook 책임 아님
  - audit log 는 `~/.claude/data/pre_tool_use_audit.jsonl` 에 wire up (★ live activation task)
- live activation 시 chair에 명시 확인 필요: "hook 내부 exception = DENY (현재 동작) · hook spawn 실패 = claude-code 차원 allow (fail-safe)" 두 doctrine 분리

## 2. SP1-SP7 PASS 판정 매트릭스

| SP | 현재 hook 직접 지원 | 추가 구현 필요 | 검증 priority |
|---|---|---|---|
| SP1 | ✓ (4 allow case 동작 확인) | - | HIGH |
| SP2 | ✗ | path-based check 추가 (`_matches_forbidden_path`) | HIGH |
| SP3 | 부분 (Bash 내 BOT_*_TOKEN만) | Write content 정규식 매칭 추가 | MEDIUM |
| SP4 | 부분 (Group 5 일부) | rm -rf / git push --force / reset --hard 패턴 추가 | HIGH |
| SP5 | ✓ (import collision 0 · slot 분리) | - | HIGH |
| SP6 | ✓ (dispatch 호출 match 0) | dispatch 호출 fixture 작성 | MEDIUM |
| SP7 | doctrine 충돌 검토 필요 | claude-code 차원 fail-safe 정의 명시 | HIGH |

## 3. live activation 시 신규 fixture 생성 대상

- `tests/fixtures/pre_tool_use_anu_guard/sp1_normal_tool_noop/` × 7
- `tests/fixtures/pre_tool_use_anu_guard/sp2_forbidden_path_block/` × 4 + negative × 2
- `tests/fixtures/pre_tool_use_anu_guard/sp3_credential_pattern_block/` × 4
- `tests/fixtures/pre_tool_use_anu_guard/sp4_destructive_command_block/` × 5
- `tests/fixtures/pre_tool_use_anu_guard/sp5_axis_1_2_collision_zero/` × 3 (sample dispatch + ledger 검증)
- `tests/fixtures/pre_tool_use_anu_guard/sp6_dispatch_pass_through/` × 3
- `tests/fixtures/pre_tool_use_anu_guard/sp7_hook_crash_failsafe_doctrine_split/` × 2

각 fixture = evidence.json + expected.json + PROVENANCE.md (task-2643 fixture 패턴 그대로).

## 4. 통합 smoke 절차 (★ live activation task 진입 시)

1. backup `~/.claude/settings.json` → `~/.claude/settings.json.backup.<ts>`
2. staged template merge (PreToolUse 항목만 추가)
3. ENV `CLAUDE_PRE_TOOL_USE_HOOK_ENABLED=1` 설정
4. SP1-SP7 fixture 일괄 실행 (각 SP → hook dry-run + live spawn 비교)
5. live canary session 1 회 (정상 ANU 작업 5-10 tool call · false positive 0 확인)
6. 24h 후 false positive rate 검토 (chair packet post_activation_monitoring 기준 10% 미만)
7. 회장 final acceptance 시 monitoring 영구 활성화

## 5. forbidden_action_count = 0

본 spec 작성 단계 destructive action 실행 0. 모든 SP는 정적 설계 단계.

끝
