Repository navigation
feat(retention): purge hook for runtime extensions and organization file sweep - #472
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
purgeOrganization(slice 1, #471) deletes an organization's rows and the files its rows point at. A distribution that keeps its own tables referencing the organization or its users has no way to delete them in the same transaction, so the purge would hit a foreign key. Files stored before any row pointed at them (an interrupted render) are never found. And the purge isn't exported, so the hosted product can't call it.Change
RuntimeExtension.onOrganizationPurge(tx, { organizationId, userIds })runs inside the purge transaction, after the organization row is locked and before its rows and users are deleted.userIdsare the sole-member users that are about to be deleted.txis narrowed to$queryRaw/$executeRaw, the same narrowing the seller VAT confirmation hook uses. If the hook throws, the whole purge rolls back. Self-hosted installs register no extension, so nothing changes for them.DocumentArtifactStore.deleteOrganization(organizationId).purgeOrganizationcalls it after the ref-based deletes. The disk store removes the<root>/<organizationId>/directory. Refs are<organizationId>/<kind>/<documentId>/<hash>.<ext>, and ids are limited to[a-zA-Z0-9_-]+, which the store already enforced onputand now shares with the sweep. So the sweep removes exactly one path segment and can't reachorg-12when purgingorg-1. It also refuses..,/and empty ids.@quits/oss/organization-purgeexportspurgeOrganization,deleteOrganizationRows,OrganizationPurgeResultand the hook types. The packed-artifact check already imports every export key.Where this sits in QUI-252 (9 slices)
Linear
Refs QUI-252
Verification
vp test run -c vitest.integration.config.ts src/domain/__tests__/organization-purge.integration.test.ts src/trpc/routers/__tests__/onboarding-v2-export.integration.test.ts: 7 passed against a fresh PostgreSQL with the CI auth env. This covers:vp test run -c vitest.config.ts src/selfhost src/lib/runtime: 13 passed, including the new disk-store test. That test covers prefix-sharing ids (org-12,org-1_x,org), repeated and empty sweeps, and rejected ids.vp lint --deny-warningson the changed files: clean.bun run typecheck:app: clean.Risk
purgeOrganizationyet.New optional members on two public types, plus a new export subpath. These are additive, so existing implementations keep compiling.