Visitar URL original
feat(mothership): erase private memory when a member leaves or an organization is deleted by waleedlatif1 · Pull Request #9503 · simstudioai/sim · GitHub
Skip to content

feat(mothership): erase private memory when a member leaves or an organization is deleted - #9503

Merged
waleedlatif1 merged 3 commits into
stagingfrom
feat/memory-offboarding-erasure
Oct 31, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
feat/memory-offboarding-erasure

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Mothership's private memory (the memory sidecar, live only in hosted dev) is now erased when its owner is offboarded (Mothership D106, simstudioai/mothership#878). Account deletion already queues the worker's memory cleanup. This PR also queues it, in the same transaction as the change it follows, when:

  • a member is removed from an organization (removeUserFromOrganization): target organization_member
  • an external collaborator is removed from an organization's workspaces (removeExternalUserFromOrganizationWorkspaces): target organization_member, since their workspace chats used that organization's memory
  • a member is moved to another organization: organization_member for the source organization
  • an organization is deleted (enqueueOrganizationResourceCleanup, called by the admin delete): target organization

lib/mothership/generated/memory-notes-access.ts is regenerated from the worker contract (bun run contracts:sync).

Companion: simstudioai/mothership#878

Product update (if relevant)

None visible. Private memory is limited to effective super-users with the benchmark deployment opt-in, and only hosted dev runs the memory sidecar. On staging and production the worker answers these cleanup events without erasing anything.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • lib/mothership/memories/offboarding.integration.ts runs against real Postgres (bun run test:integration lib/mothership/memories/offboarding.integration.ts, passing locally). A removal whose actor lacks authority rolls back and queues nothing. A committed member removal and an external-collaborator removal each queue organization_member for that user. enqueueOrganizationResourceCleanup in a rolled-back transaction queues nothing, and in a committed one queues organization.
  • It fails with membership.ts and resource-cleanup.ts reverted to staging (expected 2 queued erasures, received none).
  • Ordering: merge after the worker side is deployed to the environment this Sim talks to. An older worker answers 400 to the new targets, so the outbox retries and eventually dead-letters them; nothing is lost that the worker holds today.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 31, 2026 7:11am UTC

Request Review

@github-actions github-actions Bot added the requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep label Oct 31, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Cross-repo companion check

One or more companion PRs aren't merged into staging yet. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.

  • ❌ simstudioai/mothership#878 — OPEN, not merged (targets staging) — feat(worker): erase private memory when its owner is offboarded

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge after the companion worker changes are deployed, as noted in the PR description.

Summary

Queues private memory cleanup in the same transaction as member removal, external collaborator removal, organization transfer, or organization deletion.

  • Leaving an organization now queues erasure of that person's private memory.
  • Deleting an organization now queues erasure of its private memory.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Member leaves or organization is deleted] --> B[Database transaction]
  B --> C[Change organization access or resources]
  C --> D[Queue memory cleanup]
  D --> E{Transaction commits?}
  E -->|Yes| F[Outbox delivers cleanup to worker]
  E -->|No| G[Discard changes and cleanup event]
Loading

Reviews (4) · Last reviewed commit: "test(mothership): cover a successful ext..." · Reviewed by Greptile

…anization is deleted

Account deletion already queues the worker's memory cleanup. Removing a
member, removing an external collaborator from an organization's workspaces,
moving a member to another organization and deleting an organization now
queue it too, in the same transaction, with the worker's new
organization_member and organization targets.
@waleedlatif1
waleedlatif1 force-pushed the feat/memory-offboarding-erasure branch from e53a76c to 5446713 Compare October 31, 2026 06:47
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

… database

The unit tests only checked mocked outbox calls. The integration test runs
member removal, external removal and organization cleanup against Postgres:
each committed change queues its erasure, a rolled-back one queues nothing.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
waleedlatif1 merged commit 09ed990 into staging Oct 31, 2026
69 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/memory-offboarding-erasure branch October 31, 2026 07:33

This branch was previously deployed

1 inactive deployment
Preview — 0f6cd971 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant