# task-2775+9 — PR #255 same-branch: _reverse_line_iter blank-line correctness micro-fix (efficiency 아님, ACTIVE=false)

상태명: `TASK2775_PLUS9_REVERSE_ITER_BLANKLINE_CORRECTNESS_MICROFIX_APPROVED_FOR_DEV2_ACTIVE_FALSE`
담당: dev2-team (PR #255 / branch `task/task-2775-dev2` 소유)
회장 승인: 2026-06-26 — **+9 초소형 correctness micro-fix 1회.**
★ HIGH 0 / Critical 0 / scope 0 / efficiency 0 / CI 11/11 green 수용. **efficiency/O(N)/ledger scan 재발 0**이라
`LEDGER_COUNT_STRUCTURE_REDESIGN_REQUIRED` 트리거 **미발동**. 단 fresh MEDIUM 1건(driver:536) 남아 MERGE_CANDIDATE
미확정 → A안(blank-line correctness cleanup).
★ 이 승인은 **merge / activation / real fire / systemd enable·start / flag 생성 승인이 아님.** ACTIVE=false.

## 수정 대상 (Gemini fresh MEDIUM driver:536)
`_reverse_line_iter`가 **파일이 빈 줄로 시작할 때**(파일이 `\n`으로 시작/빈 줄로 시작) 루프 종료 후 `if buf:`에서
`buf == b""`라 **첫 빈 라인을 누락**할 수 있는 correctness edge. `_reverse_line_iter`가 `__all__` 노출 범용
유틸이라 빈 라인도 정확히 반환하도록 보정.

## ★ 성격 규정 (회장 verbatim — 범위 엄격 한정)
- 이번 +9는 **efficiency/O(N)/ledger scan 패치가 아니다.**
- **reverse scan 구조 재작업이 아니다.**
- **`_reverse_line_iter`의 blank-line edge만 닫는 correctness cleanup**이다.
- **ledger count 정책 / max_count stop 정책 / epoch break 금지 정책은 건드리지 말 것.**

## 구현 원칙
- 파일이 빈 줄로 시작하는 경우에도 reverse iterator가 **그 첫 빈 라인을 정확히 yield**하도록 보정
  (예: `if pos == 0: return` 후 루프 종료 시 buf 비어도 항상 마지막 조각 yield).
- **trailing newline / leading newline / consecutive blank lines / empty file** 케이스를 구분해 테스트.
- ★ **전체 파일 read 후 reversed 방식으로 되돌아가면 STOP.**
- `read_text` / `readlines` / `list(file)` 후 reversed **금지 유지**.
- **chunk 기반 `seek(SEEK_END)` reverse iterator 구조 유지.**
- `_count_active_window_pickups`의 stop 조건은 계속 **`count >= max_count` 하나만 유지**.
- **`processed_at < activation_epoch` break 금지 유지.**
- `processed_at` 부재 / 파싱 실패 / naive 제외 정책 **무회귀 유지**.

## 범위 (엄수)
- **PR #255 같은 브랜치(`task/task-2775-dev2`) 위 commit 추가**. **새 PR 생성 금지**.
- expected_files **2개만**: `dispatch/anu_pickup_driver.py` · `tests/regression/test_limited_activation_bounds_2775.py`.
- **수정 금지**: preflight / **test-2760** / governor / runner / launcher / owner-proof / entrypoint·systemd /
  `.github/**` / `scripts/finish-task.sh` / production flag 파일.
- **금지**: merge / activation / real fire / `systemctl enable·start` / activation flag 생성 / canary /
  recurring / backlog consumption / **Gemini thread 임의 resolve** / **efficiency 구조 재작업**.

## 필수 테스트 (test_limited_activation_bounds_2775.py)
- `_reverse_line_iter`가 **파일 시작 빈 줄을 누락하지 않음**.
- **trailing newline 처리 무회귀**.
- **consecutive blank lines** 처리.
- **empty file** 처리.
- **chunk boundary에서 blank line이 걸리는 경우** 처리.
- `_count_active_window_pickups`는 빈 줄을 만나도 기존처럼 **skip / parse fail 처리하며 count correctness 유지**.
- active window 3건 tail + historical 대량 케이스에서 **여전히 parse/read bounded**(+8 성능 무회귀).
- **+8 reverse scan 테스트 무회귀** · **+7 thread4 0644 / thread5 fail-closed 무회귀**.
- **2775 bounds 전체 PASS** · **test-2760 전체 PASS** · **2721 driver 인접 회귀 PASS** · `py_compile` PASS ·
  expected_files 밖 수정 **0**.

## 결과 보고 (필수)
- PR #255 head · base/head SHA · **diff 파일 수**.
- **driver:536 대응 내용** · **reverse iterator blank-line 테스트 결과**.
- **+8 bounded reverse 성능 무회귀 증거**.
- 테스트 결과 · ACTIVE=false / real fire 0 증거 · **fresh-head Gemini 재리뷰 필요 여부**.

## ★ +9 이후 경로 (회장 verbatim)
+9 완료 후 fresh-head Gemini 재리뷰에서 **High 0 / Critical 0 / fresh Medium 0 / efficiency 0 + CI green**이면
→ 다음은 **unresolved thread 정리 단계**. OUTDATED thread + stale-fresh thread resolve는 코드 수정이 아니라
**OWNER/회장 승인 영역** → +9에서 **임의 resolve 금지**. ★ 이걸 닫고도 Gemini가 또 efficiency를 물면 그때는
진짜 구조 재설계.

## 완료 처리 + ANU callback (필수)
- 완료 시 `memory/events/task-2775+9.done` + `memory/reports/task-2775+9.md`.
- 봇 idle 전 **ANU callback 필수**. collector=ANU, owner_key=`c119085addb0f8b7`, self-key 금지. callback prompt
  UTF-8 **≤3900 bytes**, envelope 만(task_id·PR#255·new head sha·result_path·report_path·one-line). **merge 금지.**
- PASS 나와도 **머지 금지** — ANU 독립검증 → fresh-head Gemini 재리뷰 → CI 확인 → MERGE_CANDIDATE로만 보고.

## 진행
dev2는 blank-line edge correctness cleanup(chunk reverse 구조 유지)·테스트(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+9.md"
    - "memory/events/task-2775+9.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
```