This commit is contained in:
@@ -24,6 +24,7 @@ CLOSABLE_STATUSES = frozenset({"pending", "auto_pending", "pending_review"})
|
||||
SOURCE_TARGET_STATUS = {
|
||||
"code_review_fix": "auto_disabled",
|
||||
"code_review_pipeline": "auto_disabled",
|
||||
"nemotron_direct_response": "auto_disabled",
|
||||
"openclaw_recommendation": "rejected",
|
||||
"openclaw": "rejected",
|
||||
}
|
||||
@@ -51,15 +52,6 @@ def _coerce_datetime(value: Any) -> Optional[datetime]:
|
||||
return None
|
||||
|
||||
|
||||
def _source_for_row(row: Any) -> str:
|
||||
return str(
|
||||
_row_get(row, "action_type")
|
||||
or _row_get(row, "plan_type")
|
||||
or _row_get(row, "created_by")
|
||||
or "unknown"
|
||||
)
|
||||
|
||||
|
||||
def _parse_metadata(raw: Any) -> Dict[str, Any]:
|
||||
if isinstance(raw, dict):
|
||||
return dict(raw)
|
||||
@@ -72,6 +64,39 @@ def _parse_metadata(raw: Any) -> Dict[str, Any]:
|
||||
return {"legacy_metadata_raw": str(raw)[:1000]}
|
||||
|
||||
|
||||
def _parse_payload(raw: Any) -> Dict[str, Any]:
|
||||
if isinstance(raw, dict):
|
||||
return dict(raw)
|
||||
if not raw:
|
||||
return {}
|
||||
try:
|
||||
parsed = json.loads(str(raw))
|
||||
return parsed if isinstance(parsed, dict) else {}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
def _source_for_row(row: Any) -> str:
|
||||
created_by = str(_row_get(row, "created_by") or "")
|
||||
if created_by == "nemotron":
|
||||
payload = _parse_payload(_row_get(row, "payload"))
|
||||
actions = payload.get("action_plan") if isinstance(payload.get("action_plan"), list) else []
|
||||
is_direct_response = payload.get("dispatch_to") == "direct_response"
|
||||
is_reply_only = bool(actions) and all(
|
||||
isinstance(action, dict) and action.get("action") == "reply_simple"
|
||||
for action in actions
|
||||
)
|
||||
if is_direct_response or is_reply_only:
|
||||
return "nemotron_direct_response"
|
||||
|
||||
return str(
|
||||
_row_get(row, "action_type")
|
||||
or _row_get(row, "plan_type")
|
||||
or created_by
|
||||
or "unknown"
|
||||
)
|
||||
|
||||
|
||||
def build_action_plan_hygiene_preview(
|
||||
rows: Iterable[Any],
|
||||
*,
|
||||
@@ -140,12 +165,12 @@ class ActionPlanHygieneService:
|
||||
try:
|
||||
rows = session.execute(text("""
|
||||
SELECT id, status, priority, created_at, action_type, plan_type,
|
||||
created_by, description, metadata_json
|
||||
created_by, description, metadata_json, payload
|
||||
FROM action_plans
|
||||
WHERE status IN ('pending', 'auto_pending', 'pending_review')
|
||||
AND (
|
||||
action_type IN ('code_review_fix', 'openclaw_recommendation')
|
||||
OR created_by IN ('code_review_pipeline', 'openclaw')
|
||||
OR created_by IN ('code_review_pipeline', 'openclaw', 'nemotron')
|
||||
)
|
||||
ORDER BY created_at ASC
|
||||
""")).fetchall()
|
||||
@@ -163,12 +188,12 @@ class ActionPlanHygieneService:
|
||||
try:
|
||||
rows = session.execute(text("""
|
||||
SELECT id, status, priority, created_at, action_type, plan_type,
|
||||
created_by, description, metadata_json
|
||||
created_by, description, metadata_json, payload
|
||||
FROM action_plans
|
||||
WHERE status IN ('pending', 'auto_pending', 'pending_review')
|
||||
AND (
|
||||
action_type IN ('code_review_fix', 'openclaw_recommendation')
|
||||
OR created_by IN ('code_review_pipeline', 'openclaw')
|
||||
OR created_by IN ('code_review_pipeline', 'openclaw', 'nemotron')
|
||||
)
|
||||
ORDER BY created_at ASC
|
||||
""")).fetchall()
|
||||
|
||||
Reference in New Issue
Block a user