Skip to content

fix(review-desk): Purge private Review items and add missing foreign keys - #2477

Merged
dcramer merged 4 commits into
mainfrom
fix/review-item-purge-fks
Nov 1, 2026
Merged

dcramer merged 4 commits into
mainfrom
fix/review-item-purge-fks

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Transcript purge did not touch Review items. So the title, body, and answer of an item from a private Conversation stayed after Junior purged that Conversation.

Purge. When purgeConversationTree scrubs a non-public tree, it now deletes the private Review items that the tree added (added_by_conversation_id). This follows the existing rule for Briefs: private Briefs are deleted, public Briefs stay. The assignees, links, and Slack card rows cascade. A public item stays, also when its destination turned private later, because other Conversations can still link to it. selectExpiredRoots also counts private items as remaining work, the same as private Briefs.

Foreign keys (migration 0070_review_item_foreign_keys):

  • junior_review_items.added_by_conversation_id → junior_conversations with ON DELETE cascade. This matches the link table. Conversation rows stay after a purge, so this changes nothing today.
  • junior_review_item_slack_cards.conversation_id → junior_conversations with ON DELETE cascade.
  • junior_review_items.closed_by_user_id: now ON DELETE set null. Before, it had no rule, so it blocked the User delete. A null value already means "an agent closed it".

Existing rows meet the new constraints: the add tool inserts the added-by Conversation as a link, and that link already has a foreign key. Cards are posted only for linked Conversations.

Decisions for you

  • Private items are hard-deleted on purge. They are not redacted. An open private item from an Automation run goes away when the tree of the first run is purged, even if a later run still links to it.
  • With set null on closed_by_user_id, an item closed by a deleted User reads as closed by an agent.

The rule is documented in chat/review-items/README.md ("Purge").

via David Cramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Oct 31, 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 1, 2026 9:51pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c274a56. Configure here.

@dcramer
dcramer enabled auto-merge (squash) November 1, 2026 21:25
@dcramer

dcramer commented Nov 1, 2026

Copy link
Copy Markdown
Member

Needs rebased

sentry-junior Bot and others added 4 commits November 1, 2026 21:46
…keys

Transcript purge of a non-public Conversation tree now deletes the Review
items it added, the same way it deletes its Briefs. Add foreign keys for
added_by_conversation_id and Slack card conversation_id, and set null on
closed_by_user_id when its User is deleted.

Co-Authored-By: David Cramer <[email protected]>
…vate items

A purge already leaves an open item of an Automation open, because a
later run can still change it (#2506). The private item delete did not
skip it, so a purge of the first run removed an item that the Automation
still updates. Skip open Automation items in the delete and in the purge
selection, so the next purge deletes the item after it closes.

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior
sentry-junior Bot force-pushed the fix/review-item-purge-fks branch from f7c9aa7 to f941ba8 Compare November 1, 2026 21:50
@dcramer
dcramer merged commit 6a1fb89 into main Nov 1, 2026
43 checks passed
@dcramer
dcramer deleted the fix/review-item-purge-fks branch November 1, 2026 21:55

This branch was successfully deployed

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

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant