Gate managed workspace execution behind owner-bound authority - #2106
Merged
jackwener merged 4 commits intoAug 4, 2026
Merged
Conversation
zhiiw
marked this pull request as ready for review
August 4, 2026 08:15
Member
|
Review by maka-审美专家 — 通过(对抗性审查,附必须跟进项) 核实结论:授权模型(WeakMap 对象身份 + per-owner token,伪造结构性不可能)、fail-closed 全分支确认(非漂移 Git 错误重抛不吞、无 default-allow)、九个新测试中六个专钉拒绝路径(断言稳定 code 非文案)、包边界收口完整(内部符号不在 index.ts / exports map,且有契约测试钉住缺席)。公共面 dropped binding/receipt、WorkspaceVersionRecordV1 readonly + freeze 关掉调用方篡改向量——这些都值得肯定。PR 描述对自身局限(检测-撤销而非原子互斥)的坦诚与代码一致。 必须跟进(M1.2 动工前):
当前无生产消费者、门控 fail-closed、CI 11/11 绿,合入。上述 4 项请开 follow-up issue 挂到 M1.2。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change gates managed-workspace execution behind an owner-bound, short-lived authority scope. Runtime consumers no longer receive a reusable raw worktree path or a transferable receipt; they can only operate through an opaque scope issued after the storage owner revalidates the complete managed-workspace boundary.
The primary invariant is:
What changed
ManagedWorkspaceOwner.cwd/binding/receipt exposure with an opaque, revocable execution scope.workspaceEffect: none) scopes on the same handle and drain all of them during owner shutdown.Why
The earlier baseline and owner APIs could prove that a managed worktree existed, but they did not provide a narrow execution boundary. A consumer that obtained the raw worktree path could retain or reuse it after the proof became stale. This PR makes execution admission an explicit storage-owned capability and closes that authority leak before managed workspaces are connected to runtime tools.
Ownership and atomicity boundary
ManagedWorkspaceOwnerand its storage-internal execution authority.This is a detection-and-revocation boundary, not a claim that arbitrary external filesystem writers can be atomically excluded. Stronger process isolation belongs to the subsequent worker/sandbox integration.
Deliberately out of scope
owner.close()protection from inside an active callback; the worker integration will add an execution-context guard.Validation
npm --workspace @maka/core run buildnpm --workspace @maka/storage run build中文说明
概要
本次修改把 managed workspace 的执行入口收敛为由
ManagedWorkspaceOwner持有的短生命周期授权作用域。调用方不再获得可长期保存的原始 worktree 路径、binding 或 receipt;只有在 storage owner 重新验证完整 managed-workspace 边界后,才能在回调期间拿到一个不透明、可撤销的 scope。核心不变量是:
主要修改
ManagedWorkspaceOwner独占的内部 execution authority。cwd、binding、receipt 的直接暴露,改为 opaque execution scope。workspaceEffect: none)scope;owner shutdown 会等待所有 scope 收敛。为什么要做
之前的 baseline/owner API 能证明 managed worktree 存在,但无法形成狭窄的执行授权边界。调用方拿到原始路径后,可以在证明过期后继续保存或复用它。本 PR 在 managed workspace 接入 runtime tools 之前,把执行许可收敛为 storage-owned capability,从 API 权限上关闭这条泄漏路径。
Owner 与原子性边界
ManagedWorkspaceOwner及其 storage-internal execution authority。这是一条“检测 + 撤销”边界,并不声称能够原子排除任意外部文件系统写入者。更强的进程隔离属于下一阶段 worker/sandbox 集成。
明确不在本 PR 范围内
owner.close()的保护;后续 worker 集成将加入 execution-context guard。验证