# alta

Alta (*dar de alta*, to enrol) is Paul's team-provisioning app: it creates
a **team** — one CARLOS instance per Oficina app, each bound to its own
standalone environment owned by scope `alta`, attached at
`<label>.<app>.oficina.works`, registered with Home — through Home's signed
operator endpoint and the CARLOS `team` credential. Paul-only, separate from
Home.

The design is Home's `implementation/team-provisioning-app.md` (APPROVED,
discussion 92), with `team-provisioning-amendment.md` (the Home endpoint,
implemented at Home `82d9388`; `homecompat` pins `0cee9ba`) and carlos/platform
`implementation/team-scoped-credentials.md` (merged `9bcbab0f5`, not
released). Read all three before changing behaviour here; a change that
departs from them needs the same review they had.

A [rastrillo](https://amadan.net/rastrillo/rastrillo) app, on the current
`amadan.net/rastrillo/rastrillo` import path (never the frozen
`github.com/carlosframework/rastrillo` one), styled with estilo.

## Layout

- `homeop/` — Alta's half of Home's operator endpoint: the signed
  operation, plan and inspect challenge, every verb's input and Home's
  result, **field for field and tag for tag as Home's
  `internal/operator` declares them** (Home re-encodes what it decodes and
  compares bytes; a moved field is a refused request). `homeop/fakehome` is
  an in-memory Home for the engine's tests.
- `console/` — the CARLOS console client: one `team` credential per app,
  the account by **sqid** (`bds`), client-side envelope sealing, and the §8
  guards every request passes before it is sent. `console/fakeconsole` is
  the console as a team credential meets it, with the platform walks.
- `provision/` — Alta's sealed SQLite state (`store.go`,
  `migrations/`), the per-app recipes (`apps.go`, §5's GENERATED / SET /
  PLATFORM), and the §6 state machine (`engine.go`, `steps.go`).
- `internal/web/` — the pages (§11), Home sign-in, the operator-only gate.
- `cmd/alta/` — serving, and `alta keygen`.
- `homecompat/` — a separate, test-only module that runs Alta's engine
  against **Home's real operator code** at the pinned commit. It takes a
  module path under `amadan.net/oficina/home/` because Go admits imports of
  Home's `internal/` only from there; it is never built into anything.
  Bump its `go.mod` pin when Home's operator code changes, and re-read the
  diff of `internal/operator` against `homeop/protocol.go`.

## Rules Alta holds hard

- **Alta never holds a platform credential.** No SMTP password, no
  `CARLOS_RELAY`, no TURN secret, no operate or instance token. PLATFORM
  keys are waited for, never written; the guard refuses every prefix's SMTP
  five, the relay, the mail-events key, scan callback secrets and store
  coordinates, whatever the recipe says.
- **Generated keys are never regenerated.** Existence is checked by name;
  a DEK that changes under a database makes it unreadable.
- **Nothing is inferred from a timeout.** A request is stored, sealed,
  before it is sent; a lost answer is recovered by exact replay. A refused
  request never consumed a sequence.
- **Nothing is deleted to clean up**, and labels and retired hostnames are
  never reused. The only DELETEs are §9's, inside a retire-apps run.
- **No address at rest once it is no longer needed.** The owner's address
  lives sealed in `owner_inputs`, the credential plan and the owner-seed
  request until the seed has committed and every recipe that writes it (a
  stopgap allowlist, or a seeded app's owner: `EQUIPO_OWNERS`,
  `BASE_OWNER`) is written, then all three are deleted (`secure_delete`).
- **Logs carry step keys and fixed codes only**: never a label, an address,
  a key or a platform value.
- Screens work without JavaScript; the only script is estilo's `busy.js`.
  Destructive actions have their own confirm page with a typed label.
- The gate is `make ci` (vet, gofmt, tests, homecompat), the same
  definition CI runs. `CGO_ENABLED=0` throughout. Use `make`, not bare
  `go test`: the Makefile pins the toolchain.

## Serving

`rastrillo.Resolve` + `Serve` speak the CARLOS activation contract;
`./alta -addr :8080` serves anywhere. `GET /healthz` and `GET
/api/version` are the framework's. Alta hibernates: a run waiting on a
domain or a walk advances when Paul next opens a page or presses Resume,
and every 20 s while the process is awake.

## Deploying

Not before the CARLOS team credential and its floor release exist (Paul's
condition on ruling 8). The checklist is the README's "Deploying". No live
CARLOS writes, no AWS and no deploys from an agent session.

## Work in a worktree, and catch main up first

    git -C <repo> fetch origin
    git -C <repo> worktree add ../<repo>-<task> -b <branch> origin/main

Several sessions share this machine; a checkout has one HEAD between all of
them. Remove the worktree when the work has landed.
