oficina / base Public

Add the Base first-slice implementation plan

Eleven tasks: skeleton and store, the glass look and fonts, sign-in,
invites, catalogue and Platform client, installer, Home/Store/Settings,
the assertion issuer, the shared consumer with Scratchpad and Welcome,
passkeys, and release with a live check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev e94f1be86bf7e536af4f6f0eadafdd16aa37b998 parent a80335c
1 file changed, +401 −0
  • docs/superpowers/plans/2026-11-06-base-first-slice.md +401 −0
diff --git a/docs/superpowers/plans/2026-11-06-base-first-slice.md b/docs/superpowers/plans/2026-11-06-base-first-slice.md
new file mode 100644
index 0000000..96ff5e4
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-06-base-first-slice.md
@@ -0,0 +1,401 @@
+# Base First Slice Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** A team signs in to Base, invites a teammate, and installs and uninstalls real apps (Welcome and Scratchpad) on Base's own Platform account; installed apps know who the person is.
+
+**Architecture:** One Go module holds three binaries:
+
+- `base`: the front door.
+- `scratchpad` and `welcome`: two tiny apps installed through Base.
+
+Base talks to Platform through a narrow `platform.Client`. Installing means writing an instance's config environment and then creating the instance. Identity flows by Base minting `rastrillo/assertion` tokens, using the handoff flow designed for Oficina home. Every installed app verifies them through one shared `consumer` package.
+
+**Tech Stack:** Go (`GOTOOLCHAIN=go1.26.10`, `CGO_ENABLED=0`), `amadan.net/rastrillo/rastrillo v0.33.0` (auth, passkey, sessions, csrf, migrate, mail, assertion, crypto, assets, harness), chi, SQLite.
+
+**Spec:** `docs/superpowers/specs/2026-11-06-base-first-slice-design.md`. The visual reference is `.superpowers/mockups/index.html`, which is git-ignored and published at [https://base-first-slice.docs-t1.dev.platform.tito.io](https://base-first-slice.docs-t1.dev.platform.tito.io).
+
+## Global Constraints
+
+- **Module and layout:** module path `amadan.net/carlos/base`. Copy equipo's boot shape (`oficina/equipo/cmd/equipo/main.go:26-55`): `rastrillo.Resolve` → `db.Open` → app → `rastrillo.Serve`. Routes use chi.
+- **Pages work with scripts off** (app spec 12.5):
+ - Every write is a plain `<form method="post">` answered with a 303.
+ - Scripts are `defer` add-ons.
+ - Anything that waits uses a `<noscript>` meta refresh.
+- **Not an operating system** (spec 18.2): no windows, title bars or window controls. Opening an app is a normal link to its origin.
+- **Assertions:**
+ - Signed with `rastrillo/assertion` (P-256), with `iss` = Base origin and `aud` = the installed instance's origin.
+ - Lifetime 120 s.
+ - `kid` = lowercase hex SHA-256 of `Keypair.SignPub()` (65 bytes).
+ - `Ext` carries display fields only.
+ - Origins must be `https://` hostnames; the verifier rejects IP addresses.
+- **Shared app contract:** every app Base installs reads exactly these four variables. Nothing in Base is specific to Scratchpad.
+ - `BASE_APP_ORIGIN`
+ - `BASE_APP_ISSUER`
+ - `BASE_APP_CONSUMER_ID`
+ - `BASE_APP_KEYS` (base64 of a JSON object mapping each `kid` to the base64 of its 65-byte public key)
+- **Platform:**
+ - Two service credentials, because a credential holds one role:
+ - `BASE_PLATFORM_INSTANCE_TOKEN` (role `instance`)
+ - `BASE_PLATFORM_OPERATE_TOKEN` (role `operate`)
+ - Both are account-wide (no `--app`). Header: `Authorization: Bearer <token>`.
+ - Never call `instances-manifest`; an operator enables each catalogue app once (spec 5.6).
+- **Instance hosts:**
+ - Each is `<BASE_SLUG>-<appid>.<BASE_APPS_DOMAIN>`: one DNS label, at most 32 characters, matching `[a-z0-9]([a-z0-9-]*[a-z0-9])?`.
+ - The instance's config environment has the same name as the label.
+- **Look** (spec 6):
+ - Approved colours: `#2FC6C0`, `#8B5CF6`, `#F472B6`, `#6EE7DC`; glass tint `rgba(14,17,42,.40)`; secondary text `#DDE3F0`.
+ - Fog loops of 10–17 s; everything stops under `prefers-reduced-motion`.
+ - Controls are 44px tall.
+ - Timeless Sans only: `STYL` 100 for body text, 0 for headings and the wordmark. Preloaded with `font-display: block`.
+ - WCAG AA contrast.
+- **Timeless font:** never committed. `hack/fonts.sh` fetches `https://media.timeless.co/type/Timeless-Type-Family-1.094.zip`, checks SHA-256 `510685dfce6010b74a1a250af7de1204e1b9901be152a39f5dd6be85fc6d6084`, and extracts `Sans-Grotesk/TimelessSansVF.woff2`. The fallback is DM Sans (OFL, committed), with metrics matched as in ppl.
+- **Copy** (exact strings the spec fixes):
+ - Uninstall confirmation: "Uninstall {App}? It's removed from Home for everyone at {Base name}. Its data is kept, and comes back if you install it again."
+ - Steps: "Signed in", "Invite your team", "Install your first app".
+ - Invited state: "Invited. Hasn't signed in yet."
+ - All new user-facing copy goes through the copy-review skill before it lands.
+- **Commits:** subject under 80 characters, a body after a blank line, and the trailer `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. Work on branch `first-slice`, not `main`.
+- **Servers you start for local checks:** bind them to `127.0.0.1` only, and share them with `carlos devbox share --port`, which also supplies the HTTPS origins assertions need.
+
+## Review Focus
+
+1. **A replayed or late assertion:** posting the same assertion twice, or posting it after 120 s, must not sign anyone in. Test: `TestAssertionReplayRefused`, `TestAssertionExpiredRefused` (Task 9).
+2. **Install pressed twice, or in two tabs:** this must create one instance, not two and not an error. Test: `TestInstallTwiceIsOneInstance` (Task 6).
+3. **An install that fails halfway:** config written but the create refused, or an instance that never answers. The app must show as failed with a retry, never as a tile that leads nowhere. Test: `TestInstallCreateRefusedMarksFailed`, `TestInstallNeverAnswersMarksFailed` (Task 6).
+4. **Someone who shouldn't get an assertion asks for one:** a signed-in person who has been removed, a request for an app that isn't installed, or an unknown consumer. They must be refused without an assertion. Test: `TestAuthorizeRefusals` (Task 8).
+5. **Inviting an existing address in different case** (`Maria@Acme.co` vs `maria@acme.co`): this must not create a second member. Test: `TestInviteIsCaseInsensitive` (Task 4).
+
+---
+
+## File map
+
+```
+cmd/base/main.go boot Base
+cmd/scratchpad/main.go boot Scratchpad
+cmd/welcome/main.go boot Welcome
+internal/config/config.go Base settings from the environment
+internal/store/ migrations, members, installs, owner bootstrap
+internal/look/ layout, CSS, fonts handler, shared template funcs
+internal/web/ Base routes and handlers (signin, home, people, store, settings)
+internal/catalog/ catalog.json (embedded) and its type
+internal/platform/ Client interface, HTTP client, Fake
+internal/install/ Installer: install, uninstall, readiness, first-boot Welcome
+internal/issuer/ /authorize: mints assertions for installed apps
+internal/consumer/ shared app side: start, assertion, finish, sessions, replay store
+internal/scratchpad/ Scratchpad's notes page
+internal/welcome/ Welcome's page
+hack/fonts.sh fetch Timeless (pinned)
+scripts/prepare-apps.sh operator: create, ship and enable each catalogue app once
+Makefile, run.sh, .env.local.example, README.md
+```
+
+### Task 1: Skeleton, config, store and owner bootstrap
+
+**Files:**
+- Create: `go.mod`, `Makefile`, `run.sh`, `.env.local.example`, `cmd/base/main.go`, `internal/config/config.go`, `internal/store/{migrations.go,migrations/0001_base.sql,members.go,installs.go,bootstrap.go}`
+- Modify: `.gitignore` (add `/.env.local`, `/.local/`, `*.db*`, `/releases/`, `internal/look/static/fonts/timeless/`)
+- Test: `internal/config/config_test.go`, `internal/store/store_test.go`
+
+**Interfaces:**
+- Produces:
+ - `config.Load(getenv func(string) string) (config.Config, error)`. `Config` has these fields:
+ - `Origin`, `Name`, `Slug`, `Owner`, `AppsDomain`, `Timezone *time.Location`
+ - `PlatformConsole`, `PlatformAccount`, `InstanceToken`, `OperateToken`
+ - `AssertionKey *crypto.Keypair`
+ - `AllowLoggedMail bool`
+ - Environment variables, all prefixed `BASE_`: `ORIGIN`, `NAME`, `SLUG`, `OWNER`, `APPS_DOMAIN`, `TIMEZONE` (default `Europe/London`), `PLATFORM_CONSOLE`, `PLATFORM_ACCOUNT`, `PLATFORM_INSTANCE_TOKEN`, `PLATFORM_OPERATE_TOKEN`, `ASSERTION_KEY` (base64 of `crypto.MarshalKeypair`), `ALLOW_LOGGED_MAIL`.
+ - `store.Schema`, and `store.BootSchema = migrate.Merge(sessions.Schema, auth.Schema, pow.Schema, store.Schema)`.
+ - `store.Member{ID, Email, Name string; Role string /* "owner"|"member" */; InvitedAt time.Time; JoinedAt *time.Time}`, plus:
+ - `store.Members(ctx, db) ([]Member, error)`
+ - `store.MemberByEmail(ctx, db, email) (Member, bool, error)`
+ - `store.Invite(ctx, db, email string) (Member, bool /*created*/, error)`
+ - `store.MarkJoined(ctx, db, id string) error`
+ - `store.Bootstrap(ctx, db, ownerEmail string) error`: seeds the owner only when there are no members.
+ - `store.Install{App, Host, State string /* "installing"|"installed"|"failed" */; Error string; UpdatedAt time.Time}`, plus:
+ - `store.Installs(ctx, db) ([]Install, error)`
+ - `store.ClaimInstall(ctx, db, app, host string) (bool, error)`: true only for the caller that moves the app into `installing`.
+ - `store.SetInstallState(ctx, db, app, state, errMsg string) error`
+ - `store.DeleteInstall(ctx, db, app string) error`
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestLoadRequiresOriginAndOwner`: a missing `BASE_ORIGIN` or `BASE_OWNER` gives an error naming the variable.
+ - `TestLoadRefusesLoggedMailOffLoopback`: `BASE_ALLOW_LOGGED_MAIL=1` with a non-loopback origin gives an error.
+ - `TestSlugMakesLegalHosts`: a slug that would make a label over 32 characters, or with illegal characters, is refused.
+ - `TestBootstrapSeedsOwnerOnce`: the first call gives one member with role `owner`; a second call with a different email leaves one member.
+ - `TestClaimInstallOnlyOnce`: two claims on the same app give `true`, then `false`.
+- [ ] **Step 2:** Run `go test ./internal/... -run 'TestLoad|TestSlug|TestBootstrap|TestClaim'`. Expected: FAIL (packages missing).
+- [ ] **Step 3:** Implement the code above. The member `ID` is `assertion.RandomID()`. It becomes the assertion `sub`, so it is never the email. `Makefile` copies equipo's targets: `ci`, `test` (`rastrillo budget test -count=1 ./...`) and `release` building all three binaries. `run.sh` copies equipo's, with `BASE_*` names.
+- [ ] **Step 4:** Run the same tests. Expected: PASS. Also run `go vet ./...`.
+- [ ] **Step 5:** Commit: "Add Base skeleton, config and member store".
+
+### Task 2: The look: layout, CSS and fonts
+
+**Files:**
+- Create:
+ - `internal/look/look.go`
+ - `internal/look/templates/layout.html`
+ - `internal/look/static/app.css`
+ - `internal/look/static/fonts/dm-sans/4.004/DMSans-VF.woff2` (copy from `~/amadan.net/ppl/ppl/.claude/worktrees/profile-instance/internal/ppl/static/fonts/dm-sans/4.004/`, with `OFL.txt`)
+ - `internal/look/static/fonts/timeless/.keep`
+ - `hack/fonts.sh`
+- Test: `internal/look/look_test.go`
+
+**Interfaces:**
+- Produces:
+ - `look.Assets` (a `rastrillo.NewAssets` over the embedded `static`).
+ - `look.FontHandler() http.Handler`, mounted at `GET /static/fonts/` with `Cache-Control: public, max-age=31536000, immutable`.
+ - `look.Page(w http.ResponseWriter, name string, data any) error`: renders `layout.html` with one page template. Every Task 3–7 page uses it.
+ - Layout blocks: `title`, `main`. The layout carries the atmosphere: `.light`, plus `.fog` with four `<i>`.
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestLayoutPreloadsTimeless`: the rendered layout contains `<link rel="preload" href="/static/fonts/timeless/1.094/TimelessSansVF.woff2" as="font" type="font/woff2" crossorigin>`.
+ - `TestFontsImmutable`: the DM Sans path answers 200 with the immutable header. A missing Timeless file answers 404.
+ - `TestLayoutHasNoRequiredScript`: every `<script>` in the layout has `defer`, and the page has no inline `onclick`.
+- [ ] **Step 2:** Run `go test ./internal/look/`. Expected: FAIL.
+- [ ] **Step 3:** Implement. Port `app.css` from the mockup's `<style>`:
+ - Keep the tokens, glass, fog paths, light sway, tiles and controls.
+ - Drop the mockup-only `.page`, `.row`, `figure` and `figcaption` rules.
+ - Add the `@font-face` blocks: `Timeless Sans` with `font-display: block`, and the `DM Sans` fallback with `size-adjust: 98%` and `ascent-override: 98.3%`, as ppl's `app.css:59-75` does.
+ - `hack/fonts.sh` downloads the zip, checks the SHA-256, extracts into `internal/look/static/fonts/timeless/1.094/`, and exits non-zero on a mismatch.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Add Base layout, glass styles and fonts".
+
+### Task 3: Sign in, sign out and the member gate
+
+**Files:**
+- Create: `internal/web/app.go`, `internal/web/signin.go`, `internal/web/templates/{signin.html,confirm.html}`
+- Modify: `cmd/base/main.go`
+- Test: `internal/webtest/harness_test.go`, `internal/webtest/signin_test.go`
+
+**Interfaces:**
+- Consumes: `config.Config`, `store.*`, `look.Page`.
+- Produces:
+ - `web.App(db *sql.DB, cfg config.Config, mailer mail.Sender, inst Installer, logger *slog.Logger) (http.Handler, error)`.
+ - The Installer interface (implemented in Task 6): `type Installer interface { Install(ctx context.Context, app string) error; Uninstall(ctx context.Context, app string) error }`.
+ - `web.CurrentMember(r *http.Request) (store.Member, bool)`.
+ - The test harness `newApp(t) *testApp`, with `get`, `post` (sets `Origin`), `signIn(email)` and `mailbox()`, copied from equipo's `internal/equipotest/harness_test.go`.
+ - Until Task 6 lands, `main` and the harness pass a no-op `Installer`.
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestOwnerCanSignIn`: the bootstrapped owner gets a link in the mailbox; following it reaches `/` with 200.
+ - `TestStrangerRefused`: an address that is neither owner nor invited gets no session. The page says sign-in isn't available for that address; the wording goes through copy-review.
+ - `TestInvitedMemberJoinsOnFirstSignIn`: after signing in, `JoinedAt` is set.
+ - `TestSignOut`: after a POST to `/auth/signout`, `/` redirects to `/signin`.
+- [ ] **Step 2:** Run `go test ./internal/webtest/ -run 'TestOwner|TestStranger|TestInvited|TestSignOut'`. Expected: FAIL.
+- [ ] **Step 3:** Implement by copying equipo's `setup/session_handlers.go:32-63`:
+ - `auth.New` with `KeymailServers: []string{"keymail.dev"}`, `SigninScreen: true`, `BeginPath: "/auth/begin"`, and `pow.NoProof`.
+ - The `Authorize` callback calls `store.MemberByEmail` and marks the member joined.
+ - Wrap every browser route in `csrf.Protect`.
+ - Mail comes from `mail.FromEnv("CARLOS", logger)`, as in equipo's `config.go:39-44`. Boot is refused without it unless `AllowLoggedMail` is set.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Sign in to Base with email or Keymail".
+
+### Task 4: People and invites
+
+**Files:**
+- Create: `internal/web/people.go`, `internal/web/templates/people.html`
+- Test: `internal/webtest/people_test.go`
+
+**Interfaces:**
+- Consumes: `store.Invite`, `store.Members`, `web.CurrentMember`.
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestOwnerInvites`: a POST to `/people` with `email=maria@acme.co` adds a row showing "Invited. Hasn't signed in yet." and puts one invitation in the mailbox. The invitation links to `BASE_ORIGIN/signin`.
+ - `TestInviteIsCaseInsensitive`: inviting `Maria@Acme.co` after `maria@acme.co` leaves one member and sends no second invitation.
+ - `TestMemberCannotInvite`: a non-owner's POST gets 403.
+ - `TestPeopleWorksWithoutScripts`: the page's form posts to `/people` and the reply is a 303.
+- [ ] **Step 2:** Run `go test ./internal/webtest/ -run 'TestOwnerInvites|TestInvite|TestMemberCannot|TestPeople'`. Expected: FAIL.
+- [ ] **Step 3:** Implement. Lowercase and trim the email before `store.Invite`. Run the invitation copy through copy-review.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Invite teammates to Base".
+
+### Task 5: Catalogue and Platform client
+
+**Files:**
+- Create: `internal/catalog/{catalog.go,catalog.json}`, `internal/platform/{client.go,http.go,fake.go}`
+- Test: `internal/catalog/catalog_test.go`, `internal/platform/http_test.go`
+
+**Interfaces:**
+- Produces:
+ - `catalog.Entry{ID, Name, Summary, Tint string /* "amber"|"teal"|"violet"|"mist"|"rose" */; Icon string; Default bool}`, with `catalog.All() []Entry` and `catalog.Get(id string) (Entry, bool)`.
+ - `catalog.json` lists `welcome` (Default true, amber) and `scratchpad` (rose).
+ - The `platform.Client` interface:
+ - `SetEnv(ctx context.Context, app, environment string, vars map[string]string) error`
+ - `CreateInstance(ctx context.Context, app, host, environment string) error`: a 409 counts as success.
+ - `DeleteInstance(ctx context.Context, app, host string) error`
+ - `platform.NewHTTP(console, account, instanceToken, operateToken string, hc *http.Client) platform.Client`.
+ - `platform.Fake`: records calls, can be told to fail a given call, and implements `Client`.
+
+- [ ] **Step 1: Write failing tests** against an `httptest.Server` that records requests.
+ - `TestSetEnvShape`: `PUT {console}/api/cli/apps/{account}/{app}/config` with the operate token and body `{"environment":E,"message":"Base: install","set":{K:{"kind":"env","value":V}}}`.
+ - `TestCreateInstanceShape`: `POST .../instances` with the instance token and body `{"host":H,"environment":E,"message":"Base: install"}`. A 201 or a 409 is success.
+ - `TestDeleteInstanceShape`: `DELETE .../instances/{host}` with `X-Carlos-Message: Base: uninstall`.
+ - `TestErrorsCarryStatusNotBody`: a 403 gives an error naming the call and the status, without the response body.
+ - `TestCatalogIDsAreLabels`: every ID is a legal label part.
+- [ ] **Step 2:** Run `go test ./internal/catalog/ ./internal/platform/`. Expected: FAIL.
+- [ ] **Step 3:** Implement. Endpoints and bodies follow `carlos/platform/internal/console/apiinstances.go:608-683,1476-1537` and `apiconfig.go:279-304`. Base sets only `kind: "env"`, because nothing it sends is secret, so no sealing is needed.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Add the catalogue and a Platform client".
+
+### Task 6: Installer
+
+**Files:**
+- Create: `internal/install/install.go`
+- Test: `internal/install/install_test.go`
+
+**Interfaces:**
+- Consumes: `platform.Client`, `catalog.Get`, the `store` install functions, `config.Config`.
+- Produces:
+ - `install.New(db *sql.DB, cfg config.Config, pc platform.Client, probe func(ctx context.Context, origin string) error, logger *slog.Logger) *install.Installer`, which implements `web.Installer`.
+ - `install.HostFor(cfg config.Config, app string) (label, host string)`.
+ - `install.ProbeVersion(hc *http.Client) func(ctx, origin) error`: polls `GET {origin}/api/version` every 2 s until it gets a 200, giving up after 5 minutes.
+ - `(*Installer).EnsureDefaults(ctx) error`: installs every `Default` entry that isn't installed. Called once from `main` at boot, in the background.
+ - `install.AppVars(cfg config.Config, app, origin string) map[string]string`: the four `BASE_APP_*` values.
+
+- [ ] **Step 1: Write failing tests** using `platform.Fake` and a probe stub.
+ - `TestInstallWritesEnvThenCreates`: `SetEnv` is called with exactly `BASE_APP_ORIGIN=https://acme-scratchpad.bab.oncarlos.com`, `BASE_APP_ISSUER=<cfg.Origin>`, `BASE_APP_CONSUMER_ID=scratchpad` and `BASE_APP_KEYS=<base64 JSON {kid: base64 SignPub}>`. Then `CreateInstance` is called with the same label as environment. Then the state is `installed`.
+ - `TestInstallTwiceIsOneInstance`: two concurrent `Install` calls make one `CreateInstance` call.
+ - `TestInstallCreateRefusedMarksFailed`: the Fake fails the create. The state becomes `failed` with an error message, and a later `Install` retries.
+ - `TestInstallNeverAnswersMarksFailed`: the probe returns a timeout, and the state becomes `failed`.
+ - `TestUninstallDeletesInstanceKeepsNothingInBase`: `DeleteInstance` is called with the host, and the install row is gone.
+ - `TestEnsureDefaultsInstallsWelcomeOnce`.
+- [ ] **Step 2:** Run `go test ./internal/install/`. Expected: FAIL.
+- [ ] **Step 3:** Implement.
+ - `Install`: claim the app (`store.ClaimInstall`), then `SetEnv`, then `CreateInstance`, then the probe, then mark it `installed`, or `failed` with a short message that holds no response body.
+ - The `kid` is the lowercase hex SHA-256 of `cfg.AssertionKey.SignPub()`.
+ - Install runs in a goroutine started by the handler; the request doesn't wait for it.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Install and uninstall apps on Base's account".
+
+### Task 7: Home, Store and Settings pages
+
+**Files:**
+- Create: `internal/web/{home.go,store.go,settings.go}`, `internal/web/templates/{home.html,store.html,uninstall.html,settings.html}`
+- Test: `internal/webtest/home_test.go`, `internal/webtest/store_test.go`
+
+**Interfaces:**
+- Consumes: `web.Installer`, `store.Installs`, `catalog.All`, `install.HostFor`.
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestHomeGreetsByTimeOfDay`: with a fixed clock at 09:00 in `Europe/London`, the page shows "Good morning, Paul." The name is the member's `Name`, or else the email's local part capitalised.
+ - `TestHomeSteps`: a fresh Base shows "Signed in" done and the other two steps not done. After an invitation and an installed non-default app, all three are done.
+ - `TestHomeTilesLinkToOrigins`: each `installed` app's tile is `<a href="https://acme-scratchpad.bab.oncarlos.com/">` with its tint class. Apps still `installing` or `failed` show no tile.
+ - `TestStoreInstallButtonPostsAndRedirects`: an owner's POST to `/store/scratchpad/install` calls `Installer.Install` and answers 303 to `/store`.
+ - `TestStoreShowsInstallingWithRefresh`: while an app is `installing`, the page has `<noscript><meta http-equiv="refresh" content="2"></noscript>` and the button is disabled.
+ - `TestStoreShowsFailedWithRetry`.
+ - `TestUninstallNeedsConfirm`: `GET /store/scratchpad/uninstall` shows the exact confirmation copy from Global Constraints. Only a `POST` uninstalls.
+ - `TestMemberSeesStoreButCannotInstall`: there's no install button for a member, and their POST gets 403.
+- [ ] **Step 2:** Run `go test ./internal/webtest/ -run 'TestHome|TestStore|TestUninstall|TestMember'`. Expected: FAIL.
+- [ ] **Step 3:** Implement against the mockup's markup and classes. "Ask Base anything" is drawn but inert: a disabled field with a `title` saying it arrives later. Settings shows the Base name, the signed-in address and Sign out.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Add Home, Store and Settings".
+
+### Task 8: Issuer: assertions for installed apps
+
+**Files:**
+- Create: `internal/issuer/issuer.go`, `internal/issuer/templates/handoff.html`
+- Modify: `internal/web/app.go` (mount `GET /authorize` behind `RequireSession`)
+- Test: `internal/issuer/issuer_test.go`
+
+**Interfaces:**
+- Consumes: `web.CurrentMember`, `store.Installs`, `install.HostFor`, `cfg.AssertionKey`.
+- Produces:
+ - `GET /authorize?consumer=<app>&nonce=<n>` renders `handoff.html`: a form that POSTs a field `assertion` to `{aud}/auth/assertion`, with a Continue button and a deferred script that submits it.
+ - The claims:
+ - `iss` = Base origin, `aud` = the app's origin, `sub` = `Member.ID`.
+ - `nonce` = the request's nonce; `jti` = `assertion.RandomID()`.
+ - `iat` = now, `exp` = now + 120, `auth_time` = the session's sign-in time.
+ - `Ext` = `{"name":…, "email":…, "base":cfg.Name}`.
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestAuthorizeSignsForInstalledApp`: a verifier built with `assertion.NewVerifier(base, app, keys)` accepts the posted token. `aud`, `sub` and `nonce` match.
+ - `TestAuthorizeRefusals`, a table test. Each case gets 4xx and no assertion in the body:
+ - no session: redirect to sign-in
+ - unknown consumer
+ - consumer known but not `installed`
+ - missing or malformed nonce
+ - member removed after signing in
+- [ ] **Step 2:** Run `go test ./internal/issuer/`. Expected: FAIL.
+- [ ] **Step 3:** Implement with `assertion.Sign(cfg.AssertionKey, claims)`. The handoff page sets `Cache-Control: no-store`.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Issue identity assertions to installed apps".
+
+### Task 9: Consumer package, Scratchpad and Welcome
+
+**Files:**
+- Create:
+ - `internal/consumer/{consumer.go,migrations/0001_consumer.sql}`
+ - `internal/scratchpad/{scratchpad.go,templates/notes.html,migrations/0001_notes.sql}`
+ - `internal/welcome/{welcome.go,templates/welcome.html}`
+ - `cmd/scratchpad/main.go`, `cmd/welcome/main.go`
+- Test: `internal/consumer/consumer_test.go`, `internal/scratchpad/scratchpad_test.go`, `internal/e2e/handoff_test.go`
+
+**Interfaces:**
+- Produces:
+ - `consumer.Load(getenv) (consumer.Config, error)`: reads the four `BASE_APP_*` variables and builds the `assertion.Verifier`.
+ - `consumer.Mount(r chi.Router, db *sql.DB, cfg consumer.Config, sess *sessions.Manager)`, which mounts:
+ 1. `GET /auth/start?return_to=`: sets a `__Host-base-pending` cookie holding the nonce, then 303 to `{issuer}/authorize?consumer=…&nonce=…`.
+ 2. `POST /auth/assertion`: requires `Origin` to equal the issuer, verifies the token, stores it pending, then 303 to `/auth/finish`.
+ 3. `GET /auth/finish`: compares the nonce with `subtle.ConstantTimeCompare`, atomically consumes the pending row and records the `jti`, then starts the session.
+ - `consumer.Require(next http.Handler) http.Handler`: an unauthenticated request redirects to `/auth/start`.
+ - `consumer.Person(r) (sub, name, base string, ok bool)`.
+ - Lifetimes: pending 600 s, inbox 120 s, as in home's `handoff/store.go:40-48`.
+
+- [ ] **Step 1: Write failing tests.**
+ - `TestHandoffEndToEnd` (in `internal/e2e`): seed Scratchpad as `installed` with `store.ClaimInstall` and `store.SetInstallState`, then build the Base app (Task 3 harness) and the Scratchpad app in-process. Base's origin is `https://base.test` and Scratchpad's is `https://acme-scratchpad.test`; requests use those `Host` values. A cookie jar shared per origin drives start, authorize, assertion and finish. Scratchpad's page then shows "Signed in as Paul, Acme Ltd".
+ - `TestAssertionReplayRefused`: posting the same assertion a second time gives no session.
+ - `TestAssertionExpiredRefused`: verifying at `iat + 121` gives no session.
+ - `TestAssertionWrongOriginRefused`: a POST with `Origin` other than the issuer gets 403.
+ - `TestSessionOutlivesBase`: after the handoff, Base's handler is replaced with one that always gives 503. Scratchpad's `/` still answers 200 for the signed-in person.
+ - `TestNotesSharedAcrossMembers`: two people's sessions see the same notepad text after one saves.
+- [ ] **Step 2:** Run `go test ./internal/consumer/ ./internal/scratchpad/ ./internal/e2e/`. Expected: FAIL.
+- [ ] **Step 3:** Implement.
+ - Scratchpad is one page with a `<textarea>` form that saves the shared note, plus the signed-in line.
+ - Scratchpad's access rule (spec 1.7: the app decides): anyone the configured Base vouches for may read and write. Say so in a code comment and in its README section.
+ - Welcome is one page: a greeting, the Base name, and a link back to Home.
+ - Both use the `look` package, so they share the atmosphere.
+- [ ] **Step 4:** Run the tests again. Expected: PASS.
+- [ ] **Step 5:** Commit: "Add the consumer side, Scratchpad and Welcome".
+
+### Task 10: Passkeys on Base sign-in
+
+**Files:**
+- Modify: `internal/web/signin.go`, `internal/web/templates/signin.html`, `internal/store/migrations/` (add passkey schema via `passkey.Schema` in `BootSchema`)
+- Test: `internal/webtest/passkey_browser_test.go` (`//go:build browser`)
+
+**Interfaces:**
+- Consumes: `rastrillo/passkey`: `New`, `DiscoverBegin`/`DiscoverFinish`, `RegisterBegin`/`RegisterFinish`, `JS()`. Wiring follows rastrillo's `skill/signin.md` ("Sign-in screen") and `docs/site/passkeys.md`.
+
+- [ ] **Step 1: Write a failing browser test.** `TestPasskeyRegisterThenSignIn`, using `rastrillo/harness` with a virtual authenticator:
+ 1. The owner signs in by email.
+ 2. They add a passkey from Settings.
+ 3. They sign out.
+ 4. They sign in with "Use a passkey".
+- [ ] **Step 2:** Run `RASTRILLO_CHROME=$(which chromium) go test -tags browser ./internal/webtest/ -run TestPasskey`. Expected: FAIL.
+- [ ] **Step 3:** Implement. With scripts off, the passkey button is hidden and email sign-in still works.
+- [ ] **Step 4:** Run the test again. Expected: PASS. Also run the non-browser suite.
+- [ ] **Step 5:** Commit: "Sign in to Base with a passkey".
+
+### Task 11: Release, operator script and live check
+
+**Files:**
+- Create: `scripts/prepare-apps.sh`, `README.md`
+- Modify: `Makefile` (release builds `base`, `scratchpad` and `welcome` for linux/arm64)
+
+- [ ] **Step 1:** Write `scripts/prepare-apps.sh <account> <release-dir>`. For each catalogue ID it runs:
+ 1. `carlos apps create`
+ 2. `carlos deploy --app <id> --account <account> --channel stable` with the binary
+ 3. `carlos instances enable --app <id>`
+
+ It stops on the first failure. Re-running it is safe: steps that are already done are skipped.
+- [ ] **Step 2:** Write the README with humane-docs: what Base is, local run (`run.sh` plus `carlos devbox share --port` for HTTPS origins), deploying, the operator's one-time steps, and the four `BASE_APP_*` variables an app must read.
+- [ ] **Step 3:** Run `make ci`. Expected: PASS. Run the browser suite once.
+- [ ] **Step 4: Live check** on a flagship account Paul names (never on `main`'s behalf without asking):
+ 1. Deploy Base to the `edge` channel.
+ 2. Run `prepare-apps.sh`.
+ 3. Sign in as owner and invite a second address.
+ 4. Install Scratchpad, open it, and confirm "Signed in as".
+ 5. Write a note, uninstall, then install again. Confirm the note is back. This settles the spec 5.6 question about the parked database. If the note is gone, file the Platform request from spec section 9; don't work around it.
+ 6. Record the results in `docs/live-check.md`.
+- [ ] **Step 5:** Commit: "Add release, operator script and README".