carlos / platform Public

spec rev 2: answer Astra round 1 (4 P1, 10 P2)

Console-side retention sweep over three families, three-state settings,
per-account DPA applicability, per-recipient notices, incident notices,
deletion inventory and issuance checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f8c6793005f12e45b5ed2cb3af956aadd83e979b parent 89a4b18
3 files changed, +528 −258
  • docs/superpowers/reviews/CODEX-FINDINGS-dpa-and-retention.md +59 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R2.md +98 −0
  • docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md +371 −258

CI cancelled — superseded by a newer push — run details

CI log
=== gate ===
go: downloading go1.26.10 (linux/arm64)
go version go1.26.10 linux/arm64
opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1
  tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz
  tofu: downloaded, digest verified
  aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip
  aws: downloaded, digest verified
  archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip
  archive: downloaded, digest verified
  installed in /tmp/carlos-opentofu-aprMpV
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading golang.org/x/sys v0.49.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading github.com/superfly/ltx v0.5.1
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.45.6
go: downloading golang.org/x/net v0.62.0
go: downloading golang.org/x/mod v0.41.0
go: downloading github.com/pion/logging v0.2.4
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/aws/aws-sdk-go-v2/service/ssm v1.74.0
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/pion/randutil v0.1.0
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading golang.org/x/sync v0.24.0
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0
go: downloading golang.org/x/text v0.43.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec

amadan: job cancelled — a newer push superseded it

Intent

Human

<task-notification> <task-id>bjgi1pqth</task-id> <tool-use-id>toolu_01CW39p1e2FSwn419GduAwS5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/260ddc60-0dfc-4cf8-8857-7688d6275097/tasks/bjgi1pqth.output</output-file> <status>completed</status> <summary>Background command "Run Astra spec review in background" completed (exit code 0)</summary> </task-notification>

diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-dpa-and-retention.md b/docs/superpowers/reviews/CODEX-FINDINGS-dpa-and-retention.md
new file mode 100644
index 000000000..3bc52a5bd
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-dpa-and-retention.md
@@ -0,0 +1,59 @@
+Reviewed commit `89a4b186d98532b7a162508a76ade9c99f282985`, round 1. The spec is unchanged from the brief’s earlier commit. No files changed; no test suites run. The live privacy page could not be retrieved, so completeness against policy text beyond the supplied excerpts remains unverified.
+
+1. **P1 — §5.2 cannot represent an explicit “keep indefinitely” override.**
+ The [schema](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:220) uses app-level `NULL` for inheritance, while the controls also offer indefinite retention. With an account default of 30 days, an app cannot select indefinite retention: `NULL` inherits 30, and permitted numeric values start at 1. Implementing that mapping would delete statistics the customer selected to keep. The equivalent ambiguity affects “platform limit” for logs.
+ **Fix:** Define three states per field: inherit, explicit indefinite/platform limit, and finite days; resolve each field independently. **Fault family:** customer retention intent must survive storage and resolution.
+
+2. **P1 — §6.1 leaves an approved CLI login capable of minting credentials after deletion.**
+ The [deletion list](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:302) removes sessions and CLI tokens but omits `cli_auth_requests`. For an approved ordinary login, [pollCLIAuth](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/authstore.go:720) inserts a token without checking whether the user still exists. [CLITokenAddressContext](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/authstore.go:810) subsequently validates the token without joining `users`. Approve login, delete sign-in, then poll: a valid credential reappears.
+ **Fix:** Delete pending authorizations in the same transaction and make credential issuance reject a deleted identity, including callbacks already in flight. **Fault family:** deletion must revoke both issued credentials and outstanding authority to issue them.
+
+3. **P1 — §§2 and 5.5 do not actually expire all retained log data.**
+ [Log pruning](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/logretention.go:195) calls ordinary `Store.Delete`; [S3 deletion](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/release/store.go:1367) supplies no version ID. The [deployment bucket is versioned](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/infra/modules/deployment-buckets/main.tf:23), and its lifecycle explicitly expires only selected prefixes, excluding logs. Pruned chunks therefore remain recoverable as noncurrent versions indefinitely. Separately, [the shipping loop](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/logship.go:90) only prunes apps known to that process, under that box’s prefix. A terminated box leaves nobody responsible for its chunks. Changing the age calculation fixes neither case.
+ **Fix:** Specify bounded, version-aware cleanup covering retired boxes and apps no longer observed by a shipping process. **Fault family:** retention must cover every stored copy regardless of producer lifetime.
+
+4. **P1 — §4 measures the notice period from publication rather than notification.**
+ [Publication permits effectiveness after 30 days](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:172), but delivery happens later in a bounded hourly pass. A customer notified the following day receives 29 days; a delivery outage can leave them receiving no notice before the document becomes current. [Version selection](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:74) depends only on `effective_at`, whereas [§7 promises 30 days after notice](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:348).
+ **Fix:** Gate activation on completed notification plus the promised interval, or model applicability per account. Define treatment of accounts and DPA acceptances created during the notice period. **Fault family:** a contractual change cannot take effect before its notice obligation is satisfied.
+
+5. **P2 — §3.4 leaves the document fetch’s network boundary unspecified.**
+ [The fetch contract](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:142) requires only a successful HTTP 200. It specifies no scheme restriction, destination checks, redirect policy, deadline or body limit. An operator-entered public URL can redirect to an internal endpoint or return an unbounded response. Existing [outbound-request protections](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/alertdial.go:135) check actual dial destinations; the [client](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/alertdial.go:176) also refuses redirects and sets a timeout.
+ **Fix:** Specify HTTPS, checked destinations at dial time, refused or equivalently checked redirects, bounded headers/body and an overall deadline. **Fault family:** operator-supplied document locations must not grant unrestricted console network access.
+
+6. **P2 — §4’s delivery record loses failed recipients and does not ensure fair progress.**
+ [The proposed account-level mark](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:177) intentionally copies [notifyPlanOwners](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/plangracepass.go:250): one successful owner completes the account. If another owner’s delivery fails, it is never retried. A new owner also cannot be distinguished from an already notified one. With bounded processing in ID order and no cursor or retry schedule, persistently failing early accounts can consume every tick. A restart between send and marking can duplicate delivery.
+ **Fix:** Persist recipient-level delivery state, define owner-change semantics, and schedule retries without starving untouched recipients. Explicitly accept at-least-once delivery unless the transport supports deduplication. **Fault family:** every intended recipient must remain independently deliverable.
+
+7. **P2 — §5.5 adds a separate box read despite an existing suitable settings record.**
+ The proposed [retention.json](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:270) requires additional per-app reads. Existing [telemetry settings](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/telemetry/telemetry.go:49) already provide additive account/app objects, inheritance and [cached, change-gated reads](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/telemetry_pass.go:162). The new design also needs explicit handling for app creation after an account default was set, interrupted account-wide publication, and malformed records: falling back from a requested one day to the box’s seven days contradicts “never longer.”
+ **Fix:** Extend the existing telemetry record and propagation path, preserving last-good values on read errors. Define creation, retry and rollout coverage before exposing success. **Fault family:** retention propagation must converge without additional per-box polling or silently relaxing a limit.
+
+8. **P2 — §6 lacks a complete disposition for personal data and account-owned credentials.**
+ Beyond the omitted authorization in finding 2, personal references remain in [step-up and pending-action records](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/stepup.go:115), [pending approvals](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/pending.go:67), [alert connectors](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/alertstore.go:30), stars, onboarding marks and creator fields. Conversely, deleting all `cli_tokens` by address would remove credentials belonging to surviving accounts: [link and platform tokens deliberately retain the minting person’s address](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/authstore.go:883).
+ **Fix:** Add an explicit delete/anonymize/retain inventory, including linked sign-in subjects. Distinguish personal tokens from account-owned credentials. Keep sole-owner checks and local deletions in the transaction; local membership changes already support [that transaction shape](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/planmembers.go:53). **Fault family:** person deletion must remove personal state without destroying another principal’s authority.
+
+9. **P2 — §6.3’s eight-day backup claim contradicts the configured snapshot window.**
+ [§6.3](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:321) treats seven-day noncurrent-version expiry as sufficient. The [snapshot retention constant is seven days](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/lease/lease.go:95), applied by the [box-wide configuration](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/ops/litestream.go:129). Only after replacement or deletion does the [additional noncurrent-version window](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/infra/modules/deployment-buckets/main.tf:137) start. A pre-deletion snapshot can therefore remain recoverable beyond eight days.
+ **Fix:** Establish and verify an end-to-end expiry mechanism satisfying the promise; account for snapshot retention, object versions and stopped replicators. **Fault family:** backup erasure deadlines must cover successive retention layers.
+
+10. **P2 — §2 overstates the built 30-day mail-event deletion guarantee.**
+ The only production call to [pruneMailEvents](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/mailevents.go:75) occurs when recording another mail notification. The [prune itself](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/mailevents.go:229) is time-bounded, but it has no independent scheduled caller. When notifications stop, existing recipient-address rows can remain indefinitely.
+ **Fix:** Add a periodic retention pass independent of incoming events. **Fault family:** expiry must not depend on future activity.
+
+11. **P2 — §5.1’s separate request-record retention does not match the storage layout.**
+ [§5.1 excludes request records from customer retention](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:203), but [request records enter the same log sink and shipping pipeline](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/reqrec_loop.go:1). The proposed chunk deletion therefore shortens them too. Additionally, [the box’s age setting accepts values above seven days](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/logretention.go:60).
+ **Fix:** Either explicitly make request records share the effective log limit with a seven-day ceiling, or separate their storage and pruning. **Fault family:** independently promised retention requires independently enforceable storage boundaries.
+
+12. **P2 — §7’s region promise includes data whose destination is operator-selected.**
+ [§7 includes logs, statistics and mail events, then promises customer-selected regions](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:337). However, [analytics shipping](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/usage_loop.go:65) and log shipping use [the status/deployment store selected from box configuration](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/host/agent.go:5891), independently of the app’s selected region. Mail events reside in the console database. Selecting Sydney for an app does not select Sydney for those stores.
+ **Fix:** State the actual locations by data category, or build regional placement for every category covered by the promise. **Fault family:** contractual data-location claims must match actual storage routing.
+
+13. **P2 — §§2 and 9 omit the mechanism for §7’s breach-notification promise.**
+ [§7 promises notification within 48 hours of awareness](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:339), but the promise table and implementation slices provide no incident entry, affected-account selection, notification deadline or delivery tracking. [Legal notices](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:167) concern document publication and cannot represent that workflow. Keeping it entirely by email contradicts §1’s instruction to build every promise.
+ **Fix:** Add an operator-triggered breach-notification workflow with an awareness timestamp, affected recipients and tracked delivery. **Fault family:** every promised notification needs an executable, tracked path.
+
+14. **P2 — §5.4 understates discovery cost and overpromises completion time.**
+ A per-app resolver fits the existing walker: it obtains the account sqid and app name from [the directory hierarchy](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/analytics/prune.go:121). It can skip that app’s analytics subtree, but account/app discovery listings still occur. Also, [daily admission](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/internal/console/analyticsprune.go:42) deliberately postpones interrupted passes until tomorrow, using a saved cursor. Consequently, the [“deleted within a day” promise](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md:234) fails when a pass exhausts its budget before reaching the app.
+ **Fix:** Distinguish discovery listings from skipped analytics listings, avoid bucket work when no finite policies exist, and specify completion wording consistent with backlog and cursor behavior. **Fault family:** retention cost and timing claims must match bounded scheduler behavior.
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R2.md
new file mode 100644
index 000000000..8a648a472
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R2.md
@@ -0,0 +1,98 @@
+# Review brief: DPA and customer-set retention spec, round 2 of 3
+
+Repo carlos/platform, branch `dpa-and-retention`, commit TIP (named in the prompt).
+Under review: `docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md`.
+Authorities: the code on this commit (its base is main edaed836). Relevant
+merged work: the visitor-statistics prune (`internal/console/analyticsprune.go`,
+`internal/analytics/prune.go`), box log retention (`internal/host/logretention.go`,
+`internal/host/logship.go`), console delivery (`internal/console/delivery.go`,
+`consolemail.go`), the owner-notice pattern (`notifyPlanOwners` in
+`internal/console/plangracepass.go`), account deletion (`internal/console/ownership.go`),
+route declarations (`internal/console/routedecls.go`), the operator gate
+(`operatorOnly`), step-up auth (`internal/console/stepup.go`), and AGENTS.md.
+Do not review against unmerged branches; if this work needs one, say so as a P1 and stop.
+
+You are an independent reviewer. Read the document, then the code it
+names, and check every claim against that code.
+
+## Fixed: do not re-argue
+
+- Paul's rulings, 2026-11-25 (spec §1): the DPA is accepted in the console
+ with no operator approval step; every promise in the privacy policy and
+ DPA is built; customers set retention per account and per app, default
+ indefinite. Report only mechanisms that fail to honour them.
+- Logs may only be shortened, not lengthened past the box's retention
+ (§5.3). You may argue the mechanism, not the scope.
+- The DPA legal text (§7) is boilerplate pending a lawyer; review whether
+ §7 matches what the platform actually does (subprocessors, regions,
+ deletion, breach), not its legal drafting.
+
+## What to check
+
+1. §2: is every "built" claim true on this commit? Is any privacy-policy
+ promise (the policy text is quoted in §2 and §8) missing from the table?
+2. §3: gate order and roles against the existing owner-only settings POSTs
+ and `requireFreshAuth`; whether the acceptance record proves what was
+ accepted (§3.4 digest fetch: SSRF, redirects, size, timeouts — the URL
+ comes from an operator, but the console fetches it).
+3. §4: the notice pass against `notifyPlanOwners`: retry, duplicates on
+ restart, accounts created after publish, owner changes, deleted accounts,
+ and whether "bounded per tick" can starve.
+4. §5.4: whether `analytics.Prune`'s walk can take a per-app resolver as
+ described (does it walk per app? where do account and app names come
+ from in the key layout?), and whether an app with no setting really costs
+ no listing. The daily admission and cursor semantics must still hold.
+5. §5.5: the box read of `apps/<sqid>/<app>/retention.json`. Is there an
+ existing per-app record the agent already reads on the serial bump that
+ this can ride, or does it add per-box polling of new keys (S3 request
+ cost is a standing concern: no new per-box polling)? Old-box/new-console
+ and new-box/old-console behaviour; the census implication.
+6. §6: deleting a user — every table that references a person's address
+ (grep the store for address/user columns), what breaks for sole owners,
+ in-flight sessions and CLI tokens, Keymail links, and whether "one
+ transaction" is achievable given the store's layout.
+7. Anything in the spec that contradicts AGENTS.md (gate order, wire-shape
+ additivity, "every carlos command is designed for a user with no infra
+ access", provider-neutral core).
+
+## Round 2
+
+Earlier rounds: round 1, `docs/superpowers/reviews/CODEX-FINDINGS-dpa-and-retention.md`
+(NOT READY, 4 P1, 10 P2). Rev 2 marks each response (R1-n). The biggest
+change: retention is enforced by a console-side sweep over the analytics,
+logs and errors families (version-aware, covering retired boxes), so the
+box change and its census are gone (§5.4-5.5).
+
+First give one line per P1 and P2 from round 1: resolved, partly, or not.
+Carry every unresolved or partly resolved finding forward at its current
+severity, then add new findings. The verdict covers everything
+outstanding, earlier rounds included.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The
+ census, and review of any newly changed security, root, termination
+ or production-storage behaviour, still check the fix; see AGENTS.md,
+ "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem,
+the evidence (file:line, verified), the failure scenario, a concrete
+fix and the invariant or trust boundary it breaks (that is its fault
+family). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another
+ round.
+- **NOT READY**: one or more P1s, listed.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.
diff --git a/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md b/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md
index a8d183259..5ca2a282e 100644
--- a/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md
+++ b/docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md
@@ -1,8 +1,12 @@
# Data processing agreements and customer-set retention
-Status: draft rev 1, 2026-11-25. Branch `dpa-and-retention`.
+Status: draft rev 2, 2026-11-25. Branch `dpa-and-retention`.
Asked for by Paul, 2026-11-25 (prompts on the branch ledger).
+Review history: round 1 (Astra, `CODEX-FINDINGS-dpa-and-retention.md`,
+commit 89a4b186): NOT READY, 4 P1, 10 P2. Every finding is accepted;
+each change below is marked **(R1-n)**. Round 2 is next; budget is 3.
+
## 1. Why
A customer who runs an app on the flagship processes personal data
@@ -38,20 +42,23 @@ the DPA this work adds promise:
| Promise | State on main edaed836 | This work |
|---|---|---|
-| Visitor statistics kept 400 days | prune built (a3c407d4), operator-wide `CARLOS_ANALYTICS_RETENTION_DAYS`, not switched on for the flagship | replaced by the customer's setting, default indefinite (§5); policy text changes |
-| Request records up to 7 days | built (box log retention) | unchanged |
-| Mail events 30 days | built (`mailevents.go`) | unchanged |
+| Visitor statistics kept 400 days | prune built (a3c407d4), operator-wide `CARLOS_ANALYTICS_RETENTION_DAYS`, version-aware, not switched on for the flagship | replaced by the customer's setting, default indefinite (§5); policy text changes |
+| Request records up to 7 days | **not true today**: the box prunes them with a plain delete in a versioned bucket, so every pruned chunk survives as a noncurrent version forever, and a retired box's chunks are never pruned at all (R1-3, R1-11) | the retention sweep (§5.4) deletes every version, for every box, live or gone |
+| Logs and errors (not in the policy today; in the DPA) | same gap as request records | same sweep |
+| Mail events 30 days | **only pruned when another mail event arrives** (`mailevents.go:75`); an idle account keeps them forever (R1-10) | prune on the hourly worker (§5.6) |
| Demo IP gone 7 days after the demo | built (`demo_store.go`) | unchanged |
| Delete everything about a person, incl. the sign-in record, within 30 days of a request | **by hand only; no deletion path exists** | self-serve and operator deletion (§6) |
-| Email account owners 30 days before a policy change that matters | **not built** | legal notices (§4) |
+| Console backups gone within 8 days | console replica keeps one 24 h generation; bucket expires noncurrent versions after 7 days | unchanged; §6.4 states the arithmetic |
+| Email account owners 30 days before a policy change that matters | **not built** | notices (§4) |
| DPA on request | **by email** | built in (§3) |
-| DPA: notice before a new subprocessor | n/a | legal notices (§4) |
-| DPA: delete or return customer data at the end | account delete + reap built (`ownership.go`) | the DPA states what deletion covers and when; nothing new to build |
-| DPA: help with data-subject requests | n/a | the app's data is the customer's; logs, statistics and backups are covered by §5 and §6 |
+| DPA: 30 days' notice of a subprocessor change, right to object | n/a | notices (§4), per-account applicability (§3.5) |
+| DPA: breach notice within 48 hours | n/a | incident notices (§4.4) (R1-13) |
+| DPA: delete app data, backups included, within 30 days of deleting the app or account | account delete + reap built (`ownership.go`) | verified and stated in §6.5 (R1-9) |
+| DPA: help with data-subject requests | n/a | the app's data is the customer's; logs and statistics are covered by §5, people by §6 |
## 3. Accepting the DPA
-### 3.1 Operator configuration
+### 3.1 Documents
A **legal document** is a row the operator publishes from the operator
area (`/fleet/legal`, `operatorOnly`):
@@ -61,28 +68,27 @@ legal_documents(
id INTEGER PRIMARY KEY,
kind TEXT NOT NULL, -- 'dpa' | 'terms' | 'privacy'
version TEXT NOT NULL, -- operator's label, e.g. '2026-11-25'
- url TEXT NOT NULL, -- the published text, e.g. https://carloku.com/dpa/
- sha256 TEXT NOT NULL, -- digest of the text at url when published (§3.4)
+ url TEXT NOT NULL, -- the published text at a stable, versioned URL
+ sha256 TEXT NOT NULL, -- digest of the body at url when published (§3.4)
summary TEXT NOT NULL, -- what changed, plain text, goes in the notice
published_at INTEGER NOT NULL,
- effective_at INTEGER NOT NULL, -- >= published_at; notice period (§4)
- published_by TEXT NOT NULL, -- operator address
+ effective_at INTEGER NOT NULL,
+ needs_notice INTEGER NOT NULL, -- 0 only for a change the operator marks as not needing notice
+ published_by TEXT NOT NULL,
UNIQUE(kind, version)
)
```
-Rows are append-only: never updated, never deleted. The current
-version of a kind is the newest row whose `effective_at` has passed;
-a row not yet effective is "upcoming". With no `dpa` row the feature
-is off and the settings pane does not render.
-
-`terms` and `privacy` rows exist only to drive notices (§4); nothing
-is accepted against them in this work.
+Rows are append-only. With no `dpa` row the DPA pane does not render.
+The **first** `dpa` row has `needs_notice = 0` and `effective_at =
+published_at`: there is nobody to notify. Every later row with
+`needs_notice = 1` must have `effective_at` at least 35 days after
+`published_at` (30 days of notice plus 5 days for delivery, §4.2).
### 3.2 The account settings pane
-`/a/{sqid}/settings` gains a **Data processing** pane, rendered when a
-`dpa` document is current:
+`/a/{sqid}/settings` gains a **Data processing** pane when a `dpa`
+document exists:
- **No DPA in force:** one line saying what a DPA is for, a link to the
current text, and a form for the details the agreement names:
@@ -90,14 +96,12 @@ is accepted against them in this work.
name and role. An **Accept** button submits it.
- **In force:** "DPA {version} in force since {date}, accepted by
{signer} for {legal name}", a link to the record (§3.3), and, when a
- newer version is upcoming, "Version {v} takes effect on {date}:
- {summary}".
+ newer version is pending for this account, "Version {v} applies from
+ {date}: {summary}".
-Accepting is **owner-only**: binding the customer to a contract is an
-owner's decision, the same rule as billing. Gate order is the house
-order: session → CSRF → owner (byte-identical 404) → write rate limit
-→ `requireFreshAuth` last (a contract acceptance is a sensitive action,
-like a billing change).
+Accepting is **owner-only**. Gate order is the house order: session →
+CSRF → owner (byte-identical 404) → write rate limit →
+`requireFreshAuth` last.
### 3.3 The record
@@ -111,297 +115,406 @@ dpa_acceptances(
country TEXT NOT NULL, -- ISO 3166-1 alpha-2
signer_name TEXT NOT NULL,
signer_role TEXT NOT NULL,
- accepted_by TEXT NOT NULL, -- the signed-in owner's address
+ accepted_by TEXT NOT NULL,
accepted_ip TEXT NOT NULL, -- s.clientIP(r)
accepted_at INTEGER NOT NULL,
ended_at INTEGER -- set when the account is deleted
)
```
-One live row per account (`ended_at IS NULL`); a second acceptance of
-the same document is refused, and accepting after the account's row
-ended writes a new row. An accepted DPA follows later versions on their
-`effective_at` without re-acceptance, as the DPA text says (§7): the
-record keeps the version accepted, and the pane shows the version in
-force.
+One live row per account (`ended_at IS NULL`, a partial unique index).
+Acceptance accepts the **newest published** `dpa` document, including
+one published but not yet effective: an owner accepting during a
+notice period sees the pending version's summary on the form and
+accepts that version directly, so they are owed no notice for it.
The acceptance writes an audit row (`dpa.accept`, empty app) and emails
-the accepting owner a confirmation with the record's fields, the
-document URL and its digest, through `s.deliver`.
+the accepting owner a confirmation with the record's fields, the URL
+and its digest.
+
+`GET /a/{sqid}/settings/dpa` (member-readable) renders the record as a
+printable page with the operator's name (§3.6), the customer details,
+version, URL, digest, who accepted and when, and a "Print or save as
+PDF" button. No generated PDF: the console has no PDF renderer of its
+own.
+
+### 3.4 Pinning the text (R1-5)
-`GET /a/{sqid}/settings/dpa` (member-readable: any member may need to
-show a customer's auditor the record) renders the record as a printable
-page: the operator's name (§3.5), the customer details, version, URL,
-digest, accepted by, at, and a "Print or save as PDF" button. A
-generated PDF is out of scope: the console has no PDF renderer of its
-own (the PDF engine is a metered tenant service), and a print
-stylesheet gives the customer the same file.
+Publishing fetches `url` once and stores the SHA-256 of the body. The
+fetch uses the same guarded client as alert webhooks
+(`alertdial.go`): HTTPS only, the destination checked at dial time
+against private, loopback, link-local and metadata ranges, no
+redirects, a 10-second overall deadline, and a 2 MiB body limit. Any
+failure refuses the publish with the reason. The operator keeps every
+version at a stable URL (the flagship: `/dpa/{version}/`).
-### 3.4 Pinning the text
+### 3.5 Which version applies to an account (R1-4)
-The record must prove which text was accepted. When the operator
-publishes a document, the console fetches `url` once, stores the
-SHA-256 of the body, and refuses to publish on a fetch failure or a
-non-200. The record page and the confirmation email carry the digest.
-The operator keeps every version's text at a stable URL (the flagship:
-`/dpa/` for the current and `/dpa/{version}/` for each published one),
-and `url` names the versioned one.
+A version takes effect for an account, not globally. For an account
+with a live acceptance of version A, the version in force is the
+newest `dpa` document V, at or after A, such that either V is A, or
+all of:
-### 3.5 Operator settings
+- `V.effective_at <= now`, and
+- `V.needs_notice = 0`, or this account's notice for V (§4) was
+ delivered to at least one owner at least 30 days ago.
-Two console environment variables name the operator in the record and
-the emails: `CONSOLE_LEGAL_ENTITY` ("Team Tito Limited, Dublin,
-Ireland" on the flagship) and `CONSOLE_PRIVACY_ADDRESS`
-(privacy@carloku.com). Unset: the pane does not render even with a
-`dpa` row, and `/fleet/legal` says why.
+So a notice delivered late moves that account's date later; it never
+shortens the notice. The pane, the record page and `/fleet/legal` all
+read this one function (`dpaInForce(account, now)`), with a table test
+covering accepted-during-notice, late delivery, failed delivery,
+skipped versions, and an account created during the notice period
+(which accepts the newest version directly, §3.3).
-### 3.6 The operator list
+An objection under the DPA is handled by email; the console records
+nothing for it in this work.
-`/fleet/legal` lists the published documents, a form to publish a new
-one, and the accounts with a DPA in force: account, legal name,
-country, version accepted, accepted by, when. Read-only: there is
-nothing to approve. A rail entry in `opRail`.
+### 3.6 Operator settings
-## 4. Legal notices
+`CONSOLE_LEGAL_ENTITY` ("Team Tito Limited, Dublin, Ireland") and
+`CONSOLE_PRIVACY_ADDRESS` (privacy@carloku.com) name the operator in
+the record and the emails. Unset: no pane renders, and `/fleet/legal`
+says why.
-Publishing a document with a summary schedules a notice:
+### 3.7 The operator list
-- `dpa`: to the owners of every account with a DPA in force.
-- `terms`, `privacy`: to the owners of every account.
+`/fleet/legal` lists the published documents with each one's notice
+progress (§4.3), a form to publish, the accounts with a DPA in force
+(account, legal name, country, version accepted, version in force,
+accepted by, when), and the incident form (§4.4). Nothing to approve.
+A rail entry in `opRail`.
-The publish form refuses an `effective_at` sooner than 30 days after
-`published_at` unless the operator ticks "this change doesn't need
-notice" (a typo fix), in which case no notice is sent. Thirty days is
-the policy's own promise; it is a constant, not a setting.
+## 4. Notices (R1-4, R1-6, R1-13)
-Delivery is a background pass on the existing hourly worker, shaped
-like `notifyPlanOwners`: per account, per-delivery timeout, failures
-logged with `jobFailed`, and a mark set only after at least one
-delivery to that account succeeded, so the next pass retries.
+One delivery mechanism carries three kinds of operator notice.
+
+### 4.1 Recipients, per person
```
-legal_notices(document_id INTEGER, account_id INTEGER, notified_at INTEGER,
- PRIMARY KEY(document_id, account_id))
+notices(
+ id INTEGER PRIMARY KEY,
+ kind TEXT NOT NULL, -- 'document' | 'incident'
+ document_id INTEGER, -- for 'document'
+ subject TEXT NOT NULL,
+ body TEXT NOT NULL,
+ audience TEXT NOT NULL, -- 'all-owners' | 'dpa-owners' | 'accounts'
+ created_at INTEGER NOT NULL,
+ created_by TEXT NOT NULL,
+ aware_at INTEGER, -- for 'incident': when the operator became aware
+ open_until INTEGER NOT NULL -- recipients are re-resolved until this time
+)
+notice_deliveries(
+ notice_id INTEGER NOT NULL,
+ account_id INTEGER NOT NULL,
+ address TEXT NOT NULL,
+ attempts INTEGER NOT NULL DEFAULT 0,
+ next_attempt_at INTEGER NOT NULL,
+ delivered_at INTEGER,
+ last_error TEXT,
+ PRIMARY KEY(notice_id, account_id, address)
+)
+notice_accounts(notice_id INTEGER, account_id INTEGER, PRIMARY KEY(notice_id, account_id)) -- for 'accounts'
```
-The pass works through accounts in id order, bounded per tick so a
-large fleet doesn't send everything in one hour. An account deleted
-before its turn is skipped. The notice is plain text: the summary, the
-effective date, the URL, and for `dpa` that the customer may object by
-writing to the privacy address before that date.
+The hourly pass, for each notice still open, inserts a delivery row for
+every current owner of every account in its audience that has none
+(`INSERT OR IGNORE`), so an owner added during the notice period is
+notified too. A document notice stays open until its `effective_at`.
+An owner who loses the role keeps their row; a delivery already sent
+is not undone.
+
+### 4.2 Sending
+
+The same pass then sends up to N deliveries (N = 200 per hour)
+ordered by `next_attempt_at`, through `s.deliver` with a per-delivery
+timeout. Success sets `delivered_at`. Failure increments `attempts`,
+records `last_error` and sets `next_attempt_at` to now + min(2^attempts
+hours, 24 h). Because failures move to the back, a failing address
+never starves untried ones. Delivery is at least once: a restart
+between sending and marking can send twice, and that is accepted
+(the transports have no deduplication). An account deleted before
+delivery has its rows removed. With N = 200 per hour, 5 days of slack
+(§3.1) covers 24,000 owners; `/fleet/legal` warns when the undelivered
+count would not fit before `effective_at - 30 days`.
+
+### 4.3 Document notices
+
+Publishing a document with `needs_notice = 1` creates its notice:
+`dpa` to `dpa-owners` (owners of accounts with a live acceptance of an
+earlier version), `terms` and `privacy` to `all-owners`. The body is
+the summary, the date, the URL, and for `dpa` that the customer may
+object by writing to the privacy address before that date.
+
+For `terms` and `privacy` the console cannot hold back the website, so
+`/fleet/legal` shows, per document, how many owners were notified at
+least 30 days before `effective_at` and lists those who were not; the
+operator publishes the site change once that list is empty or
+explained. For `dpa` the per-account rule in §3.5 makes late
+delivery safe by construction.
+
+### 4.4 Incident notices
+
+The DPA promises notice of a personal-data breach within 48 hours of
+the operator becoming aware. `/fleet/legal` has an incident form
+(`operatorOnly` + `requireFreshAuth`): when the operator became aware,
+the affected accounts (a list, or all), subject and body. It creates a
+`kind = 'incident'`, `audience = 'accounts'` notice that stays open for
+48 hours, sends on the next pass (the form also runs the pass at once
+for that notice), and `/fleet/legal` shows its delivery progress
+against `aware_at + 48 h`, in red when any delivery is still
+outstanding past it. The audit row records the operator and
+`aware_at`. Deciding that something is a breach, and what to say,
+stays the operator's judgement.
## 5. Retention set by the customer
-### 5.1 What it covers
+### 5.1 What it covers (R1-11)
-Two kinds of data the operator keeps about an app's visitors and users
-on the customer's behalf:
+Data the operator keeps about an app's visitors and users on the
+customer's behalf, in the deployment bucket under each app's prefix:
-- **Visitor statistics** (the daily analytics files).
-- **Logs and errors** (the shipped chunks each box keeps per app).
+- **Visitor statistics**: `apps/<sqid>/<app>/analytics/...`
+- **Logs, errors and request records**: the `logs` and `errors` chunk
+ families. Request records are written into the same sink as logs
+ (`reqrec_loop.go`), so they share the log setting. The policy's
+ "up to 7 days" for them holds because the log setting can only be
+ shortened below the operator's limit, which the flagship sets to 7.
-Request records stay at the operator's 7 days: they are the operator's
-own security data, which the policy already bounds. An app's own
-databases, files and object store are the customer's to manage and are
-not touched.
+An app's own databases, files and object store are the customer's to
+manage and are not touched.
-### 5.2 The settings
+### 5.2 The settings (R1-1)
Account settings gains a **Data retention** pane (owner-only writes,
-member-readable), and app settings a **Data retention** section with
-the same two controls, each either "Use the account's setting" or a
-value:
+member-readable), and app settings a **Data retention** section. Each
+of the two controls holds one of three states:
-- Visitor statistics: **Keep indefinitely** (the default) or keep N
- days, 1 to 3660.
-- Logs and errors: **Keep as long as the platform allows** (the
- default) or keep N days, from 1 up to the box's log retention.
+| State | Statistics | Logs |
+|---|---|---|
+| `inherit` (app level only; the app default) | the account's setting | the account's setting |
+| `keep` (the account default) | keep indefinitely | keep to the operator's limit |
+| `days` + N | N days, 1 to 3660 | N days, 1 to the operator's limit |
```
retention_settings(
account_id INTEGER NOT NULL,
- app TEXT NOT NULL DEFAULT '', -- '' = the account default
- stats_days INTEGER, -- NULL = inherit (app) / indefinite (account)
- log_days INTEGER, -- NULL = inherit (app) / platform limit (account)
+ app TEXT NOT NULL DEFAULT '', -- '' = the account row
+ stats_mode TEXT NOT NULL, -- 'inherit' | 'keep' | 'days'; 'inherit' refused on the account row
+ stats_days INTEGER, -- set iff stats_mode = 'days'
+ log_mode TEXT NOT NULL,
+ log_days INTEGER,
updated_by TEXT NOT NULL,
updated_at INTEGER NOT NULL,
- PRIMARY KEY(account_id, app)
+ PRIMARY KEY(account_id, app),
+ CHECK ((stats_mode = 'days') = (stats_days IS NOT NULL)),
+ CHECK ((log_mode = 'days') = (log_days IS NOT NULL))
)
```
-The effective value for an app is its own row, else the account's
-row, else the default. Every change writes an audit row
-(`retention.set`) naming the old and new values. Shortening shows the
-consequence before it saves: "Statistics older than N days will be
-deleted within a day."
-
-### 5.3 Why logs cannot be "indefinite"
-
-Logs are bounded by the box's own retention (`CARLOS_LOG_RETENTION_DAYS`
-and `_MB`, default 7 days and 50 MiB per app per box). Keeping them
-forever is a storage cost the operator pays and the plan does not
-charge for, so in this work a customer may **shorten** log retention
-but not lengthen it past the box's. Longer log retention is a plan
-feature for later (#1024's archive tier), not a setting here. This
-departs from "indefinite by default" for logs only; statistics follow
-the ruling exactly.
-
-### 5.4 Statistics: the console prune
-
-`analyticsPrunePass` today applies one operator-wide age. It becomes:
-
-- The operator setting `CARLOS_ANALYTICS_RETENTION_DAYS` stays, as a
- **ceiling**: unset means no ceiling. The effective age for an app is
- the shorter of the ceiling and the customer's setting; with neither,
- nothing is pruned.
-- `analytics.PruneOptions` gains a per-app resolver,
- `RetentionFor(account, app string) int` (0 = keep), in place of the
- single `RetentionDays`. The walk already visits apps one at a time,
- so the resolver is called per app with no extra listing.
-- The daily admission, cursor, limits and dry run are unchanged.
-- An app with no setting and no ceiling is still walked by nothing: the
- pass skips listing an app whose effective age is 0.
-
-The flagship then leaves `CARLOS_ANALYTICS_RETENTION_DAYS` unset, and
-the 400-day promise is withdrawn from the policy (§8).
-
-### 5.5 Logs: the box prune
-
-The box needs each app's shorter setting. The console writes it into
-the bucket where boxes already read per-app state:
-
-```
-apps/<sqid>/<app>/retention.json {"log_days": 3, "updated_at": "..."}
-```
-
-written on every change to the app's effective `log_days` (an account
-change rewrites every app of the account that inherits it), deleted
-when the effective value returns to the platform limit, and the
-serial bumped. The box agent reads it with the rest of the app's
-records and applies `min(box retention, log_days)` to the age limit;
-the byte cap is unchanged. A missing or unparsable file means the box's
-own retention, never shorter-than-asked silently and never longer: an
-unparsable file is logged and treated as missing. Wire shape is
-additive: an old box ignores the file and keeps the box's retention,
-which is longer than asked; the pane therefore says the setting applies
-"within a day on every box that runs the app", and the release that
-carries the box change ships before the console change switches the
-control on.
-
-This changes code in the root binary's census scope (`internal/host`);
-the census card and its review apply (AGENTS.md).
-
-## 6. Deleting a person
-
-### 6.1 Self-serve
+A missing row is `inherit` at the app level and `keep` at the account
+level. Each field resolves independently: app row, then account row,
+then `keep`. So an app can choose `keep` under an account that set 30
+days. Every change writes an audit row (`retention.set`) with old and
+new values. Shortening says what it does before it saves: "Statistics
+older than N days will be deleted. This usually happens within a day,
+and always within a week." (R1-14)
+
+The settings live in console.db only: the sweep (§5.4) runs in the
+console, so nothing new is written to the bucket and no box reads
+anything new (R1-7).
+
+### 5.3 Operator limits
+
+- `CARLOS_ANALYTICS_RETENTION_DAYS` (console) stays, as a **ceiling**
+ on statistics: unset means no ceiling.
+- `CARLOS_LOG_RETENTION_DAYS` is read by the console too, as the
+ ceiling for the log families, defaulting to 7 like the box. An
+ operator who raises it on boxes raises it on the console.
+
+The effective age of a family for an app is the shorter of the ceiling
+and the customer's setting; `keep` with no ceiling means no limit.
+
+### 5.4 One sweep for every family (R1-3, R1-14)
+
+`analyticsPrunePass` becomes the **retention sweep**. It keeps the
+daily admission, the saved cursor, the delete and key limits and the
+dry run, and it already lists and deletes every object version
+(`ListVersionsPage`, `DeleteVersions`). It changes in three ways:
+
+1. **Per app.** `analytics.PruneOptions.RetentionDays` becomes
+ `RetentionFor(acct, app string, fam applog.Family) int` (0 = keep).
+ The walker already learns account and app from the directory
+ hierarchy (`analytics/prune.go:121`). Discovery listings (accounts,
+ apps) still happen; for a family whose effective age is 0 the
+ walker lists nothing under it.
+2. **Three families.** For each app it walks `analytics`, `logs` and
+ `errors`, per box subtree, including boxes that no longer exist,
+ and deletes every version of every object in an expired day or
+ hour. This is what removes noncurrent versions the box's own prune
+ leaves behind, and chunks from retired boxes that nobody prunes.
+3. **Nothing to do, no bucket work.** When no ceiling is set and no
+ app's settings resolve to a finite age, the pass returns before
+ listing anything. On the flagship the log ceiling is always set
+ (7), so the pass always runs there.
+
+The box's own prune is unchanged: it keeps bounding local cost and
+bucket size between sweeps, and the sweep cleans up after it.
+
+Timing: a pass that runs out of its limits stops and resumes from its
+cursor the next day, so the promise everywhere is "usually within a
+day, always within a week". The pass logs a warning and fails its job
+(existing behaviour) whenever a backlog remains, and `/fleet/legal`
+shows the last complete pass's date; a sweep that has not completed in
+7 days is an alert.
+
+Cost: one daily listing per app per family per box subtree, plus the
+deletes. That is the same shape the analytics prune already pays, now
+for three families; no per-box polling is added.
+
+IAM: the console's version delete under `apps/*/*/analytics/` is
+`enable_analytics_version_prune` (region-host). It widens to the
+`logs/` and `errors/` families, under a renamed variable
+`enable_retention_version_prune` (old name kept as an alias for one
+release).
+
+### 5.5 What changes on boxes
+
+Nothing. This removes the census work the first revision had.
+
+### 5.6 Mail events (R1-10)
+
+`pruneMailEvents` also runs from the hourly worker, not only when a
+new event arrives, so an idle sender's events still go after 30 days.
+
+## 6. Deleting a person (R1-2, R1-8)
+
+### 6.1 What a person is, in console.db
+
+The plan's first task is the inventory: every table and column that
+holds a person's address or a sign-in subject, each with one of three
+dispositions, checked by a test that fails when a new column holding
+an address appears without one (the record-write census pattern). The
+dispositions known now:
+
+| Data | Disposition |
+|---|---|
+| `users` row, sign-in methods, linked sign-in subjects (Keymail, social) | delete |
+| email sign-in codes, step-up and pending-action records (`stepup.go`), pending approvals (`pending.go`) | delete |
+| sessions | delete |
+| `cli_auth_requests` for the address, pending or approved | delete |
+| personal CLI tokens (minted by the person for themselves) | delete |
+| account-owned tokens that record the minting person (link and platform tokens, `authstore.go:883`) | keep the token; replace the address with `deleted-person` |
+| memberships; invitations sent to or by them | delete |
+| stars, onboarding marks, alert connectors they own | delete |
+| creator fields on apps and other account objects | replace with `deleted-person` |
+| audit rows | keep, as the policy says |
+| DPA acceptances naming them | keep: the customer's contract record, and the DPA says so |
+
+### 6.2 Closing the doors
+
+- The deletion runs in **one transaction** with the sole-owner check
+ (the shape `planmembers.go:53` already uses for membership changes).
+- **Credential issuance checks the person exists.** `pollCLIAuth`
+ (`authstore.go:720`) inserts a token only if the `users` row still
+ exists, in the same transaction, so an approval in flight when the
+ person is deleted mints nothing. Session creation and the other
+ token-minting paths get the same check; the inventory test lists
+ every minting path.
+- Token validation (`CLITokenAddressContext`, `authstore.go:810`) needs
+ no join: deleting the tokens is enough once nothing can mint new
+ ones.
+
+### 6.3 Self-serve and operator
`/settings` (the person's own page) gains **Delete my sign-in**. It
refuses, naming the accounts, while the person is the only owner of an
-account: they must delete the account or make someone else an owner
-first. Otherwise, after `requireFreshAuth` and a typed confirmation of
-their address, it removes in one transaction:
-
-- the user row and sign-in methods, email sign-in codes, Keymail link;
-- sessions and CLI tokens (with their last-used IPs);
-- memberships and invitations sent to or by them;
-- DPA acceptance records naming them as `accepted_by` or signer are
- **kept**: they are the customer's contract record, not the person's
- account, and the DPA text says so;
-- audit rows are kept, as the policy says.
-
-The person is signed out everywhere and gets a confirmation email.
+account. After `requireFreshAuth` and typing their address, it runs
+§6.2 and emails a confirmation. `/fleet/people/{address}` gains the
+same action for requests that arrive by email (`operatorOnly` +
+`requireFreshAuth`), audited against the ops account.
-### 6.2 Operator
+### 6.4 Console backups
-`/fleet/people/{address}` gains the same deletion for requests that
-arrive by email, under `operatorOnly` and `requireFreshAuth`, with the
-same sole-owner refusal; the operator resolves that case with the
-account first. The operator action is audited against the ops account.
+Deleted rows leave the console's backups within 8 days: the replica
+keeps one generation of at most 24 hours, and the bucket expires
+noncurrent versions after 7 days.
-### 6.3 Backups
+### 6.5 App data after deleting an app or account (R1-9)
-The console replica and the bucket's noncurrent-version lifecycle
-(7 days) mean deleted rows leave backups within 8 days, as the policy
-already says. Nothing to build.
+The DPA promises 30 days. The plan's first slice measures it on dev:
+the reap delay after an account or app delete, then the replica
+prefix's objects all becoming noncurrent, then the 7-day noncurrent
+expiry. Litestream's 7-day snapshot retention (`lease.go:95`) applies
+only while a replicator runs; reap deletes the whole replica prefix,
+snapshots included. If the measured worst case exceeds 30 days, the
+DPA's number changes before publishing, not the other way round.
## 7. The DPA text (flagship)
-A standard processor agreement, published by the flagship at
-carloku.com/dpa/, written for this work as boilerplate and to be
-checked by a lawyer before it is relied on. Its parts:
-
-1. Parties: Team Tito Limited (processor) and the customer named in the
- acceptance (controller). Formed by acceptance in the console.
-2. Subject, duration, nature and purpose: hosting and serving the
- customer's apps, for as long as the account exists.
-3. Data and data subjects: whatever the customer's apps process;
- visitor statistics, logs and errors, request records, mail events.
-4. Processor duties (Art. 28(3)): documented instructions only;
- confidentiality; security measures (Annex 2); subprocessors only as
- listed, with 30 days' notice of a change and a right to object;
- help with data-subject requests and with Articles 32 to 36; breach
- notice without undue delay and within 48 hours of becoming aware;
- deletion at the end; information and audits.
-5. Transfers: data stays in the regions the customer picks; where it
- leaves the EU or UK, the Commission's standard contractual clauses
- (module 2) and the UK addendum apply.
-6. Changes: new versions take effect on the date given, at least 30
- days after notice, unless the customer objects.
-7. Liability: as in the terms.
-8. Annex 1: details of processing. Annex 2: security measures (TLS
- everywhere, encryption at rest, per-app isolation, least-privilege
- credentials, backups, access by named operators only). Annex 3:
- subprocessors: Amazon Web Services (hosting, storage, backups, DNS,
- email; Ireland, London, Virginia, Sydney), Stripe (payments; account
- holders only, not app data).
-
-Keymail is the operator's own and not a subprocessor. Let's Encrypt
-sees only hostnames and is listed in the privacy policy, not here.
-
-The text goes through copy review before it is published.
+A standard processor agreement at carloku.com/dpa/, drafted as
+boilerplate and to be read by a lawyer before it is relied on. It is
+in copy review in the carloku repo (branch `dpa-page`). The facts it
+must match:
+
+- Parties: Team Tito Limited (processor), the customer named in the
+ acceptance (controller). Formed by acceptance in the console.
+- Data covered: app data; visitor statistics; logs, errors and request
+ records; mail delivery records.
+- **Where (R1-12):** an app's databases, files and storage stay in the
+ region the customer runs it in. Visitor statistics, logs, errors,
+ request records and mail records are kept in the EU (Ireland),
+ whatever region the app runs in. Transfers out of the EU and UK use
+ the Commission's standard contractual clauses (module 2) and the UK
+ addendum.
+- Retention: as §5; deletion as §6.5.
+- Breach: within 48 hours of becoming aware (§4.4).
+- Changes: 30 days' notice, applying per account (§3.5).
+- Subprocessors for app data: Amazon Web Services only. Stripe sees
+ account holders' billing data, not app data. Let's Encrypt sees
+ hostnames only.
## 8. Copy changes outside the console
- carloku `/dpa/` and `/dpa/{version}/`: new (§7).
-- carloku `/privacy/`: "we will sign a data processing agreement with
- you on request" becomes "accept our data processing agreement in your
- account settings"; the 400-day line becomes "for as long as the app's
- owner chooses; until they choose, we keep them"; logs and errors get
- a line ("for as long as the app's owner chooses, up to 7 days"); the
- deletion line gains "or delete your sign-in yourself in the console".
-- Published as a new `privacy` document with a notice (§4), so owners
- hear about it 30 days ahead.
-- `docs/site`: the console guide gains the two panes.
+- carloku `/privacy/`: the DPA line points at account settings; the
+ 400-day line becomes "for as long as the app's owner chooses; until
+ they choose, we keep them"; logs and errors get a line; the deletion
+ line gains "or delete your sign-in yourself in the console"; where
+ visitor and log data is kept (§7) is stated.
+- Published as a new `privacy` document with notice (§4.3).
+- `docs/site`: the console guide gains the panes.
## 9. Slices
-Each slice lands as its own branch merge; the first is something Paul
-can see.
-
-1. **DPA acceptance.** `legal_documents` with publish and digest,
- `/fleet/legal`, the settings pane, `dpa_acceptances`, the record
- page, the confirmation email, `CONSOLE_LEGAL_ENTITY` and
- `CONSOLE_PRIVACY_ADDRESS`. Plus the carloku `/dpa/` pages. Witness:
- on dev, publish a DPA, accept it from a test account, see it on
- `/fleet/legal`, print the record.
-2. **Legal notices.** `legal_notices`, the 30-day rule on publish, the
- hourly pass. Witness: on dev, publish a version with a summary and
- see the notice arrive at a test owner.
-3. **Statistics retention.** The settings tables and panes for
- statistics, the per-app prune. Witness: a dev app set to 1 day loses
- its older days on the next pass (dry run first).
-4. **Log retention.** `retention.json`, the box read (census), the log
- control. Ships in a box release before the console control turns on.
-5. **Deleting a person.** Self-serve and operator.
-6. **Flagship switch-on.** Set the two env vars, publish the DPA and
- the changed privacy policy with 30 days' notice, update the policy
- copy.
+Each slice lands as its own merge; the first is something Paul can see.
+
+1. **DPA acceptance.** `legal_documents` with the guarded fetch,
+ `/fleet/legal` (documents and list), the settings pane,
+ `dpa_acceptances`, the record page, the confirmation email, the two
+ env vars, `dpaInForce` with its table test (notices treated as
+ absent until slice 2). Plus the measurement in §6.5. Witness on dev:
+ publish, accept from a test account, see it on `/fleet/legal`, print
+ the record.
+2. **Notices.** `notices`, `notice_deliveries`, the hourly pass,
+ document notices with the 35-day rule, incident notices,
+ `dpaInForce` reading deliveries. Witness: publish a second DPA
+ version on dev and see the notice arrive and the in-force date
+ follow it.
+3. **Retention.** `retention_settings`, the panes, the sweep over three
+ families, the IAM widening, the mail-events prune. Witness: a dev
+ app set to 1 day loses older statistics and logs, including
+ noncurrent versions, on the next pass (dry run first).
+4. **Deleting a person.** The inventory test, the issuance checks, the
+ transaction, self-serve and operator.
+5. **Flagship switch-on (Paul's go).** Env vars, IAM apply, publish the
+ DPA and the changed privacy policy with notice.
## 10. Not in this work
-- An approval queue, negotiated DPAs, per-customer terms: by email,
- outside the platform.
+- An approval queue, negotiated DPAs, per-customer terms.
+- Recording objections in the console.
- A generated PDF of the record.
- Acceptance of terms at sign-up.
-- Lengthening log retention past the box's (#1024 archive tier).
-- Retention for request records, mail events, backups.
+- Lengthening log retention past the operator's limit (#1024 archive
+ tier).
+- Regional placement of statistics and logs.