Skip to content

fix: keep isolated gateway workspaces and skills inside state dir - #114487

Merged
steipete merged 7 commits into
mainfrom
steipete/statedir-isolation-r5t7
Jul 28, 2026
Merged

steipete merged 7 commits into
mainfrom
steipete/statedir-isolation-r5t7

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes two isolation leaks for gateways using a non-default OPENCLAW_STATE_DIR.

The first live repro used openclaw onboard --non-interactive with a scratch state directory. Onboarding still persisted the operator-home workspace in both agents.defaults.workspace and the initial agents.entries.main.workspace; the per-agent value then won during agent resolution, so writes such as Skill Workshop apply targets escaped into the real home workspace.

The second live repro started a scratch gateway and observed 91 home-scoped personal Claude-compatible skills in the isolated agent. A non-default state directory should not inherit personal skill roots from the operator's home.

Why This Change Was Made

Non-interactive onboarding now derives its implicit workspace as <state-dir>/workspace only when the effective state directory is non-default. Explicit --workspace, existing config, and nonblank OPENCLAW_WORKSPACE_DIR keep their existing precedence, and the default-state output remains unchanged.

The normal skill loader, embedded session resource manager, and skill watcher now include the home-scoped personal-agent root only for the default state directory. Workspace, project, bundled, configured extra, plugin, and state-owned managed skill roots remain available. No config keys, channel/agent routing behavior, or Skill Workshop service/store code changed.

User Impact

Scratch, test, profile, and multi-instance gateways can onboard and load skills without reading from or writing into the operator's default OpenClaw workspace and personal skill roots. Standard installs using the default state directory retain their existing workspace and personal-skill behavior.

Evidence

  • node scripts/run-vitest.mjs src/config/paths.test.ts src/commands/onboard-non-interactive/local/workspace.test.ts src/commands/onboard-non-interactive.gateway.test.ts src/skills/loading/agents-directory.test.ts src/skills/runtime/refresh.test.ts src/agents/sessions/package-manager.test.ts
    • 4 Vitest shards passed
    • 6 test files passed
    • 93 tests passed
  • node scripts/check-changed.mjs -- <14 changed files>
  • Autoreview: clean, no accepted/actionable findings after compatibility fixes for explicit/blank workspace env overrides and filesystem-aware state-directory identity.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 09:42
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 8:09 AM ET / 12:09 UTC.

ClawSweeper review

What this changes

The PR makes non-default OpenClaw state directories use a state-owned implicit workspace and prevents core and Codex-native skill discovery from inheriting the operator-home personal skill directories.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 7 items remain

Keep this PR open for protected maintainer review: the proposed isolation boundary is coherent and focused, but the current branch still lacks directly inspectable after-fix gateway evidence and needs a fresh compatibility review after rebasing onto current main. Likely related people: steipete is the assigned author of the proposed implementation; current-main ownership provenance could not be established confidently from the available read-only inspection.

Priority: P2
Reviewed head: 1065e349f5240262215e942ce5930d9e0eee7f41
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation and focused coverage are substantial, but missing inspectable real behavior proof remains a merge gate and the Codex dependency contract still needs direct verification.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body reports focused tests and a changed-check run, but it does not provide directly inspectable after-fix live gateway output showing that a scratch state directory writes a state-owned workspace and excludes home-scoped skills. Add a redacted terminal transcript, recording, or runtime log; redact private paths, IP addresses, keys, and non-public endpoints, then update the PR body for an automatic fresh review or ask a maintainer to comment @clawsweeper re-review if needed.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused tests and a changed-check run, but it does not provide directly inspectable after-fix live gateway output showing that a scratch state directory writes a state-owned workspace and excludes home-scoped skills. Add a redacted terminal transcript, recording, or runtime log; redact private paths, IP addresses, keys, and non-public endpoints, then update the PR body for an automatic fresh review or ask a maintainer to comment @clawsweeper re-review if needed.
Evidence reviewed 5 items Onboarding boundary: The proposed workspace resolver preserves explicit workspace input and existing configuration, then selects &lt;state-dir>/workspace only when the state directory is non-default.
Core skill isolation: The proposed core loader and watcher gate home-scoped .agents/skills discovery on the default-state predicate, while retaining workspace, managed, bundled, configured-extra, and plugin paths.
Codex session integration: The branch adds a native-skill-isolation fingerprint to Codex thread binding state and applies the isolation result through the thread lifecycle, so an existing binding can be reconsidered when the selected roots differ.
Findings None None.
Security None None.

How this fits together

Non-interactive onboarding writes an initial agent workspace into configuration, then the core and Codex app-server skill loaders assemble skills for that agent. This change uses the selected state directory to decide whether home-scoped personal skills remain eligible, affecting isolated gateway sessions and their persisted thread bindings.

flowchart LR
  A[Gateway onboarding] --> B[State directory choice]
  B --> C[Initial agent workspace]
  B --> D[Skill root policy]
  D --> E[Core skill loader]
  D --> F[Codex app-server]
  C --> G[Agent session]
  E --> G
  F --> G
Loading

Decision needed

Question Recommendation
After a rebase, should maintainers accept state-directory isolation as the intended compatibility contract for personal skills and Codex-native skills, once direct runtime proof and the Codex app-server contract are attached? Request proof and contract verification: Require a redacted after-fix gateway transcript and a direct verification of the Codex app-server runtime contract before landing.

Why: The change deliberately alters discovery for existing non-default state-directory deployments and crosses the Codex app-server boundary; tests support the direction, but the persistent compatibility contract needs a maintainer-confirmed final review.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused tests and a changed-check run, but it does not provide directly inspectable after-fix live gateway output showing that a scratch state directory writes a state-owned workspace and excludes home-scoped skills. Add a redacted terminal transcript, recording, or runtime log; redact private paths, IP addresses, keys, and non-public endpoints, then update the PR body for an automatic fresh review or ask a maintainer to comment @clawsweeper re-review if needed.
  • Resolve merge risk (P1) - The branch changes existing workspace and personal-skill discovery semantics for non-default OPENCLAW_STATE_DIR users; the intended default-state and explicit-workspace compatibility paths need fresh proof on the rebased head.
  • Resolve merge risk (P1) - The PR only reports tests and CI/check output. It does not contain a directly inspectable redacted terminal transcript, recording, or runtime log showing a scratch gateway both writes the state-owned workspace and excludes operator-home skills.
  • Resolve merge risk (P1) - The branch is behind current main, so the compatibility review and proof must be refreshed against the actual merge result before landing.
  • Resolve merge risk (P1) - The Codex-specific path relies on app-server runtime behavior; this review could not complete the repository-required direct sibling ../codex source inspection, so that contract needs maintainer confirmation before a merge verdict.
  • Complete next step (P2) - This protected maintainer-labeled PR needs contributor-supplied live proof, a rebase refresh, and a maintainer-confirmed Codex dependency-contract check rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +408, Tests +497, Docs +6. Total +911 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 11 560 152 +408
Tests 9 501 4 +497
Docs 2 15 9 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 1076 165 +911

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/codex/src/app-server/native-skill-isolation.test.ts, serialized state: extensions/codex/src/app-server/session-binding.ts, serialized state: src/agents/sessions/package-manager.test.ts, serialized state: src/agents/sessions/package-manager.ts, unknown-data-model-change: src/agents/sessions/package-manager.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase and prove the two user paths (recommended)
    Rebase the branch, then attach redacted live evidence for default-state compatibility and non-default-state isolation before merge.
  2. Accept the isolation contract explicitly
    Maintainers may accept the compatibility change if they intentionally want all non-default state roots to exclude operator-home personal skills.
  3. Pause the Codex-native portion
    Pause or split the PR if the exact Codex app-server configuration contract cannot be verified without a safer supported mechanism.

Technical review

Best possible solution:

Rebase onto current main, retain the explicit-workspace and default-state compatibility behavior, and add a redacted real gateway transcript that shows the written agent workspace plus the resulting absence of home-scoped personal skills; then confirm the Codex app-server isolation call against the exact sibling-Codex runtime contract.

Do we have a high-confidence way to reproduce the issue?

No high-confidence independently reproduced path is available in this review: the source and added tests describe the state-directory leak, but there is no inspectable current-head live gateway transcript showing the before/after result.

Is this the best way to solve the issue?

Unclear: state-root isolation is the right owner boundary if the current Codex app-server contract supports it, but a rebased live proof and direct dependency-contract check are needed before calling this the best durable fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bb634261cb9f.

Labels

Label justifications:

  • P2: The PR fixes an isolation defect for scratch, profile, and multi-instance gateways without evidence of an emergency outage or data loss.
  • merge-risk: 🚨 compatibility: It changes default workspace selection and whether existing non-default state-directory installations discover operator-home personal skills.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and a changed-check run, but it does not provide directly inspectable after-fix live gateway output showing that a scratch state directory writes a state-owned workspace and excludes home-scoped skills. Add a redacted terminal transcript, recording, or runtime log; redact private paths, IP addresses, keys, and non-public endpoints, then update the PR body for an automatic fresh review or ask a maintainer to comment @clawsweeper re-review if needed.

Evidence

What I checked:

  • Onboarding boundary: The proposed workspace resolver preserves explicit workspace input and existing configuration, then selects <state-dir>/workspace only when the state directory is non-default. (src/commands/onboard-non-interactive/local/workspace.ts:15, 1065e349f524)
  • Core skill isolation: The proposed core loader and watcher gate home-scoped .agents/skills discovery on the default-state predicate, while retaining workspace, managed, bundled, configured-extra, and plugin paths. (src/skills/loading/workspace.ts:1228, 1065e349f524)
  • Codex session integration: The branch adds a native-skill-isolation fingerprint to Codex thread binding state and applies the isolation result through the thread lifecycle, so an existing binding can be reconsidered when the selected roots differ. (extensions/codex/src/app-server/thread-lifecycle-preflight.ts:1, 1065e349f524)
  • Focused regression coverage: The branch adds coverage for non-default-state onboarding, core skill loading and watching, package-manager discovery, workspace snapshots, and Codex-native isolation; the PR body reports 93 focused tests and a changed-check run, but these are supplemental rather than live behavior proof. (extensions/codex/src/app-server/native-skill-isolation.test.ts:1, 1065e349f524)
  • Current-base refresh needed: GitHub reports the branch as mergeable but behind main; the supplied current-main SHA is bb63426 while the PR base SHA is 89b6d85, so the final review should use a rebased head. (bb634261cb9f)

Likely related people:

  • steipete: Authored all seven commits in this branch and is assigned to the PR; no independent current-main feature-history owner could be established from the available read-only inspection. (role: proposed implementation author and assigned PR owner; confidence: low; commits: 998d6e4f4b42, 1b496034c349, 1065e349f524; files: src/commands/onboard-non-interactive/local/workspace.ts, src/skills/loading/workspace.ts, extensions/codex/src/app-server/native-skill-isolation.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and rerun the focused isolation coverage on the resulting head.
  • Add a redacted live terminal transcript showing the non-default-state onboarding workspace and the excluded personal skill roots.
  • Confirm the Codex app-server isolation mechanism against the exact sibling-Codex source/runtime contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-27T09:47:51.804Z sha f334ab8 :: needs real behavior proof before merge. :: none

@steipete steipete self-assigned this Jul 28, 2026
@steipete
steipete force-pushed the steipete/statedir-isolation-r5t7 branch from f334ab8 to 1065e34 Compare July 28, 2026 12:04
@steipete
steipete force-pushed the steipete/statedir-isolation-r5t7 branch from 1065e34 to cbdcafd Compare July 28, 2026 16:57
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer landing disposition for exact head cbdcafdc088ccab6db37561915f8aebe023f80f9:

  • Rank-up move “rebase onto current main and rerun focused isolation coverage”: applied. The seven-commit branch rebased without conflicts, and the nine focused files passed 153 tests across five Vitest shards. Exact-head CI run 30380660193 is green.
  • Rank-up move “add a redacted live terminal transcript showing the non-default-state workspace and excluded personal skills”: skipped as additional proof for this landing. The PR records the original live repro, and the rebased regressions cover default-state compatibility, explicit/blank workspace precedence, non-default state-owned workspaces, core personal-skill exclusion, watcher roots, and Codex-native isolation. The maintainer accepts the absence of a new inspectable after-fix transcript.
  • Rank-up move “confirm the Codex app-server mechanism against exact sibling Codex source/runtime”: applied against fresh openai/codex origin/main at fa1d4c40d0e63eef2e0ba8a9e004ccd0a80b77f5. codex-rs/app-server-protocol/src/protocol/v2/thread.rs:57 exposes per-thread config; codex-rs/app-server/src/request_processors/thread_processor.rs:980 passes that map into load_with_overrides; codex-rs/core-skills/src/config_rules.rs:16 accepts session-flag skills.config rules and canonicalizes path selectors; codex-rs/app-server/src/request_processors/catalog_processor.rs:18 returns path, scope, and enabled state; and codex-rs/core-skills/src/loader.rs:321 classifies both $CODEX_HOME/skills and $HOME/.agents/skills as user scope while preserving repo/system/admin roots.

The fresh exact-head ClawSweeper run 30380776255 remained in its setup-state action beyond the comment lease and has not produced a new Rank-up list. Its latest exact-head comment is still a start placeholder; no lease recovery or duplicate review was attempted. The completed review’s three moves are dispositioned above.

@steipete
steipete merged commit 0f91859 into main Jul 28, 2026
119 checks passed
@steipete
steipete deleted the steipete/statedir-isolation-r5t7 branch July 28, 2026 17:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…224005-host

* origin/main: (72 commits)
  fix: macOS-only Parallels smoke harness regression (#75293)
  fix(ios): use configured speech language for system voice (#113372)
  refactor: centralize isolated agent test ownership (#115340)
  test(ui): stabilize browser route readiness (#115320)
  fix(cron): clear automation after failed scheduler shutdown (#115316)
  fix: keep isolated gateway workspaces and skills inside state dir (#114487)
  docs: document local TTS on macOS, Linux, and Windows (#110230)
  fix(tasks): clone only the requested task page (#114277)
  fix(agents): prevent Code Mode resume loss and unbounded preparation (#115314)
  fix(process): preserve the first process cancellation reason (#115317)
  fix(nostr): report unavailable ingress when queue open fails (#115313)
  fix: prevent Slack and Feishu ingress startup leaks (#115295)
  fix(slack): avoid unsafe emphasis boundaries (#111575)
  fix: prevent changed checks from expanding into full lint (#115322)
  fix(codex): stabilize prompts and expose real cache regressions (#115238)
  refactor(ui): derive page route specs from the route table (#115214)
  fix(compaction): plan cut points in trigger units (#111886) (#115309)
  fix: prevent cron and gateway stress-run timeouts (#115241)
  fix(ci): validate frozen Matrix QA targets (#115298)
  test(macos): block real process fallthrough (#113337)
  ...

# Conflicts:
#	CHANGELOG.md
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…enclaw#114487)

* fix: isolate non-default state workspaces and skills

* fix(codex): isolate native personal skills

* chore: refresh plugin SDK API manifest

* fix: keep SDK manifest generation scoped

* refactor(codex): keep isolation plugin-local

* test: satisfy optional skill snapshot typing

* refactor(codex): extract thread lifecycle preflight
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…afea23-host

* origin/main: (72 commits)
  fix: macOS-only Parallels smoke harness regression (openclaw#75293)
  fix(ios): use configured speech language for system voice (openclaw#113372)
  refactor: centralize isolated agent test ownership (openclaw#115340)
  test(ui): stabilize browser route readiness (openclaw#115320)
  fix(cron): clear automation after failed scheduler shutdown (openclaw#115316)
  fix: keep isolated gateway workspaces and skills inside state dir (openclaw#114487)
  docs: document local TTS on macOS, Linux, and Windows (openclaw#110230)
  fix(tasks): clone only the requested task page (openclaw#114277)
  fix(agents): prevent Code Mode resume loss and unbounded preparation (openclaw#115314)
  fix(process): preserve the first process cancellation reason (openclaw#115317)
  fix(nostr): report unavailable ingress when queue open fails (openclaw#115313)
  fix: prevent Slack and Feishu ingress startup leaks (openclaw#115295)
  fix(slack): avoid unsafe emphasis boundaries (openclaw#111575)
  fix: prevent changed checks from expanding into full lint (openclaw#115322)
  fix(codex): stabilize prompts and expose real cache regressions (openclaw#115238)
  refactor(ui): derive page route specs from the route table (openclaw#115214)
  fix(compaction): plan cut points in trigger units (openclaw#111886) (openclaw#115309)
  fix: prevent cron and gateway stress-run timeouts (openclaw#115241)
  fix(ci): validate frozen Matrix QA targets (openclaw#115298)
  test(macos): block real process fallthrough (openclaw#113337)
  ...

# Conflicts:
#	CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant