Skip to content

Document audit goroutine field-ownership invariants - #46962

Merged
pelikhan merged 4 commits into
mainfrom
copilot/code-quality-document-goroutine-safety
Jul 21, 2026
Merged

Document audit goroutine field-ownership invariants#46962
pelikhan merged 4 commits into
mainfrom
copilot/code-quality-document-goroutine-safety

Conversation

CopilotAI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

auditAnalysisResults is populated from multiple goroutines without synchronization, relying on an implicit invariant that each field has a single writer. This change makes that ownership model explicit at the struct and helper boundaries so future refactors do not accidentally introduce races.

  • Concurrency contract on auditAnalysisResults

    • Added a doc comment on auditAnalysisResults describing the lock-free concurrency model.
    • Explicitly states that fields must remain single-writer unless synchronization is introduced.
  • Per-helper ownership annotations

    • Added one-line comments to each launch* helper naming the fields it exclusively writes:
      • launchCoreAuditAnalyses
      • launchMetricsAnalysis
      • launchJobDetailsAnalysis
      • launchFirewallAuditAnalyses
      • launchFirewallAnalysis
      • launchSupplementalAuditAnalyses
  • Intent made local to the fan-out points

    • Ownership is documented where goroutines are launched, so readers do not need to reconstruct the invariant from closures and setters.
// auditAnalysisResults is populated concurrently during audit collection.// Each field is written by exactly one goroutine...typeauditAnalysisResultsstruct {
metricsLogMetricsfailedJobCountintjobDetails []JobInfoWithDuration// ...
}
// launchMetricsAnalysis exclusively writes results.metrics.funclaunchMetricsAnalysis(...) { ... }

CopilotAIand others added 3 commits July 21, 2026 04:09
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Document goroutine-safety field-ownership invariants on auditAnalysisResultsDocument audit goroutine field-ownership invariantsJul 21, 2026
CopilotAI requested a review from pelikhanJuly 21, 2026 04:24
@pelikhan
pelikhan marked this pull request as ready for review July 21, 2026 04:29
CopilotAI review requested due to automatic review settings July 21, 2026 04:29
@pelikhan
pelikhan merged commit a40fd9a into mainJul 21, 2026
1 check passed
@pelikhan
pelikhan deleted the copilot/code-quality-document-goroutine-safety branch July 21, 2026 04:29

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents lock-free field ownership for concurrent audit analysis.

Changes:

  • Adds concurrency invariants and helper ownership annotations.
  • Includes an unrelated generated workflow behavior change.
Show a summary per file
FileDescription
pkg/cli/audit.goDocuments goroutine field ownership.
.github/workflows/smoke-call-workflow.lock.ymlRegenerates inputs, permissions, and secrets unexpectedly.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment on lines +1116 to +1117
issues: write
pull-requests: write
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.15

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Document goroutine-safety field-ownership invariants on auditAnalysisResults

3 participants

@pelikhan