Skip to content

fix(canary): forward premerge base to CLI budget checks - #8242

Merged
huangruiteng merged 1 commit into
mainfrom
codex/canary-premerge-cli-base-20261107
Nov 7, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/canary-premerge-cli-base-20261107

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

loopx canary premerge --from-git-diff --git-diff-base integration/base could report integration/base while the selected CLI output budget check inherited a different comparison base. The differential could then charge the candidate for output growth already present in its target branch.

Premerge passes its selected target through the shared smoke runner. The runner sets both existing differential ref inputs in the budget child's environment, matching the CI handoff. This makes the child resolve the selected target's common ancestor with HEAD and apply the existing fixture, ceilings and growth checks. The forwarding applies to that child for both catalog and risk-profile runs. Standalone smoke-suite callers and neighboring checks retain their own environment.

Validation

  • A real CLI regression reproduced the conflicting inherited refs on the base. At this head, the selected budget child receives the named target and the default origin/main target in separate runs. Concurrent calls and standalone runs retain their separate refs. A deliberate child exit remains a failed premerge gate.
  • With both inherited ref variables cleared, the production premerge CLI invoked the actual budget wrapper and differential successfully using a named non-main ref. Git traced the budget checkout to that ref. Both arms pointed at the candidate for this transport check.
  • Focused canary tests, the smoke-suite runner smoke, Ruff, RFC pairing and the public boundary scan passed. Quick premerge passed all direct and selected checks after installing the checkout's npm development dependencies. The first local run exposed the missing dependency in the separate semantic vocabulary check.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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.1-sol | OpenAI | max | runtime_reported

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

在集成分支上提交变更的工程师,会用 premerge 检查这次提交相对目标分支的 CLI 输出增长。旧版回执可以显示 integration/base,实际预算比较却使用外部环境里的基线。这样会把目标分支上已有的增长归到候选提交,工程师得重新查找基线并重放检查。

修复后,预算子进程使用工程师在同一条命令里选定的基线,失败仍由原检查门报告。评审覆盖本地 premerge 的基线交接与比较结果。远端 CI 和合并资格有各自的判定。

改动思路 / Approach

Premerge 已掌握用户选的目标,直接检查用它计算三点差分。预算比较器也已有两条环境变量的输入,CI 会把它们设成同一值,让比较器取目标与 HEAD 的共同祖先。此处把同一选择传到 runner,由 runner 写入预算子进程的环境副本,选择和执行各自留在原来的位置。

保留现有分工,因为 premerge 持有目标选择,runner 持有子进程环境,differential 持有比较语义与预算。当前变更限于 catalog 和 risk-profile 两条 premerge 调用及 CLI 预算子进程,原有命令即可完成检查。独立 smoke-suite 与相邻检查在实测中都继续读到各自的环境。手工为每次调用设置两条变量会重复输入目标,且作用域扩到整次调用。

具体改动 / Changes

关键代码讲解

  • build_premerge_validation_gate 在入口归一化目标名。这个值给直接检查和回执,也传给 catalog 与 risk-profile 的 suite。省略目标时仍取 origin/main,指定非主干目标时,两条选查路径都携带该目标。premerge.py
  • build_canary_smoke_suite_run 将执行参数绑定到同一个 run_check,供串行、线程池和保留串行项复用。这样单次调用选中的目标随工作项进入各执行分支。并发 suite 的两条目标不同,实测各自的预算子进程都读到正确目标。runner.py
  • _run_check 仅在携带 premerge 目标且脚本为 CLI 预算 wrapper 时,给该次 Popen 的环境副本设置 LOOPX_CLI_OUTPUT_BASE_REF 与 LOOPX_CLI_OUTPUT_MAIN_REF。相邻脚本、父进程和独立执行实测仍读出原环境。退出码、输出和门禁失败由现有收集路径返回。runner.py

按 79665b97a0a453380da02e15b1b62eee895147df 的 docs/development/testing-and-quality.md 验收。Real-Path Gate 对照同一 Git fixture 经过真实 CLI launcher 和预算子进程。Regression Sensitivity 在旧实现捕获两条错误环境基线,并在该 head 读回正确值。Failure Path 验证 child exit 7 穿透到门禁并给出顶层失败。三个用例映射到现有 Canary 回归。自修复表同时新增诊断条目,要求复发时分别核对目标、子进程解析出的 ref 和候选自身的预算结果。这是排查指导,执行约束来自原门禁。测试与质量契约 回归用例

对主干的风险 / Risks

最容易被漏掉的是外层目标正确、预算进程仍看错基线,或修复后目标值串到其它检查。用同一 fixture 运行旧版,外层已回读 integration/base,实际预算进程输出 ambient-base 与 ambient-main,聚焦断言以 1 退出。指定 head 的 28 项本地测试通过,覆盖命名目标、默认值、同一 checkout 并行运行、独立 suite 和子进程失败。预算子进程退出 7 时,外层失败计数为 1,合并门为 false。作者另行走通了实际预算 wrapper,Git trace 记录了命名目标用于共同祖先解析和 detached checkout。该项 wrapper 证据覆盖目标交接,所用目标指向同一候选提交。

本地 exact-head quick premerge 的 6 个直接检查和 3 个选中检查通过。已提供的远端静态检查失败另行归因。我在同一不可变基线与 head 上重放相同 Ruff 命令,都在 tests/control_plane/test_goal_create_completion.py:184 报同一条 F841,文件 blob 相同。相关汇总项作为诊断保留,远端 CI 和合并状态仍由原门禁处理。本次复核使用 macOS 源码 checkout,尚无该 head 的跨平台运行证据。已提供的静态检查日志

我的整体评价 / Verdict

批准 65296441836a7ce4b6bad55ea8627c20707b684e 的交付范围。调用者用原命令即可获得与所选目标一致的预算结果,重复校验时也能继续用原失败回执定位真实超限。改动集中在既有 Python 子进程适配层,新增覆盖守住环境隔离和失败传播。

English verdict: APPROVE. The exact head forwards premerge's selected base to the real budget subprocess and preserves standalone behavior and failure propagation.

@huangruiteng
huangruiteng merged commit 92500fe into main Nov 7, 2026
20 of 26 checks passed
@huangruiteng
huangruiteng deleted the codex/canary-premerge-cli-base-20261107 branch November 7, 2026 09:07
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.

2 participants