Repository navigation
fix(server): accept synthetic messages and compaction without booting a session's folder - #60801
Conversation
There was a problem hiding this comment.
Looks sound. On the base, the new server test fails (the session folder container boots on /synthetic and /compact); with this PR it passes. Neither handler in packages/server/src/handlers/session.ts reads Location.Service. Core Session.synthetic/Session.compact only write the inbox row, optionally commit a staged revert (a route that already skips the folder middleware) and call execution.wake, which schedules the run in the background. Nearby server tests and the server/protocol type checks pass, and regenerating the client leaves no changes.
Public API: the OpenAPI 404 response for session.synthetic and session.compact changes from SessionNotFoundError | LocationNotFoundError to SessionNotFoundError. This is backwards compatible: these routes just no longer return that error.
One behaviour change, not blocking: for a session whose worktree is gone, POST /compact (and /synthetic without resume: false) now returns 200, and the failure surfaces later as an execution failure event instead of a request error. That seems like the right trade for durable admission.
Synthetic messages and compaction requests now succeed even when a session's working folder is asleep or deleted.
Posting a synthetic message or requesting compaction only writes a durable item into the session's inbox in SQLite. Neither route needs the session's folder service container booted on the HTTP request thread, and normal prompt execution is unchanged.
❌ Before
POST /api/session/:sessionID/syntheticandPOST /api/session/:sessionID/compactran the session folder middleware before entering the handler.resume: false.400.✅ After
revert.commitandwait.resume: false) or compaction barrier leaves sleeping folder containers asleep.📊 Numbers: HTTP requests against cold and deleted session folders
POST /synthetic(resume: false) on a sleeping folder200, 0 folders bootedPOST /compacton a sleeping folder200, 0 folders bootedPOST /syntheticor/compactafter worktree deletion400folder not found200, inbox item savedThe new server test fails before the change (sleeping folders boot and deleted folders return
400) and passes after (1 pass, 8 assertions).👀 Read:
packages/protocol/src/groups/session.tsaroundsession.syntheticandsession.compact, checking that neither handler inpackages/server/src/handlers/session.tsreadsLocation.Service. The rest is routine OpenAPI regeneration.🔍 Found in a code audit · no user reports · verified with an embedded server test
Checks run
bun test test/session-admit-location.test.ts(inpackages/server): 1 passbun test test/session-instances.test.ts test/session-update.test.ts(inpackages/server): 3 passbun run generate(inpackages/protocolandpackages/client) +bun script/sdk-docs.ts: 0 problemsbun turbo typecheck: 35/35 passAdded by the opencode bot (AI-generated).
Public API: session.synthetic and session.compact no longer list LocationNotFoundError in their 404 response (backwards compatible)