Skip to content

Commit 8574aa5

Browse files
redcourageclaude
authored andcommitted
fix(go): apply Phase A review feedback + slim progress doc
Reviewer A (Go 코드 품질) Critical 2 + Major 다수: - isNormalShutdown dead branch 제거 (nil || ctx.Canceled 만) - stubHandler 가 *Deps 캡처 (8 call site 시그니처 통일) - Register 가 error 반환 + defer recover() (AddTool panic 가드) - log.Printf → slog.Error - go.mod toolchain go1.25.0 directive - Deps ghost field 제거 → 빈 struct + 향후 sketch 코멘트 Reviewer B (설계/문서) Major 8 — doc 정확도: - LOC 정정 (main.go 80→74, tools.go 137→134) - §1.5 code block runnable + topk non-nullable 정정 - §2.2 absolute path placeholder + namespace 충돌 설명 - §4.7 macOS bash 3.2 coproc 경고 - §7 다음 마일스톤 11개로 확장 phase-a-mcp-boot.md 슬림화 (588→180줄): - F1~F6 narrative → 동작/한계 매트릭스 - §3 Level 1.1~1.6 6 시퀀스 → 핵심 3 블록 (build/list/call) - §4 cookbook 8 subsection → mcp_call 헬퍼 + 8 tool 호출 1 블록 - §6 코드 변경 요약 삭제 (git diff에 있음) 검증: go build · go vet · smoke test (initialize → tools/list 8 → tools/call) ✅ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b5e2c9b commit 8574aa5

6 files changed

Lines changed: 165 additions & 538 deletions

File tree

cmd/rune-mcp/main.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ package main
1616
import (
1717
"context"
1818
"errors"
19-
"io"
20-
"log"
19+
"log/slog"
2120
"os"
2221
"os/signal"
23-
"strings"
2422
"syscall"
2523

2624
sdkmcp "github.com/modelcontextprotocol/go-sdk/mcp"
@@ -56,26 +54,21 @@ func main() {
5654
Version: version,
5755
}, nil)
5856

59-
mcp.Register(srv, deps)
57+
if err := mcp.Register(srv, deps); err != nil {
58+
slog.Error("rune-mcp register failed", "err", err)
59+
os.Exit(1)
60+
}
6061

6162
if err := srv.Run(ctx, &sdkmcp.StdioTransport{}); err != nil && !isNormalShutdown(err) {
62-
log.Printf("rune-mcp serve error: %v", err)
63+
slog.Error("rune-mcp serve error", "err", err)
6364
os.Exit(1)
6465
}
6566
}
6667

67-
// isNormalShutdown reports whether err corresponds to expected stdio teardown
68-
// (stdin EOF, ctx cancel from SIGINT/SIGTERM, or the SDK's internal
69-
// jsonrpc2.ErrServerClosing surfacing as "server is closing"). Those are not
70-
// failures and must not produce exit code 1.
68+
// isNormalShutdown reports whether err corresponds to expected stdio teardown.
69+
// The SDK's `Connection.Wait` filters io.EOF to nil before returning, so on
70+
// stdin EOF Run returns nil. The only other expected exit is ctx cancel from
71+
// SIGINT/SIGTERM, which surfaces as context.Canceled.
7172
func isNormalShutdown(err error) bool {
72-
if err == nil {
73-
return true
74-
}
75-
if errors.Is(err, io.EOF) || errors.Is(err, context.Canceled) {
76-
return true
77-
}
78-
// jsonrpc2.ErrServerClosing lives in an internal package, so we can't use
79-
// errors.Is. The message is stable per the SDK source.
80-
return strings.Contains(err.Error(), "server is closing")
73+
return err == nil || errors.Is(err, context.Canceled)
8174
}

docs/v04/notes/flow-matrix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
| 11 | `adapters/logio/capture_log.go::Append` | 3/10 | write tool 3개 (CAP·BAT·DEL) |
7676

7777
> **TM** = teammate scope. 타입 시그니처는 팀원 확정에 의존하지만, 내 구현 코드의 거의 모든 경로가 이 에러 타입을 참조한다.
78+
>
79+
> **현재 상태 (2026-04-25, Phase A 합격 후)**: Tier S 1·2·4 (`Deps`, `obs/slog`, `lifecycle/boot`)는 본 매트릭스가 "stdlib-only로 즉시 시작 가능"이라 분류했지만, 실제로는 Phase A가 vertical slice 우선 (SDK 연결)로 진행되며 **셋 다 still skeleton 상태**다. `Deps`는 빈 struct, `obs/slog``NewRequestID() == ""` stub, `lifecycle/boot.go::RunBootLoop``_ = ctx`. Phase A.5 또는 Phase 4 진입 전에 보강 필요. 자세한 phase별 상태는 [`docs/v04/progress/`](../progress/).
7880
7981
---
8082

docs/v04/progress/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ README의 7-Phase 로드맵(Phase 1 외부 deps → Phase 7 검증)이 **horizon
2626
| 마일스톤 | 상태 | 문서 | 관련 커밋 |
2727
|---|---|---|---|
2828
| Phase A — MCP boot (handshake + tools/list) | ✅ 합격 | [phase-a-mcp-boot.md](phase-a-mcp-boot.md) | `19b7bf6` (브랜치 `yg/first-mcp-boot`) |
29-
30-
이후 마일스톤 (예정):
31-
- Phase B — `rune_diagnostics` environment 섹션 진짜 응답 (stdlib only)
32-
- Phase 1 — `go.mod` 외부 deps 본격 추가 (gRPC · envector SDK · embedder proto)
33-
- Phase 4a — Vault 클라이언트 + 부팅 시퀀스 연결
34-
- Phase 4b — envector SDK 연결 (Q4 PR 머지 후)
35-
- Phase 4c — embedder 클라이언트
36-
- Phase 5 — service 레이어 오케스트레이션
37-
- Phase 7 — golden fixture 기반 bit-identical 검증
29+
| Phase A.5 — smoke test 추가 (CI 회귀 방지) | ⏳ 예정 |||
30+
| Phase B — `rune_diagnostics` environment 섹션 진짜 응답 (stdlib only) | ⏳ 예정 |||
31+
| Phase 1 — `go.mod` 외부 deps 본격 추가 (gRPC · envector SDK · embedder proto) | ⏳ 예정 |||
32+
| Phase 2 — `internal/domain` + `internal/policy` 순수 로직 (TM scope) | ⏳ 예정 |||
33+
| Phase 3 — `record_builder` 703 LoC + `payload_text` 364 LoC 포팅 (TM scope) | ⏳ 예정 |||
34+
| Phase 4a — Vault 클라이언트 + 부팅 시퀀스 연결 | ⏳ 예정 |||
35+
| Phase 4b — envector SDK 연결 (Q4 PR 머지 후) | ⏳ 예정 |||
36+
| Phase 4c — embedder 클라이언트 | ⏳ 예정 |||
37+
| Phase 5 — service 레이어 오케스트레이션 (`stubHandler` → 실제 service 호출) | ⏳ 예정 |||
38+
| Phase 7 — golden fixture 기반 bit-identical 검증 | ⏳ 예정 |||
39+
40+
> Phase 6 (MCP wiring)은 Phase A에서 부분 선행됐으므로 별도 마일스톤으로 빼지 않음. Phase 5의 service 호출 교체에 흡수됨.
3841
3942
## 사용 방식
4043

0 commit comments

Comments
 (0)