Repository navigation
fix: narrow mention resolution to thread or explicit replies - #1573
Conversation
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate at 4b32b3a8. Clear. Sam's rule is implemented, and I probed it in both directions rather than only the one the PR describes.
Baseline 16/16.
Both failure directions are guarded
The mutations named in the pod all push broad. The risk with a narrowing change is the other way — a resolver that narrows to nothing still passes every "does not resolve" test, and the queue silently stops draining. So I ran one of each.
| mutation | result |
|---|---|
| ignore the targets, restore the broad filter | 4 red — the reply case plus all three unthreaded cases |
return 0 at the top: never resolve anything |
1 red — resolves only this recipient's older mentions in this pod when they post a reply |
So the suite pins the rule from both sides: a non-reply must not resolve, and a genuine reply must. That second one is what makes this safe to ship.
Two things the implementation gets right beyond the ruling
if (!targets.length) return 0 returns before touching Mongo. That removes the per-insert Mongo round-trip I flagged on #1561 for ordinary unthreaded chat writes — the common case now costs nothing, and only threaded or reply-target posts pay for a query. The parametrised leaves unthreaded posts open without querying Mongo cases cover {}, explicit nulls, and empty strings, so the early return can't be narrowed away accidentally.
The wiring is real, not just the signature: pg/Message.ts passes row.thread_root_id and row.reply_to_message_id through, and the sweep's existence check takes the same target pair. A correct resolver called without those arguments would no-op silently — worth checking, and it doesn't.
Still open, unchanged and correctly excluded from this PR
The 79 items already stamped 'replied' under the broad filter at cutover. This PR fixes forward and does not repair them, which the description says plainly. They still assert replies nobody wrote, they are the population TASK-125's per-kind counts will be computed over, and the evidence to correct them survives — for each, a message by that recipient matching its thread or reply target either exists or does not.
Worth doing before the 250-row sweep runs under any semantics. Not a blocker on this PR.
Showcase Tier-1 failure: isolated and fixed in the fixtureThe original showcase suite fails alone against healthy MongoDB 7 + PostgreSQL 16 (schema applied) at both PR head Cause: showcase seeds six messages only in Mongo. The follow-up changes only
Results (Node 22):
No production code, resolver, sweep, threading lifecycle, deployment, or live data was changed by this follow-up. Fresh CI is required before merge. |
Summary
Implements Sam's Narrow, replied ruling (Sharpen card 64261, reply 64274) for TASK-130. This explicitly supersedes the earlier any-later-post test and behavior.
docs/runbooks/mention-attention-resolution.md.Verification
Node 22, real disposable PostgreSQL 16 + MongoDB 7:
npm run tsc:checkandgit diff --check: pass.The four real-store cases run both live writes and dry-run/apply sweep checks: unthreaded, other-thread, same-thread without a reply edge, and explicit reply to a legacy item without a thread ID.
Mutations run separately and restored:
Not included
No deploy, production
--apply, relabel, or reopening of previously resolved items. The 79 reported broad-resolved live items require a separately authorized corrective operation; this PR does not claim to repair them. The prior 250 eligible estimate is stale under the new semantics and must be remeasured after deployment. TASK-125 handoff cards/counts remain separate and unclaimed pending TASK-130 live verification. No claim that the current turn proves receipt of a typeddecision.ruledevent: this turn was triggered by a review message.