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

# Plan - REVIEW_TEST

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

`CODE_REVIEW-cloud-G07.md`의 구현 에이전트 소유 섹션을 채우는 것까지가 구현이다. 이번 루프는 SDD S15를 live/runtime evidence로 닫는 후속 작업이다. Plane token, webhook secret, DB password 같은 secret 원문은 기록하지 말고, Plane API/UI, Core log, DB ledger의 비밀 없는 출력만 남긴다. Milestone lock 결정이 아닌 환경/secret/service 준비, 검증 증거 공백, 반복 실패는 사용자 리뷰 요청이 아니며 이 plan 안에서 재현 가능한 evidence 또는 차단 사유로 기록한다.

## 배경

이전 루프는 projection 관련 unit test와 2026-06-16 DB ledger를 제시했지만, `plane-todo`의 필수 완료 조건인 같은 target의 Plane UI/API evidence를 남기지 못했다. 두 smoke work item은 현재 Plane API에서 404이고, 신규 `roadmap_creation_sync` jobs는 `tenant and project are required for missing-create`로 projection 단계에 도달하지 못했다. SDD S15는 original comment, body update, `[milestone-id]` title update, Todo move가 Plane UI/API와 `roadmap_sync_steps`에서 같은 work item/milestone 기준으로 확인되어야 한다.

## 사용자 리뷰 요청 흐름

사용자 리뷰 요청은 선택된 Milestone `구현 잠금 > 결정 필요` 항목이 실구현을 차단할 때만 active review stub의 `사용자 리뷰 요청` 섹션에 기록한다. Plane credential 위치, Core service 상태, deleted smoke item, missing verification evidence, runtime retry 실패는 사용자 리뷰 요청이 아니며 `검증 결과`와 `계획 대비 변경 사항`에 실제 출력으로 남긴다.

## Archive Evidence Snapshot

- Current archived plan: `agent-task/m-plane-origin-authoring-roundtrip-sync/10+09_plane_todo/plan_cloud_G07_0.log`
- Current archived review: `agent-task/m-plane-origin-authoring-roundtrip-sync/10+09_plane_todo/code_review_cloud_G07_0.log`
- Verdict: FAIL
- Required summary:
  - `code_review_cloud_G07_0.log` shows the required Plane UI/API evidence checkbox remained unchecked; reviewer rechecked both `/work-items/{id}/` and `/issues/{id}/` for `092429ca...` and `c90fbc3e...`, and both items returned 404.
  - The final Core log verification returned `(no output - exit 1)`, so the loop did not connect a projection action to projected/complete state.
  - Fresh `roadmap_creation_sync` jobs existed but discarded with `roadmapsyncpipeline: tenant and project are required for missing-create`, so they did not satisfy S15 projection evidence.
- Affected files: `CODE_REVIEW-cloud-G07.md` evidence is mandatory. Patch `services/core/internal/gitosync/bridge.go`, `services/core/cmd/server/main.go`, `services/core/internal/config/config.go`, `services/core/internal/scheduler/roadmap_sync_jobs.go`, `services/core/internal/roadmapsyncpipeline/service.go`, or related focused tests only if runtime evidence proves a code/config propagation defect.
- Verification evidence from previous loop: `go test -count=1 ./internal/roadmapsync ./internal/roadmapsyncpipeline ./internal/adapters/plane` passed, and DB ledger contained 2026-06-16 completed steps for deleted smoke items. This does not replace current Plane UI/API evidence.
- Allowed narrow reread paths: `agent-task/m-plane-origin-authoring-roundtrip-sync/10+09_plane_todo/plan_cloud_G07_0.log`, `agent-task/m-plane-origin-authoring-roundtrip-sync/10+09_plane_todo/code_review_cloud_G07_0.log`, `agent-task/archive/2026/06/m-plane-origin-authoring-roundtrip-sync/09+08_scan_enqueue/complete.log`.

## Roadmap Targets

- Milestone: `agent-roadmap/phase/agent-ops-mcp-control-plane/milestones/plane-origin-authoring-roundtrip-sync.md`
- Task ids:
  - `plane-todo`: preserve original comment, project Milestone body/title, and move Plane work item to Todo
- 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:
  - `S15`: task=`plane-todo`; evidence=`original comment, body update, title update, Todo move recorded`
- Completion mode: spec-check-on-pass

## 분석 결과

### 실패 원인

- The previous implementation accepted ledger-only evidence even though the active checklist and SDD require Plane UI/API evidence.
- Existing ledger rows point to deleted Plane work items, so they cannot prove current title/body/comment/Todo state.
- The fresh runtime jobs seen on 2026-06-21 failed before projection because missing-create jobs lacked tenant/project inputs at runtime or runtime config did not supply them.

### 범위 결정 근거

- Scope remains `plane-todo` and S15 only.
- Do not complete `slot-finalize`, `remote-baseline`, `full-cycle`, or roadmap state updates here.
- Do not create roadmap tasks or Plane child tickets for plan/code-review linkage.
- A fresh dev Plane work item or active Milestone missing-create/reconcile target may be used only to collect secret-redacted S15 evidence.

### 빌드 등급

- `cloud-G07`: the follow-up depends on live Plane API/UI state, Core compose logs, River jobs, DB ledger, and evidence-trust diagnosis after unit tests already passed.

## 구현 체크리스트

- [ ] `code_review_cloud_G07_0.log`의 Required findings와 SDD S15 Evidence Map을 확인하고 ledger-only evidence를 PASS 근거로 쓰지 않는다.
- [ ] Fresh projection target을 준비하거나 기존 valid target을 찾아 Plane API/UI에서 original comment, `[milestone-id]` title, projected body, Todo state를 secret 없이 기록한다.
- [ ] 같은 target의 DB `roadmap_sync_steps`에서 `develop_matched`, `original_comment_preserved`, `plane_body_updated`, `plane_todo_moved`가 모두 같은 identity/work item 기준으로 기록됐는지 확인한다.
- [ ] Fresh jobs가 `tenant and project are required for missing-create`로 projection 전 실패하면 runtime config/bridge/job arg 원인을 좁히고, 필요한 경우 focused code fix와 regression test를 추가한다.
- [ ] Core log 또는 동등한 deterministic evidence로 projection action이 projected/complete state와 연결됨을 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.

### [REVIEW_TEST-1] Recover Same-Target Plane UI/API And Ledger Evidence

#### 문제

Before: `code_review_cloud_G07_0.log` records DB ledger rows from 2026-06-16, but both referenced Plane work items now return 404. The required Plane UI/API evidence checkbox is unchecked, and S15 cannot verify original comment, title/body projection, or Todo state for the same target.

After: the review stub contains a secret-redacted same-target evidence bundle: Plane API/UI evidence for original comment, `[milestone-id]` title, projected body, Todo state, plus DB `roadmap_sync_steps` rows for the same work item or milestone identity.

#### 해결 방법

- Prefer a fresh valid reconcile/projection cycle so evidence is current.
- If using an existing target, first prove the Plane work item still exists through the adapter endpoint shape `/api/v1/workspaces/{workspace}/projects/{project}/work-items/{id}/`.
- Record only non-secret fields: work item id prefix or full non-secret UUID, title, state id/name, body presence or redacted body excerpt, comment prefix/count, roadmap item id, step names, timestamps.
- Do not count deleted-item 404 plus old DB ledger as S15 completion.

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

- [ ] `CODE_REVIEW-cloud-G07.md`: record same-target Plane API/UI and DB ledger evidence.
- [ ] `services/core/internal/roadmapsyncpipeline/service.go`: patch only if valid input reaches projection but side effects or ledger ordering are wrong.
- [ ] `services/core/internal/roadmapsync/plane_projection.go`: patch only if original comment, title/body projection, or Todo move inputs are wrong.
- [ ] `services/core/internal/adapters/plane/client.go`: patch only if Plane API payload/path mapping is wrong.
- [ ] Focused tests: add/update only if a source defect is found.

#### 테스트 작성

- If no source defect is found and fresh live evidence satisfies S15, no new test is required.
- If a defect is found, add the smallest focused regression test in `plane_projection_test.go`, `service_test.go`, or `client_test.go`.

#### 중간 검증

```sh
ssh toki@toki-labs.com 'zsh -lc '\''cd "$HOME/agent-work/nomadcode/services/core" && go test -count=1 ./internal/roadmapsync ./internal/roadmapsyncpipeline ./internal/adapters/plane'\'''
```

Expected: packages pass.

### [REVIEW_TEST-2] Recover Projection Log Or Equivalent Runtime Evidence

#### 문제

Before: the final Core log verification in `code_review_cloud_G07_0.log` returned `(no output - exit 1)`, and fresh River jobs were discarded before projection with `tenant and project are required for missing-create`.

After: the review stub contains Core log output for `roadmap creation sync completed`, `plane_todo_moved`, `plane body`, or equivalent deterministic evidence that the projection action completed for the same target. If missing-create tenant/project propagation is the blocker, it is fixed or captured with focused failing/passing tests.

#### 해결 방법

- Verify runtime config has non-empty Plane workspace/project values before triggering missing-create jobs. Do not print secret values.
- If `gito missing-create sync enqueued` jobs still discard before projection, inspect job args or logs enough to determine whether `gitosync.BridgeConfig.Tenant/Project`, `cmd/server` config wiring, or runtime env is empty.
- Patch only a proven code/config propagation defect. If the issue is an unprepared dev environment, record exact non-secret setup evidence and rerun after fixing the environment in the remote runner.
- Collect Core log and DB evidence after the fresh projection, not only old logs.

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

- [ ] `CODE_REVIEW-cloud-G07.md`: record Core log/equivalent runtime evidence and any config diagnosis.
- [ ] `services/core/internal/gitosync/bridge.go`: patch only if missing-create job args drop configured tenant/project.
- [ ] `services/core/cmd/server/main.go`: patch only if bridge config is not wired from `PLANE_WORKSPACE_SLUG`/`PLANE_PROJECT_ID`.
- [ ] `services/core/internal/config/config.go`: patch only if required config normalization/validation allows an unsafe empty runtime for this path.
- [ ] `services/core/internal/scheduler/roadmap_sync_jobs.go`: patch only if worker drops job args before `SyncCreation`.
- [ ] Focused tests: add/update only for the proven defect.

#### 테스트 작성

- If code is patched, add a focused regression test that proves tenant/project are preserved from bridge/server/job args into `SyncCreationInput` for missing-create jobs.
- If no code patch is needed, record why environment repair plus live evidence is sufficient.

#### 중간 검증

```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 ./internal/roadmapsyncpipeline'\'''
```

Expected: packages pass.

## 의존 관계 및 구현 순서

- `09+08_scan_enqueue` is already PASS; use its complete log only as prerequisite evidence.
- First recover or create a valid projection target.
- Then collect same-target Plane API/UI, DB ledger, and Core log/equivalent evidence.
- Patch code only when runtime evidence identifies a defect.

## 수정 파일 요약

| 파일 | 항목 |
|------|------|
| `CODE_REVIEW-cloud-G07.md` | Required evidence capture |
| `services/core/internal/gitosync/bridge.go` | Conditional tenant/project propagation fix |
| `services/core/cmd/server/main.go` | Conditional bridge config wiring fix |
| `services/core/internal/config/config.go` | Conditional config validation fix |
| `services/core/internal/scheduler/roadmap_sync_jobs.go` | Conditional job arg propagation fix |
| `services/core/internal/roadmapsyncpipeline/service.go` | Conditional projection/ledger fix |
| `services/core/internal/roadmapsync/plane_projection.go` | Conditional projection input/order fix |
| `services/core/internal/adapters/plane/client.go` | Conditional Plane API mapping 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/roadmapsync ./internal/roadmapsyncpipeline ./internal/adapters/plane ./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 "roadmap creation sync completed|plane_todo_moved|plane work item created|plane body|gito creation sync enqueued|gito missing-create sync enqueued"'\'''
```

Expected: output links the fresh target's reconcile/projection action to projected or completed state without secrets.

```sh
ssh toki@toki-labs.com 'zsh -lc '\''docker exec code-server-postgres psql -U nomadcode -d nomad-core-dev -c "select i.roadmap_item_id, i.work_item_id, s.step, s.completed_at from roadmap_sync_identities i join roadmap_sync_steps s on s.roadmap_sync_identity_id = i.id where s.step in ('\''develop_matched'\'','\''original_comment_preserved'\'','\''plane_body_updated'\'','\''plane_todo_moved'\'') order by s.completed_at desc limit 20;"'\'''
```

Expected: the same target used for Plane API/UI evidence has all four expected steps.

Plane API/UI evidence must also be recorded with the adapter endpoint shape `/work-items/{id}/` and, for original comment, the work item comments endpoint or UI evidence. Print only non-secret fields and redact user-sensitive body text if needed.

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