fix(maf): harden phase 5 approval safety
This commit is contained in:
1 parent
f82363d81f
commit
a55992e31c
11 files changed
+489
-146
No files matched your search
+28
-9
@@ -26,7 +26,7 @@ def _now() -> datetime:
|
||||
|
||||
|
||||
def action_to_dict(row: MafRoundtableActionRow) -> dict[str, Any]:
|
||||
"""Serialise an action ORM row to a plain dict (public — reused by the store facade)."""
|
||||
"""Serialise an action ORM row to the internal persistence representation."""
|
||||
return {
|
||||
"id": row.id,
|
||||
"session_id": row.session_id,
|
||||
@@ -52,16 +52,35 @@ def action_to_dict(row: MafRoundtableActionRow) -> dict[str, Any]:
|
||||
|
||||
|
||||
def action_to_public_dict(action: Mapping[str, Any]) -> dict[str, Any]:
|
||||
"""Return the allow-listed action representation exposed by MAF HTTP APIs.
|
||||
"""Return only the stable, audit-safe Action DTO fields."""
|
||||
|
||||
Target lease keys and idempotency keys are persistence/coordinator
|
||||
details. They must never cross the public boundary.
|
||||
"""
|
||||
return {
|
||||
field: action[field]
|
||||
for field in _PUBLIC_ACTION_FIELDS
|
||||
if field in action
|
||||
}
|
||||
|
||||
public = dict(action)
|
||||
public.pop("target_key", None)
|
||||
public.pop("idempotency_key", None)
|
||||
return public
|
||||
|
||||
_PUBLIC_ACTION_FIELDS: tuple[str, ...] = (
|
||||
"id",
|
||||
"session_id",
|
||||
"run_id",
|
||||
"agent_id",
|
||||
"tool_name",
|
||||
"logical_action_id",
|
||||
"turn_index",
|
||||
"risk_level",
|
||||
"status",
|
||||
"arguments",
|
||||
"result",
|
||||
"external_object_id",
|
||||
"approval_id",
|
||||
"attempt_count",
|
||||
"started_at",
|
||||
"finished_at",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
)
|
||||
|
||||
|
||||
# Back-compat alias for internal callers that used the old private name.
|
||||
|
||||
Reference in new issue
Block a user