feat(awooop): show callback evidence capture status
This commit is contained in:
@@ -98,6 +98,7 @@ class CallbackReplyItem(BaseModel):
|
||||
persisted_awooop_status_chain: dict[str, Any] | None = None
|
||||
km_stale_completion_summary: dict[str, Any] | None = None
|
||||
persisted_km_stale_completion_summary: dict[str, Any] | None = None
|
||||
evidence_capture_status: dict[str, Any] | None = None
|
||||
run_detail_href: str | None = None
|
||||
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ _SOURCE_CORRELATION_PRE_WINDOW_HOURS = 2
|
||||
_KM_STALE_COMPLETION_CALLBACK_SCHEMA_VERSION = (
|
||||
"km_stale_owner_review_completion_callback_summary_v1"
|
||||
)
|
||||
_CALLBACK_EVIDENCE_CAPTURE_STATUS_SCHEMA_VERSION = "callback_evidence_capture_status_v1"
|
||||
|
||||
# =============================================================================
|
||||
# Tenants
|
||||
@@ -1027,6 +1028,56 @@ def _callback_reply_public_status(callback_reply: dict[str, Any]) -> str:
|
||||
}.get(raw_status, "observed")
|
||||
|
||||
|
||||
def _callback_reply_evidence_capture_status(
|
||||
*,
|
||||
callback_reply: Mapping[str, Any],
|
||||
persisted_awooop_status_chain: dict[str, Any] | None,
|
||||
persisted_km_stale_completion_summary: dict[str, Any] | None,
|
||||
event_at: Any,
|
||||
) -> dict[str, Any]:
|
||||
"""Explain whether callback-time evidence snapshots were persisted."""
|
||||
captured: list[str] = []
|
||||
missing: list[str] = []
|
||||
if persisted_awooop_status_chain:
|
||||
captured.append("awooop_status_chain")
|
||||
else:
|
||||
missing.append("awooop_status_chain")
|
||||
if persisted_km_stale_completion_summary:
|
||||
captured.append("km_stale_completion_summary")
|
||||
else:
|
||||
missing.append("km_stale_completion_summary")
|
||||
|
||||
if not missing:
|
||||
status_value = "captured"
|
||||
reason = "ok"
|
||||
next_action = "none"
|
||||
elif captured:
|
||||
status_value = "partial"
|
||||
reason = "partial_snapshot_rollout_transition"
|
||||
next_action = "press_telegram_detail_or_history_after_rollout"
|
||||
else:
|
||||
status_value = "not_captured"
|
||||
raw_status = str(callback_reply.get("status") or "")
|
||||
reason = (
|
||||
"callback_reply_delivery_failed_snapshot_missing"
|
||||
if raw_status == "callback_reply_failed"
|
||||
else "legacy_callback_before_snapshot_rollout"
|
||||
)
|
||||
next_action = "press_telegram_detail_or_history_after_rollout"
|
||||
|
||||
return {
|
||||
"schema_version": _CALLBACK_EVIDENCE_CAPTURE_STATUS_SCHEMA_VERSION,
|
||||
"status": status_value,
|
||||
"reason": reason,
|
||||
"action": str(callback_reply.get("action") or "").strip() or None,
|
||||
"captured": captured,
|
||||
"missing": missing,
|
||||
"snapshot_rollout": "t167_t169",
|
||||
"next_action": next_action,
|
||||
"event_at": event_at,
|
||||
}
|
||||
|
||||
|
||||
def _callback_reply_event_item(row: Mapping[str, Any]) -> dict[str, Any]:
|
||||
"""Convert one callback reply outbound row into a read-only evidence item."""
|
||||
callback_reply = _as_dict(row.get("callback_reply"))
|
||||
@@ -1036,6 +1087,12 @@ def _callback_reply_event_item(row: Mapping[str, Any]) -> dict[str, Any]:
|
||||
run_id = row.get("run_id")
|
||||
status_value = _callback_reply_public_status(callback_reply)
|
||||
event_at = row.get("sent_at") or row.get("queued_at")
|
||||
persisted_awooop_status_chain = _as_dict(
|
||||
row.get("persisted_awooop_status_chain"),
|
||||
) or None
|
||||
persisted_km_stale_completion_summary = _as_dict(
|
||||
row.get("persisted_km_stale_completion_summary"),
|
||||
) or None
|
||||
|
||||
return {
|
||||
"message_id": row.get("message_id"),
|
||||
@@ -1057,12 +1114,18 @@ def _callback_reply_event_item(row: Mapping[str, Any]) -> dict[str, Any]:
|
||||
"agent_id": row.get("agent_id"),
|
||||
"run_created_at": row.get("run_created_at"),
|
||||
"callback_reply": callback_reply,
|
||||
"persisted_awooop_status_chain": _as_dict(
|
||||
row.get("persisted_awooop_status_chain"),
|
||||
) or None,
|
||||
"persisted_km_stale_completion_summary": _as_dict(
|
||||
row.get("persisted_km_stale_completion_summary"),
|
||||
) or None,
|
||||
"persisted_awooop_status_chain": persisted_awooop_status_chain,
|
||||
"persisted_km_stale_completion_summary": (
|
||||
persisted_km_stale_completion_summary
|
||||
),
|
||||
"evidence_capture_status": _callback_reply_evidence_capture_status(
|
||||
callback_reply=callback_reply,
|
||||
persisted_awooop_status_chain=persisted_awooop_status_chain,
|
||||
persisted_km_stale_completion_summary=(
|
||||
persisted_km_stale_completion_summary
|
||||
),
|
||||
event_at=event_at,
|
||||
),
|
||||
"run_detail_href": (
|
||||
f"/awooop/runs/{run_id}?project_id={project_id}"
|
||||
if run_id and project_id
|
||||
|
||||
Reference in New Issue
Block a user