Repository navigation
app: every lock in the guarded tree unlocks from a defer - #2172
Merged
Merged
Conversation
Uncommitted work of the guard lane, saved before the tip merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The guard law (every lock in the guarded tree unlocks from a defer) also named briefDebounce.take, added on app/v3 after the guard lane started. claim now holds the lock with a deferred unlock; the write fires outside. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What changes
Every lock in the guarded tree is now released through a deferred unlock. This fixes the law
TestEveryLockInTheGuardedTreeUnlocksFromADefer, which was red on app/v3. A lock with a hand-written unlock leaks when the code under it panics and the panic is absorbed. The next caller then waits forever, so a fault becomes a freeze.Each critical section that did not run to the end of its function moved into a small function of its own, which holds the lock with
defer:remember→rememberHeldRetry→knownWorkRefusalGatedtraceAnswer→firstAnswersMoveToTask→moveToTaskGatedfactoryPower→currentHostbriefDebounce.take→claimstageAgentsWhere,recoveringAgents,currentSeaminternal/residentBehaviour does not change. Work that must run outside the lock (for example
ActOnTask, the startup trace and the brief write) still runs after the lock is released.Evidence
go test ./internal/guard/ok.go vetand gofmt are clean.go test ./internal/resident/ok. Fullgo test ./cmd/codeaf/: result below.Limits
🤖 Generated with Claude Code