Enhancement Description
Add goleak-based leak detection to daemon/service tests to prevent resource leaks from silently shipping.
Background
Daemon/controller/runtime code is concurrency-heavy. Without leak detection, tests may pass while leaking goroutines, masking production resource issues.
Scope
Add goleak to TestMain for priority packages
- Files: internal/daemon/controller/**_test.go
- Files: internal/daemon/server/**_test.go
- Files: internal/daemon/runtime/**_test.go
Expand gradually to other packages
- Files: internal/** (as needed)
Document known safe leaks with explicit ignores
- Files: affected TestMain implementations
Non-Goals
- Fixing all existing leaks in the same PR (separate issues if widespread)
- Changing runtime behavior purely for test convenience
- Adding heavy integration tests
Risks and Open Questions
- Some third-party libs may spawn background goroutines; need explicit allowlist
- Risk of flaky tests if cleanup ordering is inconsistent
- Must ensure goleak is configured correctly for parallel tests
Validation Plan
Unit and Integration Checks
- go test ./... with goleak enabled
- Ensure tests clean up goroutines by stopping servers/controllers properly
End-to-End Checks
- Run focused daemon/controller tests repeatedly to ensure no flakiness
- Validate CI consistently detects introduced leaks (intentional leak test)
Evidence Required in Issue Updates
- Test output showing goleak active
- List of allowed leaks (if any) with justification
- CI evidence catching an intentional leak (optional)
Acceptance Criteria
- Goleak enabled for priority packages
- Tests fail on new goroutine leaks
- Known safe leaks are explicitly ignored with documented reasons
- CI consistently runs leak checks
Deliverables
- PR adding goleak harness and updating affected tests
- Notes listing any temporary allowlisted leaks
Enhancement Description
Add goleak-based leak detection to daemon/service tests to prevent resource leaks from silently shipping.
Background
Daemon/controller/runtime code is concurrency-heavy. Without leak detection, tests may pass while leaking goroutines, masking production resource issues.
Scope
Add goleak to TestMain for priority packages
Expand gradually to other packages
Document known safe leaks with explicit ignores
Non-Goals
Risks and Open Questions
Validation Plan
Unit and Integration Checks
End-to-End Checks
Evidence Required in Issue Updates
Acceptance Criteria
Deliverables