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

@@ -359,6 +359,50 @@ _CONTEXT_CONFIGURABLE_KEYS: frozenset[str] = frozenset(
}
)
# These fields activate or authorize MAF WriteGuard behavior. They may only
# cross the Gateway boundary on the typed, server-created request from
# ``DeerFlowRuntimeClient``. In particular, accepting them from a public
# ``body.config`` would let a caller forge an active MAF run or a post-approval
# passthrough.
_MAF_PRIVATE_CONTEXT_KEYS: frozenset[str] = frozenset(
{
"maf_run_id",
"maf_session_id",
"maf_user_id",
"turn_index",
"write_policy",
"capability_snapshot",
"maf_approved_tool",
"maf_approved_action_id",
}
)
def _is_internal_maf_request(request: Any) -> bool:
state = getattr(request, "state", None)
return bool(getattr(state, "maf_internal", False))
def _merge_internal_maf_context(config: dict[str, Any], context: Mapping[str, Any], request: Any) -> None:
"""Forward server-generated MAF context, never public request fields."""
if not _is_internal_maf_request(request):
for container_name in ("context", "configurable"):
container = config.get(container_name)
if isinstance(container, dict):
for key in _MAF_PRIVATE_CONTEXT_KEYS:
container.pop(key, None)
return
configurable = config.setdefault("configurable", {})
runtime_context = config.setdefault("context", {})
for key in _MAF_PRIVATE_CONTEXT_KEYS:
if key not in context:
continue
if isinstance(configurable, dict):
configurable.setdefault(key, context[key])
if isinstance(runtime_context, dict):
runtime_context.setdefault(key, context[key])
def merge_run_context_overrides(config: dict[str, Any], context: Mapping[str, Any] | None) -> None:
"""Merge whitelisted keys from ``body.context`` into both ``config['configurable']``
@@ -1022,6 +1066,7 @@ async def start_run(
if value is not None and top_level_key not in body_context:
body_context[top_level_key] = value
merge_run_context_overrides(config, body_context or None)
_merge_internal_maf_context(config, body_context, request)
stream_modes = normalize_stream_modes(body.stream_mode)