Skip to content

feat: replace per-tool approvals with sandbox boundaries #1564

Closed

Description

@Astro-Han

Status

Accepted and ready for implementation. There are no open design questions in this issue.

This issue is delivered as one end-to-end PR. The earlier two-PR split is superseded because it would merge a temporary dual permission/boundary state, require mode synchronization and duplicate prompts, then immediately delete that work. The implementation may use several reviewable green commits, but only the final architecture lands on main.

The issue body is the authoritative behavioral contract. Discussion comments do not reopen settled decisions unless this body is explicitly updated.

Goal

Make the enforceable session execution boundary authoritative:

  • ordinary local work inside an Auto workspace runs without generic per-tool approval;
  • crossing the active sandbox profile is the only operation that can request additional local authority;
  • approval expands the current session boundary instead of granting one tool call;
  • an operation that cannot remain sandboxed returns requires_bypass;
  • Bypass is entered only through an explicit user action;
  • exposed Browser, Computer Use, Office, MCP, connector, and orchestration tools run through their own brokers and hard guards without generic runtime approval;
  • the replaced permission matrix, grants, modes, prompts, and CLI flags are deleted in the same PR.

Agreed design

One session execution boundary

Each session owns one authoritative boundary:

type ExecutionBoundary =
  | {
      kind: "managed";
      profile: SandboxProfile;
      revision: number;
    }
  | {
      kind: "bypass";
      revision: number;
    }
  | {
      kind: "external";
      revision: number;
    };
  • A normal Auto session uses a managed workspace-write profile.
  • Bypass means Maka provides no sandbox enforcement.
  • Deep Research uses an internal managed read-only profile and a restricted tool surface; it is not a third user-selectable mode.
  • Headless runners such as Harbor may use an explicit external isolation boundary.
  • Desktop and TUI derive Auto or Bypass from this boundary instead of storing a second permission-mode authority.

Auto base profile

  • Read and write all selected workspace roots.
  • Allow ordinary edits, deletion, shell commands, and local Git operations.
  • Do not specially deny writes to .git, .agents, or .codex inside a selected workspace.
  • Allow the runtime temporary directories required by sandboxed execution.
  • Start with process network egress restricted. The first required network expansion asks once and applies to the rest of the session.
  • WebSearch and other brokered web tools remain separate product-tool exposure decisions; they are not controlled by SandboxProfile.network.
  • Fail closed when Maka cannot enforce the advertised managed profile. An explicitly supplied external sandbox is valid; otherwise only the user may choose Bypass.
  • PTY execution that cannot be sandboxed is unavailable in Auto and returns requires_bypass.

Authoritative persistence and revision

Boundary state and boundary requests live in one settle-once log table in sessions.sqlite.

  • Do not copy the current boundary into SessionHeader.
  • Do not store new boundary requests in the legacy file-backed InteractionStore.
  • Every session starts with a revision 0 genesis row containing the full boundary snapshot.
  • An expansion request is inserted immutably with its normalized expansion, justification, and base revision.
  • A denial settles only the request outcome and does not change the boundary revision.
  • An approval runs in one SQLite BEGIN IMMEDIATE transaction: lock the pending request, load the current applied boundary, revalidate the immutable expansion, settle the canonical outcome, assign the next revision when the boundary changes, and persist the full resulting snapshot.
  • User-initiated Auto/Bypass changes are recorded in the same log with a new revision and full snapshot.
  • Switching back to Auto restores the session's previously accumulated managed profile.
  • The current boundary is the full snapshot with the highest applied revision, not a header copy or in-memory cache.
  • The same request ID settles once and retries idempotently.

Concurrent approvals serialize through the same transaction. A stale request may still be approved when its immutable expansion remains valid against the current managed boundary; disjoint expansions merge without losing state. An expansion already present settles as an approved no-op without inventing a revision. A changed boundary kind or explicit-deny conflict settles as a conflict and never overwrites current state.

One boundary-expansion contract

The only expandable local authority is SandboxBoundaryExpansion:

type SandboxBoundaryExpansion = {
  filesystem?: {
    entries: Array<{
      path: string;
      access: "read" | "write";
      scope: "exact" | "subtree";
    }>;
  };
  network?: {
    enabled: true;
  };
};
  • Filesystem paths are normalized absolute paths.
  • An expansion contains no deny rules, full profile, tool category, raw arguments, cwd, risk score, hash, TTL, or one-call grant.
  • An expansion can only add authority and cannot remove or weaken explicit denies from the base profile.
  • The normalized expansion shown to the user must exactly equal the expansion applied on approval.

Agent-requested expansion

Ordinary local tool schemas stay unchanged.

  1. A local filesystem or process tool that cannot run inside the current managed boundary returns structured sandbox_boundary_required information with the smallest enforceable suggested expansion.
  2. The Agent decides whether that authority is necessary.
  3. The Agent calls the dedicated built-in request_sandbox_boundary tool with the expansion and an Agent-authored justification.
  4. Runtime normalizes and validates the request before it becomes visible.
  5. On approval, the boundary transaction applies the expansion.
  6. The Agent retries the original tool call under the new boundary.

There is no proposal ID, ephemeral registry, TTL, or automatic retry of the original tool call. Bash must declare required path or network capability; command-string parsing is not an authorization mechanism. Sandbox diagnostics may suggest a narrow enforceable expansion but cannot grant authority, automatically open a prompt, or invent a broader request.

request_sandbox_boundary is available only to interactive local sessions. Browser, Computer Use, Office, MCP, connectors, and other broker-owned tools cannot use it.

requires_bypass

There is no one-call unsandboxed grant.

  • An operation that cannot be expressed and enforced as a managed profile expansion returns structured requires_bypass to the current tool invocation.
  • The failure remains in the same turn so the Agent can try a boundary-safe alternative.
  • requires_bypass does not create an interaction, prompt, transcript card, or automatic mode switch.
  • Only an existing user-facing Permissions control can enter Bypass.
  • Entering Bypass always requires one explicit confirmation because it disables Maka sandbox enforcement.

Tool ownership

Tool family Enforcement owner
Bash and background shell Current session sandbox profile
Read, Write, Edit, Glob, Grep, and other local filesystem tools Sandboxed filesystem worker and current session profile
PTY Current session profile when enforceable; otherwise unavailable in Auto
Browser, Computer Use, Office, and Rive Tool exposure plus native broker and hard guards
MCP and remote connectors Tool exposure plus server or connector scopes
Child agents and orchestration tools Inherit the parent boundary or declare an explicit external boundary
Headless and Harbor tools Explicit external isolation supplied by the harness

The macOS Permission Center remains. Accessibility, screen recording, microphone, notifications, and Apple Events are operating-system prerequisites, not generic tool approvals.

Product surfaces

Desktop boundary prompt

SandboxBoundaryPrompt replaces the additional-permission and sandbox-escalation branches and renders in the stable composer interaction slot. It is not a modal and not an ordinary transcript tool card.

It shows only:

  • a concise heading;
  • the Agent-authored justification;
  • each exact requested scope, humanizing read/write and exact/subtree;
  • Reject and Allow for this session.

It does not show revision, current profile, tool category, risk labels, raw arguments, technical state, remember controls, Stop, or duplicate lifetime copy.

The visual baseline follows the existing Maka composer system: chat-measure width, compact neutral surface, existing typography/tokens/buttons, no internal divider lines between scope entries, and no large warning wash. After settlement the interactive card leaves the composer slot and the result remains ordinary transcript history.

Desktop Permissions control

The user-facing Permissions selector contains only Auto and Bypass.

Selecting Bypass opens the existing AlertDialog pattern:

  • title: Switch to Bypass?;
  • state clearly that the current session will run without Maka sandbox enforcement;
  • explain that host filesystem and network access become available and that Bypass is intended only for trusted, externally isolated environments;
  • default focus and Escape keep Auto;
  • actions are Keep Auto and Enter Bypass.

The dialog uses a small warning icon and a destructive confirmation button, not a large red surface.

TUI boundary prompt

The boundary request remains an unboxed transcript block:

  • one attention heading;
  • Agent-authored justification;
  • one line per exact expansion entry;
  • y or Enter allows for the session;
  • n or Escape denies;
  • there is no a action and no detail disclosure for tool arguments.

The editor waits while the decision is pending. Narrow terminals wrap labels and values without losing the exact scope.

TUI Permissions control

Keep /permissions as the product entry point, but expose only auto | bypass.

  • /permissions opens the existing bottom picker with Auto and Bypass.
  • /permissions auto|bypass remains available as a typed command.
  • Selecting Bypass opens a second bottom picker.
  • Keep Auto is selected by default.
  • Arrow keys move, Enter selects, and Escape keeps Auto or closes the picker.
  • There is no blind mode-cycling shortcut and no single key that immediately disables the sandbox.
  • The status line shows auto or bypass.

Non-interactive and external execution

  • maka run defaults to Auto.
  • maka run never exposes request_sandbox_boundary, never prompts, and never expands authority.
  • A boundary-required tool call returns structured failure; the Agent may choose a boundary-safe approach, otherwise the run exits nonzero.
  • Resuming a session restores its persisted boundary but still cannot expand it non-interactively.
  • --yolo is the only explicit startup option for Bypass. There is no -y alias.
  • Remove --permission-mode, --allow, and --deny.
  • Headless and Harbor use an explicitly supplied external boundary and never silently fall back to Auto or Bypass.

Migration and deletion

On first read, legacy sessions receive a genesis boundary:

  • ask and execute become managed Auto workspace-write;
  • explore becomes the internal managed read-only boundary required by its owning product flow and is no longer user-selectable;
  • bypass becomes Bypass.

At startup, pending legacy tool_permission, additional_permissions, and sandbox_escalation interactions settle with the existing host_restarted outcome and leave the pending queue. Settled historical events remain readable but never route new execution through a compatibility executor.

Delete the superseded production paths in the same PR:

  • PermissionEngine;
  • PermissionMode × ToolCategory;
  • Bash risk classification used for authorization;
  • remembered tool scopes and auto reviewers;
  • invocation/turn grants, TTL, consumption, intent hashes, and command hashes;
  • generic permission responses and permissionRequired;
  • authorization uses of categoryHint;
  • additional-permission and sandbox-escalation protocols/executors;
  • the legacy Desktop PermissionPrompt, summaries, risk tones, diffs, remember checkbox, styles, copy, stories, and tests;
  • the generic TUI permission card, remember-for-turn state, and a key;
  • Ask/Execute/Explore user-facing controls and old CLI flags.

Preserve protocol-specific hard guards, tool availability, audit history, the OS Permission Center, and native capability onboarding.

Delivery plan

One flat PR from the latest main, implemented with TDD and organized as reviewable green commits:

  1. Add core contracts and the single authoritative SQLite boundary log, including migration, atomic settlement, and concurrency behavior.
  2. Make runtime and sandbox execution read the current boundary for every invocation; add request_sandbox_boundary, structured boundary failures, requires_bypass, and legacy-pending closure.
  3. Wire the Desktop/shared UI and TUI boundary prompts plus Auto/Bypass controls.
  4. Finish maka run and external-boundary behavior, then delete the complete generic permission system and legacy modes.
  5. Run focused tests, formatting/lint/typecheck, the full workspace test suite, and one representative Desktop fake-backend E2E journey.

Acceptance

Core and storage

  • Expansion validation permits only normalized additive filesystem/network authority.
  • Explicit denies cannot be weakened.
  • Genesis migration is deterministic for every legacy mode.
  • Approval outcome and boundary update are atomic across process failure.
  • Concurrent stale approvals cannot lose state or over-grant.
  • Duplicate settlement is idempotent.
  • No-op and conflict outcomes preserve revision semantics.
  • Resume restores the effective session boundary.
  • Legacy pending permission interactions close fail-safe after upgrade.

Runtime and sandbox

  • Auto runs ordinary workspace reads, writes, edits, deletion, Bash, and local Git without generic approval.
  • .git, .agents, and .codex inside the workspace are writable under the sandbox.
  • Filesystem, foreground/background shell, PTY where supported, and process network execution use the current session profile on every invocation.
  • Outside-workspace access cannot execute before an approved exact session expansion.
  • Process network access cannot execute before an approved session expansion.
  • The approved expansion equals the displayed expansion.
  • A rejected expansion changes no authority.
  • An operation requiring unsandboxed execution cannot run until the user switches the session to Bypass.
  • Browser, Computer Use, Office, MCP, connector, and orchestration tools cannot request local boundary expansion.
  • Child agents inherit the parent boundary.
  • Managed execution fails closed when enforcement is unavailable.

Product and CLI

  • Desktop and TUI match the approved prompt, keys, Auto/Bypass controls, and Bypass confirmation.
  • Non-interactive Auto cannot register or invoke the request tool and fails closed on unavoidable boundary requirements.
  • Only --yolo starts non-interactive Bypass.
  • External harness execution remains explicit.
  • Deep Research remains internally read-only.
  • No live production reference remains to the old permission matrix, grants, modes, prompts, or escalation executors.

Implementation constraints

  • Do not split the work by package; code for one behavioral invariant ships together.
  • Do not merge a temporary dual permission/boundary state.
  • Do not keep old permission execution as a fallback after migration.
  • Do not introduce a universal capability language for Browser, Computer Use, Office, MCP, or connectors.
  • Do not parse shell commands to infer authority.
  • Do not treat user-mentioned paths as implicit authorization.
  • Do not automatically switch to Bypass.
  • Do not claim that Git, audit logs, or the local process sandbox contain native or remote tools.
  • Do not add another cleanup PR unless implementation reveals a concrete, independently fixable executor gap.

展开中文实施方案

当前状态

方案已确认,可以开始实施。这个 issue 没有尚未收口的设计问题。

这个 issue 由一个端到端 PR 完成。此前的两 PR 拆分已经作废,因为它会先把临时的 permission/boundary 双轨状态合入 main,为此增加模式同步和重复 Prompt,然后马上再删除这些过渡代码。实现过程可以拆成多个便于审查、始终保持绿色的 commit,但 main 只接收最终架构。

Issue 正文是行为契约的权威来源。讨论区评论不会重新打开已经确认的决定,除非正文被明确更新。

要做到什么

让会话中可执行的真实边界成为唯一权威:

  • Auto workspace 内的普通本地工作不再逐工具审批;
  • 只有越过当前 sandbox profile 时,才能请求增加本地权限;
  • 用户批准的是当前会话的边界扩张,不是某一次工具调用;
  • 无法留在 sandbox 内执行的操作返回 requires_bypass;
  • 只有用户明确操作才能进入 Bypass;
  • 已暴露的 Browser、Computer Use、Office、MCP、connector 和编排工具由各自的 broker 与硬限制负责,不再经过通用 runtime 审批;
  • 被替代的权限矩阵、grant、模式、Prompt 和 CLI 参数在同一个 PR 中删除。

已确认设计

每个会话只有一个执行边界

每个会话拥有一份权威边界:

type ExecutionBoundary =
  | {
      kind: "managed";
      profile: SandboxProfile;
      revision: number;
    }
  | {
      kind: "bypass";
      revision: number;
    }
  | {
      kind: "external";
      revision: number;
    };
  • 普通 Auto 会话使用 managed workspace-write profile。
  • Bypass 表示 Maka 不再提供 sandbox enforcement。
  • Deep Research 使用内部 managed read-only profile 和收窄的工具面,不是第三种用户可选模式。
  • Harbor 等 Headless runner 可以声明明确的 external isolation boundary。
  • Desktop 和 TUI 从这份 boundary 推导 Auto 或 Bypass,不再保存第二份 permission-mode 权威状态。

Auto 基础 profile

  • 所有选中 workspace root 都可读写。
  • 普通编辑、删除、Shell 命令和本地 Git 操作直接执行。
  • 不再特殊禁止写入 workspace 内的 .git、.agents 或 .codex。
  • 允许 sandbox 执行所需的 runtime 临时目录。
  • 进程出网默认受限。第一次确实需要网络 expansion 时询问一次,批准后对本会话持续有效。
  • WebSearch 等 broker web 工具仍由独立的产品工具暴露策略控制,不属于 SandboxProfile.network。
  • Maka 无法落实 advertised managed profile 时 fail closed。调用方明确提供 external sandbox 时可以使用;否则只有用户可以选择 Bypass。
  • PTY 无法 sandbox 时在 Auto 中不可用,并返回 requires_bypass。

权威持久化与 revision

Boundary 状态和 boundary 请求统一写入 sessions.sqlite 中一张 settle-once log 表。

  • 不把当前 boundary 复制到 SessionHeader。
  • 新 boundary 请求不写入旧的文件型 InteractionStore。
  • 每个会话从 revision 0 的 genesis 行开始,其中保存完整 boundary snapshot。
  • Expansion 请求先以 immutable 形式写入,包括规范化后的 expansion、理由和 base revision。
  • 拒绝只结算 request outcome,不改变 boundary revision。
  • 批准在一个 SQLite BEGIN IMMEDIATE 事务内完成:锁定 pending request、读取当前 applied boundary、针对当前状态重新验证 immutable expansion、结算 canonical outcome、在 boundary 实际变化时分配下一 revision,并写入完整 resulting snapshot。
  • 用户主动切换 Auto/Bypass 也写入同一张 log,产生新 revision 和完整 snapshot。
  • 切回 Auto 时恢复本会话此前累积的 managed profile。
  • 当前 boundary 取 applied revision 最高的完整 snapshot,不取 SessionHeader 副本或内存缓存。
  • 同一个 request ID 只结算一次,重试保持幂等。

并发批准通过同一事务串行化。Stale request 的 immutable expansion 如果对当前 managed boundary 仍然有效,可以继续批准;互不冲突的 expansion 依次合并,不丢状态。已经包含的 expansion 作为 approved no-op 结算,不虚构 revision。Boundary kind 已变化或与 explicit deny 冲突时结算为 conflict,绝不覆盖当前状态。

唯一 boundary expansion 契约

唯一可扩张的本地权限是 SandboxBoundaryExpansion:

type SandboxBoundaryExpansion = {
  filesystem?: {
    entries: Array<{
      path: string;
      access: "read" | "write";
      scope: "exact" | "subtree";
    }>;
  };
  network?: {
    enabled: true;
  };
};
  • 文件系统路径必须是规范化后的绝对路径。
  • Expansion 不包含 deny、完整 profile、工具类别、raw arguments、cwd、risk、hash、TTL 或单次 grant。
  • Expansion 只能增加权限,不能移除或弱化 base profile 的 explicit deny。
  • 用户看到的规范化 expansion 必须与批准后实际应用的 expansion 完全一致。

由 Agent 发起 expansion

普通本地工具的 schema 保持不变。

  1. 本地文件或进程工具无法在当前 managed boundary 内运行时,返回结构化 sandbox_boundary_required,并给出最小可 enforce 的建议 expansion。
  2. Agent 判断这份权限是否确实必要。
  3. Agent 调用专用内置工具 request_sandbox_boundary,传入 expansion 和 Agent 自己撰写的理由。
  4. Runtime 在请求展示给用户前重新规范化并验证。
  5. 用户批准后,boundary transaction 应用 expansion。
  6. Agent 在新 boundary 下重试原工具调用。

不存在 proposal ID、临时 registry、TTL,也不由 runtime 自动重试原工具调用。Bash 必须主动声明需要的路径或网络能力,不能解析 command string 来猜权限。Sandbox diagnostics 可以建议一份窄且可 enforce 的 expansion,但不能授予权限、自动弹出 Prompt 或发明更宽的请求。

request_sandbox_boundary 只提供给交互式本地会话。Browser、Computer Use、Office、MCP、connector 和其他由 broker 负责的工具不能调用它。

requires_bypass

不再有单次 unsandboxed grant。

  • 无法表达并落实为 managed profile expansion 的操作,对当前工具调用返回结构化 requires_bypass。
  • 失败留在同一轮中,Agent 可以尝试 boundary-safe 替代方案。
  • requires_bypass 不创建 interaction、Prompt、transcript card,也不自动切换模式。
  • 只有现有用户可见的 Permissions 控件可以进入 Bypass。
  • 每次进入 Bypass 都需要一次明确确认,因为它会关闭 Maka sandbox enforcement。

工具职责

工具类型 Enforcement owner
Bash 和后台 Shell 当前会话 sandbox profile
Read、Write、Edit、Glob、Grep 等本地文件工具 Sandboxed filesystem worker 和当前会话 profile
PTY 可 enforce 时使用当前会话 profile;否则 Auto 中不可用
Browser、Computer Use、Office、Rive 工具暴露状态、原生 broker 和硬限制
MCP 和远程 connector 工具暴露状态、server 或 connector scope
子 Agent 和编排工具 继承父会话 boundary,或声明明确的 external boundary
Headless 和 Harbor 工具 Harness 提供的明确 external isolation

macOS Permission Center 继续保留。辅助功能、屏幕录制、麦克风、通知和 Apple Events 是操作系统前置条件,不是通用工具审批。

产品界面

Desktop boundary Prompt

SandboxBoundaryPrompt 替代 additional-permission 和 sandbox-escalation 分支,渲染在稳定的 composer interaction slot 中。它不是 modal,也不是普通 transcript tool card。

只显示:

  • 简短标题;
  • Agent 撰写的理由;
  • 每一项精确申请范围,并用人话表达 read/write 与 exact/subtree;
  • 拒绝 和 本会话允许。

不显示 revision、当前 profile、工具类别、风险标签、raw arguments、技术状态、remember 控件、Stop 或重复的有效期说明。

视觉沿用 Maka 现有 composer 系统:chat-measure 宽度、紧凑中性 surface、既有 typography/token/button、scope entry 之间没有内部横线,也没有大面积 warning 色。结算后交互卡离开 composer slot,结果作为普通 transcript history 留存。

Desktop Permissions 控件

用户可见的 Permissions selector 只包含 Auto 和 Bypass。

选择 Bypass 后打开现有 AlertDialog:

  • 标题为 切换到 Bypass?;
  • 明确当前会话将不再受 Maka sandbox enforcement;
  • 说明 host filesystem 和 network 将可访问,Bypass 只适用于可信且已有外部隔离的环境;
  • 默认 focus 和 Escape 都保持 Auto;
  • 操作为 保持 Auto 和 进入 Bypass。

Dialog 使用一个小 warning icon 和 destructive 确认按钮,不使用大面积红色 surface。

TUI boundary Prompt

Boundary 请求使用无边框 transcript block:

  • 一行 attention heading;
  • Agent 撰写的理由;
  • 每项精确 expansion 单独一行;
  • y 或 Enter 为本会话允许;
  • n 或 Escape 拒绝;
  • 没有 a,也没有 tool arguments detail disclosure。

Decision pending 时 editor 等待。窄终端可以换行,但不能丢失精确 scope。

TUI Permissions 控件

保留 /permissions 作为产品入口,但只暴露 auto | bypass。

  • /permissions 打开现有 bottom picker,只有 Auto 和 Bypass。
  • /permissions auto|bypass 保留 typed command 入口。
  • 选择 Bypass 后打开第二层 bottom picker。
  • 默认选中 Keep Auto。
  • 方向键移动、Enter 选择、Escape 保持 Auto 或关闭 picker。
  • 不增加盲切模式快捷键,也没有任何单键可以立即关闭 sandbox。
  • Status line 显示 auto 或 bypass。

非交互与 external execution

  • maka run 默认 Auto。
  • maka run 不暴露 request_sandbox_boundary、不弹 Prompt、也不扩张权限。
  • 工具撞到 boundary 时返回结构化失败;Agent 可以选择 boundary-safe 方案,否则 run 非零退出。
  • Resume 会话恢复其持久化 boundary,但非交互运行仍然不能扩张。
  • --yolo 是唯一显式启动 Bypass 的参数,不提供 -y alias。
  • 删除 --permission-mode、--allow 和 --deny。
  • Headless 和 Harbor 使用调用方明确提供的 external boundary,绝不静默回落到 Auto 或 Bypass。

迁移与删除

首次读取旧会话时写入 genesis boundary:

  • ask 和 execute 迁移为 managed Auto workspace-write;
  • explore 迁移为其 owning product flow 所需的内部 managed read-only boundary,并从用户可选模式中删除;
  • bypass 迁移为 Bypass。

启动时,仍 pending 的旧 tool_permission、additional_permissions 和 sandbox_escalation interaction 使用现有 host_restarted outcome 结算,并离开 pending queue。Settled 历史事件保持可读,但新的执行绝不经过 compatibility executor。

同一个 PR 中删除所有被替代的生产路径:

  • PermissionEngine;
  • PermissionMode × ToolCategory;
  • 用于授权的 Bash risk classification;
  • remembered tool scope 和 auto reviewer;
  • invocation/turn grant、TTL、consume、intent hash 和 command hash;
  • generic permission response 和 permissionRequired;
  • categoryHint 的授权职责;
  • additional-permission 和 sandbox-escalation protocol/executor;
  • 旧 Desktop PermissionPrompt、summary、risk tone、diff、remember checkbox、style、copy、story 和 test;
  • generic TUI permission card、remember-for-turn state 和 a 键;
  • Ask/Execute/Explore 用户控件和旧 CLI flags。

保留协议自身的 hard guard、工具可用性、audit history、OS Permission Center 和原生 capability onboarding。

交付计划

从最新 main 创建一个 flat PR,使用 TDD,并按便于审查、始终绿色的完整意图组织 commit:

  1. 增加 core contract 和单一权威 SQLite boundary log,包括迁移、原子 settlement 和并发语义。
  2. 让 runtime 和 sandbox 每次执行都读取当前 boundary;增加 request_sandbox_boundary、结构化 boundary failure、requires_bypass 和 legacy pending 收尾。
  3. 接通 Desktop/shared UI、TUI boundary Prompt 和 Auto/Bypass 控件。
  4. 完成 maka run 与 external-boundary 行为,然后删除完整 generic permission 系统和旧模式。
  5. 运行聚焦测试、format/lint/typecheck、完整 workspace test suite,以及一条代表性的 Desktop fake-backend E2E journey。

验收标准

Core 与 storage

  • Expansion validation 只允许规范化、只增不减的 filesystem/network 权限。
  • Explicit deny 不能被弱化。
  • 每一种旧模式都能确定性迁移为 genesis。
  • Approval outcome 和 boundary update 在进程故障下仍保持原子性。
  • 并发 stale approval 不会丢状态或过度授权。
  • 重复 settlement 保持幂等。
  • No-op 和 conflict outcome 保持正确 revision 语义。
  • Resume 恢复有效会话 boundary。
  • 升级后 legacy pending permission interaction fail-safe 关闭。

Runtime 与 sandbox

  • Auto 下普通 workspace read/write/edit/delete、Bash 和本地 Git 不再通用审批。
  • Workspace 内 .git、.agents 和 .codex 在 sandbox 内可写。
  • Filesystem、前后台 Shell、受支持的 PTY 和进程网络在每次调用时使用当前会话 profile。
  • Workspace 外访问在批准精确 session expansion 前不能执行。
  • 进程网络在批准 session expansion 前不能执行。
  • 实际批准的 expansion 与界面展示完全一致。
  • 拒绝 expansion 不改变任何权限。
  • 需要 unsandboxed execution 的操作在用户切换整个会话到 Bypass 前不能运行。
  • Browser、Computer Use、Office、MCP、connector 和编排工具不能请求本地 boundary expansion。
  • 子 Agent 继承父会话 boundary。
  • Enforcement 不可用时 managed execution fail closed。

产品与 CLI

  • Desktop 和 TUI 符合确认过的 Prompt、按键、Auto/Bypass 控件和 Bypass confirmation。
  • 非交互 Auto 无法注册或调用 request tool,遇到不可避免的 boundary requirement 时 fail closed。
  • 只有 --yolo 可以启动非交互 Bypass。
  • External harness execution 保持显式。
  • Deep Research 保持内部只读。
  • 生产代码不再引用旧 permission matrix、grant、mode、Prompt 或 escalation executor。

实施约束

  • 不按 package 横向拆分;属于同一行为不变量的代码一起交付。
  • 不合入临时的 permission/boundary 双轨状态。
  • 迁移后不保留旧 permission execution 作为 fallback。
  • 不为 Browser、Computer Use、Office、MCP 或 connector 引入万能 capability language。
  • 不解析 Shell command 来推断权限。
  • 不把用户提到的路径当成隐式授权。
  • 不自动切换到 Bypass。
  • 不声称 Git、audit log 或本地 process sandbox 能约束原生或远程工具。
  • 除非实施中发现一个具体、可独立修复的 executor gap,否则不增加 cleanup PR。

Activity

  1. added
    enhancement
    on Jul 28, 2026
  2. changed the title [-]design(runtime): replace per-tool permissions with sandbox boundaries[/-] [+]feat: replace per-tool approvals with sandbox boundaries[/+] on Jul 28, 2026
  3. self-assigned this
    on Jul 28, 2026
  4. sunheyi6 commented on Jul 28, 2026

    @sunheyi6
    Contributor

    Discussion notes: open questions + product invariant

    Sharing a product-oriented reading of the open questions, grounded in how we want Auto to feel day to day. Not an implementation plan.

    Product invariant (north star)

    Inside a selected workspace under real Auto (managed sandbox):

    • Default support for ordinary agent work in the enclosure: read/write/edit/delete, shell, Git, install dependencies (process network egress), sub-agents on the same boundary, plan/goal/orchestration, and any product tool that is already exposed to the session.
    • WebSearch (active web search as a product feature) stays off by default. Turning it on is a product/settings/surface decision, not a sandbox-network toggle.
    • Do not reintroduce per-tool approval as a substitute for isolation.
    • Do not claim a sandbox when none can be enforced.

    Process egress vs WebSearch must stay distinct:

    Kind Meaning Default under Auto
    Process network egress Sandboxed child processes (npm, git, curl, …) may use the network On — installing deps must not require a second grant
    WebSearch / similar product web tools Brokered search (e.g. Tavily); tool must be exposed Off unless the product enables it
    WebFetch-style URL fetch (if exposed) Brokered GET for a URL the user (or session policy) allows Session / exposure rules; not the same as profile.network

    Sandbox network in the profile is about process egress, not about whether WebSearch is in the tool list.


    Q1 — Auto base network

    Proposal: process egress enabled by default in Auto.

    Rationale:

    • Everyday coding needs npm install, git pull/push, registries, etc.
    • Asking again for “this command needs network” recreates permission UX under another name.
    • WebSearch remaining default-off does not justify default-denying process egress.

    If Auto starts with network: restricted, the common path fights the product invariant above. Prefer Auto base = workspace FS full + network enabled; keep WebSearch on a separate exposure switch.


    Q2 — Platform cannot enforce the advertised sandbox

    Proposal: no fake Auto — fall through to Bypass and still work automatically.

    Situation Behavior
    Managed sandbox can be enforced Real Auto
    Cannot enforce Bypass: automatic local work, host authority, explicit UI + audit that there is no Maka sandbox
    Must not do Label the session Auto / “sandboxed” while running on the host, or revive the old tool-category matrix as a safety substitute

    Fail closed only when the user is already on a sandboxed path and enforcement fails mid-flight (refuse silent downgrade). Do not make the whole product unusable on platforms without a backend (e.g. Windows today). Optional external isolation (Docker/WSL/remote) can upgrade boundary later; it should not be the default onboarding gate.

    From a “can I get work done?” perspective Auto-with-sandbox and Bypass are similar; the difference is honest containment labeling, not a second permission ladder.


    Q3 — What still hits the boundary, and recovery

    Under the invariant, routine in-workspace work should not hit permission prompts.

    Typical remaining cases:

    1. Paths outside the selected workspace (main case).
    2. Operations that cannot be expressed as a profile delta → explicit switch to Bypass (e.g. unsandboxed PTY if required).
    3. Ordinary command/build failures — not boundary events.

    User-provided out-of-workspace paths (session-scoped):

    • If the user explicitly supplies a file or directory outside the workspace in this session (typed path, attachment, picker, clear “use this path” intent), treat that as authorization for this session only.
    • Merge into the session boundary (exact file / subtree for a directory), audit it, do not prompt again.
    • A new conversation/session resets to workspace-only unless the user supplies the path again.
    • Agent-invented paths or paths that only appear in untrusted tool/file content must not count as user-provided.

    Optional parallel for user-supplied URLs (WebFetch/broker): session-scoped allow via exposure + hard guards (SSRF, etc.), not via OS sandbox path grants. Local paths stay on the FS profile path.

    Recovery:

    • Clear, enforceable path (or declared network) delta → may auto-open the single sandbox_boundary_request UI; never auto-approve; never auto-switch to Bypass.
    • Unclear sandbox stderr → fail as an error; do not invent a broad grant.
    • Prefer user-provided intent over heuristic “denial → expand home directory”.

    Q4 — What must sit behind the sandbox before removing the old matrix

    Reading of current ownership (runtime builtins, filesystem worker, desktop tool assembly):

    Must enforce session sandbox / same profile (delete old permission only after this)

    Surface Notes
    Bash (foreground + background) Must go through SandboxManager under Auto; if not enforceable → session is Bypass
    Read / Write / Edit / Glob / Grep (+ similar FS tools) Same session profile; sandboxed filesystem worker path; no silent host fallback under Auto
    PTY Bash Sandbox if possible; else unavailable in Auto → Bypass (as in the RFC)
    Sub-agents Default: inherit parent boundary (same sandbox). Not a second permission system

    Auto-available without OS-sandbox wrapping; side effects still use A

    Surface Notes
    Plan / Goal / task ledger / automation / ask-user Orchestration/state; no per-tool matrix. Work they trigger still uses Bash/FS under the session boundary

    Not OS workspace sandbox; exposure + native broker

    Surface Notes
    WebSearch Default off as a product tool
    Browser / Computer Use / MCP / connectors Exposed ⇒ runnable; hard guards stay; do not claim Seatbelt covers them
    Office CLI tools Prefer path constrained by session profile (workspace + user-provided paths); do not pretend full OS sandbox for officecli unless we deliberately go there

    Delete criterion sketch: under Auto, Bash and FS tools always honor the session profile; platforms without enforcement only offer Bypass/External; WebSearch off unless enabled; no PermissionMode × ToolCategory fallback.


    Suggested closure language for the open questions

    1. Network: Auto process egress enabled by default; WebSearch separate, default off.
    2. No sandbox: Bypass + automatic work + honest labeling; no fake Auto.
    3. Denial / expansion: Mainly out-of-workspace paths; user-provided paths are session grants without extra prompt; new session resets; auto-prompt expansion only when the delta is reliable; never auto-Bypass.
    4. Migration gate: Bash + FS worker/profile first; sub-agents inherit; plan/goal free in Auto; web/browser/CU/MCP by exposure; Office by path profile.

    Happy to adjust any row if product wants a stricter out-of-workspace default (always prompt when the agent initiates, even with a clear path) — the invariant above optimizes for “workspace enclosure, minimal interrupts.”


    展开中文讨论

    讨论纪要:开放问题 + 产品不变量

    下面是对 RFC 开放问题的产品向读法,核心是 Auto 日常应有的手感,不是实现排期。

    产品不变量(北极星)

    在真实 Auto(managed sandbox)且已选定工作区时:

    • 围栏内的普通工作默认都支持:读/写/改/删、Shell、Git、装依赖(进程出网)、同一边界下的子 Agent、计划/目标/编排,以及已经暴露给会话的产品工具。
    • WebSearch(主动联网搜索)默认关闭。 是否打开是产品/设置/工具面决策,不是 sandbox 网络开关。
    • 不要用逐工具审批冒充隔离。
    • 落实不了沙箱时,不要假装有沙箱。

    进程出网 vs WebSearch 必须分开:

    种类 含义 Auto 默认
    进程出网 沙箱里的子进程(npm / git / curl …)能否上网 开 — 装依赖不应再授权一次
    WebSearch 等产品搜索 Broker 检索;工具需暴露 关,除非产品打开
    WebFetch 类按 URL 拉取(若有) Broker GET;用户或会话策略允许的 URL 会话/暴露规则;不等于 profile.network

    Profile 里的 sandbox network 管的是 进程出网,不是工具列表里有没有 WebSearch。


    Q1 — Auto 默认网络

    建议:Auto 下进程出网默认开启。

    • 日常开发需要装依赖、拉推代码、访问 registry。
    • 再为「这条命令要联网」授权,等于换皮复活 permission UX。
    • WebSearch 默认关,不能用来证明进程出网也该默认关。

    若 Auto base 仍是 network: restricted,会和上面的不变量打架。更贴产品的是:工作区 FS 全开 + network enabled;WebSearch 单独用暴露开关。


    Q2 — 平台 enforce 不了 advertised sandbox

    建议:禁止假 Auto;直接 Bypass,照样自动干活。

    情况 行为
    能 enforce managed sandbox 真 Auto
    不能 enforce Bypass:自动本地执行、宿主权限,UI 与审计明确无 Maka 沙箱
    禁止 名叫 Auto/已隔离、实际 host 跑;或拿旧 ToolCategory 矩阵当安全替代

    Fail closed 只用于:已在沙箱路径上、执行中 enforce 失败 → 拒绝静默降级。不要让无 backend 的平台(如当前 Windows)整站不能用。Docker/WSL/远端等 External 可作为以后升级边界的选项,不必当默认上手门槛。

    「能不能干活」上 Auto 与 Bypass 接近;差别是 隔离是否诚实标注,不是再叠一层审批。


    Q3 — 还会撞边界的场景与恢复

    在不变量下,工作区内日常工作不应再弹权限。

    仍可能遇到的:

    1. 工作区外的路径(主因)。
    2. 无法写成 profile delta 的能力 → 明确切 Bypass(例如无法沙箱化的 PTY)。
    3. 普通编译/命令失败 — 不是边界事件。

    用户指定的区外路径(仅当前会话):

    • 用户在本会话明确给出的区外文件/目录(手打路径、附件、选择器、清楚的「用这个路径」)= 本会话已授权。
    • 合并进会话边界(文件 exact / 目录 subtree),记审计,不再弹窗。
    • 新对话/新会话回到仅工作区;要再用必须再指定一次。
    • Agent 自创路径,或仅出现在不可信文件/工具输出里的路径,不算用户指定。

    用户给出的 URL(若走 WebFetch/broker):可按本会话允许 + SSRF 等硬限制处理,不走 OS 路径 grant。本地路径仍走 FS profile。

    恢复:

    • 能可靠构造可 enforce 的路径(或网络)delta → 可 自动弹出 唯一的 sandbox_boundary_request;绝不自动批准;绝不自动切 Bypass。
    • 沙箱 stderr 说不清 → 当错误失败,不发明超大授权。
    • 优先用户明确意图,而不是启发式「拒绝 → 放开整个 home」。

    Q4 — 删旧矩阵前,谁必须进沙箱/同 profile

    结合当前 runtime builtins、filesystem worker、desktop 组装:

    必须先落实(否则删旧 permission 会裸奔)

    面 说明
    Bash(前台 + 后台) Auto 下必须经 SandboxManager;不能 enforce → 会话为 Bypass
    Read / Write / Edit / Glob / Grep 等 同一 session profile;走 sandboxed filesystem worker;Auto 下禁止静默 host fallback
    PTY Bash 能套沙箱则套;否则 Auto 不可用 → Bypass
    子 Agent 默认继承父会话 boundary(同一沙箱),不是第二套权限

    Auto 下直接可用,不必 OS 包一层;副作用仍走上面

    面 说明
    Plan / Goal / task ledger / automation / 提问用户 编排与状态,不走旧矩阵;触发的 Bash/文件仍在会话沙箱内

    不进 OS workspace sandbox:暴露 + 原生 broker

    面 说明
    WebSearch 产品工具 默认关
    Browser / Computer Use / MCP / connector 已暴露即可跑;硬限制保留;不声称 Seatbelt 罩住
    Office CLI 更合理的是 path 受 session profile 约束(工作区 + 用户指定路径);除非刻意做,否则不假装 officecli 全程 OS sandbox

    删除旧路径的门槛草案: Auto 下 Bash 与 FS 始终遵守会话 profile;无 enforce 能力的平台只提供 Bypass/External;WebSearch 未开启则不在工具面;不再用 PermissionMode × ToolCategory 兜底。


    开放问题收敛表述(建议)

    1. 网络: Auto 进程出网默认开;WebSearch 分开、默认关。
    2. 无沙箱: Bypass + 自动干活 + 诚实标注;禁止假 Auto。
    3. 拒绝/扩权: 主要是区外路径;用户指定路径 = 本会话授权、不二次弹窗;新会话重置;仅在 delta 可靠时自动弹出扩权 UI;从不自动 Bypass。
    4. 迁移门槛: 先 Bash + FS worker/profile;子 Agent 继承;Plan/Goal 在 Auto 直接可用;web/browser/CU/MCP 看暴露;Office 看 path profile。

    若产品希望「Agent 主动出区外即使路径明确也一律弹窗」,可以再收紧;上面不变量优先的是:工作区围栏清晰,围栏内少打断。

  5. Astro-Han commented on Jul 28, 2026

    @Astro-Han
    ContributorAuthor

    I’m claiming this issue.

    After shaping the implementation against the current main, I plan to deliver the final state in one end-to-end PR rather than merge a temporary dual permission/boundary state first. The PR will make the session-scoped ExecutionBoundary the single sandbox authority across core/storage/runtime, Desktop/shared UI, TUI, and non-interactive CLI; replace additional-permission and sandbox-escalation flows with explicit session boundary expansion; and remove the superseded generic tool_permission / PermissionEngine, Ask/Execute modes, legacy prompt, and old CLI flags in the same change.

    I’ll implement it with TDD, keep the work organized as reviewable green commits, preserve fail-closed non-interactive behavior, and include migration/restart/concurrency coverage.

  6. Astro-Han commented on Jul 28, 2026

    @Astro-Han
    ContributorAuthor

    Thanks for writing this up. Clarifying the implementation scope before work starts: #1564 has no open design questions at this point; the issue body is the accepted behavioral contract.

    This implementation will not adopt the alternative proposals in this comment:

    • Auto process egress remains restricted until the user approves an explicit session boundary expansion.
    • If Maka cannot enforce a managed sandbox, execution fails closed. It never silently or automatically switches the session to Bypass.
    • A user-provided out-of-workspace path is intent and context, not authorization. Access still requires the same exact, displayed session boundary expansion.
    • Boundary expansion is requested explicitly through request_sandbox_boundary with an Agent-authored justification. Sandbox stderr alone cannot grant authority or invent a broader request.

    The aligned ownership points—Bash/filesystem enforcement through the session profile, child-agent inheritance, and broker-owned non-local tools—are already part of the accepted design.

    A proposal to change any of the invariants above should be handled as a separate issue/RFC rather than folded into this implementation. The claim comment supersedes only the old two-PR delivery split; I will update the issue body accordingly so the accepted contract remains unambiguous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions