Skip to content

fix(conversations): Save the root Actor Identity only on the first write - #3066

Merged
BYK merged 1 commit into
mainfrom
fix/root-actor-identity-first-write
Nov 10, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/root-actor-identity-first-write

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #3065.

Every Conversation write saved the root Actor's Identity again, even though actor_identity_id never changes after the first write. When someone posted from the dashboard into a Slack thread, mergeActor added 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.

resolveConversationActorIdentityId now returns the stored actor_identity_id when 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.ts fails on main: the starter's Slack Identity ends up with the poster's user_id and email. In the full local suite, the thread tests sometimes fail with Conversation parent changed for agent:4ee809ff…. main hits the same failure, so it's an existing flake.

via @szokeasaurusrex.

--

View Session in Sentry

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]>
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 10, 2026 11:19am UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

17 screenshot changes — 17 changed · 0 added · 0 removed

Review screenshots in Frameshift

Code · Desktop
Code · Desktop
Changed
Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Attachment Zoom · Mobile
Conversation Attachment Zoom · Mobile
Changed
Show 11 more changed screenshots
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Captured Memories Popover · Mobile
Conversation Captured Memories Popover · Mobile
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Fork Dialog · Desktop
Conversation Fork Dialog · Desktop
Changed
Conversation Fork Dialog · Mobile
Conversation Fork Dialog · Mobile
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Unsent Answers · Desktop
Conversation Unsent Answers · Desktop
Changed
Conversation Unsent Answers · Mobile
Conversation Unsent Answers · Mobile
Changed
Conversations Sections Collapsed · Desktop
Conversations Sections Collapsed · Desktop
Changed
Push Notifications Tip · Desktop
Push Notifications Tip · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay overall.

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.

Create a migration for this as a follow up.

@BYK
BYK merged commit 070d824 into main Nov 10, 2026
45 checks passed
@BYK
BYK deleted the fix/root-actor-identity-first-write branch November 10, 2026 11:57
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

1 active deployment
Preview – junior-docs — 47cb43ed Deployed Nov 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard post links a Slack root Actor to the poster's User

2 participants