console: the DPA record page
Task 6 of the DPA acceptance plan (spec 3.3). GET /a/{sqid}/settings/dpa
shows, to any member, the acceptance in force: customer, signer, time,
the version accepted with its URL, the version in force, the shortened
fingerprint, and the processor from the acceptance's own letterhead and
document. An owner with no acceptance sees the none line and a link to
settings; any other member gets the plain 404.
Copy rows DPA-C27 to DPA-C41; a no-print class for the console header and
the page's buttons with a styleguide entry; claim, route and parity
censuses updated.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
docs/console-styleguide.md+11 −0docs/parity.md+1 −1internal/console/approved_dpa_copy_test.go+4 −0internal/console/claim_invariant_fixtures_test.go+1 −0internal/console/claim_invariant_probes_read_test.go+1 −0internal/console/dparecord.go+133 −0internal/console/dparecord_test.go+121 −0internal/console/routedecls.go+1 −0internal/console/server.go+2 −0internal/console/templates/console_chrome.html+4 −1internal/console/templates/dpa_record.html+24 −0internal/console/testdata/claim-routes.txt+1 −0parity/parity.tsv+1 −1
Intent
<task-notification> <task-id>ab1940c587d8f4f70</task-id> <tool-use-id>toolu_018u4gKqoCweWuwi84uLrRdL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/260ddc60-0dfc-4cf8-8857-7688d6275097/tasks/ab1940c587d8f4f70.output</output-file> <status>completed</status> <summary>Agent "Implement Task 5: settings pane and accept" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Owners can accept the data processing agreement from account settings and members see the result. Nothing was pushed. Commit: `bbcdace3` "console: accept the DPA in account settings". The known stale `packed-refs.lock` message printed; `git log -1` confirms the commit and the tree is clean. Tests: the 9 tests from the brief plus 4 more pass, with the copy deck gate, styleguide, account settings, claim and parity census tests, and the new route's claim probe. Build, vet and gofmt are clean. With the id/digest/letterhead check turned off, the 3 stale-form tests fail, so they do catch a missing check. Concerns (details in the report): - **In-force date:** a later version that needs notice never takes effect in slice 1 (no notice lookup yet), so it stays on the "pending" line even after its date passes. - **Pending line:** the ". " after the "Read version N" link comes from the approved mockup, not from a deck row. - **Email:** a multi-line address is joined with ", " so the "Customer:" line stays on one line. - **Step-up stash:** while a step-up is pending, the stash holds the typed address briefly in `pending_actions`. That is how every stepped-up form works, but it is a second copy. - **Files beyond the brief:** to keep CI passing I also updated the claim route list, fixture and probe, `parity.tsv`, the regenerated `docs/parity.md`, and the styleguide entry. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/.superpowers/sdd/2026-11-25-dpa-acceptance/task-5-report.md</result> <usage><subagent_tokens>232213</subagent_tokens><tool_uses>101</tool_uses><duration_ms>1254082</duration_ms></usage> </task-notification>
<task-notification> <task-id>abdede8c9331ef8dd</task-id> <tool-use-id>toolu_01NcqhKtp5EWhwdG1JnWhNbK</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/260ddc60-0dfc-4cf8-8857-7688d6275097/tasks/abdede8c9331ef8dd.output</output-file> <status>completed</status> <summary>Agent "Review Task 5 (spec + quality)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>### Spec Compliance - ✅ **Gate order (risk a).** The order is session (`dpapane.go:298-302`) → 64 KiB body cap (`:303`) → `storeFormCSRF` (`:304`) → `owner` (`:307`) → `allowWrite` (`:311`) → `requireFreshAuth` last (`:315`). Nothing before the owner check reads `{sqid}`. A form-parse failure (400) or a CSRF failure (403) comes from `storeFormCSRF` (`storepage.go:85-96`), which checks only the session token, so it can't reveal whether an account exists. `owner` gives members and non-members the same `http.NotFound` (`server.go:3282-3293`). `TestDPAAcceptMemberGets404` (`dpapane_test.go:279-308`) checks member, non-member and an unrouted path for identical bytes and no Location header. - ✅ **Unescaped render (risk b).** `canonicalAgreement([]byte(doc.Body))` runs on exactly the bytes that are then wrapped in `template.HTML(doc.Body)` (`dpapane.go:211-216`). The body is rendered only in the form and "changed" states, and `renderDPAForm` allows "changed" only when the pane is already "form" (`:401`). It sits in a `div`, with a newline straight after `{{.Body}}` (`account_settings.html:233-234`). Every other field is a plain `string` and gets html/template escaping: the in-force line, the pending line (including the operator's summary), the privacy address, the typed form values, the country names and the hidden ids. The pending link `href="{{.URL}}"` is in an attribute context, so html/template sanitises the URL. The pane doesn't render the letterhead fields at all. - ✅ **Binding after step-up (risk c).** `resume` sends the parked form back through the router (`stepup.go:455-460`), so `handleDPAAccept` runs again and re-reads the newest dpa and current letterhead after the gates (`dpapane.go:324-338`). It compares those with the posted ids and digest (`:353`). Nothing captured before parking is trusted. `TestDPAAcceptStaleAfterStepUpReplay` (`dpapane_test.go:402-419`) covers this. - ✅ **Race between the re-read and `AcceptDPA` (risk d).** The row records `doc.ID` and `lh.ID` (`dpapane.go:362-366`), and those equal the posted values the owner saw. If a publish lands in that gap, the owner is recorded as accepting the version they actually read. The newer version then shows as pending, which is the same as accepting a moment earlier. I think that's acceptable. Two owners racing hit the partial unique index, which maps to `ErrDPAAlreadyInForce` (`legal_store.go:264-276`, `dpapane.go:369-373`). - ✅ **Email subject (risk e).** The legal name goes through `dpaField` with `lines=false`, which drops `unicode.IsControl` characters, including CR, LF and NEL (`dpapane.go:225-235`). `deliver` doesn't sanitise on its own, but its mail path sends subject and body as separate fields through SES's structured input (`consolemail.go:218-220`), not raw headers. No header injection path. - ✅ **Record URL (risk f).** It is built as `s.cfg.Origin + accountSettingsURL(sqid) + "/dpa"` (`dpapane.go:381`) and never uses `r.Host`. The test can't tell the two apart, since the fixture's Origin equals `ts.URL`, but the code is clearly right. - ✅ **Census and parity edits (risk g).** All of them only add lines: `claim-routes.txt:246`, `claim_invariant_fixtures_test.go:1132`, a new probe that checks for a real row (`claim_invariant_probes_nonapp_test.go:864-891`), `parity.tsv:185` and the regenerated `docs/parity.md`. No existing assertion was touched. Other parity rows already list `GET /a/{sqid}/settings` (`parity.tsv:133,180`). - ✅ **Validation.** Lengths are counted in runes, required after trimming, with limits of 200/500/100/100. Country must be a `countryNames` key. Errors are per field and typed values are kept (`dpapane.go:263-287`, template `:241-270`). - ✅ **"Already in force".** Both the pre-check (`:344-348`) and the `ErrDPAAlreadyInForce` branch (`:369-373`) redirect with the C19 flash. No second row is written. - ✅ **Audit.** Action `dpa.accept`, empty app, detail is `"version "+v` (`:379`). It uses `s.audit` rather than the `auditActivity` the brief named. That's equivalent here, and `s.audit` has about 160 existing callers. - ✅ **Email failure.** A failed delivery is only logged (`:384-388`). The address isn't logged or audited anywhere. - ✅ **Members.** Members see "inforce" or "none" and never the form (`:183-205`). With no letterhead or no dpa document there is no pane (`:170-172`). Splitting the template's `{{if .IsOwner}}` keeps Service credentials, Errors, Analytics and Delete owner-only (`account_settings.html:40,211,275`). - ✅ **Copy.** I checked C01–C26, C42 and C43 against the deck (`dpa-acceptance-copy.md:19-44,60-61`). They match byte for byte in the template (`account_settings.html:213-272`), the constants (`dpapane.go:31-35`) and the helpers (`:60-104`). - ✅ **CSS.** `.agreement` and `.dpa-form` are named classes in `console_chrome.html:236-255`, with a styleguide entry (`docs/console-styleguide.md:314-341`). The textarea uses `var(--field)` and the inputs' border, inset shadow and focus ring. - ⚠️ **Cannot verify from the diff: spec §3.2/§3.3 says the pane shows the agreement "with the parties filled in from the current letterhead and the details typed into the form".** The pane renders the stored body as is. The letterhead entity never appears on the form, yet the form binds `letterhead_id`. The brief and plan don't ask for the fill-in, and the approved mockup isn't in the tree, so I couldn't compare against it. This is for the controller or the whole-branch review to decide. ### Strengths - Security comments explain why the gate order and the re-check matter, not just what they do (`dpapane.go:207-216,289-296`). - The binding check comes before validation and before the "already" check, and the 409 re-render binds the new ids. The implementer forced the check off and confirmed the three stale tests fail. - `dpaField` drops control and bidi override characters while keeping line breaks in the address. That hardens both the email and the stored record. - A census probe records a real row through the production path, with the bound form, rather than just being listed. ### Issues #### Critical (Must Fix) None. #### Important (Should Fix) None. #### Minor (Nice to Have) 1. **Invisible characters in source.** `dpapane.go:259` writes the bidi range bounds as raw U+202A/U+202E/U+2066/U+2069 characters inside rune literals; I confirmed the bytes with `od`. They are invisible in review, and source scanners flag them as Trojan Source characters. The repo elsewhere writes escapes (`internal/grouproll/box.go:648`, `internal/billingstripe/client.go:244`). Use `'\u202a'`…`'\u202e'` and `'\u2066'`…`'\u2069'`. 2. **One branch untested.** The `ErrDPAAlreadyInForce` branch from `AcceptDPA` (`dpapane.go:369-373`) has no test. `TestDPAAcceptTwiceShowsInForce` (`dpapane_test.go:421-457`) exits through the `LiveDPA` pre-check at `:344`. A test that inserts the live row between the pre-check and the insert, or calls the store directly, would cover the race path. 3. **Dead link until Task 6.** The record link in the pane and the email (`dpapane.go:180,381`) points at `/a/{sqid}/settings/dpa`, which has no route until Task 6. That's expected from the plan order, but don't release between Task 5 and Task 6. 4. **Rate-limit message.** It starts lowercase and isn't from the DPA deck (`dpapane.go:312`). It copies `oplegal.go:311`'s existing wording, so it's consistent, but it sits outside "every user-facing string comes from the deck". 5. **Two line-separator characters kept.** U+2028 and U+2029 aren't `IsControl`, so they survive in single-line fields such as the legal name. They're harmless with SES structured send and HTML escaping, but stripping them along with the bidi characters would be tidier. ### Assessment **Task quality:** Approved **Reasoning:** All seven named risks check out. The gate order and identical 404, the canonical re-check right before `template.HTML`, the re-check after step-up replay, the recorded ids, the header safety, the origin-based URL and the census edits only adding lines are all verified by citation. What remains is cosmetic or test coverage, plus one gap between spec and brief (parties filled in) for the controller to decide.</result> <usage><subagent_tokens>102772</subagent_tokens><tool_uses>29</tool_uses><duration_ms>264503</duration_ms></usage> </task-notification>
Attributed to this commit: 18.9 g CO₂e (2,383,700 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/console-styleguide.md b/docs/console-styleguide.md| index fcc505dba..858d66a18 100644 |
| --- a/docs/console-styleguide.md |
| +++ b/docs/console-styleguide.md |
| @@ -340,6 +340,17 @@ A field's error is a `p.error` straight after the field. Use `.dpa-form` |
| only where one form collects several related details at once; a single |
| setting is a settings row. |
| +### Keeping chrome off the paper |
| + |
| +A page meant to be printed (the data processing agreement record) hides |
| +what is not the document: the console header carries `no-print`, and so |
| +does any row of buttons or links on the page. The class changes nothing on |
| +screen; in print it removes the element. |
| + |
| +```html |
| +<p class="no-print"><button type="button" onclick="window.print()">Print this record</button></p> |
| +``` |
| + |
| ### Variable rows and the save bar |
| A list of named values edited in place: one compact row per variable, an |
diff --git a/docs/parity.md b/docs/parity.md| index 8e59b4834..58a757f99 100644 |
| --- a/docs/parity.md |
| +++ b/docs/parity.md |
| @@ -28,7 +28,7 @@ CLI rows are checked against the command registry (`parity/cli.tsv`). |
| | auth-login | cli-only | `auth login` | | | Signs this terminal in; the browser half is an auth row. | |
| | auth-identity | cli-only | `auth whoami`<br>`auth logout`<br>`auth default` | | | This terminal's own identity and default console. | |
| | account-delete | console-only | | `POST /a/{sqid}/delete` | | Deleting an account needs a passkey. | |
| -| dpa-accept | console-only | | `GET /a/{sqid}/settings`<br>`POST /a/{sqid}/dpa/accept` | | An owner accepts the data processing agreement, and confirms with a passkey. | |
| +| dpa-accept | console-only | | `GET /a/{sqid}/settings`<br>`GET /a/{sqid}/settings/dpa`<br>`POST /a/{sqid}/dpa/accept` | | An owner accepts the data processing agreement, and confirms with a passkey. | |
| | plan-keep | gap | | `GET /a/{sqid}/plan/keep`<br>`POST /a/{sqid}/plan/keep` | [wp-cli-verbs](#wp-cli-verbs) | Choosing which apps to keep when a plan lapses. | |
| | getting-started | console-only | | `POST /a/{sqid}/getting-started/hide`<br>`POST /a/{sqid}/getting-started/show`<br>`POST /a/{sqid}/getting-started/skip`<br>`POST /a/{sqid}/getting-started/done` | | A checklist in the page. | |
| | nav-index | console-only | | `GET /a/{sqid}/index`<br>`GET /a/{sqid}/apps/{app}/index`<br>`GET /a/{sqid}/apps/{app}/settings/index` | | Phone navigation pages that list sections. | |
diff --git a/internal/console/approved_dpa_copy_test.go b/internal/console/approved_dpa_copy_test.go| index 45364b3a3..af211e840 100644 |
| --- a/internal/console/approved_dpa_copy_test.go |
| +++ b/internal/console/approved_dpa_copy_test.go |
| @@ -41,6 +41,10 @@ var dpaCopyBuilt = map[string]bool{ |
| "DPA-C16": true, "DPA-C17": true, "DPA-C18": true, "DPA-C19": true, "DPA-C20": true, |
| "DPA-C21": true, "DPA-C22": true, "DPA-C23": true, "DPA-C24": true, "DPA-C25": true, |
| "DPA-C26": true, "DPA-C42": true, "DPA-C43": true, |
| + // Task 6: the record page (dpa.record.*). |
| + "DPA-C27": true, "DPA-C28": true, "DPA-C29": true, "DPA-C30": true, "DPA-C31": true, |
| + "DPA-C32": true, "DPA-C33": true, "DPA-C34": true, "DPA-C35": true, "DPA-C36": true, |
| + "DPA-C37": true, "DPA-C38": true, "DPA-C39": true, "DPA-C40": true, "DPA-C41": true, |
| } |
| func parseDPACopyDeck(t *testing.T) []navCopyRow { |
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go| index 608aebb76..c749ea3b3 100644 |
| --- a/internal/console/claim_invariant_fixtures_test.go |
| +++ b/internal/console/claim_invariant_fixtures_test.go |
| @@ -860,6 +860,7 @@ var claimFixtures = map[string]claimFixture{ |
| "route GET /a/{sqid}/fleets/{fleet}": claimRead("renders one fleet's boxes and placements"), |
| "route GET /a/{sqid}/index": claimRead("renders the account's sections as a phone index"), |
| "route GET /a/{sqid}/settings": claimRead("renders account settings"), |
| + "route GET /a/{sqid}/settings/dpa": claimRead("renders the account's data processing agreement record; writes nothing"), |
| "route GET /a/{sqid}/plan/keep": claimRead("renders the keep page (plans 4d) from the plan row, lapse items and an inventory read; writes nothing"), |
| "route GET /a/{sqid}/team": claimRead("renders members and invites"), |
| "route GET /a/{sqid}/trash": claimRead("lists trashed apps; purge is the trash/delete door"), |
diff --git a/internal/console/claim_invariant_probes_read_test.go b/internal/console/claim_invariant_probes_read_test.go| index c96c8da03..1a07fa649 100644 |
| --- a/internal/console/claim_invariant_probes_read_test.go |
| +++ b/internal/console/claim_invariant_probes_read_test.go |
| @@ -217,6 +217,7 @@ var claimReadProbes = map[string]claimProbe{ |
| "route GET /a/{sqid}/fleets/{fleet}": claimPageRead(claimWorldFleet, "/a/bab/fleets/pi", "<h1>pi</h1>"), |
| "route GET /a/{sqid}/index": claimPageRead(nil, "/a/bab/index", `id="nav-apps"`), |
| "route GET /a/{sqid}/settings": claimPageRead(nil, "/a/bab/settings", "<h1>Account settings</h1>"), |
| + "route GET /a/{sqid}/settings/dpa": claimPageRead(nil, "/a/bab/settings/dpa", "<h1>Data processing agreement</h1>"), |
| "route GET /a/{sqid}/plan/keep": claimPageRead(claimWorldLapse, "/a/bab/plan/keep", "<h1>Choose what stays</h1>"), |
| "route GET /a/{sqid}/team": claimPageRead(nil, "/a/bab/team", "<h1>Team</h1>", claimFxOwner), |
| "route GET /a/{sqid}/trash": claimPageRead(func(t *testing.T, cx *claimCase) { cx.trash(t, "titogo") }, |
diff --git a/internal/console/dparecord.go b/internal/console/dparecord.go| new file mode 100644 |
| index 000000000..ed52a0019 |
| --- /dev/null |
| +++ b/internal/console/dparecord.go |
| @@ -0,0 +1,133 @@ |
| +package console |
| + |
| +import ( |
| + "errors" |
| + "log" |
| + "net/http" |
| + "strings" |
| +) |
| + |
| +// The record page for an account's data processing agreement (DPA and |
| +// retention spec §3.3): GET /a/{sqid}/settings/dpa. Any member may read |
| +// it. It shows the acceptance in force with the document and letterhead |
| +// the acceptance itself names, never the current ones. |
| + |
| +// dpaRecordView is what templates/dpa_record.html shows. With Live false |
| +// it is the owner's "none yet" page and the rest is empty. |
| +type dpaRecordView struct { |
| + Live bool // false: the owner's "none yet" page |
| + LegalName string |
| + AddressLines []string |
| + Country string |
| + AcceptedBy string |
| + When string |
| + Version string |
| + VersionURL string |
| + VersionShow string |
| + InForce string |
| + Digest string |
| + DigestShort string |
| + Processor string |
| + SettingsURL string |
| +} |
| + |
| +// dpaRecordWhenLayout is dpa.record.row.when's value format. |
| +const dpaRecordWhenLayout = "2 January 2006 at 15:04 UTC" |
| + |
| +// dpaRecordProcessorText is dpa.record.processor, then dpa.record.processor_vat |
| +// when the letterhead has a VAT number. |
| +func dpaRecordProcessorText(lh *Letterhead) string { |
| + t := lh.Entity + ", " + lh.RegisteredOffice + ". Company number " + lh.CompanyNumber + "." |
| + if lh.VATNumber != "" { |
| + t += " VAT number " + lh.VATNumber + "." |
| + } |
| + return t |
| +} |
| + |
| +// dpaShortDigest is a digest as first 4, an ellipsis and last 4. |
| +func dpaShortDigest(d string) string { |
| + r := []rune(d) |
| + if len(r) <= 9 { |
| + return d |
| + } |
| + return string(r[:4]) + "…" + string(r[len(r)-4:]) |
| +} |
| + |
| +// dpaURLNoScheme is a page URL as shown: without its scheme. |
| +func dpaURLNoScheme(u string) string { |
| + for _, p := range []string{"https://", "http://"} { |
| + if strings.HasPrefix(u, p) { |
| + return u[len(p):] |
| + } |
| + } |
| + return u |
| +} |
| + |
| +func (s *Server) handleDPARecord(w http.ResponseWriter, r *http.Request) { |
| + addr, raw, acct, role, ok := s.account(w, r) |
| + if !ok { |
| + return |
| + } |
| + fail := func(what string, err error) { |
| + log.Printf("console: dpa record %s: %s: %v", acct.Sqid, what, err) |
| + http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| + } |
| + live, err := s.store.LiveDPA(acct.ID) |
| + if err != nil { |
| + fail("live acceptance", err) |
| + return |
| + } |
| + v := &dpaRecordView{SettingsURL: accountSettingsURL(acct.Sqid)} |
| + if live == nil { |
| + if role != RoleOwner { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + } else { |
| + doc, err := s.store.LegalDocument(live.DocumentID) |
| + if err != nil { |
| + fail("document", err) |
| + return |
| + } |
| + lh, err := s.store.LetterheadByID(live.LetterheadID) |
| + if err != nil { |
| + fail("letterhead", err) |
| + return |
| + } |
| + docs, err := s.store.LegalDocuments("dpa") |
| + if err != nil { |
| + fail("documents", err) |
| + return |
| + } |
| + if doc == nil || lh == nil { |
| + fail("acceptance references", errDPARecordMissing) |
| + return |
| + } |
| + inForce := dpaInForce(*live, docs, nil, s.now()) |
| + if inForce.Version == "" { |
| + inForce.Version = doc.Version |
| + } |
| + country := live.Country |
| + if n, ok := countryNames[country]; ok { |
| + country = n |
| + } |
| + v.Live = true |
| + v.LegalName = live.LegalName |
| + v.AddressLines = strings.Split(strings.ReplaceAll(live.Address, "\r\n", "\n"), "\n") |
| + v.Country = country |
| + v.AcceptedBy = live.SignerName + ", " + live.SignerRole + " (" + live.AcceptedBy + ")" |
| + v.When = live.AcceptedAt.UTC().Format(dpaRecordWhenLayout) |
| + v.Version, v.VersionURL, v.VersionShow = doc.Version, doc.URL, dpaURLNoScheme(doc.URL) |
| + v.InForce = inForce.Version |
| + v.Digest, v.DigestShort = doc.SHA256, dpaShortDigest(doc.SHA256) |
| + v.Processor = dpaRecordProcessorText(lh) |
| + } |
| + p := s.accountPage(w, r, addr, raw, acct, role) |
| + p.Title = "Data processing agreement" |
| + p.ActiveNav = "settings" |
| + p.DPARecord = v |
| + s.render(w, http.StatusOK, "dpa_record", p) |
| +} |
| + |
| +// errDPARecordMissing: an acceptance names a document or letterhead that is gone. |
| +var errDPARecordMissing = errors.New("the acceptance names a document or letterhead that does not exist") |
diff --git a/internal/console/dparecord_test.go b/internal/console/dparecord_test.go| new file mode 100644 |
| index 000000000..73a350347 |
| --- /dev/null |
| +++ b/internal/console/dparecord_test.go |
| @@ -0,0 +1,121 @@ |
| +package console |
| + |
| +import ( |
| + "net/http" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +// The DPA record page (dparecord.go, spec §3.3). |
| + |
| +// dpaAcceptFor writes a live acceptance for the ops account directly. |
| +func dpaAcceptFor(t *testing.T, fx *consoleFixture, docID, lhID int64) DPAAcceptance { |
| + t.Helper() |
| + a := DPAAcceptance{ |
| + AccountID: OpsAccountID, DocumentID: docID, LetterheadID: lhID, |
| + LegalName: "Shop <Limited>", Address: "1 Main Street\nDublin", Country: "IE", |
| + SignerName: "Ada Lovelace", SignerRole: "Director", AcceptedBy: "paul@keymail.dev", |
| + AcceptedIP: "127.0.0.1", AcceptedAt: time.Date(2026, 11, 20, 9, 5, 0, 0, time.UTC), |
| + } |
| + if _, err := fx.st.AcceptDPA(a); err != nil { |
| + t.Fatal(err) |
| + } |
| + return a |
| +} |
| + |
| +func TestDPARecordMemberSees(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + if err := fx.st.AddMember(OpsAccountID, "kim@keymail.dev", RoleMember, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + docID, lhID := dpaWorld(t, fx) |
| + dpaAcceptFor(t, fx, docID, lhID) |
| + // A newer letterhead and a newer, not yet effective version must not |
| + // leak into the record of what was accepted. |
| + dpaLetterhead(t, fx, "Newer Hosting Limited") |
| + member, _ := signInAs(t, fx, "kim@keymail.dev", "code-dpa-record-member") |
| + status, _, raw := get(t, member, fx.u("/settings/dpa")) |
| + if status != http.StatusOK { |
| + t.Fatalf("record = %d:\n%s", status, raw) |
| + } |
| + if strings.Contains(raw, "Shop <Limited>") { |
| + t.Errorf("legal name not escaped:\n%s", raw) |
| + } |
| + body := oplText(raw) |
| + digest := oplDigest([]byte(oplFragment)) |
| + for _, want := range []string{ |
| + oplDeck(t, "DPA-C27"), oplDeck(t, "DPA-C28"), oplDeck(t, "DPA-C38"), |
| + "<th>" + oplDeck(t, "DPA-C29") + "</th>", "<th>" + oplDeck(t, "DPA-C35") + "</th>", |
| + "Shop <Limited><br>1 Main Street<br>Dublin<br>Ireland", |
| + "Ada Lovelace, Director (paul@keymail.dev)", |
| + "20 November 2026 at 09:05 UTC", |
| + `1 (<a href="https://example.com/dpa/1/">example.com/dpa/1/</a>)`, |
| + `<code title="` + digest + `">` + digest[:4] + "…" + digest[len(digest)-4:] + "</code>", |
| + "Example Hosting Limited, 1 Main Street, Dublin. Company number 123456.", |
| + `<a class="btn btn-secondary" href="` + fx.path("/settings") + `">` + oplDeck(t, "DPA-C40") + "</a>", |
| + `<button type="button" onclick="window.print()">` + oplDeck(t, "DPA-C39") + "</button>", |
| + } { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("record lacks %q:\n%s", want, body) |
| + } |
| + } |
| + if strings.Contains(body, "Newer Hosting") { |
| + t.Errorf("record shows the current letterhead, not the accepted one") |
| + } |
| +} |
| + |
| +func TestDPARecordCopy(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInPaul(t, fx) |
| + docID := dpaPublish(t, fx, "1", oplFragment, time.Now().Add(-time.Hour)) |
| + lh, err := fx.st.SetLetterhead(Letterhead{ |
| + Entity: "Example Hosting Limited", RegisteredOffice: "1 Main Street, Dublin", CompanyNumber: "123456", |
| + VATNumber: "IE1234567X", Signatory: "For Example", PrivacyAddress: "privacy@example.com", |
| + CreatedBy: "paul@keymail.dev", CreatedAt: time.Now(), |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + dpaAcceptFor(t, fx, docID, lh) |
| + _, _, raw := get(t, c, fx.u("/settings/dpa")) |
| + body := oplText(raw) |
| + want := oplDeck(t, "DPA-C36", "entity", "Example Hosting Limited", "office", "1 Main Street, Dublin", "company_number", "123456") + |
| + " " + oplDeck(t, "DPA-C37", "vat_number", "IE1234567X") |
| + if !strings.Contains(body, "<td>"+want+"</td>") { |
| + t.Errorf("processor cell is not %q:\n%s", want, body) |
| + } |
| +} |
| + |
| +func TestDPARecordNonMember404(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + docID, lhID := dpaWorld(t, fx) |
| + dpaAcceptFor(t, fx, docID, lhID) |
| + stranger, _ := signInAs(t, fx, "eve@keymail.dev", "code-dpa-record-stranger") |
| + ss, _, sbody := get(t, stranger, fx.u("/settings/dpa")) |
| + _, _, unrouted := get(t, stranger, fx.ts.URL+"/no/such/path") |
| + if ss != http.StatusNotFound || sbody != unrouted { |
| + t.Fatalf("non-member = %d, want the byte-identical 404", ss) |
| + } |
| +} |
| + |
| +func TestDPARecordNoneYet(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + if err := fx.st.AddMember(OpsAccountID, "kim@keymail.dev", RoleMember, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + dpaWorld(t, fx) |
| + owner := signInPaul(t, fx) |
| + status, _, raw := get(t, owner, fx.u("/settings/dpa")) |
| + body := oplText(raw) |
| + if status != http.StatusOK || !strings.Contains(body, oplDeck(t, "DPA-C41")) || |
| + !strings.Contains(body, `href="`+fx.path("/settings")+`"`) { |
| + t.Fatalf("owner none page = %d:\n%s", status, body) |
| + } |
| + member, _ := signInAs(t, fx, "kim@keymail.dev", "code-dpa-record-none") |
| + ms, _, mbody := get(t, member, fx.u("/settings/dpa")) |
| + _, _, unrouted := get(t, member, fx.ts.URL+"/no/such/path") |
| + if ms != http.StatusNotFound || mbody != unrouted { |
| + t.Fatalf("member without a record = %d, want the plain 404", ms) |
| + } |
| +} |
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go| index 4a44dffb3..2490684ba 100644 |
| --- a/internal/console/routedecls.go |
| +++ b/internal/console/routedecls.go |
| @@ -118,6 +118,7 @@ var routeDecls = []routeDecl{ |
| {Pattern: "POST /fleet/store/{account}/{decision}", Handler: (*Server).handleStoreDecisionPage}, |
| {Pattern: "POST /a/{sqid}/store/apply", Handler: (*Server).handleStoreApplyPage}, |
| {Pattern: "POST /a/{sqid}/dpa/accept", Handler: (*Server).handleDPAAccept}, |
| + {Pattern: "GET /a/{sqid}/settings/dpa", Handler: (*Server).handleDPARecord}, |
| {Pattern: "GET /fleet/metrics", Handler: (*Server).handleFleetMetrics}, |
| // Fleet alerts (alertpages.go): the operator pages, same gate. Their |
| // writes are registered without a method, as the economics doors below |
diff --git a/internal/console/server.go b/internal/console/server.go| index e025a2c53..9832eacf7 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -2378,6 +2378,8 @@ type page struct { |
| // DPA is the account settings page's Data processing agreement |
| // section (dpapane.go); nil means no section. |
| DPA *dpaPane |
| + // DPARecord is the DPA record page (dparecord.go). |
| + DPARecord *dpaRecordView |
| // RegionLine is the Instances tab's app-region note (C7 or C8, spec |
| // §10); "" shows nothing. RegionLineWarn marks C8. |
diff --git a/internal/console/templates/console_chrome.html b/internal/console/templates/console_chrome.html| index 5174aa4d5..ea9418ea0 100644 |
| --- a/internal/console/templates/console_chrome.html |
| +++ b/internal/console/templates/console_chrome.html |
| @@ -253,6 +253,9 @@ |
| @media (pointer: coarse) { .dpa-form textarea { font-size: max(16px, 1rem); } } |
| .dpa-form .error { margin: 0.3rem 0 0; } |
| .dpa-form button { margin: 1.25rem 0 0.5rem; } |
| + /* Printing a record page (dpa_record.html): the console header and the |
| + page's buttons stay off the paper. */ |
| + @media print { .no-print { display: none !important; } } |
| .settings-layout { |
| display: grid; grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr); |
| gap: 2.5rem; align-items: start; |
| @@ -1206,7 +1209,7 @@ |
| } |
| {{end}} |
| -{{define "console_header"}}<header> |
| +{{define "console_header"}}<header class="no-print"> |
| {{if .Account}} |
| <details class="switcher" id="switcher"> |
| <summary> |
diff --git a/internal/console/templates/dpa_record.html b/internal/console/templates/dpa_record.html| new file mode 100644 |
| index 000000000..d68807b3b |
| --- /dev/null |
| +++ b/internal/console/templates/dpa_record.html |
| @@ -0,0 +1,24 @@ |
| +{{define "dpa_record"}}{{template "top" .}} |
| +{{with .DPARecord}}<div class="pagehead"> |
| + <p class="eyebrow">Account · {{$.Account.Name}}</p> |
| + <h1>Data processing agreement</h1> |
| + <p class="lede">The record of what was accepted, and by whom.</p> |
| +</div> |
| +{{if .Live}}<div class="tablewrap"> |
| +<table> |
| + <tr><th>Customer</th><td>{{.LegalName}}<br>{{range .AddressLines}}{{.}}<br>{{end}}{{.Country}}</td></tr> |
| + <tr><th>Accepted by</th><td>{{.AcceptedBy}}</td></tr> |
| + <tr><th>When</th><td>{{.When}}</td></tr> |
| + <tr><th>Version accepted</th><td>{{.Version}} (<a href="{{.VersionURL}}">{{.VersionShow}}</a>)</td></tr> |
| + <tr><th>Version in force</th><td>{{.InForce}}</td></tr> |
| + <tr><th>Fingerprint of the text</th><td><code title="{{.Digest}}">{{.DigestShort}}</code></td></tr> |
| + <tr><th>Processor</th><td>{{.Processor}}</td></tr> |
| +</table> |
| +</div> |
| +<p class="small">The fingerprint changes if a single character of the agreement changes, so it proves which text was accepted.</p> |
| +<p class="no-print"><button type="button" onclick="window.print()">Print this record</button> |
| +<a class="btn btn-secondary" href="{{.SettingsURL}}">Back to settings</a></p> |
| +{{else}}<p>No agreement is in force yet. You can accept one in account settings.</p> |
| +<p class="no-print"><a class="btn btn-secondary" href="{{.SettingsURL}}">Back to settings</a></p> |
| +{{end}}{{end}} |
| +{{template "bottom" .}}{{end}} |
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt| index 51e60b9c2..87c2ee1e8 100644 |
| --- a/internal/console/testdata/claim-routes.txt |
| +++ b/internal/console/testdata/claim-routes.txt |
| @@ -64,6 +64,7 @@ route GET /a/{sqid}/fleets/{fleet} |
| route GET /a/{sqid}/index |
| route GET /a/{sqid}/plan/keep |
| route GET /a/{sqid}/settings |
| +route GET /a/{sqid}/settings/dpa |
| route GET /a/{sqid}/team |
| route GET /a/{sqid}/trash |
| route GET /a/{sqid}/{$} |
diff --git a/parity/parity.tsv b/parity/parity.tsv| index 83792b08d..6dc7840cd 100644 |
| --- a/parity/parity.tsv |
| +++ b/parity/parity.tsv |
| @@ -182,7 +182,7 @@ cli-tokens account gap GET /settings ; GET /auth/cli/tokens ; POST /auth/cli/to |
| auth-login account cli-only auth login Signs this terminal in; the browser half is an auth row. |
| auth-identity account cli-only auth whoami ; auth logout ; auth default This terminal's own identity and default console. |
| account-delete account console-only POST /a/{sqid}/delete Deleting an account needs a passkey. |
| -dpa-accept account console-only GET /a/{sqid}/settings ; POST /a/{sqid}/dpa/accept An owner accepts the data processing agreement, and confirms with a passkey. |
| +dpa-accept account console-only GET /a/{sqid}/settings ; GET /a/{sqid}/settings/dpa ; POST /a/{sqid}/dpa/accept An owner accepts the data processing agreement, and confirms with a passkey. |
| plan-keep account gap GET /a/{sqid}/plan/keep ; POST /a/{sqid}/plan/keep wp-cli-verbs Choosing which apps to keep when a plan lapses. |
| getting-started account console-only POST /a/{sqid}/getting-started/hide ; POST /a/{sqid}/getting-started/show ; POST /a/{sqid}/getting-started/skip ; POST /a/{sqid}/getting-started/done A checklist in the page. |
| nav-index account console-only GET /a/{sqid}/index ; GET /a/{sqid}/apps/{app}/index ; GET /a/{sqid}/apps/{app}/settings/index Phone navigation pages that list sections. |