Skip to content

Keep each Session's native state under its own directory - #925

Merged
SaladDay merged 4 commits into
mainfrom
feat/per-session-native-state
Nov 5, 2026
Merged

SaladDay merged 4 commits into
mainfrom
feat/per-session-native-state

Conversation

@SaladDay

@SaladDay SaladDay commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

This is D2b protocol PR 1, the Runtime–Harness boundary. One Environment will soon serve several Sessions in sequence. To prepare for that, each Session's native Harness state now lives only under directories derived from its state key, agent.StateDir(StateRoot|RuntimeRoot, kind, key). While there is one Session per Runtime, nothing else changes. An installation must be reinstalled, not upgraded.

Paths

Harness Native path New location
Codex CODEX_HOME <StateRoot>/runtime/codex/state/<key>
Codex SQLite home <RuntimeRoot>/runtime/codex/state/<key>
Claude Code, with a workspace CLAUDE_CONFIG_DIR <StateRoot>/runtime/claude_sdk/state/<key>/config
Claude Code, with a workspace HOME, TMPDIR home and scratch under <RuntimeRoot>/runtime/claude_sdk/state/<key>
Claude Code, environment: none CLAUDE_CONFIG_DIR, HOME, TMPDIR, working directory config, home, tmp and work under <StateRoot>/runtime/claude_sdk/state/<key>. HOME used to be the daemon's shared home, where the native CLI writes its MCP logs.
MiniMax Code native state already compliant

Deleted

  • Codex's private allocSessionDir and its path sanitizer.
  • Claude Code's per-Runtime directory fields and WorkspaceConfig.
  • The single-use helpers workspaceDirs and workspaceEnvironment.
  • DiscoveryOptions.Profile, which no adapter reads after this change.
  • The stale daemon/agent-sessions and profile-level runtime entries in the unlabelled-state check.
  • Test cases that never ran.

The Claude readiness check now runs with a temporary HOME, TMPDIR and CLAUDE_CONFIG_DIR, which it discards afterwards.

Docs

  • The rule is in contracts/agents-api/harness-onboarding.md (Register the adapter), with its zh mirror.
  • The Codex and Claude guides state only the new paths and link to the rule.

Verification

  • A blind review found one Medium (Claude's environment: none HOME) and six Low issues. All are fixed.
  • go test passes on agent/... and cli. A new two-key test asserts disjoint directories and that the native environment points into them, including environment: none.
  • go vet, check-runtime-contract, check-harness-catalog and check-translations pass.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@SaladDay
SaladDay merged commit a4f74df into main Nov 5, 2026
21 checks passed
@SaladDay
SaladDay deleted the feat/per-session-native-state branch November 5, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant