Repository navigation
feat(runner): enable Windows task runtimes and isolated SSH - #882
AaronWangCong wants to merge 4 commits into
Conversation
6a3d63b to
176ac5d
Compare
Yanami-2K
left a comment
There was a problem hiding this comment.
已核对可见部分:CI(含 Windows runtime contracts 和 Windows platform adapter contracts)全绿、无冲突;cmd/agentflow-runner 在 Windows 上强制关闭自动更新、restart_windows.go 在重启时 fail closed,符合描述;gitwork.StartSSHWithAgentFactory 保留了 StrictHostKeyChecking yes/IdentitiesOnly yes,会拒绝含换行或 NUL 的 socket,ssh_factory_test.go 断言私钥不会落到文件或环境变量。以下原因让我无法在本轮给出批准结论,需要维护者判断:
- 堆叠 PR 的审查时机:当前对比 main 的 99 个文件里有 28 个来自 #881(本轮已单独批准)。描述写了 #881 合入后会 rebase,建议先合 #881,等本 PR rebase 到只剩 72 个运行时文件后再做正式审查和批准,避免两个 PR 对同一批文件的修改出现偏差。
- 安全敏感的代码未能看全:工具未返回
internal/runtime/git_ssh_agent_windows.go(+231)、docker_process_lease.go(+171)、conversation_approval_windows.go(+137)、materialize_binding_windows.go(+172)、runner/daemon.go、runner/exec.go、sandbox_docker.go、sandbox_script_docker.go等约 70 个文件的 patch,gitwork/ssh.go和ssh_transport_windows.go也被截断。容器内 SSH agent、审批 hook、进程租约都涉及凭据和越权风险,建议由人逐行审。 internal/gitwork/ssh_transport_windows.go的 MSYS AF_LOCAL 模拟:agent 实际监听在127.0.0.1的 TCP 端口,本机所有用户都能连接,安全性完全依赖 socket 文件里的 16 字节 cookie 和目录 DACL。请在描述或注释里说明:(a) 握手阶段是否校验了 MSYS 协议中的对端 pid/uid/gid,或有意不校验;(b) cookie 文件在SetNamedSecurityInfo收紧目录权限之前是否可能被其他用户读到;(c) 握手未完成的连接(pending)有没有超时,防止本地进程占满连接。- 行为变化需要确认:原生 Windows 任务在 root 退出后会杀掉整个 Job 里的后台进程,而 Docker 侧「成功的脚本服务对后续节点保持可用」,两套语义不同。引入自动化 SOP 时这是否可以接受、是否需要写进用户文档,需要维护者确认。
Yanami-2K
left a comment
There was a problem hiding this comment.
跟进上一轮的审查意见。这次仍然只留评论,不批准。
已确认的部分
- 描述里新增的「Windows SSH transport」一节回答了上一轮的三个问题,和可见代码一致:
internal/gitwork/ssh_transport_windows.go的listenSSHAgent先用SetNamedSecurityInfo给会话目录加上只允许 Runner 账号 SID 访问的受保护 DACL(D:P(A;OICI;FA;;;<SID>)),之后才监听127.0.0.1:0并写入 cookie 文件。- cookie 有 128 位,由
crypto/rand生成;客户端的 PID/UID/GID 只是兼容字段,不作为身份凭据。 - 握手有 5 秒读写超时,本地连接洪泛只影响可用性。描述里也写明了:会话目录的父目录必须是 Runner 私有目录,这是信任边界的前提。
StartSSHWithAgentFactory校验了 factory 返回的 socket(拒绝空值、\r\n\x00、nil cleanup),失败时会清理目录。ssh_factory_test.go断言了以下几点:私钥不会落盘、不会进入环境变量;身份去重;cleanup 幂等;配置保留StrictHostKeyChecking yes和IdentitiesOnly yes。- 18 项 CI 全绿,包括
Windows runtime contracts和Windows platform adapter contracts。
仍未能核对、需要人工审查的部分
- 工具没有返回 diff 的文件约 70 个,这次仍然没看到,其中包括安全或并发敏感的实现:
internal/runtime/git_ssh_agent_windows.go(+231,容器内 SSH agent)、conversation_approval_windows.go(+137,审批 hook)、docker_process_lease.go(+171,心跳租约和强制退出时回收进程)、materialize_binding_windows.go(+172)、internal/runner/daemon.go和exec.go。请维护者按描述里给的 stacked comparison 逐个过一遍这些文件,尤其要确认 agent 私钥只存在内存里,以及租约过期时只回收自己拥有的进程树。 - 和 main 对比,当前 diff 仍然包含 #881 的全部 28 个文件。按作者的计划,应先合入 #881,再把本 PR rebase 到只剩 runtime 改动,然后正式批准,避免同一批基础改动在两个 PR 里被分别审查。
- 可见部分有一处非阻塞建议:
internal/processgroup/process_windows.go的Start在根进程退出后立即调用Kill(pid)回收整个 Job。这和描述里的「Native Windows tasks ... stop remaining descendants when the root exits」一致,但和 Unix 行为不同:Unix 上后台子进程可以存活。建议在用户文档(Runner 的 Windows 说明)里明确写出这一点,避免脚本节点里nohup/start启动的服务被意外结束。
|
LoopForge PR Review Bot — reviewed commit Verdict: PASS ✅ What I checked
Note: this is static review + cross-compile vet for the Windows-only paths (sandbox here is Linux-only), not an execution test on a real Windows host. Flagging as informational only — no blocking defect found. |
What changed
Enables Windows Runner task execution with native CLI discovery, Git Bash shell nodes, managed asset snapshots, Windows-safe paths and approval hooks. Personal SSH keys stay in memory through an isolated Git-for-Windows transport; Linux Docker tasks get a separate short-lived in-container SSH agent for each command.
Part 2 of the Windows execution-machine work from #875. Depends on #881. The temporary comparison against main includes that foundation; after it merges this PR will be rebased so only the runtime changes remain. Installer/download delivery and full lifecycle CI stay in #875.
Windows disables automatic in-process Runner replacement even when explicitly requested; installer updates own that lifecycle. Active Docker commands also use a Runner-owned heartbeat lease, so cancellation and forced Runner exit reap their owned process tree. Successful script services remain available to subsequent nodes in the reused sandbox.
Scope
Compatibility
Unix transports, symlink bindings and process-group behavior remain behind their existing platform adapters. Native Windows tasks own their complete process tree and stop remaining descendants when the root exits. With local authentication selected, Codex and Claude Code use the Runner account's existing CLI login; provider credential modes follow the task's selection. Linux images used from Windows need Python 3 at
/usr/bin/python3or/usr/local/bin/python3; personal container Git SSH also needs the OpenSSH client tools. The web interactive PTY continues to require a Unix execution machine.Windows SSH transport
The full transport source uses Git for Windows' MSYS loopback protocol:
Validation
Windows and Linux runtime test-package compilation on this exact commit; native Windows Runner/Gate builds. Windows ARM64 and Darwin ARM64 Runner/Gate cross-builds passed and artifact headers confirm their architectures.
Focused Windows process, procwatch, Git SSH, runtime, Runner, preview and CLI tests.
Final runtime/Runner source: 896 Linux tests/subtests passed, including the unchanged default supervisor and actual Codex/Claude gateways; selected vet and public checks passed. The complete integration baseline also passed 4,906 Linux tests/subtests and full vet.
Latest compiled Windows Runner: all six live Docker acceptance groups passed in 204.92s, covering real Chromium, Gate/Codex tasks, SSH push and isolation, cancellation, normal services, failure cleanup and reconnect.
Forced Runner termination: actual script and pinned Codex tasks both reap their exact parent/child/grandchild identities with no delayed writes; completed unrelated services remain alive. The generic OpenCode provider path with
OwnProcessGroup=falseand byte-exact JSON stdin also passed.Native Windows process, SSH, runtime and approval acceptance passed, including all nine actual pinned Codex policy cases in the delivery integration.
Standalone Windows runtime CI builds Runner/Gate, builds the embedded chatbot assets required by Runner test imports, then tests CLI, process/SSH, runtime, Runner and filesystem identity contracts and runs vet. Its build/test/vet commands also passed locally.
Public-content check,
git diff --checkand Gitleaks 8.30.1 pass on the runtime candidate.Review the 72 runtime-only files in the stacked comparison. The temporary comparison against main contains 99 files including the foundation.
All 18 official checks passed on
176ac5d, including the independent Windows runtime job.Safety