fix(maf): harden stage-4 quality gate (P0/P1)
P0-1 migration: detect the same-named stage-3 execution_stage CHECK by sqltext (must contain rework + manager_review), SQLite rebuild / PG-MySQL drop+add, PG boolean default TRUE, validate_schema checks constraint content + seat_tasks status CHECK/unique/FKs; tests start from a real stage-3 schema. P0-2: a missing/invalid manager review (timeout/exception/empty/invalid JSON/missing per-seat decision) is never an acceptance - system rework under the cap, contract fallback (reassign/controlled_gap/ask_user) afterwards, source=system events. P0-3: unaccepted deliveries are isolated from the fact ledger, cross-review and final report (deferred merge, delivery_json envelope, accepted_task_results in checkpoint, accepted-only synthesis, no turn_results fallback). P0-4: seat-task init is atomic get-or-create over the full expected set; recovery fills missing tasks without overwriting frozen contracts; quality gate blocks missing required tasks. P1: zero config values honoured; duplicate detection persists SHA-256 conclusion digests in history (survives restarts); findings never satisfy evidence, evidence_refs must resolve to trusted ledger refs (unverified_evidence_ref); conversation SSE projection tests added and manager/finalizer messages are no longer mislabelled as seat.delivery.submitted.
This commit is contained in:
1 parent
a786cdcad0
commit
1aeee86984
24 files changed
+4706
-47
No files matched your search
@@ -55,11 +55,19 @@ def build_structured_workflow(
|
||||
dispatch_seat_entry: Any | None = None,
|
||||
manager_answer: Any | None = None,
|
||||
clarification_terminal: Any | None = None,
|
||||
quality_gate: Any | None = None,
|
||||
waiting_input_terminal: Any | None = None,
|
||||
) -> Any:
|
||||
"""Build a structured (fixed-topology) MAF Workflow.
|
||||
|
||||
Topology: planner → parallel seat executors → cross_review → approval gate
|
||||
→ finalizer | waiting_terminal.
|
||||
Topology (Stage 3): planner → parallel seat executors → cross_review →
|
||||
approval gate → finalizer | waiting_terminal.
|
||||
|
||||
Topology (Stage 4 quality gate): quality seat-tasks loop → quality gate →
|
||||
(waiting_input | cross_review) → approval gate → finalizer | waiting_terminal.
|
||||
When ``quality_gate`` is provided, the seat fan-out is replaced by the
|
||||
single quality loop executor and ``waiting_input_terminal`` becomes an
|
||||
additional workflow output for the ``ask_user`` pause path.
|
||||
"""
|
||||
from agent_framework import Case, Default, WorkflowBuilder
|
||||
|
||||
@@ -71,6 +79,8 @@ def build_structured_workflow(
|
||||
outputs.append(manager_answer)
|
||||
if clarification_terminal is not None:
|
||||
outputs.append(clarification_terminal)
|
||||
if waiting_input_terminal is not None:
|
||||
outputs.append(waiting_input_terminal)
|
||||
builder = WorkflowBuilder(
|
||||
start_executor=start,
|
||||
name="maf-structured-roundtable",
|
||||
@@ -97,7 +107,20 @@ def build_structured_workflow(
|
||||
builder.add_switch_case_edge_group(dispatch_router, cases)
|
||||
seat_start = dispatch_seat_entry
|
||||
|
||||
if execution_mode == "chain" and seat_executors:
|
||||
if quality_gate is not None:
|
||||
# Stage 4: single quality-loop node replaces the seat fan-out; the
|
||||
# quality gate routes ask_user pauses to waiting_input_terminal and
|
||||
# everything else to cross-review.
|
||||
builder.add_edge(seat_start, quality_gate)
|
||||
gate_cases = []
|
||||
if waiting_input_terminal is not None:
|
||||
gate_cases.append(Case(
|
||||
condition=lambda out: isinstance(out, dict) and out.get("decision") == "waiting_input",
|
||||
target=waiting_input_terminal,
|
||||
))
|
||||
gate_cases.append(Default(target=cross_review))
|
||||
builder.add_switch_case_edge_group(quality_gate, gate_cases)
|
||||
elif execution_mode == "chain" and seat_executors:
|
||||
builder.add_edge(seat_start, seat_executors[0])
|
||||
for previous, current in zip(seat_executors, seat_executors[1:]):
|
||||
builder.add_edge(previous, current)
|
||||
@@ -249,6 +272,8 @@ def create_workflow(
|
||||
dispatch_router: Any | None = None,
|
||||
dispatch_seat_entry: Any | None = None,
|
||||
clarification_terminal: Any | None = None,
|
||||
quality_gate: Any | None = None,
|
||||
waiting_input_terminal: Any | None = None,
|
||||
) -> Any:
|
||||
"""Factory: create the appropriate workflow for the given mode."""
|
||||
if mode == "manager_only":
|
||||
@@ -290,4 +315,6 @@ def create_workflow(
|
||||
dispatch_seat_entry=dispatch_seat_entry,
|
||||
manager_answer=manager_answer,
|
||||
clarification_terminal=clarification_terminal,
|
||||
quality_gate=quality_gate,
|
||||
waiting_input_terminal=waiting_input_terminal,
|
||||
)
|
||||
Reference in new issue
Block a user