Canonicalize each sandbox workspace once
每个沙箱工作区只规范化一次
[`LocalSandboxProvider.confine()`](../../../../packages/sandbox/sandbox-local/src/index.ts) canonicalizes `workspaceRoot` and copies the policy before dispatch. POSIX profile builders call [`workspaceWritableRoots()`](../../../../packages/sandbox/sandbox/src/roots.ts), which resolves that workspace again. The common preprocessing also runs for POSIX read-only policies that grant no workspace writes.
English
Problem
LocalSandboxProvider.confine() canonicalizes workspaceRoot and copies the policy before dispatch. POSIX profile builders call workspaceWritableRoots(), which resolves that workspace again. The common preprocessing also runs for POSIX read-only policies that grant no workspace writes.
Proposal
Remove the common policy copy. Keep canonicalization in shared POSIX root derivation; canonicalize once inside windowsAclRunnerArgv(), reusing that value for argv, SID derivation, and ACL grants. Preserve per-call extra-root validation and each backend's temporary-directory rules.
Alternatives considered
Keep common preprocessing. It supplies every backend with one physical workspace identity, but POSIX repeats the filesystem work. Explicit Windows normalization preserves the Windows ACL decision.
Acceptance criteria
Direct profile builders and runnerCommand retain canonical roots. Windows argv, SID, and grant keys agree. Existing alias-rejection and read-only checks pass; a focused trace confirms removal of the duplicate workspace lookup.
Risks
Incomplete relocation can split Windows grant identity. Do not cache extra roots: enforcement must recheck a directory replaced by a symlink.
中文
Problem
LocalSandboxProvider.confine() 在分派前规范化 workspaceRoot 并复制策略。POSIX 配置构建函数调用 workspaceWritableRoots(),再次解析同一工作区。对于不授予工作区写权限的 POSIX 只读策略,公共预处理也会执行。
Proposal
移除公共策略复制。保留共享 POSIX 根目录推导中的规范化;在 windowsAclRunnerArgv() 内规范化一次,并在 argv、SID 推导和 ACL 授权中复用该值。保留每次调用的额外根目录校验,以及各后端的临时目录规则。
Alternatives considered
保留公共预处理。 它为每个后端提供统一的物理工作区标识,但 POSIX 会重复访问文件系统。显式保留 Windows 规范化可维持 Windows ACL 决策。
Acceptance criteria
直接调用配置构建函数和使用 runnerCommand 时仍得到规范化的根目录。Windows argv、SID 与授权键保持一致。现有别名拒绝和只读检查通过;聚焦的跟踪结果确认重复的工作区查找已移除。
Risks
迁移不完整可能使 Windows 授权标识不一致。不得缓存额外根目录:执行权限限制时必须重新检查被符号链接替换的目录。