# task-2775+6 — PR #255 same-branch: Gemini HIGH(disabled short-circuit) + MEDIUM(temp cleanup) micro-fix (ACTIVE=false)

상태명: `TASK2775_PLUS6_GEMINI_HIGH_MEDIUM_MICROFIX_APPROVED_FOR_DEV2_ACTIVE_FALSE`
담당: dev2-team (PR #255 / branch `task/task-2775-dev2` 소유)
회장 승인: 2026-06-26 — **A안: Gemini HIGH+MEDIUM same-branch micro-fix 1회**.
★ 이 승인은 **merge / activation / real fire / systemd enable·start / flag 생성 승인이 아님.**
ACTIVE=false · systemd disabled · flags OFF 유지.

## 배경 (fresh-head a58b81aa Gemini 결과)
ANU 독립검증 PASS(2파일·69 passed) 후 fresh-head Gemini:
- **HIGH**(thread outdated=true·resolved=false): driver가 `disabled`로 전환된 뒤에도 `main()` 호출마다
  ledger 전체를 다시 읽고(`_count_active_window_pickups`) `_atomic_write_flag_disabled`로 fsync 쓰기를 반복할
  수 있다는 I/O 병목 지적.
- **MEDIUM**(driver:465·resolved=false): `_atomic_write_flag_disabled`에서 `OSError` 외 예외
  (KeyboardInterrupt 등) 시 temp 파일이 잔존할 수 있음.

## 수정 목표
- **Gemini HIGH**: disabled 상태에서 bound gate가 ledger 전체 읽기 / disabled atomic write를 **반복할 수 있다는
  지적을 닫는다**.
- **Gemini MEDIUM**: `_atomic_write_flag_disabled` temp 파일 cleanup을 **try/finally로 보장**.

## 구현 방향
1. `limited_activation_bound_gate()` 또는 그 직전 경로에서 **`p0b_driver_enabled`가 이미 disabled/OFF이면**
   N/T ledger scan 및 `_atomic_write_flag_disabled` 재쓰기 **전에 조기 short-circuit**.
2. 이 조기 short-circuit은 **기존 default-OFF / legacy / test-2760 경로를 깨면 안 된다**.
3. 이미 disabled인 경우 **새 disabled write를 반복하지 말고, ledger 전체 읽기도 하지 않는다는 것을 테스트로 고정**.
4. `_atomic_write_flag_disabled`는 temp 파일 생성 후 **어떤 예외가 나도 temp 파일이 남지 않도록 try/finally
   cleanup 보장**.
5. ★ **단, KeyboardInterrupt/BaseException 계열을 삼키면 안 된다.** cleanup 후 **원래 예외는 그대로 전파**.

## 범위 (엄수)
- **PR #255 같은 브랜치(`task/task-2775-dev2`) 위 commit 추가**. **새 PR 생성 금지**(불가 시 STOP).
- expected_files **2개만**:
  - `dispatch/anu_pickup_driver.py`
  - `tests/regression/test_limited_activation_bounds_2775.py`
  - (가능하면 테스트 추가. 테스트 추가 불필요로 driver 1파일만 수정 시 **그 이유를 보고**.)
- **수정 금지**: governor / runner / launcher / owner-proof / **preflight(`anu_activation_preflight.py`)** /
  **test-2760** / entrypoint shell·systemd / `.github/**` / `scripts/finish-task.sh`.
- **금지**: merge / activation / real fire / `systemctl enable·start` / activation flag 생성 / canary 주입 /
  recurring 등록 / backlog consumption.

## 필수 테스트 (test_limited_activation_bounds_2775.py)
- driver disabled/OFF 상태에서 bound gate가 **ledger count 함수를 호출하지 않음**.
- driver disabled/OFF 상태에서 **`_atomic_write_flag_disabled`를 반복 호출하지 않음**.
- 기존 limited_runtime 두 flag ON + epoch 부재/손상 auto-disabled 테스트 **무회귀**.
- `_atomic_write_flag_disabled` 예외 발생 시 **temp 파일 cleanup 보장**.
- **cleanup 이후 원래 예외가 삼켜지지 않음**(전파 확인).
- **2775 bounds 전체 PASS**.
- **test-2760 36 PASS**.
- `py_compile` PASS · expected_files 밖 수정 **0**.

## 결과 보고 (필수)
- PR #255 같은 브랜치 **head 갱신 여부** · base/head SHA.
- **diff 파일 수**.
- **Gemini HIGH/MEDIUM 대응 내용**.
- 테스트 결과.
- **ACTIVE=false / real fire 0 증거**.
- **fresh-head Gemini 재리뷰 필요 여부**.

## 완료 처리 + ANU callback (필수)
- 완료 시 `memory/events/task-2775+6.done` + `memory/reports/task-2775+6.md`.
- 봇 idle 전 **ANU callback 필수**(성공/실패/blocked 무관). collector=ANU, owner_key=`c119085addb0f8b7`,
  self-key 금지. callback prompt UTF-8 **≤3900 bytes** (`printf '%s' "$P" | wc -c`), envelope 만
  (task_id·PR#255·new head sha·result_path·report_path·one-line). **merge 절대 금지.**
- PASS 나와도 **머지 금지** — ANU 독립검증 → fresh-head Gemini 재리뷰 → CI 확인 → MERGE_CANDIDATE로만 보고.
  회장 명시 승인 전까지 PR #255 open 유지.

## 진행
dev2는 HIGH short-circuit + MEDIUM try/finally cleanup 구현·테스트(real fire 0)·로컬검증 후 branch push로
**PR #255 갱신**, 보고서 + .done + ANU callback으로 마감. ANU가 이후 독립검증/Gemini 재리뷰/CI 확인 → 회장 머지 판단.

## allowed_resources (본 task의 capability)

```yaml
allowed_resources:
  paths:
    - "dispatch/anu_pickup_driver.py"
    - "tests/regression/test_limited_activation_bounds_2775.py"
    - "memory/reports/task-2775+6.md"
    - "memory/events/task-2775+6.done"
  forbidden_paths:
    - ".github/**"
    - "memory/events/*.cron-*"
    - "scripts/finish-task.sh"
    - "dispatch/anu_activation_preflight.py"
    - "tests/regression/test_*2760*.py"
    - "utils/spawn_safety_governor.py"
    - "dispatch/anu_result_pickup_runner.py"
    - "dispatch/anu_callback_launch_audit.py"
    - "dispatch/anu_owned_callback_enforcement.py"
    - "memory/state/p0b_driver_enabled"
    - "memory/state/p0b_callback_launch_enabled"
  commands:
    - "pytest"
    - "python3 -m py_compile"
    - "git"
    - "gh"
  merge_policy: "manual"
  ttl_hours: 24
```