feat(maf): Phase 5 - action coordinator, approval flow, frontend MAF roundtable pages

- Backend: action_coordinator, capability_snapshot, event_normalizer, tool_executor updates
- Backend: approved_tool_executor with write guard, action leases, migration script
- Frontend: maf-roundtable module (API client, event timeline, approval cards, fact flow panel)
- Frontend: MafRoutes, MafSessionsPage, MafRunDetailPage
- Tests: action_leases, migration_phase5, phase5_entry_e2e, real_write_e2e/http_e2e
- Docs: update implementation plan

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-02 13:07:21 +08:00
1 parent 21c4c898e7
commit f82363d81f
55 files changed
+6304 -167

No files matched your search

@@ -0,0 +1,89 @@
"""Acceptance coverage for the additive Phase-5 target-lease migration."""
from __future__ import annotations
import importlib.util
from pathlib import Path
import pytest
from sqlalchemy import inspect, text
from sqlalchemy.ext.asyncio import create_async_engine
from deerflow.persistence.maf_roundtable.model import Base
def _migration_module():
script = Path(__file__).resolve().parent.parent / "scripts" / "migrate_maf_roundtable_phase5.py"
spec = importlib.util.spec_from_file_location("migrate_maf_roundtable_phase5", script)
assert spec and spec.loader
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
@pytest.mark.asyncio
async def test_phase5_lease_migration_is_additive_and_idempotent():
module = _migration_module()
engine = create_async_engine("sqlite+aiosqlite://", echo=False)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
await conn.execute(text("DROP TABLE maf_roundtable_action_leases"))
async with engine.begin() as conn:
await conn.run_sync(module._migrate_sync, dry_run=False)
def check(sync_conn):
inspector = inspect(sync_conn)
assert "maf_roundtable_action_leases" in inspector.get_table_names()
columns = {column["name"] for column in inspector.get_columns("maf_roundtable_action_leases")}
assert {"target_key", "action_id", "lease_expires_at"} <= columns
indexes = {index["name"] for index in inspector.get_indexes("maf_roundtable_action_leases")}
assert {"ix_maf_action_leases_action_id", "ix_maf_action_leases_lease_expires_at"} <= indexes
async with engine.begin() as conn:
await conn.run_sync(check)
await conn.execute(text(f"DROP INDEX {module.ACTION_INDEX}"))
await conn.execute(text(f"DROP INDEX {module.EXPIRY_INDEX}"))
await conn.run_sync(module._migrate_sync, dry_run=False)
await conn.run_sync(check)
await conn.run_sync(module._migrate_sync, dry_run=True)
await engine.dispose()
@pytest.mark.asyncio
async def test_phase5_migration_dry_run_is_safe_when_table_is_absent():
module = _migration_module()
engine = create_async_engine("sqlite+aiosqlite://", echo=False)
async with engine.begin() as conn:
await conn.run_sync(module._migrate_sync, dry_run=True)
tables = await conn.run_sync(lambda sync_conn: inspect(sync_conn).get_table_names())
assert "maf_roundtable_action_leases" not in tables
await engine.dispose()
def test_phase5_ddl_uses_sqlite_datetime():
module = _migration_module()
ddl = module._create_lease_table_sql(SimpleDialect("sqlite"))
assert "lease_expires_at DATETIME NOT NULL" in ddl
assert "created_at DATETIME NOT NULL" in ddl
def test_phase5_ddl_uses_postgresql_timestamp_with_timezone():
module = _migration_module()
ddl = module._create_lease_table_sql(SimpleDialect("postgresql"))
assert "lease_expires_at TIMESTAMP WITH TIME ZONE NOT NULL" in ddl
assert "created_at TIMESTAMP WITH TIME ZONE NOT NULL" in ddl
assert "DATETIME" not in ddl
def test_phase5_ddl_uses_mysql_microsecond_datetime():
module = _migration_module()
ddl = module._create_lease_table_sql(SimpleDialect("mysql"))
assert "lease_expires_at DATETIME(6) NOT NULL" in ddl
assert "created_at DATETIME(6) NOT NULL" in ddl
class SimpleDialect:
def __init__(self, name: str) -> None:
self.name = name