Skip to content

Commit 6b8c4ef

Browse files
authored
fix(control-plane): preserve claimant-fair deferred resume, isolate unclaimed cross-peer waits, and pin VerifyTree replan invariants (#10269)
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
1 parent 15d0400 commit 6b8c4ef

10 files changed

Lines changed: 469 additions & 3 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# VerifyTree Checkpoint: Multi-Agent Replan Liveness and Execution Readiness (2026-12-06)
2+
3+
- **Date:** 2026-12-06
4+
- **RFC:** [Verify Tree: Layered Verification for Semantic State Machines and System Evolution (v0)](../../verify-tree-v0.md)
5+
- **Language mirror:** [中文版](2026-12-06-multi-agent-replan-liveness-verify-tree.zh-CN.md)
6+
- **Baseline:** `b6ed93e6890db` (`origin/main`)
7+
8+
## 1. Root Outcome Protected
9+
10+
In a shared multi-agent Goal, an idle peer lane must wake and replan whenever it has eligible deferred resume work, an unacknowledged goal/vision gap, or an unowned work transition, while remaining quiet when its own explicit wait or anti-spin acknowledgement genuinely holds. This Verify Tree branch pins the exact invariants, counterexamples, positive controls, and Loop 3 rewrite contracts derived from recurring multi-agent quiet-stall incidents.
11+
12+
```text
13+
Outcome: Multi-Agent Goal-Oriented Liveness Without Spin-Loops
14+
├── Branch 1 [REQUIRED]: Presentation-Budget Independence (Deferred Resume Fairness)
15+
│ ├── Owner: summary_projection.ts::laneFairVisibility
16+
│ │ + project_asset_todo_summary.py::_claimant_fair_bounded_dict_items
17+
│ │ + resume_planning.ts::deferredVisibility
18+
│ ├── Invariant: ready_by_agent[agent] > 0 ==> current_agent_deferred_resume_count >= 1
19+
│ ├── Counterexample: 10+ ready deferred todos from peers fill global cap=8; peer at #11 drops to 0
20+
│ └── Evidence: resume_planning.test.ts + test_project_asset_contract.py
21+
│ + test_verify_tree_release_invariants.py (File + SQLite)
22+
├── Branch 2 [REQUIRED]: Peer-Lane Isolation in Blocked-Successor Waits
23+
│ ├── Owner: resume_planning.ts::successorWaits
24+
│ ├── Invariant: unclaimed todo waiting on todo_done:<X> where owner(X) != agent
25+
│ │ MUST NOT enter blocked_successor_items or park agent in agent_scope_wait
26+
│ ├── Positive Control: claimed_by == agent waiting on peer B's <X> REMAINS a valid wait;
27+
│ │ unclaimed wait on user gate / unclaimed / self-owned non-blocked target stays valid
28+
│ ├── Counterexample: unclaimed historical deferred todos waiting on peer B parked unrelated idle peer A
29+
│ └── Evidence: resume_planning.test.ts + test_verify_tree_release_invariants.py (File + SQLite)
30+
├── Branch 3 [REWRITE CONTRACT]: Vision ACK Anti-Spin vs. Unclosed-Vision Liveness
31+
│ ├── Owner: replan_semantics.ts::acknowledgeVisionEvidence + replan_rules.py
32+
│ ├── Protected Tradeoff: same-timestamp fresh_vision_path_outcome ACK prevents 3m spin loops
33+
│ │ on as_needed visions (replan_semantics.test.ts)
34+
│ ├── Counterexample: vision_patch_proposed + as_needed + prose-only replan_trigger_summary
35+
│ │ + same-timestamp fresh_vision_path_outcome ACK silences VISION_ACCEPTANCE_GAP
36+
│ │ indefinitely unless a typed trigger fires
37+
│ └── Loop 3 Rewrite Gate: separate bounded anti-spin cooldown from permanent gap silencing;
38+
│ require typed observable triggers instead of prose-only trigger summaries
39+
└── Branch 4 [CROSS-LAYER READINESS]: Executor Readiness != Liveness (Account Entitlement)
40+
├── Owner: packages/loopx-codex-provider-routing/src/.../native_policy.ts + native_host.py
41+
├── Invariant: used_percent == 0 on plan_type == "free" (no credits) MUST classify as plan_ineligible,
42+
│ never available; active slots removed from policy.slots MUST rotate off
43+
├── Counterexample: expired subscription downgraded to free reported 0% used and trapped all traffic
44+
└── Evidence: packages/loopx-codex-provider-routing/smoke/native-policy.test.mjs
45+
+ test_plan_entitlement_health.py (PR #10267)
46+
```
47+
48+
## 2. Executable Cross-Machine Invariants Added
49+
50+
In [test_verify_tree_release_invariants.py](../../../../../tests/control_plane/test_verify_tree_release_invariants.py) (exercising real `File` and `SQLite` authority stores with zero persistence mocks):
51+
52+
1. **Invariant 5 — Multi-agent deferred-resume presentation-budget independence (`File` + `SQLite`):**
53+
- **Setup:** 10 overdue `resume_at` deferred Todos claimed by peer agents (`operations`, `value-scout`) precede 1 overdue `resume_at` deferred Todo claimed by `agent-a` at slot #11 (beyond the global display cap of 8).
54+
- **Verified through production CLI (`quota should-run --agent-id agent-a`):** `deferred_work_counts.ready_by_agent["agent-a"] == 1`, `current_agent_deferred_resume_count == 1`, `effective_action == "successor_replan_required"`, and `should_run is True`.
55+
2. **Invariant 6 — Peer-lane isolation against cross-peer unclaimed blocked successors (`File` + `SQLite`):**
56+
- **Setup:** `value-scout` owns open `todo_peer_c1`; an unclaimed deferred Todo `todo_unclaimed_c4` waits on `todo_done:todo_peer_c1`; `agent-a` has an open unacknowledged `vision_acceptance_gap` and zero open Todos of its own.
57+
- **Verified through production CLI (`quota should-run --agent-id agent-a`):** `blocked_successor_wait_candidates == []`, `effective_action == "autonomous_replan_required"`, `should_run is True`, and `autonomous_replan_obligation` carries `vision_acceptance_gap`.
58+
- **Positive control (TS owner `resume_planning.test.ts`):** When `agent-a` explicitly claims a dependent successor waiting on `todo_peer_c1`, `blocked_successor_items` retains that successor.
59+
60+
## 3. Loop 3 Rewrite Subtraction Contract (For the Next Rewrite)
61+
62+
When refactoring or rewriting the control plane toward a single TypeScript core (Issue #9852 / Loop 3), any candidate implementation MUST preserve these four properties against the frozen Verify Tree before deleting legacy Python projections:
63+
64+
1. **Query-before-display-cap rule:** Never slice a shared multi-agent lane (`deferred_resume_candidates`, `claimed_*`, `resume_blocked_items`) to a fixed global display count before per-agent admission or wakeup evaluation. Presentation limits may bound display serialization only after per-lane completeness or claimant-fair retention (`>= 1` per distinct bucket) is guaranteed.
65+
2. **Causal ownership rule for quiet waits:** An agent may enter `agent_scope_wait` ONLY for waits causally bound to that agent (explicitly `claimed_by == agent`, or an unclaimed wait on an unclaimed/user-gate/self-owned target). Unclaimed backlog dependencies waiting on another peer's work are diagnostic visibility, never quiet-wait authority for unrelated peers.
66+
3. **Typed trigger rule for unclosed visions:** Anti-spin cooldowns and unclosed-vision wake triggers must remain separate state dimensions. A prose-only `replan_trigger_summary` on an `as_needed` vision must not be mistaken for a live external trigger; external conditions (PR merge, review decision, regression watch) must attach typed observable conditions or monitors.
67+
4. **Readiness-over-liveness rule for execution adapters:** Every model/account/proxy adapter must separate process/network liveness from serving readiness (entitlement/plan eligibility, policy membership, transport reachability), ensuring failed/ineligible nodes fail closed and rotate rather than masquerading as 100%-free healthy capacity.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# VerifyTree 检查点:多 Agent 重规划活性与执行就绪性(2026-12-06)
2+
3+
- **日期:** 2026-12-06
4+
- **RFC:** [Verify Tree:面向语义状态机与系统演化的分层验证框架(v0)](../../verify-tree-v0.zh-CN.md)
5+
- **语言镜像:** [English](2026-12-06-multi-agent-replan-liveness-verify-tree.md)
6+
- **基线:** `b6ed93e6890db`(`origin/main`)
7+
8+
## 1. 保护的根目标结果
9+
10+
在共享多 Agent Goal 中,当空闲 peer 车道存在自己可恢复的 deferred Todo、未确认的目标/愿景缺口或待接续的工作转换时,控制面必须按规则唤醒并触发重规划;而当该车道确实持有自身的显式等待或防空转确认时,仍保持安静不空耗配额。本 Verify Tree 分支将反复出现的多 Agent 静默停摆事故沉淀为可验证不变量、最小反例、正例对照与面向下一次重写(Loop 3)的减法契约。
11+
12+
```text
13+
根目标结果:多 Agent 面向目标的重规划活性(且不陷入空转循环)
14+
├── 分支 1 [必选]:展示预算无关性(Deferred Resume 跨 Agent 公平保留)
15+
│ ├── 单一 owner:summary_projection.ts::laneFairVisibility
16+
│ │ + project_asset_todo_summary.py::_claimant_fair_bounded_dict_items
17+
│ │ + resume_planning.ts::deferredVisibility
18+
│ ├── 不变量:ready_by_agent[agent] > 0 ==> current_agent_deferred_resume_count >= 1
19+
│ ├── 最小反例:其他 peer 的 10+ 条就绪 deferred Todo 占满全局上限 8,排在第 11 位的 peer 被截为 0
20+
│ └── 决定性证据:resume_planning.test.ts + test_project_asset_contract.py
21+
│ + test_verify_tree_release_invariants.py(File + SQLite)
22+
├── 分支 2 [必选]:Blocked-Successor 等待的 Peer 车道隔离
23+
│ ├── 单一 owner:resume_planning.ts::successorWaits
24+
│ ├── 不变量:无人认领且等待 todo_done:<X>(其中 owner(X) != agent)的 Todo,
25+
│ │ 绝不能进入 blocked_successor_items 或把 agent 锁进 agent_scope_wait
26+
│ ├── 正例对照:agent 显式认领(claimed_by == agent)等待 peer B 的 <X> 时保持有效等待;
27+
│ │ 单 Agent/等待 user_gate/无人认领或自有非阻塞前置保持原有安全等待
28+
│ ├── 最小反例:历史无人认领 deferred Todo 等待 peer B 的任务,导致无关空闲 peer A 被误锁静默等待
29+
│ └── 决定性证据:resume_planning.test.ts + test_verify_tree_release_invariants.py(File + SQLite)
30+
├── 分支 3 [重写契约]:Vision ACK 防空转与未闭环愿景活性边界
31+
│ ├── 单一 owner:replan_semantics.ts::acknowledgeVisionEvidence + replan_rules.py
32+
│ ├── 保护的权衡:同时间戳 fresh_vision_path_outcome ACK 防止 as_needed 愿景陷入 3 分钟空转
33+
│ ├── 最小反例:vision_patch_proposed + as_needed + 纯自然语言 replan_trigger_summary
34+
│ │ + 同时间戳 fresh_vision_path_outcome ACK 会无限期消音 VISION_ACCEPTANCE_GAP,
35+
│ │ 直到另一条类型化触发器命中
36+
│ └── Loop 3 重写门禁:将有界防空转冷却与永久缺口消音解耦;
37+
│ 外部等待条件须绑定类型化可观测触发器,而非纯文字 trigger 摘要
38+
└── 分支 4 [跨层就绪性]:执行层就绪性 ≠ 存活(账号订阅资格门禁)
39+
├── 单一 owner:packages/loopx-codex-provider-routing/src/.../native_policy.ts + native_host.py
40+
├── 不变量:plan_type == "free"(无付费余额)即便 used_percent == 0 也必须判为 plan_ineligible,
41+
│ 绝不判为 available;被移出 policy.slots 的活动槽位须自动切离
42+
├── 最小反例:过期降级为 free 的槽位回报 0% 已用,被误判 100% 空闲并永久锁死全部流量
43+
└── 决定性证据:packages/loopx-codex-provider-routing/smoke/native-policy.test.mjs
44+
+ test_plan_entitlement_health.py(PR #10267)
45+
```
46+
47+
## 2. 新增的可执行跨状态机发布不变量
48+
49+
已在 [test_verify_tree_release_invariants.py](../../../../../tests/control_plane/test_verify_tree_release_invariants.py) 中接入(真实 `File` 与 `SQLite` 权威存储,零持久化 mock):
50+
51+
1. **不变量 5 — 多 Agent Deferred Resume 展示预算无关性(`File` + `SQLite`):**
52+
- **场景:** 其他 peer(`operations`、`value-scout`)占据前 10 条已到期 `resume_at` deferred Todo(超过全局展示上限 8),`agent-a` 自己的已到期 deferred Todo 排在第 11 位。
53+
- **生产 CLI 入口验证(`quota should-run --agent-id agent-a`):** `deferred_work_counts.ready_by_agent["agent-a"] == 1`、`current_agent_deferred_resume_count == 1`、`effective_action == "successor_replan_required"` 且 `should_run is True`。
54+
2. **不变量 6 — 跨 Peer 无人认领阻塞后继的车道隔离(`File` + `SQLite`):**
55+
- **场景:** `value-scout` 持有 open 任务 `todo_peer_c1`,无人认领的 deferred Todo `todo_unclaimed_c4` 等待 `todo_done:todo_peer_c1`,`agent-a` 持有未确认的 `vision_acceptance_gap` 且名下无 open Todo。
56+
- **生产 CLI 入口验证(`quota should-run --agent-id agent-a`):** `blocked_successor_wait_candidates == []`、`effective_action == "autonomous_replan_required"`、`should_run is True`,且 `autonomous_replan_obligation` 携带 `vision_acceptance_gap`。
57+
- **正例对照(TS 单测 `resume_planning.test.ts`):** 当 `agent-a` 显式认领等待 `todo_peer_c1` 的后继任务时,`blocked_successor_items` 正确保留该等待。
58+
59+
## 3. 面向下一次重写(Loop 3)的减法验收契约
60+
61+
后续向单一 TypeScript 控制面核心推进减法与重写(Issue #9852 / Loop 3)时,任何候选实现在删除旧 Python 投影代码前,必须对冻结的 Verify Tree 守住以下 4 条硬约束:
62+
63+
1. **先按车道语义选人、再做展示裁剪:** 绝不能在单 Agent 准入或唤醒计算之前,把共享多 Agent 列表(`deferred_resume_candidates`、`claimed_*`、`resume_blocked_items`)按全局固定上限截断;展示裁剪只能在确保按车道完整或跨认领者公平保留(每个独立桶至少保留 1 条)之后进行。
64+
2. **静默等待必须具备因果归属:** 仅当等待与当前 Agent 具备直接因果绑定(显式 `claimed_by == agent`,或无人认领且等待无人认领/user_gate/自有前置)时才允许进入 `agent_scope_wait`;等待其他 peer 任务的无人认领历史积压只作诊断可见性,绝不能成为其他空闲 peer 的静默等待依据。
65+
3. **未闭环愿景的防空转与唤醒解耦:** 防空转冷却(anti-spin cooldown)与未闭环愿景的唤醒条件必须拆为独立维度;`as_needed` 愿景上纯自然语言的 `replan_trigger_summary` 不构成机读外部触发器,PR 合并/评审状态/回归巡检等外部条件必须绑定类型化可观测条件或 monitor。
66+
4. **执行层就绪性严于进程存活:** 每个模型/账号/代理适配器都必须将进程或接口存活与服务就绪(订阅计划资格、策略池成员关系、代理链路可达性)分离,失格节点必须 fail-closed 并自动轮换,绝不能以“用量 0%”伪装成健康容量。

‎docs/architecture/rfcs/verify-tree-v0.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ protocols, while live correction, remote exactly-once, takeover, observer
597597
quality and intervention retain their dedicated RFC owners.
598598

599599
- **Cross-machine release invariant consolidation:** Executable release checks across File and SQLite backends (`tests/control_plane/test_verify_tree_release_invariants.py`) are consolidated alongside existing Lean 4 proofs (`regression/`) and bounded host-lease/turn-recovery models (`tests/models/`); see [the VerifyTree consolidation checkpoint ledger](ledger/verify-tree-v0/2026-12-05-v2-4-2-consolidation-checkpoint.md) for exact baselines and retained M2/M3 open items.
600+
- **Multi-agent replan liveness and execution readiness:** Presentation-budget-independent deferred-resume fairness, peer-lane isolation for unclaimed cross-peer blocked successors, the Vision ACK anti-spin vs. liveness rewrite contract, and executor plan-entitlement readiness are pinned in [the multi-agent replan liveness VerifyTree checkpoint](ledger/verify-tree-v0/2026-12-06-multi-agent-replan-liveness-verify-tree.md) and enforced on real File + SQLite backends in `tests/control_plane/test_verify_tree_release_invariants.py`.
600601

601602
## 12. Open decisions
602603

‎docs/architecture/rfcs/verify-tree-v0.zh-CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ LoopX 自举是首个落地场景;通用外部领域直接复用这套目标
251251
来源链单次准入最多读取 64 个 operation、16 层并按 operation 合并重复读取,以 15 秒经过时间限制发起新检查(已启动 validator 保留各自超时,预算耗尽按不可用 fail-closed 处理而非回退缓存成功;多个本地委派输入不构成跨源原子快照)。可选 `acceptance_scope` 严格限定在选定工作区内的 registry/runtime 路径,不把私有命令或本机路径拼入模型输入;CLI、MCP、打包 App 与受影响飞书入口共用同一后端 owner,不新增飞书专有协议,实时纠偏、远端恰好一次、任务接管、observer 质量与受控干预仍归各自既有 RFC 所有。
252252

253253
- **跨状态机发布不变量整合:** 真实 File 与 SQLite 后端上的可执行发布检查(`tests/control_plane/test_verify_tree_release_invariants.py`)已与仓内 Lean 4 证明(`regression/`)及有界 host-lease / turn-recovery 模型(`tests/models/`)合拢;具体基线与保留在 M2/M3 开放范围的事项见 [VerifyTree 整合检查点账本](ledger/verify-tree-v0/2026-12-05-v2-4-2-consolidation-checkpoint.zh-CN.md)。
254+
- **多 Agent 重规划活性与执行就绪性:** 展示预算无关的 deferred resume 跨 Agent 公平保留、跨 peer 无人认领阻塞后继的车道隔离、Vision ACK 防空转与未闭环活性重写契约,以及执行层账号订阅资格就绪性已沉淀至 [多 Agent 重规划活性 VerifyTree 检查点](ledger/verify-tree-v0/2026-12-06-multi-agent-replan-liveness-verify-tree.zh-CN.md),并在 `tests/control_plane/test_verify_tree_release_invariants.py` 中接入真实 File + SQLite 后端校验。
254255

255256
## 12. 未决事项
256257

0 commit comments

Comments
 (0)