feat(awooop): expose mcp bridge truth chain
This commit is contained in:
@@ -7,6 +7,7 @@ Telegram cards can be audited without guessing which subsystem owns the truth.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
@@ -20,6 +21,7 @@ from src.db.base import get_db_context
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
_MAX_ROWS = 100
|
||||
_JSON_TEXT_FIELDS = {"gate_result", "source_envelope"}
|
||||
|
||||
|
||||
def _clean(value: Any) -> Any:
|
||||
@@ -38,7 +40,15 @@ def _clean(value: Any) -> Any:
|
||||
|
||||
|
||||
def _clean_row(row: Any) -> dict[str, Any]:
|
||||
return {key: _clean(value) for key, value in dict(row).items()}
|
||||
cleaned: dict[str, Any] = {}
|
||||
for key, value in dict(row).items():
|
||||
if key in _JSON_TEXT_FIELDS and isinstance(value, str):
|
||||
try:
|
||||
value = json.loads(value)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
cleaned[key] = _clean(value)
|
||||
return cleaned
|
||||
|
||||
|
||||
async def _fetch_all(db: Any, sql: str, params: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
@@ -507,6 +517,7 @@ async def fetch_truth_chain(source_id: str, project_id: str = "awoooi") -> dict[
|
||||
trace_id,
|
||||
agent_id,
|
||||
tool_name,
|
||||
gate_result,
|
||||
result_status,
|
||||
block_gate,
|
||||
block_reason,
|
||||
|
||||
Reference in New Issue
Block a user