Repository navigation
fix(harness): key a new session's first turn by its session id - #375
Conversation
executeTurn opens the session before leasing a sandbox, but leased with input.sessionId, which is undefined when /turn omits it. acquireTurnSandbox then keyed the workspace by the per-turn lease holder (anon:<uuid>): the microVM tier refuses that key, so every tool call of a new session's first turn failed, and on any keyed tier turn 1 wrote into a workspace no later turn of the session opened. Lease under the opened session's id instead. Found on the KVM rig while running rossoctl#369's P4 turns. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
(Self-review — GitHub won't let the author approve.) Clean, well-scoped fix. executeTurn now leases under opened.sessionManager.getSessionId() instead of input.sessionId (undefined for a new session), which fixes both the microVM invalid-workspace-key failure and the turn-1 workspace orphaning. The new regression test fails on main and pins the correct key; the updated lease-holder test still guards the original concerns (no shared anon workspace, no empty key). Verified getSessionId() on the real SessionManager, confirmed executeTurn is the sole non-test caller of acquireTurnSandbox, and ran the three relevant test files locally — all pass. LGTM.
Commits: 1 commit, signed-off ✓
CI: all checks green
| // The OPENED session's id, not input.sessionId: a /turn that omitted it has just been given one by | ||
| // openTurnSession, and leasing under `undefined` keyed the workspace by the per-turn lease holder | ||
| // (`anon:<uuid>`) -- a key the microVM tier refuses, and one no later turn of the session reuses. | ||
| const acquired = await acquireTurnSandbox( |
There was a problem hiding this comment.
nit: with this change, acquireTurnSandbox's sessionId ?? holderId fallback and its "anonymous turn" comment are effectively dead code — its only production caller now always passes a real session id. Worth tightening the parameter to string (and updating that comment) in a follow-up so the anon: fallback can't silently return via a future call site.
Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
fix(harness): key a new session's first turn by its session id
executeTurnopens the session before it leases a sandbox, so that a missing session 404s before any pool work (pinned byturn-session-before-lease.test.ts). But it leased withinput.sessionId, which isundefinedwhen/turnomits it.acquireTurnSandboxthen keyed the workspace by the per-turn lease holder,anon:<uuid>.Two failures followed:
invalid-workspace-key: workspace_key "anon:…" must match [A-Za-z0-9][A-Za-z0-9._-]{0,127}.Authenticated turns are not affected: the token names an existing session, so
sessionIdis set.The fix leases under
opened.sessionManager.getSessionId(), the same id the response returns. Every/turnentry point goes throughexecuteTurn: sync unauthenticated, sync authenticated, and SSE.Tests
harness/test/turn-new-session-workspace-key.test.ts. It fails onmain, receivinganon:<uuid>.harness/test/turn-lease-holder.test.ts. It pinned theanon:fallback on the premise that such a turn has no continuity to preserve, but every such turn creates a session the client then continues. The concerns the old case guarded still hold: the key is neither a sharedanonworkspace nor empty.make typecheckandmake lintclean.Notes
acquireTurnSandboxkeeps itssessionId ?? holderIdfallback and its "anonymous turn" comment.executeTurn, its only non-test caller, no longer reaches that path. Happy to tighten the parameter tostringin this PR if preferred.Refs #369 (needed by its P4 tier).
🤖 Generated with Claude Code