Repository navigation
fix(release): serialize integrated canary smoke, cap macOS shards, add --ensure-chat-bundle - #10248
Conversation
…d --ensure-chat-bundle Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
受影响对象与触发任务:运行 full-public 套件的开发者与执行 scripts/qualify_release_commit.py 的本地发布资格操作者。改进前,在 18 核 Apple Silicon 上执行发布资格检查时,12 分片并发会压满性能核引发 10s 超时,full-public --jobs 4 会把约 14.9s 的集成冒烟拖到 74.18s 失败;改进后,集成冒烟自动在并发批次结束后串行执行,macOS 默认并发收敛至 8 分片,按需可附带 --ensure-chat-bundle 校验或构建前端包且不污染受跟踪文件。可观测改进效果:control-plane-integrated-canary-smoke.py 在 parallel_jobs=4 时被排入串行收尾阶段;default_pytest_parallelism 在 18 核 macOS 返回 8 而 Linux 保持 12;--ensure-chat-bundle 默认关闭且开启时仅在 verify --source 失败时执行 build --install 与二次 verify。非目标边界:不修改 Linux 分片公式,不改变已有 --shards 显式参数语义,也不将 --ensure-chat-bundle 设为默认行为。
改动思路 / Approach
整体设计遵循最小复用原则:三项机制均直接落在既有权威边界内,未引入新状态拥有者或跨层耦合。当前 PR 边界:仅包含上述三项独立可验证、可逆的发布流水线改进及对应单测。具体而言,针对集成冒烟的 CPU 竞争问题,直接在 loopx/canary/runner.py 的 SERIAL_SMOKE_SCRIPTS 注册表登记 control-plane-integrated-canary-smoke.py,复用两阶段调度机制在普通并发冒烟之后串行执行,避免放宽 60s 硬延迟预算而掩盖真实性能回归;针对 macOS 并发超卖,在 scripts/qualify_release_commit.py 的 default_pytest_parallelism 增加 platform_name 感知,将 darwin 收敛至 min(8, max(1, cpus // 2));针对前端包准备,以默认关闭的 --ensure-chat-bundle 调用既有 scripts/chat_bundle.py,并在前后两次调用 _require_clean_source 保证洁净树约束。
具体改动 / Changes
依据规格文档 docs/product/release-readiness.md(提交基线 a54c53d25afdaa53a710141095b831cafb42b12d)中的单波分片并发与洁净源码检出约定,本 PR 三项验收标准均已落实:OPT1-SERIAL-CANARY(implemented)、OPT1-DARWIN-SHARDS(implemented)、OPT1-ENSURE-CHAT-BUNDLE(implemented)。
关键代码讲解
SERIAL_SMOKE_SCRIPTS(loopx/canary/runner.py):新增"control-plane-integrated-canary-smoke.py"条目并附简洁原因说明。在build_canary_smoke_suite_run中,_serial_smoke_reason按规范化命令的脚本 basename 精确查表,将其归入serial_indexes,使其在并行ThreadPoolExecutor阶段结束后按序执行并打上serial_execution_required=True标记。default_pytest_parallelism(scripts/qualify_release_commit.py):新增关键字参数platform_name: str | None = None。当(platform_name or sys.platform).lower() == "darwin"时返回min(8, max(1, cpus // 2))(18 核 Apple Silicon 返回8),其余平台保持max(1, min(12, round(cpus * 2 / 3))),且显式--shards覆盖不受影响。_ensure_chat_bundle与main(scripts/qualify_release_commit.py):_ensure_chat_bundle先运行scripts/chat_bundle.py verify --source(捕获子进程输出避免污染 JSON stdout),返回 0 时直接返回;非零时依次运行build --install与二次verify --source,任一步失败即抛出含错误详情的RuntimeError。main仅在args.ensure_chat_bundle为真时于初始_require_clean_source后调用它,并在完成后再次校验post_bundle_source == source。
对主干的风险 / Risks
本次改动面窄且可逆,主要风险边界及防控措施如下:
- 默认分片变更与测试兼容:在 macOS 宿主机直接无参调用
default_pytest_parallelism(18)的返回值由12收敛至8,已同步更新tests/control_plane/test_release_commit_qualification.py明确覆写测试darwin与linux及--shards覆盖语义。 --ensure-chat-bundle默认关闭隔离与脏树防护:未传递该开关时main完全跳过_ensure_chat_bundle,保持 100% 默认路径等价性(单测已证实不触发chat_bundle.py);启用时前后的双次_require_clean_source校验会阻断任何非 gitignored 改动。- 残余边界:单测中对
_run_check及临时仓库中chat_bundle.py使用轻量桩替代完整 Vite 构建,真实 8 分片全量发布资格运行留待发布候选提交门禁执行。
我的整体评价 / Verdict
本 PR 精准解决发布流水线中的真实可靠性痛点,long_horizon 与 user_experience 均判断为 improved(UI 视觉评审 not_applicable),code_volume(necessary)、change_proportionality(proportionate)、architecture_assessment(retain)、default_off_isolation(isolated)、authority_semantics(aligned)及 semantic_alignment(aligned / local_only)均满足要求,且 observable_semantics 已验证为 intentional_change_validated。
本地验证汇总(exact head 5410795411e4d6e643c78b562b63dbec85d33af1):
- 针对性单测(
uv run --extra test python -m pytest -q tests/canary/test_premerge_parallel_and_dedup.py tests/control_plane/test_release_commit_qualification.py):PASS(51 passed in 22.82s) - 代码规范与类型检查(
ruff check4 files &mypy --follow-imports=silent2 files):PASS - 公共边界检查(
loopx check --scan-path ...):PASS(errors=0,4 files clean) - Pre-merge 门禁(
loopx canary premerge --from-git-diff --git-diff-base origin/main -j 1):PASS(6 direct checks + 18/18 smokes passed,含semantic-vocabulary-drift-smoke.py)
English verdict: APPROVE PR #10248 at exact head 5410795 — serial isolation for control-plane-integrated-canary-smoke.py, darwin shard cap at 8, and opt-in --ensure-chat-bundle with clean-source enforcement are locally verified with 51/51 targeted pytest cases, ruff/mypy, public boundary scan, and 18/18 canary premerge checks passing.
Summary
Improves release qualification and pre-merge canary pipeline reliability without altering existing default qualification semantics:
loopx/canary/runner.py):control-plane-integrated-canary-smoke.pytoSERIAL_SMOKE_SCRIPTSwith rationale: it enforces a strict<= 60swall-clock latency budget across real File+SQLite loops and can false-fail under parallel CPU contention (~74.18s > 60sunderfull-public --jobs 4vs~14.9sisolated serial).scripts/qualify_release_commit.py):default_pytest_parallelism(cpu_count=None, *, platform_name=None)sodarwincaps default single-wave shard concurrency atmin(8, max(1, cpus // 2))(8 shards on 18-core Apple Silicon instead of 12, avoiding P-core oversubscription timeouts), while preserving Linuxmax(1, min(12, round(cpus * 2 / 3)))and explicit--shardsoverrides unchanged.scripts/qualify_release_commit.py):--ensure-chat-bundle(defaultFalsefor full CLI parity). When enabled on a clean checkout, it verifiesscripts/chat_bundle.py verify --source, builds and re-verifies (build --install+verify --source) into gitignored/loopx/web/chat/if needed, and re-verifies clean git source identity.tests/canary/test_premerge_parallel_and_dedup.py: verifycontrol-plane-integrated-canary-smoke.pyserial classification and execution ordering underparallel_jobs=4.tests/control_plane/test_release_commit_qualification.py: verifydefault_pytest_parallelismacross core counts ondarwinandlinux,--shardsoverride parity, and--ensure-chat-bundledefault-off and opt-in build/re-verify behavior.Local Verification (Source Checkout)
uv run --extra test python -m pytest -q tests/canary/test_premerge_parallel_and_dedup.py tests/control_plane/test_release_commit_qualification.py->51 passeduv run --extra test ruff check loopx/canary/runner.py scripts/qualify_release_commit.py tests/canary/test_premerge_parallel_and_dedup.py tests/control_plane/test_release_commit_qualification.py->All checks passed!uv run --extra test mypy --follow-imports=silent loopx/canary/runner.py scripts/qualify_release_commit.py->Success: no issues found in 2 source filesloopx check --scan-path ...->errors=0, public boundary scan clean (4 files)loopx --format json canary premerge --from-git-diff --git-diff-base origin/main -j 1->ok: true,direct_check_count: 6,selected_check_count: 18,executed_check_count: 18,failure_count: 0