Repository navigation
fix(conversations): Save the root Actor Identity only on the first write - #3066
Merged
Merged
Conversation
A dashboard post into a Slack thread merged the poster's email into the stored Slack root Actor. Each Conversation write saved that Actor's Identity again, so the verified email linked the thread starter's Slack Identity to the poster's User. The poster then got the starter's Conversations, photo, and handle. The root Actor is set once, so a later write now reuses the stored Identity id and does not save the Identity again. Fixes #3065 Co-Authored-By: Daniel Szoke <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
17 screenshot changes — 17 changed · 0 added · 0 removed Review screenshots in Frameshift Show 11 more changed screenshots |
BYK
approved these changes
Nov 10, 2026
23 tasks done
sentry-junior Bot
added a commit
that referenced
this pull request
Nov 10, 2026
Before #3066, a dashboard post into a Slack thread could link the thread starter's Slack Identity to the poster's User. Migration 0095 finds those Identities, removes the Participant rows that the link added, and clears the copied email and User link. An Identity is repaired only when the poster's web Identity, with the same email, wrote in one of its roots, and none of its own Slack instructions carry that email from the Slack profile. Refs #3065 Co-Authored-By: BYK <[email protected]>
BYK
added a commit
that referenced
this pull request
Nov 10, 2026
…3072) Follow-up to #3066, as asked in [the review](#3066 (review)). Refs #3065. Migration `0095` repairs Slack Identities that a dashboard post linked to the poster's User before #3066. **Evidence.** A Slack instruction stores the Actor from the Slack profile (`createSlackActor`) in `provenance.actor`. Slack is the only source that may give a Slack Identity its email. So an instruction with the Identity's Slack user and email proves that email, and nothing else does. **Candidates.** A Slack Identity is a candidate when: - it has a User and a verified email, and no evidence proves that email; - the User's web Identity (`junior/<email>`, same email) wrote an event in a root that the Slack Identity started. This is the #3065 path. **Self-check instead of a dry run.** Slack emails are unique in a workspace, so a User has at most one correct Slack Identity per team. The migration repairs a candidate only when evidence proves exactly one other Slack Identity of the same User in that team. It leaves every other candidate as it is: - a poster with no Slack Identity of their own; - a poster whose own Slack Identity has no evidence, because they linked it through a dashboard post or because retention removed its events. The migration is idempotent. **Repair** (one statement, so every part reads the same rows): - Delete the poster's Participant rows on roots that the damaged Identity started or sent a Turn in. Keep a row when the poster started that root, or wrote in it, through another Identity. - Clear `user_id`, `email`, `email_normalized`, and `email_verified` on the Identity. That is its state before the link. Its own Slack Turns have no email, so they cannot link it again. - Clear the Identity's `display_name` when it matches the poster's web Identity and no Slack evidence proves it. The same write copied the poster's name when Slack gave the starter none. - Clear the poster User's `display_name` when the starter's own Slack instructions prove it is the starter's name and no proven Slack Identity of the User has it. Clear it on the User's web Identities too: dashboard posts copy the User name there, and the next save copies it back. Conversations read the User name before the Identity name, so without this all of the poster's work showed the starter's name. - Bump `detail_version` on the affected roots. **Not repaired:** - Review items that the starter's Turns assigned to the poster by default. The item does not record whether the agent picked the assignee or the default did. - OAuth Identities, timezone, and customization that the starter's Turns saved on the poster's User during the link. These are keyed by User, and nothing records which person saved them. **Report.** The migration reports its counts with `RAISE INFO`, and `junior upgrade` now prints Postgres `INFO` messages, so the counts appear in the junior-prod Vercel build log. The report has no identifiers: ```text 0095 Slack Identity repair: N candidates, N repaired, N skipped with no proven Slack Identity, N skipped with more than one, N Participant rows removed, N roots updated, N User names and N web Identity names cleared ``` The skipped counts show how many victims a later fix must reach. **Merge only when junior-prod production serves a release that contains #3066.** Every junior-prod build runs `junior upgrade` before the build, while the current deployment still serves traffic. If an older release serves traffic when the migration runs, its workers can link an Identity again, and the migration does not run again. #3066 shipped in `0.291.0`, and junior-prod production serves `0.291.0`. I checked it locally against Postgres 17 with the pre-#3066 code. Cases checked: - A starter linked to a poster with a proven Slack Identity is repaired. The poster keeps their link and the roots they started or wrote in. - A Participant row added by the starter's Turn in a third person's root is removed. - No repair when the poster has no Slack Identity, or when no Slack Identity of the poster has evidence. - An old linked victim with no events does not block the repair of other victims. - A poster User that took the starter's name gets its name cleared. - A second run changes nothing. `migration-info-messages.test.ts` covers the report path. There is no committed test for 0095 itself, per repo policy. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A11f5880521588bd262f4d0d1 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A11f5880521588bd262f4d0d1/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3065.
Every Conversation write saved the root Actor's Identity again, even though
actor_identity_idnever changes after the first write. When someone posted from the dashboard into a Slack thread,mergeActoradded the poster's email to the Slack root Actor (the stored Actor had no email). Saving that Identity again marked the email as verified, which linked the thread starter's Slack Identity to the poster's User. Since #3021, the poster also became a Participant of every Conversation the starter had started.resolveConversationActorIdentityIdnow returns the storedactor_identity_idwhen the Conversation already has one. It saves an Identity only on the first write, or for an older row that has none. The merged stored Actor still exists, but later writes no longer act on it. #2439 step 8 deletes it.Behavior change: a later Conversation write no longer adds profile fields (email, name) to the root Actor's Identity. The component test that asserted this now asserts the new rule. In my reading of the code, a person's own Turns still save their Slack profile on that Identity through the Turn Actor resolution in
turn-cursor.ts, but no test here covers that.Not in this PR: repairing Identities that are already linked to the wrong User. #3065 has the detection signal (more than one Slack Identity per User in the same team). The repair should follow the #2439 dry-run and migration rules.
The new test in
messages.test.tsfails onmain: the starter's Slack Identity ends up with the poster'suser_idand email. In the full local suite, the thread tests sometimes fail withConversation parent changed for agent:4ee809ff….mainhits the same failure, so it's an existing flake.via @szokeasaurusrex.
--
View Session in Sentry