Skip to content

fix(a2a): merge candidate step skeletons through the run-id index - #199

Open
ruanzhengxin-zhuxing wants to merge 1 commit into
mainfrom
harness/618c8f1e
Open

fix(a2a): merge candidate step skeletons through the run-id index#199
ruanzhengxin-zhuxing wants to merge 1 commit into
mainfrom
harness/618c8f1e

Conversation

@ruanzhengxin-zhuxing

Copy link
Copy Markdown
Collaborator

修正 pipeline_snapshot.py reducer 合并候选子步骤骨架的方式,消除「候选下同 id 子步骤 pending(空结论)与 completed 并存」的状态歧义。

问题

candidate_started 事件携带候选子步骤的 pending 骨架(status=pending、无 conclusion)。reducer 把这个列表当作普通坐标字段直接写进 candidate["steps"],却没有把骨架项登记到 _candidate_steps_by_run_id 索引。

因此后续 candidate_step_started / candidate_step_completed_upsert_candidate_step 查索引时查不到,会再新建一个同 runId 的 dict 并 append。同一个候选子步骤在 snapshot 里出现两份:

  • 骨架副本:status=pendingconclusion 缺失
  • 生命周期副本:status=completed,带 conclusion

这正是 pipeline snapshot 中 steps.*.candidates.*.steps.0 的状态歧义(template_generatingcost_estimating 各出现 pending 空结论 + completed 两份)。

同一缺陷在候选重启时还会丢弃已跟踪的子步骤状态,因为骨架列表每次都被整体替换。

改动

  • steps 从候选坐标中分离,骨架改为经 run-id 索引做 upsert 合并,生命周期事件复用同一 dict,不再产生同 id 副本。
  • 骨架的 status 仅作首次创建时的初始值:重复投递的骨架(候选重启、snapshot 重新水合)不会把已进入 working/completed/failed 的子步骤打回 pending,也不会清空其 conclusion
  • 骨架的展示性字段(name/index/total)仍会补齐到已跟踪的条目。

公开 snapshot schema 不变,SNAPSHOT_SCHEMA_VERSION 未改动。

验证

  • 新增 2 条回归用例:骨架 + 生命周期事件不产生同 id 重复项;重复投递骨架不回退已完成子步骤。
  • tests/a2a 全量 1434 通过。
  • ruff checkty check src/ 全通过。

`candidate_started` carries a pending skeleton of the candidate's sub-steps.
The reducer wrote that list straight into `candidate["steps"]` as part of the
coordinate merge without registering the entries in
`_candidate_steps_by_run_id`. Later `candidate_step_started` /
`candidate_step_completed` events therefore missed the index, appended a
second dict with the same `runId`, and the snapshot ended up exposing the same
candidate sub-step twice: one pending copy with no conclusion next to the
completed one. That is the `steps.*.candidates.*.steps.0` state ambiguity seen
in the pipeline snapshot.

Split `steps` out of the candidate coordinate and merge the skeletons through
the run-id index instead, so lifecycle events reuse the tracked dict. The
skeleton status is only used as the initial value, which keeps a re-delivered
skeleton (candidate restart, snapshot rehydration) from rewinding a
working/completed/failed step back to pending or dropping its conclusion.
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.

1 participant