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:
董宏凯 committed 2026-08-07 00:04:55 +08:00
1 parent a786cdcad0
commit 1aeee86984
24 files changed
+4706 -47

No files matched your search

@@ -220,6 +220,39 @@ class MafRoundtableConfig(BaseModel):
le=60,
description="后台自动 reconcile 扫描间隔(秒);补偿投影失败的审计事件。",
)
# Stage 4 (R3-Q): seat task quality contracts + manager acceptance gate.
quality_gate_enabled: bool = Field(
default=True,
description="V2 结构化派活是否启用席位任务合同与总控验收闸门;关闭时退化为 Stage 3 行为。",
)
max_rework_attempts: int = Field(
default=2,
ge=0,
le=8,
description="同一席位任务最多返工次数(初稿之外);到达上限后按 fallback_policy 升级。",
)
max_reassignments: int = Field(
default=1,
ge=0,
le=4,
description="同一席位任务最多改派次数(备用席位接管);到达上限后受控降级为 controlled_gap。",
)
min_delivery_chars: int = Field(
default=40,
ge=0,
le=10000,
description="席位交付结论(summary)的最小有效长度;低于此值触发 below_min_length 确定性失败。",
)
min_delivery_evidence: int = Field(
default=1,
ge=0,
le=16,
description="席位交付必须提供的最少证据/依据条目;低于此值触发 missing_evidence 确定性失败。",
)
default_fallback_policy: Literal["reassign_then_gap", "controlled_gap", "ask_user"] = Field(
default="reassign_then_gap",
description="到达返工/改派上限后的默认降级策略:改派后受控缺口 / 直接受控缺口 / 请求用户澄清。",
)
@field_validator("default_manager_agent_id", mode="before")