# task-2729 Phase 2 — PR convergence pipeline 자동화 (live-prune + owner_gemini entrypoint + base-sync + authoritative-completion)

## 회장 인가 (2026-06-03, task-2729 Phase 2 — Phase 1 PASS 후 자동 연속)
Phase 1(progress watcher dispatch gate) PASS 후 **회장 재확인 없이 연속 진행**. PR convergence pipeline 결함 4·5·6·7 보강. **"code exists"≠"automation works" — IMPLEMENTED/VERIFIED/WIRED/ACTIVE 분리. production ACTIVE 전환 별도 회장 승인.**

## ★ audit-report-first (구현 전 필수)
dev 는 **구현 전 audit report** 를 `memory/events/task-2729-p2.audit.json` 에 생성: 현 코드 경로(completion_callback_fallback_cancel collect_and_prune / collector entrypoint / merge_queue_executor base-sync / owner_gemini 부재) + 결선 gap + 최소 변경점. audit 후 expected_files 재확인(≤5, 초과 시 CHAIR_REQUIRED).

## ANU audit 결과 (read-only)
- `completion_callback_fallback_cancel.py`: collect_and_prune/DI remover 존재 → live prune 결선 가능.
- `normal_completion_callback_collector_entrypoint.py`: success 트랜잭션 내 prune 호출 결선 필요.
- `utils/owner_gemini_trigger.py`: **부재 → 신규**.
- base-sync: `utils/merge_queue_executor.py`·`utils/repository_policy_adapter.py` 존재 → watcher 에서 호출(merge_queue_executor 직접 수정 필요 시 6파일 → CHAIR_REQUIRED).

## 목표 (결함 4·5·6·7)
1. **live_prune_not_wired(7)**: collector success 트랜잭션에서 registry pending fallback 을 real cancel/tombstone 결선 + live 관측. (Phase1 watcher 가 fallback prune 추적과 연계)
2. **OWNER_GEMINI_TRIGGER_NOT_WIRED(6)**: `owner_gemini_trigger.py` 전용 entrypoint(hardcoded body '/gemini review'·dedupe·head-lock·audit jsonl·OWNER PAT). watcher 가 새 head 에서 자동 발사(request-only)·review-settle 회수 결선.
3. **BASE_SYNC_REQUIRED_BEFORE_MERGE(5)**: watcher/pipeline 이 merge approval 후 BEHIND PR 을 base-sync(update-branch, admin override 아님)→재검증→merge 자동 처리. conflict/diff초과/admin·force 필요 시 중단.
4. **AUTHORITATIVE_COMPLETION_BY_SCOPE_EVIDENCE(4)**: finish-task EXTERNAL_DIRTY block 시 권위 scope evidence(merge-base clean+CI+LOCAL_FIX_VERIFIED)로 완료 인정 마커(수동 .done 위조 아님).

## expected_files (audit 후 확정 — lock, ≤5. Phase1 겹침은 목적·검증 분리 기록)
1. `utils/completion_callback_fallback_cancel.py` (live prune 결선 + cause enum 유지)
2. `utils/normal_completion_callback_collector_entrypoint.py` (collector→prune success 트랜잭션 결선)
3. `utils/owner_gemini_trigger.py` (신규 — 전용 entrypoint)
4. `scripts/ci_watch_handoff_runner.py` (★Phase1 겹침: Phase1=watcher 골격/terminal callback, Phase2=base-sync+owner_gemini+D-resolve+authoritative-completion pipeline. 검증 분리 기록)
5. `tests/regression/test_pr_convergence_pipeline_2729.py` (신규)
- ★ 5파일 초과·merge_queue_executor 직접수정·forbidden 필요 시 CHAIR_REQUIRED.

## 완료 조건
1. live prune 결선 regression PASS (collector success → registry fallback real tombstone, fake remover).
2. owner_gemini_trigger entrypoint regression PASS (dedupe·head-lock·hardcoded body·audit jsonl, 실 gh 미호출 mock).
3. base-sync pipeline regression PASS (BEHIND 감지→base-sync→재검증, conflict/admin/force 중단 분기).
4. authoritative-completion marker regression PASS (EXTERNAL_DIRTY block→scope evidence 완료 인정, 수동 .done 위조 0).
5. Phase1 progress_watcher + 기존 callback/fallback 회귀 무손상.
6. capability matrix: callback_fallback_prune·owner_gemini_trigger·base_sync_pipeline·authoritative_completion 4축 분리 기록. **전부 ACTIVE=false 유지**.
7. ANU key literal 0, /home/jay raw 0, forbidden 0.

## 금지 (회장 11 — Phase1과 동일)
admin override·force push·rebase·production ACTIVE=true·credential/ANU key raw 노출·unrelated cleanup·finish-task.sh·critical_gap.py·terminal_callback.py·systemd/.github/deploy 수정·회장 승인 없는 merge. expected_files 5밖 → CHAIR_REQUIRED.

## ★ Phase 2 후 PR 생성 전 재확인 (회장)
Phase1+2 통합 후 PR 생성 전: CI 11/11 · fresh OWNER Gemini(자동발사) HIGH/CRITICAL 0 · effective diff expected_files 내 · forbidden 0 · ANU key 0 · ACTIVE=false 재확인. 통과 시 PR 생성 → owner_gemini → review-settle watcher → MERGE_APPROVAL_CANDIDATE. merge 별도 회장 approval 전 금지.

## 중간보고 (회장 — 7 트리거만)
Critical7 · fresh HIGH 반복 · expected_files 확장 필요 · credential/permission · admin/force/rebase 필요 · ACTIVE=true 필요 · merge 승인 필요. 그 외 ANU 자동 수렴 + 최종 결과만 보고.

## allowed_resources
```yaml
allowed_resources:
  paths:
    - "utils/completion_callback_fallback_cancel.py"
    - "utils/normal_completion_callback_collector_entrypoint.py"
    - "utils/owner_gemini_trigger.py"
    - "scripts/ci_watch_handoff_runner.py"
    - "tests/regression/test_pr_convergence_pipeline_2729.py"
    - "memory/state/automation_capability_matrix.json"
    - "memory/reports/task-2729.md"
    - "memory/events/task-2729-p2.audit.json"
    - "memory/events/task-2729-p2.done"
  forbidden_paths:
    - "scripts/finish-task.sh"
    - "teams/shared/verifiers/critical_gap.py"
    - "scripts/harness/v36/terminal_state_callback.py"
    - "utils/merge_queue_executor.py"
    - "deploy/systemd/**"
    - ".github/**"
  commands: ["pytest","python3 -m pytest","python3 -m py_compile","bash -n"]
  merge_policy: "none"
  ttl_hours: 48
```

## goal_assertions (auto)
- `python3 -m pytest tests/regression/test_pr_convergence_pipeline_2729.py -q`
- `python3 -c "import sys; s=open('utils/owner_gemini_trigger.py').read(); sys.exit(0 if '/gemini review' in s and 'dedupe' in s.lower() else 1)"`
- `python3 -c "import sys; bad=[f for f in ['utils/owner_gemini_trigger.py','scripts/ci_watch_handoff_runner.py'] if 'c119085addb0f8b7' in open(f).read()]; sys.exit(1 if bad else 0)"`

## 상태
CHAIR_APPROVED_TASK2729_PHASE2 (Phase1 PASS 후 자동 연속) — dev 위임. audit-report-first. PR 생성 전 재확인. ACTIVE=false 고정·production 전환 별도 승인. 중간보고 7트리거만.