---
type: plan
scope: project
project: dispatch-quality-gates
created: 2026-04-24
updated: 2026-04-24
status: active
parent: anu-guide-system (Phase 4)
---

# 프로젝트 계획서: Dispatch Quality Gates — 위임 작업 품질 자동화

**프로젝트**: dev-system / dispatch-quality-gates
**목표**: 아누 의존도 제거 — 코드 레벨에서 위임 작업 품질을 자동 강제
**미팅**: 13명 전원합의 5사이클 (`memory/meetings/2026-04-24-dispatch-quality-automation.md`)
**상위**: 아누 가이드 시스템 Phase 4 (`memory/plans/anu-guide-system/`)

---

## 배경

3대 루트 원인:
- RC-1: 영향 범위 전수조사 누락 (task-2142: FeatureGate.tsx 수정, use-feature-access.ts 누락)
- RC-2: 연쇄 이슈 직렬 발견 (task-2143/2144: Vitest → pytest 연쇄 CI 실패)
- RC-3: 실동작 미검증 (task-2140: "UI 직접 확인 불가"인데 완료 처리)

제이회장님 지시: "아누가 잊어먹어도 실제로 코드가 자동으로 진행할 수 있게 해야함"

---

## 아키텍처 개요

```
[dispatch.py] ─── Pre-flight ──→ [봇 작업] ──→ [finish-task.sh] ─── Post-flight ──→ [.done]
     │                                                │
     ├─ _auto_inject_affected_files()                 ├─ Step 2.6: Impact Scanner Gate
     └─ _auto_generate_goal_assertions()              ├─ Step 2.6.5: CI Preflight Gate
                                                      ├─ Step 2.11: Unresolved Issue Gate
                                                      ├─ Step 2.12: Goal Assertions Gate
                                                      └─ Step 3: .done + gate_results JSON
                                                      
[config/gate-config.json] ← 모든 게이트의 단일 설정 소스
```

---

## 컴포넌트 명세

### 1. scripts/impact_scanner.py (신규, ~200줄)
- **목적**: 수정 파일 기반 역방향 영향 범위 스캔
- **호출자**: finish-task.sh Step 2.6
- **입력**: --project-root, --task-id (git diff에서 자동 추출)
- **출력**: JSON `{"gate_result": "PASS|WARN|BLOCK", "unmodified_references": [...]}`
- **심볼 추출**: Python=AST, TypeScript=regex (`export function/class/type/interface`)
- **검색**: grep -rn (exclude: node_modules, .git, __pycache__, dist, build, .worktrees)
- **임계치**: 0건=PASS, 1-5건=WARN, 6건+=BLOCK
- **안전장치**: 심볼당 3초 타임아웃, 최대 5심볼, COMMON_FILTER 20단어

### 2. scripts/ci_preflight.sh (신규, ~80줄)
- **목적**: 멀티 러너 CI 게이트 (pytest + tsc + vitest/jest)
- **호출자**: finish-task.sh Step 2.6.5
- **입력**: project_root, [--affected-only commit_count]
- **tech stack 감지**: pyproject.toml→pytest, tsconfig.json→tsc, vitest.config.*→vitest
- **타임아웃**: 러너당 120초, 전체 300초
- **출력**: `[CI-PREFLIGHT] overall=PASS|FAIL`

### 3. l1_smoketest_check.py (수정, +30줄)
- **목적**: "확인 불가" 패턴 차단 + 증거 필수
- **BLOCK_PATTERNS**: "UI 직접 확인 불가", "환경 제약으로 확인 불가", "해당없음.*스모크" 등
- **EXEMPT_PATTERNS**: task 키워드에 UI/컴포넌트/화면 없으면 스크린샷 면제
- **증거 필수**: 스크린샷 경로 OR curl 200 OR pytest passed

### 4. dispatch.py (수정, +80줄)
- `_auto_inject_affected_files(task_desc, workspace_root) -> str`
  - 백틱 코드 토큰 추출 → grep -rl → affected_files 자동 주입
  - COMMON_FILTER 20단어 제외, 최대 10토큰, 20파일 초과 시 경고만
- `_auto_generate_goal_assertions(task_desc, workspace_root) -> str`
  - 검증 시나리오에서 실행 가능 shell command 추출 → goal_assertions 섹션 생성
  - ALLOWED_COMMANDS 화이트리스트 (grep, curl, pytest, tsc, cat, jq)

### 5. finish-task.sh (수정, +100줄)
- Step 2.6: Impact Scanner Gate — impact_scanner.py 호출
- Step 2.6.5: CI Preflight Gate — ci_preflight.sh 호출
- Step 2.11: Unresolved Issue Gate — 보고서 미해결 카운트 (범위 내 3건 한도)
- Step 2.12: Goal Assertions Gate — task 파일 goal_assertions 실행
- Step 3 수정: .done 파일에 gate_results JSON 추가

### 6. config/gate-config.json (신규, ~40줄)
- 게이트별: enabled, mode(warn/fail), timeout, threshold
- 초기값: impact_scanner=warn, ci_preflight=warn, l1_smoketest=fail, goal_assertions=fail, unresolved=warn

---

## 도입 전략 (Phase 분리)

### Phase 4-1A: 즉시 FAIL (명백한 위반만)
- l1_smoketest 강화 (mode=fail)
- goal_assertions 게이트 (mode=fail)
- dispatch.py auto_inject + auto_generate

### Phase 4-1B: WARN 모드 (데이터 수집)
- impact_scanner (mode=warn)
- ci_preflight (mode=warn)
- unresolved_gate (mode=warn)
- gate-config.json + .done gate_results

### Phase 4-2: FAIL 승격 (2주 후)
- false positive < 10% 확인 → gate-config.json mode: warn → fail

---

## 팀 배정

| 작업 | 담당 팀 | task_id | 의존성 |
|------|---------|---------|--------|
| l1_smoketest 강화 | 7팀 (이잠나) | task-2145 | 없음 |
| impact_scanner.py | 1팀 (헤르메스) | task-2146 | 없음 |
| dispatch.py 확장 | 2팀 (오딘) | task-2147 | 없음 |
| finish-task.sh 게이트 | 3팀 (다그다) | task-2148 | impact_scanner, ci_preflight 완료 후 |
| ci_preflight.sh | 4팀 (비슈누) | task-2149 | 없음 |
| gate-config.json | 5팀 (엔키) | task-2150 | 없음 |
| 통합 테스트 | composite | task-2151 | 전체 완료 후 |

P1 (병렬): task-2145, 2146, 2147, 2149, 2150
P2 (순차): task-2148 (finish-task.sh — P1 결과물 통합)
P3 (검증): task-2151 (통합 테스트)

---

## 검증 기준

1. "UI 직접 확인 불가" 포함 보고서 → l1_smoketest FAIL
2. impact_scanner: FeatureGate.tsx 수정 시 use-feature-access.ts WARN 발생
3. ci_preflight: pytest FAIL → 전체 FAIL, tsc 타임아웃 → WARN
4. goal_assertions: `curl -s localhost:8000/api/status` exit 0 → PASS
5. dispatch.py: `` `FeatureGate` `` 토큰 → affected_files에 2+ 파일 자동 주입
6. gate-config.json: mode=warn 변경 → 해당 게이트 WARNING만 (차단 안 함)
7. .done 파일에 gate_results 필드 존재
8. 통합: 8개 시나리오 전체 PASS
