fix: prevent reconcileAndEnrich from falsely stopping fuse-tracked sessions#147
Merged
fix: prevent reconcileAndEnrich from falsely stopping fuse-tracked sessions#147
Conversation
…ssions When the opencode adapter's list() doesn't return a running session (because opencode doesn't persist running sessions to native storage), reconcileAndEnrich() would mark it stopped after the 30s grace period. This fires before the lifecycle fuse ever gets a chance to detect the real session completion. Fix: check for an active fuse AND alive PID before marking a session stopped. If both conditions hold, the session stays running and the fuse handles lifecycle detection. Also wires up fuse set/cancel in the daemon's launch/stop paths. Fixes #146
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.
Problem
The daemon falsely marks opencode sessions as stopped within seconds of launch (#146).
Root cause:
reconcileAndEnrich()insession-tracker.tshas a 30s grace period. After that, if the opencode adapter'slist()doesn't return the session (opencode doesn't persist running sessions to native storage), the daemon assumes it's dead. This fires before the lifecycle fuse (#144) ever gets a chance to detect real completion.Evidence: Two sessions launched 2026-03-12 were marked stopped in ~10s but actually ran ~20 minutes and opened PRs.
Fix
reconcileAndEnrich()now checks for an active fuse + alive PID before marking a session stopped. If both conditions hold, the session staysrunningand the fuse handles lifecycle detection as intended.Also wires up fuse
set/cancelin the daemon's launch and stop paths so every launched session gets a fuse automatically.Changes
session-tracker.ts:reconcileAndEnrichaccepts optionalhasFuse(id)+isAlive(pid)callbacks; skips stopping sessions that have active fuses with alive PIDsserver.ts: Passes fuse engine check to session tracker; sets fuse on launch, cancels on stopsession-tracker.test.ts: 4 new regression tests covering fuse+PID behaviorVerification
npm run typecheck✅npm run lint✅npm run build✅E2E Proof
Session
2fb3f47b— 68-second opencode session creating a Node.js project:Daemon state confirms correct timing:
startedAt: 2026-03-13T05:50:57.650ZstoppedAt: 2026-03-13T05:52:05.754ZWebhook delivered to OrgLoop →
agentctl-supervisorroute fired ✅Fixes #146