Review fixes: narrow intake redact predicate to the bot's own nudge + edge tests

reviewer agent flagged the broadened redact_thread predicate (event_id OR in_reply==root)
as over-matching any plain reply to a thread root. Gate the bare-in_reply clause to the bot's
own sender (the nudge is always ours); thread children (cards/acks/human yes-no) still match by
rel_type=m.thread. Add unit edges for _name_similarity's all-generic fallback and a contact_id
NULL orphan case for the grid-blob email heal.
This commit is contained in:
Keysat
2026-06-20 13:05:13 -05:00
parent 8c9b8b8cc1
commit acd316ead4
3 changed files with 35 additions and 6 deletions
+8 -4
View File
@@ -254,10 +254,14 @@ async def main():
for ev in chunk:
rel = ((getattr(ev, "source", None) or {}).get("content", {}) or {}).get("m.relates_to") or {}
in_reply = (rel.get("m.in_reply_to") or {}).get("event_id")
# A thread child carries event_id==root; the un-threaded nudge carries only
# m.in_reply_to.event_id==root. Catch both so the thread AND its main-timeline
# pointer clear together.
if rel.get("event_id") == root or in_reply == root:
# A thread child carries rel_type=m.thread + event_id==root (the cards/acks +
# the human's yes/no replies — any sender). The un-threaded nudge is the BOT's
# own plain reply to root (only m.in_reply_to==root, no rel_type); gate that
# clause to our sender so we don't also redact an unrelated human plain-reply
# to the same root (root itself is already redacted above).
is_thread_child = rel.get("rel_type") == "m.thread" and rel.get("event_id") == root
is_own_nudge = in_reply == root and getattr(ev, "sender", None) == mx["user_id"]
if is_thread_child or is_own_nudge:
await redact_card(room_id, ev.event_id)
token = getattr(resp, "end", None)
scanned += len(chunk)