Skip to content

Windows 11 全流程不可用:启动引导即失败(O_NOFOLLOW/dir_fd/flock/信号 等 POSIX 依赖) #70

Description

@xing-kj

环境

  • Windows 11 (10.0.22631)、Python 3.12、pip install -e . 源码安装 v0.1.7
  • 后端:opencode CLI 1.18.21

现象

lh-harness run 在 Windows 上从启动引导到运行循环多处直接失败,无法完成任何任务:

Cannot start run: unsafe run directory layout: secure control-bus directory creation is unavailable

绕过引导后继续暴露:

阶段 错误
控制总线/事件账本 O_NOFOLLOWdir_fdfcntl.flock 均为 POSIX 专属,Windows 直接不可用
角色提示词写入 执行 mkdir -p / chmod(cmd.exe 无此命令)
所有角色 episode 命令模板使用 POSIX 单引号与 VAR=x cmd 前缀,cmd.exe 解析失败(0.1s 即 error)
Executor 超时清理 signal.SIGKILL 在 Windows 不存在 → AttributeError → worker_exception
进程存活探测 os.kill(pid, 0) 在 Windows 语义是 TerminateProcess(pid, 0),会把"探测"变成"击杀",且 pid 复用后会误杀无关进程(实测打断过整个测试进程树)

根因归纳

  1. 锚定无符号链接遍历(O_NOFOLLOW + dir_fd)与 fcntl.flock 无 Windows 等价物,代码在这些平台选择 fail-closed,但没有降级路径;
  2. 命令模板硬编码 POSIX shell 语法;
  3. 进程组 API(killpg/SIGKILL/SIGHUP)直接引用;
  4. 仓库此前没有任何测试 CI(仅 release workflow),以上问题无法被自动发现。

复现

任意 Windows 机器源码安装后执行:

lh-harness run --task "检查当前目录并总结其中的文件。" --no-dashboard

修复

PR #66(两个 commit)已完整修复并在 Windows 11 实测:

  • 全量测试套件 402 passed / 4 skipped / 0 failed(修复前:启动即崩)
  • 新增 Windows Job Object 封装(内核保证进程树终止,免疫 pid 复用)
  • 新增三平台(ubuntu/windows/macos)pytest CI

Fixes 通过 PR #66 交付,欢迎 review。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions