<!-- task=m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode plan=1 tag=REVIEW_API -->

# Code Review Reference - REVIEW_API

> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
> The task is NOT complete until every implementation-owned section below is filled in.
> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving.
> Fill implementation-owned sections, then stop with active files in place and report ready for review.
> If implementation is blocked by a user-only decision, user-owned external environment prerequisite, or scope conflict, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Evidence gaps that a follow-up agent can close by rerunning commands or collecting artifacts are normal follow-up issues, not user-review blockers by themselves.
> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record the needed decision in `사용자 리뷰 요청` and stop for code-review.
> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume.
> Follow the ownership table at the bottom of this file for which sections you own.

## 개요

date=2026-06-16
task=m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode, plan=1, tag=REVIEW_API

## Roadmap Targets

- Milestone: `agent-roadmap/phase/agent-ops-mcp-control-plane/milestones/gito-protosocket-consumer-wire-readiness.md`
- Task ids:
  - `transport-adapter`: JSON text websocket transport를 실제 proto-socket binary/protobuf transport 또는 동등 adapter로 교체
  - `envelope-decode`: binary frame에서 받은 `structpb.Struct` envelope을 기존 `gitoevents.DecodeBranchUpdatedEnvelope` 입력으로 안전하게 변환
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- Current archived plan: `agent-task/m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode/plan_cloud_G07_0.log`
- Current archived review: `agent-task/m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode/code_review_cloud_G07_0.log`
- Verdict: FAIL
- Required summary:
  - `services/core/internal/gitosync/runner.go:64` and `services/core/internal/gitosync/runner.go:74` silently drop inbound decoded envelopes and disconnect EOF when the buffered channel is full.
  - `services/core/internal/gitosync/runner_test.go:123` verifies transport `Write`/`Read` manually but does not prove `gitoevents.Client.Run` delivers the binary `branch.updated` event to the handler exactly once.
  - `services/core/internal/gitosync/runner_test.go:89` covers invalid packet bytes but not valid-Struct malformed/mismatched envelope side-effect behavior through the real transport/client path.
- Affected files:
  - `services/core/internal/gitosync/runner.go`
  - `services/core/internal/gitosync/runner_test.go`
  - `services/core/internal/gitoevents/events_test.go` if an extra decoder regression is needed
- Verification evidence from prior loop:
  - `git diff --check` passed after review-applied `gofmt`.
  - `cd services/core && go test ./internal/gitosync ./internal/gitoevents ./internal/protosocket` passed.
  - `cd services/core && go test ./...` passed.
  - `cd services/core && go test ./internal/gitosync -run TestRunnerTransportUsesBinaryProtoSocketSubscribeAndEvent -count=1 -v` passed.
- Roadmap carryover: keep the same `transport-adapter` and `envelope-decode` targets; do not mark roadmap tasks directly.
- Allowed archive reread: only the two archived files listed above if exact prior wording is needed.

## 이 파일을 읽는 리뷰 에이전트에게

> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.

각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.

1. 판정을 append한다.
2. `CODE_REVIEW-cloud-G07.md` -> `code_review_cloud_G07_N.log`, `PLAN-cloud-G07.md` -> `plan_cloud_G07_M.log`로 아카이브한다.
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다.
4. PASS이고 task group이 `m-gito-protosocket-consumer-wire-readiness`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다.

---

## 구현 항목별 완료 여부

| 항목 | 완료 여부 |
|------|---------|
| [REVIEW_API-1] Make inbound queue overflow and disconnect observable | [x] |
| [REVIEW_API-2] Prove the production client handler path over binary proto-socket | [x] |
| [REVIEW_API-3] Cover malformed and mismatched Struct frames through the side-effect boundary | [x] |

## 구현 체크리스트

- [x] inbound decoded envelopes and disconnect/error signals are never silently dropped; overflow or close is either backpressured or returned as an explicit `Read` error.
- [x] a real proto-socket server plus `gitoevents.Client.Run` test proves `event.subscribe` is sent and exactly one on-target binary `branch.updated` event reaches the handler.
- [x] valid-Struct malformed/mismatched frames, including wrong channel/action and missing payload, are covered through the real transport/client side-effect boundary before a valid event.
- [x] `gofmt`, `git diff --check`, `cd services/core && go test ./internal/gitosync ./internal/gitoevents ./internal/protosocket`, and `cd services/core && go test ./...` are executed.
- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.

## 코드리뷰 전용 체크리스트

> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.

- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_N.log`로 아카이브한다.
- [x] active `PLAN-*-G??.md`를 `plan_cloud_G07_M.log`로 아카이브한다.
- [x] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다.
- [x] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
- [x] PASS이면 active task 디렉터리 `agent-task/m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode/`를 `agent-task/archive/YYYY/MM/m-gito-protosocket-consumer-wire-readiness/01_wire_transport_decode/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [x] PASS이고 task group이 `m-gito-protosocket-consumer-wire-readiness`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
- [x] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-gito-protosocket-consumer-wire-readiness/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G07.md` and `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다.
- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다.
- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.

## 계획 대비 변경 사항

- 없음. 계획에 제시된 설계 요구사항(Overflow 및 Disconnect 방지, client.Run 연동 검증, malformed/mismatched struct drop 검증)을 지연 없이 모두 완벽하게 이행하였습니다.

## 주요 설계 결정

- `protoSocketTransport` 내부에서 비동기 리스너 콜백(AddListenerTyped, AddDisconnectListener)이 inbound 채널로 메시지를 인입할 때 무손실 처리를 위해 backpressure를 적용하도록 select/enqueue 방식을 도입하였습니다.
- transport가 Close() 될 때 blocking 상태를 해제하기 위해 `closed chan struct{}` 시그널링 채널을 추가하여 안전하게 루프가 종료되도록 하였습니다.
- 테스트의 유연성을 위해 transport에 `inboundCap` 필드를 추가하여 버퍼 오버플로우 상황을 시뮬레이션할 수 있게 하였습니다.

## 사용자 리뷰 요청

- 상태: 없음
- 사유 유형: 없음
- 결정 필요: 없음
- 차단 근거: 없음
- 실행한 검증/명령: 없음
- 자동 후속 불가 이유: 없음
- 재개 조건: 없음

## 리뷰어를 위한 체크포인트

- `protoSocketTransport`가 branch event 또는 terminal error/EOF를 silent drop하지 않는지 확인한다.
- `gitoevents.Client.Run`이 real proto-socket server와 production transport 조합에서 handler를 정확히 한 번 호출하는지 확인한다.
- malformed or mismatched `structpb.Struct` frames do not cause handler side effects and do not prevent a later valid event from being consumed.

## 검증 결과

### REVIEW_API-1 중간 검증

```bash
cd services/core && go test ./internal/gitosync -run 'TestProtoSocketTransport.*(Overflow|Disconnect|Drop)' -count=1
```

```
ok  	github.com/nomadcode/nomadcode-core/internal/gitosync	0.313s
```

### REVIEW_API-2 중간 검증

```bash
cd services/core && go test ./internal/gitosync -run TestProtoSocketTransportClientRunDeliversBinaryBranchUpdatedEvent -count=1
```

```
ok  	github.com/nomadcode/nomadcode-core/internal/gitosync	0.063s
```

### REVIEW_API-3 중간 검증

```bash
cd services/core && go test ./internal/gitosync -run TestProtoSocketTransportClientRunDropsMalformedAndMismatchedStructs -count=1
```

```
ok  	github.com/nomadcode/nomadcode-core/internal/gitosync	0.111s
```

### 최종 검증

```bash
gofmt -w services/core/internal/gitosync/runner.go services/core/internal/gitosync/runner_test.go services/core/internal/gitoevents/events_test.go
git diff --check
cd services/core && go test ./internal/gitosync ./internal/gitoevents ./internal/protosocket
cd services/core && go test ./...
```

```
# gofmt -w services/core/internal/gitosync/runner.go services/core/internal/gitosync/runner_test.go services/core/internal/gitoevents/events_test.go
(No output, exited with code 0)

# git diff --check
(No output, exited with code 0)

# go test ./internal/gitosync ./internal/gitoevents ./internal/protosocket
ok  	github.com/nomadcode/nomadcode-core/internal/gitosync	0.367s
ok  	github.com/nomadcode/nomadcode-core/internal/gitoevents	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/protosocket	(cached)

# go test ./...
ok  	github.com/nomadcode/nomadcode-core/cmd/plane-smoke	(cached)
?   	github.com/nomadcode/nomadcode-core/cmd/server	[no test files]
ok  	github.com/nomadcode/nomadcode-core/internal/adapters/a2a	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/adapters/jira	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/adapters/mattermost	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/adapters/openai	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/adapters/plane	(cached)
?   	github.com/nomadcode/nomadcode-core/internal/agent	[no test files]
ok  	github.com/nomadcode/nomadcode-core/internal/authoring	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/config	(cached)
?   	github.com/nomadcode/nomadcode-core/internal/db	[no test files]
ok  	github.com/nomadcode/nomadcode-core/internal/gitoevents	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/gitosync	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/http	(cached)
?   	github.com/nomadcode/nomadcode-core/internal/model	[no test files]
ok  	github.com/nomadcode/nomadcode-core/internal/notification	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/projectsync	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/protosocket	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/roadmapsync	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/roadmapsyncpipeline	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/scheduler	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/storage	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/workflow	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/workitem	(cached)
ok  	github.com/nomadcode/nomadcode-core/internal/workitempipeline	(cached)
```

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?**
> If anything is blank, go back and fill it in before saving this file.
> Leave review-agent-only sections unchanged.

## 소유권

| Section　　　　　　　　　　　　　　　　　| Owner                                      | Note　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　 |
| ------------------------------------------| --------------------------------------------| ----------------------------------------------------------------------------|
| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation                     | Implementing agent must not modify or execute these　　　　　　　　　　　　|
| Roadmap Targets　　　　　　　　　　　　　| Fixed at stub creation from plan           | Implementing agent must not modify　　　　　　　　　　　　　　　　　　　　 |
| Archive Evidence Snapshot　　　　　　　　| Fixed at stub creation from follow-up plan | Implementing agent may use only the listed archive paths for narrow reread |
| 구현 항목별 완료 여부　　　　　　　　　　| Implementing agent                         | Check `[ ]` to `[x]` only　　　　　　　　　　　　　　　　　　　　　　　　　|
| 구현 체크리스트　　　　　　　　　　　　　| Implementing agent                         | Check `[ ]` to `[x]` only　　　　　　　　　　　　　　　　　　　　　　　　　|
| 코드리뷰 전용 체크리스트　　　　　　　　 | Review agent only                          | Implementing agent must not modify　　　　　　　　　　　　　　　　　　　　 |
| 계획 대비 변경 사항, 주요 설계 결정　　　| Implementing agent                         | Replace placeholder text with actual content　　　　　　　　　　　　　　　 |
| 사용자 리뷰 요청　　　　　　　　　　　　 | Implementing agent                         | Keep `상태: 없음` unless user input is required　　　　　　　　　　　　　　|
| 리뷰어를 위한 체크포인트　　　　　　　　 | Fixed at stub creation                     | Review focus　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　 |
| 검증 결과　　　　　　　　　　　　　　　　| Implementing agent                         | Paste actual output　　　　　　　　　　　　　　　　　　　　　　　　　　　　|

## 코드리뷰 결과

### 종합 판정

PASS

### 차원별 평가

| 차원 | 평가 | 근거 |
|------|------|------|
| Correctness | Pass | `protoSocketTransport` no longer uses lossy `default` sends; inbound events and disconnect EOF are backpressured or unblocked by `Close`. |
| Completeness | Pass | All three follow-up items are implemented and the review stub checklist is complete. |
| Test coverage | Pass | Added focused tests for overflow/disconnect observability, real `gitoevents.Client.Run` binary interop, and malformed/mismatched struct drop behavior. |
| API contract | Pass | The transport remains on binary proto-socket `PacketBase` + `structpb.Struct`, and the subscribe/event path matches the Gito contract. |
| Code quality | Pass | `gofmt -l` returned no files; no debug prints, stale JSON text transport, or TODOs were found in the touched gitosync/gitoevents files. |
| Plan deviation | Pass | Follow-up scope stayed within `runner.go` and focused tests, with prior wider docs/roadmap changes left outside this verdict. |
| Verification trust | Pass | Re-ran focused tests, `git diff --check`, `go test ./internal/gitosync ./internal/gitoevents ./internal/protosocket`, and `go test ./...`; all passed. |

### 발견된 문제

없음

### 다음 단계

PASS: archive this review/plan pair, write `complete.log`, move the split task directory to archive, and report milestone completion event metadata for the runtime.
