Skip to content

feat(permissions)!: refine Ask-mode policy and command approvals - #4013

Merged
wsp1911 merged 3 commits into
openBitFun:mainfrom
wsp1911:recover/pr-4008
Nov 20, 2026
Merged

wsp1911 merged 3 commits into
openBitFun:mainfrom
wsp1911:recover/pr-4008

Conversation

@wsp1911

@wsp1911 wsp1911 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Replaces #4008 after rebasing its three commits onto main.

Summary

  • Refine Ask-mode defaults and assign domain actions and resource scopes to built-in tools. Allow routine workspace edits and low-risk operations while retaining approval for deletion, sensitive paths, external directories, publishing, and commands that do not qualify as read-only.
  • Add shell-aware command permission analysis, conservative read-only classification, directory-flow tracking, native PowerShell AST parsing, and bounded workspace glob expansion. Bind saved command approvals to the command, shell, working directory, and TTY.
  • Give approval models the current tool description, input schema, complete arguments, and up to five prior tool inputs. Structure requests with Markdown sections, trim the oldest history below a conservative 30k-token budget, and require decision-only responses for chat approvals.

Related issues: None linked.

Type and Areas

Type: Feature, breaking permission-policy change, and UI/UX.

Areas: Product permission contracts, Agent Runtime, core tool execution and approval pipeline, shell analysis, AI adapters, Web UI permission settings and prompts, locales, and generated capability documentation.

Motivation / Impact

Ask mode currently interrupts ordinary development operations and gives approval models limited context. This change reduces routine confirmations, evaluates shell commands in their execution context, and supplies richer inputs for model-assisted approval. Explicit rules, file permissions, and independent execution constraints remain authoritative.

Permission settings and command approval labels are updated in English, Simplified Chinese, and Traditional Chinese where applicable. Command-analysis reasons are hidden from confirmation prompts.

Verification

Checks on the rebased branch:

  • git diff --check HEAD~3 HEAD passed.
  • The permission contract suite passed all 33 tests. The core permission defaults suite passed all 4 tests with agent-runtime,tools-miniapp enabled.
  • ChatInputApprovalBand.test.tsx passed all 19 tests.
  • pnpm run capabilities:check verified 24 features and 23 settings, covering 701 Tauri commands and 4,411 UI interaction candidates across 476 files. pnpm run i18n:audit passed with zero warnings.

The rebase preserves the upstream removal of the GenerativeUI tool. Its permission action and test references were dropped, and the capability catalogs were regenerated.

The three commit messages also record focused Rust permission/parser/pipeline tests, native PowerShell parsing, frontend tests, pnpm run check:web, pnpm run i18n:audit, capability checks, repository hygiene, and core boundary checks. Those prior results are reported from commit metadata; the full Rust and repository suites were not rerun during PR preparation after the rebase.

CLI CI follow-up from #4008 (before the rebase):

  • Reproduced the failure on Ubuntu CI and locally on Windows: the mock treated the new Markdown approval prompt as a normal product-control model round.
  • Updated approval-request recognition and the mock response to the current DECISION=ALLOW protocol. Temporary diagnostic assertions were removed after confirming the root cause; the original persisted-config assertion remains.
  • cargo test --locked -p openbitfun-cli --test cli_command_contracts exec_cli_contracts::cli_agent_controls_its_own_isolated_config_through_openbitfun_control -- --exact --nocapture - passed locally after failing before the fix.
  • cargo test --locked -p openbitfun-cli --test cli_command_contracts - passed locally on Windows: 45 passed, 1 existing graphical-environment test ignored.
  • pnpm run fmt:rs and git diff --check - passed.
  • The original CLI product-control contract also passes after removing the temporary diagnostic assertions.
    Remote coverage: The command-approval commit reports mock-based remote coverage. Live Remote Workspace (SSH/container), Remote Control (relay/bots), Peer Device Mode, and Detached Dispatch scenarios have not been exercised for this PR.

Reviewer Notes

  • Breaking change: Migrated built-in tools now use domain permission actions. Existing custom_tool rules and grants for those tools are not migrated and may need to be recreated with the new actions. Legacy bash rules and exact command grants remain readable.
  • Approval-model requests now include complete tool arguments and recent tool inputs. Tool execution results and assistant text are excluded; oversized current requests are rejected rather than silently truncated.
  • Review shell parsing and read-only classification conservatism, context-bound saved approvals, and the interaction with existing file and execution constraints.
  • Includes three permission commits. The approval-context commit also aligns the CLI approval fixture with the current request and response protocol.
  • AI-assisted PR preparation. Testing level: focused automated checks; no full end-to-end or live remote validation. No UI screenshots were captured during PR preparation.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Allow ordinary workspace edits and routine tool operations without
confirmation while retaining approval for deletion, sensitive paths,
external directories, publishing, and command execution.

Define domain actions and concrete resource scopes for built-in tools.
Separate Agent process control from user terminal control, update the
rules editor and permission copy, and refresh generated documentation.

Validation: 76 focused Rust tests, 9 frontend tests, check:web,
i18n:audit, and capability catalog checks.

BREAKING CHANGE: Migrated built-in tools use domain permission actions.
Existing custom_tool rules and grants for those tools are not migrated.
Analyze commands using the selected shell and evaluate argument patterns
per command, preserving file permissions and independent constraints.

Add conservative read-only classification, directory flow tracking,
native PowerShell AST parsing and bounded workspace glob expansion.
Bind saved approvals to the command, shell, working directory and TTY.

Update permission settings and command approval labels, and hide command
analysis reasons from confirmation prompts. Keep legacy bash rules and
exact grants readable.

Validation: focused Rust permission, parser and pipeline tests; native
PowerShell parsing; frontend tests and check:web; i18n and capability
checks; repository hygiene and core boundaries. Remote behavior was
covered with mocks, without live SSH, relay, peer or dispatch testing.
Give approval models the current tool description, input schema,
complete arguments, and up to five prior tool inputs.

Organize review requests with Markdown sections and one trust rule.
Trim the oldest history to stay below a conservative 30k-token budget,
and use decision-only output for chat approvals.

Align CLI approval mocks with the Markdown review request and the
decision-only response protocol.

Validation:
- 13 AI adapter permission tests.
- 3 focused core approval and history tests.
- CLI command contracts: 45 passed, 1 ignored.
- Original CLI product-control test passes after diagnostic cleanup.
@wsp1911
wsp1911 merged commit b87264d into openBitFun:main Nov 20, 2026
13 checks passed
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