Skip to content

refactor(quota): consume EffectTurn in TurnEnvelope runtime path - #2983

Merged
huangruiteng merged 1 commit into
mainfrom
codex/m6-q6-effect-quota-20260809
Aug 9, 2026
Merged

refactor(quota): consume EffectTurn in TurnEnvelope runtime path#2983
huangruiteng merged 1 commit into
mainfrom
codex/m6-q6-effect-quota-20260809

Conversation

@huangruiteng

Copy link
Copy Markdown
Owner

Summary

Q6 first slice: make the real runtime path consume interpret_quota_should_run_packet instead of parsing raw payload fields directly for the canonical slots.

  • build_turn_envelope now derives action.recommended_action, writeback.next_cli_actions, and scheduler.action / cadence_class through EffectTurn.
  • quota_action_signature_document and the CLI turn-envelope view use the same interpreter, so the parity contract is preserved.
  • Adds a focused test proving the envelope's canonical slots match interpret_quota_should_run_packet.
  • Updates the effect-interpreter RFC replacement status with R5 and marks Q6 in progress.

No public CLI output changes.

Validation

  • tests/control_plane + turn driver/envelope tests: 910 passed
  • turn envelope tests: 29 passed
  • maintainability ratchet: clean
  • ruff: passed
  • loopx canary premerge --from-git-diff: selected=13 failures=0, self_merge_allowed=true, public boundary passed

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: APPROVED

head 02fc7d17c4fde507afd8d5667ec52a2444e79afa。这是对 refactor(quota): consume EffectTurn in TurnEnvelope runtime path 的完整 PR 解读,覆盖 3 个改动文件、TurnEnvelope 运行时路径、RFC 状态与 parity 测试。GitHub 不允许作者审批自己的 PR,因此以 COMMENTED 发布作者自有回退态,但评审结论是无 blocker。

动机

interpret_quota_should_run_packet 已经能把 quota should-run payload 解释成 EffectTurn,但 build_turn_envelope 仍直接手写读取 recommended_actionnext_cli_actions、scheduler action/cadence 等 canonical slots。两条路径会漂移。这个 PR 让真实运行时 TurnEnvelope 消费同一个 EffectTurn,统一来源。

改动思路

  • build_turn_envelope 内部新增 _quota_effect_turn(),用 interpret_quota_should_run_packet 生成 EffectTurn
  • _action_projection / _scheduler 接收 EffectTurn,canonical slots 优先从 EffectTurn 派生,缺失时 fallback 到原 payload 字段。
  • quota_action_signature_document 与 CLI turn-envelope view 复用同一 interpreter,保持 parity。
  • RFC 更新 R5 完成状态,Q6 标记 in progress。

具体改动

  • loopx/control_plane/quota/turn_envelope.py:新增 _quota_effect_turn()_scheduler() / _action_projection() 消费 EffectTurn
  • tests/test_turn_envelope.py:新增 parity 测试,证明 envelope 的 recommended_action、next_cli_actions、scheduler.action/cadence_class 与 interpret_quota_should_run_packet 一致。
  • docs/architecture/rfcs/agent-loop-effect-interpreter-v0.md:更新 R5/Q6 状态。

关键代码讲解

  1. _quota_effect_turn():从 payload 解析 agent identity,调用 interpret_quota_should_run_packet(payload, goal_id, agent_id),返回 EffectTurn。
  2. _scheduler(payload, turn):优先取 effect_turn.next_effect.scheduler_action / cadence_class,再 fallback 到 scheduler_hint 原字段;reason_code/spend_policy 仍来自 source。
  3. _action_projection(payload, turn)recommended_action 优先 effect_turn.observation.recommended_actionwriteback.next_cli_actions 优先 effect_turn.next_effect.cli_actions,保留原 payload fallback。
  4. parity 测试:直接用 interpret_quota_should_run_packet 构造 turn,再与 build_turn_envelope(source) 输出比较,锁住 canonical slots。

正向路径

调用 build_turn_envelope(source),内部先解释 EffectTurn;action/writeback/scheduler 的 canonical slots 从 effect turn 派生;quota_action_signature_document 与 CLI view 得到相同值。新测试直接证明 envelope 与 interpreter 一致。

负向路径

如果 EffectTurn 的 canonical slot 为空,代码 fallback 到原 payload 字段,避免输出缺字段;如果 interpreter 与 payload 冲突,parity 测试会暴露,而不会让 envelope 悄悄使用另一套来源。

对主干的风险

低。39 个 focused pytest(turn envelope、live quota effect、maintainability ratchet)通过,ruff/diff check 通过,git merge-tree origin/main HEAD 无冲突,canary premerge 全绿。GitHub pytest 当前 in-progress,但本地等价覆盖已通过。

我的整体评价

这是 Q6 的正确第一片:把解释器从测试侧接入真实运行时路径,并用 parity 测试固定契约。无 blocker,按仓库 merge policy 路由合并。


English Verdict

Approved (author-owned fallback; cannot formally approve). Head 02fc7d17c4fde507afd8d5667ec52a2444e79afa. TurnEnvelope now derives canonical action, writeback, and scheduler slots through interpret_quota_should_run_packet, with parity tests, RFC status updates, no merge conflict, and green focused tests plus canary. No blocking findings.

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: APPROVED

head 02fc7d17c。这是对 PR #2983 的完整 owner review。该 PR 是 M6 Q6 的第一片真实运行时替换:quota should-run --turn-envelope 的 canonical action/writeback/scheduler 槽现在通过 interpret_quota_should_run_packet 消费 EffectTurn,不再是测试-only 映射;同时更新 RFC replacement status。

验证

  • tests/control_plane + turn driver/envelope tests:910 passed
  • turn envelope 聚焦测试:29 passed
  • maintainability ratchet:clean
  • ruff:通过
  • loopx canary premerge --from-git-diffselected=13 failures=0self_merge_allowed=true,public boundary 通过
  • GitHub checks:dependency-review / pytest / build 全部通过

结论

无 blocker。CLI quota 的 TurnEnvelope 热路径现在真实消费 EffectTurn,公共输出保持不变。按仓库 merge policy 路由合并。

@huangruiteng
huangruiteng merged commit 2c81e1f into main Aug 9, 2026
5 checks passed
@huangruiteng
huangruiteng deleted the codex/m6-q6-effect-quota-20260809 branch August 9, 2026 03:25
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