Skip to content

Commit 295a48b

Browse files
authored
fix: worktree tasks inherit configured permission defaults (#131547)
Remove the worktree-only Workspace fallback while preserving explicit permission selections and recorded session roots. Existing stored modes and approval-file floors remain unchanged. Fixes #131536.
1 parent 13125bf commit 295a48b

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎docs/gateway/permission-modes.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Managed worktree sessions use the worktree checkout as `sessionRoot`. A nested w
2626

2727
File tools recognize aliases of the session's trusted root and working directory, including absolute paths using those aliases. This does not expand the boundary: unrelated external symlinks pointing inward remain denied, as do symlinks and raw `symlink/..` traversal that escape the root. `read-only` sessions still omit mutation tools.
2828

29-
A new managed worktree session defaults to `workspace` when no mode is specified. Other sessions with no recorded mode keep the existing config-driven behavior.
29+
New sessions, including managed worktree sessions, inherit the configured global or per-agent tool/exec policy when no mode is specified. Creating a worktree pins the working directory without selecting a permission mode. Explicit modes and modes already saved on existing sessions remain unchanged.
3030

3131
## Policy precedence and clamping
3232

‎docs/start/why-openclaw.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ Since the comparison snapshot, Hermes has added [optional persistent local Pytho
253253
Each enterprise configuration item links to its reference:
254254

255255
- Sandbox on: `agents.defaults.sandbox.mode: "all"` with the [`openshell`](/gateway/openshell) or [`docker`](/gateway/sandboxing) backend; `workspaceAccess: "ro"` unless the agent owns the workspace.
256-
- Select [`guarded` or `workspace`](/gateway/permission-modes) per session; `full` requires `operator.admin`. Managed worktree sessions default to `workspace`; other sessions without a mode use configured tool/exec policy.
256+
- Select [`guarded` or `workspace`](/gateway/permission-modes) per session; `full` requires `operator.admin`. Sessions without a mode, including managed worktree sessions, use configured tool/exec policy.
257257
- Front the gateway with [Tailscale](/gateway/tailscale) or an [identity-aware proxy](/gateway/trusted-proxy-auth); define [`gateway.roles`](/gateway/operator-scopes) with a deny-all default; leave DM policy on [pairing](/channels/pairing).
258258
- Everything behind [SecretRefs](/gateway/secrets); run `openclaw secrets audit --check` against your config in CI.
259259
- Enable [message auditing](/gateway/audit); export [OpenTelemetry](/gateway/opentelemetry) to your SIEM with operator-owned retention and monitoring for dropped data.

‎src/gateway/server-methods/sessions-create.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ export const sessionCreateHandlers: GatewayRequestHandlers = {
549549
: undefined,
550550
spawnedCwd: p.worktree === true ? undefined : sessionCwd,
551551
sessionRoot: p.worktree === true ? undefined : sessionRoot,
552-
permissionMode: p.permissionMode ?? (p.worktree === true ? "workspace" : undefined),
552+
permissionMode: p.permissionMode,
553553
...(p.toolOverrides !== undefined ? { toolOverrides: p.toolOverrides } : {}),
554554
prepareLifecycle,
555555
onLifecycleCleanupError: (error) => {

‎src/gateway/server.sessions.create.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,8 @@ test("sessions.create provisions and reuses a session worktree for later runs",
17531753
const worktree = created.payload?.worktree;
17541754
expect(worktree?.branch).toBe("openclaw/release-planning");
17551755
expect(created.payload?.entry.spawnedCwd).toBe(worktree?.path);
1756-
expect(created.payload?.entry.permissionMode).toBe("workspace");
1756+
expect(created.payload?.entry.permissionMode).toBeUndefined();
1757+
expect(loadSessionEntry({ sessionKey: key, storePath })?.permissionMode).toBeUndefined();
17571758
expect(created.payload?.entry.sessionRoot).toBe(worktree?.path);
17581759
worktreeId = worktree?.id;
17591760
expect(findLiveRegistryWorktreeByOwner(process.env, "session", key)).toMatchObject({
@@ -2387,6 +2388,7 @@ test("sessions.create maps worktree options and preserves a nested workspace cwd
23872388
worktree: true,
23882389
worktreeName: "target-task",
23892390
worktreeBaseRef: "base-branch",
2391+
permissionMode: "workspace",
23902392
},
23912393
{ client: { connect: { scopes: ["operator.admin"] } } as never },
23922394
);
@@ -3013,6 +3015,7 @@ test("sessions.create reset-in-place detaches the prior worktree permission boun
30133015
parentSessionKey: "main",
30143016
emitCommandHooks: true,
30153017
worktree: true,
3018+
permissionMode: "workspace",
30163019
},
30173020
{ client: { connect: { scopes: ["operator.admin"] } } as never },
30183021
);

0 commit comments

Comments
 (0)