Repository navigation
refactor(explore): reuse canonical finding order projection - #8915
Conversation
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com> Co-authored-by: TRAE CLI <traecli@bytedance.com>
cocolord
left a comment
There was a problem hiding this comment.
Reviewer: model_agent, GPT-5, OpenAI, self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
受影响的调用方是启用 Work Yardstick 的 Explore turn-context 读取器,以及依赖稳定 finding 顺序来关联普通执行反馈的后续工作。改动前,canonical result projection 已经折叠并排序 append-only finding,但 explore_turn_context 又重新折叠同一日志、构造第二张 order map;两条生产路径必须永久保持一致,增加维护和回归成本。改动后,canonical projection 通过内部 opt-in 直接携带同一 ordinal,Yardstick 读取器复用它,并删除第二套 fold/order-map producer。可观察结果是:启用 Yardstick 时方法反馈仍按原 append ordinal 关联;默认公开 history 与禁用路径继续不暴露 recorded_order。本 PR 不改变持久化事件、公开 schema、方法选择策略、lease/fencing、权限、结算或 replay checkpoint,也不宣称模型采用、校准收益或跨任务收益。
这是一条有用但有边界的 Subtraction Gate 增量:它完成了一个已证明重复 producer 的退役,但整个 mechanism-convergence RFC 的 C1/C4/C9 收敛、真实采用与 outcome 证明仍然开放。
改动思路 / Approach
权威事实仍然是 append-only Explore result log;result_log._fold_by_result_id 继续唯一地产生 canonical _recorded_order。当前 PR 让 build_explore_result_projection 接受一个默认 false 的内部参数,并由 explore_turn_context 仅在 work_yardstick_enabled 为真时请求 ordinal。这样 projection owner 负责一次折叠和排序,Yardstick typed owner 只消费结果,不再让 adapter 重新生产同一事实。
架构判断为保留该边界:canonical folding 属于 projection owner;目标方法选择与有效性判断仍属于 TypeScript Yardstick owner;本 PR 只删除 Python adapter 中重复的 local helper 逻辑。当前 PR 边界是单一 producer 收敛与 caller 迁移,不新增状态、CLI、协议或 effect。base/head 对照证明默认 projection 哈希保持一致,内部 opt-in 才增加 ordinal,因此 shared surface 的默认兼容性与 feature-off isolation 均保留。
具体改动 / Changes
评审依据是 docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.md,固定 revision f757bb181f9391194db37905470c2256d1d168a7。
5.5-Subtraction-Gate:要求迁移真实 caller、退役重复 normal producer,并保留内核不变量。本 head 将 Yardstick turn-context 迁移到 canonical projection 的 opt-in ordinal,并删除第二次 fold/order-map reconstruction;exact-head Python 88/88、TS 31/31 与 standard premerge 5/5 通过。5.6-Source-Checkpoint:要求 ordinal 只供 opted-in work reader,公开 history 与 disabled behavior 保持原 wire。base/head 同 fixture 的默认 projection 哈希均为2984bd2f0252bb7d7ed370d1de16c10081d1929622b023d231099007812e76c9且不含 ordinal;head 内部 opt-in 返回[1, 0]。
关键代码讲解
loopx/capabilities/explore/result_log.py:build_explore_result_projection新增include_internal_finding_order=False。它把 canonical fold 已有的_recorded_order通过_finding_view有条件投影,不改变默认 caller。loopx/capabilities/explore/result_log.py:_finding_view集中决定 ordinal 是否进入内部 view,同时继续让 measurements 与 work_yardstick 的既有消费者获得所需顺序。loopx/capabilities/explore/turn_context.py:explore_turn_context在 Yardstick enabled 时请求内部 ordinal,并删除直接调用_fold_by_result_id的第二套 producer。后续project_work_yardstick_sources与 TypeScriptyardstick_decision.ts继续消费相同 finding view。
对主干的风险 / Risks
最高风险有两个方向。第一,若 opt-in 条件过宽,recorded_order 会泄露到公开 history,造成 wire drift;base/head paired probe 的默认哈希一致,且 exact-head CLI 测试明确断言公开 finding 不含该字段。第二,若内部 ordinal 丢失,普通执行 feedback 会在同 timestamp、后继 decision 或 replay 情况下错误选择 source;Python Work Yardstick CLI 全套 88 个用例和 TS Explore/Yardstick 31 个用例覆盖 enabled、disabled、foreign、tentative、stale、late-visible、replay 与 successor 场景。
改动没有触及 authority、actor lifecycle、持久化格式、异常协议或 obligation 文本;不存在新 semantic vocabulary,也没有默认行为变化。远端 DCO、Python changes、dependency review 和 package smokes已成功;仍在排队的 CI 只影响 merge-readiness,当前本地 standard premerge 已覆盖本 diff 的 changed-Python compile、semantic drift、maintainability 与 Explore canaries。剩余风险主要是未执行全仓所有非相关测试,但 exact-head 定向覆盖和 risk-based premerge 对当前两处 projection 改动是充分的。
我的整体评价 / Verdict
这是比例合适的结构收敛:14 additions / 17 deletions,删除一个重复 producer,同时复用已有 canonical state owner,没有创建 wrapper、协议、配置或迁移负担。长程行为保持:方法反馈、replay 与后续选择的真实 caller 测试通过;用户体验不涉及可见 UI/CLI 变化,默认公开 projection 的 base/head 哈希一致。整个 RFC 仍有采用与 outcome 证据缺口,因此这不是 mechanism-convergence 总目标完成,但它是独立可审、可回滚且符合 Subtraction Gate 的实现切片。
未发现 blocking finding。残余风险是 GitHub 远端队列尚未完全结束;合入前仍需 exact-head merge-readiness 读回,不能用本评审替代 CI/branch policy 或 maintainer authority。
English verdict: APPROVE - exact head c6c9906 removes the duplicate finding-order producer, preserves the default public projection byte-for-byte under the paired fixture, and passes 88 Python, 31 TypeScript, and 5 selected premerge checks.
Problem
The merged Explore/Yardstick feedback path reconstructed execution-only finding ordinals in
explore_turn_contextafter the canonical result projection had already folded the same append-only history. That duplicated the producer-to-reader fold/order path.Change
This is a bounded Subtraction Gate slice. The existing execution-observation wrapper remains because benchmark callers still consume its distinct boundary.
Validation
uv run --extra test ruff check loopx/capabilities/explore/result_log.py loopx/capabilities/explore/turn_context.pyuv run --extra test mypy loopx/capabilities/explore/result_log.py loopx/capabilities/explore/turn_context.pyGenerated
uv.lockwas not committed.