carlos / platform Public

spec rev 3: Paul's rulings on round 2, and the PDF on headed paper

Identity gate with guard test, console-set notice dates, auto-purge
through the one purge, 15-day console backups, acceptance bound to the
document shown, uncapped incident sender, hourly sweep re-admission,
census restored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9c0f92fc8ea5ae4e03bf9e0632d16cd1785d90b2 parent ecc65c5
2 files changed, +372 −88
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R3.md +106 −0
  • docs/superpowers/specs/2026-11-25-dpa-and-retention-design.md +266 −88

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-hWS6tX
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading golang.org/x/sys v0.49.0
go: downloading golang.org/x/crypto v0.58.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/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading golang.org/x/net v0.62.0
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.14
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.23
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.31
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/randutil v0.1.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/prometheus/client_golang v1.17.0
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/prometheus/procfs v0.12.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/klauspost/compress v1.20.2
go: downloading golang.org/x/net v0.62.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
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 github.com/google/uuid v1.6.0
go: downloading modernc.org/memory v1.11.0
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 github.com/dustin/go-humanize v1.0.1
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

Attributed to this commit: 41.9 g CO₂e (4,427,918 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on dpa-and-retention, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R3.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R3.md
new file mode 100644
index 000000000..86108fe3d
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-dpa-and-retention-R3.md
@@ -0,0 +1,106 @@
+# Review brief: DPA and customer-set retention spec, round 3 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 3
+
+Earlier rounds: round 1 `CODEX-FINDINGS-dpa-and-retention.md` (4 P1, 10 P2);
+round 2 `CODEX-FINDINGS-dpa-and-retention-R2.md` (3 P1, 5 P2). Rev 3 marks
+responses (R2-n).
+
+Stopping rule 2 triggered in round 2 for two fault families, and Paul ruled
+(2026-11-25, recorded in the spec's review history). Treat these as fixed
+scope; report only mechanisms that fail to honour them:
+- deletion revocation: one `identityGate` plus a guard test (§6.2);
+- notice before change: the console sets the terms/privacy date from actual
+ deliveries; the website itself is held back by a written rule, not code (§4.3);
+- app deletion: the trash sweep calls the Trash page's own purge (§6.5);
+- console backups: the policy says 15 days (§6.4).
+New in rev 3 at Paul's request: the record as a PDF on headed paper (§3.6, §3.8).
+
+First give one line per P1 and P2 from round 2: resolved, partly, or not.
+Carry every unresolved finding forward, then add new findings. A NOT READY
+must also say whether the P1s share one cause, and whether refusing the case
+up front or cutting the feature would remove them.
+
+## 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 5ca2a282e..017838dfa 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,11 +1,23 @@
# Data processing agreements and customer-set retention
-Status: draft rev 2, 2026-11-25. Branch `dpa-and-retention`.
+Status: draft rev 3, 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.
+Review history:
+
+- Round 1 (Astra, `CODEX-FINDINGS-dpa-and-retention.md`, 89a4b186):
+ NOT READY, 4 P1, 10 P2, all accepted, marked **(R1-n)**.
+- Round 2 (Astra, `CODEX-FINDINGS-dpa-and-retention-R2.md`, f8c67930):
+ NOT READY, 3 P1, 5 P2, marked **(R2-n)**. Two P1s repeated round 1's
+ fault families (R1-2 deletion revocation, R1-4 notice before change),
+ so stopping rule 2 applied and Paul chose, 2026-11-25:
+ - deletion: **one gate and a guard test** (§6.2);
+ - notice: **the console sets the date** from actual deliveries (§4.3);
+ - the new P1 on app deletion: **auto-purge after the trash period**
+ through the Trash page's own purge (§6.5);
+ - console backups: **say 15 days** in the policy (§6.4).
+- Paul, 2026-11-25: the record is a **PDF on headed paper** (§3.8).
+- Round 3 is the last in the budget.
## 1. Why
@@ -48,12 +60,12 @@ the DPA this work adds promise:
| 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) |
-| 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 |
+| Console backups gone within 8 days | **not true**: console.db snapshots are kept 7 days (`lease.go:95`, `ops/litestream.go:448`), then live 7 more as noncurrent versions (R2-4) | the policy says 15 days (§6.4, Paul) |
| Email account owners 30 days before a policy change that matters | **not built** | notices (§4) |
| DPA on request | **by email** | built in (§3) |
| 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: delete app data, backups included, within 30 days of deleting the app or account | **not for every app**: the trash sweep refuses an app with email estate or a provisioned store (`lifetimes_purge.go:236`, `release/trash.go:345`); only the Trash page's manual purge tears those down (`ownership.go:625`) (R2-3) | auto-purge through the same purge (§6.5) |
| 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
@@ -68,22 +80,26 @@ 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 at a stable, versioned URL
- sha256 TEXT NOT NULL, -- digest of the body at url when published (§3.4)
+ url TEXT NOT NULL, -- the human-readable page at a stable, versioned URL
+ body_url TEXT, -- 'dpa' only: the agreement as a bare HTML fragment (§3.8)
+ body TEXT, -- 'dpa' only: that fragment, sanitized, as fetched
+ sha256 TEXT NOT NULL, -- digest of the fetched bytes (body_url for 'dpa', else url) (§3.4)
summary TEXT NOT NULL, -- what changed, plain text, goes in the notice
published_at INTEGER NOT NULL,
- effective_at INTEGER NOT NULL,
+ effective_at INTEGER, -- NULL until known: set by the console for 'terms'/'privacy' (§4.3)
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. 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).
+Rows are append-only, apart from `effective_at` being set once (§4.3).
+With no `dpa` row the DPA pane does not render. The **first** row of a
+kind has `needs_notice = 0` and `effective_at = published_at`: there is
+nobody to notify. A later `dpa` row with `needs_notice = 1` names an
+`effective_at` at least 35 days after `published_at` (30 days of notice
+plus 5 for delivery); it is the earliest date, and §3.5 moves it later
+per account.
### 3.2 The account settings pane
@@ -110,6 +126,7 @@ dpa_acceptances(
id INTEGER PRIMARY KEY,
account_id INTEGER NOT NULL,
document_id INTEGER NOT NULL REFERENCES legal_documents(id),
+ letterhead_id INTEGER NOT NULL REFERENCES letterhead(id),
legal_name TEXT NOT NULL,
address TEXT NOT NULL,
country TEXT NOT NULL, -- ISO 3166-1 alpha-2
@@ -123,24 +140,35 @@ dpa_acceptances(
```
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 form offers the **newest published** `dpa` document, including one
+published but not yet effective: an owner accepting during a notice
+period sees that version's summary and accepts it directly, so they are
+owed no notice for it.
+
+**The acceptance names what was shown (R2-7).** The form carries the
+document's `id` and `sha256` as hidden fields. The POST, and the
+step-up replay of it (`stepup.go:325` parks and replays the form),
+accepts only if that id is still the newest `dpa` document and the
+digest matches. Otherwise nothing is recorded and the pane re-renders
+with the newer text and "A new version was published while you were
+reading. Review it and accept again." The record stores the id it was
+given, never "whatever is newest now".
The acceptance writes an audit row (`dpa.accept`, empty app) and emails
-the accepting owner a confirmation with the record's fields, the URL
-and its digest.
+the accepting owner a confirmation with the record's fields, the
+document's URL and digest, and a link to download the PDF (§3.8). The
+console's mail is plain text without attachments, so the PDF is a link,
+not an attachment.
-`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.
+`GET /a/{sqid}/settings/dpa` (member-readable) shows the record: the
+operator, the customer details, version, URL, digest, who accepted and
+when, a **Download PDF** button (§3.8), and a print stylesheet as the
+fallback when no PDF engine is configured.
### 3.4 Pinning the text (R1-5)
-Publishing fetches `url` once and stores the SHA-256 of the body. The
+Publishing fetches the document once (`body_url` for a `dpa`, `url`
+otherwise) and stores the SHA-256 of the bytes. 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
@@ -169,20 +197,76 @@ skipped versions, and an account created during the notice period
An objection under the DPA is handled by email; the console records
nothing for it in this work.
-### 3.6 Operator settings
+### 3.6 The letterhead
-`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.
+The operator sets the letterhead once, from `/fleet/legal`
+(`operatorOnly` + `requireFreshAuth`):
+
+```
+letterhead(
+ id INTEGER PRIMARY KEY, -- append-only; the newest row is current
+ logo BLOB, -- PNG or SVG, at most 200 KB; SVG sanitized (no script, no external refs)
+ logo_type TEXT,
+ entity TEXT NOT NULL, -- e.g. 'Team Tito Limited'
+ registered_office TEXT NOT NULL,
+ company_number TEXT NOT NULL,
+ signatory TEXT NOT NULL, -- e.g. 'For and on behalf of Team Tito Limited'
+ privacy_address TEXT NOT NULL, -- e.g. privacy@carloku.com
+ footer TEXT, -- e.g. 'Carloku is run by Team Tito Limited.'
+ created_at INTEGER NOT NULL,
+ created_by TEXT NOT NULL
+)
+```
+
+No letterhead: no pane renders, and `/fleet/legal` says why. Each
+acceptance records the `letterhead.id` current when it was made, so its
+PDF always carries the letterhead it was accepted under. (This replaces
+rev 2's two environment variables.)
### 3.7 The operator list
`/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`.
+accepted by, when), the letterhead form (§3.6) with a sample PDF, and
+the incident form (§4.4). Nothing to approve. A rail entry in `opRail`.
+
+### 3.8 The PDF on headed paper
+
+`GET /a/{sqid}/settings/dpa.pdf` (member-readable, the same gates as
+the record page, plus the write rate limit as a cost bound) returns the
+executed agreement as a PDF:
+
+1. **Page header** on every page: the letterhead logo and entity name;
+ **page footer**: registered office, company number, the footer line,
+ "Version {v}" and "Page n of m".
+2. **The agreement**, from the stored `body` of the accepted document,
+ with the parties filled in: the operator from the letterhead, the
+ customer from the record.
+3. **Execution page**: for the customer, legal name, address, country,
+ signer's name and role, "Accepted electronically in the {operator}
+ console by {accepted_by} on {date, UTC}"; for the operator, the
+ letterhead's signatory line and "Formed on acceptance"; then the
+ document URL, its SHA-256, and the record's id.
+
+The console builds one self-contained HTML document from a template in
+`internal/console/templates` (no external resources: the logo is a
+`data:` URI, fonts are the PDF engine's own) and posts it to the PDF
+engine it already proxies for tenants (`Config.PDFEngine`,
+`forms/chromium/convert/html`), as an operator call: not metered against
+the account, a 30-second deadline, a 10 MiB response limit. It renders
+on each request; nothing is cached or stored, since the inputs are all
+immutable rows. With no engine configured, the button is hidden and the
+record page's print stylesheet is the fallback.
+
+**The stored body.** The flagship publishes each version twice: the
+site page at `/dpa/{version}/` and the agreement alone, a bare HTML
+fragment, at `/dpa/{version}/agreement.html`. Publishing fetches the
+fragment through the guarded client (§3.4), digests the raw bytes, and
+stores it after an allow-list sanitize (headings, paragraphs, lists,
+links, emphasis; nothing else survives). The PDF and the digest
+therefore describe exactly the text the customer accepted, whatever
+happens to the website later.
## 4. Notices (R1-4, R1-6, R1-13)
@@ -237,6 +321,13 @@ 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`.
+"Delivered" means the transport accepted the message (`s.deliver`
+returned nil). A later bounce does not undo it: the notice went to the
+address on file.
+
+Incident notices (§4.4) do not wait for the hourly pass or share its
+cap (R2-8): see §4.4.
+
### 4.3 Document notices
Publishing a document with `needs_notice = 1` creates its notice:
@@ -245,12 +336,28 @@ 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.
+**For `terms` and `privacy` the console sets the date (Paul, R2-2).**
+The operator does not choose `effective_at`. The audience is fixed at
+publication: the owners of every account at that moment. The console
+sets `effective_at` once, to 30 days after the last of those deliveries
+is accepted by the transport, and from then on shows it on
+`/fleet/legal`. Until then `/fleet/legal` reads "Upcoming: date set
+once every owner has been emailed", with the count still outstanding.
+The notice email cannot know the final date, so it says "applies no
+earlier than {published_at + 35 days}; the date will be on {url}", and
+the operator puts the console's date on the site page. An owner who joins after publication gets the notice too,
+but is not in the fixed audience and does not move the date. An
+account deleted before its delivery leaves the audience.
+
+The console cannot hold back carloku.com: changing the policy page on
+or after the console's date is a rule for us, written into the carloku
+repo's AGENTS.md beside the website deploy instructions. The website
+deploy is manual already, so this is one more check in it, not a gate
+in code. That boundary is stated here so nobody mistakes the console's
+date for enforcement of the site.
+
+For `dpa`, §3.5's per-account rule makes late delivery safe by
+construction.
### 4.4 Incident notices
@@ -259,8 +366,14 @@ 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
+48 hours. Before saving, the form shows the number of recipients and
+the hours left before `aware_at + 48 h`. Saving starts a dedicated
+sender for that notice at once (R2-8): no per-hour cap, limited only by
+the transport's own send rate (SES allows at least 14 a second, so
+10,000 owners take about 12 minutes), with the same retry schedule,
+capped at 1 hour between attempts while the deadline is ahead. The
+hourly pass picks up anything left after a console restart, incident
+notices first. `/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,
@@ -316,8 +429,8 @@ 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)
+older than N days will be deleted, usually within a day." (R1-14,
+R2-5: no unconditional maximum is promised anywhere.)
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
@@ -360,12 +473,14 @@ dry run, and it already lists and deletes every object version
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.
+Timing (R2-5): admission changes from "once a day" to "once a day, or
+once an hour while the last pass left a backlog" (a non-empty saved
+cursor), so a large backlog after someone shortens retention drains at
+up to 24 bounded passes a day instead of one. The cursor records the
+family as well as the box, and a test covers resuming mid-family. The
+promise everywhere is "usually within a day"; nothing promises a hard
+maximum. A sweep with a backlog older than 3 days raises an operator
+alert, and `/fleet/legal` shows the last complete pass's date.
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
@@ -377,9 +492,13 @@ IAM: the console's version delete under `apps/*/*/analytics/` is
`enable_retention_version_prune` (old name kept as an alias for one
release).
-### 5.5 What changes on boxes
+### 5.5 What changes on boxes, and the census (R2-6)
-Nothing. This removes the census work the first revision had.
+No box behaviour changes. The census still applies: `internal/analytics`
+is linked into the root binary (`apimode.go:37`), and the IAM widening
+is a file under `infra/`. Slice 3 carries a census card for both, and
+its independent review covers the widened version-delete authority on
+production storage.
### 5.6 Mail events (R1-10)
@@ -414,12 +533,35 @@ dispositions known now:
- 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.
+- **One identity gate (Paul's ruling on R1-2/R2-1).** A user can be
+ created, or a credential minted, in exactly one place:
+ `identityGate(tx, address, attemptStartedAt)`. It refuses when a
+ deletion of that address committed after the attempt began, and runs
+ inside the same transaction as the insert it guards. Every path
+ calls it: `ResolveSignIn`'s create (`signinmethods_store.go:93`,
+ reached from `completeSigninSession`, `emailsignin.go:311`, after
+ the code is consumed at `:427`), session creation, `pollCLIAuth`'s
+ token insert (`authstore.go:720`), social and Keymail callbacks,
+ invitation acceptance, and agent-login links.
+- **What "began" means.** Each attempt already has a row with a
+ creation time: the email code, the CLI auth request, the OAuth state,
+ the invitation, the link. The gate takes that time, never "now".
+ A fresh sign-in started after the deletion passes, so the person can
+ register again later; only an attempt that predates the deletion is
+ refused.
+- **The marker.** Deletion writes `identity_deletions(subject_hmac,
+ deleted_at)`, the address under the console's existing HMAC key, and
+ the hourly worker removes rows older than the longest-lived attempt
+ (asserted by a test that reads every attempt TTL constant; today the
+ longest is the 7-day invitation, so markers are kept 8 days and the
+ privacy policy says so). Linked sign-in subjects (Keymail, social)
+ get a marker each.
+- **The guard test.** A source test lists every `INSERT INTO users`,
+ `sessions`, `cli_tokens` and sign-in-method statement in
+ `internal/console` and fails unless it sits in a function that calls
+ `identityGate` in the same transaction. A new minting path cannot
+ land without it. Plus an interleaving test per path: start the
+ attempt, delete the person, complete the attempt, expect refusal.
- Token validation (`CLITokenAddressContext`, `authstore.go:810`) needs
no join: deleting the tokens is enough once nothing can mint new
ones.
@@ -435,19 +577,43 @@ same action for requests that arrive by email (`operatorOnly` +
### 6.4 Console backups
-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.
+Deleted rows leave the console's backups within 15 days (Paul, R2-4):
+console.db snapshots are kept 7 days (`lease.go:95`, applied box-wide
+including console.db, `ops/litestream.go:448`), and once a snapshot is
+removed the bucket keeps it 7 more days as a noncurrent version. One
+day of margin covers the hourly snapshot and lifecycle timing. Slice 4
+measures it on dev before the policy changes. The policy says 15 days;
+nothing in the platform changes.
### 6.5 App data after deleting an app or account (R1-9)
-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.
+The DPA promises 30 days.
+
+**Auto-purge through the one purge (Paul's ruling on R2-3).** Today the
+trash sweep refuses apps with email estate or a provisioned store and
+waits for a person on the Trash page. The Trash page's purge
+(`ownership.go`, from the mail-estate check through `purgeAppStores`
+and the mail teardown to the prefix sweep) moves into one function,
+`purgeApp(ctx, acct, app, actor)`, with every guard it has today. The
+page calls it with the person as actor; the trash sweep calls it, once
+the trash period ends, with the system as actor, instead of refusing.
+"One purge rule, never a second deleter with weaker guards" (the
+sweep's own comment) still holds: there is still exactly one deleter.
+A purge that fails part-way keeps the records and retries on the next
+sweep, as re-entering the page does today. The control-plane and fleet
+seed refusals stay. An app still in the trash 7 days after its period
+ended raises an operator alert with the last error.
+
+This is termination behaviour on production storage, so the task gets
+its own review (stopping rule 3).
+
+**Measurement.** Slice 4 measures the worst case on dev for an app with
+a database, an object store and an email service: the trash period,
+the purge, every object becoming noncurrent, and the 7-day noncurrent
+expiry. Litestream's snapshot retention applies only while a
+replicator runs; the purge 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)
@@ -475,46 +641,58 @@ must match:
## 8. Copy changes outside the console
-- carloku `/dpa/` and `/dpa/{version}/`: new (§7).
+- carloku `/dpa/`, `/dpa/{version}/` and `/dpa/{version}/agreement.html`:
+ new (§7, §3.8).
- 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.
+ line gains "or delete your sign-in yourself in the console" and says
+ a scrambled marker of the address is kept 8 days; backups "within 8
+ days" becomes "within 15 days" (§6.4); where visitor and log data is
+ kept (§7) is stated.
- Published as a new `privacy` document with notice (§4.3).
+- carloku `AGENTS.md`: change a policy page only on or after the
+ console's date (§4.3).
- `docs/site`: the console guide gains the panes.
## 9. Slices
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,
+1. **DPA acceptance.** `legal_documents` with the guarded fetch and
+ stored body, `letterhead`, `/fleet/legal` (documents, letterhead,
+ list), the settings pane with the id-and-digest binding,
+ `dpa_acceptances`, the record page, the confirmation email,
+ `dpaInForce` with its table test (notices treated as absent until
+ slice 3). Witness on dev: set a letterhead, publish, accept from a
+ test account, see it on `/fleet/legal`, open the record.
+2. **The PDF on headed paper** (§3.8). Witness: download it on dev and
+ check every page header, footer and the execution page.
+3. **Notices.** `notices`, `notice_deliveries`, the hourly pass,
+ document notices (the 35-day DPA rule, the console-set date for
+ terms and privacy), incident notices with their own sender,
`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.
+4. **Retention.** `retention_settings`, the panes, the sweep over three
+ families with hourly re-admission on backlog, the IAM widening, the
+ census card, 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).
+5. **Deleting.** The inventory test, `identityGate` and its guard and
+ interleaving tests, the transaction, self-serve and operator; the
+ one `purgeApp` and auto-purge from the trash sweep (own review);
+ the measurements in §6.4 and §6.5.
+6. **Flagship switch-on (Paul's go).** Letterhead, 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.
- Recording objections in the console.
-- A generated PDF of the record.
+- Attaching the PDF to email (the console's mail has no attachments).
- Acceptance of terms at sign-up.
- Lengthening log retention past the operator's limit (#1024 archive
tier).
- Regional placement of statistics and logs.
+- Holding back the carloku.com website in code (§4.3).