harden against mib007 mention-path 500 (insert-then-error)
Smoke test found: any @handle in a comms message 500s AFTER the row is inserted (agents.url_key column missing on this instance), so a retry duplicates the message. Neutralise ALL '@' the bridge emits (incl. its own @nir escalation, zwsp renders identically) and make comment HTTP errors non-retryable best-effort drops; posts still retry. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YECpkAwQUwgu7NVy91R8fW
This commit is contained in:
co-authored by
Claude Fable 5
parent
9a862bee2b
commit
1a3ab878b4
@@ -115,8 +115,11 @@ def neutralize(text: str) -> str:
|
||||
"""Insert a zero-width space after '@' in ledger-derived text.
|
||||
|
||||
mib007's comms route treats the FIRST '@handle' in a message as an agent
|
||||
mention and fires an AI reply into the thread (e.g. @ellie). Ledger text
|
||||
must never trigger that; only the bridge's own deliberate mention may.
|
||||
mention: a matching agent fires an AI reply into the thread, and on this
|
||||
instance ANY mention 500s after the insert (the agent lookup references a
|
||||
nonexistent url_key column). So no bridge-emitted text may ever contain a
|
||||
bare '@handle' — including the bridge's own needs-you escalation, which is
|
||||
emitted zwsp-neutralised and renders identically in the UI.
|
||||
"""
|
||||
return (text or "").replace("@", "@")
|
||||
|
||||
@@ -151,8 +154,8 @@ def update_body(rec: dict) -> str:
|
||||
stage = rec.get("stage")
|
||||
note = neutralize(rec.get("note", ""))
|
||||
if kind == "needs-you":
|
||||
lines.append(f"@{MENTION} NEEDS YOU: this item is now waiting on a human."
|
||||
+ (f" — {note}" if note else ""))
|
||||
lines.append(neutralize(f"@{MENTION}") + " NEEDS YOU: this item is now"
|
||||
" waiting on a human." + (f" — {note}" if note else ""))
|
||||
note = "" # already included
|
||||
elif kind == "failed":
|
||||
where = f" at {stage}" if stage else ""
|
||||
@@ -249,7 +252,14 @@ def comment(state: dict, ledger_id: str, content: str, what: str) -> None:
|
||||
if not post_id:
|
||||
log(f"SKIP {what} {ledger_id[:8]}: no mapped post (predates bridge)")
|
||||
return
|
||||
msg = send_message(ensure_channel(state), content, thread_id=post_id)
|
||||
try:
|
||||
msg = send_message(ensure_channel(state), content, thread_id=post_id)
|
||||
except urllib.error.HTTPError as e:
|
||||
# mib007 comms can 500 AFTER the insert (proven: mention-path crash),
|
||||
# so retrying a failed comment risks duplicates. Comments are
|
||||
# best-effort: log and move on instead of blocking the checkpoint.
|
||||
log(f"DROP {what} {ledger_id[:8]}: HTTP {e.code} (comment not retried)")
|
||||
return
|
||||
log(f"{what:6} {ledger_id[:8]} -> comment {msg['id']}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user