refactor: implement dependency injection in controllers#113
Conversation
Instructs Claude to use glab CLI and MCP tools as source of truth for MR data instead of local git state, which may be stale during concurrent reviews. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…endencies Apply the same dependency injection pattern as GitLab controller: - Create GitHubWebhookDependencies interface with gateway + use case types - Remove all direct instantiations from controller body - Wire dependencies in composition root (routes.ts) - Update tests to verify use case calls instead of gateway internals - Migrate all imports to @/ alias with .js extension Also includes: - Add CLAUDE.md project guide and .claude/ config (agents, rules, roles, commands) - Update .gitignore to track CLAUDE.md and .claude/ config files Fixes #74 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review - PR #113 (feat/74-dependency-injection-controllers)Date: 2026-03-06 Executive Summary
Overall Score: 8.8/10 — Well-executed refactoring that aligns the GitHub controller with the GitLab controller's dependency injection pattern. Clean removal of unused code. Minor import regression to fix. Important Corrections (before merge)1. Import regression in
|
| Aspect | Observation |
|---|---|
| DI Pattern | GitHubWebhookDependencies mirrors the GitLab controller pattern — consistency achieved |
| Composition Root | Instantiation correctly moved to routes.ts |
| Type-only imports | Use cases imported with type keyword — controller depends on abstractions |
| Test refactoring | Tests assert on injected mocks, not internal implementations |
| Data source rules | New MCP prompt rules prevent stale local state during concurrent reviews |
| Dead code removal | baseUrl cleanly removed from ExecutionContext and all call sites |
Pre-Merge Checklist
[ ] Fix import regression in reviewAction.gitlab.cli.gateway.ts (use @/ aliases)
[ ] Verify CLAUDECODE env var removal is intentional
[ ] yarn verify passes without error
Pedagogical Resources
Dependency Inversion Principle (DIP)
"Depend upon Abstractions. Do not depend upon concretions."
— Robert C. Martin, Agile Software Development, 2002
This PR is a textbook application of DIP. The GitHub controller now receives abstractions through GitHubWebhookDependencies instead of instantiating concrete classes. This makes the controller testable, flexible, and decoupled.
Composition Root Pattern
"A Composition Root is a (preferably) unique location in an application where modules are composed together."
— Mark Seemann, Dependency Injection in .NET, 2011
Moving instantiation to routes.ts follows this pattern correctly — the composition root wires concrete pieces together, keeping the rest of the application framework-agnostic.
[REVIEW_STATS:blocking=0:warnings=2:suggestions=3:score=8.8]
Follow-up Review - PR #113Date: 2026-03-06 Blocking Issues VerificationThe initial review raised 2 warnings and 3 suggestions. Here is the verification:
Note: The initial review appears to have analyzed files that are NOT in the PR diff. The New Problems DetectedNo new problems detected in the modifications. Quick scan results:
Minor observation (non-blocking): The test file Final Verdict
Recommendation
[REVIEW_STATS:blocking=0:warnings=0:suggestions=1:score=9] |
Summary
GitLabWebhookDependenciesinterface (3 gateways + 6 use cases)GitHubWebhookDependenciesinterface (3 gateways + 2 use cases)routes.tswhere they belong@/alias with.jsextensiondeps.trackAssignment.execute) instead of gateway internalsTest plan
yarn typecheckpasses with 0 errorsyarn test:ci— 917 tests pass (117 files)yarn lint— 0 issuesFixes #74
🤖 Generated with Claude Code