oficina / alta Public

Clone
git clone https://amadan.net/oficina/alta

Plain git — no account needed to clone.

Download

Download this file

1# Add Equipo to the existing Oficina team
2
3Implementer: Codex GPT-6-Astra. Approved scope: Equipo's 2026-11-20
4native Oficina ID spec, E4. This runbook is for Paul on the Mac holding
5Alta's existing operator configuration and state. No commands here were
6executed 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
33Read-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
36origin. `/authorize?consumer=equipo&nonce=AAAAAAAAAAAAAAAAAAAAAA` answered
37400, 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
40secret-name listings contained none of the four `EQUIPO_HOME_*` keys.
41These are observations of that deployment, not evidence of a later release
42or of other config layers. Current live sign-in is a prerequisite, not
43something `alta-adopt configure` installs.
44
45## 1. Verify and register the canonical consumer
46
47Native assert and web authorize read the same effective registry. This
48public check creates no login session and prints no cookie/token:
49
50```sh
51curl -sS -o /dev/null -w 'Equipo consumer HTTP %{http_code}\n' \
52 'https://id.oficina.works/authorize?consumer=equipo&nonce=AAAAAAAAAAAAAAAAAAAAAA'
53curl -sS -o /dev/null -w 'Docs control HTTP %{http_code}\n' \
54 'https://id.oficina.works/authorize?consumer=docs&nonce=AAAAAAAAAAAAAAAAAAAAAA'
55```
56
57Expected: both 303. A 400 for Equipo with a 303 control means the consumer
58ID is not registered. A 303 establishes ID admission; the following manifest
59inspection establishes its exact origin. Canonical adoption requires the
60**env** registration. Its `credential.register-consumer` verifies this
61binding and returns the manifest digest; it never inserts a duplicate table
62row. A table-only registration needs a separately reviewed reconciliation,
63not another registration on top of it.
64
65Check the replica for an ID/origin collision (read-only, current CLI):
66
67```sh
68carlos 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
72Expected: no rows. If a row exists, stop; adding the same ID or origin to
73the env manifest would make Home refuse boot.
74
75On an otherwise unchanged deployment, Paul runs this to preserve the live
76manifest and add the exact binding. It reads only the public manifest from
77`carlos env list`, refuses an unexpected format or conflicting binding, and
78prints no credentials. Do not run concurrently with another manifest edit.
79
80```sh
81python3 - <<'PY'
82import base64, json, subprocess
83from pathlib import Path
84base = ['carlos', 'env']
85args = ['--account', 'oficina', '--app', 'oficina-id']
86text = subprocess.check_output(base + ['list'] + args, text=True)
87values = dict(line.split(None, 1) for line in text.splitlines()
88 if line.startswith(('HOME_CONSUMERS ', 'HOME_CONSUMERS_BASE64 ')))
89assert set(values) == {'HOME_CONSUMERS_BASE64'}, 'Inspect manifest format before changing it'
90manifest = json.loads(base64.b64decode(values['HOME_CONSUMERS_BASE64'], validate=True))
91origin = 'https://equipo.oficina.works'
92assert isinstance(manifest, dict) and 0 < len(manifest) <= 16
93assert all(isinstance(k, str) and isinstance(v, str) for k, v in manifest.items())
94assert manifest.get('equipo', origin) == origin, 'Equipo has a different origin'
95assert all(k == 'equipo' or v != origin for k, v in manifest.items()), 'Origin has another ID'
96if manifest.get('equipo') == origin:
97 print('Equipo already has the exact canonical env registration')
98else:
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')
108PY
109carlos restart --account oficina --app oficina-id
110curl --fail --silent --show-error -D - https://id.oficina.works/healthz
111```
112
113Expected health: 200 and `X-Carlos-Version` naming the reviewed Home release.
114The backup is public consumer metadata; the exclusive create prevents
115overwriting the previous manifest. If it already exists, inspect it before
116another attempt. Keep it until health and consumer checks pass.
117
118If this manifest change makes the credential service unhealthy, restore the
119saved value immediately (only if no intervening manifest edit occurred),
120restart, and check health before investigating. This rolls back the manifest
121change, not an adoption or deployment:
122
123```sh
124python3 - <<'PY'
125import base64, json, subprocess
126from pathlib import Path
127old = (Path.home() / '.oficina-id-consumers-before-equipo.b64').read_text().strip()
128assert isinstance(json.loads(base64.b64decode(old, validate=True)), dict)
129subprocess.run(['carlos', 'env', 'set', '--account', 'oficina', '--app',
130 'oficina-id', 'HOME_CONSUMERS_BASE64=' + old], check=True)
131PY
132carlos restart --account oficina --app oficina-id
133curl --fail --silent --show-error -D - https://id.oficina.works/healthz
134```
135
136On success, re-run the two public checks. Expected: Equipo and Docs both 303 after the
137process restarts. Home's native `assert` then accepts exactly
138`https://equipo.oficina.works`, with no port, slash, suffix or case variants.
139A complete native check still needs a real device grant and the deployed
140Equipo exchange; the public check alone is not a native end-to-end test.
141
142## 2. Build and select the existing operator state
143
144After both branches are reviewed and landed, run in the Alta checkout on
145the operator Mac (no live Alta server is required):
146
147```sh
148git fetch origin
149git switch main
150git pull --ff-only
151make adopt
152bash
153read -r -p 'Absolute path to the EXISTING alta-adopt config: ' ALTA_CONFIG
154read -r -p 'Absolute path to the existing short-lived CARLOS Admin token file: ' ALTA_TOKEN_FILE
155read -r -p 'Reviewed Equipo release name (X-Carlos-Version): ' EQUIPO_RELEASE
156ALTA_ADOPT="$PWD/releases/alta-adopt"
157"$ALTA_ADOPT" version
158"$ALTA_ADOPT" status --config "$ALTA_CONFIG"
159```
160
161Keep this Bash shell for the commands below. The token file must contain
162only the token, as the existing adoption setup requires. It is passed on FD
1633, never exported or stored in Alta's config/state. If its credential has
164expired, mint a fresh short-lived Admin credential using the existing
165operator procedure (`carlos services create --account oficina --role admin
166oficina-adoption`); keep its token out of command history. Revoke it after
167this session, as the original adoption runbook requires.
168
169Expected status: the `oficina` team is seeded, the original six apps'
170register steps are done, calendar has completed activation, and Equipo has
171no steps yet. No `oficina` run may be `planned`, `running` or `parked`:
172finish or resolve it before opening another Plan A, which supersedes an
173unfinished run. If Equipo is already registered, skip Plan A below. If it is
174already active, stop here: no repeat adoption is needed.
175
176Add the reviewed release's digest to `artifacts`, preserving every other
177config 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
181python3 - "$ALTA_CONFIG" "$EQUIPO_RELEASE" <<'PY'
182import hashlib, json, os, pathlib, stat, sys, tempfile
183p = pathlib.Path(sys.argv[1])
184st = p.stat()
185assert stat.S_ISREG(st.st_mode) and stat.S_IMODE(st.st_mode) == 0o600 and st.st_uid == os.getuid()
186cfg = json.loads(p.read_text())
187cfg.setdefault('artifacts', {})['equipo'] = hashlib.sha256(sys.argv[2].encode()).hexdigest()
188fd, tmp = tempfile.mkstemp(dir=p.parent, prefix='.equipo-config-')
189try:
190 with os.fdopen(fd, 'w') as f:
191 json.dump(cfg, f, indent=2)
192 f.write('\n')
193 os.replace(tmp, p)
194finally:
195 if os.path.exists(tmp): os.unlink(tmp)
196print('Equipo reviewed release recorded; keys and state path preserved')
197PY
198"$ALTA_ADOPT" preflight --config "$ALTA_CONFIG" --app equipo \
199 --carlos-token-fd 3 3<"$ALTA_TOKEN_FILE"
200```
201
202Expected: `equipo: ready`. No write. Missing Home identity, inherited keys
203on other instances, team-mode config, unreviewed release, or an unexpected
204operations response stops the run. Fix the reported cause, never remove the
205gate or edit the journal. All Equipo config and release preparation belongs
206before the first `configure`, which captures an immutable baseline.
207An unscoped `preflight` now includes Equipo and will refuse until its
208separate 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
217Expected dry run: continuation of Plan A for **equipo only**. The applied
218command prints a run ID and both confirmation URLs. It binds the existing
219SQID and registers missing apps; it does not seed a second team. If other
220apps are listed, inspect the existing state before applying.
221
222Open `https://oficina.works/operator/confirm`, then
223`https://id.oficina.works/operator/confirm` in the system browser. Confirm
224with a fresh passkey; compare the plan prefix on both pages. Both must name
225Equipo and the existing team SQID. Complete each plan/confirmation/advance
226within its 15-minute window. No owner retyping or re-seeding is needed for
227this continuation.
228
229```sh
230read -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
235Expected: run `done awaiting-configuration`; Equipo provision and register
236steps done, directory row pending, existing team and registrations retained.
237Wait for any previous confirmation window to expire before opening another
238plan; 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
249Dry run names the two agent keys and their write layer. Apply writes them
250conditionally, restarts **only the canonical Equipo host**, waits for the
251agent-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
261Expected dry run: `equipo: ready`. Apply prints a **new** run ID. Confirm on
262both Home pages again, for Equipo and the same existing SQID and plan prefix.
263Then:
264
265```sh
266read -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"
270carlos 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
274Expected: activation run `done`, verify and activate steps done, and exactly
275`oficina | equipo | https://equipo.oficina.works | equipo | live` on the
276replica once caught up. A roster member's native `/api/native/teams` includes
277`{"app":"equipo","origin":"https://equipo.oficina.works","consumer_id":"equipo"}`.
278Equipo native lists Oficina and signs in after its separate native build is
279installed. Removed members and non-live instances remain excluded.
280Back up the state database with the existing procedure and revoke the
281session's Admin credential. Do not downgrade the journal or delete rows.
282
283## Contract the separate Equipo session must implement
284
285Reference 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),
288and `amadan.net/oficina/agent-access.git` (`http.go`, `remote.go`, registry
289and principal types). Docs pins `8ed8ba826000` at that revision. The file
290links follow main; reproduce the exact inspected implementation locally with:
291
292```sh
293git -C /Users/paulcampbell/amadan.net/oficina/docs show \
294 7de2d40c1c77a8b43544a4b47c7806411eafd65f:internal/docs/agent_access.go
295```
296
2971. 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.
3042. 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.
3113. 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.
3204. 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.
3295. 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.
3326. 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
338Alta sends no bearer in its probes. For Equipo, like Calls and Slides, it
339requires the pre-configuration generic API **401** to change to the exact
340agent-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,
343calendar's active canary, reviewed release digest, unchanged instance and
344storage identity, every preserved config digest/source/layer, exact agent
345keys, and Home identity. `configure` writes only the two agent keys, so all
346Home credentials and unrelated config must be prepared before its baseline.
347