<!-- task=m-plane-origin-authoring-roundtrip-sync/09+08_scan_enqueue plan=1 tag=REVIEW_TEST -->

# Plan - REVIEW_TEST

## 이 파일을 읽는 구현 에이전트에게

`CODE_REVIEW-cloud-G07.md`의 구현 에이전트 소유 섹션을 채우는 것까지가 구현이다. 검증을 실행하고 실제 stdout/stderr와 증거 경로를 기록한 뒤 active 파일을 그대로 두고 리뷰 준비를 보고한다. 선택된 SDD/Milestone lock 결정이 막을 때만 review stub의 `사용자 리뷰 요청`을 채운다. 환경/secret/service 준비, 검증 증거 공백, 반복 실패는 사용자 리뷰 요청이 아니며 이 follow-up 안에서 재현 가능한 증거 또는 차단 사유로 기록한다.

## 배경

이전 루프는 scanner/bridge focused Go 테스트는 통과했지만, `scan-enqueue`의 핵심 완료 조건인 slug 단위 `roadmap_creation_sync` enqueue evidence를 남기지 못했다. 최종 로그 검증은 `exit 1: no output`이었고, 리뷰어 DB 확인에서도 River `roadmap_creation_sync` job row가 0건이었다. 이번 루프는 SDD S14의 `active reconcile enqueue evidence recorded`를 실제 Core log 또는 queue/DB evidence로 닫거나, 증거가 비는 원인을 scanner/bridge/wiring 결함으로 좁혀 패치한다.

## 사용자 리뷰 요청 흐름

사용자 리뷰 요청은 선택된 SDD 결정 또는 Milestone lock 결정이 있을 때만 active review stub의 `사용자 리뷰 요청` 섹션에 기록한다. 외부 환경/secret/service 문제, 재현 실패, 로그/DB 증거 공백은 이 작업의 일반 follow-up 범위이며 `검증 결과`와 `계획 대비 변경 사항`에 실제 출력으로 남긴다.

## Archive Evidence Snapshot

- Current archived plan: `agent-task/m-plane-origin-authoring-roundtrip-sync/09+08_scan_enqueue/plan_cloud_G06_0.log`
- Current archived review: `agent-task/m-plane-origin-authoring-roundtrip-sync/09+08_scan_enqueue/code_review_cloud_G06_0.log`
- Verdict: FAIL
- Required summary: `code_review_cloud_G06_0.log` shows the final enqueue log command returned `exit 1: no output`; reviewer rerun also found no recent enqueue logs, and River `river_job` had 0 rows for `kind='roadmap_creation_sync'`.
- Affected files: `CODE_REVIEW-cloud-G07.md` evidence is mandatory; patch `services/core/internal/gitosync/scanner.go`, `services/core/internal/gitosync/bridge.go`, or `services/core/cmd/server/main.go` only if runtime/DB evidence proves a code defect.
- Verification evidence from previous loop: `go test -count=1 ./internal/gitosync ./cmd/server ./internal/scheduler` passed on the standard remote runner, but this does not replace live queue/log evidence.
- Allowed narrow reread paths: `agent-task/m-plane-origin-authoring-roundtrip-sync/09+08_scan_enqueue/plan_cloud_G06_0.log`, `agent-task/m-plane-origin-authoring-roundtrip-sync/09+08_scan_enqueue/code_review_cloud_G06_0.log`, `agent-task/archive/2026/06/m-plane-origin-authoring-roundtrip-sync/08+07_gito_delivery/complete.log`.

## Roadmap Targets

- Milestone: `agent-roadmap/phase/agent-ops-mcp-control-plane/milestones/plane-origin-authoring-roundtrip-sync.md`
- Task ids:
  - `scan-enqueue`: Gito wakeup fetches local develop, scans active Milestone index, and enqueues slug reconcile jobs
- Completion mode: check-on-pass

## Spec Targets

- SDD: `agent-roadmap/sdd/agent-ops-mcp-control-plane/plane-origin-authoring-roundtrip-sync/SDD.md`
- Acceptance scenarios:
  - `S14`: task=`scan-enqueue`; evidence=`active reconcile enqueue evidence recorded`
- Completion mode: spec-check-on-pass

## 분석 결과

### 실패 원인

- Plan G06 required Remote Core log or queue/DB evidence for slug-level `roadmap_creation_sync` enqueue.
- Implementation marked that checklist item complete despite the only log command returning no matches.
- Reviewer rerun confirmed package tests pass, but recent Core logs still have no enqueue lines and DB has no `roadmap_creation_sync` jobs.

### 범위 결정 근거

- Scope remains `scan-enqueue` only: Gito delivery -> local develop fetch -> active Milestone index -> slug-level enqueue evidence.
- Do not broaden into Plane body/comment/status projection, Plane `Todo`, slot finalization, roadmap state updates, or full-cycle completion.
- A controlled runtime-equivalent trigger may mutate dev queue/provider state. Keep it secret-redacted, bounded to dev, and record only non-secret ids/status/output.

### 빌드 등급

- `cloud-G07`: unit tests passed but live queue/log evidence is missing, and the follow-up requires runtime evidence-trust diagnosis across Core compose, Gito delivery, scanner, scheduler enqueue, and River DB.

## 구현 체크리스트

- [ ] `plan_cloud_G06_0.log`/`code_review_cloud_G06_0.log`의 FAIL evidence를 확인하고 이전 loop에서 통과한 unit tests는 재사용 가능 evidence로만 취급한다.
- [ ] Standard remote runner에서 비중복 accepted Gito delivery 또는 runtime-equivalent trigger를 실행/확보해 `roadmap_creation_sync` slug 단위 enqueue를 Core log 또는 River/DB job row로 기록한다.
- [ ] enqueue evidence가 계속 비면 scanner/bridge/wiring 원인을 좁혀 패치하고, 결함을 재현하는 focused regression test를 추가한다.
- [ ] 최종 검증으로 focused Go test와 Core log/DB evidence command의 실제 stdout/stderr를 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.

### [REVIEW_TEST-1] Recover Active Reconcile Enqueue Evidence

#### 문제

Before: `BranchRevisionScanner.Scan` and `Bridge.Handle` unit paths pass, but no runtime evidence proves that an accepted Gito wakeup produced a slug-level `roadmap_creation_sync` enqueue. The previous log command returned no matches, and reviewer DB check found zero River jobs.

After: the review stub contains secret-redacted evidence of a non-duplicate accepted delivery or equivalent runtime trigger that led to `gito creation sync enqueued`, `gito missing-create sync enqueued`, or a `river_job` row with `kind='roadmap_creation_sync'`. If no enqueue occurs, the relevant code path is patched and covered by a focused regression test.

#### 해결 방법

- Reconfirm the predecessor `08+07_gito_delivery` completion only from the allowed narrow archive path if needed.
- On the standard remote runner, prepare a non-duplicate accepted Gito delivery or equivalent dev trigger that reaches `gitoBridgeHTTPAdapter`/`Bridge.Handle` without printing secrets. Use ignored local secret files or in-process env loading only.
- Immediately collect Core log evidence and River/DB evidence for `roadmap_creation_sync`.
- If no evidence appears, diagnose whether the event was duplicate/off-target, scanner returned no docs, `ErrNotReady` occurred, bridge wiring is disabled, or River enqueue failed. Patch only the defect path and add/update focused tests.

#### 수정 파일 및 체크리스트

- [ ] `CODE_REVIEW-cloud-G07.md`: record exact trigger, focused test output, Core log output, and DB evidence output.
- [ ] `services/core/internal/gitosync/scanner.go`: patch only if runtime evidence shows active index scan misses active Milestone docs or wrongly treats archive docs.
- [ ] `services/core/internal/gitosync/bridge.go`: patch only if runtime evidence shows docs are scanned but `EnqueueRoadmapCreationSync` is not called or duplicate handling suppresses a valid revision.
- [ ] `services/core/cmd/server/main.go`: patch only if runtime evidence shows HTTP/proto-socket delivery reaches Core but the shared bridge/enqueuer wiring is absent or disabled.
- [ ] Relevant focused tests: add or update tests only for the proven defect.

#### 테스트 작성

- If no source defect is found and runtime evidence is recovered, no new test is required.
- If a defect is found, add the smallest focused regression test in `services/core/internal/gitosync/scanner_test.go`, `services/core/internal/gitosync/bridge_test.go`, `services/core/internal/gitosync/runner_test.go`, or `services/core/cmd/server/main_test.go`.

#### 중간 검증

```sh
ssh toki@toki-labs.com 'zsh -lc '\''cd "$HOME/agent-work/nomadcode/services/core" && go test -count=1 ./internal/gitosync ./cmd/server ./internal/scheduler'\'''
```

Expected: packages pass.

## 의존 관계 및 구현 순서

- Use the archived PASS from `08+07_gito_delivery` as the prerequisite evidence.
- First collect runtime enqueue evidence without code changes.
- Patch only if the evidence remains absent and diagnosis identifies a code or wiring defect.

## 수정 파일 요약

| 파일 | 항목 |
|------|------|
| `CODE_REVIEW-cloud-G07.md` | Required evidence capture |
| `services/core/internal/gitosync/scanner.go` | Conditional defect fix |
| `services/core/internal/gitosync/bridge.go` | Conditional defect fix |
| `services/core/cmd/server/main.go` | Conditional wiring fix |
| focused tests | Conditional regression coverage |

## 최종 검증

```sh
ssh toki@toki-labs.com 'zsh -lc '\''cd "$HOME/agent-work/nomadcode/services/core" && go test -count=1 ./internal/gitosync ./cmd/server ./internal/scheduler'\'''
```

Expected: all listed packages pass.

```sh
ssh toki@toki-labs.com 'zsh -lc '\''cd "$HOME/agent-work/nomadcode/services/core" && docker compose logs --no-color --since=60m nomadcode-core | rg "gito creation sync enqueued|gito missing-create sync enqueued|roadmap_creation_sync|active milestone"'\'''
```

Expected: output shows slug-level creation sync enqueue after an accepted non-duplicate delivery or equivalent runtime trigger. Archive Milestones must not appear as sync targets.

```sh
ssh toki@toki-labs.com "zsh -lc 'docker exec code-server-postgres psql -U nomadcode -d nomad-core-dev -c \"select id, kind, state, created_at, finalized_at from river_job where kind = '\''roadmap_creation_sync'\'' order by id desc limit 20;\"'"
```

Expected: output shows at least one recent `roadmap_creation_sync` row, or the Core log command above already provides unambiguous enqueue evidence. If both commands are empty, implementation is not ready for PASS.

모든 코드 변경 또는 증거 수집 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.
