# task-2729+10 — START_TASK_GUARD_CANONICAL_BRANCH_ASSUMPTION_BLOCKER infra hardening (audit-first)

## 레벨
Lv.3 (infra guard hardening — canonical workspace 무손상, isolated temp git repo 검증)

## 한 줄 목표
start_task_guard / finish-task GIT-GATE / pre-commit 이 **canonical workspace branch=main 가정** 때문에 정상 격리 worktree task 를 false-block(lock 미생성 → commit/finalize/callback 차단)하지 않도록, **worktree-root 기준 검증**으로 전환한다. **canonical workspace(task-2716 dirty branch)는 reset/clean/stash 0 무손상.** 모든 검증은 isolated temp git repo.

## 확정 root cause (단일 소스)
- `START_TASK_GUARD_CANONICAL_BRANCH_ASSUMPTION_BLOCKER` (memory/events/start_task_guard_canonical_branch_assumption_blocker_backlog_260606.json).
- start_task_guard #7 이 canonical workspace 의 main branch 상태(merge-base判定 + `rev-parse origin/main`, line ~289-296/489)를 요구 → canonical 이 task/task-2716 에 parked 면 실패 → `.tasks/locks/<task>.lock` 미생성 → pre-commit 차단 → commit 불가 → finish-task GIT-GATE(EXTERNAL_DIRTY_BLOCKER) → .done 0 → callback 미발사.
- 실증: task-2729+5/+7/+8 동일 — 매번 ANU lock 복구로 수동 우회.
- #182 BASE_SOURCE_ISOLATION 은 stale **base** 만 해소(symptom 1). 본 task 는 commit/finalize/callback 의 canonical branch 가정(symptom 2) 해소.

## 설계 (audit-first — 회장 #3 더 안전한 방향)
### 방향 비교
- **OPT-W (worktree-root 기준 검증, ★ANU 권장)**: guard 가 **worktree 자체**(전용 .worktrees/<task>-<bot> 경로 + branch task/<task>-<bot> + base 가 origin/main 후손인지)를 검증. canonical workspace branch/dirty 상태 **무관**. #182 로 worktree 가 fresh origin/main base 보장되므로 worktree-root 검증만으로 충분·안전. canonical 무손상.
- OPT-M (canonical-main 독립 worktree 기준): canonical 옆에 별도 main-tracking worktree 운용 후 그것 기준 검증. 추가 worktree 운영 오버헤드 + 결선 복잡. 비권장.
- → **OPT-W 채택 권장.**
### 구현 방향
- **G1 start_task_guard #7**: "canonical workspace=main" 요구 제거/완화 → worktree base 가 `origin/main` ancestor 인지(fresh-base, #182 marker 활용)만 검증. PASS 시 lock 정상 생성. canonical branch 무관.
- **G2 finish-task GIT-GATE**: EXTERNAL_DIRTY 판정을 **worktree 자기 변경(scope-guard per-task diff) 기준**으로 한정 — canonical 의 무관 dirty(다른 task)로 false-block 0. (worktree REAL_DIFF/REAL_CACHED 는 본 task 파일만 검사)
- **G3 (검토)**: pre-commit lock 검증은 유지(lock 존재 확인). lock 생성이 G1 로 정상화되면 G3 변경 불요.

## allowed_resources
```yaml
allowed_resources:
  paths:
    - "scripts/start_task_guard.py"
    - "scripts/finish-task.sh"
    - "tests/regression/test_start_task_guard_worktree_root_2729p10.py"
    - "memory/reports/task-2729+10.md"
    - "memory/plans/p0b-pickup/canonical_branch_assumption_design_260606.md"
    - "memory/events/task-2729+10.*"
    - "memory/tasks/task-2729+10-start-task-guard-canonical-branch-assumption.md"
  read_only_reference:
    - "scripts/git-hooks/pre-commit (lock 검증 — 참조, 수정 0 목표)"
    - "scripts/worktree_manager.py (#182 base marker 참조)"
    - "memory/events/start_task_guard_canonical_branch_assumption_blocker_backlog_260606.json"
  forbidden_paths:
    - "/home/jay/workspace (canonical working tree — 브랜치전환/reset/clean/stash/checkout -f 금지)"
    - "memory/events/task-* (다른 task live 마커)"
    - "memory/tasks/** (task-2729+10 제외)"
    - "dispatch.py"
    - "dispatch/**"
    - "utils/**"
    - ".github/**"
    - "hooks/**"
    - "/home/jay/.claude/**"
    - "/usr/local/bin/cokacdir"
```

## EXPECTED FILES (정확히 5 — 초과 시 즉시 HOLD_FOR_CHAIR)
1. `scripts/start_task_guard.py` — G1 worktree-root 기준 #7
2. `scripts/finish-task.sh` — G2 GIT-GATE worktree-scoped dirty (per-task diff 한정)
3. `tests/regression/test_start_task_guard_worktree_root_2729p10.py` — isolated temp git repo 회귀(canonical=task-X parked 상태서 worktree task lock 정상 생성 / 무관 dirty false-block 0)
4. `memory/reports/task-2729+10.md`
5. `memory/plans/p0b-pickup/canonical_branch_assumption_design_260606.md`
- ★ finish-task.sh(G2) 가 5파일 초과/과도 변경 필요 시 G1-only 로 축소 또는 HOLD_FOR_CHAIR.

## 필수 검증
1. isolated temp git repo 에서 canonical=task-X(non-main) parked + dirty 상태 재현.
2. 그 상태서 worktree task(fresh origin/main base) 의 start_task_guard 가 **lock 정상 생성**(false-block 0).
3. 무관 dirty(다른 task 파일)로 finish-task GIT-GATE false-block 0 (worktree 자기 변경만 검사).
4. worktree base 가 origin/main 후손 아니면(stale) 여전히 차단(정상 방어 유지).
5. canonical workspace 무손상(reset/clean/stash 0).
6. 기존 회귀 무영향.

## 금지 (회장 verbatim)
1. canonical workspace reset/clean/stash -u/checkout -f  2. task-2716 branch 수정  3. live memory artifacts 이동·삭제  4. production ACTIVE 전환  5. systemctl enable  6. real ANU spawn  7. ACTIVE=true 선언
- 모든 검증 isolated temp git repo. canonical /home/jay/workspace 무손상.

## 산출 판정
- **DISPATCH_READY** 또는 **HOLD_FOR_CHAIR**.
- 본 task = guard 가정 hardening. pickup activation 과 독립. PASS 시 후속 task callback/finalize 정상화(ANU 수동 lock 복구 불요).

## doctrine
직접 코딩 금지(ANU)/봇 위임 / canonical 무손상 / isolated temp git repo 검증 / same-PR post-Gemini push 금지 / callback ANU key 독립·self-collector 금지.
