feat(goal): 增加可恢复的 headless 单目标 CLI#549
Open
Ghost-LZW wants to merge 1 commit into
Open
Conversation
Ghost-LZW
marked this pull request as draft
July 22, 2026 01:28
Ghost-LZW
force-pushed
the
feat/headless-goal-host-api
branch
from
July 22, 2026 01:56
4f75759 to
1f2763c
Compare
Ghost-LZW
force-pushed
the
feat/headless-goal-host-api
branch
from
July 22, 2026 01:59
1f2763c to
dc40e27
Compare
Ghost-LZW
marked this pull request as ready for review
July 22, 2026 02:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为什么值得进入 botmux
botmux 已有 v3 的真实 ephemeral worker、沙箱/enforcement、append-only journal、drive lease、worker fence 与 manifest validator,但程序化运行一个单独 goal 仍只能手写 DAG,再解析面向人的 CLI 输出。
本 PR 把这些现有能力收束成一个当天可用的本机产品入口:
它可直接服务本机脚本、CI、cron 和人工触发自动化,不依赖、也不感知任何外部项目或特定 controller。
本 PR 做什么
botmux goal run:位置参数、--goal-file、--stdin三种 goal 输入。createEphemeralPool,复用既有沙箱/enforcement;没有第二套 planner、scheduler 或 mutable ledger。--jsonstdout 只写一份botmux.goal-run-result/v1终态 JSON,日志走 stderr;失败也有结构化error.code/message。0succeeded、10failed、11blocked、12cancelled、13runId / active-driver conflict、14usage / startup error。--run-id是幂等键:bots.json;goal.request.json精确字节 artifact 固定进既有run.jsonenvelope;DAG 与 secret-free bot snapshot 继续固定解析后的 bot/cwd/model/sandbox。不同 goal、bot selector、cwd 或 timeout 不能复用同一 runId。~并冻结为绝对路径;从另一 cwd 重驱不会静默跑进另一个仓库。--timeout都通过既有cancelSignal→ durablerunCancelRequested→ worker drain →runCancelled路径,终态落盘后才向 stdout ack。artifacts只来自既有 manifest validator;runDirectory明示informative-only,不把私有目录布局变成 API。明确不做什么
这不是 daemon / 远程 Host API,也没有 UDS/HTTP server、事件流、controller lease 字段、跨机器 fencing 或 discovery isolation profile。上述能力若需要,将分别走 RFC / 安全评审 / Linux E2E,不在本 PR 预埋不可运行的脚手架。
因此本 PR 也不再包含旧草案中的:
agent-sidecar与第二套 durable ledger;taskId/nodeId/leaseEpoch/leaseExpiresAt等外部 controller 专用 wire 字段;REAL_RUNS_DISABLED测试门;本机操作者运行
goal run的信任模型与直接运行 botmux 相同,并且不会绕过现有 v3 沙箱/enforcement 路径。可靠性合同
SIGKILL首个 driver,再以同一 runId 恢复为attempts/002。runCancelled。runNode。goal.request.jsonexact bytes 与 SHA-256 进入 immutablerun.json,篡改 fail-closed。验证
基于最新
origin/master@f4cc4f56:pnpm build:通过pnpm exec tsc --noEmit:通过kill -91 skipped on macOStest/v3-goal-cli.test.tstest/v3-run-envelope.test.tstest/cli-root-help.test.tstest/v3-runtime.test.tstest/v3-cancel-runtime.test.tspnpm test:622 files passed / 9811 tests passed / 23 skippedgit diff --check origin/master...HEAD:通过Review
Bob 已按 B1–B6 逐项复核,并对最新
dc40e275的 absolute workingDir 增量复审通过;当前结论 approved,可以转 Ready。非阻塞 follow-up:
goal run --help目前走结构化 USAGE / exit 14,后续可补人类 help / exit 0。RUN_ACTIVE当前通过 file-lock timeout 文案分类,后续宜给withFileLock增加 typed error。后续(不阻塞本 PR)
若未来另提 daemon API RFC,应继承已经验证过的三条机制:过期 dead predecessor 的 cancel-fold 接管、per-task admission 串行化、以及受前任/自身双租约边界钳制的退避。跨机器 discovery isolation 另提 PR,并以 Linux 真实正/负 E2E 为合入门。