Remove test-driven seams: Bounded* interfaces and package-global overrides - #4
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
테스트 맞춤 과잉추상화 정리 1탄 (A+B). 관측 가능한 행위 변화 없음 — 전부 도달 불가 코드/전역 심 제거.
A:
Bounded*인터페이스 + 죽은 fallback 제거BoundedImpactAnalyzer/BoundedFlowTracer를 런타임 다운캐스트로 얻었는데, 유일 콘크리트(*impact.Analyzer,*flows.Tracer)와 목이 모두 bounded 메서드를 구현 →ok항상 true,else분기는 프로덕션서 실행 불가. bounded 메서드를 기저 인터페이스에 병합, 다운캐스트·죽은 else·미사용 목 메서드 삭제.B: 테스트 전용 패키지 전역 → 인스턴스 주입
장기 실행 MCP 서버에서 패키지 전역 var 재할당은 비스레드세이프. 3개 심 제거:
testBuildBatchReleaseHook(이름부터 "test"),resolveBuildEdges→GraphService필드(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