Skip to content

feat(ui): label the configured default in the session permissions picker - #132989

Merged
steipete merged 2 commits into
mainfrom
steipete/exec-policy-phase2-default-label
Aug 30, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/exec-policy-phase2-default-label

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The chat composer's permission picker shows a bare "Default" row whose description ("Follow the agent's configured policy.") never says what that policy actually is. An operator reading it cannot tell whether Default means guarded, workspace, or unrestricted — for a permissions control, that is a bad place to be vague. The row itself is load-bearing and must stay: it means inherit, so the session tracks later config changes, unlike pinning a mode. It should simply name its own resolution, the way the model picker already does with Default ({model}).

Why This Change Was Made

The gateway now projects an optional, read-only defaultPermissionMode per agent, computed from the same configured exec posture that governs unmoded sessions:

  • Computed in listAgentsForGateway (src/gateway/session-utils-store.ts) alongside the existing agentDefaultModel fact — config-metadata preparation, not per-row hot projection and not request-time discovery. It layers global tools.exec then agent tools.exec exactly as resolveExecDefaults does, then maps through the canonical SESSION_PERMISSION_BY_EXEC_MODE table.
  • Omitted when the posture has no honest label: the allowlist mode (which has no session-mode twin) and any security/ask pair that is not the canonical form for its mode — including ask: "always", which no permission mode can express. The UI then renders the plain "Default" it renders today.
  • It is a display label, never authorization. Nothing branches on it, and session behavior for unmoded sessions is unchanged.

The picker gains an optional defaultMode prop and renders Default ({mode}) via a new defaultWithMode i18n key, following the model picker's established pattern.

User Impact

The permission picker and its composer trigger now read "Default (Guarded)" when the agent's configured posture maps cleanly, and stay "Default" when it does not. No behavior change: no new config option, no SQLite change, no session ever has a mode materialized into it, and the sessionRoot disclosure gate is untouched.

Evidence

  • Live gateway proof (the half a mock cannot cover): an isolated gateway on its own port and state dir, configured with only tools.exec.mode: "ask", sends agents: [{ id: "main", defaultPermissionMode: "guarded" }] over the real WebSocket to the real Control UI — captured from live frames.
  • UI proof: mocked-dev-server Playwright captures of the open popover and trigger showing Default (Guarded) for an ask-mode config and the bare Default fallback for an allowlist config, in both the chat and new-session flows. Each capture was opened and visually confirmed, not merely produced.
  • Label computation is unit-tested across config shapes: global mode, agent override, security/ask pair forms, and both omission cases.
  • pnpm check:changed green (with the repo-pinned toolchain); protocol parity and Swift codegen green; pnpm build green; scoped protocol/gateway/UI suites pass.
  • Additive protocol field only; no client is required to consume it.

Follows #132740 (landed as a151c1e), which retired the legacy per-session exec policy fields.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 30, 2026 01:42
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 29, 2026, 11:13 PM ET / August 30, 2026, 03:13 UTC.

ClawSweeper review

What this changes

The PR projects a display-only configured permission mode from Gateway agent metadata and renders it in the Control UI chat and new-session permission pickers.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The prior P1 remains: role-derived sandbox requirements are not represented in the new agent-wide label, so a sandbox-required session can still display “Default (Full access)”.

Priority: P1
Reviewed head: 54b11a211dcaefa9d633f2caa763a2fd51c63530

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is focused and the approval-floor repair is sound, but a P1 role-derived sandbox path still makes the security label inaccurate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated Gateway and Control UI captures do not cover the role-stamped sandbox case that remains incorrect.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated Gateway and Control UI captures do not cover the role-stamped sandbox case that remains incorrect.
Evidence reviewed 7 items Introduced label omits session context: The new projection only checks the agent’s configured sandbox mode before emitting a label; it has no selected-session or creator-role input.
Role policy stamps required sandbox: A human creator assigned a role with sandbox required receives a persistent session sandbox requirement even when the agent configuration is otherwise unsandboxed.
Existing integration coverage proves the missing case exists: The session-creation test creates a role with sandbox required and verifies that the newly created session persists sandbox required.
Findings 1 actionable finding [P1] Account for role-derived required sandboxes
Security Needs attention Role sandbox restriction is omitted from the permission label: An operator role can stamp a session as sandbox-required, while the introduced agent-wide label can still show “Default (Full access)”; this weakens the accuracy of a security-sensitive control.

How this fits together

The Gateway supplies agent metadata to Control UI clients, which use it to describe inherited session settings. Session creation and execution resolution can independently impose a sandbox requirement for an operator role.

flowchart LR
  A[Agent exec configuration] --> B[Gateway agent listing]
  C[Operator role] --> D[Sandbox-required session]
  B --> E[Default permission label]
  D --> F[Execution policy resolution]
  E --> G[Control UI picker]
  G --> H[Operator sees inherited default]
  F --> I[Sandbox deny base]
Loading

Before merge

  • Account for role-derived required sandboxes (P1) - The new label only checks resolveSandboxConfigForAgent, but a human creator with gateway.roles.*.sandbox: "required" creates a session that persistently requires a sandbox. With no explicit permission mode, the chat picker still renders the agent label while resolveExecDefaults selects the sandbox deny base. Derive this label from the actual session context or omit it for this case, and cover role-created sessions; this is the prior P1 blocker still present on the current head.
  • Resolve security concern: Role sandbox restriction is omitted from the permission label - An operator role can stamp a session as sandbox-required, while the introduced agent-wide label can still show “Default (Full access)”; this weakens the accuracy of a security-sensitive control.
  • Resolve merge risk (P1) - Merging can make a sandbox-required session created under an operator role appear to inherit full access, despite execution resolving from the sandbox deny base.

Findings

  • [P1] Account for role-derived required sandboxes — src/gateway/session-utils-store.ts:369-372
  • [medium] Role sandbox restriction is omitted from the permission label — src/gateway/session-utils-store.ts:369
Agent review details

Security

Needs attention: The display-only change does not grant access, but it can falsely communicate a more permissive execution boundary to an operator.

PR surface

Source +47, Tests +208, Docs +2, Other +4. Total +261 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 58 11 +47
Tests 3 208 0 +208
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 1 +4
Total 13 273 12 +261

Review metrics

Metric Value Why it matters
Production versus test delta production +47, generated Swift +4, tests +208, docs +2 The cross-layer UI and protocol addition needs a role-derived sandbox regression at the same owner boundary as its policy claim.

Merge-risk options

Maintainer options:

  1. Make the inherited label truthful for role-created sessions (recommended)
    Carry the effective session sandbox context to the display boundary or omit the label for sessions whose role can require a sandbox, then add the role-based regression path.
  2. Pause the display feature
    Defer the agent-wide label until the Gateway can represent its session-specific policy without overstating access.

Technical review

Best possible solution:

Make the displayed inherited label session-aware, or suppress it whenever a role-created or otherwise sandbox-required session could use it, with an end-to-end role-create-to-picker regression test.

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

Yes, from source: create a session as a role whose sandbox is required while the agent sandbox is off, leave permissionMode unset, and the picker receives the agent-wide label while execution resolves the session as sandboxed.

Is this the best way to solve the issue?

No. The current agent-level projection cannot truthfully describe a session-specific role sandbox; the label needs session-aware policy context or conservative omission.

Full review comments:

  • [P1] Account for role-derived required sandboxes — src/gateway/session-utils-store.ts:369-372
    The new label only checks resolveSandboxConfigForAgent, but a human creator with gateway.roles.*.sandbox: "required" creates a session that persistently requires a sandbox. With no explicit permission mode, the chat picker still renders the agent label while resolveExecDefaults selects the sandbox deny base. Derive this label from the actual session context or omit it for this case, and cover role-created sessions; this is the prior P1 blocker still present on the current head.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The new permissions-control label can overstate the effective execution posture for real role-created sessions.
  • merge-risk: 🚨 security-boundary: The introduced display metadata omits a persistent sandbox restriction that changes the actual execution boundary.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its stated Gateway and Control UI captures do not cover the role-stamped sandbox case that remains incorrect.

Evidence

Security concerns:

  • [medium] Role sandbox restriction is omitted from the permission label — src/gateway/session-utils-store.ts:369
    An operator role can stamp a session as sandbox-required, while the introduced agent-wide label can still show “Default (Full access)”; this weakens the accuracy of a security-sensitive control.
    Confidence: 0.99

What I checked:

  • Introduced label omits session context: The new projection only checks the agent’s configured sandbox mode before emitting a label; it has no selected-session or creator-role input. (src/gateway/session-utils-store.ts:369, 54b11a211dca)
  • Role policy stamps required sandbox: A human creator assigned a role with sandbox required receives a persistent session sandbox requirement even when the agent configuration is otherwise unsandboxed. (src/gateway/operator-role-policy.ts:98, 54b11a211dca)
  • Existing integration coverage proves the missing case exists: The session-creation test creates a role with sandbox required and verifies that the newly created session persists sandbox required. (src/gateway/server.sessions.create.test.ts:315, 54b11a211dca)
  • Execution owner resolves sandbox-required sessions more strictly: Exec default resolution treats a session sandbox requirement as authoritative and selects the sandbox target, whose default security is deny. (src/agents/exec-defaults.ts:137, 54b11a211dca)
  • Control UI renders the agent-wide label for the selected session: The chat control receives the selected agent label while using only selectedSession.permissionMode to decide whether the session is inheriting, so a sandbox-required session with no explicit mode shows the inaccurate default label. (ui/src/pages/chat/chat-pane-session-controls.ts:167, 54b11a211dca)
  • Current added tests do not cover role-created sessions: The new table covers agent-configured sandbox modes and approval floors, but does not create a role-stamped sandbox-required session before asserting the agent label. (src/gateway/session-utils.test.ts:3790, 54b11a211dca)

Likely related people:

  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Add an end-to-end role-sandbox regression from session creation through Gateway metadata and the selected-session picker.
  • Ensure the displayed inherited label is absent or matches the effective sandboxed policy for that session.

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 (2 earlier review cycles)
  • reviewed 2026-08-30T01:48:04.550Z sha aaa5754c55b77bd06fa3975c9be3d2a829a80b83 :: found issues before merge. :: [P2] Derive the label from the effective default policy
  • reviewed 2026-08-30T02:58:00.395Z sha 1c92c6dac0e8e2594e0ac8f6f95b49c2eff7bb4e :: found issues before merge. :: [P1] Account for role-derived required sandboxes

@steipete

Copy link
Copy Markdown
Contributor Author

Confirmed and fixed in 1c92c6dac0e — good catch, and the cause was an instruction in my own work order telling the implementation to avoid approvals/sandbox reads for hot-path cost. That was wrong, and it is withdrawn.

The defect. configuredPermissionLabel hand-rolled the posture (start at full/off, layer global + agent tools.exec) while resolveExecDefaults additionally applies approval-file floors (minSecurity/maxAsk) and host/sandbox resolution. Under an approvals floor a configured auto could resolve to deny while the picker displayed "Default (Workspace)" — the label overstating permissiveness, which is the one direction a permissions control must never be wrong in.

The fix. The projection now calls the canonical resolveExecDefaults({ cfg, agentId, execApprovals }) instead of re-deriving the layering, so the label is by construction the mode an unmoded session actually resolves to. loadExecApprovals() is hoisted to one read per listAgentsForGateway call rather than one per agent. Because resolveExecDefaults without a sessionKey assumes sandboxAvailable: false, and session-scoped sandbox availability is not knowable at agent scope, the label is omitted entirely whenever resolveSandboxConfigForAgent(cfg, agentId).mode !== "off" — both non-main and all can produce a stricter real policy. The invariant is stated in a comment at the site: this label may never overstate permissiveness; when the effective policy is unknowable, show nothing.

Pre-fix evidence for the new regression case, verbatim:

AssertionError: expected { id: 'main', … } to not have property "defaultPermissionMode"
- Expected: undefined
+ Received: "workspace"

Ten regression cases now assert the emitted label always equals what resolveExecDefaults resolves, or is absent. Deleting the duplicated layering made this net −10 production lines (+20/−30).

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 30, 2026
Expose the configured exec posture as optional agent display metadata and
show it in the chat and New Session permission pickers. Preserve plain
Default for allowlist and non-equivalent security/ask pairs.

Keep session modes unset when inheriting config; the label does not affect
authorization, execution, filesystem boundaries, or session persistence.

Validate protocol parity, 850 scoped tests, both builds, and inspected
mocked picker screenshots. The changed gate reaches a stale oxlint 1.78
failure in unchanged plugin code; pinned oxlint 1.79 passes scoped proof.
Resolve agent defaults through canonical exec policy with one approvals snapshot per listing. Omit labels when sandbox scope or noncanonical policy pairs make them inaccurate, and preserve the existing optional picker projection.

Refs: #132989
@steipete
steipete force-pushed the steipete/exec-policy-phase2-default-label branch from 1c92c6d to 54b11a2 Compare August 30, 2026 03:07
@steipete
steipete merged commit c9b3fa5 into main Aug 30, 2026
249 checks passed
@steipete
steipete deleted the steipete/exec-policy-phase2-default-label branch August 30, 2026 03:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…ker (openclaw#132989)

* feat(ui): label configured default session permissions

Expose the configured exec posture as optional agent display metadata and
show it in the chat and New Session permission pickers. Preserve plain
Default for allowlist and non-equivalent security/ask pairs.

Keep session modes unset when inheriting config; the label does not affect
authorization, execution, filesystem boundaries, or session persistence.

Validate protocol parity, 850 scoped tests, both builds, and inspected
mocked picker screenshots. The changed gate reaches a stale oxlint 1.78
failure in unchanged plugin code; pinned oxlint 1.79 passes scoped proof.

* fix(gateway): keep default permission labels truthful

Resolve agent defaults through canonical exec policy with one approvals snapshot per listing. Omit labels when sandbox scope or noncanonical policy pairs make them inaccurate, and preserve the existing optional picker projection.

Refs: openclaw#132989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant