convergeSessions never mints a claude_session_id, so pre-migration-0012 rows can never become resumable #179

Closed
opened 2026-09-18 07:49:27 +02:00 by lz · 0 comments
Owner

Found while auditing the MCP specs, verified by reading nexus/src/lib/server/sessions/service.ts.

The asymmetry

Migration 0012 added claude_session_id TEXT NOT NULL DEFAULT '', so every session row that predates it carries the empty string. Three code paths relaunch a session, and they handle that state three different ways:

path behaviour
openWorkspaceSession (:403) existing?.claude_session_id || randomUUID() — mints
setSessionAgent restart (:948) mints and writes it back with an updateTable
convergeSessions (:1341) passes resume: Boolean(row.claude_session_id) — mints nothing, writes nothing

And resumeFlag (:119) returns the empty string when the id is empty:

function resumeFlag(claudeSessionId: string, resume: boolean): string {
  if (!claudeSessionId) return '';
  return ` ${resume ? '--resume' : '--session-id'} ${shellQuote(claudeSessionId)}`;
}

So convergence relaunches such a session with no --session-id and no --resume at all: a fresh, unpinned conversation each time, and the row stays '' — so it can never become resumable. The restart path would fix the row, but only if the operator happens to use it.

Severity

Low blast radius, permanent effect. It reaches only rows created before 0012 ran, but for those the conversation is lost on every restore, silently, forever.

Fix

Make convergeSessions mint-and-persist like the restart path does, then launch with --session-id. The comment at :400 already explains the intent — "a freshly-minted id has no conversation yet, so only --resume when there's a real pinned id" — and convergence is the one path that implements the first half without the second.

Test: a session row with claude_session_id = '' that goes through convergence must come out with a persisted uuid, and the launch must carry --session-id rather than nothing. Prove it fails first — a test written against the current code that asserts the row is unchanged would pass and prove nothing.

Worth doing before the fleet status layer (#177), which changes what drives convergence.

Found while auditing the MCP specs, verified by reading `nexus/src/lib/server/sessions/service.ts`. ## The asymmetry Migration 0012 added `claude_session_id TEXT NOT NULL DEFAULT ''`, so every session row that predates it carries the empty string. Three code paths relaunch a session, and they handle that state three different ways: | path | behaviour | |---|---| | `openWorkspaceSession` (`:403`) | `existing?.claude_session_id \|\| randomUUID()` — mints | | `setSessionAgent` restart (`:948`) | mints **and writes it back** with an `updateTable` | | `convergeSessions` (`:1341`) | passes `resume: Boolean(row.claude_session_id)` — mints nothing, writes nothing | And `resumeFlag` (`:119`) returns the **empty string** when the id is empty: ```ts function resumeFlag(claudeSessionId: string, resume: boolean): string { if (!claudeSessionId) return ''; return ` ${resume ? '--resume' : '--session-id'} ${shellQuote(claudeSessionId)}`; } ``` So convergence relaunches such a session with no `--session-id` and no `--resume` at all: a fresh, unpinned conversation each time, and the row stays `''` — so it can never become resumable. The restart path would fix the row, but only if the operator happens to use it. ## Severity Low blast radius, permanent effect. It reaches only rows created before 0012 ran, but for those the conversation is lost on every restore, silently, forever. ## Fix Make `convergeSessions` mint-and-persist like the restart path does, then launch with `--session-id`. The comment at `:400` already explains the intent — *"a freshly-minted id has no conversation yet, so only `--resume` when there's a real pinned id"* — and convergence is the one path that implements the first half without the second. **Test:** a session row with `claude_session_id = ''` that goes through convergence must come out with a persisted uuid, and the launch must carry `--session-id` rather than nothing. Prove it fails first — a test written against the current code that asserts the row is unchanged would pass and prove nothing. ## Related Worth doing before the fleet status layer (#177), which changes what drives convergence.
lz added this to the MCP support (#140) milestone 2026-09-21 16:38:30 +02:00
lz closed this issue 2026-09-21 19:10:29 +02:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lz/agent-nexus#179
No description provided.