Enforce manualmutexunlock in CI and eliminate non-deferred mutex unlock paths#35189
Merged
Conversation
6 tasks
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix manualmutexunlock analyzer not enforced by CI
Enforce May 27, 2026
manualmutexunlock in CI and eliminate non-deferred mutex unlock paths
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables CI enforcement of the manualmutexunlock custom linter and refactors remaining production mutex unlock paths to use deferred unlock patterns for panic-safe lock release.
Changes:
- Adds
-manualmutexunlockto the custom linter flags in the CGO workflow. - Converts manual mutex unlock sequences to
defer-based unlocks. - Uses scoped closures where needed to keep critical sections narrow.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/cgo.yml |
Enables manualmutexunlock in the enforced custom linter set. |
pkg/agentdrain/coordinator.go |
Defers coordinator read-lock release in minerFor. |
pkg/agentdrain/miner.go |
Defers miner locks in event training and analysis paths. |
pkg/cli/compile_watch.go |
Refactors debounce mutex handling to deferred unlocks. |
pkg/cli/docker_images.go |
Refactors Docker mock state and download cleanup locking. |
pkg/console/spinner.go |
Refactors spinner lifecycle locking to deferred unlocks. |
pkg/parser/virtual_fs.go |
Defers builtin virtual file read-lock release. |
pkg/parser/virtual_fs_wasm.go |
Defers builtin virtual file read-lock release in wasm builds. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
manualmutexunlockwas registered but not enforced in CI, allowing production lock/unlock sequences that could leak locks on panic/early-return. This PR enables enforcement and refactors the remaining flagged sites to use deferred unlock patterns.CI enforcement
.github/workflows/cgo.ymlcustom linter selector to include-manualmutexunlockinLINTER_FLAGS.Panic-safe lock handling in production paths
Lock/RLock→Unlock/RUnlockpairs with deferred unlocks (often via small scoped closures to keep lock lifetime tight) in:pkg/agentdrain/miner.gopkg/agentdrain/coordinator.gopkg/console/spinner.gopkg/cli/compile_watch.gopkg/cli/docker_images.gopkg/parser/virtual_fs.gopkg/parser/virtual_fs_wasm.goRefactor pattern used
defer: