Skip to content

fix(lifecycle): retain shared resources when creators leave - #8762

Merged
mzxchandra merged 15 commits into
stagingfrom
codex/shared-resource-lifecycle
Oct 13, 2026
Merged

mzxchandra merged 15 commits into
stagingfrom
codex/shared-resource-lifecycle

Conversation

@mzxchandra

@mzxchandra mzxchandra commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Transfer shared workspace resources to the existing billed account before removing access, and transfer organization-only resources to an existing organization owner. Preserve archived roots, child rows/documents, and file history without changing non-null API contracts.
  • Preserve implicit upload attribution through handoff, including empty uploads, and keep legitimate first writes at version 1. Serialize content writes, archive rollback, and retention cleanup with member removal by locking the workspace before existing files.
  • Repair references from earlier departures before permanent account deletion, using transactional successor validation and a user-row barrier against late creator references. Both v1 admin removal routes use the common revocation path.
  • Retain public MCP execution identity and block creator deletion until an admin makes the server private or deletes it. Require live workspace API keys to be replaced/revoked instead of transferring credentials.

Type of Change

  • Bug fix

Testing

  • 74 affected real PostgreSQL cases pass: file history, full member-removal races, lifecycle retention, and storage accounting. Eight contention cases verify both arrival orders for content writes, archive rollback, and retention cleanup.
  • The unchanged code reproduced four PostgreSQL deadlocks. Removing each early lock independently reproduced its failure; restored code passes. Earlier history controls verify uploader attribution, first-write numbering, restored versions, and retained storage references.
  • 158 affected unit tests pass. Scoped Biome, API-validation and test-pattern audits, generated artifacts, and diff checks pass. Full repository tests, typecheck and build run in CI.
  • Earlier HTTP lifecycle acceptance verifies handoff, departed-user denial, account deletion, surviving-user access, file bytes, non-null contracts, and storage/history preservation; it was not rerun for the lock-order correction.

Checklist

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

Scope notes

Shared service-account and workspace-env credential lifecycle is intentionally deferred: their existing creator cascade remains, with no new transfer or deletion guard. Existing workflow owner-based execution/environment fallback is preserved. Public MCP execution-identity cleanup is a separate follow-up. Already-admitted requests may finish after departure; permanent deletion repairs their committed references or rejects late user references. HTTP document setup uses a provider-independent fixture, so these tests do not claim connector indexing or provider execution coverage.

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Oct 13, 2026 5:24am UTC

Request Review

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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.

All reported issues were addressed across 10 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/v1/admin/workspaces/[id]/members/route.ts
@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; no new actionable issue remains.

Summary

This PR retains shared resources when their creators leave and repairs older creator references before account deletion.

  • Leaving a workspace now hands shared resources to a reachable survivor.
  • Organization-only resources move to an active organization owner.
  • Account deletion repairs shared links left by earlier departures.
  • Account deletion waits when shared execution still depends on the creator.
  • Shared file handoffs keep upload history and storage totals intact.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Member removal] --> B[Lock workspace]
  B --> C{Successor has access?}
  C -->|No| D[Keep access and resources]
  C -->|Yes| E[Preserve implicit file history]
  E --> F[Transfer shared creator references]
  F --> G[Remove access]
  H[Account deletion] --> I[Lock organization and Project gates]
  I --> J[Lock related workspaces]
  J --> K{User row available without waiting?}
  K -->|No| L[Roll back and request retry]
  K -->|Yes| M[Recheck scopes and execution dependencies]
  M --> N[Repair shared references before deleting user]
Loading

Reviews (14) · Last reviewed commit: "Merge remote-tracking branch 'origin/sta..." · Reviewed by Greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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 10 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

@mzxchandra
mzxchandra marked this pull request as ready for review October 7, 2026 22:43

@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 10 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

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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.

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/uploads/contexts/workspace/creator-handoff.ts Outdated
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile review

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic review

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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.

All reported issues were addressed across 18 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/users/account-deletion.ts
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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 19 files

Confidence score: 5/5

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

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/users/account-deletion.ts Outdated
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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 20 files

Confidence score: 5/5

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

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/workspaces/resource-handoff.ts Outdated
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile review

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic review

@mzxchandra I have started the AI code review. It will take a few minutes to complete.

@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 20 files

Confidence score: 5/5

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

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

@mzxchandra
mzxchandra merged commit 8c52d6b into staging Oct 13, 2026
51 checks passed
@mzxchandra
mzxchandra deleted the codex/shared-resource-lifecycle branch October 13, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 5b4b904f Deployed Oct 13, 2026 by vercel[bot]
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.

1 participant