-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Enhancement Description
Replace global network registry and global logger usage with injected dependencies to improve test isolation and initialization safety.
Background
Global registry and logger references create hidden dependencies, impede unit testing, and risk initialization-order issues across CLI/daemon paths.
Scope
Convert network registry to instance-scoped dependency
- Files: internal/infrastructure/network/registry.go
- Files: call sites referencing network.Get(...) (as identified)
Inject logger via constructors (remove DefaultLogger direct usage)
- Files: internal/output/** (if needed)
- Files: call sites referencing output.DefaultLogger (as identified)
Add lint/static checks to prevent reintroduction (may link to Issue 6.1)
- Files: .golangci.yml (optional)
Non-Goals
- Rewriting logging framework or introducing new log backends
- Broad functional behavior changes beyond dependency wiring
- Refactoring unrelated global singletons in other subsystems
Risks and Open Questions
- Large refactor surface area: many call sites may need signature changes
- Risk of nil logger/registry if DI wiring incomplete
- Need to confirm thread-safety and lifecycle ownership of registry instances
Validation Plan
Unit and Integration Checks
- go test ./... with targeted tests ensuring injected instances work
- Unit tests that instantiate isolated registries/loggers
- Static grep/go list checks to ensure global references are removed
End-to-End Checks
- Smoke: daemon start/stop and core operations still work with injected logger/registry
- Confirm no regressions in plugin discovery/network selection paths
Evidence Required in Issue Updates
- go list/grep output confirming global references reduced/removed
Acceptance Criteria
- Registry is created and passed by DI (no global Get usage)
- Logger is injected (no output.DefaultLogger references)
- Tests can create isolated instances without shared global state
- Static analysis prevents new global references
Deliverables
- PR converting registry and updating call sites
- PR injecting logger and updating call sites
- Optional lint rule PR to prevent regressions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels