|
| 1 | +--- |
| 2 | +status: in-progress |
| 3 | +depends: [scheduled-spam-purge] |
| 4 | +specs: |
| 5 | + - specs/behaviors/person-lifecycle.md |
| 6 | + - specs/api/moderation.md |
| 7 | +issues: [] |
| 8 | +--- |
| 9 | + |
| 10 | +# Plan: Gate the scheduled purge to production; purge private data too |
| 11 | + |
| 12 | +## Scope |
| 13 | + |
| 14 | +v0.10.2 shipped the scheduled spam purge early (2026-10-15). The sandbox ran |
| 15 | +the sweep against `published`, which it shares with production, and purged |
| 16 | +27 spam-voted accounts there. The accounts were the right ones, but two |
| 17 | +flaws showed: every pod runs the sweep, and purge never touched the private |
| 18 | +store, so purged people's private profiles stayed behind. |
| 19 | + |
| 20 | +**In:** `CFP_SCHEDULED_PURGE` (default off; on only in cfp-live-cluster), and |
| 21 | +a pod with it off never sweeps and says so at boot; Purge (button and sweep) |
| 22 | +deletes private profile, legacy password, reset tokens, claim requests and |
| 23 | +session metadata in the same transaction; `POST |
| 24 | +/api/admin/private-data/purge-orphans` (admin, `apply` false/true, counts |
| 25 | +only) for private data left by earlier purges and prunes. |
| 26 | + |
| 27 | +**Out:** an out-of-process script for the cleanup (the API's in-memory |
| 28 | +private store would write the old data back). |
| 29 | + |
| 30 | +## Implements |
| 31 | + |
| 32 | +- [behaviors/person-lifecycle.md](../specs/behaviors/person-lifecycle.md#purge-cascading-hard-delete-admin-only) |
| 33 | +- [api/moderation.md](../specs/api/moderation.md#post-apiadminprivate-datapurge-orphans) |
| 34 | +- docs/operations/deploy.md (env table), runbook.md. |
| 35 | + |
| 36 | +## Approach |
| 37 | + |
| 38 | +1. `PrivateStoreTx.deletePersonData(personId)`, staged by `store.transact` |
| 39 | + like the other private writes; `purgePeople` calls it per person. |
| 40 | +2. `SessionMetadataStore.removeAllFor(personId)` after the commit. |
| 41 | +3. `scheduledPurgeEnabled(config)` gates the plugin. |
| 42 | +4. The orphan cleanup runs under `publicRepo.withLock`, so a sign-up that |
| 43 | + has written its private profile but not its public record is never |
| 44 | + counted. |
| 45 | + |
| 46 | +## Validation |
| 47 | + |
| 48 | +- [ ] `npm run type-check && npm run lint && npm test` clean. |
| 49 | +- [ ] Tests: the gate; `deletePersonData` persisted to disk, other people |
| 50 | + untouched; Purge deletes the private profile; the cleanup is |
| 51 | + admin-only, counts without emails, deletes on `apply`, then counts 0. |
| 52 | + |
| 53 | +## Risks / unknowns |
| 54 | + |
| 55 | +- `apply: true` can't be undone; the runbook says to count first. |
| 56 | + |
| 57 | +## Notes |
| 58 | + |
| 59 | +## Follow-ups |
0 commit comments