feat(orchestrator): radio receipts inline (005 phase B)
Requirement 005: every radio message in the Stream and the radio log shows the avatars of the agents that read it, with read time and an ack badge where a receipt exists; receipt rows no longer appear as entries of their own, and the sender shows once. Read times come from seen marks, stamped only after a fresh presence pass no older than two sighting intervals; a stored time before its row is refused. An operator message links to its relay row through the ts radio.py prints first on stdout right after store(), checked against an exact row (sender Operator, relay text, targets, no to_sessions); a ts shared by two rows shows no readers. radio.py clips printed addresses; the hub keeps the first stdout line whole. Accepted MEDUSA false positives: MM-SCAN-058 at server.py:73, JB-SCAN-641 and JB-SCAN-616 at radio.py:389 (clip, the output sanitizer), FLA-SCAN-055 at radio.py:109. Committed below the 90/5 bar on the operator's word; the receipts e2e runs through the queue. 🎯 Fix: 89 % 💥 Break: 6 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 84 🚦 Gate: ⛔ fix 89 % < 90, break 6 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
92f5087eed
commit
30b2a32095
25 files changed
+1432
-87
No files matched your search
@@ -81,17 +81,34 @@ class Directory:
|
||||
return found
|
||||
|
||||
|
||||
def valid_entry(entry: object) -> bool:
|
||||
if not isinstance(entry, dict) or set(entry) != {"session", "name", "first_seen", "source"}:
|
||||
return False
|
||||
texts = all(isinstance(entry[key], str) and entry[key] for key in ("session", "name", "source"))
|
||||
moment = entry["first_seen"]
|
||||
return texts and isinstance(moment, int | float) and not isinstance(moment, bool) and math.isfinite(moment)
|
||||
|
||||
|
||||
class Names:
|
||||
def __init__(self, file: Path) -> None:
|
||||
"""Args:
|
||||
file: the store; an entry or an observed name of the wrong shape
|
||||
or type is left out.
|
||||
"""
|
||||
self.file = file
|
||||
self.lock = threading.Lock()
|
||||
self.titled = -math.inf
|
||||
data = read_json(file)
|
||||
data = data if isinstance(data, dict) else {}
|
||||
entries, observed = data.get("entries"), data.get("observed")
|
||||
keys = {"session", "name", "first_seen", "source"}
|
||||
self.entries = [entry for entry in entries if isinstance(entry, dict) and set(entry) == keys] if isinstance(entries, list) else []
|
||||
self.observed: dict[str, str] = observed if isinstance(observed, dict) else {}
|
||||
self.data = data if isinstance(data, dict) else {}
|
||||
entries, observed = self.data.get("entries"), self.data.get("observed")
|
||||
self.entries = [entry for entry in entries if valid_entry(entry)] if isinstance(entries, list) else []
|
||||
self.observed: dict[str, str] = {key: name for key, name in observed.items() if isinstance(name, str)} if isinstance(observed, dict) else {}
|
||||
|
||||
def payload(self) -> dict:
|
||||
return {"entries": self.entries, "observed": self.observed}
|
||||
|
||||
def save(self) -> None:
|
||||
write_atomic(self.file, json.dumps(self.payload(), sort_keys=True).encode("utf-8"))
|
||||
|
||||
def observe(self, sightings: list[tuple[str, str, float | None, str]], now: float) -> None:
|
||||
"""Args:
|
||||
@@ -120,7 +137,7 @@ class Names:
|
||||
first = seen if seen is not None and seen > floor else max(now, floor)
|
||||
self.entries.append({"session": session, "name": name, "first_seen": first, "source": source})
|
||||
if changed:
|
||||
write_atomic(self.file, json.dumps({"entries": self.entries, "observed": self.observed}, sort_keys=True).encode("utf-8"))
|
||||
self.save()
|
||||
|
||||
def listed(self) -> list[dict]:
|
||||
with self.lock:
|
||||
|
||||
Reference in new issue
Block a user