You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6b33427
Browse filesBrowse the repository at this point in the historyBrowse files
fix(comms): resolve WHO a send is for before sending it, and never send without recording
A client status email went out correctly and attached to the wrong person. Both send paths
resolved the recipient with a blind first-match: the CLI fallback via
`?search=<addr>&per_page=1` then `rows[0]`, and the API router via `SOMLeads::findDuplicate()`
ending in an unordered `->first()`. The address belonged to two leads — the NCMA record with the
relationship, and a Stripe-created duplicate — and it picked the duplicate. Neither path could
warn: `per_page=1` means it never learned a second row existed. (#185438, EPIC #185439)
Resolution now happens ONCE, in front of the branch, and is allowed to refuse:
- `resolveLeadForHandle` asks for 50 rows, filters to an EXACT address match, and returns the
tie as a first-class outcome. `decideLeadMatch` is the pure half, tested against the two rows
production actually returned.
- Ambiguous refuses and prints every candidate with `--lead <id>` beside it. `--force` does NOT
break a tie; guessing between two real people is a question only the operator can answer.
- No lead refuses unless `--force`, which sends unattributed and says so.
- The resolved id is passed to the router as `to_lead_id`, so the API never runs its own
resolver. One CLI fix closes both paths — and fixing only the fallback I had blamed would
have shipped a change that fixed nothing.
And nothing sends without the ledger hearing about it:
- `recordDirectSend` takes the resolved id instead of guessing one.
- Any send that does not land in lead_comms — a record POST that fails, a router that returns
no comm id, a `--force` send with no lead — is appended to ~/.iris/comms-unlogged.jsonl.
Printing the failure was not enough: the line scrolls past and the send is then missing from
the ledger with nothing anywhere that remembers.
- `iris mail audit` lists them and `--backfill` writes them to their leads. It is complete
going forward and honest about the past: sends made before the spool existed left no trace,
and implying otherwise would be the same false assurance in a new place.
Verified against production, not fixtures: the real ambiguous address resolves to `ambiguous`
with both leads named; an unknown address resolves to `none`; the spool round-trips; and the
backfiller repaired the actual incident, moving the email onto lead anomalyco#10394 as comm anomalyco#5603.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FEVuQjtBdw2Mq3EpE56GFY
0 commit comments