Repository navigation
Captain Code v0.3.3
Fix: the brain could stop answering
v0.3.3 fixes a deadlock that froze the shared brain. Every TUI then showed "still working" on turns whose workers had already finished. Upgrade if you use a jev decision leg.
The deadlock
- After a confidently routed turn, the brain sometimes asks jev in the background how it would have routed the same turn. By default 1 in 5 such turns is sampled. When jev answered, the brain charged the call while still holding its main lock, and the charge waits for that same lock, so it waited forever.
- Every sidebar poll and every finishing turn then queued behind that lock. Finished answers never reached the TUI, and thousands of connections piled up. The bug was in every release since v0.2.4.
- The check is now recorded, the lock released, and only then is the call charged. A regression test covers it.
- To turn the background check off on older versions, set
CAPTAIN_TRIAGE_SHADOW_RATE=0.
Seeing and stopping a stuck brain
- The brain's main lock now remembers which code took it. If it's held for more than a minute, the brain log names that code and later says when the lock is released.
- A brain asked to stop (SIGTERM) now waits at most 10 seconds for the lock, then ends its workers and exits anyway. Before, a stuck brain ignored SIGTERM, so a restart couldn't replace it.
captaincode.shnow waits for the old brain to exit after asking it to stop. If it still answers, it allows up to 4 minutes for cleanup; if it answers nothing, it kills it.
Install or update: go install github.com/lemma-ventures/captaincode/cmd/captaincode@latest.