Description
The auditAnalysisResults struct in pkg/cli/audit.go (line ~329) is written concurrently by multiple goroutines without a mutex. This is safe only because each goroutine exclusively owns exactly one field — but this invariant is invisible to readers and future maintainers. A future refactor that inadvertently shares a field could introduce a data race with no compile-time warning.
Suggested Changes
- Add a doc comment to the
auditAnalysisResults struct declaration explaining the field-ownership concurrency model (e.g. "Fields are written by exactly one goroutine each; see launch* comments for ownership")
- Add a one-line comment to each
launch* helper stating which fields it exclusively writes
- No behavior changes required
Optionally, add a -race-gated integration test assertion or a compile-time static-analysis hint.
Files Affected
pkg/cli/audit.go — auditAnalysisResults struct declaration and all launch* helpers
Success Criteria
auditAnalysisResults struct has a doc comment explaining field-ownership concurrency model
- Each
launch* helper has a comment naming its exclusively-owned fields
make build passes; no behavior changes
Source
Extracted from Audit Goroutine Context Blindness discussion #46848
Priority
Medium — prevents future data races from invisible invariants
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 46.7 AIC · ⌖ 7.94 AIC · ⊞ 7K · ◷
Description
The
auditAnalysisResultsstruct inpkg/cli/audit.go(line ~329) is written concurrently by multiple goroutines without a mutex. This is safe only because each goroutine exclusively owns exactly one field — but this invariant is invisible to readers and future maintainers. A future refactor that inadvertently shares a field could introduce a data race with no compile-time warning.Suggested Changes
auditAnalysisResultsstruct declaration explaining the field-ownership concurrency model (e.g. "Fields are written by exactly one goroutine each; see launch* comments for ownership")launch*helper stating which fields it exclusively writesOptionally, add a
-race-gated integration test assertion or a compile-time static-analysis hint.Files Affected
pkg/cli/audit.go—auditAnalysisResultsstruct declaration and alllaunch*helpersSuccess Criteria
auditAnalysisResultsstruct has a doc comment explaining field-ownership concurrency modellaunch*helper has a comment naming its exclusively-owned fieldsmake buildpasses; no behavior changesSource
Extracted from Audit Goroutine Context Blindness discussion #46848
Priority
Medium — prevents future data races from invisible invariants