# Equipo

One instance belongs to one team. Members share projects and work.
Read `docs/superpowers/specs/2026-11-01-equipo-design.md` and the current
controller brief before changing behavior. Task dispatch instructions take
precedence over generic workflows.

## Model text and authority

1. Model-written text is never the person's words. A tapped option the model
   wrote is a choice among model text, not a statement by the person.
2. A change never authorises its own merge. Evidence the candidate can edit
   (its own checks, its own diff) is never trusted.
3. Untrusted text enters a prompt only quoted, under a label naming its source.
4. Anything an agent writes that leaves the system or opens in a browser needs
   the person's tap or a standing project setting they chose, plus deterministic
   checks. A private tailnet limits readers; it does not stop a page sending
   data elsewhere.
5. A sandbox that runs agent-chosen code has no network. Dependencies come
   from a mirror.

## Data and authority

- Never use `scope.Owned` or `scope.OwnedBy` for shared team records.
- Derive `Actor` from the verified session, never a submitted form field.
- Check the current roster inside each write transaction. Removal and role
  changes must affect existing sessions immediately. Lookup errors deny access.
- Use the transaction handle throughout a transaction. Append the audit event
  there too, with no credentials in it.
- Never bind requests onto GORM models. Read allowed fields explicitly and use
  `.Select` for updates.
- Keep migrations additive. App tables belong in `Models` and `Schema`;
  framework sessions, auth and proof tables belong only in `BootSchema`.
- An unknown count must remain unknown. Never turn a query error into zero.
- `NewStore` grants no authority. Execution is off unless
  `EQUIPO_EXECUTION_ENABLED=1`; runner dispatch uses only the gated paths.

## Boot and interface

Require `EQUIPO_ORIGIN` and `EQUIPO_INSTANCE_KEY`. Require a mail channel:
CARLOS mail submission (`CARLOS_MAIL=submit`, set only by the CARLOS agent), or
both `CARLOS_SMTP_HOST` and `CARLOS_SMTP_FROM`, unless local logged mail is
explicitly enabled with `EQUIPO_ALLOW_LOGGED_MAIL=1`. Logged mail is
allowed only on loopback or a staging origin. Build the sender with `equipo.Mailer` (`mail.FromCarlos`) only on
the serve path, never in a seed or one-shot, which has no control socket.
`EQUIPO_OWNERS` is enforced by bootstrap only when the database has no team.
Never log credentials or sign-in links in production.

Production upgrades: an agent runs `scripts/upgrade-thin.sh <version> --execute` (and its rollback) itself, then tells Paul. With a green staging run and no waiver it needs no one's go (Paul, 2026-11-20). A waiver is Paul's decision; once he approves one, the agent still runs the upgrade, not Paul (Paul, 2026-11-22). The cutover scripts and anything needing the owner's sign-in (enrolment links, revoking machines) stay with Paul.

The page renderer is not in the instance (it would pass the platform's 256 MiB ship cap). A release whose `renderer.tar.gz` changed is published before staging with `scripts/publish-renderer.sh publish <the runner release directory>`: the archive and its `SOURCES` on the forge, under the tag linked into the runner. Staging downloads and checks it (`publish-renderer.sh check`) before it installs anything, and refuses an unpublished one. Self-serve installs fetch it from there.

Use Rastrillo v0.45.0 APIs from the pinned module cache. Resolve activation,
open one database, construct the app, clear `opts.DBPath`, then serve.
The database closes on shutdown and on failed app construction.

Use the day theme and sidebar shell. Link tokens.css and theme.css. Keep
vendored static files byte-identical and put app styling in equipo.css.
The sign-in door (`internal/equipo/door`, Home's smart-door spec) is
estilo's door around rastrillo's one-way screen; `static/estilo/` is
estilo's, byte for byte.
Use the attribute grammar, token colors, scriptless forms and phone index
navigation. Do not add a split screen or an authentication bypass.

## Copy and verification

App-owned runtime strings live only in `internal/equipo/copy.go`. Mark changed
entries pending with `python3 scripts/copy-status.py pending` (bounded JSON
stdin: candidate root and keys). The trusted-base `.equipo/copy.json` contract
extracts changed values independently of markers. When an owner enables
"Copy can accept on my behalf" for this project, Copy reviews structured
strings and the runner applies the result and invokes `accept` only for the
reviewed changed keys, with matching server records and exact text hashes.
Engineering never invokes `accept` or writes acceptance markers. With the
setting off, Copy does not run and pending copy still blocks release.
`regenerate` repairs pending bookkeeping; `verify` checks without writing.
The release gate remains `make copy-release-check`. Owner edits and imports
teach only that delegating owner's Copy notes; forge diffs never teach.
Use plain words, no em dashes and no exclamation marks. Leave README prose
unchanged unless the task explicitly authorizes reviewed or flagged draft copy.

Write a failing test before implementation. Observe each guard fail by
breaking the behavior it protects, then restore it. Record the commands and
results in the controller report.

`make ci` is the shared local and CI gate: build, vet, formatting, staticcheck,
govulncheck, gitleaks, budgets, tests, migration check and performance. Keep
`.amadan/ci` and `.amadan/ci.d/` delegating to the same Make targets. Follow the
controller's narrower gate list for individual tasks. Builds use `CGO_ENABLED=0`.

Never merge, push the default branch, or deploy autonomously. Human deployment
uses a versioned release. Keep scratch under on-disk `$TMPDIR`, leave Go caches
at their defaults, bind local servers to `127.0.0.1`, and clean up processes
and scratch before handing back.
