fix(provisioner): preserve Claude session directory across restart (#12) - #57
Merged
Merged
Conversation
- docs/edit-history/2026-04-14.md: append tick-3 section covering the admin test-token route (#53), the prior-tick doc-sync PR (#54), and the hermes required_env alignment (#55). Record measured test counts (Go +4 for the TestAdminTestToken_* quartet). - CLAUDE.md: bump Go test count 695 → 699 with a note pointing at the new quartet. Route-table row and env-var mentions for the admin route already landed with #53; verified on main. - .env.example: add MOLECULE_ENABLE_TEST_TOKENS with a comment about the prod-hidden default. Closes the code-review doc-sync flag from #53 (var was in CLAUDE.md but missing from .env.example). No PLAN.md / README.md / README.zh-CN.md update needed — none of the three merges expose a user-visible surface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolves #12. The claude-code SDK stores conversations in /root/.claude/sessions/ and Postgres tracks current_session_id, but the container filesystem was recreated on every restart — next agent message failed with "No conversation found with session ID: <uuid>". Add a per-workspace named Docker volume (ws-<id>-claude-sessions) mounted read-write at /root/.claude/sessions. Gated by runtime=claude-code so other runtimes don't pay for a path they don't use. Volume is cleaned up in RemoveVolume alongside the config volume. Two opt-outs discard the volume before restart for a fresh session: - env WORKSPACE_RESET_SESSION=1 on the container - POST /workspaces/:id/restart?reset=true (or {"reset": true} body) Plumbed via new ResetClaudeSession field on WorkspaceConfig + provisionWorkspaceOpts helper so the flag stays request-scoped (not persisted on CreateWorkspacePayload). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HongmingWang-Rabbit
marked this pull request as ready for review
April 14, 2026 17:50
This was referenced Apr 21, 2026
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 21, 2026
…sessions fix(provisioner): preserve Claude session directory across restart (#12)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #12.
Problem
On workspace restart, Postgres keeps
current_session_idpopulated but the container filesystem (/root/.claude/sessions/) is recreated fresh. Next message → "No conversation found with session ID: " and the SDK dies (seen repeatedly on PM and Dev Lead after auth-token-rotation restarts).Fix
ws-<id>-claude-sessionsmounted at/root/.claude/sessionsruntime=claude-code(other runtimes don't use this path)RemoveVolumewhen workspace is deleted (delete cascade)WORKSPACE_RESET_SESSION=1env in the container → volume discarded before recreatePOST /workspaces/:id/restart?reset=true(or{"reset": true}body) → same, request-scopedPlumbed via a new
ResetClaudeSessionfield onWorkspaceConfigand aprovisionWorkspaceOptshandler helper so the flag stays request-scoped (not persisted onCreateWorkspacePayload).Test plan
go test -race ./...pass (platform-wide, all packages green)go build ./...andgo vet ./...clean?reset=trueagainst a running claude-code workspace once deployed🤖 Generated with Claude Code