Expand description
Per-session workspace-mode state: which repo a roaming/detached Claude Code
session is currently bound to. Persisted outside any repo so it survives a
session that changes directories. Set by tracevault repo switch
(sub-plan B); read by stream/commands as a resolution fallback.
Structs§
- Inferred
Repo - One
SessionState::inferred_reposentry: the repo a checkout resolved to withinproject_id, or none. ANonerepo is remembered only untilretry_after(RFC3339), so a checkout registered or added to the project later is picked up without asking on every event. A found repo has no expiry: it is a fact about the server that changes only by a re-register. - Project
Binding - A resolved binding to a registered project.
- Repo
Binding - A resolved binding to a registered repo.
- Session
State - Session-level active binding plus per-worktree subagent overrides (keyed by the subagent’s git worktree toplevel path — design §7).
Enums§
- Force
Status - What a
ProjectBinding::forced_untilcurrently says about its force.
Constants§
- WORKTREES_
FILE - Inside an anchored session dir: every worktree toplevel the session ran
an event in, one per line. The
originmarker names only the latest, andcheck/verify-startin a checkout must still find a session that worked there and then moved on — as they did when the session kept a second dir in that checkout.
Functions§
- anchored_
session_ dirs anchored_session_dirs_inthe user’s state dir.- anchored_
session_ dirs_ in - The dirs of sessions anchored OUTSIDE
local_sessions_dir(seeSessionState::storage_root) that ran an event inworktree_top, read from the per-session state files instate_dir. A session started in an umbrella dir keeps its dir there, so the checkout it worked in has to look it up this way. Sorted; unreadable entries are skipped. - env_
session_ id - The session of the agent that runs this command, from its environment:
$TRACEVAULT_SESSION_ID(exported by the Claude Code / Codex SessionStart hook), else$AMP_CURRENT_THREAD_ID. - force_
status - Classify a stored
forced_until— seeForceStatus. - load
- Load a session’s state, returning the default (empty) state if the file is absent or malformed (workspace state is best-effort, never fatal).
- load_
from - Load a session’s state from an explicit sessions dir (test seam / callers that resolve the dir themselves). Absent or malformed → default state.
- ran_in
- Whether the session in
session_dirran an event inworktree_top: itsoriginmarker names it, or itsWORKTREES_FILElists it. - record_
storage_ root - Record
rootas the session’sSessionState::storage_rootunless one is already recorded:SessionStartfires again on resume,/clearand compaction, from wherever the shell has moved, and the session dir must not move with it. Returns whether it wrote. - record_
worktree - Add
worktree_toptosession_dir’sWORKTREES_FILEunless listed. - save
- Persist a session’s state, creating the state dir if needed.
- session_
dir <root>/.visdom/sessions/<session_id>forsession_id(or the.tracevault/one an earlier release started it in), whererootis the session’s recordedstorage_root, elsefallback_root(the root resolved from the caller’s working directory). Every reader and writer of a session dir goes through this, so a session is found where its hook keeps it.- session_
id_ from_ env env_session_idon given values:tracevaultwins, thenamp_thread.- sessions_
dir $XDG_STATE_HOME/visdom/sessionsor~/.local/state/visdom/sessions. A session recorded under the legacytracevault/sessionsbeside it is still read from there (seeload_from).- storage_
root - The session’s recorded
SessionState::storage_root, if that directory still exists. Its.visdom/may not exist yet: a git root is recorded whether or not it has one, and the stream hook creates it on first use, exactly as it would for an event whosecwdresolved there. - update_
in - Load, change and save a session’s state while holding an exclusive lock
on
<session_id>.lockbeside it, so the session’s parallel hooks — each recording what it looked up — do not overwrite each other’s changes. The lock is advisory: writers that do not take it (the interactiveswitchcommands) are as before. The OS releases it when the holder exits.