Skip to content

Saving a session fails when the state root is a junction on Windows #7098

Closed

Description

@SparkofSpike

Saving a session fails outright on Windows when the Codewhale state root is
relocated to another volume — the supported way to keep ~/.codewhale off the
system drive. Nothing is written, no conversation is kept, and the only signal
is a red "cannot save session" notice.

Environment

  • Codewhale 0.10.2 (release binary, codewhale 0.10.2 (ff466b2ed0bf))

  • Windows 11, %USERPROFILE%\.codewhale is a directory junction:

    mklink /J C:\Users\<user>\.codewhale D:\CodeWhaleData
    
  • Same behaviour with any volume the state root is relocated to.

Steps to reproduce

  1. Relocate the state root with a directory junction as above.
  2. Run any session that persists: codewhale exec --auto "Run: echo hello", or
    an interactive session's autosave / /save.
  3. Observe the red "cannot save session" notice, and the log.

Expected

The session document is written under the junction target
(sessions/<id>.json), as it is on a non-relocated install.

Actual

No session document is written. logs/tui-*.log records one line per attempt:

WARN persistence: persistence write failed what=session:<id>
  error_kind=InvalidInput
  error=Fleet artifact path must stay within the workspace

The failure is not in the write itself. SessionManager::save_session_inner
hydrates approval receipts before it serializes the document, and
ApprovalReceiptStore::log_file opens
<sessions>/<id>/approval_receipts.jsonl through the strictly confined
WorkspaceFile::open. On Windows that opener walks the path component by
component and refuses any reparse point — including the junction that is the
state root — so the save dies before reaching the write_atomic call that would
have written the document.

open_resolved_root exists for exactly this case (added in #6947; #6949 made
the same distinction for sub-agent state): it resolves the root once, then runs
the same link-refusing walk below it. The session-side state opens were never
converted to it.

Evidence

With the reported layout, the built binary from the fixing branch:

  • codewhale exec --auto "Run the shell command: echo CWJUNCTION_OK" → exit 0,
    wrote sessions/cf02b940-8436-4289-b16b-756d7a516228.json (58,986 bytes)
    through the junction.
  • The same layout on the 0.10.2 release binary produced the warning above and no
    document.

Same class of failure as #6947 (session artifacts) and #6949 (sub-agent state):
a user-owned relocated root treated as if it were an untrusted workspace root.

Attribution

🤖 Generated by SpikeBot 000(CodeWhale-LOCAL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions