oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Native Oficina ID server verification
2
3Implementer: Codex GPT-6-Astra.
4
5Initial red: `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run TestNativeExchangeGates -count=1` failed all cases with HTTP 404 before the route existed. The first device unit test failed to compile before RegisterNative, NativeSession and SessionHash existed.
6
7Each mutation below was applied alone, tested, and restored in a finally block. A caught mutation must produce a test assertion failure, not a compile failure.
8
9## native nonce
10
11`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/(verifier|web-nonce)$ -count=1 -timeout=15s`
12
13Caught:
14
15```text
16--- FAIL: TestNativeExchangeGates (0.07s)
17--- FAIL: TestNativeExchangeGates/verifier (0.03s)
18native_test.go:142: status 200 want 401
19--- FAIL: TestNativeExchangeGates/web-nonce (0.04s)
20native_test.go:142: status 200 want 401
21```
22
23## pinned signature issuer audience and expiry
24
25`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/(audience|issuer|key|expired)$ -count=1 -timeout=15s`
26
27Caught:
28
29```text
30--- FAIL: TestNativeExchangeGates (0.11s)
31--- FAIL: TestNativeExchangeGates/audience (0.03s)
32native_test.go:142: status 200 want 401
33--- FAIL: TestNativeExchangeGates/issuer (0.03s)
34native_test.go:142: status 403 want 401
35--- FAIL: TestNativeExchangeGates/key (0.03s)
36native_test.go:142: status 200 want 401
37```
38
39## Origin including empty
40
41`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/(origin|empty-origin)$ -count=1 -timeout=15s`
42
43Caught:
44
45```text
46--- FAIL: TestNativeExchangeGates (0.11s)
47--- FAIL: TestNativeExchangeGates/origin (0.05s)
48native_test.go:142: status 200 want 400
49--- FAIL: TestNativeExchangeGates/empty-origin (0.06s)
50native_test.go:142: status 200 want 400
51```
52
53## fetch provenance
54
55`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/fetch$ -count=1 -timeout=15s`
56
57Caught:
58
59```text
60--- FAIL: TestNativeExchangeGates (0.03s)
61--- FAIL: TestNativeExchangeGates/fetch (0.03s)
62native_test.go:142: status 200 want 400
63```
64
65## JSON media
66
67`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/json$ -count=1 -timeout=15s`
68
69Caught:
70
71```text
72--- FAIL: TestNativeExchangeGates (0.03s)
73--- FAIL: TestNativeExchangeGates/json (0.03s)
74native_test.go:142: status 200 want 400
75```
76
77## unknown input fields
78
79`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/unknown-field$ -count=1 -timeout=15s`
80
81Caught:
82
83```text
84--- FAIL: TestNativeExchangeGates (0.03s)
85--- FAIL: TestNativeExchangeGates/unknown-field (0.03s)
86native_test.go:142: status 200 want 400
87```
88
89## duplicate input fields
90
91`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/duplicate-field$ -count=1 -timeout=15s`
92
93Caught:
94
95```text
96--- FAIL: TestNativeExchangeGates (0.04s)
97--- FAIL: TestNativeExchangeGates/duplicate-field (0.04s)
98native_test.go:142: status 200 want 400
99```
100
101## replay reservation
102
103`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/replay$|^TestNativeConcurrentExchange$ -count=1 -timeout=15s`
104
105Caught:
106
107```text
108--- FAIL: TestNativeExchangeGates (0.03s)
109--- FAIL: TestNativeExchangeGates/replay (0.03s)
110native_test.go:142: status 200 want 401
111--- FAIL: TestNativeConcurrentExchange (0.04s)
112native_test.go:207: concurrent mints 8
113```
114
115## identical unknown including choice new
116
117`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeUnknownIsIdentical$ -count=1 -timeout=15s`
118
119Caught:
120
121```text
122--- FAIL: TestNativeUnknownIsIdentical (0.01s)
123native_test.go:169: unknown status: 409
124```
125
126## roster before replay reservation
127
128`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeUnknownIsIdentical$ -count=1 -timeout=15s`
129
130Caught:
131
132```text
133--- FAIL: TestNativeUnknownIsIdentical (0.02s)
134native_test.go:178: unknown allocated oficina_handoff_replay 1 <nil>
135```
136
137## roster unavailable
138
139`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/unavailable$ -count=1 -timeout=15s`
140
141Caught:
142
143```text
144--- FAIL: TestNativeExchangeGates (0.02s)
145--- FAIL: TestNativeExchangeGates/unavailable (0.02s)
146native_test.go:142: status 403 want 503
147```
148
149## session epoch at mint
150
151`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/epoch$ -count=1 -timeout=15s`
152
153Caught:
154
155```text
156--- FAIL: TestNativeExchangeGates (0.02s)
157--- FAIL: TestNativeExchangeGates/epoch (0.02s)
158native_test.go:142: status 200 want 403
159```
160
161## reserve releases writer before mint
162
163`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeConcurrentExchange$ -count=1 -timeout=15s`
164
165Caught:
166
167```text
168--- FAIL: TestNativeConcurrentExchange (2.02s)
169native_test.go:200: concurrent status 503
170```
171
172## absolute seven days
173
174`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeSessionAbsoluteLifetime$ -count=1 -timeout=15s`
175
176Caught:
177
178```text
179--- FAIL: TestNativeSessionAbsoluteLifetime (0.02s)
180native_test.go:263: absolute native lifetime slid
181```
182
183## home derived method resolution
184
185`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeSessionAbsoluteLifetime$ -count=1 -timeout=15s`
186
187Caught:
188
189```text
190--- FAIL: TestNativeSessionAbsoluteLifetime (0.03s)
191native_test.go:260: native resolution {pr_aaaaaaaaaaaaaaaaaaaaaaaaaa home-assertion-native 2026-11-20 14:23:01 +0000 UTC 2026-11-20 14:23:01 +0000 UTC} oficina identity refused
192```
193
194## source session method
195
196`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeSessionOnRejectsLocal$ -count=1 -timeout=15s`
197
198Caught:
199
200```text
201--- FAIL: TestNativeSessionOnRejectsLocal (0.01s)
202native_test.go:285: local session authorized native device
203```
204
205## native unlink deletion
206
207`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeUnlinkDeletesSession$ -count=1 -timeout=15s`
208
209Caught:
210
211```text
212--- FAIL: TestNativeUnlinkDeletesSession (0.02s)
213native_test.go:294: native sessions retained 1 <nil>
214```
215
216## device actor and source person
217
218`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/(actor|session-person)$ -count=1 -timeout=15s`
219
220Caught:
221
222```text
223--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.46s)
224--- FAIL: TestPersonAPINativeDeviceTransactionGuards/actor (0.45s)
225person_api_native_id_test.go:251: native device guard accepted actor
226--- FAIL: TestPersonAPINativeDeviceTransactionGuards/session-person (0.01s)
227person_api_native_id_test.go:251: native device guard accepted session-person
228```
229
230## device source method
231
232`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/session-method$ -count=1 -timeout=15s`
233
234Caught:
235
236```text
237--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.45s)
238--- FAIL: TestPersonAPINativeDeviceTransactionGuards/session-method (0.45s)
239person_api_native_id_test.go:251: native device guard accepted session-method
240```
241
242## device source expiry
243
244`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/session-expiry$ -count=1 -timeout=15s`
245
246Caught:
247
248```text
249--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.45s)
250--- FAIL: TestPersonAPINativeDeviceTransactionGuards/session-expiry (0.45s)
251person_api_native_id_test.go:251: native device guard accepted session-expiry
252```
253
254## device transactional roster
255
256`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/roster$ -count=1 -timeout=15s`
257
258Caught:
259
260```text
261--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.45s)
262--- FAIL: TestPersonAPINativeDeviceTransactionGuards/roster (0.45s)
263person_api_native_id_test.go:251: native device guard accepted roster
264```
265
266## device expiry follows original session
267
268`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDevice$ -count=1 -timeout=15s`
269
270Caught:
271
272```text
273--- FAIL: TestPersonAPINativeDevice (0.47s)
274person_api_native_id_test.go:111: wrong owner, source, or expiry
275```
276
277## audit credential exclusion
278
279`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDevice$ -count=1 -timeout=15s`
280
281Caught:
282
283```text
284--- FAIL: TestPersonAPINativeDevice (0.46s)
285person_api_native_id_test.go:120: credential or label in audit
286```
287
288## audit failure rollback
289
290`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/audit$ -count=1 -timeout=15s`
291
292Caught:
293
294```text
295--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.46s)
296--- FAIL: TestPersonAPINativeDeviceTransactionGuards/audit (0.46s)
297person_api_native_id_test.go:251: native device guard accepted audit
298```
299
300## device key length
301
302`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceGates$/key$ -count=1 -timeout=15s`
303
304Caught:
305
306```text
307--- FAIL: TestPersonAPINativeDeviceGates (0.47s)
308--- FAIL: TestPersonAPINativeDeviceGates/key (0.00s)
309person_api_native_id_test.go:196: native HTTP 200, want 422
310```
311
312## device revocation cascade
313
314`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeSessionRevocation$/session$ -count=1 -timeout=15s`
315
316Caught:
317
318```text
319--- FAIL: TestPersonAPINativeSessionRevocation (0.46s)
320--- FAIL: TestPersonAPINativeSessionRevocation/session (0.46s)
321person_api_native_id_test.go:281: native device remained live session
322```
323
324## push cleanup cascade
325
326`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeSessionRevocation$/session$ -count=1 -timeout=15s`
327
328Caught:
329
330```text
331--- FAIL: TestPersonAPINativeSessionRevocation (0.46s)
332--- FAIL: TestPersonAPINativeSessionRevocation/session (0.46s)
333person_api_native_id_test.go:285: push secret survived push_registrations
334```
335
336## device same origin
337
338`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceGates$/no-origin$ -count=1 -timeout=15s`
339
340Caught:
341
342```text
343--- FAIL: TestPersonAPINativeDeviceGates (0.47s)
344--- FAIL: TestPersonAPINativeDeviceGates/no-origin (0.00s)
345person_api_native_id_test.go:196: native HTTP 200, want 403
346```
347
348## Scope and contracts
349
350Paul's clarification on 2026-11-20 limits this branch to existing explicit
351Oficina ID links. Every unlinked subject, even with `choice:"new"`, receives
352403 unknown. There is no allocation or 409 choice path. The approved spec's
353Order section records Home roster integration as follow-up work.
354
355`POST /native/oficina-id` accepts JSON `{assertion, verifier, choice?}`.
356`verifier` is canonical unpadded base64url of 32 random bytes (43 ASCII
357characters). Challenge hashes those ASCII characters; the nonce hashes the
358native context and decoded challenge, taking the first 16 bytes as Home's
359handoff protocol specifies. Only absent choice or `"new"` is accepted; it
360never allocates. Origin and Sec-Fetch-Site headers are refused, including an
361empty Origin. There are no cookies set. All answers are JSON and no-store:
362
363- 200: `{name, value, expires_at}`, with expiry in Unix seconds.
364- 400: `{"state":"invalid"}`.
365- 401: `{"state":"failed"}`.
366- 403: `{"state":"unknown"}`, byte-identical for every unknown subject.
367- 503: `{"state":"unavailable"}` for unavailable roster/storage.
368
369`POST /api/v1/auth/devices/native` accepts JSON `{public_key, label}` and the
370exchange session as a Cookie. Send `Origin: <instance origin>`. A device bearer,
371a web Oficina ID session, a local session, and mixed credentials cannot
372register a device. public_key is canonical unpadded base64url of the existing
373pairing protocol's 32-byte Curve25519 signing public key. label is 1–128 UTF-8
374bytes without NUL, CR or LF. No person or actor field is accepted.
375Idempotency-Key is not required: each success registers a new device.
376
377The 200 response is pairing's existing PersonCredential:
378`{id, token, audience, instance_id, expires_at}`. audience is
379`equipo.person.v1`; expires_at is an RFC3339 UTC timestamp, seven days after
380the source session's At, including when registration occurs days later.
381Errors use the existing `{code, copy_key, request_id, current_revision?}`
382envelope: 401 unauthenticated, 403 forbidden, 422 invalid_input and 503
383unavailable. Paired devices retain their existing 30-day expiry.
384
385The audit action `person_device.native` records the verified actor and device
386ID only. It has no token, session hash, public key or label. This adds no
387rendered interface text. Source session deletion revokes its native devices,
388clears pending credential responses and removes their push tokens and pending
389pushes. Unlink and roster deletion/address changes reach the same cascade.
390Home grant revocation alone has the native spec's disclosed offline residual:
391without instance session deletion, an already issued session and device may
392last to their absolute seven-day expiry.
393
394## Transaction and live evidence
395
396The handoff module is advanced to e03a01a1881c to reuse its verified native
397nonce and durable Reserve implementation; Rastrillo remains v0.30.3.
398Reserve commits its own short transaction before mintNative is invoked.
399The latter opens its own transaction and uses that handle for link resolution,
400current roster/epoch checks, the session insert and audit. No external hook
401or framework session writer is called with that writer held. With unlinked
402allocation deferred, there are no Admit, Unlinked or HomeOnly hooks here.
403
404TestNativeVerifierDoesNotWaitOnWriter holds the only connection in a write
405transaction and verifies a bad assertion returns without waiting on it.
406TestNativeConcurrentExchange performs successful exchanges with the pool
407limited to one connection; the mutation that holds a writer across the mint
408fails with 503 instead of wedging. It also proves only one of eight concurrent
409redemptions succeeds and replay survives a new Store. TestNativeConcurrentUnlink
410covers exchange racing unlink and replay after relink.
411
412TestPersonAPINativeLiveExchange runs a fake Home signing server and Equipo's
413production router on loopback HTTP/TLS listeners. It obtains an assertion,
414exchanges it, registers a device, and successfully reads the engine snapshot
415using only the resulting device bearer. Its source-session and credential
416expiries agree. Test cleanup closes both listeners and their databases.
417
418## Home follow-up, inspected read-only
419
420Inspected Home origin/main at 17cdcaff33452b49eb7bd38c999219a5bc49dcc4.
421No Home files were changed.
422
423- `internal/home/native_assert.go`: nativeAssert already accepts any exact
424 origin in consumers(), except the operator consumer, and calls shared
425 mintPolicy. Equipo requires no app-specific assert bypass or new audience
426 predicate. Its exact origin must be an active consumer.
427- `internal/home/consumer_registry.go`: consumers() is HOME_CONSUMERS plus
428 active consumer-table records. Registration must use the existing operator
429 flow; duplicate ID/origin entries in the environment and table fail closed.
430 Source inspection cannot attest to a deployed registry entry: the operator
431 must verify each Equipo consumer and its exact origin before rollout.
432- Add Equipo to `nativeTeamApps` in `internal/home/directory_native.go`, so
433 GET /api/native/teams can return it as the sixth native app.
434- Add the integrated app in `directoryApps()` in
435 `internal/home/directory_runtime.go`; this also supplies the allowed apps
436 for directorydata.Store and the directory roster source. Merely adding the
437 native filter entry is insufficient: AgentChoices also filters allowed apps.
438- Add Equipo to `directorydata.CanonicalOrigin` for the existing `oficina`
439 team and its `equipo` consumer at `https://equipo.oficina.works`.
440 Other teams use their registered `https://<label>.equipo.oficina.works`
441 route. The canonical rule also gates operator adoption planning.
442- Add the display catalog entry and any desired preview configuration in
443 `directory_catalog.go`; cover Equipo in chooser/catalog tests.
444- Extend TestNativeAssert for a registered Equipo audience and near-misses,
445 and TestNativeDirectoryTeams for a current member's live Equipo instance,
446 including pending/disabled and non-member exclusion. Keep unavailable
447 directory reads as errors, never empty team counts.
448- Paul still performs Alta adoption and Home confirmations to create the
449 membership and live team_instances records. This branch does not provision
450 or assert their existence, or create an unlinked person locally.
451
452## Restored verification
453
454All 28 mutations above failed their intended assertions and were restored.
455With `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`:
456
457- `go test ./internal/equipo ./internal/equipo/oficinaid ./internal/equipo/personapi ./internal/wire/wireschema -count=1`: passed.
458- `go test ./internal/plan3test -run TestPersonAPI -count=1`: passed, including both contract tests and all native route tests.
459- The app and integration size allowances are updated to the measured 21508
460 source lines and 11852 test lines, respectively, for the added wiring and
461 security/integration tests.
462- `make runner-dead-references lanes-check fmt-check budget migration-check`:
463 passed, with the Go 1.26.11 toolchain directory first on PATH.
464- `go vet ./internal/equipo ./internal/equipo/oficinaid ./internal/equipo/personapi ./internal/wire/wireschema ./internal/plan3test`: passed.
465- `make copy-release-check`: passed; no new rendered copy was introduced.
466- Reference scan after staging all new files: 2487 text files, 2846 matches,
467 zero failures.
468
469## Review fixes (Astra review 1, by Claude)
470
471**P1. A native session could approve a paired device.** Pairing approval
472mints a 30-day credential, so a 7-day Oficina ID session could outlive
473itself through it. `DeviceStore.Approve` now refuses any principal with a
474`SessionHash` (`ErrForbidden`), and `DeviceBrowser.ApproveForm` refuses a
475native cookie before reaching approval. The person's web session still
476approves.
477
478- `personapi.TestNativeSessionNeverApprovesAPairedDevice` and
479 `TestNativeSessionNeverApprovesFromTheBrowserForm` failed first ("native
480 session reached the approval write", "native session reached approval").
481- `plan3test.TestPersonAPINativeSessionNeverApprovesPairing` drives both
482 routes with the minted native cookie (403 each, device stays unapproved),
483 then approves with the person's web session (200).
484- Mutations: store guard to `if false` failed the store test and the
485 end-to-end test (`native HTTP 200, want 403`); browser guard removed failed
486 the browser-form test. Both restored.
487
488**P2. The native inputs lost `required`.** The generator writes input
489schemas with nothing required, which replaced the hand-written
490`BeginDeviceInput` (`public_key`, `label`). `wireschema.InputRequired` now
491names the fields the handlers refuse to go without, for `BeginDeviceInput`
492and `NativeRequest` (`assertion`, `verifier`), and panics on a name the
493type lacks. The document carries both lists.
494
495- `wireschema.TestNativeInputsRequireWhatTheirHandlersRequire` validates
496 incomplete bodies (refused) and complete ones (accepted); it failed first
497 on four bodies.
498- Mutation: dropping the required list failed that test and
499 `TestPersonAPIDeviceContract`. Restored.
500
501`TestRequestBodies` (inputs require nothing) now exempts exactly the
502`InputRequired` names.
503
504Gates on macOS, with `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`: `fmt-check`,
505`gitleaks`, `budget` (plan3test raised to the measured 11887 test lines),
506`migration-check`, `copy-release-check`, `lanes-check` and
507`runner-dead-references` pass; `personapi`, `oficinaid`, `wireschema` and
508the `TestPersonAPI` contracts pass. `make test` here fails only where macOS
509cannot run it: the Linux runner packages, the browser tests (no Chromium),
510and `TestCoordinatorAcceptance3B` and `TestPublishCoreAuthorizationContract`,
511which fail the same way on main. `vet` and `staticcheck` stop at
512`internal/toolproxy` (`unix.O_PATH`, Linux only). CI on Linux is the gate.
513