Skip to content

fix(m8): 启动前按 resolved commit 校验源码资产,失败快速报错 (#488) - #491

Merged
Shadow-Azure merged 3 commits into
mainfrom
agent/asset-init-failure-52358e5a4cc7
Dec 4, 2026
Merged

Shadow-Azure merged 3 commits into
mainfrom
agent/asset-init-failure-52358e5a4cc7

Conversation

@ZTGolem

@ZTGolem ZTGolem commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

This is by an automated agent, not a human.

问题

生产运行 e996315d-ae5d-45a8-bc04-bf2cd60bb601(模板 702e7b83-...,运行名「评测 · SWE-bench Verified · train · v2026.11-split-train」)启动成功,但 100/100 用例在 init 阶段失败,failure_counts 只有 asset_source_init_failed。直接根因是 OpenSpec-cn 的源码构建只跑 tsc、不把 design.md 复制进 dist;平台侧的 resolve_assets 只使用历史 load test 冻结生成资产,没有按 resolved commit 执行 install/init,所以启动预检显示 ready,问题直到 Runner 逐用例重建资产才暴露。

修改

  • source mode 在解析资产时下载 pinned source archive,并按 resolved commit 执行 install + init;使用本次生成的资产做 selection、digest、bundle 和 manifest.load_test,不再沿用历史 load test 的生成内容。
  • _execute_load_test 增加 timeout 与 require_generated;resolve 侧允许 init 生成空集(只选 Git 资产时),但选中生成资产缺失时返回 asset_source_init_incomplete。
  • manifest.source_validation 记录校验版本、resolved commit、ran_at/duration;SOURCE_VALIDATION_VERSION 进入 request/selection digest,旧快照(含 49c118ed)失效并重新校验;复用路径额外校验 manifest 的版本和 commit。
  • 校验失败映射为启动错误:asset_source_init_failed / asset_source_install_failed / asset_source_init_incomplete(422,permanent),asset_source_validation_timeout / asset_source_validation_unavailable(503,retryable);details 使用 asset_phase(不是 phase,避免与启动步骤键冲突),保留 bounded log_tail;校验日志不写命令文本,避免把 admin 配置里的 URL/token 暴露给非管理员。
  • 新增 flow 条目 m8-source-launch-validation,关联 [m8-22] 源码构建资产缺失未在启动前校验,全量模板 100/100 资产初始化失败 #488。

验证

  • pytest tests/backend/test_agent_assets.py tests/backend/test_eval_templates.py tests/backend/test_eval_launch_jobs.py -q:106 passed on Python 3.12.
  • ruff check on the changed backend/test files: passed.
  • 检视修复:补 install 失败、timeout、legacy 快照、async details 等回归测试;超时降到 240s/命令;诊断行取 init 输出;瞬时 install 失败映射 503。
  • npm test: 130 passed; npm run verify:flow: ok.
  • 冒烟:本地控制面 + 真实 launch modal;用一个 init 必失败的 source,launch 现在在「解析 Agent 资产」阶段失败并显示 asset_source_init_failed,不创建 run(截图见下)。
  • 冒烟矩阵:
场景 结果 证据
原型 prototype/index.html 启动弹层基线 PASS 布局/字段基线
修复后 init 失败启动 FIXED 错误码 asset_source_init_failed、阶段:init、无 run

Before / After

Before(生产旧行为):启动成功、创建 run,100/100 用例在 init 阶段失败(asset_source_init_failed),没有机会在启动阶段阻断。

After(本 PR 本地冒烟):启动在资产解析阶段失败,弹层显示 asset_source_init_failed 与 阶段:init,不创建 run;布局与 prototype/index.html 的启动弹层一致(无前端代码改动)。

After: launch fails fast

Prototype launch modal baseline

限制

  • 上游 chenmr0/OpenSpec-cn 的 build.js 修复不在本仓库;本 PR 先保证平台快速失败,不再派发 100 个必失败用例。6 个全量模板要恢复执行,需要上游修复后重新加载测试,或把 asset_ref 固定到 a7ec200/8fdc456 并重跑 load test。
  • 同一 commit 的不同请求形状(不同 paths)会各自执行一次 install/init;后续可加 validation 缓存优化。
  • 非 async 的 source-mode 启动仍可能超过网关 60s;控制台走 async,机器触发建议也用 async。
  • source 页的 ready 仍是默认 ref 的旧 load-test 记录;per-commit 记录在 snapshot 的 source_validation 里。
  • 校验在 API host 上执行,是 runner 容器内 install/init 的代理;真实执行仍由 runner 按 commit 重建。
  • 未合并、未关闭 issue;需要人工合并。

dsh-superagent produced this pull request under the ZTGolem account.

@ZTGolem ZTGolem added this to the 问题修复 milestone Dec 4, 2026
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