fix(maf): harden phase-3 dispatch recovery and participant writes

Make ensure_participants concurrent-safe, restore clarification checkpoints without re-planning, and only create threads for validated seats.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-05 21:47:46 +08:00
1 parent ddf83f7728
commit 1a080311bd
4 files changed
+599 -35

No files matched your search

@@ -648,6 +648,26 @@ async def _resolve_manager_dispatch(
})
await ctx.send_message({"decision": "clarification", "agents": []})
# ── P1-2: Clarification checkpoint recovery ──────────────────────────
# A clarification checkpoint stores a lightweight dict (not a full
# MafDispatchPlan). Recovery must restore the original prompt without
# calling the manager model again, creating seat threads, or emitting
# duplicate audit events.
if state.intent_type == "clarification":
prompt = str((state.dispatch_plan or {}).get("clarification_prompt") or "").strip()
if not prompt:
await clarification("checkpoint_clarification_prompt_missing")
return
state.selected_seat_agent_ids = []
state.plan = None
state.status = "waiting_input"
state.stage = "waiting_input"
state.mark_completed(executor._node_id)
await _persist_dispatch_checkpoint(adapter, state)
await ctx.send_message({"decision": "clarification", "agents": [], "replayed": True})
return
# A checkpoint written after validation survives process recovery and is
# never re-planned. It still creates any selected threads that were not
# bound before interruption.