diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md
index 678369f..b81a862 100644
--- a/docs/agent/AGENT.md
+++ b/docs/agent/AGENT.md
@@ -1058,6 +1058,7 @@ Example `styles.css`: [section-code.md](./skills/iapl-block/resources/section-co
| animations | `transform` / `opacity` only, the token durations (`duration-fast`, reduced motion built in) or `motion-reduce:`; IntersectionObserver for "is it on screen" | animating `height` / `top` / `margin`, `transition-all`, a `scroll` listener doing work per event |
| client components | small, interaction only (§6.9); import from `@intecion/ipal-kit/client` freely — a page ships only what it renders (1.18.0) | a whole section `'use client'` |
| data | the cached helpers of `lib/content` (`getSettings`, `resolveRoute`, `getSiteShell`…), `depth` as low as the page needs, `select` when you need one field, `cache()` around your own getters | `findGlobal` in a component without `cache()`, `depth: 2` "to be safe", a query per list item |
+| what grows | logs with a retention (consent log 1095 days, statistics 90; `forms: { submissionRetentionDays }` on the client's decision), `versions: { maxPerDoc: 20 }` where you turn versions on, unused media reviewed; `iapl-doctor --deep --only growth` ([performance.md](../performance.md) §6) | `maxPerDoc: 0`, submissions kept forever without a decision, a persistent volume on `.next` |
| budgets | `e2e/performance.spec.ts` from the `iapl-performance` skill (`perfBudgets()` from `/doctor`): fails when a page gets slower | "it felt fast on my machine" |
Target on the built site (mobile, Lighthouse/PageSpeed): LCP < 2.5 s, CLS < 0.1, INP < 200 ms — the plugin's default
@@ -1562,6 +1563,7 @@ bash .agents/skills/iapl-audit/scripts/audit.sh
pnpm exec iapl-doctor # + --deep --url http://localhost:3000 on the built site
node .agents/skills/iapl-seo-check/scripts/seo-check.mjs http://localhost:3000
pnpm test:e2e e2e/performance.spec # the budget gate (iapl-performance) on the built site
+pnpm exec iapl-doctor --deep --only growth # what grows: sizes, versions, retention, old submissions, unused media
pnpm generate:types && pnpm tsc --noEmit
pnpm build # --webpack in the script; locally, not only dev
# hardcoding and the field zoo in blocks
diff --git a/docs/agent/skills/iapl-performance/SKILL.md b/docs/agent/skills/iapl-performance/SKILL.md
index d7b9230..e4233b5 100644
--- a/docs/agent/skills/iapl-performance/SKILL.md
+++ b/docs/agent/skills/iapl-performance/SKILL.md
@@ -1,6 +1,6 @@
---
name: iapl-performance
-description: Makes and keeps an IAPL site fast — page loading (LCP image, fonts, nothing render-blocking, static rendering), elements (lazy below the fold, reserved space, click-to-load embeds), animations (transform/opacity, reduced motion, no scroll handlers), resources (only the JS a page uses, compression, no third-party request before consent), images (AVIF/WebP, sizes, upload limits) and the server (queries per render, depth, select, caching). Measures the built site, runs the doctor's performance group, and adds the budget gate that fails when a change makes the site slower. Use when building pages or blocks, before handing over, after an IAPL upgrade, and whenever "slow", PageSpeed, Lighthouse, Core Web Vitals, LCP, CLS or INP come up.
+description: Makes and keeps an IAPL site fast — page loading (LCP image, fonts, nothing render-blocking, static rendering), elements (lazy below the fold, reserved space, click-to-load embeds), animations (transform/opacity, reduced motion, no scroll handlers), resources (only the JS a page uses, compression, no third-party request before consent), images (AVIF/WebP, sizes, upload limits) and the server (queries per render, depth, select, caching); what grows in the database and on disk over the years (logs and their retention, form submissions, versions, KV, unused media, the image cache). Measures the built site, runs the doctor's performance group, and adds the budget gate that fails when a change makes the site slower. Use when building pages or blocks, before handing over, after an IAPL upgrade, and whenever "slow", PageSpeed, Lighthouse, Core Web Vitals, LCP, CLS, INP, a growing database or disk come up.
---
# iapl-performance
@@ -48,7 +48,19 @@ a change makes a page slower. PageSpeed Insights on the deployed site shows the
- **Queries per render** (the reference gate counts them): over 30 for an ordinary page → a missing `cache()`, a
`depth` too high, or a loop of `findByID`.
-## 4. Before "done"
+## 4. What grows (performance.md §6)
+```bash
+pnpm exec iapl-doctor --deep --only growth # counts and sizes per collection, oldest records, versions, expired KV, unused media, disk
+```
+- Logs purge themselves (consent log 1095 days, statistics 90). Form submissions are kept unless
+ `iapl({ forms: { submissionRetentionDays } })` — ask the client (personal data) and record it in AGENTS.md.
+- Versions: where you turn them on, `versions: { maxPerDoc: 20 }` (globals `max`); never `0`.
+- Unused media (`growth-media`): list them for the client; the plugin never deletes media or submissions by itself.
+- Coolify: no persistent volume on `.next` (the image cache starts empty on each deploy); database backups on the
+ MongoDB resource.
+- Thresholds of the findings: `iapl-doctor.json` → `growth`.
+
+## 5. Before "done"
`iapl-doctor --only performance` without warnings (or each one silenced with a reason in `iapl-doctor.json`),
the budget test green, and the numbers in `AGENTS.md` → "Project decisions" when the client accepted an exception
(a heavy font, a third-party widget).
diff --git a/docs/agent/skills/iapl-reference/SKILL.md b/docs/agent/skills/iapl-reference/SKILL.md
index f4b89a6..d7b08fc 100644
--- a/docs/agent/skills/iapl-reference/SKILL.md
+++ b/docs/agent/skills/iapl-reference/SKILL.md
@@ -215,6 +215,7 @@ Mandatory set: AGENT.md §0b, skill **iapl-setup**; checks: **iapl-audit**, **ia
| storage | `payload.config.ts` | `buildR2Storage(['media'], { s3Storage })` — always (without `R2_*` = local disk) | upload → URL from `R2_PUBLIC_URL` | storage.md |
| e-mail | `payload.config.ts` | `email: mailAdapter()` (SMTP from the panel / Graph from env; also `panelSmtpAdapter`, `graphAdapter`, `sendEmail` from `/server`) | Site integrations → E-mail sending → **Send test** | email.md |
| forms — action | `app/(frontend)/[locale]/actions.ts` | `'use server'`; `export const sendForm = createSubmitAction({ getCachedPayload, headers })` (`/server`) | submit → document in Form Submissions + e-mails | forms.md, skill **iapl-form** |
+| forms — retention | config (client decision) | `forms: { submissionRetentionDays: 365 }` (1.18.0; default: kept) | `iapl-doctor --deep --only growth-submissions` quiet; old submissions gone a day after the next submission | performance.md §6, forms.md |
| forms — files | config + panel | `forms: { attachments: true }`; a **File** field on the form; an e-mail with fixed recipients in Forms → E-mails; `mailAdapter({ graph: { largeAttachments } })` when Graph must stay under 3 MB; Azure: `Mail.ReadWrite` limited to the forms mailbox for files of 3 MB and more over Graph | Test e-mail with "Attach a 10 MB test file" arrives; a submission with a PDF arrives with the attachment; nothing in Media | forms.md "Files", email.md "Attachments" |
| forms — render | form block | `` (`/rsc`) | form from the panel, Turnstile, message from Notifications | forms.md |
| Turnstile | panel / env | `SiteProviders` wires `TurnstileProvider`; keys in Site integrations → Spam protection or env; server: `verifyTurnstile` (`/server`) | widget in the form; dashboard alert on a bad key | turnstile.md |
diff --git a/docs/agent/skills/iapl-reference/resources/api.md b/docs/agent/skills/iapl-reference/resources/api.md
index 8e28407..ff3c531 100644
--- a/docs/agent/skills/iapl-reference/resources/api.md
+++ b/docs/agent/skills/iapl-reference/resources/api.md
@@ -452,7 +452,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
| Export | Import from | What it does / when |
|---|---|---|
| `createSubmitAction({ getCachedPayload, headers, … })` | `@intecion/ipal-kit/server` | Creates the server action `sendForm(formId, locale, values, token?)`: honeypot → `clientIp` → `submitForm` → text from Notifications; returns `SubmitActionResult`. Standard: `export const sendForm = createSubmitAction({ getCachedPayload, headers })` in `actions.ts` |
-| `submitForm({ payload, formId, data, files?, attemptKey?, turnstileToken?, ip?, locale?, maxPerMinute?, consentFieldName?, turnstileHostnames? })` | `@intecion/ipal-kit/server` | Server core (`consentFieldName`: argument → `iapl({ forms: { consentFieldName } })` → `'consent'`; `turnstileHostnames` rejects a token solved on another domain): rate limit → Turnstile → validation against the panel definition (+ GDPR consent) → saves the submission; returns a `SubmitFormResult` code, not text. Usually through `createSubmitAction`; server-only |
+| `submitForm({ payload, formId, data, files?, attemptKey?, turnstileToken?, ip?, locale?, maxPerMinute?, consentFieldName?, turnstileHostnames? })` | `@intecion/ipal-kit/server` | Server core (`consentFieldName`: argument → `iapl({ forms: { consentFieldName } })` → `'consent'`; `turnstileHostnames` rejects a token solved on another domain): rate limit → Turnstile → validation against the panel definition (+ GDPR consent) → saves the submission (and, with `forms.submissionRetentionDays`, deletes older ones at most once a day); returns a `SubmitFormResult` code, not text. Usually through `createSubmitAction`; server-only |
### Honeypot
@@ -878,6 +878,7 @@ Bin: `iapl-doctor` (`pnpm exec iapl-doctor [dir] [--json] [--md] [--strict] [--f
| `runDeepProbe(ctx)` | `@intecion/ipal-kit/doctor` | `pnpm exec payload run …/dist/modules/doctor/probe.js` in the project → `DoctorStatus`. |
| `collectDoctorStatus(payload)` | `@intecion/ipal-kit/doctor` | Read-only counts: `usersWithout2fa`, `pendingCookies`, `media` (images over `IMAGE_RULES`, 1.18.0), `plugin`, `node`. |
| `PERF_BUDGETS`, `SERVER_BUDGET`, `perfBudgets(overrides)`, `overBudget(measured, budget)`, `IMAGE_RULES` | `@intecion/ipal-kit/doctor` | Performance budgets (1.18.0, performance.md): the defaults per profile (`mobile`, `desktop`: `lcp`, `cls`, `inp`, `tbt`, `jsBytes`, `cssBytes`, `fontBytes`, `requests`, `renderBlocking`, `thirdParty`) and per render (`queriesPerRender`); a project's own on top; the broken budgets of one measurement as lines (empty = within budget); the image limits (1.5 MB, 2560 px, AVIF/WebP). Types `PerfBudget`, `PerfMeasurement`, `PerfProfile`, `ServerBudget`. The gate: `iapl-performance/resources/performance.spec.template.ts` + `perf-lab.mjs`. |
+| `collectGrowth(payload)` → `GrowthStatus`, `growthRules`, `GROWTH_DEFAULTS`, `folderBytes(dir)` | `@intecion/ipal-kit/doctor` | What grows (1.18.0, performance.md §6): per collection documents, bytes (MongoDB) and the oldest record; versions per collection and global with their limit; `payload-kv` entries and expired ones; media no document points at (first 5000 documents) — counts only. The `growth` rules (`growth-size`, `-versions`, `-retention`, `-submissions`, `-kv`, `-media`, `-disk`) and their default thresholds (`iapl-doctor.json` → `growth`, type `GrowthThresholds`). |
| `performanceRules` | `@intecion/ipal-kit/doctor` | The doctor's `performance` group (`perf-images-config`, `perf-fonts`, `perf-render-blocking`, `perf-embeds`, `perf-animations`, `perf-budgets`, `perf-live`, `perf-images`) — part of `doctorRules`. |
| `buildDoctorEndpoint({ tokenVar, access })` | `@intecion/ipal-kit/doctor` | `GET /ipal/doctor` (`/api/ipal/doctor`): 404 until the token variable (default `IAPL_DOCTOR_TOKEN`, ≥ 32 chars) is set, Bearer token or `access`, rate-limited. Added by `iapl` unless `doctor: false`. |
| `jobsRunAccess({ secretVar? })` | `@intecion/ipal-kit` | The rule iapl puts on `jobs.access.run` when the project writes none: `cronSecretMatches(req, process.env[secretVar])` or an admin with the second factor. Reuse it in your own rule: `run: (a) => jobsRunAccess()(a) \|\| myCheck(a)`. Type `JobsRunAccessOptions`. |
diff --git a/docs/dev/perf/README.md b/docs/dev/perf/README.md
index 59673e4..dec6baf 100644
--- a/docs/dev/perf/README.md
+++ b/docs/dev/perf/README.md
@@ -140,9 +140,45 @@ the proxy does no database work; the 434 KB cookie database is loaded only by a
8. **Doctor performance rules: warnings now, errors later?** In 1.18.0 they warn (as asked); `perf-live`
uncompressed HTML and `perf-images` could become errors in 1.19.0.
+## Growth review (owner's addition, 2026-12-01): what swells the site and its database
+
+Measured on the reference site (MongoDB 7) after the full reference suite as traffic: 15 collections, the largest
+`pages` (15 × 9 KB); consent record 185 B, form submission 647 B, KV entry 371 B on average, plus 2–6 indexes per
+collection. `pnpm exec iapl-doctor --deep --only growth` on it: 2.6 s, two infos (3 submissions without a
+retention; 1 of 17 media unused — `logo-example-studio-1.webp`, a duplicate logo a test uploaded).
+
+| Store | Today (1.17.2 defaults) | file:line | 1.18.0 |
+|---|---|---|---|
+| consent-records | purged after 1095 days, once a day per process, only after a new record; one unbounded `deleteMany` | `consent/consentLog.ts:124,161`, `shared/purge.ts:16` | retention recorded for the doctor; `growth-retention` reports a purge that has not caught up |
+| stats-visits (opt-in) | purged after 90 days, same mechanism | `stats/endpoint.ts:53,153` | same |
+| form-submissions | **no retention, nothing deletes them**; files never stored | `forms/submitForm.ts:324` | opt-in `forms.submissionRetentionDays` (default: kept); `growth-submissions` |
+| payload-kv: mail-service nonces | expiry checked only on read: a nonce whose call-back never came stayed for good | `email/relay/store.ts:174` | expired nonces swept (once a day, at the next enrolment) |
+| payload-kv: 2FA counters, relay state | one per staff account / host; never deleted | `security/totp/verifyLimit.ts:84`, `relay/store.ts:114` | left alone: bounded; a sweep could race a live verify |
+| versions | the plugin turns none on; Payload keeps 100 per document / global | `payload/dist/collections/config/sanitize.js:172` | `growth-versions` (0 = unlimited, or over 50 000) |
+| cookie-review (opt-in) | upsert by name; `gone` rows kept | `consent/scanner/scan.ts:297` | documented |
+| payload-preferences / locked-documents / jobs | Payload cleans them; the plugin queues no jobs | — | — |
+| media | deleted with the document (disk and R2); nothing finds unused media | `storage/buildR2Storage.ts:140` | `growth-media` (counts, never deletes) |
+| `.next/cache/images` | 31-day TTL, no size cap | `storage/buildImagesConfig.ts:56` | `growth-disk` (info); Coolify: no volume on `.next` |
+| logs | the plugin writes no files | — | — |
+
+Postgres / SQLite: the same purges through Drizzle's `deleteMany`; no TTL indexes; sizes not read (counts only).
+
+### Growth — for the owner (yes / no)
+
+9. **A default retention for form submissions** (e.g. 365 days) on every site, existing ones included. Deletes
+ data on live sites on their next submission. Recommendation: no default; the agent asks the client
+ (`submissionRetentionDays`) and the doctor reports sites without one — or yes with 730 days and a loud upgrade note.
+10. **MongoDB TTL indexes** for the consent log and statistics (expire `createdAt` / `lastAt` after the retention),
+ so the purge runs even when no new record comes. Same records deleted as today, sooner on a quiet site; one index
+ build per site at start. Recommendation: yes for 1.19.0 (opt-out), Mongo only.
+11. **Delete `gone` cookie-review rows after a year.** Deletes the scanner's history. Recommendation: no.
+12. **A media clean-up action in the panel** (list the unused media, delete after confirmation). Recommendation:
+ yes, as a panel view — never automatic.
+13. **`maxPerDoc: 20`** in the reference and the starter wherever versions get turned on (none today). Recommendation: yes (no data deleted until a document is saved again).
+
### Shared with IAWL
-Proposed for both products (performance.md §6): the Core Web Vitals targets and the lab profile; JS ≤ 250 KB,
+Proposed for both products (performance.md §7): the Core Web Vitals targets and the lab profile; JS ≤ 250 KB,
CSS ≤ 50 KB, fonts ≤ 250 KB and two families, ≤ 40 requests on the phone, one render-blocking stylesheet, no
third-party origin before consent; images ≤ 1.5 MB and ≤ 2560 px at upload, AVIF / WebP in the width the screen
needs, one high-priority LCP image, lazy below the fold. Not shared: the database budget (MongoDB queries per render
diff --git a/docs/doctor.md b/docs/doctor.md
index 07a858d..1ed961e 100644
--- a/docs/doctor.md
+++ b/docs/doctor.md
@@ -70,6 +70,11 @@ returns counts only — never names, e-mails or values:
{ "mail": { "graphEnv": false, "relay": { "connected": true, "disconnected": false, "nameReplaced": false, "state": "active" }, "replyAddress": true, "status": null, "transport": "relay" }, "media": { "images": 42, "oversized": 0, "tooWide": 0 }, "node": "v22.20.0", "openSignUp": [], "pendingCookies": 0, "plugin": "1.15.0", "staffOnOwnRoles": [], "staffOpenToOthers": [], "turnstile": null, "turnstileSecretFromEnv": false, "usersSetupClosed": 0, "usersWithout2fa": 0 }
```
+`growth` (since 1.18.0): per collection its documents, its size with indexes (MongoDB; `null` elsewhere) and the date
+of its oldest record; versions per versioned collection and global with their limit; `payload-kv` entries and how
+many have expired; media no document points at (`checked` documents read, at most 5000); the retention in days of
+each plugin log — counts, sizes and dates only.
+
`media` (since 1.18.0): how many images the upload collections hold and how many are over the plugin's limits
(1.5 MB, 2560 px) — counts only, `null` without an upload collection.
@@ -146,6 +151,13 @@ Turn off: `iapl({ doctor: false })`. Adapt: `iapl({ doctor: { tokenVar: 'MY_TOKE
| | `perf-budgets` | info | a project that runs Playwright has a performance budget test in `e2e/` (the `iapl-performance` skill's template) |
| | `perf-live` | warning | (live) the home HTML is compressed, has no blocking `