| 1 | # Add Equipo to the existing Oficina team |
| 2 | |
| 3 | Implementer: Codex GPT-6-Astra. Approved scope: Equipo's 2026-11-20 |
| 4 | native Oficina ID spec, E4. This runbook is for Paul on the Mac holding |
| 5 | Alta's existing operator configuration and state. No commands here were |
| 6 | executed against production with writes during implementation. |
| 7 | |
| 8 | ## Prerequisites |
| 9 | |
| 10 | - Land and deploy the reviewed Home `native/equipo-in-directory` change to |
| 11 | **both** `oficina` and `oficina-id`; verify their `X-Carlos-Version`. |
| 12 | - Land this Alta change and build `make adopt` on the operator Mac. |
| 13 | Before deleting Home's source branch after a squash merge, re-pin Alta's |
| 14 | test-only `homecompat` module to the Home merge commit and pass `make ci`. |
| 15 | - The separately implemented Equipo adoption contract below must be |
| 16 | deployed at `https://equipo.oficina.works`, with its existing instance, |
| 17 | storage and access policy preserved. Its native exchange must also be |
| 18 | deployed before testing native sign-in. |
| 19 | - Configure Equipo's existing Oficina ID integration **before** capturing |
| 20 | the adoption baseline: `EQUIPO_HOME_ISSUER=https://id.oficina.works`, |
| 21 | `EQUIPO_HOME_CONSUMER_ID=equipo`, `EQUIPO_HOME_KEYS_BASE64` containing the |
| 22 | pinned Home public key map, and `EQUIPO_HOME_DEK_BASE64` containing its |
| 23 | persistent 32-byte key. Use the Equipo rollout for this step: preserve an |
| 24 | existing DEK, never regenerate it. The key map is a base64-encoded JSON |
| 25 | object mapping key IDs to encoded public keys (`connect/config.go`). |
| 26 | - Use a current CARLOS CLI with `services` and `db query`. Reuse the same |
| 27 | Alta config, state path, operator key and pins. Do not initialize again |
| 28 | or run keygen. Alta's web process must not run concurrently with the |
| 29 | adoption runner; both own the same signed streams. |
| 30 | - Calendar's Plan B must still be active in the existing journal. The |
| 31 | runner checks this again before Equipo activation. |
| 32 | |
| 33 | Read-only observations on 2026-11-20, 14:42–14:49 UTC: Home served |
| 34 | `5e5ebe54f4c4eacfb6aa053919c91ebce0d05af8`; its default |
| 35 | `HOME_CONSUMERS_BASE64` had ten entries, neither `equipo` nor its canonical |
| 36 | origin. `/authorize?consumer=equipo&nonce=AAAAAAAAAAAAAAAAAAAAAA` answered |
| 37 | 400, with the identical Docs control answering 303. Equipo served |
| 38 | `b6c76de2`, its operations path returned its generic API 401, and |
| 39 | `/auth/start` redirected locally to `/signin`. The default Equipo env and |
| 40 | secret-name listings contained none of the four `EQUIPO_HOME_*` keys. |
| 41 | These are observations of that deployment, not evidence of a later release |
| 42 | or of other config layers. Current live sign-in is a prerequisite, not |
| 43 | something `alta-adopt configure` installs. |
| 44 | |
| 45 | ## 1. Verify and register the canonical consumer |
| 46 | |
| 47 | Native assert and web authorize read the same effective registry. This |
| 48 | public check creates no login session and prints no cookie/token: |
| 49 | |
| 50 | ```sh |
| 51 | curl -sS -o /dev/null -w 'Equipo consumer HTTP %{http_code}\n' \ |
| 52 | 'https://id.oficina.works/authorize?consumer=equipo&nonce=AAAAAAAAAAAAAAAAAAAAAA' |
| 53 | curl -sS -o /dev/null -w 'Docs control HTTP %{http_code}\n' \ |
| 54 | 'https://id.oficina.works/authorize?consumer=docs&nonce=AAAAAAAAAAAAAAAAAAAAAA' |
| 55 | ``` |
| 56 | |
| 57 | Expected: both 303. A 400 for Equipo with a 303 control means the consumer |
| 58 | ID is not registered. A 303 establishes ID admission; the following manifest |
| 59 | inspection establishes its exact origin. Canonical adoption requires the |
| 60 | **env** registration. Its `credential.register-consumer` verifies this |
| 61 | binding and returns the manifest digest; it never inserts a duplicate table |
| 62 | row. A table-only registration needs a separately reviewed reconciliation, |
| 63 | not another registration on top of it. |
| 64 | |
| 65 | Check the replica for an ID/origin collision (read-only, current CLI): |
| 66 | |
| 67 | ```sh |
| 68 | carlos db query --account oficina --app oficina-id \ |
| 69 | "SELECT consumer_id,origin,state FROM consumers WHERE consumer_id='equipo' OR origin='https://equipo.oficina.works'" |
| 70 | ``` |
| 71 | |
| 72 | Expected: no rows. If a row exists, stop; adding the same ID or origin to |
| 73 | the env manifest would make Home refuse boot. |
| 74 | |
| 75 | On an otherwise unchanged deployment, Paul runs this to preserve the live |
| 76 | manifest and add the exact binding. It reads only the public manifest from |
| 77 | `carlos env list`, refuses an unexpected format or conflicting binding, and |
| 78 | prints no credentials. Do not run concurrently with another manifest edit. |
| 79 | |
| 80 | ```sh |
| 81 | python3 - <<'PY' |
| 82 | import base64, json, subprocess |
| 83 | from pathlib import Path |
| 84 | base = ['carlos', 'env'] |
| 85 | args = ['--account', 'oficina', '--app', 'oficina-id'] |
| 86 | text = subprocess.check_output(base + ['list'] + args, text=True) |
| 87 | values = dict(line.split(None, 1) for line in text.splitlines() |
| 88 | if line.startswith(('HOME_CONSUMERS ', 'HOME_CONSUMERS_BASE64 '))) |
| 89 | assert set(values) == {'HOME_CONSUMERS_BASE64'}, 'Inspect manifest format before changing it' |
| 90 | manifest = json.loads(base64.b64decode(values['HOME_CONSUMERS_BASE64'], validate=True)) |
| 91 | origin = 'https://equipo.oficina.works' |
| 92 | assert isinstance(manifest, dict) and 0 < len(manifest) <= 16 |
| 93 | assert all(isinstance(k, str) and isinstance(v, str) for k, v in manifest.items()) |
| 94 | assert manifest.get('equipo', origin) == origin, 'Equipo has a different origin' |
| 95 | assert all(k == 'equipo' or v != origin for k, v in manifest.items()), 'Origin has another ID' |
| 96 | if manifest.get('equipo') == origin: |
| 97 | print('Equipo already has the exact canonical env registration') |
| 98 | else: |
| 99 | assert len(manifest) < 16, 'Env registry is full' |
| 100 | backup = Path.home() / '.oficina-id-consumers-before-equipo.b64' |
| 101 | with backup.open('x', encoding='ascii') as saved: |
| 102 | saved.write(values['HOME_CONSUMERS_BASE64'] + '\n') |
| 103 | backup.chmod(0o600) |
| 104 | manifest['equipo'] = origin |
| 105 | encoded = base64.b64encode(json.dumps(manifest, separators=(',', ':')).encode()).decode() |
| 106 | subprocess.run(base + ['set'] + args + ['HOME_CONSUMERS_BASE64=' + encoded], check=True) |
| 107 | print('Added equipo -> https://equipo.oficina.works; restart the credential service') |
| 108 | PY |
| 109 | carlos restart --account oficina --app oficina-id |
| 110 | curl --fail --silent --show-error -D - https://id.oficina.works/healthz |
| 111 | ``` |
| 112 | |
| 113 | Expected health: 200 and `X-Carlos-Version` naming the reviewed Home release. |
| 114 | The backup is public consumer metadata; the exclusive create prevents |
| 115 | overwriting the previous manifest. If it already exists, inspect it before |
| 116 | another attempt. Keep it until health and consumer checks pass. |
| 117 | |
| 118 | If this manifest change makes the credential service unhealthy, restore the |
| 119 | saved value immediately (only if no intervening manifest edit occurred), |
| 120 | restart, and check health before investigating. This rolls back the manifest |
| 121 | change, not an adoption or deployment: |
| 122 | |
| 123 | ```sh |
| 124 | python3 - <<'PY' |
| 125 | import base64, json, subprocess |
| 126 | from pathlib import Path |
| 127 | old = (Path.home() / '.oficina-id-consumers-before-equipo.b64').read_text().strip() |
| 128 | assert isinstance(json.loads(base64.b64decode(old, validate=True)), dict) |
| 129 | subprocess.run(['carlos', 'env', 'set', '--account', 'oficina', '--app', |
| 130 | 'oficina-id', 'HOME_CONSUMERS_BASE64=' + old], check=True) |
| 131 | PY |
| 132 | carlos restart --account oficina --app oficina-id |
| 133 | curl --fail --silent --show-error -D - https://id.oficina.works/healthz |
| 134 | ``` |
| 135 | |
| 136 | On success, re-run the two public checks. Expected: Equipo and Docs both 303 after the |
| 137 | process restarts. Home's native `assert` then accepts exactly |
| 138 | `https://equipo.oficina.works`, with no port, slash, suffix or case variants. |
| 139 | A complete native check still needs a real device grant and the deployed |
| 140 | Equipo exchange; the public check alone is not a native end-to-end test. |
| 141 | |
| 142 | ## 2. Build and select the existing operator state |
| 143 | |
| 144 | After both branches are reviewed and landed, run in the Alta checkout on |
| 145 | the operator Mac (no live Alta server is required): |
| 146 | |
| 147 | ```sh |
| 148 | git fetch origin |
| 149 | git switch main |
| 150 | git pull --ff-only |
| 151 | make adopt |
| 152 | bash |
| 153 | read -r -p 'Absolute path to the EXISTING alta-adopt config: ' ALTA_CONFIG |
| 154 | read -r -p 'Absolute path to the existing short-lived CARLOS Admin token file: ' ALTA_TOKEN_FILE |
| 155 | read -r -p 'Reviewed Equipo release name (X-Carlos-Version): ' EQUIPO_RELEASE |
| 156 | ALTA_ADOPT="$PWD/releases/alta-adopt" |
| 157 | "$ALTA_ADOPT" version |
| 158 | "$ALTA_ADOPT" status --config "$ALTA_CONFIG" |
| 159 | ``` |
| 160 | |
| 161 | Keep this Bash shell for the commands below. The token file must contain |
| 162 | only the token, as the existing adoption setup requires. It is passed on FD |
| 163 | 3, never exported or stored in Alta's config/state. If its credential has |
| 164 | expired, mint a fresh short-lived Admin credential using the existing |
| 165 | operator procedure (`carlos services create --account oficina --role admin |
| 166 | oficina-adoption`); keep its token out of command history. Revoke it after |
| 167 | this session, as the original adoption runbook requires. |
| 168 | |
| 169 | Expected status: the `oficina` team is seeded, the original six apps' |
| 170 | register steps are done, calendar has completed activation, and Equipo has |
| 171 | no steps yet. No `oficina` run may be `planned`, `running` or `parked`: |
| 172 | finish or resolve it before opening another Plan A, which supersedes an |
| 173 | unfinished run. If Equipo is already registered, skip Plan A below. If it is |
| 174 | already active, stop here: no repeat adoption is needed. |
| 175 | |
| 176 | Add the reviewed release's digest to `artifacts`, preserving every other |
| 177 | config field, including the state path and keys. This is the SHA-256 of the |
| 178 | **release name**, without a newline, not the binary's hash: |
| 179 | |
| 180 | ```sh |
| 181 | python3 - "$ALTA_CONFIG" "$EQUIPO_RELEASE" <<'PY' |
| 182 | import hashlib, json, os, pathlib, stat, sys, tempfile |
| 183 | p = pathlib.Path(sys.argv[1]) |
| 184 | st = p.stat() |
| 185 | assert stat.S_ISREG(st.st_mode) and stat.S_IMODE(st.st_mode) == 0o600 and st.st_uid == os.getuid() |
| 186 | cfg = json.loads(p.read_text()) |
| 187 | cfg.setdefault('artifacts', {})['equipo'] = hashlib.sha256(sys.argv[2].encode()).hexdigest() |
| 188 | fd, tmp = tempfile.mkstemp(dir=p.parent, prefix='.equipo-config-') |
| 189 | try: |
| 190 | with os.fdopen(fd, 'w') as f: |
| 191 | json.dump(cfg, f, indent=2) |
| 192 | f.write('\n') |
| 193 | os.replace(tmp, p) |
| 194 | finally: |
| 195 | if os.path.exists(tmp): os.unlink(tmp) |
| 196 | print('Equipo reviewed release recorded; keys and state path preserved') |
| 197 | PY |
| 198 | "$ALTA_ADOPT" preflight --config "$ALTA_CONFIG" --app equipo \ |
| 199 | --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE" |
| 200 | ``` |
| 201 | |
| 202 | Expected: `equipo: ready`. No write. Missing Home identity, inherited keys |
| 203 | on other instances, team-mode config, unreviewed release, or an unexpected |
| 204 | operations response stops the run. Fix the reported cause, never remove the |
| 205 | gate or edit the journal. All Equipo config and release preparation belongs |
| 206 | before the first `configure`, which captures an immutable baseline. |
| 207 | An unscoped `preflight` now includes Equipo and will refuse until its |
| 208 | separate contract is deployed; use the explicit `--app equipo` above. |
| 209 | |
| 210 | ## 3. Register Equipo against the already seeded team |
| 211 | |
| 212 | ```sh |
| 213 | "$ALTA_ADOPT" plan-a --config "$ALTA_CONFIG" |
| 214 | "$ALTA_ADOPT" plan-a --config "$ALTA_CONFIG" --apply |
| 215 | ``` |
| 216 | |
| 217 | Expected dry run: continuation of Plan A for **equipo only**. The applied |
| 218 | command prints a run ID and both confirmation URLs. It binds the existing |
| 219 | SQID and registers missing apps; it does not seed a second team. If other |
| 220 | apps are listed, inspect the existing state before applying. |
| 221 | |
| 222 | Open `https://oficina.works/operator/confirm`, then |
| 223 | `https://id.oficina.works/operator/confirm` in the system browser. Confirm |
| 224 | with a fresh passkey; compare the plan prefix on both pages. Both must name |
| 225 | Equipo and the existing team SQID. Complete each plan/confirmation/advance |
| 226 | within its 15-minute window. No owner retyping or re-seeding is needed for |
| 227 | this continuation. |
| 228 | |
| 229 | ```sh |
| 230 | read -r -p 'Registration run ID printed by plan-a: ' EQUIPO_REGISTER_RUN |
| 231 | "$ALTA_ADOPT" advance --config "$ALTA_CONFIG" --run "$EQUIPO_REGISTER_RUN" --apply |
| 232 | "$ALTA_ADOPT" status --config "$ALTA_CONFIG" |
| 233 | ``` |
| 234 | |
| 235 | Expected: run `done awaiting-configuration`; Equipo provision and register |
| 236 | steps done, directory row pending, existing team and registrations retained. |
| 237 | Wait for any previous confirmation window to expire before opening another |
| 238 | plan; never alter the clock or state to bypass `plan-open`. |
| 239 | |
| 240 | ## 4. Configure and activate Equipo |
| 241 | |
| 242 | ```sh |
| 243 | "$ALTA_ADOPT" configure --config "$ALTA_CONFIG" --app equipo \ |
| 244 | --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE" |
| 245 | "$ALTA_ADOPT" configure --config "$ALTA_CONFIG" --app equipo --apply \ |
| 246 | --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE" |
| 247 | ``` |
| 248 | |
| 249 | Dry run names the two agent keys and their write layer. Apply writes them |
| 250 | conditionally, restarts **only the canonical Equipo host**, waits for the |
| 251 | agent-access challenge, and records the delivery check. Expected ending: |
| 252 | `Delivery check recorded.` The release must stay the reviewed release. |
| 253 | |
| 254 | ```sh |
| 255 | "$ALTA_ADOPT" activate --config "$ALTA_CONFIG" --apps equipo \ |
| 256 | --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE" |
| 257 | "$ALTA_ADOPT" activate --config "$ALTA_CONFIG" --apps equipo --apply \ |
| 258 | --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE" |
| 259 | ``` |
| 260 | |
| 261 | Expected dry run: `equipo: ready`. Apply prints a **new** run ID. Confirm on |
| 262 | both Home pages again, for Equipo and the same existing SQID and plan prefix. |
| 263 | Then: |
| 264 | |
| 265 | ```sh |
| 266 | read -r -p 'Activation run ID printed by activate: ' EQUIPO_ACTIVATE_RUN |
| 267 | "$ALTA_ADOPT" advance --config "$ALTA_CONFIG" --run "$EQUIPO_ACTIVATE_RUN" --apply \ |
| 268 | --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE" |
| 269 | "$ALTA_ADOPT" status --config "$ALTA_CONFIG" |
| 270 | carlos db query --account oficina --app oficina \ |
| 271 | "SELECT t.label,i.app,i.origin,i.consumer_id,i.state FROM team_instances i JOIN teams t ON t.id=i.team_id WHERE t.label='oficina' AND i.app='equipo'" |
| 272 | ``` |
| 273 | |
| 274 | Expected: activation run `done`, verify and activate steps done, and exactly |
| 275 | `oficina | equipo | https://equipo.oficina.works | equipo | live` on the |
| 276 | replica once caught up. A roster member's native `/api/native/teams` includes |
| 277 | `{"app":"equipo","origin":"https://equipo.oficina.works","consumer_id":"equipo"}`. |
| 278 | Equipo native lists Oficina and signs in after its separate native build is |
| 279 | installed. Removed members and non-live instances remain excluded. |
| 280 | Back up the state database with the existing procedure and revoke the |
| 281 | session's Admin credential. Do not downgrade the journal or delete rows. |
| 282 | |
| 283 | ## Contract the separate Equipo session must implement |
| 284 | |
| 285 | Reference inspected at [Docs commit 7de2d40](https://amadan.net/oficina/docs/commit/7de2d40c1c77a8b43544a4b47c7806411eafd65f): |
| 286 | [agent access source](https://amadan.net/oficina/docs?ref=main&path=internal/docs/agent_access.go), |
| 287 | [config wiring](https://amadan.net/oficina/docs?ref=main&path=cmd/docs/main.go), |
| 288 | and `amadan.net/oficina/agent-access.git` (`http.go`, `remote.go`, registry |
| 289 | and principal types). Docs pins `8ed8ba826000` at that revision. The file |
| 290 | links follow main; reproduce the exact inspected implementation locally with: |
| 291 | |
| 292 | ```sh |
| 293 | git -C /Users/paulcampbell/amadan.net/oficina/docs show \ |
| 294 | 7de2d40c1c77a8b43544a4b47c7806411eafd65f:internal/docs/agent_access.go |
| 295 | ``` |
| 296 | |
| 297 | 1. Read `EQUIPO_AGENT_ISSUER` and `EQUIPO_AGENT_TEAM` together. Both absent |
| 298 | leaves agent access disabled; partial/malformed config refuses boot. |
| 299 | Require valid Home identity config. Issuer is |
| 300 | `https://connect.oficina.works`; team is the Home directory **SQID**, not |
| 301 | `oficina`, an Equipo database team ID, or a hostname. If a separate team |
| 302 | mode is configured, the binding must agree; Alta adoption itself refuses |
| 303 | `EQUIPO_TEAM_*` keys and does not enable team mode. |
| 304 | 2. Mount agent routes ahead of Equipo's device/session authentication |
| 305 | middleware. `GET /api/v1/operations` takes no body. With no valid bearer, |
| 306 | answer **401**, `Cache-Control: no-store`, `Content-Type: application/json`, |
| 307 | exactly one `WWW-Authenticate: Bearer` (parameters are permitted), and |
| 308 | exactly `{"error":{"code":"unauthenticated","message":"Connect to Oficina first."}}`. |
| 309 | The message may be another nonempty string. No request ID, copy key, |
| 310 | wrapper fields, redirect, extra JSON value, or generic API 401 shape. |
| 311 | 3. Use agent-access's delegated `Authorization: Bearer <token>` contract, |
| 312 | not an Equipo device credential. `NewRemoteVerifier(agentIssuer, |
| 313 | equipoOrigin+"/api/v1", homeIssuer)` checks online at |
| 314 | `POST https://connect.oficina.works/api/v1/credential`, forwarding the |
| 315 | bearer and JSON `{"resource":"https://equipo.oficina.works/api/v1"}`. |
| 316 | It requires matching returned resource and identity issuer, plus a |
| 317 | nonempty subject and grant. Do not hand-roll a permissive substitute. |
| 318 | Resolve the Home person locally and enforce Equipo's current membership |
| 319 | and permissions, including revocation, as Docs' `prepareMode` does. |
| 320 | 4. With an authorized bearer, return 200 `{"operations":[...]}` with |
| 321 | descriptors filtered to the principal's team/scopes. Actual invocation |
| 322 | is `POST /api/v1/operations/{name}`, `Content-Type: application/json`, |
| 323 | raw operation arguments including the exact team SQID, with the same |
| 324 | bearer verification and current permissions. Use the shared registry's |
| 325 | schema/size checks, and Docs' permission/revocation recheck for writes. |
| 326 | Operation names and which Equipo actions to expose belong to that |
| 327 | session's approved contract. A fake public list added only to satisfy |
| 328 | Alta is not an integration. |
| 329 | 5. Keep `/healthz` at 200 and `/api/version` at the stamped version, with |
| 330 | `X-Carlos-Version` naming the same release (Alta `SameRelease` accepts |
| 331 | the existing git-describe/short-hash pair). No redirects on these probes. |
| 332 | 6. If `EQUIPO_HOME_ISSUER` or `EQUIPO_HOME_CONSUMER_ID` are stored as secrets, |
| 333 | `GET /auth/start` must directly return 302/303 to Home's exact |
| 334 | `/authorize?consumer=equipo&nonce=...`; Alta never follows it. Plain env |
| 335 | values are read from effective config instead. The normal app should |
| 336 | actually sign in with the same issuer/consumer in either case. |
| 337 | |
| 338 | Alta sends no bearer in its probes. For Equipo, like Calls and Slides, it |
| 339 | requires the pre-configuration generic API **401** to change to the exact |
| 340 | agent-access **401** above. An unauthenticated 200 is refused for these apps. |
| 341 | `adopt/delivery.go` (`shape`, `BaselineOps`, `Delivered`) implements this; |
| 342 | `adopt/observer.go` checks baseline/write/after/delivery-check evidence, |
| 343 | calendar's active canary, reviewed release digest, unchanged instance and |
| 344 | storage identity, every preserved config digest/source/layer, exact agent |
| 345 | keys, and Home identity. `configure` writes only the two agent keys, so all |
| 346 | Home credentials and unrelated config must be prepared before its baseline. |
| 347 | |