Repository navigation
Keep due monitor polling out of autonomous replan instructions - #10116
huangruiteng wants to merge 1 commit into
Conversation
Signed-off-by: huangruiteng <huangrt01@163.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Exact reviewed head: 10116@e59947d972718f5ad6c7b13aa77ad4cceab433e8 (base f8f19b11ed3ae738db8ab9bd30a458d1595e78ff).
动机 / Motivation
当 Agent 宿主或外层调度器执行 loopx quota should-run 且当前回合同时触发自主重规划(autonomous_replan_required)与到期监控(due continuous_monitor Todo)时,控制面会把该 Turn 的结算身份(heartbeat_receipt.settlement_identity.binding_kind)绑定到 autonomous_replan,而此前 payload_work_lane_contract 仍会透传 obligation="attempt_due_monitor"、must_attempt_work=true 的工作通道契约(work_lane_contract)。如果宿主遵照该指令执行外部监控轮询,随后调用 loopx quota monitor-poll 会必然以 heartbeat_receipt_identity_conflict 失败,导致已发生的外部读取无法落账。
- Affected caller/operator: Agent hosts and outer controllers executing
loopx quota should-runwhen an autonomous replan overlaps with a duecontinuous_monitortodo. - Before/after scenario: Before
e59947d972718f5ad6c7b13aa77ad4cceab433e8: underprimary_goalwith a duewatch_onlymonitor andautonomous_replan_required,work_lane_contractadvertisedobligation="attempt_due_monitor",must_attempt_work=trueeven thoughbinding_kind="autonomous_replan". Aftere59947d972718f5ad6c7b13aa77ad4cceab433e8: theprimary_goaltodo_monitor_duepath is suppressed (work_lane_contract=None), but underprogress_scope="dependency_observation"with the exact same duewatch_onlyorprivate_monitortodo,build_work_lane_contractstill emitsmonitor_kind="dependency_observation",obligation="attempt_due_monitor",must_attempt_work=trueandquota monitor-pollstill fails withheartbeat_receipt_identity_conflict. - Observable outcome: Fixes
primary_goal(monitor_kind="todo_monitor_due") replan responses (85 passed pytest tests, 161 passed TS tests, ruff, mypy ontask_orchestration.py, and 18/18 premerge checks withnode_modules), while leaving a live-reproduced gap onprogress_scope="dependency_observation"due monitors (Finding F1). - Non-goals: Does not alter TypeScript
quota.run_decision,monitor_poll_admission.ts, receipt validation, orquiet_until_material_monitor_transition/advancement_taskwork-lane projections. - Remaining gap: Blocking Finding F1:
payload_work_lane_contractrelies solely onwork_lane_contract_is_due_monitor_attempt(monitor_kind == "todo_monitor_due"), missingwork_lane.py:852-875(monitor_kind == "dependency_observation",obligation == "attempt_due_monitor",must_attempt_work == True).
改动思路 / Approach
作者将过滤放在 loopx/control_plane/quota/task_orchestration.py:payload_work_lane_contract(与 OUTCOME_FLOOR_RECOVERY 及 AGENT_SCOPE_NON_EXECUTION_ACTIONS 共用同一最终投影收口点),先统一把 Mapping 规范化为 dict,再在 effective_action == EffectiveAction.AUTONOMOUS_REPLAN_REQUIRED.value 且 work_lane_contract_is_due_monitor_attempt(work_lane_contract) 为真时返回 None,并保持 agent_todo_summary 与其余非重规划车道不变。
Localized projection fix in task_orchestration.py + end-to-end regression in test_monitor_replan_closeout.py.
payload_work_lane_contract is the right architectural owner for suppressing incompatible work-lane projections on autonomous_replan_required; only its predicate is incomplete (Finding F1). 该边界保留了 test_replan_host_context_projection.py:298 依赖的 quiet_until_material_monitor_transition 与 interaction_contract.py:1548 已做门控的 advancement_task.auxiliary_monitor_poll,但复用 work_lane_contract_is_due_monitor_attempt(work_lane.py:152-159)时忽略了 build_work_lane_contract 的第二个 attempt_due_monitor 生产分支(work_lane.py:852-875)。
具体改动 / Changes
loopx/control_plane/quota/task_orchestration.py(+15/-5):在payload_work_lane_contract中引入work_lane_contract_is_due_monitor_attempt,提前执行_as_dict_or_none规范化,并在effective_action == EffectiveAction.AUTONOMOUS_REPLAN_REQUIRED.value且work_lane_contract_is_due_monitor_attempt(work_lane_contract)为真时返回None。tests/control_plane/test_monitor_replan_closeout.py(+32/-0):新增test_replan_with_due_monitor_only_advertises_the_bound_duty,在隔离 SQLite 运行时中覆盖初次 guard、同 Turn 回放、quota monitor-poll返回heartbeat_receipt_identity_conflict以及next_due_at/last_checked_at保持不变。
- 规范对齐(
loopx/semantics/vocabulary_v0.json@f8f19b11ed3ae738db8ab9bd30a458d1595e78ff):R1(重规划回合不暴露冲突的attempt_due_monitor契约)not_met(primary_goal通过,dependency_observation缺失);R2(normal_run辅助监控与正常monitor_due结算对等)implemented。 - 跨 Python/TS 指令面逐条核查(
decision_text_assessment):已核查execution_obligation.py:90-117、decision_summary.py:242-251、interaction_contract.py:453-463,1548-1558、interaction_contract.ts:259-269与turn_envelope.ts:334。前四处均不会在autonomous_replan_required下生成monitor-pollCLI 指令,但turn_envelope.ts:334会把payload.work_lane_contract原样复制进宿主contractCapsule,因此 F1 泄漏的attempt_due_monitor会直接进入宿主上下文。
对主干的风险 / Risks
阻塞发现 F1(P1 / Blocking):dependency_observation 作用域下的到期监控仍会在 autonomous_replan_required 中泄漏 attempt_due_monitor
- Problem:
loopx/control_plane/quota/task_orchestration.py:183-187仅调用work_lane_contract_is_due_monitor_attempt(work_lane_contract)(loopx/control_plane/work_items/work_lane.py:152-159),该谓词只匹配monitor_kind == "todo_monitor_due"且must_attempt_work is True。然而在loopx/control_plane/work_items/work_lane.py:852-875,当progress_scope == "dependency_observation"、无开放 advancement Todo、且到期监控未抢占 advancement(对所有watch_only="true"到期监控及private_boundary/LOCAL监控均成立)时,build_work_lane_contract生成的契约是monitor_kind="dependency_observation"、obligation="attempt_due_monitor"、must_attempt_work=True。该分支直接绕过payload_work_lane_contract的新拦截。 - Evidence: 在 exact head
e59947d972718f5ad6c7b13aa77ad4cceab433e8上,使用本 PR 自己的 SQLite 回归夹具(同样的todo_watch、watch_only="true"、later_vision=True),仅将前置运行记录设为progress_scope="dependency_observation"(并同步通过build_quota_should_run验证watch_only="true"与action_kind="private_monitor"),实测 CLIloopx quota should-run返回effective_action="autonomous_replan_required"、binding_kind="autonomous_replan"、selected_todo=None,但work_lane_contract仍输出{"lane": "continuous_monitor", "monitor_kind": "dependency_observation", "obligation": "attempt_due_monitor", "must_attempt_work": true, "reason_codes": ["dependency_observation", "monitor_todo_only", "monitor_due"]},同时违反本 PR 回归测试第 127–128 行的两条断言;随后执行loopx quota monitor-poll仍以error_code="heartbeat_receipt_identity_conflict"失败。并且 Pythonmonitor_poll.py:111与 TypeScriptmonitor_poll_admission.ts:76均以must_attempt_work+obligation == "attempt_due_monitor"判定到期监控尝试。 - Impact: 任何上一轮为
dependency_observation(监控/依赖观测回合的标准progress_scope)且含到期watch_only或私有边界监控的 Goal,在进入自主重规划时仍会收到互相矛盾的指令并触发不可落账的轮询失败。 - Fix: 在
loopx/control_plane/quota/task_orchestration.py:183-187中,将AUTONOMOUS_REPLAN_REQUIRED分支的条件扩展为同时拦截work_lane_contract_is_due_monitor_attempt(work_lane_contract)或(work_lane_contract.get("obligation") == "attempt_due_monitor" and work_lane_contract.get("must_attempt_work") is True)(无需修改work_lane_contract_is_due_monitor_attempt本身,以免影响依赖monitor_due_items的agent_lane_recommendation.py:428),并在tests/control_plane/test_monitor_replan_closeout.py与tests/control_plane/test_task_orchestration_contract.py中补充dependency_observation端到端与单测回归。
非重规划车道与本地验证结果(PASS / FAIL)
- Sibling-lane / default-off parity(PASS):实测
normal_run(开放 advancement Todo + 到期watch_only监控)完整保留work_lane_contract.auxiliary_monitor_poll与cli_channel.auxiliary_monitor_poll.availability == "ready"及轮询命令;实测非重规划monitor_due回合完整保留attempt_due_monitor并成功执行quota monitor-poll(ok: true);autonomous_replan_required+ 开放 advancement Todo 时cli_channel.auxiliary_monitor_poll已由interaction_contract.py:1548正确门控为receipt_binding_required。 - 本地验证套件(PASS / FAIL):
pytest5 组相关测试(含test_monitor_replan_closeout.py、test_task_orchestration_contract.py、test_auxiliary_monitor_poll_availability.py、test_work_lane_contract_core.py、test_replan_successor_guard_reentry.py):PASS(85 passed in 245.28s)。node --test6 组 TS 控制面测试(auxiliary_monitor_settlement、quota_run_decision、quota_monitor_poll_commit、interaction_contract、interaction_execution_decision、replan_settlement):PASS(161 passed, 0 failed)。ruff check、生产文件mypy --follow-imports=silent loopx/control_plane/quota/task_orchestration.py、DCOSigned-off-by、标准canary premerge(含semantic-vocabulary-drift-smoke.py,配合node_modules共 18/18 项):PASS。- 负例探针(
dependency_observation+ 到期watch_only/private_monitor+autonomous_replan_required):FAIL(复现阻塞发现 F1)。
我的整体评价 / Verdict
本 PR 选对了修改边界(payload_work_lane_contract),体量克制(+47/-5),复用现有词汇(EffectiveAction.AUTONOMOUS_REPLAN_REQUIRED,零新词汇漂移),且已验证非重规划车道(normal_run 辅助监控、monitor_due 轮询结算)保持完全对等;无前端/渲染 UI 变更(visual_review: not_applicable)。但在 long_horizon 与 user_experience 上当前收益尚不能证实(not_yet_proven):由于拦截条件仅覆盖 monitor_kind="todo_monitor_due",遗漏了 work_lane.py:852-875 在 progress_scope="dependency_observation" 下产出的同类 obligation="attempt_due_monitor"、must_attempt_work=True 契约,导致本 PR 声明消除的冲突在同一类常驻监控场景下仍可稳定复现。请按 F1 的最小修复补齐该条件与回归测试后再复审。
Exact head: e59947d972718f5ad6c7b13aa77ad4cceab433e8
English verdict: REQUEST_CHANGES at e59947d. Blocking finding F1: payload_work_lane_contract only checks work_lane_contract_is_due_monitor_attempt (monitor_kind == "todo_monitor_due"), so progress_scope="dependency_observation" turns with a due watch_only or private-boundary monitor (work_lane.py:852-875) still emit obligation="attempt_due_monitor" and must_attempt_work=True during autonomous_replan_required and fail quota monitor-poll with heartbeat_receipt_identity_conflict; broaden the guard to also match obligation == "attempt_due_monitor" and must_attempt_work is True and add regression coverage. Sibling lanes (normal_run auxiliary poll, genuine monitor_due), 85 pytest, 161 TS tests, ruff, mypy on task_orchestration.py, DCO, and 18/18 premerge checks passed.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-astra · OpenAI · runtime_reported · high
Request changes conclusion
[P2] 依赖观察模式仍要求重规划 Turn 执行一个无法结算的轮询。 把同一隔离夹具的最近运行范围换成 dependency_observation。两个后端都将 Turn 绑定到 autonomous_replan,同时给出 obligation=attempt_due_monitor 和 must_attempt_work=true。按该身份执行 monitor-poll 均返回 heartbeat_receipt_identity_conflict,随后读回的 next_due_at 仍为原值。 位置为 loopx/control_plane/quota/task_orchestration.py:185。
动机 / Motivation
调度器应让宿主从同一份准入决定取得可执行的职责,并能用该 Turn 身份写回。目标分支会同时给出重规划和到期监控的指令;执行轮询时,写入接口拒绝其身份。当前提交修正了常规工作范围。在 File 和 SQLite 上,调度仍报告监控到期,却已从常规重规划指令移除必做轮询。该复核使用本地 CLI、临时 Goal 和实际存储;监控对象使用合成输入。把同一隔离夹具的最近运行范围换成 dependency_observation。两个后端都将 Turn 绑定到 autonomous_replan,同时给出 obligation=attempt_due_monitor 和 must_attempt_work=true。按该身份执行 monitor-poll 均返回 heartbeat_receipt_identity_conflict,随后读回的 next_due_at 仍为原值。
改动思路 / Approach
固定同一个已到期的观察任务、代理、配额和 Turn 身份,分别以常规和依赖观察范围运行。每次除了检查外层 effective_action,还追踪内层工作义务、使用相同身份的写回结果,以及独立待办查询所见的到期时间。
具体改动 / Changes
关键代码讲解
work_lane_contract_is_due_monitor_attempt 识别 todo_monitor_due。对于到期的 watch_only 任务,依赖观察分支也能生成必做轮询,却使用 dependency_observation 作为 monitor_kind。因此最终投影保留了第二项指令,收据仍然只属于重规划。 本次检查对应提交 e59947d972718f5ad6c7b13aa77ad4cceab433e8 和验收项 monitor-in-dependency-observation。PR 说明
| 检查 | 独立观察 |
|---|---|
| 仓库重规划收尾套件 | 5 项全部通过。 |
| 同一监控处于常规范围 | 两个后端的新提交均移除轮询义务,保留重规划身份。 |
| 最近运行的范围为 dependency_observation | 指令仍要求轮询,执行被拒绝且到期时间保持不变。 |
对主干的风险 / Risks
如果宿主按必做指令先去外部取数,才会在写回时发现身份冲突。未推进的到期时间让同一目标继续显示到期,后续调度可能重复外部读取。收据接口拒绝了错误写入,但无法替调用方收回已经付出的读取成本。未访问真实的外部监控目标。先前的 Gemini 评审已指出这一分支,本轮在两个后端独立重现。
我的整体评价 / Verdict
按本轮绑定及实际轮询义务消除冲突,保留监控到期事实。请在两个后端覆盖依赖观察的准入、轮询身份拒绝和 due time 独立读回,并保留真正的监控 Turn。
English verdict: REQUEST_CHANGES on e59947d. In the dependency-observation lane a replan-bound turn still requires a due poll that the same receipt cannot settle.
| # obligation and cannot settle the competing monitor poll. | ||
| if ( | ||
| effective_action == EffectiveAction.AUTONOMOUS_REPLAN_REQUIRED.value | ||
| and work_lane_contract_is_due_monitor_attempt(work_lane_contract) |
There was a problem hiding this comment.
依赖观察模式仍要求重规划 Turn 执行一个无法结算的轮询。 把同一隔离夹具的最近运行范围换成 dependency_observation。两个后端都将 Turn 绑定到 autonomous_replan,同时给出 obligation=attempt_due_monitor 和 must_attempt_work=true。按该身份执行 monitor-poll 均返回 heartbeat_receipt_identity_conflict,随后读回的 next_due_at 仍为原值。 按本轮绑定及实际轮询义务消除冲突,保留监控到期事实。请在两个后端覆盖依赖观察的准入、轮询身份拒绝和 due time 独立读回,并保留真正的监控 Turn。
Behavior
When a monitor is due during an autonomous replan, the quota response currently tells the agent to poll it. The same response binds the turn to the replan, so recording that poll fails with
heartbeat_receipt_identity_conflict. A host following both instructions can perform an external read it cannot record.This change omits the competing poll instruction from the final work-lane projection. The Todo summary still reports the due monitor and the replan keeps its original settlement identity. A monitor-bound turn can still poll, and an advancement turn retains its optional monitor context. The existing typed decision selects the route. Scheduling and receipt validation continue to use the same owners.
Verification