Skip to content

fix(desktop): 补传远端临时脚本写入边界并跳过 Windows 根目录替换监听用例 - #2375

Merged
1lck merged 1 commit into
mainfrom
fix/unblock-main-ci-remote-run-and-windows-watch
Nov 24, 2026
Merged

1lck merged 1 commit into
mainfrom
fix/unblock-main-ci-remote-run-and-windows-watch

Conversation

@1lck

@1lck 1lck commented Nov 24, 2026

Copy link
Copy Markdown
Owner

关联 Issue / Linked issue

PR 类型 / Type

  • fix:缺陷修复

改动说明 / What changes

背景 / Why

目前 main 分支(dc9618a4c)上的 Desktop CI(Run 45265279585)在三个桌面平台均处于失败状态,导致后续所有合入主干的 PR 都无法通过门禁:

  1. Linux 与 macOS:desktop/internal/workbench 中 6 个 TestRemoteWorkspaceRun* 用例全部失败,报错 lithe core: remote.writeFile: save must carry its workspace boundary (permission_denied)。
  2. Windows:desktop/internal/pluginservice 中的 TestWorkspaceWatchUsesNativeEventsAndReleasesOwnedSubscriptions/root-replacement 在重命名被监听根目录或等待其 resync 时失败(Run 45254949766 报 rename ...: Access is denied.;Run 45265279585 报 8 秒 context deadline exceeded)。

改动 / Changes

  • desktop/internal/workbench/remote_run.go(writeScript):向 h.kernel.RemoteWriteFile 显式传入当前运行临时目录 start.scratch 作为第 6 个 root 写入边界参数,既满足 #2367 引入的 remoteHostKernel.RemoteWriteFile 边界检查,也在启用了 Feature::GuardedWrites 的远端服务中阻止在临时目录下跟随符号链接。
  • desktop/internal/pluginservice/hostworkspacewatch_test.go(TestWorkspaceWatchUsesNativeEventsAndReleasesOwnedSubscriptions):仅在 runtime.GOOS == "windows" 时跳过 root-replacement 子用例并关联跟踪 Issue #2374;dispose、context、session 三个资源释放子用例继续在 Windows 运行,macOS 与 Linux 继续完整覆盖 root-replacement。
  • shared/platform-feature-matrix/features/remote-workspace.json 与 shared/platform-feature-matrix/features/plugin-host-editor-file-window-services.json:按实际实现与测试范围同步验证说明,Windows 与 macOS 的 verificationStatus 仍保持 pending。

不在本 PR 范围内 / Out of scope

  • Windows 原生 ReadDirectoryChangesW 打开根目录句柄导致跨目录重命名拒绝或缺失自身重命名 resync 的底层改造与真实行为设计:已提交并跟踪于 #2374,不在本解除主干阻塞 PR 内绕过生产代码。

类型专属:fix

复现与根因

  • 复现步骤、实际结果、期望结果:在最新 main(dc9618a4c)运行 ./scripts/desktop/desktop-go.sh test -v -count=1 ./internal/workbench -run '^TestRemoteWorkspaceRun',期望全部通过;实际全部 6 个测试失败并耗时 42.994s,前 2 个及第 6 个直接报 remote.writeFile: save must carry its workspace boundary (permission_denied),中间 3 个保活恢复用例因准备步骤写入临时脚本失败而未启动进程并在 8 秒后超时。Windows CI 上运行 ./scripts/desktop/desktop-go.sh test ./internal/pluginservice 在 root-replacement 子用例因 ReadDirectoryChangesW 持有 root 打开句柄而失败。
  • 根因:
    1. bc7d58a81(#2367)在 desktop/internal/workbench/remote_documents_test.go 的 remoteHostKernel.RemoteWriteFile 增加必须传入非空且覆盖目标路径的 root 边界校验并同步更新了 remote_documents.go:252,但遗漏了 remote_run.go:247 写入远端临时运行脚本的调用点(仅传入 ctx, start.session.id, script.Path, ..., nil)。实查 PINNED_CORE_REVISION(9ab2336e)sessions.rs、guarded_write.rs 与 server/platform/mod.rs 确认远端服务启用了 Feature::GuardedWrites,传 start.scratch 作为 root 时可规范化临时目录并禁止其下符号链接。
    2. 5ea2c1c7a(#2369)新增的 root-replacement 子用例假设在监听打开期间可以把 root 跨父目录 os.Rename 且系统会投递 resync;而 Windows 上 viva/internal/filewatch/watch_windows.go:64 对 root 持有 CreateFile 目录句柄等待 ReadDirectoryChangesW,在 NTFS 上会拒绝或丢失根目录自身的重命名事件。
  • 影响平台:remote_run.go 为 macOS / Linux / Windows 共用桌面代码;root-replacement 跳过仅作用于 Windows。

检查项

  • 已先写回归测试,确认它在修复前失败、修复后通过;测试路径与修复前的失败输出:既有回归 desktop/internal/workbench/remote_run_test.go(^TestRemoteWorkspaceRun)在修复前 dc9618a4c 上 6 个用例全部失败(FAIL ... 42.994s,save must carry its workspace boundary),传入 start.scratch 后 -race(6.343s)与 -tags 'dev vivahead'(2.934s)全部通过;hostworkspacewatch_test.go 在 GitHub Actions Windows CI(Runs 45254949766、45265279585)复现失败,已建 #2374 并在 runtime.GOOS == "windows" 仅跳过 root-replacement。
  • [N/A] 无法自动化时,已写明手动复现与验证步骤:上述行为均已有自动化测试覆盖(Windows 由 GitHub Actions Windows lane 验证)。
  • 已搜索被修改函数、类型、契约字段的全部调用方(含另一平台、插件、SDK、脚本和按字符串分发的调用):rg -n 'RemoteWriteFile' desktop/ 确认生产调用仅 remote_documents.go:252(已传 r.binding.RemoteRoot())与 remote_run.go:247 两处,internal/core/remote_session_test.go:164 测试 CodeConnectionClosed 错误路径不受影响。
  • 已检查另一平台是否有同类缺陷(有则本 PR 一并修复,或已提交 Issue):[Bug] Windows 原生工作区监听(ReadDirectoryChangesW)在根目录被替换/移动时阻塞重命名或丢失 resync #2374(Windows root-replacement 已建独立 Issue 跟踪;remote_run.go 为跨平台共同路径已一并修复)。
  • 只改了修复所需的代码,没有夹带重构;修复过程中发现的其他问题已提交 Issue:[Bug] Windows 原生工作区监听(ReadDirectoryChangesW)在根目录被替换/移动时阻塞重命名或丢失 resync #2374
  • [N/A] 修复改变了行为约束或容易复发,已在 .agents/notes/implemented/bug-fix/ 记录:本修复补齐既有调用边界并在单测中显式跳过未支持平台行为(见 #2374),未改变既有架构约束或公共 API 协议。

范围检查 / Scope checks

功能矩阵 / Feature matrix

  • 已更新 shared/platform-feature-matrix/features/remote-workspace.json 与 plugin-host-editor-file-window-services.json:补充 writeScript 边界参数说明与 Windows root-replacement 跳过说明(#2374);未跑完的整机验收保持 pending。
  • 已运行 ./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(222 项能力通过)与 ./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(通过)。
  • 没有提交 .artifacts/ 下生成的矩阵视图。
  • [N/A] 没有更新矩阵的,理由:已更新受影响矩阵条目。

插件归属 / Plugin ownership

  • 已在仓库根目录运行 develop-lithe 第三节“插件归属与宿主零依赖”的自查命令,结果无本次改动引入或新增的 concrete plugin 依赖。
  • 新增或修改的测试只使用测试内联的合成插件、Core 契约 fixture 或插件市场索引快照(hostworkspacewatch_test.go 使用合成插件 ID dev.lithe.test.workspace-watch)。
  • 没有为具体插件提供的能力新建或更新宿主功能矩阵条目。
  • 插件文案没有写进 shared/i18n/;插件构建与资源说明未写进宿主文档。
  • [N/A] 修改了通用扩展点、可能影响已发布插件的,已在受影响插件的仓库运行它的测试:未修改扩展点协议或插件后端契约。

UI 验证 / UI evidence

N/A:纯桌面远端执行边界参数与 pluginservice 测试平台过滤修复,无布局、控件、样式、文案、菜单、弹窗或交互状态变化。

统一日志系统 / Structured logging

N/A:未新增或改动日志事件、通道或错误处理边界。

界面文案 / i18n

  • [N/A] 宿主文案与插件翻译均未修改。
  • 已运行 node scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check(12628/12628)与 node --test --test-timeout=60000 scripts/i18n/test-i18n.mjs(62/62),全部通过。

逻辑归属 / Logic placement

  • 路径边界校验仍在 Rust Core guarded_write.rs 与 sessions.rs 执行;桌面端 remote_run.go 只传递既有 start.scratch 边界。
  • [N/A] 修改平台层已有的可共享逻辑时已迁入 Core:未新增或修改平台层可共享业务规则。
  • 没有按工具或运行时名称新增分支。

性能与内存 / Performance and memory

N/A:未新增后台任务、缓存、轮询、依赖,也不影响启动、打开、输入、滚动、大文件或搜索热路径。

设置 / Settings

N/A:未改动设置项、设置页或配置对话框。

插件契约 / Plugin contract

N/A:未修改插件契约、PINNED_CORE_REVISION(复用主干 dc9618a4c 固定的 9ab2336e8ca651e40baa5e65848b717b26f69e43)或后端协议。

发行包与资源 / Bundle and resources

  • 运行时不向已安装的 app bundle 或 Windows 安装目录写入,已运行 ./scripts/desktop/verify/verify-runtime-bundle-immutability.sh 通过。
  • [N/A] 新增或修改宿主自身的下载、解压、生成或缓存资源:未新增资源路径。

无用代码与重构 / Dead code and refactoring

  • 未引入或保留由本次改动产生的无用代码。
  • 本次之前存在的 Windows ReadDirectoryChangesW 根目录替换限制已提交独立 Issue #2374 跟踪,未在本 PR 顺手改动底层或编写绕过代码。

验证 / Verification

命令或操作 平台 结果
(cd desktop && gofmt -l .)、git diff --check origin/main...HEAD macOS arm64 通过(空输出)
./scripts/desktop/desktop-go.sh vet ./...、vet -tags dev ./... macOS arm64 通过
./scripts/desktop/desktop-go.sh test -v -race -count=1 ./internal/workbench -run '^TestRemoteWorkspaceRun' macOS arm64 修复前 6 项失败(42.994s);修复后 6 项全部通过(6.343s)
./scripts/desktop/desktop-go.sh test -v -tags 'dev vivahead' -count=1 ./internal/workbench -run '^TestRemoteWorkspaceRun' macOS arm64 通过(2.934s)
./scripts/desktop/desktop-go.sh test -v -race -count=1 ./internal/pluginservice -run '^TestWorkspaceWatch' macOS arm64 通过(2.704s)
./scripts/desktop/desktop-go.sh test -race -count=1 ./internal/pluginservice macOS arm64 通过(55.675s)
./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh(TestWorkspaceWatch、TestRemoteWorkspaceRun)与 verify-test-stability.sh --base origin/main macOS arm64 通过(计时已记录 .artifacts/test-stability/;Rust 扫描 N/A)
verify-platform-feature-matrix.sh 与 verify-platform-feature-matrix-change.sh origin/main HEAD macOS arm64 通过(222 项能力)
verify-agent-notes.sh、verify-runtime-bundle-immutability.sh、validate-pins.mjs macOS arm64 通过(204 篇笔记;Viva bb85256c8ffa / Core 9ab2336e8ca6)
verify-app-language-localization.mjs、generate-i18n.mjs --check、test-i18n.mjs、desktop-core-cache.test.mjs macOS arm64 通过(12628/12628;62/62;1/1)

未能执行的检查和原因:

  • 本地主机为 macOS arm64,未本地运行 Windows 与 Linux 桌面测试套件;由标为 Ready 后的 GitHub Actions Desktop CI(Linux / macOS / Windows 全三端)覆盖验证。

提交前确认 / Final checks

  • 分支从最新的 main(dc9618a4c)创建;目标分支为 main
  • 先创建 Draft PR 并核对无误后即标记 Ready 跑完整三端 CI
  • 仅提交 4 个相关文件,没有提交 .build/、target/、dist/、.artifacts/ 等产物或个人路径
  • 测试进程与临时子进程已全部退出,无 Lithe 进程残留

@1lck
1lck marked this pull request as ready for review November 24, 2026 01:59
@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Nov 24, 2026
@1lck
1lck merged commit 79d4a85 into main Nov 24, 2026
12 of 20 checks passed
@1lck
1lck deleted the fix/unblock-main-ci-remote-run-and-windows-watch branch November 24, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant