Plan 1: round 2 fix (P2-N1) and P3s; READY AFTER FIXES
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+11
−6
docs/superpowers/plans/2026-11-01-equipo-plan-1-foundation.md+11 −6
CI failed — run details
diff --git a/docs/superpowers/plans/2026-11-01-equipo-plan-1-foundation.md b/docs/superpowers/plans/2026-11-01-equipo-plan-1-foundation.md| index 766d0fcb..2ff6b061 100644 |
| --- a/docs/superpowers/plans/2026-11-01-equipo-plan-1-foundation.md |
| +++ b/docs/superpowers/plans/2026-11-01-equipo-plan-1-foundation.md |
| @@ -38,7 +38,7 @@ |
| ## Grounding and scope decisions |
| -Initial grounding used Equipo `5042a9e`, memoria `617eb2a` and Rastrillo `v0.28.0`. Round 1 revisions were checked at Equipo HEAD `b8bfd57`, against that same Rastrillo tag (`86dd77b`) and `/home/paulca/amadan.net/carlos/platform-team-service/internal/team`. Prototype HEAD is `cb280f7`; its package diff against `ceee7a67` is empty. Copy from `ceee7a67`. |
| +Initial grounding used Equipo `5042a9e`, memoria `617eb2a` and Rastrillo `v0.28.0`. Round 1 revisions were checked at Equipo HEAD `b8bfd57`, against that same Rastrillo tag (tag object `86dd77b`, commit `58718d8`) and `/home/paulca/amadan.net/carlos/platform-team-service/internal/team`. Prototype HEAD is `cb280f7`; its package diff against `ceee7a67` is empty. Copy from `ceee7a67`. |
| | Source | Decision | |
| |---|---| |
| @@ -80,7 +80,7 @@ Shared app types: `Role string` with only `owner` and `member`; `Actor{Address s |
| **Interfaces:** Consume the pinned Rastrillo APIs. Produce `App(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logger) (*http.ServeMux, error)`, `Config{Origin, InstanceKey string; Owners []string; AllowLoggedMail bool}`, `LoadConfig(getenv func(string) string) (Config, error)`, `Schema`, `BootSchema`, `Models`, and the `Store` contract above. Keep the scaffold decomposition with `Router(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logger) (chi.Router, error)`, `Mux(r http.Handler) *http.ServeMux` and `Configure(opts *rastrillo.Options, mux *http.ServeMux, started time.Time)`; update the generated HTTP/browser/performance harness callers together. Preserve `TestPerfScreens` and its `perftest.ScreenConfig.Signin` hook; Task 3 supplies a capturing-mailer sign-in helper, and Task 8 measures the private pages with its session cookie. Until Task 3, private routes return service unavailable rather than an unauthenticated scaffold page. |
| -- [ ] **Step 1: Write failing boot/gate tests.** `TestFoundationFailsClosed` requires an unauthenticated private request to fail, an empty key, invalid origin or incomplete SMTP config to reject boot, and missing owners to reject first boot on an empty DB. `TestFoundationMigratesTwice` applies `BootSchema` twice without losing a row. `TestCIGateSteps` checks executable CI wrappers call the same Make targets. Assertion examples: |
| +- [ ] **Step 1: Write failing boot/gate tests.** `TestFoundationFailsClosed` requires an unauthenticated private request to fail, an empty key, invalid origin or incomplete SMTP config to reject boot. (Missing owners on an empty DB is Task 3's `TestRosterBootstrapOnce`, since `Bootstrap` is a Task 3 interface.) `TestFoundationMigratesTwice` applies `BootSchema` twice without losing a row. `TestCIGateSteps` checks executable CI wrappers call the same Make targets. Assertion examples: |
| ```go |
| // TestFoundationFailsClosed |
| @@ -114,7 +114,7 @@ Shared app types: `Role string` with only `owner` and `member`; `Actor{Address s |
| **Interfaces:** Produce `(*Store).Bootstrap(ctx context.Context, owners []string) error`, `Member(ctx context.Context, address string) (Member, error)`, `SetMember(ctx context.Context, actor Actor, address string, role Role, active bool, revision int64) error`; `NewAuth(d *db.DB, cfg Config, mailer mail.Sender, store *Store, logger *slog.Logger) (*auth.Auth, error)`; middleware `requireMember(next http.Handler) http.Handler` on the app. |
| -- [ ] **Step 1: Write tests.** `TestRosterBootstrapOnce` checks one team and normalized unique owners across two boots; changed or absent `EQUIPO_OWNERS` after first boot cannot add or resurrect members. `TestRosterProtectsLastOwner` tests store calls: last active owner cannot be removed/demoted, and a member cannot promote themselves. `TestRosterChangesAffectExistingSession` uses a test-only private handler behind the production middleware: demotion keeps the session but denies owner store mutations; removal deletes every session for that subject, and re-adding the member cannot revive an old cookie. A DB lookup failure on a still-valid session returns 503. `TestSigninAdmission` signs in owner/member through a capturing mailer, denies an outsider and invalid cookies, and checks that `Authorize` returns false on a DB error. `TestSigninCSRF` covers the mounted auth POST routes only; roster HTTP checks wait for Task 8. `TestAuthProductionConfig` applies `BootSchema` and calls the production `NewAuth`, requiring `auth.New` to succeed with its real guard and no `ProofOff`. `TestSigninNoProof` rejects missing, premature and replayed tokens and accepts a valid aged token without JavaScript. Assert: |
| +- [ ] **Step 1: Write tests.** `TestRosterBootstrapOnce` checks that an empty DB with no `EQUIPO_OWNERS` refuses to boot, then one team and normalized unique owners across two boots; changed or absent `EQUIPO_OWNERS` after first boot cannot add or resurrect members. `TestRosterProtectsLastOwner` tests store calls: last active owner cannot be removed/demoted, and a member cannot promote themselves. `TestRosterChangesAffectExistingSession` uses a test-only private handler behind the production middleware: demotion keeps the session but denies owner store mutations; removal deletes every session for that subject, and re-adding the member cannot revive an old cookie. A DB lookup failure on a still-valid session returns 503. `TestSigninAdmission` signs in owner/member through a capturing mailer, denies an outsider and invalid cookies, and checks that `Authorize` returns false on a DB error. `TestSigninCSRF` covers the mounted auth POST routes only; roster HTTP checks wait for Task 8. `TestAuthProductionConfig` applies `BootSchema` and calls the production `NewAuth`, requiring `auth.New` to succeed with its real guard and no `ProofOff`. `TestSigninNoProof` asserts that missing, premature and replayed tokens send no mail (the framework answers with a 303 to `err=check`; assert on the capturing mailer, not the status) and that a valid aged token sends one link without JavaScript. Assert: |
| ```go |
| if !errors.Is(err, equipo.ErrForbidden) { t.Fatal("member changed roster") } |
| @@ -126,7 +126,7 @@ Shared app types: `Role string` with only `owner` and `member`; `Actor{Address s |
| - [ ] **Step 3: Implement the roster.** Bootstrap in one transaction only when the team row is absent; persist monotonically increasing `RosterEpoch` on changes. Seed owners from the configured list, then use the DB as authority. Attribute the initial seed audit to `bootstrap`, not to a person who has not signed in. Roster changes use revision checks and preserve at least one owner. On removal, delete rows in the framework `sessions` table for the normalized subject in the same transaction as the roster update and audit; failure rolls back the removal. Keep the live roster check as well. Task 4 adds the assigned-decision-owner removal rule once projects exist. Missing rows are `ErrNotFound`; DB errors remain `ErrUnavailable`. |
| - [ ] **Step 4: Wire existing auth.** After `BootSchema`, create `pow.New` with the instance key, `Nonces: pow.SQLNonces(d.Writer())`, `Difficulty: pow.NoProof` and `MinAge: pow.DefaultMinAge` (three seconds). Pass the guard as `Proof` to the process's single `auth.New`; leave `ProofOff` false. Set `Authorize` to return true only for current active members, false on missing rows or any DB error; `SubjectFor` returns the normalized address. Keep `KeymailServers: []string{"keymail.dev"}` and the supplied mailer/key/origin. |
| - Choose `SigninScreen: true` and the shipped `ui` `signin`/`signin-title` partials in a stage-layout `signin_page.html` wrapper. Build the state with `Auth.SigninState(r)`, call `PrepareSigninResponse`, then render; wire `RenderConfirm` to that renderer. The partial includes `.State.Proof.Fields` on Begin forms and checks `NeedsScript`, so this `NoProof` configuration needs no `pow.Assets()` or script URLs. Verified at the tag in `ui/partials/signin.html`, `TestSigninNoProofRendersAnEnabledSubmit` and `TestBrowserNoProofWorksWithoutJavaScript`. |
| + Schedule `Auth.Sweep` and the nonce store's sweep hourly from the app's background loop so spent tokens and old links are pruned. Session creation after a racing removal is closed by checking a per-member removal epoch in `requireMember`: a session created before the member's latest re-add is refused. Choose `SigninScreen: true` and the shipped `ui` `signin`/`signin-title` partials in a stage-layout `signin_page.html` wrapper. Build the state with `Auth.SigninState(r)`, call `PrepareSigninResponse`, then render; wire `RenderConfirm` to that renderer. The partial includes `.State.Proof.Fields` on Begin forms and checks `NeedsScript`, so this `NoProof` configuration needs no `pow.Assets()` or script URLs. Verified at the tag in `ui/partials/signin.html`, `TestSigninNoProofRendersAnEnabledSubmit` and `TestBrowserNoProofWorksWithoutJavaScript`. |
| Mount GET `/signin`, POST `/auth/begin`, GET `/auth/callback`, GET and POST `/auth/verify`, POST `/auth/forget`, and POST `/signout`; set `BeginPath` and `ForgetPath` to those mounted paths. Protect mutating routes with `csrf.Protect(cfg.Origin)`. Private routes use `Auth.RequireSession`, then `auth.From(r)` and a live roster lookup. Preserve framework keymail, email fallback, rate limiting and cookies. |
| @@ -149,7 +149,7 @@ Shared app types: `Role string` with only `owner` and `member`; `Actor{Address s |
| ``` |
| - [ ] **Step 2: Run red tests.** `go test ./internal/equipotest -run 'TestProjects|TestProject|TestRosterRemovalWhileAssigned' -count=1`. |
| -- [ ] **Step 3: Implement metadata transactions.** Only team owners configure account labels, repository/app bindings and decision owners; all active members can read. Accept `amadan.net/<owner>/<repo>` or its HTTPS spelling, canonicalize to an HTTPS URL with exactly those two non-empty path segments, and store no credential. Blank `AppName` is valid. Require kind and owner-entered `DefaultBranch` in the record and create/edit form. Use one validated canonical branch-name spelling for saved branches and target refs. Do not probe repositories or CARLOS. Refuse roster removal while any project decision is assigned to that member; check this inside the removal transaction. Validate owners within the same transaction as the project write, use allowlisted form DTOs later, and audit the actual person. Store idempotency keys with the actor, operation and input hash. A CARLOS label is display metadata, never a `team.AccountID` or authority boundary. |
| +- [ ] **Step 3: Implement metadata transactions.** Only team owners configure account labels, repository/app bindings and decision owners; all active members can read. Accept `amadan.net/<owner>/<repo>` or its HTTPS spelling, canonicalize to the forge-qualified form `amadan.net/<owner>/<repo>` (the same spelling `team.TargetBinding.Repository` uses, so Authority compares like with like) with exactly two non-empty path segments, and store no credential. Blank `AppName` is valid for `repository` and `website` projects; an `app` project requires one; a `repository` project must leave it blank. Require kind and owner-entered `DefaultBranch` in the record and create/edit form. Use one validated canonical branch-name spelling for saved branches and target refs. Do not probe repositories or CARLOS. Refuse roster removal while any project decision is assigned to that member; check this inside the removal transaction. Validate owners within the same transaction as the project write, use allowlisted form DTOs later, and audit the actual person. Store idempotency keys with the actor, operation and input hash. A CARLOS label is display metadata, never a `team.AccountID` or authority boundary. |
| - [ ] **Step 4: Verify.** Run the targeted tests and `make migration-check`; close/reopen the app DB and verify the same grouping and owner assignments. New form IDs are unique per rendered form; duplicate submit has one effect. |
| - [ ] **Step 5: Commit.** Stage Task 4 files; `git commit -m "feat: add projects and decision ownership"`. |
| @@ -233,7 +233,7 @@ Shared app types: `Role string` with only `owner` and `member`; `Actor{Address s |
| - [ ] **Step 3: Review copy before inserting it.** No existing runtime copy convention exists at this HEAD; establish `internal/equipo/copy.go` as that single source. Follow the copy-review skill during implementation: index every app-owned string with context, including validation, empty states, email subject/body, titles, labels and accessible names; apply Paul's edits verbatim. Required navigation names use Paul’s revised rail in the Round 1 brief and `docs/mockups/nav.html`. Other keys include `projects.empty`, `projects.add`, `signals.unconnected`, `form.invalid`, `form.conflict`, `service.unavailable`, `conversation.empty` and specialist empty states. Keep draft wording short; mark the inventory `COPY REVIEW REQUIRED` until approved. Do not copy mockup sample activity or invent final prose in this plan. Add reviewed README copy through the same gate. |
| - [ ] **Step 4: Implement the shell and routes.** Use the pinned sidebar template/attributes; customize its blocks, not its mechanics. `/` redirects to `/conversation`; `/work` is the phone index (`view=index`); content pages have parent links back to `/work#nav-<key>`. Routes: GET `/conversation`, `/needs-you`, `/journey`, `/projects`, `/connections`, `/people`, `/settings`, `/specialists/{key}`, `/projects/new`, `/projects/{id}`, `/projects/{id}/edit`. POST `/accounts`, `/projects`, `/projects/{id}`, `/team/members`, `/team/budgets`, `/specialists/{key}` use the corresponding store mutators and redirect 303 after success. Render unknown IDs/keys as 404; invalid form as 422; stale revisions as 409; owner-only denial as 403. Use a single team header linking to `/people`, followed by the four work pages, the five Specialists and the Team group (Connections, People, Settings), as in the revised mockup. The header is not a second selected nav item or a team switcher. |
| - [ ] **Step 5: Implement grouped cards and settings forms.** Projects overview uses account headings and project cards from `projects.html`; show each project’s saved kind and metadata and actual project counts in one list, with no separate app/website lists. With no jobs, activity areas have reviewed empty states, not sample work or percentages. Show configured limits and zero usage separately; missing limits are unset, not zero. Each project page is a metadata/settings detail, not the later product view. People exposes the roster; Settings exposes account-label and budget forms; specialist pages expose their stored settings plus empty working/queued/finished sections. Connections remains an empty destination; personal preferences stay in plan 3. Use `html/template` escaping, icons from the vendored icon set, and only theme tokens in app CSS. |
| -- [ ] **Step 6: Verify.** Run page tests and `go test ./internal/equipotest -run TestVendoredAssetsMatchTheLibrary -count=1`; confirm `theme.css` and `shell.css` are linked and copied library bytes match `v0.28.0`. Navigation and every form work without scripts. Update `TestPerfScreens` with seeded concrete `Paths` for project and specialist routes. Its `ScreenConfig.Signin` calls Task 3’s email-link helper using the supplied client/cookie jar and base URL, with the configured Origin on POSTs; sign-in and the `MinAge` wait occur before timing. Require 200 plus a page-specific content assertion for each private page, and keep redirects explicit for `/`; never count a sign-in redirect as a measured private page. Run `make perf`. |
| +- [ ] **Step 6: Verify.** Run page tests and `go test ./internal/equipotest -run TestVendoredAssetsMatchTheLibrary -count=1`; confirm `theme.css` and `shell.css` are linked and copied library bytes match `v0.28.0`. Navigation and every form work without scripts. Update `TestPerfScreens` with seeded concrete `Paths` for project and specialist routes. Its `ScreenConfig.Signin` calls Task 3’s email-link helper using the supplied client/cookie jar and base URL, with the configured Origin on POSTs; sign-in and the `MinAge` wait occur before timing. Require 200 plus a page-specific content assertion for each private page, and keep redirects explicit for `/`; never count a sign-in redirect as a measured private page. Add `Expect` entries or `budgets.txt` skip records for `/signin`, `/auth/callback` and a token-less `/auth/verify`; `TestPerfBoot` configures owners. `make perf` joins the CI gate in this task, not before (private routes answer 503 until Task 8). Run `make perf`. |
| - [ ] **Step 7: Commit.** Stage Task 8 files and approved copy; `git commit -m "feat: add the rail and grouped projects overview"`. |
| ## Task 9: Exercise the finished app in a browser and provide local startup |
| @@ -296,3 +296,8 @@ Resolved: Paul chose `oficina` on the flagship console, [https://console.carloku |
| - Paul’s deployment answer: Task 10 now targets `oficina` on the flagship console and the account question is resolved. |
| - Paul’s project kinds: Added app/website/repository to the record, forms, tests and each card in one Projects list. |
| - Paul’s rail: Task 8 now specifies the team header, four work pages, five Specialists and Team group with Connections, People and Settings. |
| + |
| +## Round 2 dispositions (Opus R2: READY AFTER FIXES) |
| + |
| +- P2-N1: the empty-DB owners check moved from Task 1 to Task 3's `TestRosterBootstrapOnce`. |
| +- P3s applied: perf `Expect`/skip records and `make perf` joining the gate at Task 8; hourly `Sweep` of auth and nonces; one forge-qualified repository spelling for projects and Authority; removal-epoch check against a racing sign-in; kind/app-name rules; NoProof assertions on the mailer; tag object versus commit in grounding. |