Skip to content

fix(relay): keep a Group's rule when the admin who set it deletes their account - #4623

Open
icedevera wants to merge 1 commit into
mainfrom
fix/security-group-rules-and-server-durability
Open

icedevera wants to merge 1 commit into
mainfrom
fix/security-group-rules-and-server-durability

Conversation

@icedevera

Copy link
Copy Markdown
Member

Problem

When an admin deleted their account, the relay deleted every Group rule that admin had saved last. A Group the admin had set to "No access" then fell back to the member level, so every member could read it, and write to it at Edit level.

sync_relay_group_rules.changed_by_user_id was NOT NULL. Account deletion's purge deletes rows whose *user_id column names the deleted account. Folder rules avoid this: the purge sets their author to NULL.

Change

  • sync_relay_group_rules.changed_by_user_id is now nullable. A relay that already has the table (migration workspace-group-rules-v1) rebuilds it under workspace-group-rules-v2 when it starts and keeps every row. The rebuild runs in the relay's schema transaction, and it checks the earlier table's exact schema first.
  • The purge clears changed_by_user_id on Group rules as it does on folder rules. A Group's rule now outlives whoever saved it last.

Risk and recovery: after this build migrates a relay, an earlier build refuses to start on it, because it expects the NOT NULL column. Reverting the code doesn't undo the migration.

Fixes #4587

Verification

  • New test keeps a Group hidden after the admin who hid it deletes their account (workspaceMembers.test.ts): an admin sets a Group to No access and then deletes their account. The test checks that a member's pull doesn't contain the Group, that reading the Group answers 404, that posting in it is refused, and that the owner still sees the rule. On the base commit it failed because the member's pull contained the hidden Group. With the change it passes.
  • New test keeps an earlier build's rules and lets their author be cleared (storage/groupRules.test.ts): a v1 table with a row upgrades, keeps the row, accepts a NULL author, and setup runs again cleanly.
  • On Windows: the relay typecheck passes, oxlint is clean on the changed files, and the Group, member, member reach and account deletion suites pass (113 tests). In the full relay suite on Windows, the failures were subprocess timeouts under load. They passed when rerun alone, except one test that needs a locally built engine binary.

Council review

Rounds: 2 in total (1 pre-pass, 1 council). Size: +27 product lines, 13 removed (budget 25).

Seat Round 1
GPT Sol (pre-pass, carried in) 9/10
Claude Opus 8/10
Gemini 4 Neon 9/10

Follow-ups:

  • sync_relay_workspace_level_changes deletes its row the same way when that admin deletes their account. This loses who set the members' level, but no access changes.
  • The migration test could open the database through the relay's storage opener with foreign keys on, and use a Group with a creation rule.
  • The rebuild could use the shared rebuildTables helper.

🤖 Generated with Claude Code

…ir account

Account deletion deleted every sync_relay_group_rules row the account
saved last, so a Group set to No access became visible to members. The
column is now nullable, an earlier table is rebuilt with its rows, and
the purge clears the author as it does for folder rules.

Fixes #4587

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T08:23:17.462882Z ae0c626 PR opened
🔒 Security Review ✅ Completed 2026-11-25T08:25:09.084979Z ae0c626 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting an admin's account removes the Group rules they last set, widening member access

1 participant