跳至内容

源文件索引:packages/sandbox

本页由 study-tools/generate-source-index.mjs 根据官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec 生成,共 50 个代码或界面源文件。每个标题对应一个真实路径;用途和拆分原因是面向初学者的结构化解释,自动索引不等于人工精读。

图例

本页所有条目共用以下说明:

  • 自动索引只提供定位线索,复杂行为需要回到源码和测试确认。
  • 条目中的行数、声明、结构线索和静态 import 数字是文件级定位证据,用来约束“为什么这样设计”的解释范围;它们用于定位,不替代人工源码阅读。
  • 源码链接固定到官方提交;如果当前条目与运行版本不同,应先重新生成索引再下结论。

条目按所属包分组:packages/sandbox/sandbox-local(9 条)、packages/sandbox/sandbox-policy(6 条)、packages/sandbox/sandbox-windows-acl(28 条)、packages/sandbox/sandbox(7 条)。

packages/sandbox/sandbox-local

packages/sandbox/sandbox-local/src/index.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:模块入口
  • 这个文件有什么用:它把沙箱相关的公开能力集中导出,并决定调用者可以依赖哪些边界;调用者因此不必记住所有内部文件。
  • 为什么这样设计:入口文件把公开边界固定下来,内部文件可以继续拆分或替换;其他包只依赖入口暴露的 API,依赖方向更稳定。
  • 文件级设计证据:源码顶部注释把它定位为“Local sandbox backend. It selects the platform runner chain (Linux bwrap then Landlock; macOS Seatbelt; Windows the ACL restricted-token runner), functionally probes competing candidates once, and reports each wrap's enforcement and stderr classification fa...”;固定提交中扫描到的声明包括 ConfigSandboxInternalsLocalSandboxProviderdefaultProbeBwrapdefaultProbeSeatbelt;本地静态 import 图显示它直接依赖 8 个源文件,并被 13 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdnative/landlock-run/packages/entry/src/index.tspackages/core/session/src/index.tspackages/llm/llm/src/index.tspackages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.ts
  • 对应测试:packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.tspackages/sandbox/sandbox-local/tests/landlock.e2e.tspackages/sandbox/sandbox-local/tests/local.spec.tspackages/sandbox/sandbox-local/tests/packed-install.e2e.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-local/README.md、入口和消费者,再读当前契约,沿着 packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.ts 看它怎样约束运行时,最后对照 packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 567 行;扫描到的声明包括 ConfigSandboxInternalsLocalSandboxProviderdefaultProbeBwrapdefaultProbeSeatbeltdefaultProbeWindowsAclassertPositiveFinite;源码顶部原注释(英文,仅作回查线索):Local sandbox backend. It selects the platform runner chain (Linux bwrap then Landlock; macOS Seatbelt; Windows the ACL restricted-token runner), functionally probes competing candidates once, and reports each wrap's enforcement and stderr classification fa...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/src/invariant.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:运行时不变量
  • 这个文件有什么用:它检查沙箱必须始终成立的条件,在错误刚出现时报告,而不是等到更深层才出现难以解释的结果。
  • 为什么这样设计:把不变量集中在一个位置,调用者和测试就能用同一条规则检查状态;错误在边界处报告,比在后续 UI 或网络请求中才暴露更容易修复。
  • 文件级设计证据:源码顶部注释把它定位为“Package-owned invariant companion for @deepseek-ai/dsh-sandbox-local. @module @deepseek-ai/dsh-sandbox-local/invariant”;固定提交中扫描到的声明包括 nameinjectapply;本地静态 import 图显示它直接依赖 2 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdpackages/runtime-diagnostics/invariants/src/index.tsvendor/cordis/src/index.ts
  • 对应测试:没有确认到直接测试;公共入口可能仍有间接覆盖。
  • 测试关联依据:固定提交中没有找到直接或传递的本地静态 import,也没有找到明显的同包同名测试;公共入口可能仍有间接覆盖。
  • 阅读顺序:先读相关类型和事件,再读当前状态或存储实现,沿着 packages/runtime-diagnostics/invariants/src/index.tsvendor/cordis/src/index.ts 和所在包的入口或服务理解状态变化,最后对照同包中与它同名或覆盖相近场景的测试。
  • 代码证据:固定提交归档实际读取结果:约 30 行;扫描到的声明包括 nameinjectapply;源码顶部原注释(英文,仅作回查线索):Package-owned invariant companion for @deepseek-ai/dsh-sandbox-local. @module @deepseek-ai/dsh-sandbox-local/invariant。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/src/profiles.ts

packages/sandbox/sandbox-local/tests/acl-grants.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“windows-acl write grants (LocalSandboxProvider)”、“workspace-write materializes one standing workspace grant and one private temp capabili...”、“read-only materializes no capability; upgrade creates them and downgrade leaves them re...”、“a fresh provider gives a resumed session a new temp path and SID, so crash residue cann...”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“windows-acl write grants (LocalSandboxProvider)”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“windows-acl grant ownership through the real LocalSandboxProvider: one standing capability per workspace plus one random, distinct, revocable temp capability per live session/workspace pair. The Win32 grant surface is mocked; native access checks live in sa...”;固定提交中扫描到的声明包括 MockAclWriteGrantsetupworkspaceRootflag;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdpackages/core/session/src/index.tspackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/core/session/src/index.tspackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 339 行;扫描到的声明包括 MockAclWriteGrantsetupworkspaceRootflag;扫描到的测试主题包括 “windows-acl write grants (LocalSandboxProvider)”、“workspace-write materializes one standing workspace grant and one private temp capability, then reuses both”、“read-only materializes no capability; upgrade creates them and downgrade leaves them reusable”、“a fresh provider gives a resumed session a new temp path and SID, so crash residue cannot collide”、“forks and workspace changes receive distinct temp capabilities while each workspace grant is reused”、“workspace grant failure disposes its SID, aggregates cleanup failure, and never creates a temp directory”;源码顶部原注释(英文,仅作回查线索):windows-acl grant ownership through the real LocalSandboxProvider: one standing capability per workspace plus one random, distinct, revocable temp capability per live session/workspace pair. The Win32 grant surface is mocked; native access checks live in sa...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/tests/bwrap.e2e.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“the passing probe selects the bwrap rung naturally — first in the ladder, full enforcem...”、“read-only denies a write — the file must NOT exist, and the kernel speaks the advertise...”、“read-only keeps the tree readable/executable and the fresh /dev/null writable”、“keeps descendants observable and controllable inside the private PID namespace”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“the passing probe selects the bwrap rung naturally — first in the ladder, full enforcem...”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:固定提交中扫描到的声明包括 tempDirproviderrunConfined;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdpackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox-local/src/profiles.tspackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox-local/src/profiles.tspackages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 146 行;扫描到的声明包括 tempDirproviderrunConfined;扫描到的测试主题包括 “the passing probe selects the bwrap rung naturally — first in the ladder, full enforcement, EROFS dialect”、“read-only denies a write — the file must NOT exist, and the kernel speaks the advertised dialect”、“read-only keeps the tree readable/executable and the fresh /dev/null writable”、“keeps descendants observable and controllable inside the private PID namespace”、“workspace-write lands a write inside the workspace root and still denies one beside it”、“workspace-write mounts an EPHEMERAL /tmp: the write succeeds inside, the host /tmp stays untouched”。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/tests/landlock.e2e.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“read-only denies a write — the file must NOT exist, the wrap reports the probed enforce...”、“read-only keeps the tree readable/executable and /dev/null writable”、“read-only denies a write beneath the host /dev (the /dev/shm tmpfs must stay untouched)”、“workspace-write lands a write inside the workspace root and still denies one beside it”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“read-only denies a write — the file must NOT exist, the wrap reports the probed enforce...”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:固定提交中扫描到的声明包括 tempDirproviderrunConfined;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdnative/landlock-run/packages/entry/src/index.tspackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 native/landlock-run/packages/entry/src/index.tspackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 106 行;扫描到的声明包括 tempDirproviderrunConfined;扫描到的测试主题包括 “read-only denies a write — the file must NOT exist, the wrap reports the probed enforcement”、“read-only keeps the tree readable/executable and /dev/null writable”、“read-only denies a write beneath the host /dev (the /dev/shm tmpfs must stay untouched)”、“workspace-write lands a write inside the workspace root and still denies one beside it”、“workspace-write grants the host /tmp (the documented Landlock-profile difference)”。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/tests/local.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“profile dialects”、“bwrap read-only: whole tree read-only with fresh /dev and private PID-scoped /proc, no ...”、“bwrap workspace-write: adds an ephemeral /tmp and rebinds the workspace root”、“landlock read-only: readable tree plus a writable /dev/null, nothing else”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“profile dialects”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“LocalSandboxProvider tests. No real runner is assumed to exist on the test host: runnerCommand injects deterministic runner argvs, and internals injects probe verdicts plus fake Landlock launcher / sandbox-exec scripts, so profile dialects, ladder selection...”;固定提交中扫描到的声明包括 setupabsentRunnerEntryfakeLauncherfakeSeatbeltExec;本地静态 import 图显示它直接依赖 5 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdnative/landlock-run/packages/entry/src/index.tspackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox-local/src/profiles.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 native/landlock-run/packages/entry/src/index.tspackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox-local/src/profiles.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 453 行;扫描到的声明包括 setupabsentRunnerEntryfakeLauncherfakeSeatbeltExec;扫描到的测试主题包括 “profile dialects”、“bwrap read-only: whole tree read-only with fresh /dev and private PID-scoped /proc, no writable mounts”、“bwrap workspace-write: adds an ephemeral /tmp and rebinds the workspace root”、“landlock read-only: readable tree plus a writable /dev/null, nothing else”、“landlock workspace-write: adds the host /tmp and the workspace root”、“seatbelt read-only: allow-default with every file write denied except the /dev/null literal”;源码顶部原注释(英文,仅作回查线索):LocalSandboxProvider tests. No real runner is assumed to exist on the test host: runnerCommand injects deterministic runner argvs, and internals injects probe verdicts plus fake Landlock launcher / sandbox-exec scripts, so profile dialects, ladder selection...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/tests/packed-install.e2e.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“installs this checkout\”、“the installed provider resolves the launcher INSIDE the consumer node_modules platform ...”、“confines through the installed launcher (enforcing kernel) or fails closed (non-enforci...”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“installs this checkout\”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:本次固定提交归档没有扫描到顶部注释、顶层声明或专门的结构线索;本地静态 import 图显示它直接依赖 3 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdnative/landlock-run/packages/entry/src/index.tspackages/sandbox/sandbox-local/src/index.tsvendor/cordis/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 native/landlock-run/packages/entry/src/index.tspackages/sandbox/sandbox-local/src/index.tsvendor/cordis/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 193 行;扫描到的测试主题包括 “installs this checkout\”、“the installed provider resolves the launcher INSIDE the consumer node_modules platform package”、“confines through the installed launcher (enforcing kernel) or fails closed (non-enforcing) — never unconfined”。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-local/tests/seatbelt.e2e.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“read-only denies a write — the file must NOT exist, and the kernel speaks the advertise...”、“read-only keeps the tree readable/executable and /dev/null writable”、“read-only grants no temp area: a write under the user temp dir is denied too”、“workspace-write lands a write inside the workspace root and still denies one beside it”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“read-only denies a write — the file must NOT exist, and the kernel speaks the advertise...”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:固定提交中扫描到的声明包括 tempDirproviderrunConfined;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-local/README.mdpackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox-local/src/profiles.tspackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox-local/src/profiles.tspackages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 112 行;扫描到的声明包括 tempDirproviderrunConfined;扫描到的测试主题包括 “read-only denies a write — the file must NOT exist, and the kernel speaks the advertised dialect”、“read-only keeps the tree readable/executable and /dev/null writable”、“read-only grants no temp area: a write under the user temp dir is denied too”、“workspace-write lands a write inside the workspace root and still denies one beside it”、“workspace-write grants /tmp and the user temp dir (the documented Seatbelt-profile temp areas)”。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-policy

packages/sandbox/sandbox-policy/src/index.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:模块入口
  • 这个文件有什么用:它把沙箱、策略相关的公开能力集中导出,并决定调用者可以依赖哪些边界;调用者因此不必记住所有内部文件。
  • 为什么这样设计:入口文件把公开边界固定下来,内部文件可以继续拆分或替换;其他包只依赖入口暴露的 API,依赖方向更稳定。
  • 文件级设计证据:源码顶部注释把它定位为“The sandbox POLICY home (ctx.sandboxPolicy): the single owner of the deployment's sandbox fallbacks plus per-session resolution: the file-effect SandboxMode, the workspace-write root, and the override kit (the sandbox/mode event, its fold, and its write pat...”;固定提交中扫描到的声明包括 ConfigSandboxPolicyRequestSandboxPolicyServiceresolveWorkspaceRootrenderPolicyContext;本地静态 import 图显示它直接依赖 7 个源文件,并被 35 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-policy/README.mdpackages/core/agent/src/index.tspackages/core/session/src/index.tspackages/core/system-prompt/src/index.tsapps/web/tests/shipped-composition.e2e.ts
  • 对应测试:apps/web/tests/shipped-composition.e2e.tspackages/e2b/e2b/tests/composition.e2e.tspackages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/fs/fs-sandbox/tests/fs-sandbox.spec.tspackages/fs/tool-fs/tests/tools.spec.tspackages/fs/tool-str-replace-editor/tests/tools.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 测试支持:apps/web/tests/scaffold.ts
  • 阅读顺序:先读 packages/sandbox/sandbox-policy/README.md、入口和消费者,再读当前契约,沿着 apps/web/tests/shipped-composition.e2e.tsexamples/acp-agent/tests/fixtures/parent-sandbox-override.tspackages/e2b/e2b/tests/composition.e2e.ts 看它怎样约束运行时,最后对照 apps/web/tests/shipped-composition.e2e.tspackages/e2b/e2b/tests/composition.e2e.tspackages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 154 行;扫描到的声明包括 ConfigSandboxPolicyRequestSandboxPolicyServiceresolveWorkspaceRootrenderPolicyContext;源码顶部原注释(英文,仅作回查线索):The sandbox POLICY home (ctx.sandboxPolicy): the single owner of the deployment's sandbox fallbacks plus per-session resolution: the file-effect SandboxMode, the workspace-write root, and the override kit (the sandbox/mode event, its fold, and its write pat...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-policy/src/invariant.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:运行时不变量
  • 这个文件有什么用:它检查沙箱、策略必须始终成立的条件,在错误刚出现时报告,而不是等到更深层才出现难以解释的结果。
  • 为什么这样设计:把不变量集中在一个位置,调用者和测试就能用同一条规则检查状态;错误在边界处报告,比在后续 UI 或网络请求中才暴露更容易修复。
  • 文件级设计证据:源码顶部注释把它定位为“Package-owned session-event invariants for sandbox policy. @module @deepseek-ai/dsh-sandbox-policy/invariant”;固定提交中扫描到的声明包括 nameinjectapplyvalidateEvent;本地静态 import 图显示它直接依赖 4 个源文件,并被 1 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-policy/README.mdpackages/core/session/src/index.tspackages/runtime-diagnostics/invariants/src/index.tspackages/sandbox/sandbox-policy/src/session-mode.tspackages/sandbox/sandbox-policy/tests/invariant.spec.ts
  • 对应测试:packages/sandbox/sandbox-policy/tests/invariant.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读相关类型和事件,再读当前状态或存储实现,沿着 packages/core/session/src/index.tspackages/runtime-diagnostics/invariants/src/index.tspackages/sandbox/sandbox-policy/src/session-mode.tspackages/sandbox/sandbox-policy/tests/invariant.spec.ts 理解状态变化,最后对照 packages/sandbox/sandbox-policy/tests/invariant.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 42 行;扫描到的声明包括 nameinjectapplyvalidateEvent;源码顶部原注释(英文,仅作回查线索):Package-owned session-event invariants for sandbox policy. @module @deepseek-ai/dsh-sandbox-policy/invariant。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-policy/src/session-mode.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:会话状态模型
  • 这个文件有什么用:它描述或维护沙箱、策略、会话的生命周期和状态变化,让日志、客户端和运行时共享同一条会话边界。
  • 为什么这样设计:会话状态需要被日志、运行时和界面共同理解,单独建模可以让生命周期与恢复规则不被某一个宿主私有化。
  • 文件级设计证据:源码顶部注释把它定位为“Per-session sandbox-mode override: the session log as the store. A runtime switch (a UI policy control or test scenario) is recorded as one sandbox/mode event on the session it applies to; effective = fold(events) ?? the deployment default, so an override s...”;固定提交中扫描到的声明包括 SANDBOX_MODESeffectiveSandboxModesetSandboxMode;本地静态 import 图显示它直接依赖 2 个源文件,并被 2 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-policy/README.mdpackages/core/session/src/index.tspackages/sandbox/sandbox/src/index.tspackages/sandbox/sandbox-policy/src/index.tspackages/sandbox/sandbox-policy/src/invariant.ts
  • 对应测试:间接测试线索(通过本地 import 链,非直接覆盖):apps/cli/tests/web-agent-presets.e2e.tsapps/web/tests/agent-preset-selection.e2e.tsapps/web/tests/shipped-composition.e2e.tsapps/web/tests/sidebar-subagent-activity.e2e.tsapps/web/tests/subagent-conversation.e2e.tsexamples/headless-agent/tests/code-mode.e2e.ts
  • 测试关联依据:固定提交源码中的本地静态 import 传递引用;这些测试通过包入口或中间模块到达本文件,不等于本文件被直接覆盖。
  • 阅读顺序:先读相关类型和事件,再读当前状态或存储实现,沿着 packages/core/session/src/index.tspackages/sandbox/sandbox/src/index.tspackages/sandbox/sandbox-policy/src/index.tspackages/sandbox/sandbox-policy/src/invariant.ts 理解状态变化,最后对照 apps/cli/tests/web-agent-presets.e2e.tsapps/web/tests/agent-preset-selection.e2e.tsapps/web/tests/shipped-composition.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 71 行;扫描到的声明包括 SANDBOX_MODESeffectiveSandboxModesetSandboxMode;源码顶部原注释(英文,仅作回查线索):Per-session sandbox-mode override: the session log as the store. A runtime switch (a UI policy control or test scenario) is recorded as one sandbox/mode event on the session it applies to; effective = fold(events) ?? the deployment default, so an override s...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-policy/tests/invariant.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、策略的具体场景,包括“sandbox-policy invariants”、“ignores unrelated event streams”、“rejects and attributes an unknown durable sandbox mode”、“rejects an unknown mode already present on late registration”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“sandbox-policy invariants”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:固定提交中扫描到的声明包括 setupmodeEvent;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-policy/README.mdpackages/core/session/src/index.tspackages/runtime-diagnostics/invariants/src/index.tspackages/sandbox/sandbox-policy/src/invariant.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/core/session/src/index.tspackages/runtime-diagnostics/invariants/src/index.tspackages/sandbox/sandbox-policy/src/invariant.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 53 行;扫描到的声明包括 setupmodeEvent;扫描到的测试主题包括 “sandbox-policy invariants”、“ignores unrelated event streams”、“rejects and attributes an unknown durable sandbox mode”、“rejects an unknown mode already present on late registration”。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-policy/tests/policy.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、策略的具体场景,包括“SandboxPolicyService”、“defaults to read-only under the process cwd”、“carries a configured mode and resolves the workspace root absolute”、“resolves the deployment policy for an agentless call”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“SandboxPolicyService”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Tests for the sandbox-policy home: the deployment default (mode + workspaceRoot) the service exposes, and the per-session sandbox/mode override kit (fold + write path) every enforcing capability reads.”;固定提交中扫描到的声明包括 mountedsessionagentForpolicyContextpromptMounted;本地静态 import 图显示它直接依赖 5 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-policy/README.mdpackages/core/agent/src/index.tspackages/core/session/src/index.tspackages/core/system-prompt/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/core/agent/src/index.tspackages/core/session/src/index.tspackages/core/system-prompt/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 230 行;扫描到的声明包括 mountedsessionagentForpolicyContextpromptMounted;扫描到的测试主题包括 “SandboxPolicyService”、“defaults to read-only under the process cwd”、“carries a configured mode and resolves the workspace root absolute”、“resolves the deployment policy for an agentless call”、“resolves each session mode and cwd together without changing the fallback”、“lets an approved mode outrank the session mode while retaining its root”;源码顶部原注释(英文,仅作回查线索):Tests for the sandbox-policy home: the deployment default (mode + workspaceRoot) the service exposes, and the per-session sandbox/mode override kit (fold + write path) every enforcing capability reads.。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-policy/tsdown.config.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:构建或测试配置
  • 这个文件有什么用:它告诉工具链怎样处理沙箱、策略:从哪里开始、使用哪个环境、解析哪些依赖以及输出什么产物;这些规则集中后,构建和测试才可重复。
  • 为什么这样设计:工具链配置独立于业务实现,构建、测试和发布可以复用同一套入口规则;改配置时也能单独看出运行环境变化。
  • 文件级设计证据:本次固定提交归档没有扫描到顶部注释、顶层声明或专门的结构线索;本地静态 import 图显示它直接依赖 0 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-policy/README.md
  • 对应测试:没有确认到直接测试;公共入口可能仍有间接覆盖。
  • 测试关联依据:固定提交中没有找到直接或传递的本地静态 import,也没有找到明显的同包同名测试;公共入口可能仍有间接覆盖。
  • 阅读顺序:先读 packages/sandbox/sandbox-policy/README.md,再读本配置/脚本,沿着所在包的入口或服务确认它如何影响入口和产物,最后对照对应 gate 或快照测试。
  • 代码证据:固定提交归档实际读取结果:约 25 行。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl

packages/sandbox/sandbox-windows-acl/src/acl.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“ACL editing helpers: grant/revoke a capability SID on a directory via SetEntriesInAclW + SetNamedSecurityInfoW (the same calls the POC uses, with the failure handling the POC lacks). Every API call is checked and every failure is reported with the API name,...”;固定提交中扫描到的声明包括 buildExplicitAccesslockFilePathwithPathLockgrantWriterevokeWrite;本地静态 import 图显示它直接依赖 2 个源文件,并被 5 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.tspackages/sandbox/sandbox-windows-acl/src/grant.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/acl.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着 packages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.tspackages/sandbox/sandbox-windows-acl/src/grant.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/src/token.ts 确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/acl.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 271 行;扫描到的声明包括 buildExplicitAccesslockFilePathwithPathLockgrantWriterevokeWritereadCurrentDaclmergeAndApplyhasExactGrant;源码顶部原注释(英文,仅作回查线索):ACL editing helpers: grant/revoke a capability SID on a directory via SetEntriesInAclW + SetNamedSecurityInfoW (the same calls the POC uses, with the failure handling the POC lacks). Every API call is checked and every failure is reported with the API name,...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/errors.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:错误模型
  • 这个文件有什么用:这个文件统一错误的类型、名称或转换方式。统一错误格式能让日志、用户界面和重试策略看懂同一件事。
  • 为什么这样设计:固定提交的文件顶部注释把它定位为“Fail-closed Win32 error type. Every backend API failure raises this with the API name and the exact Win32 code; the original POC silently ignored every failed call and would run children UNRESTRICTED (fail-open) — that is the failure mode this class exists ...”;把这项职责单独放置,可以让边界、输入和失败处理在一个地方被阅读和测试。
  • 文件级设计证据:源码顶部注释把它定位为“Fail-closed Win32 error type. Every backend API failure raises this with the API name and the exact Win32 code; the original POC silently ignored every failed call and would run children UNRESTRICTED (fail-open) — that is the failure mode this class exists ...”;固定提交中扫描到的声明包括 Win32Error;本地静态 import 图显示它直接依赖 0 个源文件,并被 7 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/ffi.spec.tspackages/sandbox/sandbox-windows-acl/tests/index-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/token-failure-paths.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着相关类型、协议或实现和 packages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.ts 确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/ffi.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 21 行;扫描到的声明包括 Win32Error;源码顶部原注释(英文,仅作回查线索):Fail-closed Win32 error type. Every backend API failure raises this with the API name and the exact Win32 code; the original POC silently ignored every failed call and would run children UNRESTRICTED (fail-open) — that is the failure mode this class exists ...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/ffi.ts

packages/sandbox/sandbox-windows-acl/src/grant.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“Server-side write-grant materialization. The sandbox seam holds one standing workspace grant per workspace and one revocable temp grant per live session/workspace pair. Workspace identities survive by deterministic derivation and their standing ACE; temp id...”;固定提交中扫描到的声明包括 AclWriteGrant;本地静态 import 图显示它直接依赖 2 个源文件,并被 1 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:间接测试线索(通过本地 import 链,非直接覆盖):packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.tspackages/sandbox/sandbox-local/tests/landlock.e2e.tspackages/sandbox/sandbox-local/tests/local.spec.tspackages/sandbox/sandbox-local/tests/packed-install.e2e.ts
  • 测试关联依据:固定提交源码中的本地静态 import 传递引用;这些测试通过包入口或中间模块到达本文件,不等于本文件被直接覆盖。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着 packages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts 确认输入输出,最后对照 packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 104 行;扫描到的声明包括 AclWriteGrant;源码顶部原注释(英文,仅作回查线索):Server-side write-grant materialization. The sandbox seam holds one standing workspace grant per workspace and one revocable temp grant per live session/workspace pair. Workspace identities survive by deterministic derivation and their standing ACE; temp id...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/index.ts

packages/sandbox/sandbox-windows-acl/src/invariant.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:运行时不变量
  • 这个文件有什么用:它检查沙箱必须始终成立的条件,在错误刚出现时报告,而不是等到更深层才出现难以解释的结果。
  • 为什么这样设计:把不变量集中在一个位置,调用者和测试就能用同一条规则检查状态;错误在边界处报告,比在后续 UI 或网络请求中才暴露更容易修复。
  • 文件级设计证据:源码顶部注释把它定位为“Package-owned invariant companion for @deepseek-ai/dsh-sandbox-windows-acl. @module @deepseek-ai/dsh-sandbox-windows-acl/invariant”;固定提交中扫描到的声明包括 nameinjectapply;本地静态 import 图显示它直接依赖 2 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/runtime-diagnostics/invariants/src/index.tsvendor/cordis/src/index.ts
  • 对应测试:没有确认到直接测试;公共入口可能仍有间接覆盖。
  • 测试关联依据:固定提交中没有找到直接或传递的本地静态 import,也没有找到明显的同包同名测试;公共入口可能仍有间接覆盖。
  • 阅读顺序:先读相关类型和事件,再读当前状态或存储实现,沿着 packages/runtime-diagnostics/invariants/src/index.tsvendor/cordis/src/index.ts 和所在包的入口或服务理解状态变化,最后对照同包中与它同名或覆盖相近场景的测试。
  • 代码证据:固定提交归档实际读取结果:约 31 行;扫描到的声明包括 nameinjectapply;源码顶部原注释(英文,仅作回查线索):Package-owned invariant companion for @deepseek-ai/dsh-sandbox-windows-acl. @module @deepseek-ai/dsh-sandbox-windows-acl/invariant。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/path-boundary.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:路径边界
  • 这个文件有什么用:它负责沙箱、路径的解析、规范化和安全约束,统一处理不同平台的路径差异与越界检查。
  • 为什么这样设计:路径是跨平台且涉及安全的输入,集中规范化和越界判断可以避免不同调用方产生不一致的文件目标。
  • 文件级设计证据:源码顶部注释把它定位为“Canonical directory-boundary checks for the Windows ACL workspace and private-temp capabilities. @module @deepseek-ai/dsh-sandbox-windows-acl/path-boundary”;固定提交中扫描到的声明包括 assertTempRootOutsideWorkspaceassertPrivateTempDisjointcontainsDirectory;本地静态 import 图显示它直接依赖 0 个源文件,并被 2 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/path-boundary.spec.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/path-boundary.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着相关类型、协议或实现和 packages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/path-boundary.spec.ts 确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/path-boundary.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 40 行;扫描到的声明包括 assertTempRootOutsideWorkspaceassertPrivateTempDisjointcontainsDirectory;源码顶部原注释(英文,仅作回查线索):Canonical directory-boundary checks for the Windows ACL workspace and private-temp capabilities. @module @deepseek-ai/dsh-sandbox-windows-acl/path-boundary。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/runner.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:运行驱动
  • 这个文件有什么用:它推进沙箱、运行驱动的输入、执行、输出和退出状态,把一类运行流程封装成可观察的边界。
  • 为什么这样设计:运行流程的输入、输出和退出状态集中,宿主只负责提供环境;这样命令行、测试和服务端可以复用同一条执行路径。
  • 文件级设计证据:源码顶部注释把它定位为“The windows-acl confinement runner: the argv-prefix wrapper the sandbox seam spawns in place of the caller's command. It creates the WRITE_RESTRICTED token with the workspace write-SID allowlist, spawns the wrapped argv under it with the CALLER'S stdio inhe...”;固定提交中扫描到的声明包括 RunnerFailurefailparseArgsrequireDirectorymain;本地静态 import 图显示它直接依赖 3 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/src/workspace-sid.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/runner.spec.ts
  • 测试关联依据:按同包文件名保守推断,未确认直接 import;这不是完整覆盖证明。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着 packages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/src/workspace-sid.ts 和所在包的入口或服务确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/runner.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 226 行;扫描到的声明包括 RunnerFailurefailparseArgsrequireDirectorymain;源码顶部原注释(英文,仅作回查线索):The windows-acl confinement runner: the argv-prefix wrapper the sandbox seam spawns in place of the caller's command. It creates the WRITE_RESTRICTED token with the workspace write-SID allowlist, spawns the wrapped argv under it with the CALLER'S stdio inhe...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/spawn.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“Restricted-process spawning: anonymous pipes for stdio, STARTUPINFOW with STARTF_USESTDHANDLES, CreateProcessAsUserW under the restricted token, then asynchronous pipe draining and exit waiting. Console isolation (CREATE_NO_WINDOW / CREATE_NEW_CONSOLE) is i...”;固定提交中扫描到的声明包括 quoteArgbuildCommandLineSpawnedNativespawnSandboxeddrainPipe;本地静态 import 图显示它直接依赖 2 个源文件,并被 3 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/quote.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着 packages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/quote.spec.ts 确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/quote.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 357 行;扫描到的声明包括 quoteArgbuildCommandLineSpawnedNativespawnSandboxeddrainPipewaitForExitSpawnedInheritedspawnSandboxedInherited;源码顶部原注释(英文,仅作回查线索):Restricted-process spawning: anonymous pipes for stdio, STARTUPINFOW with STARTF_USESTDHANDLES, CreateProcessAsUserW under the restricted token, then asynchronous pipe draining and exit waiting. Console isolation (CREATE_NO_WINDOW / CREATE_NEW_CONSOLE) is i...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/token.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“Restricted-token construction: open the current process token, extract its logon SID, build the well-known SIDs, and call CreateRestrictedToken with the POC's restricting-SID allowlist. Every API call is checked; any failure throws with the API name and the...”;固定提交中扫描到的声明包括 openCurrentProcessTokenfindLogonSidmakeWellKnownSidsetTokenDefaultDaclGrantRestrictingSidSet;本地静态 import 图显示它直接依赖 3 个源文件,并被 3 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/acl.spec.tspackages/sandbox/sandbox-windows-acl/tests/token-failure-paths.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着 packages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.tspackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/tests/acl.spec.tspackages/sandbox/sandbox-windows-acl/tests/token-failure-paths.spec.ts 确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/acl.spec.tspackages/sandbox/sandbox-windows-acl/tests/token-failure-paths.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 222 行;扫描到的声明包括 openCurrentProcessTokenfindLogonSidmakeWellKnownSidsetTokenDefaultDaclGrantRestrictingSidSetcreateRestrictedTokenbuildRestrictingSids;源码顶部原注释(英文,仅作回查线索):Restricted-token construction: open the current process token, extract its logon SID, build the well-known SIDs, and call CreateRestrictedToken with the POC's restricting-SID allowlist. Every API call is checked; any failure throws with the API name and the...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/win32-abi.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“Windows ABI constants for the ACL-sandbox backend. Every value was verified against the actual MinGW Windows headers on this machine (C:\Strawberry\c\x86_64-w64-mingw32\include) and cross-checked at runtime by verify/abi-probe.cpp (same numbers; static_ass...”;固定提交中扫描到的声明包括 TOKEN_ASSIGN_PRIMARYTOKEN_DUPLICATETOKEN_QUERYTOKEN_ADJUST_DEFAULTSE_GROUP_LOGON_ID;本地静态 import 图显示它直接依赖 0 个源文件,并被 11 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/acl.spec.tspackages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/ffi.spec.tspackages/sandbox/sandbox-windows-acl/tests/index-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/token-failure-paths.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着相关类型、协议或实现和 packages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts 确认输入输出,最后对照 packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.tspackages/sandbox/sandbox-windows-acl/tests/acl.spec.tspackages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 258 行;扫描到的声明包括 TOKEN_ASSIGN_PRIMARYTOKEN_DUPLICATETOKEN_QUERYTOKEN_ADJUST_DEFAULTSE_GROUP_LOGON_IDSTANDARD_RIGHTS_WRITEFILE_GENERIC_WRITEDELETE;源码顶部原注释(英文,仅作回查线索):Windows ABI constants for the ACL-sandbox backend. Every value was verified against the actual MinGW Windows headers on this machine (C:\Strawberry\c\x86_64-w64-mingw32\include) and cross-checked at runtime by verify/abi-probe.cpp (same numbers; static_ass...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/src/workspace-sid.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“The per-workspace write identity: a deterministic S-1-4-x-y SID derived from the canonical workspace path, whose ACEs form that workspace's write allowlist. Every confined execution of the same workspace — across sessions, server restarts, and calls — carri...”;固定提交中扫描到的声明包括 workspaceWriteSidtempWriteSid;本地静态 import 图显示它直接依赖 0 个源文件,并被 2 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/src/runner.ts
  • 对应测试:间接测试线索(通过本地 import 链,非直接覆盖):packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.tspackages/sandbox/sandbox-local/tests/landlock.e2e.tspackages/sandbox/sandbox-local/tests/local.spec.tspackages/sandbox/sandbox-local/tests/packed-install.e2e.ts
  • 测试关联依据:固定提交源码中的本地静态 import 传递引用;这些测试通过包入口或中间模块到达本文件,不等于本文件被直接覆盖。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md 和入口,再读当前实现,沿着相关类型、协议或实现和 packages/sandbox/sandbox-windows-acl/src/index.tspackages/sandbox/sandbox-windows-acl/src/runner.ts 确认输入输出,最后对照 packages/examples/agent-spine-demo/tests/multi-project-sandbox.e2e.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.tspackages/sandbox/sandbox-local/tests/bwrap.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 54 行;扫描到的声明包括 workspaceWriteSidtempWriteSid;源码顶部原注释(英文,仅作回查线索):The per-workspace write identity: a deterministic S-1-4-x-y SID derived from the canonical workspace path, whose ACEs form that workspace's write allowlist. Every confined execution of the same workspace — across sessions, server restarts, and calls — carri...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/acl-failure-paths.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、路径的具体场景,包括“withPathLock failure paths”、“fails closed when CreateFileW returns an invalid handle”、“closes the handle and reports when LockFileEx fails”、“closes the handle and reports when UnlockFileEx fails”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“withPathLock failure paths”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“ACL failure-path tests with stub binding tables (the failure-paths.spec.ts pattern): every checked Win32 call in the lock, read-merge-write, and grant-skip sequence has a failing counterpart, and each failure closes the handles it created before throwing. T...”;固定提交中扫描到的声明包括 aclApicraftSidcraftAclWithGrant;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 456 行;扫描到的声明包括 aclApicraftSidcraftAclWithGrant;扫描到的测试主题包括 “withPathLock failure paths”、“fails closed when CreateFileW returns an invalid handle”、“closes the handle and reports when LockFileEx fails”、“closes the handle and reports when UnlockFileEx fails”、“reports a failed CloseHandle after a successful action”、“mergeAndApply failure paths”;源码顶部原注释(英文,仅作回查线索):ACL failure-path tests with stub binding tables (the failure-paths.spec.ts pattern): every checked Win32 call in the lock, read-merge-write, and grant-skip sequence has a failing counterpart, and each failure closes the handles it created before throwing. T...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/acl.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“grantWrite merges into the current DACL: an explicit Users ACE survives grant+revoke”、“grantWrite is idempotent: a second grant over the standing exact ACE skips the SetNamed...”、“interleaved sandbox instances: A.init → B.init → A.dispose → B.dispose leaves BOTH stan...”、“dispose revokes the revocable temp ACE and keeps the standing workspace ACE (self-manag...”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“grantWrite merges into the current DACL: an explicit Users ACE survives grant+revoke”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“ACL edit tests: the read-merge-write grant keeps pre-existing explicit ACEs, interleaved sandbox instances do not clobber each other, the per-path lock primitive is deterministic, and the grant mask carries DELETE + FILE_DELETE_CHILD (never WRITE_DAC/WRITE_...”;固定提交中扫描到的声明包括 sidFromStringsidStringreadDirectAcesscratch;本地静态 import 图显示它直接依赖 5 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/acl.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 318 行;扫描到的声明包括 sidFromStringsidStringreadDirectAcesscratch;扫描到的测试主题包括 “grantWrite merges into the current DACL: an explicit Users ACE survives grant+revoke”、“grantWrite is idempotent: a second grant over the standing exact ACE skips the SetNamedSecurityInfoW apply (no eager full-tree re-propagation)”、“interleaved sandbox instances: A.init → B.init → A.dispose → B.dispose leaves BOTH standing workspace ACEs (the per-workspace reuse cache)”、“dispose revokes the revocable temp ACE and keeps the standing workspace ACE (self-managed flow)”、“rejects an overlapping private temp directory before applying either capability”、“workspace-write without a write SID fails at construction; the token layer guards the same contract”;源码顶部原注释(英文,仅作回查线索):ACL edit tests: the read-merge-write grant keeps pre-existing explicit ACEs, interleaved sandbox instances do not clobber each other, the per-path lock primitive is deterministic, and the grant mask carries DELETE + FILE_DELETE_CHILD (never WRITE_DAC/WRITE_...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/failure-paths.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、路径的具体场景,包括“spawn failure paths close their handles”、“spawnSandboxed closes all six pipe handles before throwing when CreateProcessAsUserW fails”、“spawnSandboxedInherited closes thread, process, and kill-on-close job before throwing w...”、“spawnSandboxedInherited TERMINATES the suspended child before closing handles when Assi...”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“spawn failure paths close their handles”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Failure-path unit tests with minimal stub binding tables: the spawn helpers must close every handle they created before throwing, and getTempPath must refuse to decode a buffer GetTempPathW never wrote. Pure stubs — no real Win32 calls, so these run on ever...”;固定提交中扫描到的声明包括 pipeFailureApiresumeFailureApipipeOkApiinheritedApi;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/spawn.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/spawn.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 454 行;扫描到的声明包括 pipeFailureApiresumeFailureApipipeOkApiinheritedApi;扫描到的测试主题包括 “spawn failure paths close their handles”、“spawnSandboxed closes all six pipe handles before throwing when CreateProcessAsUserW fails”、“spawnSandboxedInherited closes thread, process, and kill-on-close job before throwing when ResumeThread fails”、“spawnSandboxedInherited TERMINATES the suspended child before closing handles when AssignProcessToJobObject fails”、“getTempPath buffer defense”、“throws a clear error instead of decoding a buffer GetTempPathW never wrote”;源码顶部原注释(英文,仅作回查线索):Failure-path unit tests with minimal stub binding tables: the spawn helpers must close every handle they created before throwing, and getTempPath must refuse to decode a buffer GetTempPathW never wrote. Pure stubs — no real Win32 calls, so these run on ever...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/ffi.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“errorText”、“decodes the formatted UTF-16 message and trims it”、“returns an empty string when FormatMessageW formats nothing”、“getTempPath”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“errorText”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“FFI helper tests with stub binding tables (the failure-paths.spec.ts pattern): error formatting and temp-path decoding defenses, the last-error throwers' detail fallback, pointer decode NULL handling, and the bounded SID comparison's early exits. Pure stubs...”;固定提交中扫描到的声明包括 formatApicraftSid;本地静态 import 图显示它直接依赖 3 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/win32-abi.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 202 行;扫描到的声明包括 formatApicraftSid;扫描到的测试主题包括 “errorText”、“decodes the formatted UTF-16 message and trims it”、“returns an empty string when FormatMessageW formats nothing”、“getTempPath”、“decodes the NUL-terminated temp path GetTempPathW wrote”、“reports the Win32 failure when GetTempPathW writes nothing”;源码顶部原注释(英文,仅作回查线索):FFI helper tests with stub binding tables (the failure-paths.spec.ts pattern): error formatting and temp-path decoding defenses, the last-error throwers' detail fallback, pointer decode NULL handling, and the bounded SID comparison's early exits. Pure stubs...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/grant-failure-paths.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、路径的具体场景,包括“AclWriteGrant failure paths”、“create fails closed: a SID parse failure throws before anything is granted”、“create fails closed: a null SID pointer is rejected”、“dispose aggregates a failing revocation into an AggregateError (best-effort cleanup)”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“AclWriteGrant failure paths”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“AclWriteGrant failure-path tests with stub binding tables (the failure-paths.spec.ts pattern): create fails closed on SID-parse failure, dispose aggregates revocation and SID-free failures into an AggregateError. Pure stubs — no real Win32 calls, so these r...”;固定提交中扫描到的声明包括 grantThenFailApi;本地静态 import 图显示它直接依赖 2 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 100 行;扫描到的声明包括 grantThenFailApi;扫描到的测试主题包括 “AclWriteGrant failure paths”、“create fails closed: a SID parse failure throws before anything is granted”、“create fails closed: a null SID pointer is rejected”、“dispose aggregates a failing revocation into an AggregateError (best-effort cleanup)”、“dispose aggregates a failing SID free into an AggregateError”;源码顶部原注释(英文,仅作回查线索):AclWriteGrant failure-path tests with stub binding tables (the failure-paths.spec.ts pattern): create fails closed on SID-parse failure, dispose aggregates revocation and SID-free failures into an AggregateError. Pure stubs — no real Win32 calls, so these r...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/grant.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“create parses the SID fail-closed: a malformed SID throws before anything is granted”、“add materializes the ACE (idempotently) and reports grant order; dispose revokes revoca...”、“two grants with different SIDs coexist and revoke independently”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“create parses the SID fail-closed: a malformed SID throws before anything is granted”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“AclWriteGrant tests: the server-side grant materialization — SID parsing fail-closed, ACE add/dispose round-trip against the REAL directory DACL (observed through icacls, the operator's own tool), the recorded path order, and the standing/revocable lifecycl...”;固定提交中扫描到的声明包括 icaclsTextscratch;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 77 行;扫描到的声明包括 icaclsTextscratch;扫描到的测试主题包括 “create parses the SID fail-closed: a malformed SID throws before anything is granted”、“add materializes the ACE (idempotently) and reports grant order; dispose revokes revocable paths and keeps standing paths standing”、“two grants with different SIDs coexist and revoke independently”;源码顶部原注释(英文,仅作回查线索):AclWriteGrant tests: the server-side grant materialization — SID parsing fail-closed, ACE add/dispose round-trip against the REAL directory DACL (observed through icacls, the operator's own tool), the recorded path order, and the standing/revocable lifecycl...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/index-failure-paths.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、路径的具体场景,包括“AclSandbox constructor validation”、“rejects a writable directory that does not exist”、“resolves relative writable directories to absolute paths”、“rejects temp authority under read-only”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“AclSandbox constructor validation”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“AclSandbox orchestration failure-path tests: the win32 resolver is mocked to hand each test a stub binding table, so every checked Win32 call in init/spawn/dispose has a failing counterpart without opening real token or ACL handles. Constructor validation, ...”;固定提交中扫描到的声明包括 scratchhappyStubs;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 448 行;扫描到的声明包括 scratchhappyStubs;扫描到的测试主题包括 “AclSandbox constructor validation”、“rejects a writable directory that does not exist”、“resolves relative writable directories to absolute paths”、“rejects temp authority under read-only”、“rejects a temp SID when temp writes are disabled”、“AclSandbox init”;源码顶部原注释(英文,仅作回查线索):AclSandbox orchestration failure-path tests: the win32 resolver is mocked to hand each test a stub binding table, so every checked Win32 call in init/spawn/dispose has a failing counterpart without opening real token or ACL handles. Constructor validation, ...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/path-boundary.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、路径的具体场景,包括“Windows ACL temp path boundary”、“rejects a temp root equal to or below the workspace”、“accepts a temp parent above the workspace because a fresh child is a sibling”、“requires an actual private temp directory to be disjoint in either direction”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“Windows ACL temp path boundary”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Canonical path-overlap checks that keep workspace and temp capabilities separate.”;固定提交中扫描到的声明包括 scratch;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/path-boundary.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/path-boundary.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 65 行;扫描到的声明包括 scratch;扫描到的测试主题包括 “Windows ACL temp path boundary”、“rejects a temp root equal to or below the workspace”、“accepts a temp parent above the workspace because a fresh child is a sibling”、“requires an actual private temp directory to be disjoint in either direction”;源码顶部原注释(英文,仅作回查线索):Canonical path-overlap checks that keep workspace and temp capabilities separate.。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/probe.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“allows writes only in granted directories and denies the escape write”、“fails closed when the write SID cannot be parsed (no unrestricted fallback)”、“failed init clears provisional temp state before a retry”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“allows writes only in granted directories and denies the escape write”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“End-to-end probe of the ACL write-restriction sandbox, using the same probes as the POC verification harness: the confined child must be able to write into the granted target and temp directories, must be DENIED writing anywhere else, and (documented bounda...”;固定提交中扫描到的声明包括 pwshAvailable;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 110 行;扫描到的声明包括 pwshAvailable;扫描到的测试主题包括 “allows writes only in granted directories and denies the escape write”、“fails closed when the write SID cannot be parsed (no unrestricted fallback)”、“failed init clears provisional temp state before a retry”;源码顶部原注释(英文,仅作回查线索):End-to-end probe of the ACL write-restriction sandbox, using the same probes as the POC verification harness: the confined child must be able to write into the granted target and temp directories, must be DENIED writing anywhere else, and (documented bounda...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/provider-chain.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“windows-acl win32 chain (LocalSandboxProvider)”、“agentless workspace-write: runner argv prefix, temp root, mode flag, partial enforcemen...”、“read-only: same runner and contract, read-only mode flag”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“windows-acl win32 chain (LocalSandboxProvider)”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“The win32 chain's argv contract, denial dialect, and runner-failure rules, exercised through the REAL LocalSandboxProvider.confine() with an injected platform and runner argv prefix. Platform-independent assertions: they run in every CI lane (Windows includ...”;固定提交中扫描到的声明包括 setup;本地静态 import 图显示它直接依赖 3 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox/src/index.tsvendor/cordis/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-local/src/index.tspackages/sandbox/sandbox/src/index.tsvendor/cordis/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 58 行;扫描到的声明包括 setup;扫描到的测试主题包括 “windows-acl win32 chain (LocalSandboxProvider)”、“agentless workspace-write: runner argv prefix, temp root, mode flag, partial enforcement, ACL denial dialect”、“read-only: same runner and contract, read-only mode flag”;源码顶部原注释(英文,仅作回查线索):The win32 chain's argv contract, denial dialect, and runner-failure rules, exercised through the REAL LocalSandboxProvider.confine() with an injected platform and runner argv prefix. Platform-independent assertions: they run in every CI lane (Windows includ...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/quote.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“quoteArg”、“parses quoteArg+join back to the exact original argv”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“quoteArg”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“quoteArg unit tests plus a round-trip through the REAL CommandLineToArgvW parser (shell32.dll, shellapi.h line ~867: LPWSTR *CommandLineToArgvW(LPCWSTR lpCmdLine, int *pNumArgs)) on win32. CommandLineToArgvW applies the documented backslash rule (2n backsla...”;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/spawn.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/spawn.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 88 行;扫描到的测试主题包括 “quoteArg”、“parses quoteArg+join back to the exact original argv”;源码顶部原注释(英文,仅作回查线索):quoteArg unit tests plus a round-trip through the REAL CommandLineToArgvW parser (shell32.dll, shellapi.h line ~867: LPWSTR *CommandLineToArgvW(LPCWSTR lpCmdLine, int *pNumArgs)) on win32. CommandLineToArgvW applies the documented backslash rule (2n backsla...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/runner.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、运行驱动的具体场景,包括“workspace-write: the confined child writes granted directories only”、“read-only: no write-SID grants — workspace/temp writes denied, reads and $null redirect...”、“workspace-write: Remove-Item and Rename-Item succeed in the granted workspace (DELETE +...”、“paired SIDs: the runner trusts caller-owned private-temp grants and materializes nothin...”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“workspace-write: the confined child writes granted directories only”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“End-to-end runner tests: spawn the REAL runner entry through tsx (exactly the argv shape dsh-sandbox-local's confine() builds), with piped stdio inherited through the runner into the confined child — the same chain a production confined execution walks.”;固定提交中扫描到的声明包括 pwshAvailablerunRunner;本地静态 import 图显示它直接依赖 2 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/index.tspackages/shell/pwsh-local/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/index.tspackages/shell/pwsh-local/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 461 行;扫描到的声明包括 pwshAvailablerunRunner;扫描到的测试主题包括 “workspace-write: the confined child writes granted directories only”、“read-only: no write-SID grants — workspace/temp writes denied, reads and $null redirection fine, CIM unavailable”、“workspace-write: Remove-Item and Rename-Item succeed in the granted workspace (DELETE + FILE_DELETE_CHILD)”、“paired SIDs: the runner trusts caller-owned private-temp grants and materializes nothing itself”、“temp capabilities isolate sibling sessions that share one workspace SID”、“agentless workspace-write creates a fresh private temp per call and removes it on exit”;源码顶部原注释(英文,仅作回查线索):End-to-end runner tests: spawn the REAL runner entry through tsx (exactly the argv shape dsh-sandbox-local's confine() builds), with piped stdio inherited through the runner into the confined child — the same chain a production confined execution walks.。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/token-failure-paths.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱、路径的具体场景,包括“openCurrentProcessToken failure paths”、“reports when OpenProcess yields no handle”、“closes the process handle and reports when OpenProcessToken fails”、“reports a failed CloseHandle of the process handle”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“openCurrentProcessToken failure paths”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Restricted-token failure-path tests with stub binding tables (the failure-paths.spec.ts pattern): every checked Win32 call in the token pipeline — open, logon-SID scan, well-known SID creation, default-DACL merge, restricted-token creation — has a failing c...”;固定提交中扫描到的声明包括 logonApidaclApi;本地静态 import 图显示它直接依赖 4 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/token.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/errors.tspackages/sandbox/sandbox-windows-acl/src/ffi.tspackages/sandbox/sandbox-windows-acl/src/token.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 436 行;扫描到的声明包括 logonApidaclApi;扫描到的测试主题包括 “openCurrentProcessToken failure paths”、“reports when OpenProcess yields no handle”、“closes the process handle and reports when OpenProcessToken fails”、“reports a failed CloseHandle of the process handle”、“rejects a NULL token handle after a successful OpenProcessToken”、“findLogonSid failure paths”;源码顶部原注释(英文,仅作回查线索):Restricted-token failure-path tests with stub binding tables (the failure-paths.spec.ts pattern): every checked Win32 call in the token pipeline — open, logon-SID scan, well-known SID creation, default-DACL merge, restricted-token creation — has a failing c...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tests/workspace-sid.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“workspaceWriteSid”、“derives a stable capability-shaped SID per workspace path”、“derives distinct identities for distinct workspaces”、“is byte-sensitive: the canonical path is the caller\”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“workspaceWriteSid”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“workspaceWriteSid tests: the per-workspace write identity is deterministic (the same canonical path always derives the same SID — the property the cross-session grant reuse rests on), capability-shaped, distinct across workspaces, and byte-sensitive (the ca...”;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.mdpackages/sandbox/sandbox-windows-acl/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox-windows-acl/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 43 行;扫描到的测试主题包括 “workspaceWriteSid”、“derives a stable capability-shaped SID per workspace path”、“derives distinct identities for distinct workspaces”、“is byte-sensitive: the canonical path is the caller\”、“tempWriteSid”、“derives a stable domain-separated SID per private temp path”;源码顶部原注释(英文,仅作回查线索):workspaceWriteSid tests: the per-workspace write identity is deterministic (the same canonical path always derives the same SID — the property the cross-session grant reuse rests on), capability-shaped, distinct across workspaces, and byte-sensitive (the ca...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/tsdown.config.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:构建或测试配置
  • 这个文件有什么用:它告诉工具链怎样处理沙箱:从哪里开始、使用哪个环境、解析哪些依赖以及输出什么产物;这些规则集中后,构建和测试才可重复。
  • 为什么这样设计:工具链配置独立于业务实现,构建、测试和发布可以复用同一套入口规则;改配置时也能单独看出运行环境变化。
  • 文件级设计证据:本次固定提交归档没有扫描到顶部注释、顶层声明或专门的结构线索;本地静态 import 图显示它直接依赖 0 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.md
  • 对应测试:没有确认到直接测试;公共入口可能仍有间接覆盖。
  • 测试关联依据:固定提交中没有找到直接或传递的本地静态 import,也没有找到明显的同包同名测试;公共入口可能仍有间接覆盖。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md,再读本配置/脚本,沿着所在包的入口或服务确认它如何影响入口和产物,最后对照对应 gate 或快照测试。
  • 代码证据:固定提交归档实际读取结果:约 16 行。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox-windows-acl/verify/abi-probe.cpp

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:Windows ABI 探针
  • 这个文件有什么用:它读取实际 MinGW Windows 头文件中的 sizeof、offsetof 和枚举值,为 Node.js/Koffi FFI 定义提供 ABI 事实;它是验证探针,不是生产沙箱实现。
  • 为什么这样设计:FFI 的结构体布局和枚举值不能靠手工猜测;在目标 MinGW 头文件环境中编译并打印 sizeof、offsetof 和枚举值,再由 probe 测试与 Node.js/Koffi 定义交叉核对,可以把 ABI 漂移尽早暴露。
  • 文件级设计证据:源码顶部注释把它定位为“ABI probe: prints sizeof/offsetof/enum values from the actual MinGW Windows headers on this machine. These numbers are the source of truth for the koffi FFI definitions in the Node.js port.”;本地静态 import 图显示它直接依赖 0 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox-windows-acl/README.md
  • 对应测试:packages/sandbox/sandbox-windows-acl/tests/probe.spec.ts
  • 测试关联依据:按同包文件名保守推断,未确认直接 import;这不是完整覆盖证明。
  • 阅读顺序:先读 packages/sandbox/sandbox-windows-acl/README.md、Node/Koffi FFI 定义和实际头文件,再读当前探针,最后对照 packages/sandbox/sandbox-windows-acl/tests/probe.spec.ts,确认打印出来的布局和枚举值确实被交叉核对。
  • 代码证据:固定提交归档实际读取结果:约 195 行;源码顶部原注释(英文,仅作回查线索):ABI probe: prints sizeof/offsetof/enum values from the actual MinGW Windows headers on this machine. These numbers are the source of truth for the koffi FFI definitions in the Node.js port.。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox

packages/sandbox/sandbox/src/escalation.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:沙箱策略实现
  • 这个文件有什么用:这个文件实现沙箱的路径、权限、进程或平台策略,限制工具能力的影响范围。
  • 为什么这样设计:沙箱策略是工具执行的安全边界,集中处理权限和平台行为可以让默认拒绝、升级和清理保持一致。
  • 文件级设计证据:源码顶部注释把它定位为“The escalation vocabulary and choreography shared by every sandbox-enforcing tool family (@deepseek-ai/dsh-tool-bash, @deepseek-ai/dsh-tool-fs): the strictly-wider ladder, the argument-pairing validation, the model-facing denial/hint markers, and approveEsc...”;固定提交中扫描到的声明包括 WIDER_MODESESCALATION_TARGETSvalidateEscalationArgssandboxDenialMarkerescalationHintMarker;本地静态 import 图显示它直接依赖 2 个源文件,并被 1 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/llm/llm/src/index.tspackages/sandbox/sandbox/src/index.ts
  • 对应测试:间接测试线索(通过本地 import 链,非直接覆盖):apps/cli/tests/web-agent-presets.e2e.tsapps/web/tests/agent-preset-selection.e2e.tsapps/web/tests/permission-policy-context.e2e.tsapps/web/tests/pwsh-terminal.e2e.tsapps/web/tests/shipped-composition.e2e.tsapps/web/tests/sidebar-subagent-activity.e2e.ts
  • 测试关联依据:固定提交源码中的本地静态 import 传递引用;这些测试通过包入口或中间模块到达本文件,不等于本文件被直接覆盖。
  • 阅读顺序:先读 packages/sandbox/sandbox/README.md 和入口,再读当前实现,沿着 packages/llm/llm/src/index.tspackages/sandbox/sandbox/src/index.tspackages/sandbox/sandbox/src/index.ts 确认输入输出,最后对照 apps/cli/tests/web-agent-presets.e2e.tsapps/web/tests/agent-preset-selection.e2e.tsapps/web/tests/permission-policy-context.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 189 行;扫描到的声明包括 WIDER_MODESESCALATION_TARGETSvalidateEscalationArgssandboxDenialMarkerescalationHintMarkerEscalationOutcomeEscalationApproverEscalationApproval;源码顶部原注释(英文,仅作回查线索):The escalation vocabulary and choreography shared by every sandbox-enforcing tool family (@deepseek-ai/dsh-tool-bash, @deepseek-ai/dsh-tool-fs): the strictly-wider ladder, the argument-pairing validation, the model-facing denial/hint markers, and approveEsc...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox/src/index.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:模块入口
  • 这个文件有什么用:它把沙箱相关的公开能力集中导出,并决定调用者可以依赖哪些边界;调用者因此不必记住所有内部文件。
  • 为什么这样设计:入口文件把公开边界固定下来,内部文件可以继续拆分或替换;其他包只依赖入口暴露的 API,依赖方向更稳定。
  • 文件级设计证据:源码顶部注释把它定位为“Service Definition for the same-world process-confinement capability seam: wrap exact subprocess argv under a host-path file policy. Containers, microVMs, and remote execution replace the surrounding capability seam instead; this service shares the host ker...”;固定提交中扫描到的声明包括 SandboxModeConfinedSandboxModeSandboxExecutionPolicySandboxEnforcementSandboxPolicy;本地静态 import 图显示它直接依赖 5 个源文件,并被 48 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/core/session/src/index.tspackages/llm/llm/src/index.tspackages/sandbox/sandbox/src/escalation.tsapps/web/tests/permission-policy-context.e2e.ts
  • 对应测试:apps/web/tests/permission-policy-context.e2e.tsapps/web/tests/shipped-composition.e2e.tspackages/fs/fs-sandbox/tests/fs-sandbox.spec.tspackages/fs/tool-fs/tests/tools.spec.tspackages/interaction/permission-presets/tests/permission-presets.spec.tspackages/sandbox/sandbox-local/tests/acl-grants.spec.ts
  • 测试关联依据:固定提交源码中的本地静态 import 直接引用;测试用例直接导入了这个源文件。
  • 测试支持:apps/web/tests/scaffold.tsapps/web/tests/support.ts
  • 阅读顺序:先读 packages/sandbox/sandbox/README.md、入口和消费者,再读当前契约,沿着 apps/web/tests/permission-policy-context.e2e.tsapps/web/tests/shipped-composition.e2e.tsexamples/acp-agent/tests/fixtures/partial-landlock-sandbox.ts 看它怎样约束运行时,最后对照 apps/web/tests/permission-policy-context.e2e.tsapps/web/tests/shipped-composition.e2e.tspackages/fs/fs-sandbox/tests/fs-sandbox.spec.ts
  • 代码证据:固定提交归档实际读取结果:约 178 行;扫描到的声明包括 SandboxModeConfinedSandboxModeSandboxExecutionPolicySandboxEnforcementSandboxPolicyRunnerFailureRuleConfinedArgvSANDBOX_UNAVAILABLE;源码顶部原注释(英文,仅作回查线索):Service Definition for the same-world process-confinement capability seam: wrap exact subprocess argv under a host-path file policy. Containers, microVMs, and remote execution replace the surrounding capability seam instead; this service shares the host ker...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox/src/invariant.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:运行时不变量
  • 这个文件有什么用:它检查沙箱必须始终成立的条件,在错误刚出现时报告,而不是等到更深层才出现难以解释的结果。
  • 为什么这样设计:把不变量集中在一个位置,调用者和测试就能用同一条规则检查状态;错误在边界处报告,比在后续 UI 或网络请求中才暴露更容易修复。
  • 文件级设计证据:源码顶部注释把它定位为“Package-owned invariant companion for @deepseek-ai/dsh-sandbox. @module @deepseek-ai/dsh-sandbox/invariant”;固定提交中扫描到的声明包括 nameinjectapply;本地静态 import 图显示它直接依赖 2 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/runtime-diagnostics/invariants/src/index.tsvendor/cordis/src/index.ts
  • 对应测试:没有确认到直接测试;公共入口可能仍有间接覆盖。
  • 测试关联依据:固定提交中没有找到直接或传递的本地静态 import,也没有找到明显的同包同名测试;公共入口可能仍有间接覆盖。
  • 阅读顺序:先读相关类型和事件,再读当前状态或存储实现,沿着 packages/runtime-diagnostics/invariants/src/index.tsvendor/cordis/src/index.ts 和所在包的入口或服务理解状态变化,最后对照同包中与它同名或覆盖相近场景的测试。
  • 代码证据:固定提交归档实际读取结果:约 30 行;扫描到的声明包括 nameinjectapply;源码顶部原注释(英文,仅作回查线索):Package-owned invariant companion for @deepseek-ai/dsh-sandbox. @module @deepseek-ai/dsh-sandbox/invariant。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox/src/roots.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:路径边界
  • 这个文件有什么用:它负责沙箱的解析、规范化和安全约束,统一处理不同平台的路径差异与越界检查。
  • 为什么这样设计:路径是跨平台且涉及安全的输入,集中规范化和越界判断可以避免不同调用方产生不一致的文件目标。
  • 文件级设计证据:源码顶部注释把它定位为“The writable-root derivation shared by every enforcement dialect that expresses a mode as a canonical allow-list: workspace-write means "the workspace root plus the platform temp areas", and this module is that meaning's one home. The Seatbelt profile (@dee...”;固定提交中扫描到的声明包括 canonicalPathwritableRoots;本地静态 import 图显示它直接依赖 1 个源文件,并被 1 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/sandbox/sandbox/src/index.ts
  • 对应测试:间接测试线索(通过本地 import 链,非直接覆盖):apps/cli/tests/web-agent-presets.e2e.tsapps/web/tests/agent-preset-selection.e2e.tsapps/web/tests/permission-policy-context.e2e.tsapps/web/tests/pwsh-terminal.e2e.tsapps/web/tests/shipped-composition.e2e.tsapps/web/tests/sidebar-subagent-activity.e2e.ts
  • 测试关联依据:固定提交源码中的本地静态 import 传递引用;这些测试通过包入口或中间模块到达本文件,不等于本文件被直接覆盖。
  • 阅读顺序:先读 packages/sandbox/sandbox/README.md 和入口,再读当前实现,沿着 packages/sandbox/sandbox/src/index.tspackages/sandbox/sandbox/src/index.ts 确认输入输出,最后对照 apps/cli/tests/web-agent-presets.e2e.tsapps/web/tests/agent-preset-selection.e2e.tsapps/web/tests/permission-policy-context.e2e.ts
  • 代码证据:固定提交归档实际读取结果:约 55 行;扫描到的声明包括 canonicalPathwritableRoots;源码顶部原注释(英文,仅作回查线索):The writable-root derivation shared by every enforcement dialect that expresses a mode as a canonical allow-list: workspace-write means "the workspace root plus the platform temp areas", and this module is that meaning's one home. The Seatbelt profile (@dee...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox/tests/escalation.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“the strictly-wider ladder”、“read-only escalates to either wider mode; workspace-write only to full access”、“the target enum is the closed set every session could escalate TO (read-only is the floor)”、“validateEscalationArgs”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“the strictly-wider ladder”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Tests for the shared escalation vocabulary and choreography: the strictly- wider ladder, the argument-pairing validation, the model-facing markers, and approveEscalation's ordered fail-closed sequence. Both enforcing tool families (dsh-tool-bash, dsh-tool-f...”;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 111 行;扫描到的测试主题包括 “the strictly-wider ladder”、“read-only escalates to either wider mode; workspace-write only to full access”、“the target enum is the closed set every session could escalate TO (read-only is the floor)”、“validateEscalationArgs”、“accepts neither field, or both with a non-empty justification”、“rejects one field without the other, and a blank justification”;源码顶部原注释(英文,仅作回查线索):Tests for the shared escalation vocabulary and choreography: the strictly- wider ladder, the argument-pairing validation, the model-facing markers, and approveEscalation's ordered fail-closed sequence. Both enforcing tool families (dsh-tool-bash, dsh-tool-f...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox/tests/roots.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“canonicalPath”、“resolves symlinks (an existing path realpaths)”、“returns the spelling as-is when the path cannot be resolved (conservative — matches not...”、“writableRoots”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“canonicalPath”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Tests for the writable-root derivation: the mode's meaning as a canonical allow-list. Pinned here so the fs fence and the Seatbelt profile — both deriving from writableRoots — cannot drift.”;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 39 行;扫描到的测试主题包括 “canonicalPath”、“resolves symlinks (an existing path realpaths)”、“returns the spelling as-is when the path cannot be resolved (conservative — matches nothing until it exists)”、“writableRoots”、“read-only grants nothing”、“workspace-write grants the workspace root plus the platform temp areas, canonical and deduplicated”;源码顶部原注释(英文,仅作回查线索):Tests for the writable-root derivation: the mode's meaning as a canonical allow-list. Pinned here so the fs fence and the Seatbelt profile — both deriving from writableRoots — cannot drift.。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec

packages/sandbox/sandbox/tests/vocabulary.spec.ts

  • 所属层:packages/sandbox:可复用的 Harness 功能包
  • 文件角色:测试用例
  • 这个文件有什么用:它用自动化测试检查沙箱的具体场景,包括“SandboxUnavailableError”、“carries the structured { name, code } identity consumers key on”、“names the refused mode and the operator escape hatches in its message”、“carries the runner detail when the failure is discovered at execution time”;这些断言把“应该发生什么”变成可以重复运行的证据。
  • 为什么这样设计:把测试主题“SandboxUnavailableError”写成独立测试用例,读者可以从输入、触发动作和断言反推实现的不变量;不同回归问题也不会互相遮蔽。
  • 文件级设计证据:源码顶部注释把它定位为“Vocabulary-contract tests for the sandbox seam: the fail-closed error's structured identity is what tool results and consumers key on, so its shape is pinned here, next to the vocabulary that owns it. Provider behavior is each implementation's suite (dsh-sa...”;本地静态 import 图显示它直接依赖 1 个源文件,并被 0 个源文件直接引用。
  • 直接协作者:packages/sandbox/sandbox/README.mdpackages/sandbox/sandbox/src/index.ts
  • 对应测试:本文件本身就是测试用例。
  • 测试关联依据:本文件本身就是测试用例,不把同目录的其他测试冒充成它的“对应测试”。
  • 阅读顺序:先看它直接导入的被测实现 packages/sandbox/sandbox/src/index.ts,再读本文件的测试主题、输入和断言;最后对照测试支持和失败输出。
  • 代码证据:固定提交归档实际读取结果:约 35 行;扫描到的测试主题包括 “SandboxUnavailableError”、“carries the structured { name, code } identity consumers key on”、“names the refused mode and the operator escape hatches in its message”、“carries the runner detail when the failure is discovered at execution time”;源码顶部原注释(英文,仅作回查线索):Vocabulary-contract tests for the sandbox seam: the fail-closed error's structured identity is what tool results and consumers key on, so its shape is pinned here, next to the vocabulary that owns it. Provider behavior is each implementation's suite (dsh-sa...。
  • 固定版本:源码链接固定到官方提交 aa6c361a972c8369148dea7380bb5c21c24e07ec