fix(server): Address premature provider reaping by treating provider runtime output as session activity #3856
Closedozppupbg(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/3856/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/provider/Layers/ProviderService.ts line 307Resolvedby ozppupbg(GitHub profile, opens in a new tab)@@ -283,0 +284,21 @@284+ // Runtime event types that must NOT count as session activity.285+ // `session.exited` means the provider process is gone — bumping `lastSeenAt`286+ // would keep the directory binding alive past the runtime that backs it,287+ // defeating the reaper. Extend this set if new event types turn out to fire288+ // after a session is effectively dead.289+ const SESSION_ACTIVITY_DENY_LIST: ReadonlySet<ProviderRuntimeEvent["type"]> = new Set([290+ "session.exited",291+ ]);292+293+ const bumpSessionActivity = (event: ProviderRuntimeEvent): Effect.Effect<void> =>294+ SESSION_ACTIVITY_DENY_LIST.has(event.type)295+ ? Effect.void296+ : directory.touch(event.threadId).pipe(297+ Effect.catchCause((cause) =>298+ Effect.logDebug("provider.session.activity.touch-failed", {299+ threadId: event.threadId,300+ eventType: event.type,301+ cause,302+ }),303+ ),304+ );apps/server/src/provider/Layers/ProviderService.ts line 307Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -283,0 +284,21 @@284+ // Runtime event types that must NOT count as session activity.285+ // `session.exited` means the provider process is gone — bumping `lastSeenAt`286+ // would keep the directory binding alive past the runtime that backs it,287+ // defeating the reaper. Extend this set if new event types turn out to fire288+ // after a session is effectively dead.289+ const SESSION_ACTIVITY_DENY_LIST: ReadonlySet<ProviderRuntimeEvent["type"]> = new Set([290+ "session.exited",291+ ]);292+293+ const bumpSessionActivity = (event: ProviderRuntimeEvent): Effect.Effect<void> =>294+ SESSION_ACTIVITY_DENY_LIST.has(event.type)295+ ? Effect.void296+ : directory.touch(event.threadId).pipe(297+ Effect.catchCause((cause) =>298+ Effect.logDebug("provider.session.activity.touch-failed", {299+ threadId: event.threadId,300+ eventType: event.type,301+ cause,302+ }),303+ ),304+ );
juliusmarminge closed this
Sign in to join this conversation.


No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
a0b5dbf0-00ee-4412-87a0-79a137491f67📥 Commits
Reviewing files that changed from the base of the PR and between f61fa9499d96fee825492aba204593c37b27e0cb and bd8a0a9b4a3c9a6d321596821b35008672b9c4d0.
📒 Files selected for processing (6)
apps/server/src/persistence/ProviderSessionRuntime.tsapps/server/src/provider/Layers/CodexAdapter.test.tsapps/server/src/provider/Layers/OpenCodeAdapter.test.tsapps/server/src/provider/Layers/ProviderService.tsapps/server/src/provider/Layers/ProviderSessionDirectory.tsapps/server/src/provider/Services/ProviderSessionDirectory.ts📝 Walkthrough
Walkthrough#
Provider session runtimes can now update
last_seen_atthrough a directory touch operation. Eligible runtime events trigger this update, while denied event types are excluded and touch failures receive dedicated handling.Changes#
Provider session activity tracking
apps/server/src/persistence/ProviderSessionRuntime.tslast_seen_atby thread ID.apps/server/src/provider/Services/ProviderSessionDirectory.ts,apps/server/src/provider/Layers/ProviderSessionDirectory.ts,apps/server/src/provider/Layers/CodexAdapter.test.ts,apps/server/src/provider/Layers/OpenCodeAdapter.test.tstouch(threadId), timestamps calls, maps persistence errors, and updates adapter test doubles.apps/server/src/provider/Layers/ProviderService.tssession.exited, and handles touch failures.Sequence Diagram(s)#
Poem
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share