Skip to content

fix(dsh): pin continuation Core commands to the resolved CLI executable - #9309

Open
LIHUA919 wants to merge 2 commits into
loopx-project:mainfrom
LIHUA919:codex/dsh-cli-parity-9300
Open

LIHUA919 wants to merge 2 commits into
loopx-project:mainfrom
LIHUA919:codex/dsh-cli-parity-9300

Conversation

@LIHUA919

Copy link
Copy Markdown
Contributor

Fixes #9300

Goal / source

Issue #9300 (source review by @xiaobaifly7): DSH continuation Turns carry Core-rendered text that always prefixes bare loopx — heartbeat-prompt --thin task bodies and quota should-run settlement command_template strings both render through loopx_cli_argv() — while the plugin's /loopx skill runs the command the plugin resolved (LOOPX_BIN, PATH loopx, managed launcher, or python -m loopx.cli). When the Agent shell's PATH names a different LoopX install, guard/writeback/settlement run a different Core binary than admission used.

Gap

The Driver called heartbeat-prompt and quota should-run without --cli-bin, and the plugin exports no LOOPX_BIN/PATH adjustment for the Agent shell.

Change (packages/dsh-loopx-plugin)

  • resolveLoopXCommand derives a one-executable Core route (LoopXCommand.cliBin) for single-executable candidates: a configured LOOPX_BIN passes through as-is (absolute) and the bare loopx PATH candidate resolves against the probe PATH to that absolute file (first executable match, mirroring spawn discovery). Core's validate_cli_bin rules are respected — no shell text such as "$LOOPX_BIN" is ever passed.
  • The Driver passes the route as the global --cli-bin on quota should-run (pins settlement/recovery templates rendered through loopx_cli_argv()), and as both the global option and the heartbeat-prompt subcommand option on heartbeat-prompt --thin (the subcommand value is what task-body command prefixes embed). Rendered text starts with <abs> --cli-bin <abs> ..., which re-pins every nested Core invocation.
  • Host-injected commands that predate the field keep their plain file route (coreRouteBin); the Driver never re-resolves an injected name against its own PATH.

Managed-launcher / module form (honest limitation)

An interpreter-plus-script/module invocation (python loopx_cli.py, python -m loopx.cli) cannot be expressed as one --cli-bin value, and passing only the interpreter would render broken commands. For these forms the Driver keeps Core's bare loopx route (unchanged behavior), discloses once in its warning log (cli_route_unpinned with the closed candidate label), and documents the LOOPX_BIN-to-absolute-executable remedy in the plugin README.

Validation

  • Red/green with an independent oracle: new driver tests assert the argv handed to Core contains the absolute --cli-bin route in the global position (and both positions for heartbeat-prompt) instead of the previous bare-loopx-only prefix; red on the pre-fix tree, green after.
  • Resolver tests: absolute configured path passes through; bare configured and PATH loopx names resolve against the probe PATH; PATH precedence and non-executable files are skipped; interpreter-prefixed routes stay unpinned; unresolvable bare names degrade to the probed name (never an invented path).
  • Full plugin suite: 381 passed (372 baseline + 9 new), including the real-Path admission-closeout integration spec that runs the real Core (python -m loopx.cli) through the new flags; pnpm typecheck green.
  • Real-Core render check: heartbeat-prompt --thin --cli-bin /opt/pinned/loopx renders thin_prompt_command: /opt/pinned/loopx --cli-bin /opt/pinned/loopx ... --registry ... heartbeat-prompt --thin ....
  • uv run --extra test loopx canary premerge --from-git-diff --git-diff-base f4eeed9d325bfd6e8994175798a8d7480ab8c199: ok (direct checks, catalog canaries, risk profile smokes incl. dsh-loopx-plugin quality/package/runtime, public boundary).

Boundary

Plugin runtime + tests + plugin README only; no Core Python change (Core's --cli-bin semantics and validators are already covered by tests/test_command_invocation.py). No UI surface changed, so no first-screen capture applies.

The DSH continuation Driver rendered automatic-Turn text through Core
without --cli-bin, so thin heartbeat task bodies and quota settlement
command templates always prefixed bare loopx: when the agent shell's
PATH names a different LoopX install than the plugin-probed command,
guard, writeback and settlement ran a different Core binary than
admission used (loopx-project#9300).

resolveLoopXCommand now derives the one-executable Core --cli-bin route
for single-executable candidates, resolving bare names against the probe
PATH to that absolute file, and the Driver passes it as the global route
on quota should-run and as both the global and heartbeat-prompt options
so rendered task bodies embed the pinned executable. Host-injected
commands without the new field keep their plain file route.

Interpreter-prefixed routes (managed launcher, python -m loopx.cli)
cannot be expressed as one --cli-bin executable; their continuation text
keeps Core's bare loopx route and the Driver discloses that once in its
warning log, with LOOPX_BIN pointing at one absolute executable as the
pinning remedy.

Signed-off-by: Lihua <1017343802@qq.com>

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

[P2] 相对 PATH 让续跑仍能选中另一套 Core。 设置 PATH=bin:/usr/bin:/bin,在宿主、项目和 Agent 三个 cwd 下放置各自的 bin/loopx。路由被保存为 bin/loopx。版本探测、Driver 的 runJsonCommand 与切换 cwd 后的渲染路由执行分别命中三个不同文件。 解析和版本探测应共享同一个实际可执行路径,业务 spawn 与 Core 渲染的 --cli-bin 使用该绝对路径。无法绑定时沿既有 fallback 给出可诊断状态。 准确头源码

动机 / Motivation

用 DSH 启动或续跑 LoopX Goal,且宿主、项目或 Agent shell 使用不同工作目录及安装的用户。 基线的 Core 续跑正文及结算模板默认写入裸 loopx,由 Agent shell 的 PATH 决定运行实例。

该 PR 对绝对 PATH 文件能固定 Core。PATH 含相对目录时,版本探测、Driver 准入及 Agent 续跑仍会因 cwd 改变而使用手边不同的程序。 Node 实际启动三个隔离版本,依次命中 host、project、agent。单改为绝对路径的对照中,续跑仍使用 host 原版本。 现有 Core 继续拥有回执、写回与结算。这个窄修评估 DSH 的命令选择和传递。

改动思路 / Approach

DSH adapter 持有 executable 发现和子进程传输,Core 持有命令模板和准入回执验证。 解析和版本探测应共享同一个实际可执行路径,业务 spawn 与 Core 渲染的 --cli-bin 使用该绝对路径。无法绑定时沿既有 fallback 给出可诊断状态。 在 DSH resolver 和现有 Core --cli-bin 之间固定单文件可执行路径。解释器加脚本的传输另行处理,作为明确披露的未覆盖分支。

本次以 GitHub #9300 的契约核 SAME_CORE_EXECUTABLE 与 NESTED_CORE_ROUTE。续跑使用与 plugin 探测的 Core 同一可执行来源。 heartbeat 正文、guard 及结算模板都使用同一可执行来源。 依据

具体改动 / Changes

实际合并基点到准确头是 5 files +367/-8。真实合并基线为 f4eeed9。当前 GitHub base 的 Core 命令路由文件与该合并基点同 blob,新主干合成无冲突。

关键代码讲解

  • coreCliBinRoute 扫描 PATH 并把同一个程序名称交给 Core。join 保留相对路径,且候选 spawn 仍使用裸名称。 准确头源码
  • resolveLoopXCommand 在宿主工作目录探测版本,返回 file 和独立计算的 cliBin。 准确头源码
  • readQuota 在 Session 工作目录运行原命令,并把计算后的路由传给 Core 的 guard 模板。 准确头源码
  • readHeartbeat 同时在全局和 heartbeat 子命令参数传递同一路径,由 Core 渲染任务正文。 准确头源码

对主干的风险 / Risks

PASS。绝对 PATH 目录下,resolver 给出绝对路径。即使 Agent 换了工作目录且 PATH 仍含另一个安装,绝对路径控制组仍命中原宿主可执行文件。 当前精确头 381 项包测试和 TypeScript 检查通过,包含原包的真实 Core closeout 集成。独立的实际子进程实验覆盖绝对成功与相对失败;未向远端查询 CI。

FAIL。 设置 PATH=bin:/usr/bin:/bin,在宿主、项目和 Agent 三个 cwd 下放置各自的 bin/loopx。路由被保存为 bin/loopx。版本探测、Driver 的 runJsonCommand 与切换 cwd 后的渲染路由执行分别命中三个不同文件。 Node 将有效的相对 PATH 和配置路径绑定到各次 spawn 的 cwd,生成的续跑前缀可以再次改变安装来源。

语义与 CI 对齐

只在已激活的 Session 续跑读取 guard 和 heartbeat。单文件 route 有值时添加参数,解释器前缀沿既有裸命令分支。 Executable selection is host-local. Binding, Goal authority and settlement policy remain inside Core. 绝对路径适用范围在 README 已说明。相对路径仍发生选择偏移,应在同一 resolver 归一化并测试。 相对路径问题通过真实 Node 子进程和隔离可执行文件复现。现有真实 Core 集成测试及 381 项包测试通过。尚未在 Windows 和挂载的 Agent shell 做现场验证。

我的整体评价 / Verdict

这次修复应留在 DSH 命令适配器。让可执行文件解析、版本探测、guard 和生成的续跑命令共用一个路径,然后复验目录切换。 在 DSH resolver 和现有 Core --cli-bin 之间固定单文件可执行路径。解释器加脚本的传输另行处理,作为明确披露的未覆盖分支。 相对路径问题通过真实 Node 子进程和隔离可执行文件复现。现有真实 Core 集成测试及 381 项包测试通过。尚未在 Windows 和挂载的 Agent shell 做现场验证。

English verdict: REQUEST_CHANGES at 94292f3. A relative PATH directory can make the version probe, Driver admission, and rendered continuation select different LoopX executables. Bind both execution and rendering to the same verified executable.

Comment thread packages/dsh-loopx-plugin/src/cli.ts Outdated
const searchPath = env.PATH ?? env.Path
for (const directory of searchPath?.split(delimiter) ?? []) {
const resolved = probeExecutableFile(directory, name)
if (resolved !== undefined) return resolved

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.

[P2] 相对 PATH 让续跑仍能选中另一套 Core。 设置 PATH=bin:/usr/bin:/bin,在宿主、项目和 Agent 三个 cwd 下放置各自的 bin/loopx。路由被保存为 bin/loopx。版本探测、Driver 的 runJsonCommand 与切换 cwd 后的渲染路由执行分别命中三个不同文件。

解析和版本探测应共享同一个实际可执行路径,业务 spawn 与 Core 渲染的 --cli-bin 使用该绝对路径。无法绑定时沿既有 fallback 给出可诊断状态。 在多个 cwd 下使用同名不同标识的真实可执行文件。分别执行版本探测、Driver guard 和渲染命令,断言实际命中同一文件,覆盖裸名称和相对 LOOPX_BIN。

Review P2 on loopx-project#9309: a relative PATH entry (PATH=bin:/usr/bin:/bin) let
coreCliBinRoute store a relative route (bin/loopx), so the version probe
(host cwd), driver admission spawns (Session cwd), and the rendered
Core route execution (agent cwd) could each select a different loopx
install; the continuation prefix could still change the Core source.

The resolver now binds one absolute executable before probing:
explicit paths normalize against the discovery working directory, bare
names resolve to the exact PATH file, and relative PATH entries are
made absolute at discovery. The bound path becomes the candidate file,
so the version probe, every business spawn, and the Core-rendered
--cli-bin text run the same file. When no single executable can be
bound (unlocatable name, illegal --cli-bin value), the candidate keeps
bare probe semantics, Core keeps its bare loopx fallback route, and the
driver's existing typed warning discloses the unbound state;
coreRouteBin now only validates the resolver-bound route.

Adds a real-subprocess three-cwd regression matrix (probe, driver
admission from the Session cwd, and sh -c execution of the rendered
route in the agent cwd) with per-directory decoy installs, plus the
absolute-PATH control group; the relative case is red on 94292f3 and
green now, the control holds in both.

Signed-off-by: Lihua <1017343802@qq.com>
@LIHUA919

Copy link
Copy Markdown
Contributor Author

Reply to the P2 (relative PATH route drift): fixed in 920700c (single commit on top of 94292f3, same reviewable head lineage).

Normalization approach

  • resolveLoopXCommand now binds one absolute executable before probing and makes it the candidate file: explicit paths normalize against the discovery working directory (resolve()), bare names resolve to the exact PATH file, and relative PATH entries are made absolute at discovery (join(resolve(directory), name) with an executable-bit check). The version probe, every later business spawn (runJsonCommand), and the Core-rendered --cli-bin text therefore all run the same file — SAME_CORE_EXECUTABLE and NESTED_CORE_ROUTE for the relative case too.
  • When no single executable can be bound (unlocatable name, illegal --cli-bin value), the candidate keeps bare probe semantics, Core keeps its bare loopx fallback route, and the driver's existing typed warning discloses the state once (cli_route_unpinned with the closed candidate label). coreRouteBin is now a validating accessor over the resolver-bound cliBin only; it never re-resolves or invents a path.
  • Interpreter-prefixed routes (managed launcher, python -m loopx.cli) stay on the unpinned branch with the same disclosure as before.

Three-cwd regression matrix (real Node subprocesses)

tests/driver.spec.ts → route binding across working directories reproduces your setup: PATH=bin:/usr/bin:/bin with a distinct bin/loopx fixture in the host, project, and agent directories (each script reports its own absolute path on stderr). Three stages per run:

Stage cwd Pre-fix 94292f3 Fixed 920700c
1 version probe (resolver) host host file; route stored as bin/loopx (red: isAbsolute fails) host file; route = absolute host file
2 driver admission (runJsonCommand) project session cwd project decoy file (route re-resolved) host file only
3 rendered route execution (sh -c "<route> --cli-bin <route> …") agent would re-resolve per cwd host file only

The relative-entry case is red on 94292f3 and green on 920700c; stage 2 additionally asserts every admission spawn (>3) reported the same single executable and no admission warnings.

Control group

The absolute-PATH variant of the same matrix (first PATH entry absolute, decoys still present in both other cwds) passes on both the pre-fix and fixed heads — matching your independent experiment — and an explicit absolute PATH entry stays bound exactly as written. A unit test also pins the relative-entry normalization itself (normalizes a relative PATH entry against the discovery directory), and the unlocatable-name test now expects the unpinned fallback (cliBin undefined, bare file retained).

Validation

Full plugin suite 384 passed (381 prior + matrix/control/normalization additions, including the real-Core admission-closeout integration), pnpm typecheck green, loopx canary premerge --from-git-diff --git-diff-base f4eeed9d3 (current merge-base after fetching latest main, which has not touched packages/dsh-loopx-plugin since) passed: 16 checks, 0 failures.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

[P2] 插件自管运行时仍会把续跑交给另一套 Core。 未配置 LOOPX_BIN 时,存在自管 launcher 的真实 DSH resolver 优先选中它。用准确头的 Core 渲染真实 heartbeat 正文后,首个续跑 guard 仍以裸 loopx 开头,实际运行它命中了独立 PATH 替身。当前描述的 Fixes #9300 会一并关闭这个仍存在的安装路径问题。 让插件自管入口提供可直接执行、指向原隔离 runtime 的 launcher,向现有单可执行文件接口传它的绝对路径。用另一套 PATH 做反事实,核对 guard 和结算均命中同一 Core。若本 PR 先落单文件修复,保留 #9300 待后续解决自管路径,移除自动关闭声明。 准确头源码

动机 / Motivation

从 DSH 自管运行时或显式 LoopX 安装启动 Goal 的用户,需要续跑使用 Driver 实际准入的 Core。 基线的续跑命令由 Core 以裸 loopx 输出,Agent shell 的 PATH 可以命中另一个安装。 单文件 CLI 现在在 discovery 时绑定绝对路径,随后版本探测、准入与渲染沿此路径。自管 Python launcher 仍生成裸 loopx。 未配置 LOOPX_BIN 时,存在自管 launcher 的真实 DSH resolver 优先选中它。用准确头的 Core 渲染真实 heartbeat 正文后,首个续跑 guard 仍以裸 loopx 开头,实际运行它命中了独立 PATH 替身。当前描述的 Fixes #9300 会一并关闭这个仍存在的安装路径问题。 现有 Core 继续持有 Goal 许可、quota 与回执。验收范围是已绑定 DSH Session 的命令来源一致。

以 2026-11-23T07:42:15Z 的要求核对当前准确头。SINGLE_EXECUTABLE_ROUTE 为 implemented。 MANAGED_RUNTIME_ROUTE 为 not_met。 原始要求

改动思路 / Approach

DSH adapter 拥有 CLI 发现及进程调用,Core 拥有命令模板、绑定和 Turn 准入与结算。 保留单可执行文件的路径绑定,把自管路线接到同一 Core 路由,由现有 bootstrap 提供可直接执行的 launcher。 让插件自管入口提供可直接执行、指向原隔离 runtime 的 launcher,向现有单可执行文件接口传它的绝对路径。用另一套 PATH 做反事实,核对 guard 和结算均命中同一 Core。若本 PR 先落单文件修复,保留 #9300 待后续解决自管路径,移除自动关闭声明。 旧显式绝对 file 的 host 注入命令若没有新增 cliBin 会走 unpinned。两参数的受管 launcher 是更常见的未覆盖产品路径。

具体改动 / Changes

实际合并基点 f4eeed9 到准确头共 6 files +538/-19。与当前主干合成无冲突。主干另一条 Codex 恢复提示分支不进入本次 DSH 请求。改动沿用既有 typed 记录和路由词汇,生产路径、测试和适用文档均按此差异复核。

关键代码讲解

  • resolvePluginLoopXCommand 已有自管 launcher 时正常 bootstrap 路径把它交给 discovery。 准确头源码
  • resolveLoopXCommand 对单文件绑定绝对路由,对自管 Python+脚本保留 prefix。 准确头源码
  • coreRouteBin 调用方有显式 cliBin 才能给渲染端传路由;无绑定返回 undefined。 准确头源码
  • readQuota 仅在 resolver 给出路由时由既有参数固定渲染模板。 准确头源码

对主干的风险 / Risks

复测三个工作目录的相对 PATH 反例,版本、业务 spawn 以及 Agent shell 路由均命中宿主同一文件;显式绝对 LOOPX_BIN 的真实 Core 正文也固定了路径。 未配置 LOOPX_BIN 时,存在自管 launcher 的真实 DSH resolver 优先选中它。用准确头的 Core 渲染真实 heartbeat 正文后,首个续跑 guard 仍以裸 loopx 开头,实际运行它命中了独立 PATH 替身。当前描述的 Fixes #9300 会一并关闭这个仍存在的安装路径问题。

384 个包测试、TypeScript、package/runtime 及直接运行完整 quality 阶段通过。标准 premerge 16 项有 2 项超时,都在同一 quality 阶段的 120 秒限制。 实测使用 Node 和当前源码 Core 的真实 heartbeat 渲染,以及本地替身作为另一套 CLI。没有驱动活跃 DSH Session 或查询远端 CI,也未实测 Windows。

语义与 CI 对齐

旧显式绝对 file 的 host 注入命令若没有新增 cliBin 会走 unpinned。两参数的受管 launcher 是更常见的未覆盖产品路径。 本轮使用本地准确头验证。未查询远端 CI。

我的整体评价 / Verdict

保留单可执行文件的路径绑定,把自管路线接到同一 Core 路由,由现有 bootstrap 提供可直接执行的 launcher。 未配置 LOOPX_BIN 时,存在自管 launcher 的真实 DSH resolver 优先选中它。用准确头的 Core 渲染真实 heartbeat 正文后,首个续跑 guard 仍以裸 loopx 开头,实际运行它命中了独立 PATH 替身。当前描述的 Fixes #9300 会一并关闭这个仍存在的安装路径问题。 实测使用 Node 和当前源码 Core 的真实 heartbeat 渲染,以及本地替身作为另一套 CLI。没有驱动活跃 DSH Session 或查询远端 CI,也未实测 Windows。

English verdict: REQUEST_CHANGES at 920700c. The previous relative-PATH split is fixed. The ordinary managed launcher still renders a bare LoopX guard, and the real rendered command selects another executable on the agent PATH.

: [
...managedCandidates,
{ file: 'loopx', prefix: [], skillCommand: 'loopx' },
...managedCandidates.map(spec => ({ spec, label: 'managed-launcher' as const })),

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.

[P2] 插件自管运行时仍会把续跑交给另一套 Core。 未配置 LOOPX_BIN 时,存在自管 launcher 的真实 DSH resolver 优先选中它。用准确头的 Core 渲染真实 heartbeat 正文后,首个续跑 guard 仍以裸 loopx 开头,实际运行它命中了独立 PATH 替身。当前描述的 Fixes #9300 会一并关闭这个仍存在的安装路径问题。

让插件自管入口提供可直接执行、指向原隔离 runtime 的 launcher,向现有单可执行文件接口传它的绝对路径。用另一套 PATH 做反事实,核对 guard 和结算均命中同一 Core。若本 PR 先落单文件修复,保留 #9300 待后续解决自管路径,移除自动关闭声明。 用插件自管 runtime 和另一套 PATH CLI 运行已有公开发现和真实 heartbeat 渲染,再执行生成的 guard 与结算命令,核对所有边界选中同一 Core。

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DSH continuation Turns run bare "loopx" while the plugin's /loopx skill runs "$LOOPX_BIN"

2 participants