Repository navigation
feat(workspace): add permanent workspace deletion - #246
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds administrator-only permanent workspace deletion with exact-name confirmation, upload draining, transactional database cleanup, S3 object and version deletion, access blocking, realtime invalidation, client recovery, API routes, and settings UI. ChangesWorkspace deletion
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review loop 1Reviewed all 39 changed files from Confirmed problems and fixes
No other confirmed problems remained after this loop. Verification
|
9eef112 to
fcc5db8
Compare
fcc5db8 to
7ad4c20
Compare
Review loop 2Reviewed all 64 changed files again after loop 1, including every deletion phase, cross-system failure boundary, pending-workspace ingress, public and authenticated read path, upload capability lifetime, migration, UI retry state, documentation, and the complete rebased diff against the latest Confirmed problems and fixes
Investigated review concernThe organization-forbidden realtime close intentionally enters workspace recovery. Every producer of that terminal close means the active workspace is no longer usable, whether from deletion, membership removal, or fail-closed revalidation. The client never reconnects to that tenant; it activates a surviving accessible workspace or opens workspace creation. No change was needed. Verification
No confirmed problem remains from this loop. The branch is now waiting on the fresh GitHub checks for commit |
7ad4c20 to
789d103
Compare
Final review and rebase auditThis is the third complete review pass after the two documented adversarial loops. Problems found and fixed:
Verification after the fixes:
No unresolved review findings remain. This PR changes code only and has not deleted or modified any deployed workspace. |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (10)
apps/web/tests/features/settings/workspace-danger-zone.test.tsx (1)
98-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a surrounding-whitespace case to the confirmation test.
This test pins case sensitivity only. The deletion flow also rejects a name with surrounding whitespace. If someone adds a
.trim()to the component input, no test in this file fails, and the exact-match guarantee degrades silently.💚 Proposed additional assertion
await user.type(screen.getByLabelText('Type Nova to confirm'), 'nova'); expect(confirm).toBeDisabled(); await user.clear(screen.getByLabelText('Type Nova to confirm')); + await user.type(screen.getByLabelText('Type Nova to confirm'), ' Nova '); + expect(confirm).toBeDisabled(); + await user.clear(screen.getByLabelText('Type Nova to confirm')); await user.type(screen.getByLabelText('Type Nova to confirm'), 'Nova'); expect(confirm).toBeEnabled();As per coding guidelines: "A feature is incomplete until it has tests that would fail if the feature broke."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/tests/features/settings/workspace-danger-zone.test.tsx` around lines 98 - 102, Add a surrounding-whitespace assertion to the confirmation test near the existing case-sensitivity checks: verify that values such as “ Nova ” remain disabled, preserving the exact-match requirement and ensuring trimming the component input would fail the test.Source: Coding guidelines
packages/services/tests/storage/storage-prefix.test.ts (1)
11-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winImport the prefix helpers directly instead of casting the module namespace.
The cast at Lines 11-14 asserts that
assertSafePrefixandstoragePrefixForexist on the storage index. If the index stops re-exporting them, the type checker stays silent and the test fails at runtime with an unclear error. Import the helpers from the module that defines them, or from the index as plain named imports so the type checker enforces the contract.♻️ Proposed import
-import * as storage from '../../src/storage/index.ts'; - -const expectedStorage = storage as typeof storage & { - readonly assertSafePrefix: (prefix: string) => string; - readonly storagePrefixFor: (organizationId: string) => string; -}; -const { assertSafePrefix, storagePrefixFor } = expectedStorage; -const { S3StorageDriver } = storage; +import { assertSafePrefix, storagePrefixFor } from '../../src/storage/key.ts'; +import { S3StorageDriver } from '../../src/storage/s3.ts';As per coding guidelines: "Use strict types: do not use
anyor non-null assertions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/tests/storage/storage-prefix.test.ts` around lines 11 - 16, Remove the expectedStorage cast and import assertSafePrefix and storagePrefixFor as direct named imports from their defining module or the storage index. Update their usage to reference the named imports while retaining the S3StorageDriver import, so TypeScript verifies that both helpers are actually exported.Source: Coding guidelines
packages/services/src/storage/s3.ts (1)
252-304: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winBound the delete-and-relist loops.
Both loops re-list the prefix after every delete batch and rely on the listing becoming empty. If a provider reports a successful batch but keeps returning the same keys, or if new objects keep arriving under the prefix, the loop never exits and the deletion request never returns. Add a maximum iteration count and fail with a storage error when it is reached.
♻️ Proposed guard
async function deleteCurrentObjects( client: S3Client, bucket: string, prefix: string, ): Promise<void> { - while (true) { + for (let pass = 0; pass < MAX_DELETE_PASSES; pass += 1) { const page = await client.send( new ListObjectsV2Command({ Bucket: bucket, Prefix: prefix, MaxKeys: MAX_DELETE_OBJECTS }), ); const listed = listedObjects(page.Contents ?? [], prefix); if (listed.length > 0) { await deleteObjects( client, bucket, listed.map((entry) => ({ Key: entry.key })), 'Object storage could not delete every workspace file.', ); continue; } if (page.IsTruncated === true) { throw internal('Object storage returned an incomplete workspace file listing.'); } return; } + throw internal('Object storage could not delete every workspace file.'); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/services/src/storage/s3.ts` around lines 252 - 304, Bound the retry loops in deleteCurrentObjects and deleteVersionedObjects with a maximum iteration count. Increment the count for each list/delete cycle, and when the limit is reached, throw the established internal storage error instead of continuing to relist indefinitely; preserve the existing successful completion and truncated-listing behavior.packages/db/tests/schema/organization-cascade.test.ts (1)
33-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMake the failure message identify the offending tables.
toEqual([])prints the whole row objects on failure, but the count assertiontoBeGreaterThan(30)gives no context when a new table is added without the cascade. Consider asserting on a mapped list of table names so a failure names the table directly.♻️ Proposed clearer assertion
- expect(rows.length).toBeGreaterThan(30); - expect( - rows.filter((row) => row.referencedTable !== 'organization' || row.deleteAction !== 'c'), - ).toEqual([]); + expect(rows.length).toBeGreaterThan(30); + expect( + rows + .filter((row) => row.referencedTable !== 'organization' || row.deleteAction !== 'c') + .map((row) => row.tableName), + ).toEqual([]);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/db/tests/schema/organization-cascade.test.ts` around lines 33 - 36, Update the cascade validation assertion around the rows filtering in the organization cascade test to map offending rows to their table-name field before asserting emptiness, so failures identify the tables lacking the expected cascade. Keep the existing row filter and count assertion behavior unchanged.apps/web/tests/lib/realtime/provider.test.ts (1)
156-164: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThe fixed microtask tick count makes this test brittle.
handleTerminalClosestarts recovery without returning the promise, so the test drains it with threeawait Promise.resolve()calls. The count matches the current number of awaits insiderecoverWorkspaceAfterForbidden. If an await is added or removed in the implementation, this test fails without a behavior change, or asserts before recovery completes.Let the gate signal completion instead of counting ticks.
♻️ Proposed refactor
- handleTerminalClose(ORGANIZATION_FORBIDDEN_CLOSE_CODE, session.gate, workspace.gate); - await Promise.resolve(); - await Promise.resolve(); - await Promise.resolve(); + const activated = new Promise<void>((resolve) => { + settle = resolve; + }); + handleTerminalClose(ORGANIZATION_FORBIDDEN_CLOSE_CODE, session.gate, workspace.gate); + await activated;
workspaceGateReturningcan callsettleat the end ofsetActive.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/tests/lib/realtime/provider.test.ts` around lines 156 - 164, Replace the three fixed Promise.resolve microtask waits in the terminal-close test with completion signaling through workspaceGateReturning: have its setActive implementation invoke settle after recovery-related updates finish, then await that gate before asserting workspace.calls, location.href, and session.calls.apps/web/src/lib/realtime/provider.tsx (1)
40-40: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
z.looseObject()instead of.passthrough().This repo uses Zod 4.4.3, where
.passthrough()is legacy; replace it with the top-level constructor so the same change later avoids a deprecation warning.♻️ Proposed refactor
-const activationSchema = z.object({ error: z.unknown().optional() }).passthrough(); +const activationSchema = z.looseObject({ error: z.unknown().optional() });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/realtime/provider.tsx` at line 40, Update the activationSchema declaration to use Zod’s z.looseObject() constructor instead of chaining .passthrough(), preserving the existing error field and acceptance of unknown properties.packages/core/tests/content/attachment-service.test.ts (1)
86-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winScope the lock probe to the organization row to avoid a false positive.
waitForDatabaseLockcounts every backend in the current database that waits on any lock. Bun runs test files concurrently, so an unrelated concurrent test that waits on a lock satisfies the probe. The assertionexpect(first).toBe('lock')at Line 354 then passes even whenregisterUploaddid not wait for the organization row. Filter by the blocked relation, or by the pid that this connection blocks, so the probe proves the intended wait.♻️ Proposed narrowing with `pg_blocking_pids`
-async function waitForDatabaseLock(client: ReturnType<typeof postgres>): Promise<void> { - const deadline = Date.now() + 5_000; - while (Date.now() < deadline) { - const rows = await client<{ waiting: number }[]>` - select count(*)::int as waiting - from pg_stat_activity - where datname = current_database() - and pid <> pg_backend_pid() - and wait_event_type = 'Lock' - `; - if ((rows[0]?.waiting ?? 0) > 0) return; - await pause(10); - } - throw new Error('The upload did not wait for the organization row lock.'); -} +async function waitForDatabaseLock(client: ReturnType<typeof postgres>): Promise<void> { + const deadline = Date.now() + 5_000; + while (Date.now() < deadline) { + const rows = await client<{ waiting: number }[]>` + select count(*)::int as waiting + from pg_stat_activity + where datname = current_database() + and pid <> pg_backend_pid() + and wait_event_type = 'Lock' + and pg_backend_pid() = any(pg_blocking_pids(pid)) + `; + if ((rows[0]?.waiting ?? 0) > 0) return; + await pause(10); + } + throw new Error('The upload did not wait for the organization row lock.'); +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/tests/content/attachment-service.test.ts` around lines 86 - 100, Update waitForDatabaseLock to detect only lock waits caused by the organization-row lock, rather than counting all locks in the current database. Narrow the pg_stat_activity query using the relevant blocked relation or pg_blocking_pids for the connection holding that organization lock, while preserving the existing timeout and success behavior used by the assertion around registerUpload.packages/core/tests/org/organization-deletion-service.test.ts (2)
25-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winImport the deletion service directly instead of casting the module namespace.
Lines 48-61 assert a structure onto
coreand Lines 25-46 re-declareDeletionSummaryandDeletionResultlocally. The cast makes the test compile even ifdeleteOrganizationorgetOrganizationDeletionSummaryis removed, renamed, or given a different signature; the break then surfaces as a runtime failure rather than a typecheck failure. The service is already re-exported frompackages/core/src/index.ts, and every other test in this file imports its subject directly (registerUpload,createDoc,createIssue). Import the two functions and their result types from the service module so the compiler checks the contract.♻️ Proposed direct import
-import * as core from '../../src/index.ts'; +import { + deleteOrganization, + getOrganizationDeletionSummary, +} from '../../src/org/organization-deletion-service.ts';-const expectedCore = core as typeof core & { - readonly getOrganizationDeletionSummary: ( - principal: Principal, - driver: StorageDriver, - now?: Date, - ) => Promise<DeletionSummary>; - readonly deleteOrganization: ( - principal: Principal, - input: unknown, - driver: StorageDriver, - now?: Date, - ) => Promise<DeletionResult>; -}; -const { deleteOrganization, getOrganizationDeletionSummary } = expectedCore; const deletionDrainMilliseconds = (UPLOAD_URL_TTL_SECONDS + UPLOAD_COMPLETION_GRACE_SECONDS) * 1000;Remove the local
DeletionSummaryandDeletionResultinterfaces and use the types the service exports. ThePrincipalimport then becomes unused.As per coding guidelines: "Use strict TypeScript; avoid
anyand non-null assertions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/tests/org/organization-deletion-service.test.ts` around lines 25 - 61, Replace the `expectedCore` namespace cast and local `DeletionSummary`/`DeletionResult` interfaces with direct imports of `deleteOrganization`, `getOrganizationDeletionSummary`, and their exported result types from the deletion service module (via the existing public export). Update the test references to use those imports directly and remove the now-unused `Principal` import, preserving strict type checking without `any` or non-null assertions.Source: Coding guidelines
144-170: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the shared database-lock test helpers. Both files define identical
databaseUrl,pause, andwaitForDatagbaseLockhelpers; only the thrown message differs. The shared root cause is a missing test-support helper for lock-wait probing, so a future fix to the probe query must be applied twice.
packages/core/tests/org/organization-deletion-service.test.ts#L144-L170: movedatabaseUrl,pause, andwaitForDatabaseLockinto the shared test-support module and accept the failure message as a parameter, then import them here.packages/core/tests/content/attachment-service.test.ts#L74-L100: delete the local copies and import the shared helpers, passing the upload-specific failure message.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/tests/org/organization-deletion-service.test.ts` around lines 144 - 170, Extract the duplicate databaseUrl, pause, and waitForDatabaseLock helpers from packages/core/tests/org/organization-deletion-service.test.ts#L144-L170 and packages/core/tests/content/attachment-service.test.ts#L74-L100 into the shared test-support module, adding a failure-message parameter to waitForDatabaseLock. Remove both local helper copies, import the shared helpers in each test, and pass the organization-deletion and upload-specific failure messages respectively.packages/core/tests/org/organization-service.test.ts (1)
116-121: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueGenerate the member id with
newId().Line 117 hardcodes
'member_pending_workspace'. Every other record in this suite uses the generated-id convention. UsenewId()so the insert cannot collide if the row survives a reset or if the case is duplicated.♻️ Proposed fix
await db.insert(schema.member).values({ - id: 'member_pending_workspace', + id: newId(), organizationId: deleting.organization.id, userId: member.id, role: 'member', });Based on learnings: "Within packages/core, use the established newId() convention for generating IDs for newly added records."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/tests/org/organization-service.test.ts` around lines 116 - 121, Replace the hardcoded id in the member insert with a generated id from newId(), following the existing convention in this test suite and preserving the rest of the member record unchanged.Source: Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/features/settings/workspace-danger-zone.tsx`:
- Around line 19-44: Move deletionSummarySchema, summaryResponseSchema, and
deletionResponseSchema into `@orbit/shared`, exporting their inferred types
alongside the schemas. Remove the client-local definitions and import the shared
schemas and types in this component and the corresponding deletion route
handler, ensuring both continue parsing the same API payloads.
In `@docs/superpowers/plans/2026-08-08-workspace-deletion.md`:
- Line 31: Update the migration references in the workspace deletion plan’s Task
2 to use the checked-in 0002_glossy_mister_sinister migration and matching
journal entry instead of the 0001_*.sql placeholder, ensuring the plan does not
instruct creation of a duplicate or out-of-order migration.
- Around line 360-368: The deletion flow currently performs storage cleanup
inside the database transaction. Update
docs/superpowers/plans/2026-08-08-workspace-deletion.md:360-368 and
docs/superpowers/specs/2026-08-08-workspace-deletion-design.md:75-81 so the
durable deletion marker is committed first, paginated or bounded
driver.deletePrefix cleanup runs outside the transaction, and a short final
transaction removes the organization and related database state.
- Line 3: Remove the agentic workflow instruction line from the plan document,
including its references to “agentic workers” and superpowers skills. Leave the
remaining implementation plan and task-tracking steps unchanged.
In `@packages/core/src/org/organization-deletion-service.ts`:
- Around line 229-250: The organization storage cleanup currently runs inside
the transaction; restructure the deletion flow around the transaction callback
so the database deletion commits before invoking driver.deletePrefix. Preserve
the persisted deletionRequestedAt state and use it to make storage cleanup
retryable after commit, including when cleanup or commit fails, while keeping
the existing organization-selection and session-update behavior in the
transaction.
In `@packages/core/tests/org/member-service.test.ts`:
- Around line 51-59: Ensure the shared workspace organization’s
deletionRequestedAt state is isolated for both pending-deletion tests: in
packages/core/tests/org/member-service.test.ts:51-59 and
packages/core/tests/content/doc-service.test.ts:297-309, confirm the workspace
is reseeded per test through resetDatabase or clear deletionRequestedAt to null
after the test; apply the appropriate cleanup at both sites so later tests using
resolvePrincipal, getPublishedDoc, or listPublicDocs retain access.
In `@packages/services/src/storage/s3.ts`:
- Around line 160-168: Update both inventory loops to reject empty continuation
markers as well as undefined values when the response is truncated. In the S3
object listing flow, validate NextContinuationToken before assigning
continuationToken; apply equivalent non-empty validation to NextKeyMarker and
NextVersionIdMarker in the versioned listing flow, preserving the existing
incomplete-listing error behavior.
---
Nitpick comments:
In `@apps/web/src/lib/realtime/provider.tsx`:
- Line 40: Update the activationSchema declaration to use Zod’s z.looseObject()
constructor instead of chaining .passthrough(), preserving the existing error
field and acceptance of unknown properties.
In `@apps/web/tests/features/settings/workspace-danger-zone.test.tsx`:
- Around line 98-102: Add a surrounding-whitespace assertion to the confirmation
test near the existing case-sensitivity checks: verify that values such as “
Nova ” remain disabled, preserving the exact-match requirement and ensuring
trimming the component input would fail the test.
In `@apps/web/tests/lib/realtime/provider.test.ts`:
- Around line 156-164: Replace the three fixed Promise.resolve microtask waits
in the terminal-close test with completion signaling through
workspaceGateReturning: have its setActive implementation invoke settle after
recovery-related updates finish, then await that gate before asserting
workspace.calls, location.href, and session.calls.
In `@packages/core/tests/content/attachment-service.test.ts`:
- Around line 86-100: Update waitForDatabaseLock to detect only lock waits
caused by the organization-row lock, rather than counting all locks in the
current database. Narrow the pg_stat_activity query using the relevant blocked
relation or pg_blocking_pids for the connection holding that organization lock,
while preserving the existing timeout and success behavior used by the assertion
around registerUpload.
In `@packages/core/tests/org/organization-deletion-service.test.ts`:
- Around line 25-61: Replace the `expectedCore` namespace cast and local
`DeletionSummary`/`DeletionResult` interfaces with direct imports of
`deleteOrganization`, `getOrganizationDeletionSummary`, and their exported
result types from the deletion service module (via the existing public export).
Update the test references to use those imports directly and remove the
now-unused `Principal` import, preserving strict type checking without `any` or
non-null assertions.
- Around line 144-170: Extract the duplicate databaseUrl, pause, and
waitForDatabaseLock helpers from
packages/core/tests/org/organization-deletion-service.test.ts#L144-L170 and
packages/core/tests/content/attachment-service.test.ts#L74-L100 into the shared
test-support module, adding a failure-message parameter to waitForDatabaseLock.
Remove both local helper copies, import the shared helpers in each test, and
pass the organization-deletion and upload-specific failure messages
respectively.
In `@packages/core/tests/org/organization-service.test.ts`:
- Around line 116-121: Replace the hardcoded id in the member insert with a
generated id from newId(), following the existing convention in this test suite
and preserving the rest of the member record unchanged.
In `@packages/db/tests/schema/organization-cascade.test.ts`:
- Around line 33-36: Update the cascade validation assertion around the rows
filtering in the organization cascade test to map offending rows to their
table-name field before asserting emptiness, so failures identify the tables
lacking the expected cascade. Keep the existing row filter and count assertion
behavior unchanged.
In `@packages/services/src/storage/s3.ts`:
- Around line 252-304: Bound the retry loops in deleteCurrentObjects and
deleteVersionedObjects with a maximum iteration count. Increment the count for
each list/delete cycle, and when the limit is reached, throw the established
internal storage error instead of continuing to relist indefinitely; preserve
the existing successful completion and truncated-listing behavior.
In `@packages/services/tests/storage/storage-prefix.test.ts`:
- Around line 11-16: Remove the expectedStorage cast and import assertSafePrefix
and storagePrefixFor as direct named imports from their defining module or the
storage index. Update their usage to reference the named imports while retaining
the S3StorageDriver import, so TypeScript verifies that both helpers are
actually exported.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2bdc3189-e68e-4d9d-981a-99bbd3327eaf
📒 Files selected for processing (64)
apps/web/src/app/(app)/layout.tsxapps/web/src/app/(app)/settings/general/page.tsxapps/web/src/app/api/organizations/current/deletion/route.tsapps/web/src/app/invite/[token]/page.tsxapps/web/src/features/settings/workspace-danger-zone.tsxapps/web/src/lib/api/handler.tsapps/web/src/lib/auth/principal.tsapps/web/src/lib/realtime/provider.tsxapps/web/tests-support-issue-routes.tsapps/web/tests/app/(app)/layout.test.tsxapps/web/tests/app/api/docs/duplicate.test.tsapps/web/tests/app/api/docs/home.test.tsapps/web/tests/app/api/issues/delete-issue.test.tsapps/web/tests/app/api/organizations/current/deletion/route.test.tsapps/web/tests/app/settings/general/page.test.tsxapps/web/tests/features/settings/workspace-danger-zone.test.tsxapps/web/tests/lib/auth/principal.test.tsapps/web/tests/lib/realtime/provider.test.tsdocs/configuration.mddocs/self-hosting.mddocs/superpowers/plans/2026-08-08-workspace-deletion.mddocs/superpowers/specs/2026-08-08-workspace-deletion-design.mdpackages/core/src/content/attachment-service.tspackages/core/src/content/doc-service.tspackages/core/src/index.tspackages/core/src/org/invite-service.tspackages/core/src/org/member-service.tspackages/core/src/org/organization-deletion-service.tspackages/core/src/org/organization-lock.tspackages/core/src/org/organization-service.tspackages/core/src/realtime/publisher.tspackages/core/tests/content/attachment-service.test.tspackages/core/tests/content/doc-service.test.tspackages/core/tests/org/invite-service.test.tspackages/core/tests/org/member-service.test.tspackages/core/tests/org/organization-deletion-service.test.tspackages/core/tests/org/organization-service.test.tspackages/core/tests/realtime/publisher.test.tspackages/db/drizzle/0002_glossy_mister_sinister.sqlpackages/db/drizzle/meta/0002_snapshot.jsonpackages/db/drizzle/meta/_journal.jsonpackages/db/src/schema/content.tspackages/db/src/schema/org.tspackages/db/tests/apply-catchup.test.tspackages/db/tests/schema/index.test.tspackages/db/tests/schema/organization-cascade.test.tspackages/mcp-server/tests/auth.test.tspackages/realtime-server/src/auth.tspackages/realtime-server/src/hub.tspackages/realtime-server/tests/auth/authorize-scope.test.tspackages/realtime-server/tests/hub.test.tspackages/services/src/storage/index.tspackages/services/src/storage/key.tspackages/services/src/storage/parent.tspackages/services/src/storage/s3.tspackages/services/src/storage/types.tspackages/services/tests/storage/parent.test.tspackages/services/tests/storage/storage-prefix.test.tspackages/shared/src/events/control.tspackages/shared/src/policy/index.tspackages/shared/src/validators/organization.tspackages/shared/tests/events/control.test.tspackages/shared/tests/policy/policy.test.tspackages/shared/tests/validators/organization.test.ts
eb76ef7 to
e71fdc8
Compare
Review loop 3I reviewed the complete PR again after the prior two review and fix loops. Seven findings were evaluated:
Fresh verification after all fixes:
All seven threads have been answered and resolved. No deployed workspace was deleted or modified by this PR. |
Summary
Safety and authorization
org:deleteonly to workspace administratorsorganization.deletion_requested_at, which blocks normal web, realtime, MCP, upload, invite, public-doc, and public-attachment accessData and storage cleanup
organization_idforeign key to cascade fromorganization.id<organizationId>/prefix, bounded batches, current objects, historical versions, and delete markersMigration and deployment
mainmigration as0001and add this feature as migration0002attachment.upload_expires_atwith a conservative rolling-deploy default and backfillorganization.deletion_requested_atfor durable, fail-closed retriess3:ListBucketVersionsands3:DeleteObjectVersionin addition to existing list and delete permissionsVerification
ORBIT_TEST_LANE=workspace_deletion_final10 bun run verifyNotes
This PR adds the deletion capability only. It does not invoke deletion against any deployed workspace, and it does not modify the protected
noveum.aiorganization.