Skip to content

Add build-tagged deadlock detection - #348

Merged
yottadynamics merged 2 commits into
mainfrom
fix/deadlock-detection
Sep 14, 2026
Merged

yottadynamics merged 2 commits into
mainfrom
fix/deadlock-detection

Conversation

@yottadynamics

@yottadynamics yottadynamics commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add systemic deadlock detection for yottacode's mutexes while keeping production behavior unchanged:

  • introduce internal/syncutil.Mutex and RWMutex as build-tagged aliases
  • use standard-library locks by default and github.com/sasha-s/go-deadlock only under -tags deadlock
  • instrument production and test mutexes across the codebase
  • preserve recursive-lock and lock-order detection while disabling the global wait-duration heuristic to avoid false positives during legitimate long operations
  • use the standard-only syncutil.PollingRWMutex for context-aware TryLock polling because go-deadlock v0.3.9 cannot safely track failed cross-goroutine try-lock attempts
  • add the exact HistoryLock regression test using a real non-nil lock and parallel tool results
  • add a build-tagged subprocess probe that proves recursive-lock detection terminates with the expected diagnostic
  • run the deadlock detector in CI
  • add import-aware AST enforcement covering production and test files, including aliased and dot imports of sync
  • document the convention and narrow polling exception in CONTRIBUTING.md and .yottacode/YOTTACODE.md

Related issue

Closes the systemic follow-up to the TUI session deadlock postmortem.

How was this tested?

  • go test ./... — passed
  • go vet ./... — passed
  • go test -short -tags deadlock ./... — passed
  • go test -short -race ./... — passed
  • govulncheck ./... — passed
  • git diff --check — passed
  • LSP diagnostics — clean for ordinary files; build-tag-only deadlock files are excluded from the default gopls configuration

The detector subprocess test has a five-second context deadline, so a broken detector fails promptly instead of hanging until the package timeout.

Checklist

  • go test ./... passes
  • go vet ./... is clean
  • govulncheck ./... reports no reachable vulnerabilities
  • Tests added or updated — a new capability ships with tests, and the deadlock regression is covered
  • Docs updated in the same change
  • PR is focused on one logical change

Drafted with yottacode

yottadynamics and others added 2 commits September 14, 2026 13:27
Co-authored-by: yottacode <325888353+yottacode-agent@users.noreply.github.com>
Co-authored-by: yottacode <325888353+yottacode-agent@users.noreply.github.com>
@yottadynamics
yottadynamics merged commit e24cd04 into main Sep 14, 2026
7 checks passed
@yottadynamics
yottadynamics deleted the fix/deadlock-detection branch September 14, 2026 19:12
Sign up for free to 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.

1 participant