feat(operator): report each operator row outcome back to the agent that queued it
operator.py stores the adding session's name and id with the row. Done, cancel and failure go to that stored name and pinned session id, never re-resolved: a radio post by default, a call when that session picked it with radio.py feedback set call. The caller's own parts are dropped. The hub counts unanswered calls per session id. MEDUSA: 34 findings accepted after an independent review, 0 true positives: 3x CGS-SCAN-029 by design (operator-confirmed runner in operator.py execute and its call), 2x CGS-SCAN-030 (exec inside the name execute), CODEGEN-SCAN-003 and CGS-SCAN-028 (open inside Popen), 3x CGS-SCAN-040 (prompt loops end), 4x GENAI-SCAN-1270 (rasci.database() JSON register), 20x FLA-SCAN-055 (dba inside the word feedback). 🎯 Fix: 93 % 💥 Break: 4 % 💸 Cost: 100 % ⏱️ Time: 100 % 🛡️ Security: 100 % 🏆 Score: 89 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3418738993
commit
7d70e07b4c
14 files changed
+833
-95
No files matched your search
@@ -33,15 +33,21 @@ def read_snapshot(path: Path, now: float) -> dict[str, dict]:
|
||||
|
||||
def unanswered(news: list[dict], now: float) -> list[tuple[str, float]]:
|
||||
"""Returns:
|
||||
(callee name, call time) of every call older than UNANSWERED that its
|
||||
callee never receipted.
|
||||
(callee, call time) of every call older than UNANSWERED without a
|
||||
receipt: one per session id in `to_sessions`, answered by any
|
||||
receipt of that call; else one per name in `to`.
|
||||
"""
|
||||
receipts = {(agent(row.get("from")), round(epoch(row.get("call")) or 0, 3)) for row in news if row.get("class") == "receipt"}
|
||||
answered = {call for _, call in receipts}
|
||||
late = []
|
||||
for row in news:
|
||||
ts = epoch(row.get("ts"))
|
||||
if row.get("class") != "call" or ts is None or now - ts < UNANSWERED or not isinstance(row.get("to"), list):
|
||||
continue
|
||||
sessions = [sid for sid in row["to_sessions"] if isinstance(sid, str)] if isinstance(row.get("to_sessions"), list) else []
|
||||
if sessions:
|
||||
late += [(sid, ts) for sid in sessions if round(ts, 3) not in answered]
|
||||
continue
|
||||
late += [(name, ts) for name in map(agent, row["to"]) if name and (name, round(ts, 3)) not in receipts]
|
||||
return late
|
||||
|
||||
@@ -75,7 +81,7 @@ def presence(sessions: dict[str, dict], parts: dict[str, str], mode: str, claims
|
||||
busy = record.get("status") == "busy"
|
||||
stamp = record.get("statusUpdatedAt")
|
||||
updated = (epoch(stamp / 1000) if isinstance(stamp, int | float) and not isinstance(stamp, bool) else None) or 0
|
||||
called = names.get(sid, set()) | {agent(record.get("name"))}
|
||||
called = names.get(sid, set()) | {agent(record.get("name")), sid}
|
||||
if (busy and now - updated > STALE) or any(name in called and ts > updated for name, ts in late):
|
||||
states[sid] = "unreachable"
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user