|
| 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. |
0 commit comments