Skip to content

feat(retention): read the prune windows from config and preview them - #977

Open
HugoXK wants to merge 1 commit into
mainfrom
dev3/281-retention-windows
Open

HugoXK wants to merge 1 commit into
mainfrom
dev3/281-retention-windows

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-3

Fixes #281

Every age window pruneOldData enforced was a literal inside one function, so no deployment could read, change or preview one without a code change and a release. The windows now live in scripts/lib/retention.mjs with today's number as the effective default; loadConfig builds config.retention.windows from RETENTION_*_DAYS, where unset means the shipped default rather than "keep forever"; pruneOldData takes the windows and keeps every predicate. The new read-only scripts/retention.mjs --dry-run --days N counts what a window would delete through the same predicate, and /admin gains a read-only Data retention card with the effective window, a default mark and the current count. Sessions (expiry-based) and API tokens (no age window) are named instead of guessed. No default value changed and no new delete path exists.

Branch pushed by the Lead: dev3/281-retention-windows fast-forwarded from 4cfe2986 to e01b05ac20097723dcc8604c8e482d124414cd95 with no force and no rewrite, so the sha the author built and tested is the sha on the remote. Tree 959535f060258b71a87a186ee71f16f87a5669c6, parent 4cfe2986f6df01ac77af0eee54eddd67820d8cf8; both read back from the API after the push. The branch is one commit behind main (c3d16bbc51bc04e0fc405f1f4e6c0e7bc1868439); the author's three-way merge against that tip shows 0 conflicts in every file both sides touch (src/db.ts, src/jobs/service.ts, docs/architecture.md) and npm run check green on the merged tree.

Large-PR: 15 files, 812 changed lines — one design change (the 13 age windows move from literals into scripts/lib/retention.mjs and config.retention), plus its read-only preview script, its read-only /admin card, the docs and one test file. It is one slice, not several features; the line count is the 13 windows and their fixture rows.

Ran (author, at the tip above):

  • red at base 4cfe2986 with only test/retention.test.ts added — 0 pass / 7 fail of 7
  • npm run check at tree 959535f0 — exit 0, 2615/2615
  • npx tsx --test test/retention.test.ts — 7/7
  • node scripts/risk-gate.mjs --base 4cfe2986 — T3, basis scripts/lib/retention.d.mts

Not run: a live deployment or a production database; the counts are exercised on seeded SQLite fixtures, including a no-row-deleted assertion.

Risk: T3 (scripts/**, src/config.ts, src/db.ts, src/app.ts, src/jobs/service.ts).
Rollback: revert the squash commit; the windows fall back to the literals and /admin loses the card. No data is migrated by this change.
Docs: docs/architecture.md, docs/deploy.md, docs/security.md, .env.example.
Changelog: changelog.d/281.added.md.

…281)

Every age window `pruneOldData` enforced was a literal inside one function, so
no deployment could read, change or preview one without a code change and a
release. The windows now live in `scripts/lib/retention.mjs` with today's number
as the effective default; `loadConfig` builds `config.retention.windows` from
`RETENTION_*_DAYS`, where unset means the shipped default rather than "keep
forever"; `pruneOldData` takes the windows and keeps every predicate. The new
read-only `scripts/retention.mjs --dry-run --days N` counts what a window would
delete through the same predicate, and `/admin` gains a read-only Data retention
card with the effective window, a `default` mark and the current count. Sessions
(expiry-based) and API tokens (no age window) are named instead of guessed.

Docs: docs/architecture.md, docs/deploy.md, docs/security.md, .env.example.

Written-by: Fledge Platform Dev-3

This branch has not been deployed

No deployments
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.

feat: define data retention, account deletion and user export

1 participant