carlos / platform Public

plan: first-run next steps (slice 1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f7e8078147907c137eacbad4fa8c90d55560cd78 parent c45c33c
1 file changed, +281 −0
  • docs/superpowers/plans/2026-11-08-first-run-next-steps.md +281 −0

CI failed — run details

Intent

Attributed to this commit: 5.11 g CO₂e (675,244 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-first-run-next-steps, 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/plans/2026-11-08-first-run-next-steps.md b/docs/superpowers/plans/2026-11-08-first-run-next-steps.md
new file mode 100644
index 000000000..59ea16d5c
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-08-first-run-next-steps.md
@@ -0,0 +1,281 @@
+# First-run next steps 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 "Getting started" card at the top of `/a/<account>/` that ticks
+steps 1-2 from facts the page already has, lets the person Mark done or Skip
+steps 3-4, and can be hidden and brought back.
+
+**Architecture:** One new console-DB table of per-person, per-account marks
+(`getting_started_marks`, modelled on `app_stars`). A pure builder turns
+(marks, the viewer's CLI tokens, the apps page's already-assembled
+`AppView`s and `appRow`s, role) into a view model; `handleAccountHome`
+renders it through a new partial in `apps.html`. Four CSRF'd POST handlers
+modelled on `handleAppStar` write the marks.
+
+**Tech Stack:** Go, `database/sql` (SQLite console DB), `html/template`,
+one small static JS file for Copy.
+
+**Spec:** `docs/superpowers/specs/2026-11-08-first-run-next-steps-design.md`
+(rev 2.1, binding).
+
+## Global Constraints
+
+- No new S3 reads on the apps page; only console-DB reads (marks, CLI tokens).
+- A step never shows done when it isn't: on any read error the step is NOT done
+ (log, never fail the page).
+- Copy: no em or en dashes; brand via `{{.ConsoleName}}` / `{console}`, never a
+ literal "Carloku"; no customer or tenant names. Strings live in one copy
+ struct (`gettingStartedCopy`, file `gettingstartedcopy.go`, pattern of
+ `applistcopy.go`); final strings come from the Luna pass and are applied
+ verbatim.
+- Existing console components only: `confirm-card`, `chip`, `btn`/`btn-sm`
+ `btn-secondary`, `linkish`, `<code>` blocks, `data-copy-target` Copy buttons
+ (as in `demo_claim.html`). No new colours, no left-border accents.
+- Works with JavaScript off: Copy buttons start `hidden` and JS un-hides them;
+ prompts are selectable text; every action is a plain `<form method="post">`.
+- Roles: `RoleOwner`, `RoleMember` only. Create-app link for both; the
+ browser domain link for owners only; everyone sees the CLI/agent route.
+- Go tests: only touched packages with `-run` locally; CI runs the full suite.
+ Go commands need the Bash sandbox disabled.
+
+## Review Focus
+
+1. An expired, revoked, `app` or `service` token must not tick step 1
+ (Task 2 `TestPersonConnected`).
+2. The app filter `?q=` must not change the card: liveness reads `p.Apps`
+ (every app), never the filtered lists (Task 4 `TestGettingStartedIgnoresFilter`).
+3. A POST naming another account, a missing/wrong `csrf`, or `step=connect`
+ on skip/done is refused and writes nothing (Task 3 tests).
+4. Marks are per account: hiding in account A leaves the card in account B
+ (Task 1 `TestGettingStartedMarksPerAccount`).
+5. Completion sticks: once all four are satisfied the `completed` mark is
+ stored and the card stays gone after a token expires; "Show getting
+ started" brings back live state (Task 4 `TestGettingStartedCompletionSticks`).
+
+---
+
+### Task 1: Marks table and store methods
+
+**Files:**
+- Create: `internal/console/gettingstarted_store.go`
+- Modify: `internal/console/store.go` (call the migration beside
+ `migrateAppStars` ~line 704; add the DELETE beside each `app_stars` DELETE in
+ `removeMemberTx` ~1559 and `ReapAccount` ~1811),
+ `internal/console/ownership.go` (~836, same), `internal/console/demo_members.go`
+ (~110, same), `internal/console/store_gate.go` (classify the table NonApp
+ beside `app_stars`)
+- Test: `internal/console/gettingstarted_store_test.go`
+
+**Interfaces:**
+- Produces:
+ - `type gsMark string` with consts `gsHidden = "hidden"`, `gsCompleted =
+ "completed"`, `gsSecretsDone = "secrets:done"`, `gsSecretsSkip =
+ "secrets:skip"`, `gsDomainDone = "domain:done"`, `gsDomainSkip = "domain:skip"`.
+ - `func (s *Store) migrateGettingStarted() error` — table
+ `getting_started_marks (account_id INTEGER NOT NULL, address TEXT NOT NULL,
+ mark TEXT NOT NULL, marked_at INTEGER NOT NULL, PRIMARY KEY (account_id,
+ address, mark))`.
+ - `func (s *Store) GettingStartedMarks(accountID int64, address string) (map[gsMark]bool, error)`
+ - `func (s *Store) SetGettingStartedMark(accountID int64, address string, m gsMark, now time.Time) error`
+ — idempotent insert; setting `secrets:done` deletes `secrets:skip` and vice
+ versa (same for domain), in one transaction.
+ - `func (s *Store) ResetGettingStarted(accountID int64, address string) error`
+ — deletes every mark for that person and account (Show).
+
+- [ ] **Step 1: Write failing tests**: `TestGettingStartedMarksRoundTrip`
+ (set hidden, read back `{hidden:true}`; repeat set is no error),
+ `TestGettingStartedDoneReplacesSkip` (skip then done leaves only
+ `secrets:done`), `TestGettingStartedReset` (all marks gone),
+ `TestGettingStartedMarksPerAccount` (mark in account 1 absent in account 2,
+ and for another address), `TestGettingStartedCleanup` (RemoveMember and
+ ReapAccount delete the person's / account's rows; follow the existing
+ app_stars cleanup tests' setup, `grep -n app_stars *_test.go`).
+- [ ] **Step 2: Run** `go test ./internal/console -run 'TestGettingStarted' -count=1` → FAIL (undefined).
+- [ ] **Step 3: Implement** the file, migration call, cleanup DELETEs and gate
+ classification (`{NonApp: "personal onboarding checklist marks keyed by
+ account and address; grants no app authority"}`). If a store-gate or
+ table-inventory test lists tables, add the new one there.
+- [ ] **Step 4: Run** the same command plus `-run 'TestGettingStarted|StoreGate|AppStar'` → PASS.
+- [ ] **Step 5: Commit** `console: getting-started marks table and store`.
+
+### Task 2: The facts and the view model (pure)
+
+**Files:**
+- Create: `internal/console/gettingstarted.go`, `internal/console/gettingstartedcopy.go`
+- Test: `internal/console/gettingstarted_test.go`
+
+**Interfaces:**
+- Consumes: Task 1 `gsMark` consts.
+- Produces:
+ - `func personConnected(tokens []CLIToken, now time.Time) bool` — true iff some
+ token has `Kind == ""`, `RevokedAt.IsZero()` and `ExpiresAt.After(now)`.
+ Person tokens always carry an expiry (`CLIToken.NeverExpires` is true only
+ for app/service kinds), so a zero or epoch expiry never ticks.
+ - `func appIsLive(row appRow, v AppView, acct string) bool` — THE predicate
+ (spec call 2): `row.Verdict == "ok"` AND (`row.Deployment.UniformVersion()
+ != "" || row.Deployment.Mixed()` OR some route with `rt.Account == acct &&
+ !rt.Platform && rt.Kind == "static"` whose OWN channel `rt.Channel` matches
+ a `v.Channels[i].Name` with `Err == ""` and `Version != ""`). Resolve an
+ empty `rt.Channel` the way `ladder.go` does (`release.Rung(rt.Channel)`);
+ if empty never resolves to a channel, it does not tick.
+ - `type gsStepState string` = `"done" | "skipped" | "open" | "muted"`.
+ - `type gsStep struct { Key string; State gsStepState; ... }` with keys
+ `"connect"`, `"deploy"`, `"secrets"`, `"domain"`.
+ - `type gettingStartedView struct { Steps []gsStep; CanCreate, IsOwner bool;
+ DomainApp string; Copy gettingStartedCopy }`.
+ - `func buildGettingStarted(marks map[gsMark]bool, connected, anyLive bool, role string, firstApp string, consoleName string) (view *gettingStartedView, complete bool)`
+ — returns `nil, false` when `hidden` or `completed` is set; else steps in
+ order, ticks 1-2 from facts, 3-4 from marks; the FIRST non-done/skipped
+ step is `open`, later ones `muted`; `complete` true when all four are
+ done/skipped (caller then stores `completed` and renders nothing).
+ `DomainApp` = `firstApp` (first app by the page's order) for the owner
+ link `/a/<sqid>/apps/<DomainApp>/settings/domains`; "" = no link.
+ `{console}` in copy is replaced with `consoleName` here.
+ - `gettingStartedCopy` struct and `approvedGettingStartedCopy` var holding
+ the strings below (drafts; Luna pass replaces them verbatim).
+
+Draft copy (for the Luna pass; keys are field names):
+```
+Title: Getting started
+Hide: Hide
+Show: Show getting started
+Done: Done
+Skipped: Skipped
+MarkDone: Mark done
+Skip: Skip
+Copy: Copy
+Copied: Copied
+ConnectTitle: Connect your agent or terminal
+ConnectBody: Ask your agent to sign in. It runs one command and gives you a link to approve.
+ConnectPrompt: Sign in to {console} with the carlos CLI: run carlos auth login --no-wait and give me the link it prints.
+ConnectCLI: carlos auth login
+DeployTitle: Put your first app live
+DeployBody: Ask your agent to deploy your app.
+DeployPrompt: Deploy this app to {console}. Use the carlos CLI; my account is ready.
+DeployCreate: Create an app here instead
+SecretsTitle: Add your app's secrets
+SecretsBody: If your app needs API keys or passwords, give them to your agent, or set them yourself with carlos secrets set.
+SecretsPrompt: Set the secrets my app needs on {console}
+DomainTitle: Use your own domain
+DomainBody: Point a domain you own at your app. Your agent can attach it with the carlos CLI.
+DomainCLI: carlos domains attach --app <app> <hostname>
+DomainLink: Attach a domain in settings
+SaveFailed: Could not save that. Please try again.
+```
+
+- [ ] **Step 1: Write failing tests**:
+ - `TestPersonConnected`: table: none → false; person live → true; person
+ expired (`ExpiresAt` = now-1s) → false; person revoked → false; `Kind
+ "app"` live → false; `Kind "service"` live → false.
+ - `TestAppIsLive` (spec guard tests): uniform version + ok → true; mixed + ok
+ → true; static-only site whose route channel `stable` has Version `v1`
+ → true; sole remote instance with `unknown` verdict and a version → false;
+ static route on `stable` with empty Version while `beta` has a version →
+ false; static channel with `Err` set → false; verdict `attention` with a
+ version → false; route of another account → false.
+ - `TestBuildGettingStarted`: fresh (nothing) → step 1 open, 2-4 muted;
+ connected → step 1 done, 2 open; connected+live+secrets:skip → 4 open;
+ all four → `nil, true`; hidden → `nil, false`; completed → `nil,
+ false`; member → `CanCreate` true, `IsOwner` false; no apps → `DomainApp ""`;
+ rendered copy contains no `{console}`, no "—" or "–".
+- [ ] **Step 2: Run** `go test ./internal/console -run 'TestPersonConnected|TestAppIsLive|TestBuildGettingStarted' -count=1` → FAIL.
+- [ ] **Step 3: Implement** both files.
+- [ ] **Step 4: Run** same → PASS.
+- [ ] **Step 5: Commit** `console: getting-started facts and view model`.
+
+### Task 3: Preference handlers (Opus: auth/CSRF)
+
+**Files:**
+- Create: `internal/console/gettingstarted_handlers.go`
+- Modify: `internal/console/server.go` (register beside the star route ~2129)
+- Test: `internal/console/gettingstarted_handlers_test.go`
+
+**Interfaces:**
+- Consumes: Task 1 store methods.
+- Produces routes (all POST, all `s.account(w, r)` for session + membership,
+ person = the session address, CSRF `subtle.ConstantTimeCompare(r.FormValue("csrf"), raw)`
+ exactly as `handleAppStar`; success → `303` to `accountHomeURL(acct.Sqid, "")`;
+ store error → 500 `renderMessage` with `SaveFailed`):
+ - `POST /a/{sqid}/getting-started/hide` → `gsHidden`
+ - `POST /a/{sqid}/getting-started/show` → `ResetGettingStarted`
+ - `POST /a/{sqid}/getting-started/skip` with `step=secrets|domain`
+ - `POST /a/{sqid}/getting-started/done` with `step=secrets|domain`
+ - any other `step` (incl. `connect`, `deploy`, empty) → 400, nothing written.
+- Demo accounts: if `s.demoMutationRefusal` has an account-level form, apply
+ it; otherwise the marks are personal and allowed (say which in the report).
+
+- [ ] **Step 1: Write failing tests** using the existing star-handler test
+ harness (`grep -n handleAppStar *_test.go` / `"/star"`):
+ `TestGettingStartedHideShow` (hide → mark set, 303 to `/a/<sqid>/`; show →
+ no marks), `TestGettingStartedSkipDone` (skip secrets → `secrets:skip`;
+ done domain → `domain:done`), `TestGettingStartedRefusesBadStep`
+ (`connect`, `deploy`, `""`, `x` → 400, no rows), `TestGettingStartedRefusesCSRF`
+ (missing and wrong csrf → 403, no rows), `TestGettingStartedRefusesStranger`
+ (non-member session → 404, no rows; no session → redirect to `/`),
+ `TestGettingStartedIgnoresFormAddress` (an `address=` form field naming
+ someone else writes the session person's row only).
+- [ ] **Step 2: Run** `go test ./internal/console -run 'TestGettingStarted(HideShow|SkipDone|Refuses|Ignores)' -count=1` → FAIL.
+- [ ] **Step 3: Implement** handlers and route registration.
+- [ ] **Step 4: Run** same → PASS.
+- [ ] **Step 5: Commit** `console: getting-started hide, show, skip, done`.
+
+### Task 4: The card on the apps page
+
+**Files:**
+- Create: `internal/console/templates/getting_started.html` (`{{define
+ "getting_started"}}`), `internal/console/static/getting_started.js`
+- Modify: `internal/console/server.go` (`page` gets `GettingStarted
+ *gettingStartedView` and `ShowGettingStarted bool`; `handleAccountHome`
+ ~4248 builds them), `internal/console/templates/apps.html` (include the
+ partial right after `</div>` closing `pagehead` in BOTH branches; the Show
+ form beside the Trash link at the bottom)
+- Test: `internal/console/gettingstarted_page_test.go`
+
+**Interfaces:**
+- Consumes: Tasks 1-3.
+- `handleAccountHome`: after the app rows are built, compute `anyLive` over
+ the zipped `views`/`p.Apps` (before filtering; keep the `AppView`s from
+ `assembleAppsNamed`), `tokens, err := s.store.CLITokens(addr)` (err → log,
+ `connected=false`), `marks, err := s.store.GettingStartedMarks(acct.ID, addr)`
+ (err → log, no card, no Show link), then `buildGettingStarted`. If
+ `complete`, `SetGettingStartedMark(gsCompleted)` (err → log) and render no
+ card. `ShowGettingStarted` = marks has `hidden` or `completed` (no card).
+- Card markup: a `confirm-card` section with `<h2>` Title, Hide form (`linkish`
+ button) top right, an `<ol>` of steps; done/skipped steps show a `chip` with
+ Done/Skipped and the title; the open step shows body, the prompt in a
+ `<code id="gs-prompt-<key>">` with a hidden `data-copy-target` Copy button,
+ and its actions (Create link if `CanCreate`; domain link if `IsOwner &&
+ DomainApp != ""`; Mark done/Skip forms for secrets/domain); muted steps show
+ only the title, muted (existing `small`/muted text class). Every form carries
+ `<input type="hidden" name="csrf" value="{{.CSRF}}">` (use whatever field the
+ star form uses).
+- JS: copy of `demo_claim.js`'s `[data-copy-target]` loop only; load it the way
+ other page scripts load (nonce/CSP as they do).
+
+- [ ] **Step 1: Write failing tests** with the existing account-home render
+ harness (`grep -n handleAccountHome *_test.go`):
+ `TestGettingStartedCardFresh` (new account, no tokens: card present, step
+ connect open with the prompt text, no "Carloku" literal, no `{console}`);
+ `TestGettingStartedIgnoresFilter` (live app + `?q=zzz` still shows deploy
+ done); `TestGettingStartedHiddenShowsLink` (hidden mark: no card, Show form
+ present); `TestGettingStartedCompletionSticks` (all satisfied → `completed`
+ stored and no card; then expire the token → still no card; reset → card
+ back with connect open); `TestGettingStartedMemberNoDomainLink` (member sees
+ no `/settings/domains` link, owner does); `TestGettingStartedNoS3`
+ (if the harness counts bucket calls, assert the same count with and without
+ the card; otherwise state in the report that only DB reads were added).
+- [ ] **Step 2: Run** `go test ./internal/console -run 'TestGettingStartedCard|TestGettingStartedIgnoresFilter|TestGettingStartedHidden|TestGettingStartedCompletion|TestGettingStartedMember|TestGettingStartedNoS3' -count=1` → FAIL.
+- [ ] **Step 3: Implement** template, JS, page fields and handler wiring.
+- [ ] **Step 4: Run** same plus `-run 'AccountHome|AppList|Template'` → PASS.
+- [ ] **Step 5: Render check:** dump the fresh-state and mid-state (connect
+ done, deploy open) pages from a test to `$TMPDIR`, screenshot with headless
+ chromium at 390 px and 1280 px wide; no horizontal scroll, buttons ≥ 40 px
+ tall, card matches the existing confirm-card look. Attach paths in the report.
+- [ ] **Step 6: Commit** `console: getting-started card on the apps page`.
+
+### After the tasks (controller)
+
+- Luna copy pass over `gettingstartedcopy.go`, apply verbatim, rerun Task 2/4 tests.
+- `make census-card`; whole-branch Astra review (max 3 rounds, stopping rules).
+- `gofmt -l .`, `go vet ./internal/console`, push, CI green, merge, release.