dsh-plugin-wsl-env 0.26.3 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/CONTRIBUTING.md +32 -25
  3. package/CONTRIBUTING.zh.md +3 -2
  4. package/README.md +1 -1
  5. package/SECURITY.md +21 -7
  6. package/SECURITY.zh.md +18 -5
  7. package/SUPPORT.md +2 -2
  8. package/SUPPORT.zh.md +2 -2
  9. package/client.js +351 -48
  10. package/cordis.patch.yml +26 -10
  11. package/docs/AGENT-PROTOCOL-V7.md +4 -2
  12. package/docs/API.md +3 -1
  13. package/docs/API.zh.md +3 -1
  14. package/docs/ARCHITECTURE.md +22 -4
  15. package/docs/ARCHITECTURE.zh.md +18 -4
  16. package/docs/CONFIGURATION.md +117 -17
  17. package/docs/CONFIGURATION.zh.md +97 -11
  18. package/docs/DIAGNOSTICS.md +22 -11
  19. package/docs/DIAGNOSTICS.zh.md +17 -9
  20. package/docs/LIMITATIONS.md +27 -4
  21. package/docs/LIMITATIONS.zh.md +20 -3
  22. package/docs/MIGRATION.md +2 -2
  23. package/docs/MIGRATION.zh.md +2 -2
  24. package/docs/PARITY.md +3 -1
  25. package/docs/QUICKSTART.md +31 -20
  26. package/docs/QUICKSTART.zh.md +16 -9
  27. package/docs/README.zh.md +1 -1
  28. package/docs/RELEASING.md +25 -3
  29. package/docs/REQUIREMENTS.zh.md +7 -6
  30. package/docs/ROADMAP-1.0.md +11 -7
  31. package/lib/agent-confined.d.ts +9 -1
  32. package/lib/agent-confined.js +3 -3
  33. package/lib/agent.d.ts +54 -18
  34. package/lib/agent.js +86 -19
  35. package/lib/bwrap.d.ts +16 -0
  36. package/lib/bwrap.js +9 -0
  37. package/lib/fs-routing.d.ts +6 -0
  38. package/lib/fs-routing.js +7 -0
  39. package/lib/fs-substrate.d.ts +1 -1
  40. package/lib/fs-substrate.js +10 -18
  41. package/lib/fsio-agent.d.ts +4 -0
  42. package/lib/fsio-agent.js +37 -10
  43. package/lib/listing.d.ts +2 -2
  44. package/lib/listing.js +5 -4
  45. package/lib/messages.d.ts +70 -0
  46. package/lib/messages.js +80 -0
  47. package/lib/open-in-app.js +12 -9
  48. package/lib/picker.d.ts +4 -1
  49. package/lib/picker.js +35 -11
  50. package/lib/plugin-update.d.ts +212 -0
  51. package/lib/plugin-update.js +283 -0
  52. package/lib/ports.js +8 -1
  53. package/lib/provider-common.d.ts +22 -0
  54. package/lib/provider-common.js +18 -0
  55. package/lib/provider-marker.d.ts +23 -0
  56. package/lib/provider-marker.js +21 -0
  57. package/lib/sandbox-core.d.ts +2 -0
  58. package/lib/sandbox-core.js +5 -3
  59. package/lib/session-runtime.d.ts +10 -1
  60. package/lib/session-runtime.js +3 -1
  61. package/lib/shell-env.js +1 -1
  62. package/lib/socket-isolation.d.ts +103 -0
  63. package/lib/socket-isolation.js +166 -0
  64. package/lib/status.d.ts +21 -8
  65. package/lib/status.js +61 -23
  66. package/lib/subprocess.d.ts +3 -0
  67. package/lib/subprocess.js +5 -0
  68. package/lib/takeover-report.js +4 -11
  69. package/lib/update-check.d.ts +49 -9
  70. package/lib/update-check.js +81 -28
  71. package/lib/watcher.d.ts +1 -1
  72. package/lib/watcher.js +1 -1
  73. package/lib/wsl-doctor-command.d.ts +6 -2
  74. package/lib/wsl-doctor-command.js +24 -15
  75. package/lib/wsl-doctor-tool.js +2 -0
  76. package/lib/wsl-filesystem.d.ts +53 -12
  77. package/lib/wsl-filesystem.js +90 -31
  78. package/lib/wsl-shell.d.ts +109 -40
  79. package/lib/wsl-shell.js +128 -54
  80. package/package.json +8 -3
  81. package/scripts/doctor.mjs +199 -3
  82. package/scripts/profile-preset.mjs +10 -2
@@ -30,8 +30,9 @@ dsh headless "run the tests" # 单任务、输出答案后退出
30
30
  | Node `^22.19.0` 或 `>=24.0.0` | 仅源码/开发工作需要 | 使用已发布的插件时,发行版内不需要 Node |
31
31
 
32
32
  手边没有终端?有几条不依赖终端的路:侧边栏的 **WSL 环境** 面板按发行版运行
33
- doctor 快速检查,结果以状态徽标、编号的待修项与告警列出,并在存在相应可修复项时把对插件自有状态
34
- (残留 scope、损坏的 agent 缓存)的完整运行标为 **修复**,否则标为 **完整检查**;在输入框里输入
33
+ doctor 快速检查,结果以状态徽标、编号的待修项与告警列出;每行固定提供 **快速检查**
34
+ 与 **完整检查**,后者以 `--fix-owned` 运行完整 doctor,并修复插件自有状态
35
+ (残留 scope、损坏的 agent 缓存);两个按钮再次点击即再次执行;在输入框里输入
35
36
  `/wsl-doctor [quick|full|<分区>]` 同样在宿主侧执行、直接渲染在 UI,不进模型
36
37
  对话、零 token;在会话里请求诊断,模型会运行本插件挂载的 `wsl_doctor` 工具,
37
38
  判定落在对话里;会话启动预检在每次会话打开时把同样的判定写进日志,只有 blocked
@@ -44,7 +45,7 @@ doctor(`scripts/doctor.mjs`,或在检出目录中运行 `pnpm run doctor`)
44
45
  读取,无需单独确认。doctor 默认只读,除非传入 `--fix`(清理过期 scope、清理损坏的
45
46
  agent 缓存,两者都会复检;以及确认后的 Windows git 信任)或
46
47
  `--fix --install`(安装软件包,需确认);`--fix-owned` 把修复限定在
47
- 插件自有状态(面板的“修复”动作);
48
+ 插件自有状态(面板的“完整检查”动作);
48
49
  `--bundle <路径>` 写出可附加到问题报告的诊断文件(`--redact`
49
50
  将其中的路径脱敏)。运行可以收窄范围——`--quick` 只探首条命令的前置项
50
51
  与一次合并的可选工具探测(约 10 秒),`--sections <分区清单>`(逗号分隔)
@@ -63,9 +64,11 @@ agent 缓存,两者都会复检;以及确认后的 Windows git 信任)或
63
64
  `preset-wsl` 块——当某个层直接按 id 指向 `wsl-shell`/`wsl-fs` 时,
64
65
  `pnpm run preset --check <patch>` 会明确报错。
65
66
 
66
- 插件不修改已安装的 `resources/app.asar`:应用升级不受影响,插件升级只需重新
67
- 安装并重启。升级 = 在 Plugins 页重新安装后重启(harness 无热重载);卸载也在
68
- Plugins 页,之后可删 `~/.cache/dsh-wsl`。曾为恢复预览加过 `workspace-files-wsl`
67
+ 插件不修改已安装的 `resources/app.asar`:应用升级不受影响。侧栏 **WSL 环境**
68
+ 面板的「插件版本」卡片显示已安装与运行中的版本,经宿主的插件管理器检查 registry,
69
+ 并在有更新的稳定版时提供「一键升级」;Plugins 页重新安装仍是备用路径。升级在
70
+ 重启后生效;宿主报告 HMR 已应用时,刷新页面即可。卸载在 Plugins 页,之后可删
71
+ `~/.cache/dsh-wsl`。曾为恢复预览加过 `workspace-files-wsl`
69
72
  临时覆盖的,升级后删除:插件不再挂载该行。
70
73
 
71
74
  ## 3. 打开 WSL 工作区
@@ -79,11 +82,15 @@ Plugins 页,之后可删 `~/.cache/dsh-wsl`。曾为恢复预览加过 `worksp
79
82
  两个发行版可以同时打开,各自拥有自己的环境。
80
83
 
81
84
  侧边栏的 **WSL 环境** 面板是诊断页:它列出已安装的发行版,可对单个发行版运行
82
- 一次 doctor 快速检查,显示 bwrap、systemd、Linger 等前置项是否正常;已检查的行提供一次完整 doctor(`--fix-owned`):存在可自动修复项(残留 session
83
- scope 或损坏的 agent 缓存)时标为 **修复**,否则标为 **完整检查**;行内还显示上次
85
+ 一次 doctor 快速检查,显示 bwrap、systemd、Linger 等前置项是否正常;顶部的
86
+ 「插件版本」卡片显示已安装与运行中的版本,并提供上文的一键升级;每行固定提供
87
+ “快速检查”和“完整检查”两个按钮,后者运行完整 doctor(`--fix-owned`),会修复
88
+ 插件自有状态(残留 session scope 或损坏的 agent 缓存);两个按钮在结果出现后
89
+ 仍保持原名,再次点击即再次执行;行内还显示上次
84
90
  检查时间、来源(手动,或页面加载时的后台复核)与结果结构(通过/告警/失败/
85
91
  信息/跳过,以及分区分布);最后一次结果会从本地存档恢复,正在运行的发行版会在
86
- 页面加载时后台复核;运行时按需清扫
92
+ 页面加载时后台复核;已检查行可“清除”该发行版的结果,卡片头部可“清除全部”;
93
+ 清除只删除本地存档,不探测、不修改发行版;运行时按需清扫
87
94
  残留 scope、清理缓存并逐一复检,其余告警保留各自的手动处理办法,不安装软件包、
88
95
  不改写 Windows 配置(检查会让停止的发行版启动,所以两种动作都只在点击时执行)。工作区仍在 **添加工作区** 里打开;选中发行版内的文件夹时,应用会问一次打开方式:**Remote WSL**(默认,命令、
89
96
  文件与终端都在发行版内)或 **Windows 访问**(把该文件夹当作普通 Windows 共享,经 9p
package/docs/README.zh.md CHANGED
@@ -43,7 +43,7 @@
43
43
  | systemd + Linger(默认会话沙箱需要) | `/etc/wsl.conf` 设 `[boot] systemd=true`,`wsl --shutdown`,执行一次 `loginctl enable-linger "$USER"`;无 systemd 时设 `sessionSandbox` 为 `auto` 或 `false` |
44
44
  | 可选:`ripgrep`、`git`、`inotify-tools` | `pnpm run bootstrap <发行版>` 打印安装命令 |
45
45
 
46
- 插件不修改已安装的 `resources/app.asar`。升级 = 重新安装后重启;卸载在 Plugins 页面,之后可删 `~/.cache/dsh-wsl`。细节见 [QUICKSTART.zh.md](QUICKSTART.zh.md)。
46
+ 插件不修改已安装的 `resources/app.asar`。侧栏 **WSL 环境** 面板显示已安装与运行中的插件版本,经宿主的插件管理器检查 registry,并在有更新的稳定版时提供一键升级;在 Plugins 页重新安装仍是备用路径。升级在重启后生效;宿主报告 HMR 已应用时,刷新页面即可。卸载在 Plugins 页面,之后可删 `~/.cache/dsh-wsl`。细节见 [QUICKSTART.zh.md](QUICKSTART.zh.md)。
47
47
 
48
48
  ## 需要这个插件吗?
49
49
 
package/docs/RELEASING.md CHANGED
@@ -115,8 +115,30 @@ publish credential, so no npm token is stored in the repository.
115
115
  If trusted publishing is not configured, add an `NPM_TOKEN` repository secret and
116
116
  hand it to the Publish step in `.github/workflows/release.yml` — the step does not
117
117
  read it on its own, so add `env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}` to it.
118
- Configure required reviewers on the `npm-publish` environment to put a second
119
- person in front of every publish.
118
+ The `npm-publish` environment is the trusted-publishing binding and the audit
119
+ anchor for each run. **Required reviewers are deliberately not configured.**
120
+ This is a single-maintainer repository; the full gate chain and the tag/version
121
+ check still run before the upload, and the owner accepts that a mistaken tag can
122
+ publish without a second pair of eyes. Revisit the decision if a second
123
+ maintainer joins the release rotation.
124
+
125
+ ### Repository settings the workflow cannot verify
126
+
127
+ There is currently **no self-hosted runner registered** for this repository, so
128
+ the Windows matrix legs run on GitHub-hosted `windows-latest`. The nightly
129
+ `probes` schedule and its freshness heartbeat were removed on 2026-11-18: with
130
+ no runner, a scheduled run could only be a hosted no-op. The real-machine
131
+ evidence path is the local closed-app suite
132
+ (`test/probe/run-all-when-closed.sh --include-fs`, run with the app exited), or
133
+ the manual `probes` workflow once a self-hosted Windows+WSL runner is attached.
134
+
135
+ If a runner is added later, give it a custom `self-hosted-wsl` label rather than
136
+ the hosted `windows-latest` label, and update every matrix / `runs-on` /
137
+ fork-gate reference in `ci.yml` together.
138
+
139
+ The `npm-publish` environment has no required reviewers by decision, not by
140
+ oversight: see the paragraph above. Its presence is still required for npm
141
+ trusted publishing, so do not delete it while removing approval gates.
120
142
 
121
143
  ### Manual fallback
122
144
 
@@ -229,7 +251,7 @@ without watching this repository:
229
251
  on notable releases).
230
252
  - Content: the version, the two or three headline changes, the current
231
253
  verification snapshot in one line (unit tests, matrix, container and qemu
232
- legs, nightly probes), and the release link.
254
+ legs, the manual closed-app probe suite), and the release link.
233
255
  - Post it with the same GraphQL mutation the 2026-10-27 update used
234
256
  (`addDiscussionComment` on the discussion's node id) from a session that
235
257
  holds the maintainer's GitHub credentials — the release workflow's
@@ -7,7 +7,8 @@ docs/ 各篇里的行为承诺登记成带编号的需求条目,并给每条
7
7
  三个问题:**有哪些需求、在哪里规定、靠什么验证**。
8
8
 
9
9
  **基线**:本文核对于 `main` 2026-10-19(基线 0.12.0);0.22.0(2026-11-08)
10
- 复核了 doctor 与更新检查线(新增 R26–R28,R20 的测试文件数随发版刷新),
10
+ 复核了 doctor 与更新检查线(新增 R26–R28,R20 的测试文件数随发版刷新);
11
+ R29 的基线为 0.25.0(2026-11-11),R30 的基线为 0.26.0(2026-11-12)。
11
12
  其余条目仍以上次全表核验为准。每次发版,或 CI 配置、
12
13
  覆盖率阈值等可核验项变更后,本表须重新核验;一切以仓库现状为准。
13
14
 
@@ -50,10 +51,10 @@ docs/ 各篇里的行为承诺登记成带编号的需求条目,并给每条
50
51
  | R14 | bootstrap:bwrap/ripgrep 等的就地体检与安装 | README「Install」「Troubleshooting」;CONFIGURATION | ①②⑤:`--install` 与只读体检两式、体检对象、错误消息补救指引成文 | 0.7.4 起脚本随包(`files` 收录,补救指引在 npm 安装下可用) | 脚本本身无 CI 腿(真机排错路径覆盖) |
51
52
  | R15 | 错误码方言:每个 `FS_*` 码给出抛出者、含义、解除条件;`wsl.exe` 自身失败显式收编 | ARCHITECTURE「Error codes」表 | ①②:逐码三列成表;两类历史隐形失败(UTF-16 stdout、cwd 回退 exit 0)收编;`FS_OUTSIDE_DISTRO` 独立成码的理由明文 | `fs-decisions.test.mjs`、`fsio-agent.test.mjs`、`fs-substrate.test.mjs`、`provider.test.mjs`(断言码与消息) | — |
52
53
  | R16 | 对端 parity 合同:fsio 文本机制逐字节复刻钉死的对端版本 | PEER-PARITY 全文 | ①④⑥:钉版、验证方法(npm pack 逐函数比对)、验证日期、刻意分歧逐条声明、bump 钉版即重跑的维护规则 | `fsio-agent.test.mjs`(distro 内半区 canary);对端比对为手动方法 | 钉版升级后需重跑比对(维护规则) |
53
- | R17 | 常驻 agent 协议:ACK 计时看门狗、只读帧才重放、逐流输出上限、sha256 部署校验、租约存活、进程组两段杀 | CHANGELOG 0.3.0/0.6.0/0.7.3;PARITY Phase 1/Phase 3 | ①②④:每条健壮性属性有规格出处与实证记录;「EXEC/变异 FS 帧禁止盲重发」是写明的不变量 | `agent-protocol.test.mjs`(HELLO 版本+摘要)、`agent.test.mjs`、`agent-exec.test.mjs`(truncated 旗标)、`agent-fs-script.test.mjs`;probe:agent、probe:exec | — |
54
+ | R17 | 常驻 agent 协议:帧写出后的 ACK 握手超时与 ACK 计时执行看门狗、只读帧才重放、逐流输出上限、sha256 部署校验、租约存活、进程组两段杀 | CHANGELOG 0.3.0/0.6.0/0.7.3;PARITY Phase 1/Phase 3 | ①②④:每条健壮性属性有规格出处与实证记录;「EXEC/变异 FS 帧禁止盲重发」是写明的不变量 | `agent-protocol.test.mjs`(HELLO 版本+摘要)、`agent.test.mjs`、`agent-exec.test.mjs`(truncated 旗标)、`agent-fs-script.test.mjs`;probe:agent、probe:exec | — |
54
55
  | R18 | 配置面:每键默认值成文;层组合语义(整行替换、不深合并、后层胜) | CONFIGURATION;`cordis.patch.yml` 头注 | ⑤:随发键成表、未列表键点名;覆盖方式的正确心智模型(整行替换)成文 | `composition.test.mjs`(层组合);`style.mjs`(`files` 契约) | — |
55
56
  | R19 | 非目标集:不做什么与为什么 | LIMITATIONS 开篇原则;PARITY「Not applicable」 | ③:已知极限入册;不适用项「记下来免得像遗漏」 | —(文档性) | — |
56
- | R20 | 验证策略:三层(fake → 真脚本过真线 → 真机探针)+ CI 矩阵 + 覆盖率阈值 | ARCHITECTURE「Test layers」;README「Development」 | ④:CI 在 Node 22/24 × Linux/Windows 上跑 `pnpm test`,`pnpm run test:coverage` 只在 Node 24 上跑(门槛旗标需 Node 22.8);Node 20 有意排除(`engines` 下限);覆盖率阈值 85/84/70(行/分支/函数),测量集合覆盖 `test/` 下 50 个测试文件,且 `lib/*.js` 必须逐个实测或带理由豁免 | `pnpm test`、`pnpm run test:coverage`;CI(ci.yml) | 真机验证依赖 Windows 和可用的 WSL 发行版;非功能无量化目标(OI-1) |
57
+ | R20 | 验证策略:三层(fake → 真脚本过真线 → 真机探针)+ CI 矩阵 + 覆盖率阈值 | ARCHITECTURE「Test layers」;README「Development」 | ④:CI 在 Node 22/24 × Linux/Windows 上跑 `pnpm test`,`pnpm run test:coverage` 只在 Node 24 上跑(门槛旗标需 Node 22.8);Node 20 有意排除(`engines` 下限);覆盖率阈值 85/84/70(行/分支/函数),测量集合覆盖 `test/` 下 60 个测试文件,且 `lib/*.js` 必须逐个实测或带理由豁免 | `pnpm test`、`pnpm run test:coverage`;CI(ci.yml) | 真机验证依赖 Windows 和可用的 WSL 发行版;非功能无量化目标(OI-1) |
57
58
  | R21 | 安全过程:范围内外、响应时限、partial 属设计边界、凭据政策 | SECURITY 全文 | ②③⑥:范围、3/10/30 个工作日时限(标注「目标非合同」)、partial 定性、凭据零容忍成文 | —(过程性) | — |
58
59
  | R22 | 支持矩阵:Windows 10/11 + WSL2 + Node `^22.19.0 \|\| >=24.0.0` + peer 版本范围 | SUPPORT 全文 | ⑥:支持与不受支持清单、peer 范围及精确开发依赖成文;Node 20 在范围外(理由见 SUPPORT,`engines` 为准) | `peerDependencies`、`devDependencies` 与 `engines`(`package.json`);CI 矩阵(ci.yml) | 新 peer 版本仍需验证 |
59
60
  | R23 | 根平面 `ctx.fs` 按坐标路由:发行版 UNC 由发行版内 agent 服务(inotify 或轮询 watch),盘符路径留在宿主;接替随发的 `fs-sandbox` 行 | README「Architecture」;ARCHITECTURE「The root-plane filesystem takeover」;CONFIGURATION `fs-routing` 行;root-fs-routing.md(设计) | ①②③⑤:路由判定与接替理由(写围栏在根平面无消费者)成文;`distro` 的 `auto`/`default`/pin 三态、每个 UNC 目标由自身 distro 服务、pin 下拒外来路径,以及 `distroCwd`/`restrictToDistro`/`sandbox`/`maskWindowsDrive`/`watchMaxDepth` 逐键成表,且自成一行、不与会话级行联动;`sandbox` 失败关闭成文 | `fs-routing.test.mjs`(纯谓词与路径助手)、`provider.test.mjs`(per-distro substrate/worldPath) | 类本体无单测(需 DSH peers 与实机);由组合测试与真机探针覆盖 |
@@ -61,10 +62,10 @@ docs/ 各篇里的行为承诺登记成带编号的需求条目,并给每条
61
62
  | R25 | 安装/卸载/升级流:四步安装、幂等陷阱及补救、ES 模块重启须知 | README「Install」「Troubleshooting」 | ①③:每步预期输出、`add` 幂等性陷阱的补救(先 remove 再 add)、pnpm UNC 链接极限成文 | 人工步骤,无自动化(依赖真实 Windows 桌面应用 + WSL;打包链路由 `e2e:install` 覆盖) | 无自动化守护 |
62
63
  | R26 | 诊断三入口同一份逐项报告:独立 CLI、`/wsl-doctor` UI 命令(宿主侧、不进模型历史)、`wsl_doctor` 模型工具(进程内合并常驻状态);报告按 distro 分组逐项带显式状态标记与失败修复;`--quick`/`--sections`(工具侧 `depth`/`section`)收窄范围且未运行项显式列为跳过 | DIAGNOSTICS「The surfaces」;README「Install」;CONFIGURATION「Diagnose configuration and refusals」 | ①②④:三入口的分工与边界成文;范围化报告携带 `scope`、`--fix` 要求完整运行成文;逐项化与跳过行的形态由 parity 测试钉住 | `wsl-doctor-tool.test.mjs`(digest/渲染/CHECK_CATALOG parity)、`wsl-doctor-command.test.mjs`(语法/handler/子进程面)、`doctor.test.mjs`(CLI 采集) | 真机多 distro 报告依赖实机;报告形态的宿主渲染(命令面 UI)无单测 |
63
64
  | R27 | doctor CLI 独立性:不加载 peer 依赖与宿主服务,插件运行时本身损坏时仍可诊断;固定骨架本地化(Windows 区域设置检测,`--locale`/`DSH_WSL_DOCTOR_LOCALE` 覆盖),逐项事实保持英文,`--json` 语言无关 | DIAGNOSTICS「The surfaces」;CONFIGURATION「Message language」;LIMITATIONS「消息本地化」条 | ①②④:peer-free 内联与防漂移对拍成文;catalog 键 parity 与占位符行为有测试 | `doctor.test.mjs`(inlining parity、locale catalog、检测与覆盖) | 语言检测需 Windows registry(非 Windows 上回退英文,`run` 不抛错) |
64
- | R28 | 每日更新检查经宿主插件管理器委托,不自取;事实进 `DSH_WSL_PLUGIN_UPDATE`;`wsl-update-check.enabled: false` 可关闭 | README「Install」;CONFIGURATION `wsl-update-check` 行 | ①②⑤:委托路径、TTL、关闭开关成文 | `update-check.test.mjs` | doctor 不再自行查询 registry:更新提示只走这条委托路径 |
65
- | R29 | `workspace-write` 的额外可写目录:`writableRoots`(两行同列表)与共享 `additionalWritableRoots` 解析为同一组 Linux 根,经一次物理目录检查后绑定进命令、受限写入 resident 与 session runtime;已被工作区/临时区覆盖或嵌套的条目不绑定 | CONFIGURATION「工具链缓存与额外可写目录」;ARCHITECTURE「Sandbox」;LIMITATIONS「workspace-write 默认不授予…」 | ①②③⑤⑥:`~` 展开、UNC/Linux 拼写、跨发行版/盘符拒绝、together-grant、cached key、安全代价与 `partial` 成文 | `writable-roots.test.mjs`、`agent.test.mjs`(bwrap argv)、`provider.test.mjs`(围栏与命令两条路径)、`session-runtime.test.mjs`(key 与前缀);probe:sandbox 的授权根腿 | 真机端到端 `pnpm install` 尚未纳入探针套件;`additionalWritableRoots` 的宿主会话语义仍由上游策略决定 |
66
-
65
+ | R28 | 每日更新检查经宿主插件管理器委托,不自取;事实进 `DSH_WSL_PLUGIN_UPDATE`;`wsl-update-check.enabled: false` 可关闭;面板的「插件版本」卡片显示已安装/运行中版本、升级提醒与显式一键升级(`wsl-plugin-update`:GET 只读检查,POST 才调用 `updateBundle`) | README「Install」;QUICKSTART「Install」;CONFIGURATION `wsl-update-check` / `wsl-plugin-update` 行 | ①②⑤:委托路径、TTL、关闭开关、检查只读与点击安装的边界成文 | `update-check.test.mjs`、`plugin-update.test.mjs` | doctor 不再自行查询 registry:更新提示只走这条委托路径;一键升级依赖宿主 `updateBundle`,旧宿主/链接安装按 LIMITATIONS 手动升级 |
66
+ | R29 | `workspace-write` 的额外可写目录:`writableRoots`(两行同列表)与共享 `additionalWritableRoots` 解析为同一组 Linux 根,经一次物理目录检查后绑定进命令、受限写入 resident 与 session runtime;已被工作区/临时区覆盖或嵌套的条目不绑定 | CONFIGURATION「工具链缓存与额外可写目录」;ARCHITECTURE「Sandbox」;LIMITATIONS「workspace-write 默认不授予…」 | ①②③⑤⑥:`~` 展开、UNC/Linux 拼写、跨发行版/盘符拒绝、together-grant、cached key、安全代价与 `partial` 成文 | `writable-roots.test.mjs`、`agent.test.mjs`(bwrap argv)、`provider.test.mjs`(围栏与命令两条路径)、`session-runtime.test.mjs`(key 与前缀);probe:sandbox 的授权根腿;`doctor.test.mjs`(`sandbox.grants`);`test/probe/cache-write.sh`(真机,per-command 与 session runtime) | 真机端到端 `pnpm install` 尚未纳入探针套件;`additionalWritableRoots` 的宿主会话语义仍由上游策略决定 |
67
67
  | R30 | 发行版工作区落在非 WSL 环境时可见:会话内常驻警示(空白会话可一键切换、已开始则修正 `windowsWorkspaces`)、页头 **WSL工作区正以Windows模式打开** 标记、面板列出 Windows 访问目录,且 `auto-preset` 以日志与模型运行时上下文说明 PowerShell/9p 环境 | README「Using it」;QUICKSTART「Open a WSL workspace」;CONFIGURATION `auto-preset` 行;UPSTREAM-SESSION-NOTICE.md | ①②③⑤:判定口径(UNC 工作区 + 投影 preset 与 `auto-preset.preset` 不同)、两种成因与各自动作、投影缺失时不猜测、子代理不重复播报成文 | `auto-preset.test.mjs`(宿主侧告警与子代理/锁定/预设缺失分支)、`preset-choice.test.mjs`(访问目录判定)、`client.test.mjs`(加载器级警示状态机:显示/隐藏、切换/收起/忘记动作、badge 同步、面板目录列表);`test/browser/` 下的 Chromium 套件覆盖布局、可见性、点击与 badge 时序 | Desktop 外壳的真实装配仍靠真机探针;通用 notice 接缝仍缺(UPSTREAM-SESSION-NOTICE) |
68
+ | R31 | 受限 profile 的 socket 面隔离:`socketIsolation`(`wsl-shell`/`wsl-fs`/`fs-routing`)的 `off`/`session-bus`/`strict`;`session-bus` 遮蔽 `$XDG_RUNTIME_DIR/bus` 与 `$XDG_RUNTIME_DIR/systemd/private`,`strict` 追加 `/run/dbus/system_bus_socket`、可达的容器 socket 与 `/run/WSL`(interop 传输,复制进工作区的 PE 在 host bridge 处失败);默认 `off`,`enforcement` 仍为 `partial`;doctor `sandbox.isolation` 报告档位与探测面,`preset --socket-isolation`/`--strict` 写入嵌套行 | CONFIGURATION「Socket isolation」;SECURITY「Sandbox enforcement is partial」;LIMITATIONS「挂载 profile 不管辖进程权限」 | ①③⑤:默认不破坏、两档遮蔽面、三行一致、`strict` 代价与残余(同用户 `/proc`、interop)成文 | `socket-isolation.test.mjs`、`sandbox.test.mjs`、`session-runtime.test.mjs`、`provider.test.mjs`、`agent.test.mjs`(confined key)、`doctor.test.mjs`(`sandbox.isolation`)、`profile-preset.test.mjs`;`probe:sandbox` 的 socket 腿与 strict interop 腿 | 不关闭同用户 `/proc` / interop;顶层 `fs-routing` 行需手工同步,`fs`/`routing` 的 fsio agent 不执行模型命令 |
68
69
 
69
70
  登记覆盖面:上表登记 README 与 docs/ 中对外成文的行为承诺(含随发的服务面)。
70
71
  **有意未接线**的模块不设条目——`lib/file-reference-wsl.js`(`@` 补全的发行版侧
@@ -1,6 +1,8 @@
1
1
  # Roadmap 1.0: the WSL plugin the DSH ecosystem should have
2
2
 
3
- Status: working plan, last refreshed 2026-11-09 against `0.22.0` (the WSL-316 doctor loop and the 0.21/0.22 GUI/localization line; the §2 area tables remain the 0.15.0 baseline and are explicitly historical).
3
+ Status: working plan, last refreshed 2026-11-17 against `0.26.3` (the HMR
4
+ takeover, in-app provider check, and locale-coverage line; the §2 area tables
5
+ remain the 0.15.0 baseline and are explicitly historical).
4
6
  The 0.12.0 baseline that motivated the plan is kept below as history.
5
7
  Audience: maintainers and contributors. This is a plan, not a release promise.
6
8
  The short version: **from "the only WSL plugin" to "the default WSL plugin"** —
@@ -41,7 +43,7 @@ North-star metrics:
41
43
  |---|---|
42
44
  | Tier 1 first-run success | >= 95% |
43
45
  | Time to first successful WSL command | p50 <= 5 min, p90 <= 15 min |
44
- | Real-machine probe suite | 100% on Tier 1, nightly |
46
+ | Real-machine probe suite | 100% on Tier 1 before release (manual closed-app suite) |
45
47
  | Known documentation drift | 0 |
46
48
 
47
49
  ## 2. The 0.15.0 baseline
@@ -155,7 +157,7 @@ correct once configured" and "the plugin is correct on first contact".
155
157
  | 1-2 | Baseline and hygiene | Ten clean-machine timings; P0.4; doctor specification |
156
158
  | 3-6 | Multi-distro | P0.1 implementation, unit tests, two-distro probe, migration note |
157
159
  | 7-8 | First-run loop | P0.2, P0.3, P0.5 |
158
- | 9-10 | Compatibility and proof | P1.2, P1.3, nightly probe runner |
160
+ | 9-10 | Compatibility and proof | P1.2, P1.3, manual probe runner evidence |
159
161
  | 11-12 | Surface and performance | P1.4/P1.5 spike, P1.6 baseline, P1.7 fault injection |
160
162
  | 13+ | Ecosystem and 1.0 | P2.1-P2.4, release gates |
161
163
 
@@ -168,7 +170,7 @@ may move if the compatibility matrix exposes a higher-severity failure.
168
170
  |---|---|---|---|
169
171
  | Time to first command | Not systematically measured | p50 <= 5 min, p90 <= 15 min | Ten clean-machine runs |
170
172
  | Tier 1 first-run success | Not measured | >= 95% | Compatibility matrix |
171
- | Real-machine probes | 17 with `--include-fs` (16 base scripts plus `run.sh`; suite grew to 17 on 2026-11-06); nightly on the self-hosted Windows+WSL runner since 0.15.0 (cron 21:30 UTC, hosted runners skip green) | 100% green on the nightly run | CI `probes` job history |
173
+ | Real-machine probes | Full `--include-fs` suite run locally before release with the app closed; a manual `probes` dispatch is available once a self-hosted Windows+WSL runner exists. The nightly schedule and its heartbeat were removed on 2026-11-18 because none is registered | 100% green before release | Local closed-app suite output; manual `probes` run |
172
174
  | FS single-op p95 | ~22ms host round trip | <= 30ms | `fs-queue.mjs` |
173
175
  | 16 concurrent reads p95 | 2.4-8.2ms | <= 20ms | `fs-queue.mjs` |
174
176
  | GUI preview p95 | Backend 63.5 ms/MiB (service round trips on top) | <= 1s/MiB | `probe:gui-preview` |
@@ -187,7 +189,7 @@ probe reports.
187
189
  | Upstream never lands a seam | Keep the plugin independent; promotion work is packaging and proof, not a dependency |
188
190
  | Multi-distro refactor destabilizes routing | Introduce `distro: auto` behind tests; keep explicit pins; run two-distro probes before release |
189
191
  | `sessionSandbox: auto` hides a semantic change | Still use bwrap; report the scope mode in the result; explicit `true` keeps the strict behavior |
190
- | Real-machine CI is unavailable | Self-hosted Windows nightly; qemu for the aarch64 binary; manual suite before release |
192
+ | Real-machine CI is unavailable | Manual closed-app suite before release; qemu for the aarch64 binary; attach a self-hosted Windows+WSL runner and re-enable the manual `probes` dispatch if continuous evidence is needed |
191
193
  | Solo maintenance and bus factor | Freeze scope for 1.0; document every seam; keep the issue templates and probes current |
192
194
  | Security overclaim | Keep `enforcement: partial`; the strict preset narrows, never closes, the interop hole |
193
195
  | GUI regression repeats | Never replace the shipped `workspace-files` row again; only route and optimize |
@@ -465,8 +467,10 @@ but never executed.
465
467
  evidence (COMPATIBILITY.md). Physical aarch64 and Windows 10 are
466
468
  documented as out of scope rather than untested claims.
467
469
 
468
- **Tests/probes:** container matrix, qemu spike, COMPATIBILITY.md; nightly
469
- `probes` job is GitHub-hosted `windows-latest` and skips without WSL.
470
+ **Tests/probes:** container matrix, qemu spike, COMPATIBILITY.md; the manual
471
+ `probes` job is GitHub-hosted `windows-latest` and skips without WSL. The
472
+ nightly schedule was removed on 2026-11-18 (no self-hosted runner); run the
473
+ closed-app suite locally for evidence.
470
474
 
471
475
  **Depends on:** WSL-201 for non-systemd; WSL-203 for packaging.
472
476
 
@@ -71,6 +71,14 @@ interface ConfinedAgentRequest {
71
71
  * key because the mount table is fixed for the resident's lifetime.
72
72
  */
73
73
  writableRoots?: readonly string[];
74
+ /**
75
+ * Existing socket paths the resident's profile masks with `/dev/null`.
76
+ * Resolved by the provider from the row's `socketIsolation`; part of the key
77
+ * because the mount table is fixed for the resident's lifetime.
78
+ */
79
+ socketMasks?: readonly string[];
80
+ /** Shadow `/run/WSL`, the WSL interop transport, in the resident's profile. */
81
+ maskInterop?: boolean;
74
82
  }
75
83
  /**
76
84
  * The confined agent for one distro and one resolved policy, created on first
@@ -80,7 +88,7 @@ interface ConfinedAgentRequest {
80
88
  * @param request - the confinement request.
81
89
  * @returns the confined resident for this key.
82
90
  */
83
- export declare function confinedAgent({ distro, wslPath, policy, maskWindowsDrive, realTmp, writableRoots }: ConfinedAgentRequest): WslAgent;
91
+ export declare function confinedAgent({ distro, wslPath, policy, maskWindowsDrive, realTmp, writableRoots, socketMasks, maskInterop }: ConfinedAgentRequest): WslAgent;
84
92
  /** Test hook: forget every confined resident (the plain agent has no factory state). */
85
93
  export declare function resetConfinedAgents(): void;
86
94
  export {};
@@ -105,8 +105,8 @@ export async function runSpawnChecklist({ wslPath, distro, root, runFn }) {
105
105
  * @param request - the confinement request.
106
106
  * @returns the confined resident for this key.
107
107
  */
108
- export function confinedAgent({ distro, wslPath = "wsl.exe", policy, maskWindowsDrive = false, realTmp = true, writableRoots = [] }) {
109
- const key = `${wslPath}\0${distro}\0${policy.mode}\0${policy.workspaceRoot}\0${maskWindowsDrive ? "masked" : "visible"}\0${realTmp ? "real" : "ephemeral"}\0${writableRoots.join("\0")}`;
108
+ export function confinedAgent({ distro, wslPath = "wsl.exe", policy, maskWindowsDrive = false, realTmp = true, writableRoots = [], socketMasks = [], maskInterop = false }) {
109
+ const key = `${wslPath}\0${distro}\0${policy.mode}\0${policy.workspaceRoot}\0${maskWindowsDrive ? "masked" : "visible"}\0${realTmp ? "real" : "ephemeral"}\0${writableRoots.join("\0")}\0${socketMasks.join("\0")}\0${maskInterop ? "interop-masked" : "interop-visible"}`;
110
110
  let agent = confinedAgents.get(key);
111
111
  if (agent === undefined) {
112
112
  const linuxRoot = toLinuxPath(policy.workspaceRoot);
@@ -120,7 +120,7 @@ export function confinedAgent({ distro, wslPath = "wsl.exe", policy, maskWindows
120
120
  // `wsl.exe --exec` and the `sh <script>` pair (`lib/agent.js`'s
121
121
  // `spawnDefault`). Both confinement sites share that assembly in
122
122
  // `lib/bwrap.js`, whose module doc records what happened when they did not.
123
- argvPrefix: bwrapArgvPrefix({ mode: policy.mode, workspaceRoot: linuxRoot }, { maskWindowsDrive, realTmp, writableRoots }),
123
+ argvPrefix: bwrapArgvPrefix({ mode: policy.mode, workspaceRoot: linuxRoot }, { maskWindowsDrive, realTmp, writableRoots, socketMasks, maskInterop }),
124
124
  // workspace-write is the only mode that binds the workspace root, and
125
125
  // bwrap refuses a missing bind source (WSL-305): on a freshly imported
126
126
  // distro the first write's workspace may not exist yet, and the resident
package/lib/agent.d.ts CHANGED
@@ -23,9 +23,12 @@
23
23
  * behind a dead `wsl.exe`. The host-side watchdog is armed on the agent's
24
24
  * `ACK` — the dequeue signal — so it measures EXECUTION, never the queue
25
25
  * wait: a short-budget request queued behind a long one can no longer
26
- * kill the shared transport for a stall that was never its own. It still
27
- * catches an agent that accepted a request and then stopped answering at
28
- * all.
26
+ * kill the shared transport for a stall that was never its own. A second,
27
+ * much looser ceiling starts when the frame is WRITTEN: a resident that
28
+ * stays alive but never dequeues the request (a wedged `wait`, a blocked
29
+ * pipe) otherwise stranded it, and the serial queue behind it, forever. It
30
+ * still catches an agent that accepted a request and then stopped answering
31
+ * at all.
29
32
  * 3. **Idle agents go away.** `idleMs` after the last exchange the process is
30
33
  * killed; the next call starts a fresh one. WSL VMs are shared, but every
31
34
  * process is a promise someone has to keep.
@@ -103,6 +106,11 @@ interface PendingRequest {
103
106
  answered: boolean;
104
107
  /** The delayed cancel signal, so it can be dropped when the request settles. */
105
108
  signalTimer: NodeJS.Timeout | null;
109
+ /**
110
+ * The frame-written watchdog timer: a resident that never ACKs is wedged,
111
+ * and the ACK-armed watchdog alone would never start.
112
+ */
113
+ dispatchWatchdog: NodeJS.Timeout | null;
106
114
  }
107
115
  /** Per-kind request metrics. */
108
116
  interface RequestMetrics {
@@ -250,6 +258,8 @@ export declare class WslAgent {
250
258
  serialRequests: boolean;
251
259
  /** The maximum requests allowed in flight on this resident. */
252
260
  maxPending: number;
261
+ /** How long a written frame may await the agent's ACK. */
262
+ dispatchTimeoutMs: number;
253
263
  /** The live resident process, when any. */
254
264
  process: ChildProcess | null;
255
265
  /** The lifecycle state. */
@@ -331,6 +341,11 @@ export declare class WslAgent {
331
341
  serialRequests?: boolean;
332
342
  /** Hard ceiling in bytes on one stdout protocol line; defaults to {@link MAX_FRAME_BYTES}. */
333
343
  frameCapBytes?: number;
344
+ /**
345
+ * How long a written frame may await the agent's ACK before the transport
346
+ * is killed. Defaults to {@link DISPATCH_TIMEOUT_MS}; tests shorten it.
347
+ */
348
+ dispatchTimeoutMs?: number;
334
349
  /** Injectable process factory for tests. */
335
350
  spawnTransport?: (options: {
336
351
  wslPath: string;
@@ -564,8 +579,29 @@ export declare class WslAgent {
564
579
  * @param signal - the caller's cancellation.
565
580
  */
566
581
  private attachCancellation;
567
- /** Send a tracked request, recording dispatch before synchronous responses. */
582
+ /**
583
+ * Send a tracked request, recording dispatch before synchronous responses.
584
+ * A written frame starts the dispatch watchdog: the ACK that arms the
585
+ * execution budget is not guaranteed to arrive at all.
586
+ *
587
+ * @param pending - the request to send.
588
+ * @returns whether the frame was written.
589
+ */
568
590
  private sendPending;
591
+ /**
592
+ * Arm the frame-written watchdog: a resident that stays alive without
593
+ * dequeuing the request is a wedged transport, not a slow command.
594
+ *
595
+ * @param pending - the sent request.
596
+ */
597
+ private armDispatchWatchdog;
598
+ /**
599
+ * Release the frame-written watchdog once the ACK proves the resident
600
+ * dequeued the request.
601
+ *
602
+ * @param pending - the acknowledged request.
603
+ */
604
+ private releaseDispatchWatchdog;
569
605
  /** Dispatch the next shell request only after the preceding answer. */
570
606
  private dispatchQueued;
571
607
  /**
@@ -680,20 +716,6 @@ export declare class WslAgent {
680
716
  * @returns resolved on PONG.
681
717
  */
682
718
  ping(signal?: AbortSignal): Promise<void>;
683
- /**
684
- * Deliver an out-of-band signal to the resident shell. The serial stdin loop
685
- * cannot consume a frame while a command runs, so cancellation is a signal;
686
- * a second `wsl.exe` is the only channel that reaches the agent while it is
687
- * blocked in `wait`.
688
- *
689
- * Only an agent that shares the distro's PID namespace is addressable: the
690
- * plain agent, or a session runtime (its prefix is a scope plus mounts, but
691
- * no PID namespace). A confined resident runs inside a PID namespace whose
692
- * PIDs do not exist in the distro, so signalling its HELLO PID could hit an
693
- * unrelated process; there the KILL frame remains the (delayed) fallback.
694
- *
695
- * @param signal - the signal to deliver (`SIGUSR1` is the cancel trap).
696
- */
697
719
  /**
698
720
  * The cumulative request metrics: queue wait (submission -> ACK) and execution
699
721
  * time (ACK -> settle) per request kind, plus the peak in-flight count.
@@ -726,6 +748,20 @@ export declare class WslAgent {
726
748
  * @param error - the failure, when any.
727
749
  */
728
750
  private recordSettle;
751
+ /**
752
+ * Deliver an out-of-band signal to the resident shell. The serial stdin loop
753
+ * cannot consume a frame while a command runs, so cancellation is a signal;
754
+ * a second `wsl.exe` is the only channel that reaches the agent while it is
755
+ * blocked in `wait`.
756
+ *
757
+ * Only an agent that shares the distro's PID namespace is addressable: the
758
+ * plain agent, or a session runtime (its prefix is a scope plus mounts, but
759
+ * no PID namespace). A confined resident runs inside a PID namespace whose
760
+ * PIDs do not exist in the distro, so signalling its HELLO PID could hit an
761
+ * unrelated process; there the KILL frame remains the (delayed) fallback.
762
+ *
763
+ * @param signal - the signal to deliver (`SIGUSR1` is the cancel trap).
764
+ */
729
765
  private signalAgent;
730
766
  /**
731
767
  * Shut the agent down: SHUTDOWN first, then kill after a short grace. The
package/lib/agent.js CHANGED
@@ -23,9 +23,12 @@
23
23
  * behind a dead `wsl.exe`. The host-side watchdog is armed on the agent's
24
24
  * `ACK` — the dequeue signal — so it measures EXECUTION, never the queue
25
25
  * wait: a short-budget request queued behind a long one can no longer
26
- * kill the shared transport for a stall that was never its own. It still
27
- * catches an agent that accepted a request and then stopped answering at
28
- * all.
26
+ * kill the shared transport for a stall that was never its own. A second,
27
+ * much looser ceiling starts when the frame is WRITTEN: a resident that
28
+ * stays alive but never dequeues the request (a wedged `wait`, a blocked
29
+ * pipe) otherwise stranded it, and the serial queue behind it, forever. It
30
+ * still catches an agent that accepted a request and then stopped answering
31
+ * at all.
29
32
  * 3. **Idle agents go away.** `idleMs` after the last exchange the process is
30
33
  * killed; the next call starts a fresh one. WSL VMs are shared, but every
31
34
  * process is a promise someone has to keep.
@@ -60,6 +63,16 @@ function emptyAgentMetrics() {
60
63
  const HANDSHAKE_TIMEOUT_MS = 15000;
61
64
  /** Extra time the host watchdog waits past the request's own in-distro timeout. */
62
65
  const WATCHDOG_GRACE_MS = 13000;
66
+ /**
67
+ * How long a written frame may wait for the agent's dequeue `ACK`. The ACK is
68
+ * one line the resident prints before it runs anything, so this is not an
69
+ * execution budget; it exists to turn a resident that is alive but no longer
70
+ * dequeuing (a wedged `wait`, a blocked stdin pipe) into a bounded failure
71
+ * instead of an entry that holds the serial queue forever. Generous on
72
+ * purpose: a legitimately busy foreground command is ACKed as soon as it is
73
+ * dequeued, and only the queue wait precedes that.
74
+ */
75
+ const DISPATCH_TIMEOUT_MS = 120_000;
63
76
  /**
64
77
  * How many times a resident that reached `dead` may be revived before the
65
78
  * failure becomes permanent. Each revival gets the one permitted rebuild.
@@ -180,6 +193,7 @@ export class WslAgent {
180
193
  this.configuredSignal = config.signalTransport;
181
194
  this.configuredLease = config.leaseMs;
182
195
  this.maxPending = config.maxPending ?? MAX_PENDING_REQUESTS;
196
+ this.dispatchTimeoutMs = config.dispatchTimeoutMs ?? DISPATCH_TIMEOUT_MS;
183
197
  this.agentPid = undefined;
184
198
  this.process = null;
185
199
  this.state = "idle";
@@ -530,6 +544,7 @@ export class WslAgent {
530
544
  return;
531
545
  pending.started = true;
532
546
  this.lastAckedSeq = pending.seq;
547
+ this.releaseDispatchWatchdog(pending);
533
548
  this.recordAck(pending);
534
549
  if (pending.cancelled)
535
550
  this.armCancelSignal(pending);
@@ -672,6 +687,9 @@ export class WslAgent {
672
687
  clearTimeout(pending.watchdog);
673
688
  pending.watchdog = null;
674
689
  }
690
+ // The rebuilt agent gets a fresh ACK window too; a timer bound to the
691
+ // dead transport must not survive the relay.
692
+ this.releaseDispatchWatchdog(pending);
675
693
  relayable.push(pending);
676
694
  }
677
695
  else {
@@ -822,6 +840,7 @@ export class WslAgent {
822
840
  settled: false,
823
841
  answered: false,
824
842
  signalTimer: null,
843
+ dispatchWatchdog: null,
825
844
  armWatchdog: timeoutMs > 0
826
845
  ? () => {
827
846
  if (pending.watchdog)
@@ -888,10 +907,57 @@ export class WslAgent {
888
907
  };
889
908
  signal.addEventListener("abort", pending.onAbort, { once: true });
890
909
  }
891
- /** Send a tracked request, recording dispatch before synchronous responses. */
910
+ /**
911
+ * Send a tracked request, recording dispatch before synchronous responses.
912
+ * A written frame starts the dispatch watchdog: the ACK that arms the
913
+ * execution budget is not guaranteed to arrive at all.
914
+ *
915
+ * @param pending - the request to send.
916
+ * @returns whether the frame was written.
917
+ */
892
918
  sendPending(pending) {
893
919
  pending.sent = true;
894
- return this.writeLines(pending.lines);
920
+ if (!this.writeLines(pending.lines))
921
+ return false;
922
+ this.armDispatchWatchdog(pending);
923
+ return true;
924
+ }
925
+ /**
926
+ * Arm the frame-written watchdog: a resident that stays alive without
927
+ * dequeuing the request is a wedged transport, not a slow command.
928
+ *
929
+ * @param pending - the sent request.
930
+ */
931
+ armDispatchWatchdog(pending) {
932
+ if (pending.dispatchWatchdog)
933
+ return;
934
+ const child = this.process;
935
+ if (!child)
936
+ return;
937
+ pending.dispatchWatchdog = setTimeout(() => {
938
+ // Bind the timer to the generation it was armed on, exactly as the
939
+ // ACK-armed watchdog does.
940
+ if (this.process !== child)
941
+ return;
942
+ this.lastError = `agent did not acknowledge request ${pending.id} within ${this.dispatchTimeoutMs}ms of its dispatch`;
943
+ child.kill();
944
+ }, this.dispatchTimeoutMs);
945
+ // The transport's child process (and its pipes) already keeps the loop
946
+ // alive while there is something to time out; an idle host that has let
947
+ // every other handle go must not be held open by this diagnostic timer.
948
+ pending.dispatchWatchdog.unref?.();
949
+ }
950
+ /**
951
+ * Release the frame-written watchdog once the ACK proves the resident
952
+ * dequeued the request.
953
+ *
954
+ * @param pending - the acknowledged request.
955
+ */
956
+ releaseDispatchWatchdog(pending) {
957
+ if (!pending.dispatchWatchdog)
958
+ return;
959
+ clearTimeout(pending.dispatchWatchdog);
960
+ pending.dispatchWatchdog = null;
895
961
  }
896
962
  /** Dispatch the next shell request only after the preceding answer. */
897
963
  dispatchQueued() {
@@ -989,20 +1055,6 @@ export class WslAgent {
989
1055
  this.track({ id, kind: "exec", lines, resolve: () => resolve(), reject, timeoutMs: HANDSHAKE_TIMEOUT_MS, signal });
990
1056
  });
991
1057
  }
992
- /**
993
- * Deliver an out-of-band signal to the resident shell. The serial stdin loop
994
- * cannot consume a frame while a command runs, so cancellation is a signal;
995
- * a second `wsl.exe` is the only channel that reaches the agent while it is
996
- * blocked in `wait`.
997
- *
998
- * Only an agent that shares the distro's PID namespace is addressable: the
999
- * plain agent, or a session runtime (its prefix is a scope plus mounts, but
1000
- * no PID namespace). A confined resident runs inside a PID namespace whose
1001
- * PIDs do not exist in the distro, so signalling its HELLO PID could hit an
1002
- * unrelated process; there the KILL frame remains the (delayed) fallback.
1003
- *
1004
- * @param signal - the signal to deliver (`SIGUSR1` is the cancel trap).
1005
- */
1006
1058
  /**
1007
1059
  * The cumulative request metrics: queue wait (submission -> ACK) and execution
1008
1060
  * time (ACK -> settle) per request kind, plus the peak in-flight count.
@@ -1077,6 +1129,20 @@ export class WslAgent {
1077
1129
  else if (error !== undefined)
1078
1130
  stats.failed += 1;
1079
1131
  }
1132
+ /**
1133
+ * Deliver an out-of-band signal to the resident shell. The serial stdin loop
1134
+ * cannot consume a frame while a command runs, so cancellation is a signal;
1135
+ * a second `wsl.exe` is the only channel that reaches the agent while it is
1136
+ * blocked in `wait`.
1137
+ *
1138
+ * Only an agent that shares the distro's PID namespace is addressable: the
1139
+ * plain agent, or a session runtime (its prefix is a scope plus mounts, but
1140
+ * no PID namespace). A confined resident runs inside a PID namespace whose
1141
+ * PIDs do not exist in the distro, so signalling its HELLO PID could hit an
1142
+ * unrelated process; there the KILL frame remains the (delayed) fallback.
1143
+ *
1144
+ * @param signal - the signal to deliver (`SIGUSR1` is the cancel trap).
1145
+ */
1080
1146
  signalAgent(signal) {
1081
1147
  const pid = this.agentPid;
1082
1148
  if (pid === undefined || !this.signalable)
@@ -1207,6 +1273,7 @@ export class WslAgent {
1207
1273
  clearPending(pending) {
1208
1274
  if (pending.watchdog)
1209
1275
  clearTimeout(pending.watchdog);
1276
+ this.releaseDispatchWatchdog(pending);
1210
1277
  if (pending.signalTimer)
1211
1278
  clearTimeout(pending.signalTimer);
1212
1279
  pending.signalTimer = null;
package/lib/bwrap.d.ts CHANGED
@@ -48,6 +48,22 @@ interface BwrapProfileOptions {
48
48
  * Inert under `read-only`: the mode grants no write outside `/`.
49
49
  */
50
50
  writableRoots?: readonly string[];
51
+ /**
52
+ * Existing socket paths to shadow with `/dev/null`: the user systemd
53
+ * manager's sockets (`session-bus`) and, for `strict`, the system bus and
54
+ * the container sockets the distro user can reach. The caller resolves and
55
+ * filters the paths (`lib/socket-isolation.js`); binding a missing or
56
+ * symlinked path fails in bwrap, so this module never invents one.
57
+ */
58
+ socketMasks?: readonly string[];
59
+ /**
60
+ * Shadow `/run/WSL` with an empty tmpfs: the WSL interop transport. `/init`
61
+ * stays executable and the kernel keeps its binfmt handler, but the host
62
+ * bridge socket is gone, so a PE executed inside the profile fails at
63
+ * `connect`. The complete distro-wide closure is still `[interop]
64
+ * enabled=false`; this is the command-profile narrowing.
65
+ */
66
+ maskInterop?: boolean;
51
67
  }
52
68
  /**
53
69
  * Build the bwrap profile arguments for one file-effect policy, exactly as
package/lib/bwrap.js CHANGED
@@ -69,6 +69,15 @@ export function bwrapProfileArgs(policy, options = {}) {
69
69
  if (options.pidNamespace !== false)
70
70
  args.push("--unshare-pid");
71
71
  args.push("--proc", "/proc", "--die-with-parent");
72
+ // After `--dev /dev`, so `/dev/null` exists to bind from, and after the
73
+ // read-only root, so the mount lands over the socket the command would
74
+ // otherwise reach. The paths are existing sockets the caller verified.
75
+ for (const socket of options.socketMasks ?? [])
76
+ args.push("--ro-bind", "/dev/null", socket);
77
+ // `/run/WSL` is the interop bridge's directory, so it takes a tmpfs (a
78
+ // directory cannot be shadowed with the `/dev/null` bind used for sockets).
79
+ if (options.maskInterop)
80
+ args.push("--tmpfs", "/run/WSL");
72
81
  if (policy.mode === "workspace-write") {
73
82
  if (options.realTmp) {
74
83
  args.push("--bind", "/tmp", "/tmp");
@@ -30,6 +30,8 @@
30
30
  *
31
31
  * @module dsh-plugin-wsl-env/fs-routing
32
32
  */
33
+ import type { SocketIsolation } from "./socket-isolation.js";
34
+ import { PLUGIN_PROVIDER } from "./provider-marker.js";
33
35
  import z from "@deepseek-ai/schemastery";
34
36
  import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
35
37
  import { WslFileSystem } from "./wsl-filesystem.js";
@@ -65,6 +67,8 @@ interface RoutingConfig {
65
67
  sandbox?: boolean;
66
68
  /** Whether confined profiles shadow `/mnt`. */
67
69
  maskWindowsDrive?: boolean;
70
+ /** Which socket surfaces the routed backend's confined resident cannot reach. */
71
+ socketIsolation?: SocketIsolation;
68
72
  /** Whether the routed backend refuses paths outside the distro. */
69
73
  restrictToDistro?: boolean;
70
74
  /** How deep the in-distro watch scan walks. */
@@ -98,6 +102,8 @@ export declare function inputIsDistro(value: string | undefined): boolean;
98
102
  * mode the distro side reports through `sandboxMode`).
99
103
  */
100
104
  export declare class WslRoutingFileSystem extends LocalFileSystem {
105
+ /** Brand for the in-app takeover report; see `provider-marker`. */
106
+ get [PLUGIN_PROVIDER](): "fs";
101
107
  static Config: z<RoutingConfig>;
102
108
  /**
103
109
  * The routed backend's constructor reads the deployment default mode from