Skip to content

Keep due monitor polling out of autonomous replan instructions - #10116

Open
huangruiteng wants to merge 1 commit into
mainfrom
codex/replan-monitor-work-lane
Open

huangruiteng wants to merge 1 commit into
mainfrom
codex/replan-monitor-work-lane

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

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

  • Reproduced the contradictory instructions on the base revision using the public quota CLI and an isolated SQLite goal.
  • The regression covers initial admission, replay of the same identity, rejection of a mismatched poll and readback of the original due time.
  • Independently checked a genuine monitor turn through poll settlement and a separate advancement turn with an auxiliary monitor.
  • The six focused suites passed (57 tests). Standard diff-based premerge passed, including 10 catalog and 8 risk-profile checks.

Signed-off-by: huangruiteng <huangrt01@163.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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-run when an autonomous replan overlaps with a due continuous_monitor todo.
  • Before/after scenario: Before e59947d972718f5ad6c7b13aa77ad4cceab433e8: under primary_goal with a due watch_only monitor and autonomous_replan_required, work_lane_contract advertised obligation="attempt_due_monitor", must_attempt_work=true even though binding_kind="autonomous_replan". After e59947d972718f5ad6c7b13aa77ad4cceab433e8: the primary_goal todo_monitor_due path is suppressed (work_lane_contract=None), but under progress_scope="dependency_observation" with the exact same due watch_only or private_monitor todo, build_work_lane_contract still emits monitor_kind="dependency_observation", obligation="attempt_due_monitor", must_attempt_work=true and quota monitor-poll still fails with heartbeat_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 on task_orchestration.py, and 18/18 premerge checks with node_modules), while leaving a live-reproduced gap on progress_scope="dependency_observation" due monitors (Finding F1).
  • Non-goals: Does not alter TypeScript quota.run_decision, monitor_poll_admission.ts, receipt validation, or quiet_until_material_monitor_transition / advancement_task work-lane projections.
  • Remaining gap: Blocking Finding F1: payload_work_lane_contract relies solely on work_lane_contract_is_due_monitor_attempt (monitor_kind == "todo_monitor_due"), missing work_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

  1. 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。
  2. 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-poll CLI 指令,但 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"),实测 CLI loopx 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" 失败。并且 Python monitor_poll.py:111 与 TypeScript monitor_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):
    • pytest 5 组相关测试(含 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 --test 6 组 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、DCO Signed-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 loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

依赖观察模式仍要求重规划 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。

This branch has not been deployed

No deployments
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.

2 participants