<!-- task=m-plane-origin-authoring-roundtrip-sync/08+07_gito_delivery plan=0 tag=TEST -->

# Plan - TEST

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

`CODE_REVIEW-cloud-G07.md`의 구현 에이전트 소유 섹션을 채우는 것까지가 구현이다. 검증을 실행하고 실제 출력과 증거 경로를 붙여 넣은 뒤 active 파일을 그대로 두고 리뷰 준비를 보고한다. SDD 결정 또는 Milestone `구현 잠금 > 결정 필요` 항목이 실구현을 막을 때만 review stub의 `사용자 리뷰 요청`을 채우고 멈춘다. 직접 사용자에게 묻거나 `USER_REVIEW.md`, `complete.log`, archive 로그를 만들지 않는다. secret/service 준비, 증거 공백, 범위 조정은 일반 follow-up으로 기록한다.

## 배경

현재 마일스톤의 `gito-plane` Epic은 Gito HTTP webhook wakeup 이후 Core sync pipeline이 실제 환경에서 닫히는지 검증해야 한다. `gito-delivery`는 Forgejo push가 Gito를 거쳐 Core signed HTTP webhook으로 들어오고, duplicate delivery가 secret 없이 확인되는지를 SDD S13 근거로 남기는 작업이다.

## 사용자 리뷰 요청 흐름

사용자 리뷰 요청은 선택된 SDD 결정 또는 Milestone lock 결정이 있을 때만 active review stub의 `사용자 리뷰 요청` 섹션에 기록한다. 구현 중 직접 질문하거나 선택지를 제시하지 않으며, code-review가 검증 후 실제 `USER_REVIEW.md` 작성 여부를 판단한다.

## Archive Evidence Snapshot

- Prior dependency: `agent-task/archive/2026/06/m-plane-origin-authoring-roundtrip-sync/07+05,06_slug_reconcile/complete.log`
- Verdict: PASS
- Carryover: filename slug based reconcile and same-slug idempotency are complete; `gito-plane` plans may depend on S12 being done.
- Verification carried over: `cd services/core && go test -count=1 ./...`, `git diff --check`

## Roadmap Targets

- Milestone: `agent-roadmap/phase/agent-ops-mcp-control-plane/milestones/plane-origin-authoring-roundtrip-sync.md`
- Task ids:
  - `gito-delivery`: Forgejo push -> Gito -> Core signed HTTP webhook delivery and duplicate handling
- 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:
  - `S13`: task=`gito-delivery`; evidence=`signed delivery 202, Core log, duplicate result recorded without secret`
- Completion mode: spec-check-on-pass

## 분석 결과

### 읽은 파일

- `agent-test/local/rules.md`
- `agent-test/local/core-smoke.md`
- `agent-test/live-cycle-smoke.md`
- `agent-roadmap/phase/agent-ops-mcp-control-plane/PHASE.md`
- `agent-roadmap/phase/agent-ops-mcp-control-plane/milestones/plane-origin-authoring-roundtrip-sync.md`
- `agent-roadmap/sdd/agent-ops-mcp-control-plane/plane-origin-authoring-roundtrip-sync/SDD.md`
- `services/core/cmd/server/main.go`
- `services/core/cmd/server/main_test.go`
- `services/core/docker-compose.yml`
- `services/core/internal/http/gito_webhook.go`
- `services/core/internal/http/gito_webhook_test.go`
- `services/core/internal/gitosync/bridge.go`
- `services/core/internal/gitosync/bridge_test.go`
- `services/core/internal/gitosync/scanner.go`
- `services/core/internal/gitosync/scanner_test.go`

### 테스트 환경 규칙

- test_env: `local`
- Env rules: `agent-test/local/rules.md` present and read; local baseline is standard remote runner.
- Matched profiles: `agent-test/local/core-smoke.md`, `agent-test/live-cycle-smoke.md`
- Applied commands: current workspace precheck `cd services/core && go test -count=1 ./cmd/server ./internal/http ./internal/gitosync ./internal/roadmapsync ./internal/roadmapsyncpipeline ./internal/scheduler ./internal/adapters/plane ./internal/authoring` passed.
- Final verification source: remote runner commands from `core-smoke` plus live evidence steps from `live-cycle-smoke`.

### 테스트 커버리지 공백

- Signed HTTP handling and fake bridge enqueue are covered by `services/core/internal/http/gito_webhook_test.go` and `services/core/cmd/server/main_test.go`.
- Real Forgejo -> Gito subscription target, Core 202 response, Core log, and duplicate live delivery are not covered by unit tests and must be captured on the standard remote runner.

### 심볼 참조

- none

### 분할 판단

- Split policy evaluated before choosing files.
- Shared task group: `m-plane-origin-authoring-roundtrip-sync`
- Sibling tasks: `08+07_gito_delivery` depends on archived `07+05,06_slug_reconcile`; `09+08_scan_enqueue`; `10+09_plane_todo`; `11+10_slot_finalize`.
- Predecessor `07` is satisfied by `agent-task/archive/2026/06/m-plane-origin-authoring-roundtrip-sync/07+05,06_slug_reconcile/complete.log`.
- This plan is separate because live delivery setup/log evidence can fail independently of Plane projection or slot finalization.

### 범위 결정 근거

- Scope includes Gito subscription/Core webhook delivery evidence only.
- It excludes Plane Todo projection and slot terminal state, which belong to dependent tasks 10 and 11.
- It does not change Gito subscription secrets or print raw signatures/tokens.

### 빌드 등급

- `cloud-G07`: live external delivery, remote runner, service logs, and duplicate handling are central and cannot be fully proven by local unit tests.

## 구현 체크리스트

- [ ] Forgejo push 또는 equivalent Gito branch.updated delivery를 발생시키고 Core `POST /api/integrations/gito/webhook` 202 및 duplicate result를 secret 없이 증거화한다.
- [ ] `gito-delivery` 검증 기준의 Gito subscription target, Core webhook log, duplicate delivery 결과를 `CODE_REVIEW-cloud-G07.md`에 실제 출력으로 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.

### [TEST-1] Gito Signed Delivery Evidence

#### 문제

- Milestone line 76 requires remote `develop` push마다 Forgejo -> Gito -> Core signed HTTP webhook delivery and duplicate handling evidence.
- `ReceiveGitoWebhook` validates signature, event, delivery id, target repo/branch, duplicate keys, and calls the handler at `services/core/internal/http/gito_webhook.go:110`.
- Server wiring enables the HTTP consumer only when config is complete at `services/core/cmd/server/main.go:169`.
- SDD S13 requires secret-redacted live delivery evidence at `agent-roadmap/sdd/agent-ops-mcp-control-plane/plane-origin-authoring-roundtrip-sync/SDD.md:129`.

#### 해결 방법

- Do not change source unless live evidence exposes a concrete defect.
- On the standard remote runner, make sure Core runs the current target state with Gito webhook env configured, then trigger a branch.updated delivery by pushing to watched `develop` or using the existing Gito test-delivery path.
- Capture only non-secret evidence: HTTP status, delivery id hash or redacted id, repo id/branch/revision, Core log lines, duplicate response.

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

- [ ] `services/core/cmd/server/main.go`: inspect logs to confirm `gito http webhook consumer enabled`.
- [ ] `services/core/internal/http/gito_webhook.go`: no planned change; only patch if live delivery contradicts existing handler tests.
- [ ] `services/core/internal/gitosync/bridge.go`: no planned change; only patch if handler reaches bridge but enqueue contract fails.
- [ ] `CODE_REVIEW-cloud-G07.md`: record commands, outputs, redactions, and any skipped/blocked live step.

#### 테스트 작성

- Skip new unit tests unless a live defect is found. Existing tests cover signed HTTP validation and fake bridge enqueue; this task's missing evidence is live delivery.

#### 중간 검증

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

Expected: command exits 0 and all listed packages report `ok`.

## 의존 관계 및 구현 순서

- `08+07_gito_delivery` must start after `07+05,06_slug_reconcile` complete log exists. It is satisfied by `agent-task/archive/2026/06/m-plane-origin-authoring-roundtrip-sync/07+05,06_slug_reconcile/complete.log`.
- Dependent task `09+08_scan_enqueue` must wait for this task's `complete.log`.

## 수정 파일 요약

| 파일 | 항목 |
|------|------|
| 없음 | TEST-1 evidence-only plan |
| `CODE_REVIEW-cloud-G07.md` | TEST-1 검증 출력 기록 |

## 최종 검증

```sh
ssh toki@toki-labs.com 'zsh -lc '\''cd "$HOME/agent-work/nomadcode/services/core" && docker compose logs --no-color --since=30m nomadcode-core | rg "gito http webhook consumer enabled|gito creation sync enqueued|gito missing-create sync enqueued|gito webhook handler failed|duplicate"'\'''
```

Expected: output shows consumer enabled plus accepted/enqueued delivery evidence or an explicit duplicate result, with no secret values.

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

Expected: all listed packages pass from remote runner checkout.

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