Skip to content

[refactor] Consolidate DI containers into a single tested implementation #113

@kangeunchan

Description

@kangeunchan

Enhancement Description

One-line description (release-note style): Consolidate to a single DI container implementation with tests to reduce confusion and runtime-only failures.
Scope type: Dependency injection infrastructure consolidation

Background

Two DI containers exist (legacy Container and ContainerV2) with split usage between CLI and daemon, and zero test coverage. This increases maintenance cost and confusion.

Scope

Choose single DI container implementation (recommend ContainerV2)

Files: internal/di/container_v2.go
Files: internal/di/container.go (legacy)

Add comprehensive tests for the chosen container

Files: internal/di/*_test.go

Migrate cmd/devnet-builder wiring to the chosen container

Files: cmd/devnet-builder/** (wiring entry points)

Remove legacy container and update docs

Files: internal/di/container.go (delete)
Files: docs/**, CONTRIBUTING.md (as needed)

Non-Goals

Redesigning dependency graph or service boundaries beyond DI mechanism
Implementing new features in the container while migrating
Large refactors of unrelated CLI/daemon behavior

Risks and Open Questions

Migration can break runtime wiring; need careful smoke coverage
Container tests must cover provider registration, lifecycle, and error cases
Contributors need clear documentation to avoid reintroducing dual patterns

Validation Plan

Unit and Integration Checks

go test ./... with focus on internal/di tests (target >80% coverage)
Unit tests for provider registration, missing deps, and lifecycle ordering

End-to-End Checks

Smoke: run devnet-builder commands and devnetd daemon with new container
Ensure no nil deps or missing providers at runtime

Evidence Required in Issue Updates

Coverage report or go test output for internal/di
Example wiring diff showing cmd/devnet-builder migrated
Documentation excerpt explaining chosen container usage

Acceptance Criteria

Single DI container in repo
All use cases accessible via the chosen container
internal/di test coverage > 80%
Documentation updated with pattern and examples

Deliverables

PR adding tests and selecting container
PR migrating cmd/devnet-builder wiring
PR removing legacy container and updating docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions