fix(scheduler): dispatch stranded peer handoffs - #4312
huangruiteng wants to merge 3 commits into
Conversation
81a5813 to
7ea69f1
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
结论:REQUEST_CHANGES(exact head 7ea69f114c9ed7c8d3bc315658e7e46c4ebca2aa)。
动机
这个 PR 解决了“quota/Turn 已经选出同一 Goal 的 peer handoff,但没有真正投递”的断路问题:它引入了带确定性 receipt 的 manager-context dispatch,并在创建 peer claim 前重新读取 canonical Todo。问题定义和同 Goal、已注册 peer 的边界是清楚的。
改动思路
整体流转是 typed quota-selection frontier → dispatch_from_quota_decision → 私有 0600 handoff receipt/inbox → canonical Todo claim/readback → quota/Turn payload。no_eligible_peer、未注册 source、replay 和 claim conflict 都有显式分支,没有按可见 agent 顺序猜 recipient。这个分层复用了 manager-context、Todo 与 agent-scope 的现有 owner。
具体改动
新增 loopx/capabilities/manager_context/agent_handoff.py,负责 receipt identity、同 Goal peer 过滤、canonical Todo 重读、claim/ack 和幂等 replay;quota_selection.ts/Python projection 增加 dispatchable 与 no_eligible_peer frontier;quota should-run 和 managed Turn 在 agent id 存在时接入 dispatch,并把 receipt 投影到 payload。对应的 55 个 focused tests(manager handoff、quota selection、Turn envelope)在 exact head 全部通过。
关键代码讲解
唯一必须修复的阻塞点在 loopx/cli_commands/quota.py:736-749:handle_quota_command 内联了 dispatch_from_quota_decision 的 import/call。这个函数本来已经是仓库维护性 ratchet 关注的决策热点;基线 58dbaeaec9bfad537f5b8ad2b1def9b2dcbd5197 的 ratchet 通过且没有 oversized decision finding,而 exact head 新增了 oversized_decision_function:loopx.cli_commands.quota:handle_quota_command。请把这段调用抽成现有 quota command seam 下的有界 helper(保持 agent-id/should-run guard 和同一 payload receipt),不要用 reviewed exception 掩盖增长。
对主干的风险
这是 P1:GitHub hosted run 34737896084 的 test-shard (3)、pytest 和 merge-gate 都因该 maintainability finding 失败,故当前 exact head 不具备可合并状态。功能性测试虽绿,但不能抵消仓库级门禁;若直接合入,后续 quota 控制面会继续在一个已超限的 orchestration function 上叠加逻辑。其余 handoff 风险(跨 Goal、未注册 recipient、stale claim)在本次代码和 negative tests 中已有明确拒绝路径。
我的整体评价
协议边界、canonical Todo authority 和 replay 设计是合理的,变更也落在正确的 manager-context owner;但当前提交必须先修复 quota handler 的 ratchet 回归,再重新跑完整 hosted checks。修复后请回读新的 exact head,并至少确认 maintainability、pytest、test-shard (3) 与 merge-gate 全部通过。
English verdict: REQUEST_CHANGES — extract the new inline handoff dispatch from handle_quota_command; the exact head fails the repository maintainability ratchet and therefore hosted pytest/test-shard/merge-gate.
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
|
Rebased onto merged main 7eb4b7b and addressed the requested maintainability failure by extracting the heartbeat receipt reconciliation path from handle_quota_command. Validation on exact head 1308566:
The conflict resolution retained latest main reward-memory/periodic imports and todo presentation ordering while preserving this PR manager handoff dispatch semantics. Requesting a fresh independent review; this PR is not being self-merged. |
7ea69f1 to
1308566
Compare
|
Closing this implementation as superseded by the merged capable-manager semantic-handoff RFC (#4330, commit ddf6efa). The defect remains real, but this PR makes same-Goal, pre-existing Todo, source-excluded quota selection, and 保留并迁移的验收义务: No accepted request or Todo is being marked complete by closing this PR; the canonical implementation Todo will retain a supersedes link to #4312. |
Closes #4311
Motivation / 动机
An executor-excluded
independent_handoffcould remain globally unclaimed while the origin monitor kept polling. Delivery through a Codex message was not a durable dispatch or claim receipt.被 origin Agent 排除的
independent_handoff可能长期保持全局未认领,而 origin monitor 继续轮询;仅发送 Codex 消息不构成持久派发或认领回执。What changed / 改动
distinguish
dispatchableand typedno_eligible_peerfrontiers; both are non-quietreuse the existing manager-context inbox for same-Goal peer dispatch, with restart-safe
dispatched -> read -> claimedreceipts and terminal stale-claim conflictrequire live canonical Todo eligibility before first dispatch and canonical claim readback before acknowledgement
share
manager.context_inboxbetween quota heartbeat and managedturn run-once; project the bounded receipt through the Turn contract capsule used by frontend/Lark consumersadd a bilingual RFC and process-restart CLI acceptance test
区分
dispatchable与类型化no_eligible_peerfrontier,二者均不可静默等待复用现有 manager-context inbox 完成同 Goal peer 派发,并提供跨重启的
dispatched -> read -> claimed回执及 stale-claim 冲突终态首次派发前校验规范 Todo eligibility,确认前再次校验规范认领
quota heartbeat 与托管
turn run-once共享manager.context_inbox;有界回执进入 frontend/Lark 共用的 Turn contract capsule增加双语 RFC 与跨进程 CLI 验收
Product surfaces / 产品入口
CLI/quota and managed Turn changed. Lark consumes the same Turn-start inbox projection. No new frontend control is needed because this is internal routing rather than configurable state; the existing frontend consumes the shared Turn capsule.
Validation / 验证
ruff checkon changed Python and testspytest -q tests/test_manager_context_handoff.py tests/control_plane/test_quota_selection.py tests/test_turn_envelope.py(55 passed)npm run typecheck:control-planeThe full TypeScript suite was also attempted; Python-spawning legacy cases used the host Python 3.9 and failed on the repository's existing
dataclass(slots=True)Python >=3.11 requirement. The targeted changed surfaces pass under the pinned Python 3.13 environment.