oficina / memoria Public

WIP: rhythm checkpoint 2

Paul Campbell pushed by claude agent, operated by paul@keymail.dev f61911925524ac0655c4028cd1a3262241e321d7 parent a0e8d90
10 files changed, +83 −30
  • .amadan/ci.d/50-spacing +2 −0
  • Makefile +16 −4
  • internal/memoria/auth.go +10 −0
  • internal/memoria/signin_browser_test.go +1 −1
  • internal/memoria/signin_door_states_test.go +2 −2
  • internal/memoria/static/memoria.css +21 −16
  • internal/memoriatest/gates_test.go +6 −0
  • internal/memoriatest/rhythm_browser_test.go +14 −5
  • internal/memoriatest/signin_keymail_test.go +5 −2
  • internal/memoriatest/signindial_test.go +6 −0
diff --git a/.amadan/ci.d/50-spacing b/.amadan/ci.d/50-spacing
new file mode 100755
index 0000000..53c0bd3
--- /dev/null
+++ b/.amadan/ci.d/50-spacing
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec make spacing
diff --git a/Makefile b/Makefile
index 2889fde..96169ef 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ RELEASE_GOOS ?= linux
RELEASE_GOARCH ?= arm64
RELEASE_BIN := releases/$(APP)-$(RELEASE_GOOS)-$(RELEASE_GOARCH)
-.PHONY: build release deps test vet fmt-check migration-check ci browser
+.PHONY: build release deps test vet fmt-check migration-check spacing ci browser
# build is the compile check: with more than one package matched, go
# build discards the output, so this catches a broken package without
@@ -102,6 +102,16 @@ fmt-check:
migration-check:
go tool rastrillo migration check
+# spacing is Fiesta's stylesheet half of the spacing rhythm (Paul,
+# 2026-11-22): every margin, padding and gap in static/ is a
+# var(--rst-sp-N) step, or says why not with /* spacing-allow: why */.
+# tokens.css is rastrillo's, vendored and pinned byte for byte
+# (TestVendoredAssetsMatchTheLibrary), so it is skipped; estilo's files
+# are read like Memoria's own. The rendered half is the rhythm audit,
+# TestEveryScreenKeepsTheRhythm, in make browser.
+spacing:
+ go tool fiesta spacing -skip tokens.css internal/memoria/static
+
# ci is the one gate: what a runner executes and what you run before
# pushing are the same definition. amadan's runner falls back to this
# target when .amadan/ci is absent; ci.d/ carries the same targets,
@@ -109,7 +119,7 @@ migration-check:
# fails the build the moment models.go and migrations/ disagree,
# instead of at boot on whatever machine notices next. If the app
# declares manifest resources, also add: rastrillo generate --check
-ci: vet fmt-check test migration-check
+ci: vet fmt-check test migration-check spacing
# The browser checks (internal/memoriatest/*_browser_test.go), in a real
# Chromium through chromedp. Deliberately NOT part of `ci`: the gate
@@ -117,14 +127,16 @@ ci: vet fmt-check test migration-check
# change to the CSS or to rastrillo's pin; TestNoZoomOnTap is the iOS
# zoom-on-tap check, and TestPagesRenderUnderTheProductionCSP is the one
# browser check served through rastrillo's production stack, so it sees
-# the real CSP. TestSmartDoorInABrowser (internal/memoria) draws every
+# the real CSP. TestEveryScreenKeepsTheRhythm and TestTheDoorKeepsTheRhythm
+# are Fiesta's rhythm audit over every screen at 1280px and 390px.
+# TestSmartDoorInABrowser (internal/memoria) draws every
# sign-in state at 320px and 1280px, forced light. The Chromium comes from
# RASTRILLO_CHROME, or on a Mac from the Playwright cache: Chromium.app,
# or Google Chrome for Testing.app, found by the shell because the path
# has spaces and make's wildcard splits on them (Calendar's fix).
RASTRILLO_CHROME ?= $(shell for p in "$(HOME)"/Library/Caches/ms-playwright/chromium-*/chrome-mac*/Chromium.app/Contents/MacOS/Chromium "$(HOME)"/Library/Caches/ms-playwright/chromium-*/chrome-mac*/"Google Chrome for Testing.app"/Contents/MacOS/"Google Chrome for Testing"; do [ -x "$$p" ] && { echo "$$p"; break; }; done)
browser:
- RASTRILLO_CHROME="$(RASTRILLO_CHROME)" CGO_ENABLED=0 go test -tags browser -count=1 -run 'OnTap|ProductionCSP|NoSidewaysScroll|TypingSuggestsAndEnterAnswers|WholeResultIsALink|StaleAIAnswer|AnswerSlotSettles|ThumbsUp|TypeaheadAnswerCopies|AWholeRowOpens|ClearEmptiesTheBox' ./internal/memoriatest/
+ RASTRILLO_CHROME="$(RASTRILLO_CHROME)" CGO_ENABLED=0 go test -tags browser -count=1 -run 'OnTap|ProductionCSP|NoSidewaysScroll|TypingSuggestsAndEnterAnswers|WholeResultIsALink|StaleAIAnswer|AnswerSlotSettles|ThumbsUp|TypeaheadAnswerCopies|AWholeRowOpens|ClearEmptiesTheBox|KeepsTheRhythm' ./internal/memoriatest/
RASTRILLO_CHROME="$(RASTRILLO_CHROME)" CGO_ENABLED=0 go test -tags browser -count=1 -run 'SmartDoorInABrowser' ./internal/memoria/
.PHONY: credits
diff --git a/internal/memoria/auth.go b/internal/memoria/auth.go
index 1a677e9..949b701 100644
--- a/internal/memoria/auth.go
+++ b/internal/memoria/auth.go
@@ -166,6 +166,14 @@ type AuthEnv struct {
Mailer mail.Sender
Owners []string
HomeEnabled bool
+ // KeymailServers is rastrillo's auth.Config.KeymailServers, and nil
+ // in production: any server an address's own _keymail delegation
+ // names, dialled only at a public address (rastrillo v0.45.0). A test
+ // lists its fake's host, because the listed-servers client is the one
+ // that sends through the process's default transport, where the fake
+ // sits; the public-only client copies the real transport when auth is
+ // built and would never reach it.
+ KeymailServers []string
}
// ParseOwners splits a comma-separated allowlist, lowercasing and
@@ -242,6 +250,8 @@ func NewAuth(sqlDB *sql.DB, env AuthEnv, logger *slog.Logger, a *app) (*auth.Aut
InstanceKey: env.InstanceKey,
Mailer: env.Mailer,
Authorize: a.Admit,
+ // Nil outside tests (AuthEnv.KeymailServers).
+ KeymailServers: env.KeymailServers,
// A verified address Admit refuses gets the door, with the
// refusal on it, in auth's own 403 (app.refused) — not
// rastrillo's bare-text "verified but not admitted".
diff --git a/internal/memoria/signin_browser_test.go b/internal/memoria/signin_browser_test.go
index 527c7c1..4f36802 100644
--- a/internal/memoria/signin_browser_test.go
+++ b/internal/memoria/signin_browser_test.go
@@ -172,7 +172,7 @@ func TestSmartDoorInABrowser(t *testing.T) {
{name: "step-up", path: "/signin?reauth=1", heading: "Sign in to Memoria"},
{name: "sent", path: "/signin?sent=1", heading: "Check your email"},
{name: "confirm", path: confirm, heading: "Sign in to Memoria"},
- {name: "continuation", path: continuePreviewPath, heading: "Taking you to Keymail"},
+ {name: "continuation", path: continuePreviewPath, heading: "Signing you in"},
{name: "signed out", path: "/signed-out", heading: "You’re signed out"},
} {
for _, width := range []int64{320, 1280} {
diff --git a/internal/memoria/signin_door_states_test.go b/internal/memoria/signin_door_states_test.go
index 1ff873c..52ca613 100644
--- a/internal/memoria/signin_door_states_test.go
+++ b/internal/memoria/signin_door_states_test.go
@@ -29,7 +29,7 @@ func TestDoorStatesWithHome(t *testing.T) {
{"first visit", "/signin", nil, "Sign in to Memoria", []string{oficinaButton, otherWays, `href="/signin/oficina"`}, []string{emailField}},
{"Oficina ID remembered", "/signin", oficina, "Sign in to Memoria", []string{oficinaButton, otherWays}, []string{"Continue as", emailField}},
{"email remembered", "/signin", email, "Sign in to Memoria", []string{"Continue as alice@example.test", otherWays}, []string{oficinaButton}},
- {"Keymail remembered", "/signin", keymail, "Sign in to Memoria", []string{"Continue to Keymail", otherWays}, []string{oficinaButton}},
+ {"Keymail remembered", "/signin", keymail, "Sign in to Memoria", []string{"Continue as alice@example.test", `name="expect" value="keymail"`, otherWays}, []string{oficinaButton, "Keymail"}},
{"the chooser", "/signin?ways=1", email, "Other ways to sign in to Memoria", []string{"Oficina ID", "Back", "Use a different email"}, []string{emailField}},
{"the email way", "/signin?way=email", nil, "Sign in to Memoria", []string{emailField, "Continue"}, []string{oficinaButton}},
{"the Oficina way", "/signin?way=oficina", email, "Sign in to Memoria", []string{oficinaButton}, []string{"Continue as"}},
@@ -40,7 +40,7 @@ func TestDoorStatesWithHome(t *testing.T) {
{"a problem", "/signin?err=expired", email, "Problem signing in to Memoria", []string{"That link has expired or was already used.", emailField}, []string{oficinaButton}},
{"rate", "/signin?err=rate", nil, "Problem signing in to Memoria", []string{"Too many tries."}, nil},
{"a bad address", "/signin?err=address", nil, "Problem signing in to Memoria", []string{"That doesn't look like an email address."}, nil},
- {"Keymail failed", "/signin?force=1&err=keymail", nil, "Problem signing in to Memoria", []string{`name="force" value="1"`, "Keymail couldn't confirm it's you."}, nil},
+ {"Keymail failed", "/signin?force=1&err=keymail", nil, "Problem signing in to Memoria", []string{`name="force" value="1"`, "We couldn't confirm it's you."}, []string{"Keymail"}},
{"sent", "/signin?sent=1", email, "Check your email to sign in to Memoria", []string{"Check your email", "Use a different email"}, []string{oficinaButton, emailField}},
{"the removal", "/signin?err=removed", nil, "Problem signing in to Memoria", []string{signinRemoved, appProblem, emailField}, []string{"Something went wrong"}},
} {
diff --git a/internal/memoria/static/memoria.css b/internal/memoria/static/memoria.css
index b2c6af1..5bc380f 100644
--- a/internal/memoria/static/memoria.css
+++ b/internal/memoria/static/memoria.css
@@ -207,8 +207,13 @@ section[rst-section] { border-top: 1px solid var(--rst-line); padding-top: var(-
/* A form is a stack (tokens.css): label to field and field to hint
* --rst-sp-2, a field to the next label --rst-sp-3, and its buttons
- * (rst-actions) --rst-sp-4 clear. Only the labels' weight is Memoria's. */
-[rst-stack] label { font-weight: 560; }
+ * (rst-actions) --rst-sp-4 clear. Only the labels' weight is Memoria's.
+ *
+ * form[rst-stack], here and in the field rules below, and never a bare
+ * [rst-stack]: <main> is a stack too, and a bare one would reach every
+ * field on every page, the search box's and the sign-in door's among
+ * them. */
+form[rst-stack] > label { font-weight: 560; }
/* A hint inside a label is quiet: muted and regular weight, not the
* label's 560 (polish audit r3 B7). */
[rst-hint] { font-weight: 400; }
@@ -216,10 +221,10 @@ section[rst-section] { border-top: 1px solid var(--rst-line); padding-top: var(-
* which ran 22px past the column at 1440 and off the screen at 390
* (polish audit §B6). Password fields are here too: the Notion token
* fields were the browser's own. */
-[rst-stack] input[type="text"],
-[rst-stack] input[type="email"],
-[rst-stack] input[type="password"],
-[rst-stack] textarea {
+form[rst-stack] input[type="text"],
+form[rst-stack] input[type="email"],
+form[rst-stack] input[type="password"],
+form[rst-stack] textarea {
background: var(--rst-bg);
border: 1px solid var(--rst-line);
border-radius: var(--rst-radius-sm, 6px);
@@ -230,8 +235,8 @@ section[rst-section] { border-top: 1px solid var(--rst-line); padding-top: var(-
padding: var(--rst-sp-2) var(--rst-sp-3);
width: 100%;
}
-[rst-stack] input:focus-visible,
-[rst-stack] textarea:focus-visible {
+form[rst-stack] input:focus-visible,
+form[rst-stack] textarea:focus-visible {
border-color: var(--rst-accent);
outline: 2px solid var(--rst-accent);
outline-offset: 1px;
@@ -243,21 +248,21 @@ section[rst-section] { border-top: 1px solid var(--rst-line); padding-top: var(-
* title and body, and the Notion token. Same rule, same max(), restated
* here at their weight. TestNoZoomOnTap (make browser) measures them. */
@media (pointer: coarse) {
- [rst-stack] input[type="text"],
- [rst-stack] input[type="email"],
- [rst-stack] input[type="password"],
- [rst-stack] textarea {
+ form[rst-stack] input[type="text"],
+ form[rst-stack] input[type="email"],
+ form[rst-stack] input[type="password"],
+ form[rst-stack] textarea {
font-size: max(1rem, 1em);
}
}
/* Pasted prose is prose: the body font, not a code box. */
-[rst-stack] textarea { resize: vertical; }
+form[rst-stack] textarea { resize: vertical; }
/* The file chooser. The native control stays — it is what works with no
* script, and it says which files were chosen — but its button is drawn
* as the app's buttons are, instead of the browser's grey "Choose Files". */
-[rst-stack] input[type="file"] { color: var(--rst-text-muted); font: inherit; font-size: var(--rst-fs-sm); max-inline-size: 100%; }
-[rst-stack] input[type="file"]::file-selector-button {
+form[rst-stack] input[type="file"] { color: var(--rst-text-muted); font: inherit; font-size: var(--rst-fs-sm); max-inline-size: 100%; }
+form[rst-stack] input[type="file"]::file-selector-button {
background: var(--rst-surface);
border: 1px solid var(--rst-line-strong);
border-radius: var(--rst-radius-sm, 6px);
@@ -269,7 +274,7 @@ section[rst-section] { border-top: 1px solid var(--rst-line); padding-top: var(-
/* spacing-allow: drawn as the app's buttons are, at rastrillo's [rst-btn] padding */
padding: 0.45rem 0.75rem;
}
-[rst-stack] input[type="file"]::file-selector-button:hover { background: var(--rst-surface-2); }
+form[rst-stack] input[type="file"]::file-selector-button:hover { background: var(--rst-surface-2); }
/* The drop zone. Nothing here paints until static/drop.js has proved it
* can put a file in the input and written rst-dropzone="ready" — so a
diff --git a/internal/memoriatest/gates_test.go b/internal/memoriatest/gates_test.go
index 264b9fb..4d16e82 100644
--- a/internal/memoriatest/gates_test.go
+++ b/internal/memoriatest/gates_test.go
@@ -1116,6 +1116,12 @@ var rstWord = regexp.MustCompile(`rst-[a-z0-9-]+`)
// to the stylesheets at all.
var templateExempt = map[string]bool{
"rst-withheld": true, // a test hook for §6.5's notice block
+ // Hooks the tests find these blocks by. memoria.css spaced each with a
+ // margin of its own until the spacing rhythm (2026-11-22) put them in
+ // a stack, which spaces them now; nothing styles them any more.
+ "rst-answer": true, // §8.11's answer slot
+ "rst-search-empty": true, // the one quiet "No matches" line
+ "rst-breadcrumb": true, // the back link over /add and a document
}
// classOnlyUtilities are tokens.css utilities that keep the class
diff --git a/internal/memoriatest/rhythm_browser_test.go b/internal/memoriatest/rhythm_browser_test.go
index fef7915..ba04fc0 100644
--- a/internal/memoriatest/rhythm_browser_test.go
+++ b/internal/memoriatest/rhythm_browser_test.go
@@ -26,11 +26,20 @@
// connect pages' and the door's insides, which are estilo's and Home's
// and audited there (estilo 6238a47; Home 8125a3c).
//
-// Written against origin/main's memoria.css first (5d9034d): it failed
-// there with 43 findings across the screens (off-scale gaps such as the
-// 2rem above the footer, 1.75rem above the home lists and 1.1rem
-// results, and headings further from their text than from the block
-// before them), and passes on the stack.
+// Written against origin/main (5d9034d) first, its static/ and
+// templates/ under this branch's go.mod: 72 findings on 26 of the 34
+// screen-widths, 67 of them signed in (68 off-scale, such as the h1's
+// browser margin of 18.8px, 28px above the home lists and 17.4px under
+// the results count; and 4 headings no closer to their content than to
+// the block before them, the Add content h1 among them) and 5 on the
+// door (estilo before 6238a47: 22px under the brand). It passes on the
+// stack. MUTATION-TESTED 2026-11-22, each reverted: rst-stack taken off
+// <main> → 16 findings on a document, Add content, Sources and Notion at
+// both widths (an h1 back on its browser margin, 18.8px); [rst-ai-by]'s
+// margin put back to 0.4rem → "6.4px between blocks" in [rst-ai-answer]
+// at both widths, which only the region roots can see. (A hand margin on
+// a stack's child, [rst-home-lists] given back 1.75rem, changes nothing:
+// the stack's rule outweighs it, which is the point of the stack.)
package memoriatest
import (
diff --git a/internal/memoriatest/signin_keymail_test.go b/internal/memoriatest/signin_keymail_test.go
index 65a52f4..345d437 100644
--- a/internal/memoriatest/signin_keymail_test.go
+++ b/internal/memoriatest/signin_keymail_test.go
@@ -153,6 +153,9 @@ func keymailSigninAppWith(t *testing.T, dbPath string, owners []string, km *fake
au, err := memoria.NewAuth(d.Writer(), memoria.AuthEnv{
Origin: testOrigin, InstanceKey: "signin-keymail-instance-key",
Owners: owners, Mailer: &stubMailer{},
+ // Listed, so rastrillo's keymail client sends through
+ // http.DefaultTransport, which is km below (AuthEnv says why).
+ KeymailServers: []string{km.host},
}, logger, a)
if err != nil {
t.Fatal(err)
@@ -227,7 +230,7 @@ func TestAKeymailSigninCanLeaveThePage(t *testing.T) {
// Rendered as Memoria's door: the layout, its bar, the door, and
// rastrillo's tab title for the state. (No footer: it is a sign-in
// page, and the footer is said only to somebody signed in.)
- for _, want := range []string{"<header estilo-bar", "estilo-door", "<title>Taking you to Keymail to sign in to Memoria</title>"} {
+ for _, want := range []string{"<header estilo-bar", "estilo-door", "<title>Signing in to Memoria</title>"} {
if !strings.Contains(body, want) {
t.Errorf("the continuation page lacks %q", want)
}
@@ -260,7 +263,7 @@ func TestSigninPathsThatDoNotLeaveAreUnchanged(t *testing.T) {
}
// authorizeHref is the authorize URL a continuation page carries: the
-// door's Continue to Keymail link.
+// door's Continue link (rastrillo's words; it never names Keymail).
var authorizeHref = regexp.MustCompile(`href="(https://example\.test/oauth/authorize\?[^"]+)"`)
// A Keymail sign-in that comes back verified for an address Admit refuses
diff --git a/internal/memoriatest/signindial_test.go b/internal/memoriatest/signindial_test.go
index 423b12b..2609c6a 100644
--- a/internal/memoriatest/signindial_test.go
+++ b/internal/memoriatest/signindial_test.go
@@ -98,6 +98,12 @@ func signinAppWithOwners(t *testing.T, owners []string) (http.Handler, *dialReco
InstanceKey: "signin-dial-gate-instance-key",
Owners: []string{dialTestOwner},
Mailer: &stubMailer{},
+ // Listed, so rastrillo's keymail client sends through
+ // http.DefaultTransport, the recorder below. Unlisted (nil, as in
+ // production), it copies the transport when auth is built and
+ // dials public addresses only, and the recorder would see the
+ // DNS half of a dial and never the HTTP half (rastrillo v0.45.0).
+ KeymailServers: []string{"example.test"},
}, logger, a)
if err != nil {
t.Fatalf("NewAuth: %v", err)