Skip to content

fix(server): accept synthetic messages and compaction without booting a session's folder - #60801

Merged
kitlangton merged 1 commit into
devfrom
admit-without-location
Oct 31, 2026
Merged

kitlangton merged 1 commit into
devfrom
admit-without-location

Conversation

@kitlangton

@kitlangton kitlangton commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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

  1. ❌ POST /api/session/:sessionID/synthetic and POST /api/session/:sessionID/compact ran the session folder middleware before entering the handler.
  2. ❌ Every call booted the session's full folder service container even when resume: false.
  3. ❌ If the session's git worktree had been deleted, both routes failed with 400.

✅ After

  1. Both routes go straight to the global session service, matching revert.commit and wait.
  2. Recording a synthetic note (resume: false) or compaction barrier leaves sleeping folder containers asleep.
  3. Sessions whose worktrees were pruned still accept synthetic notes and compaction requests.
- POST /synthetic or /compact -> boot session folder container -> write SQLite inbox row
+ POST /synthetic or /compact -> write SQLite inbox row directly

📊 Numbers: HTTP requests against cold and deleted session folders

Case Before After
POST /synthetic (resume: false) on a sleeping folder ❌ Boots folder container ✅ 200, 0 folders booted
POST /compact on a sleeping folder ❌ Boots folder container ✅ 200, 0 folders booted
POST /synthetic or /compact after worktree deletion ❌ 400 folder not found ✅ 200, inbox item saved

The 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.ts around session.synthetic and session.compact, checking that neither handler in packages/server/src/handlers/session.ts reads Location.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 (in packages/server): 1 pass
  • bun test test/session-instances.test.ts test/session-update.test.ts (in packages/server): 3 pass
  • bun run generate (in packages/protocol and packages/client) + bun script/sdk-docs.ts: 0 problems
  • bun turbo typecheck: 35/35 pass

Added by the opencode bot (AI-generated).

Public API: session.synthetic and session.compact no longer list LocationNotFoundError in their 404 response (backwards compatible)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kitlangton
kitlangton merged commit 1d479d7 into dev Oct 31, 2026
23 checks passed
@kitlangton
kitlangton deleted the admit-without-location branch October 31, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant