Skip to content

Fix task child runtime selection for WorkSwarm on Windows - #579

Merged
jiangkuaixue123 merged 1 commit into
mainfrom
codex/371-workswarm-child-runtime
Nov 22, 2026
Merged

jiangkuaixue123 merged 1 commit into
mainfrom
codex/371-workswarm-child-runtime

Conversation

@zengchuang-hw

Copy link
Copy Markdown
Contributor

Refs #578
Refs #371

WorkSwarm's Windows cache can launch the task runner with an empty sys.path[0]. The caller's working directory then precedes the bundled runtime on PYTHONPATH, so a local inferrsi.py replaces the package when the child imports its executor. The same failure was reproduced on clean main b781edc2908969cc45b628adcaf62f57f2a28ad7.

The runner now prepends its own package root before that import. It still removes the Harness directory from top-level lookup, adds the task directory for sibling imports, and forwards argv/exit status as before. The change is two files: three source lines and a two-case regression. This is the bounded legacy CLI/plugin compatibility correction in #371; the author/accountable Apps parent is zengchuang-hw / Codex. It adds no production-port scope or CI requirement.

Validation at 92a2be1e0a35bafd02c57dc3be6461e888358db7:

  • Both new isolated-child cases failed before the source change (cwd and inherited conflicting runtime), then passed. They also verify the actual executor source, task helper imports, and that generic project/candidates do not resolve from Harness.
  • tests/test_benchmark_operations.py tests/test_optimization_session.py tests/test_task_protocol_child.py tests/test_engineering_benchmark_plugins.py: 108 passed, 1 skipped on native Windows/Python 3.12.1. The original WorkSwarm failure and Codex packaged task/project entries now pass. The skip requires an explicitly supplied pinned pre-move runtime and is retained as unverified.
  • Fresh isolated sdist → core wheel with no extras → separate environment outside the checkout: full installed-package probe passed.
  • Whole-tree ruff check src tests tools and git diff --check passed.

Historical pre-fix expanded compatibility result is retained in #578: 289 passed / 1 failed, three existing tarfile warnings; the same failing case was separately reproduced on main. The full 15-file expanded group has not been repeated after this minimal fix; focused affected paths and packaging were verified above, and final-head Ready CI remains required. Native DSH, Codex Desktop and WorkSwarm host sessions were not exercised; packaged entry tests do not establish those host lifecycles. Windows/macOS advisory jobs remain non-blocking. No campaign, model-quality or service-gain claim is made.

The PR is Ready. Merge requires two eligible independent final-head approvals, passing required checks and squash to main. Bug completion will be recorded separately with Delivered/Verified/Limits; parent #371 retains its shared production CPU acceptance.

Use the runner file to select its package root before importing the executor. Keep task sibling imports and isolate Harness top-level names.

Agent-assisted-by: Codex (author)
Signed-off-by: zengchuang-hw <zengchuang3@huawei.com>

Copy link
Copy Markdown
Contributor Author

@Dong1017 @amy-why-3459 @david6666666 请检视这个独立两文件修复。当前 head 92a2be1e0a35bafd02c57dc3be6461e888358db7;实际 main 复现、两个新增负例的修改前失败,以及修改后 108 项相关测试和 bare-wheel 独立安装通过,均在说明中记录。请重点核对 _run_entry 先选取自身包根、仍不把 Harness 目录暴露为顶层模块、任务 sibling imports 与参数/退出状态兼容。

该修复从 main 独立切出,不包含 #562/#564/#565 的未合入代码,也不改变 #429/#434 原有责任。两份有效独立审批和 CI 通过后按 squash 合入;原 Windows/macOS advisory 规则保持不变。

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

PR review verdict — PASS
Reviewed base b781edc and head 92a2be1 (full diff, 2 files). No prior formal reviews and no outstanding CHANGES_REQUESTED were seeded. This is a single Dong-bot (authorized delegate) vote. The two-approval merge rule still applies.

Verified:

  • optimization_session._run_entry now inserts runner.parent.parent (the src root containing inferrsi) at sys.path[0] after it removes the runner directory. It does this before from inferrsi.harness.trials.external import execute_trial. That is the intended fix. With an empty or foreign sys.path[0], a cwd or inherited inferrsi.py can no longer shadow the selected runtime.
  • The task-entry directory is still inserted at index 0 afterwards, so task-local imports such as helper still win. The runner directory stays removed, so project and candidates do not resolve from Harness. The test asserts both.
  • The caller benchmark_operations.run_task launches optimization_session.py as a file with sys.executable. The change therefore applies to the real launch path.
  • The new test, parametrized over cwd and other-runtime shadows, runs -I -S and reproduces the empty-sys.path[0] startup by hand. inferrsi/__init__.py, trials/external.py and local_process.py import only stdlib or package-relative modules at module level. That is consistent with running under -S without installed dependencies. The test also asserts that execute_trial comes from the selected runtime file, which would fail against the shadow modules without the fix.
  • bootstrap uses runpy.run_path with the default run name, so the __main__ guard does not fire. _run_entry is called directly, as intended.

Not verified here: I did not run the tests or see CI results, and I did not run anything on Windows. The Windows extended-path behavior is reasoned from the diff and the test construction. Optional note only: the inserted src root stays on sys.path for the task. That is harmless here because it contains only inferrsi, but it would be worth a comment if the package layout changes.


@Dong1017 Dong1017 added the kind:task Bounded delivery task with a delegated slice label Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

当前有 Dong1017 的一份正式 current-head LGTM / Approve(此独立 bug 的实现和 Apps 问责方为作者 zengchuang-hw,Dong 未参与实现)。已核实其当前仓库权限为 write;仍缺第二份独立有效批准,CI 正在排队/执行。

@hsliuustc0106 如有空请协助复审这个两文件最小修复;@amy-why-3459 @david6666666 的原检视请求仍保留。有意见先处理,满足两份有效审批及 CI 后再 squash 到 main。

Copy link
Copy Markdown
Contributor Author

当前 head 92a2be1e0a35bafd02c57dc3be6461e888358db7 的 Ready CI 已全部通过:45035709901。本地 108 项相关测试与 bare-wheel 完整 probe 通过;当前已有 Dong1017 的一份有效独立 LGTM / Approve,仍缺第二份。

@amy-why-3459 @david6666666 @hsliuustc0106 请协助当前头复审。仅两文件、生产代码三行,现有行为/失败和负例记录均在说明中。有意见先修,第二份有效独立批准到达后核验检查与当前头,再 squash 合入 main;不将未回复视为同意。

Copy link
Copy Markdown
Contributor Author

@jiangkuaixue123 请协助检视这个两文件的独立兼容修复,当前 head 92a2be1e0a35bafd02c57dc3be6461e888358db7,Ready CI 已全绿,108 项相关测试及 bare-wheel 完整 probe 通过。目前只有 Dong 的一份有效独立批准;请实际阅读改动和回归证据后给出结论,有意见先处理。此 bug 的普通两票规则没有 #565 的指定席位限制。

@jiangkuaixue123 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PR review verdict — PASS

Reviewed main base b781edc2908969cc45b628adcaf62f57f2a28ad7 and head 92a2be1e0a35bafd02c57dc3be6461e888358db7 against #578. The task child selects the runner's bundled runtime before importing the executor. Task-local imports, executor injection, argument forwarding, exit status, and the Harness import boundary are covered by the focused tests.

Independently ran the two new regression cases against the base and head on macOS with Python 3.12. Both reproduced the expected shadowing failure on the base and passed on the head. The four focused test files finished with 108 passed and one skip for an unavailable pinned pre-move runtime. Ruff and the PR diff check passed. Ready CI passed for the reviewed head. The original Windows WorkSwarm reproduction and retest are recorded in #578.

Codex performed the independent review and submitted this revision-scoped approval on behalf of @jiangkuaixue123 with the account holder's explicit authorization for PR #579. Review request.

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

Labels

kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants