Skip to content

Remove test-driven seams: Bounded* interfaces and package-global overrides - #4

Merged
tae2089 merged 2 commits into
mainfrom
refactor/drop-test-seams-bounded
Jul 11, 2026
Merged

Remove test-driven seams: Bounded* interfaces and package-global overrides#4
tae2089 merged 2 commits into
mainfrom
refactor/drop-test-seams-bounded

Conversation

@tae2089

@tae2089 tae2089 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

테스트 맞춤 과잉추상화 정리 1탄 (A+B). 관측 가능한 행위 변화 없음 — 전부 도달 불가 코드/전역 심 제거.

A: Bounded* 인터페이스 + 죽은 fallback 제거

BoundedImpactAnalyzer/BoundedFlowTracer를 런타임 다운캐스트로 얻었는데, 유일 콘크리트(*impact.Analyzer, *flows.Tracer)와 목이 모두 bounded 메서드를 구현 → ok 항상 true, else 분기는 프로덕션서 실행 불가. bounded 메서드를 기저 인터페이스에 병합, 다운캐스트·죽은 else·미사용 목 메서드 삭제.

B: 테스트 전용 패키지 전역 → 인스턴스 주입

장기 실행 MCP 서버에서 패키지 전역 var 재할당은 비스레드세이프. 3개 심 제거:

  • testBuildBatchReleaseHook(이름부터 "test"), resolveBuildEdgesGraphService 필드(onBatchRelease, resolveEdges), edgeResolver() 기본값 폴백
  • refreshSearchDocuments(mcp) → Deps 필드, 미설정시 service.RefreshSearchDocuments 기본

테스트는 전역 변조 대신 인스턴스 필드 설정.

검증

전체 36 패키지 그린, vet 0. 행위 무변경(제거된 분기는 프로덕션 도달 불가).

후속

C(service 파서 인터페이스 타워 붕괴 + transactional* 다운캐스트 제거), D(mcp/deps.go 10 인터페이스 DI 해체)는 별도 PR 예정.

🤖 Generated with Claude Code

tae2089 and others added 2 commits July 11, 2026 09:08
BoundedImpactAnalyzer and BoundedFlowTracer were obtained via runtime
downcast from the base ImpactAnalyzer/FlowTracer, but the sole concrete
types (*impact.Analyzer, *flows.Tracer) and the test mock all implement
the bounded method, so the downcast's ok was always true and the else
fallback branches never executed. Fold the bounded method into the base
interface, call it directly, and delete the two Bounded* interfaces, the
downcasts, the dead else branches, and the now-unused mock method.

No behavior change: the removed branches were unreachable in production.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Three package-level mutable var seams existed only so tests could swap
behavior, and reassigning a package global in a long-running MCP server
is not goroutine-safe:

- testBuildBatchReleaseHook and resolveBuildEdges (service) become
  GraphService fields (onBatchRelease, resolveEdges); edgeResolver()
  defaults to edgeresolve.ResolveWithOptions when unset.
- refreshSearchDocuments (mcp) becomes a Deps field; the handler method
  defaults to service.RefreshSearchDocuments when unset.

Tests now set the field on the instance instead of mutating a global.
The production var literally named testBuildBatchReleaseHook is gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tae2089
tae2089 merged commit b2df729 into main Jul 11, 2026
1 check failed
@tae2089
tae2089 deleted the refactor/drop-test-seams-bounded branch July 11, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant