oficina / equipo Public

Add linked Oficina ID native sessions and device registration

Keep unlinked subjects unknown until trusted Home roster integration. Bind native device lifetime and revocation to its source session, and cover both routes with contracts and guard mutation evidence.
Co-Authored-By: Codex GPT-6-Astra <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 925bc74dee421a2862a637b435f03d70d313740a parent d5bdeda
31 files changed, +1,920 −50
  • .rastrillo/budgets.txt +2 −2
  • docs/api/equipo-v1.openapi.json +215 −17
  • docs/superpowers/plans/2026-11-20-native-id-server-evidence.md +467 −0
  • docs/superpowers/specs/2026-11-20-equipo-native-oficina-id.md +120 −0
  • go.mod +1 −1
  • go.sum +2 −0
  • internal/equipo/app.go +14 −1
  • internal/equipo/migrations/0098_native_device.sql +2 −0
  • internal/equipo/migrations/schema.sql +3 −0
  • internal/equipo/oficinaid/http.go +3 −2
  • internal/equipo/oficinaid/link.go +1 −1
  • internal/equipo/oficinaid/migrations/0002_native_lifecycle.sql +10 −0
  • internal/equipo/oficinaid/native.go +144 −0
  • internal/equipo/oficinaid/native_test.go +348 −0
  • internal/equipo/oficinaid/signout.go +1 −1
  • internal/equipo/oficinaid/store.go +20 −5
  • internal/equipo/person_devices.go +1 −1
  • internal/equipo/personapi/auth.go +13 −1
  • internal/equipo/personapi/devices.go +3 −0
  • internal/equipo/personapi/extended_mutations.go +4 −0
  • internal/equipo/personapi/extended_routes.go +1 −0
  • internal/equipo/personapi/handler.go +4 −0
  • internal/equipo/personapi/native_device.go +52 −0
  • internal/equipo/personapi/native_device_test.go +42 −0
  • internal/equipo/personapi/types.go +1 −0
  • internal/equipo/store.go +13 −11
  • internal/plan3test/person_api_contract_test.go +2 −2
  • internal/plan3test/person_api_device_contract_test.go +17 −1
  • internal/plan3test/person_api_migration_test.go +2 −2
  • internal/plan3test/person_api_native_id_test.go +390 −0
  • internal/wire/wireschema/wireschema.go +22 −2

CI passed — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/oficina-id__native-exchange: Type  Size Avail | ext4   96G   85G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   85G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 5.7s
ci-box: codex: fetched and verified in 3.7s
ci-box: codex-code-mode-host: fetched and verified in 1.4s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.4s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.9s
ci-box: pi: installed and verified in 8.0s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.8s
ci-box: clone deepened in 3.2s
ci-box: file times set from content: 2773 files, 176 directories
ci-box: ready in 19.6s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
go: downloading amadan.net/oficina/home/handoff v0.0.0-20261114110939-e03a01a1881c
ok  	amadan.net/oficina/equipo/internal/equipotest	0.251s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
  4.2s
+ go list -export -test -tags testbuild -f  ./...
  3.9s
+ go list -export -test -tags browser,testbuild -f  ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
  3.1s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-11 02:51:11 +0000 UTC

go run github.com/zricethezav/gitleaks/v8@v8.30.1 version
version is set by build process
=== check ===
--- shard 0 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-work: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' ./internal/headless

receipt: test step 1m30.174s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m28.094s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m28.09s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 63.95, cpu waiting 37.63%, memory waiting 0.00%, io waiting 0.39%
--- shard 1 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-review: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$' ./internal/headless

receipt: test step 1m32.952s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m30.723s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m30.72s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 61.79, cpu waiting 37.36%, memory waiting 0.00%, io waiting 0.36%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless

receipt: test step 1m34.78s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m32.917s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m21.39s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 6.24s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 5.28s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 61.79, cpu waiting 36.72%, memory waiting 0.00%, io waiting 0.35%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless

receipt: test step 1m29.693s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m27.673s amadan.net/oficina/equipo/internal/headless
receipt: slow test 44.58s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 22.4s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.92s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.77s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 63.95, cpu waiting 37.63%, memory waiting 0.00%, io waiting 0.39%
--- shard 4 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-guards: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless

receipt: test step 1m46.852s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m45.063s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m6.8s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 12.59s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 10.4s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 9.2s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 6.07s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 50.41, cpu waiting 31.41%, memory waiting 0.00%, io waiting 0.29%
--- shard 5 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-rest: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$|^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$|^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$|^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$|^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless

receipt: test step 3m20.179s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3m18.123s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m54.75s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 24.56s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.71s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 8.22s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.39s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 14.32, cpu waiting 6.88%, memory waiting 0.00%, io waiting 0.05%
--- shard 6 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest

receipt: test step 2m6.003s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m4.107s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 8.12s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.82s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 4.59s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 3.75s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 2.51s amadan.net/oficina/equipo/internal/thintest TestResearchDoneFallsBack
machine: 32 CPUs, load 37.54, cpu waiting 22.66%, memory waiting 0.00%, io waiting 0.20%
--- shard 7 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest-contract: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest

receipt: test step 1m26.27s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m24.382s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.09s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 5.01s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.5s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.44s amadan.net/oficina/equipo/internal/thintest TestContractPreview
receipt: slow test 2.36s amadan.net/oficina/equipo/internal/thintest TestContractPublishNameTaken
machine: 32 CPUs, load 63.95, cpu waiting 37.34%, memory waiting 0.00%, io waiting 0.40%
--- shard 8 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-thin: ./internal/runner/thin
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/runner/thin
cache miss: amadan.net/oficina/equipo/internal/runner/thin: its inputs changed
budget note: internal/runner/thin took 4m40.422s, over the 45s its record on line 44 allows; reported only, timing fails on CI

receipt: test step 4m53.606s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 4m40.422s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 37s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.96s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.79s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.5s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 7.33s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 3.50, cpu waiting 1.43%, memory waiting 0.00%, io waiting 0.00%
--- shard 9 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-bug: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 50.399s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 49.279s amadan.net/oficina/equipo/internal/runner
receipt: slow test 29.25s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 52.22, cpu waiting 29.66%, memory waiting 0.00%, io waiting 0.77%
--- shard 10 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-plans: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 1m0.179s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 58.196s amadan.net/oficina/equipo/internal/runner
receipt: slow test 48.06s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 42.51s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.4s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.71s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 60.28, cpu waiting 34.10%, memory waiting 0.00%, io waiting 0.65%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 35.979s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 35.078s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.14s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.39s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.14s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.42s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 41.58, cpu waiting 19.14%, memory waiting 0.00%, io waiting 0.97%
--- shard 12 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-a started 30s late; cpu waiting 36.5%, load 29.51
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest

receipt: test step 1m7.949s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m6.134s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 27.75s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 27.66s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 25.52s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.88s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 22.76s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfiguration
machine: 32 CPUs, load 57.88, cpu waiting 35.98%, memory waiting 0.00%, io waiting 0.34%
--- shard 13 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-e started 30s late; cpu waiting 37.3%, load 29.51
test lane equipotest-e: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[E-P]' ./internal/equipotest

receipt: test step 1m16.609s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m14.767s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 19.9s amadan.net/oficina/equipo/internal/equipotest TestProjectRequestActorAndUpdate
receipt: slow test 19.88s amadan.net/oficina/equipo/internal/equipotest TestProjectConcurrentRetry
receipt: slow test 19.85s amadan.net/oficina/equipo/internal/equipotest TestProjectKindsAndDefaultBranch
receipt: slow test 19.85s amadan.net/oficina/equipo/internal/equipotest TestProjectOwnersAreMembers
receipt: slow test 19.82s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
machine: 32 CPUs, load 50.41, cpu waiting 31.41%, memory waiting 0.00%, io waiting 0.29%
--- shard 14 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-r started 30s late; cpu waiting 36.5%, load 29.51
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest

receipt: test step 1m13.186s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m8.116s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 14.13s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.34s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.15s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 9.93s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.22s amadan.net/oficina/equipo/internal/equipotest TestRosterAuditFailureRollsBack
machine: 32 CPUs, load 54.37, cpu waiting 33.40%, memory waiting 0.00%, io waiting 0.31%
--- shard 15 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-rest started 30s late; cpu waiting 36.5%, load 29.51
test lane equipotest-rest: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test[A-D]|^TestQ|^Test[E-P]|^TestR' ./internal/equipotest

receipt: test step 1m8.302s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m6.613s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 25.49s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 24.95s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 24.92s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 23.16s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsCurrentOwner
receipt: slow test 23.12s amadan.net/oficina/equipo/internal/equipotest TestSigninBackgroundSweep
machine: 32 CPUs, load 57.88, cpu waiting 35.36%, memory waiting 0.00%, io waiting 0.33%
--- shard 16 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: plan3test started 30s late; cpu waiting 36.5%, load 29.51
test lane plan3test: ./internal/plan3test
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/plan3test

receipt: test step 54.75s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 52.662s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.74s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.54s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.69s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.57s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.28s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorDefinitiveRefusalReleasesQueue
machine: 32 CPUs, load 62.90, cpu waiting 37.19%, memory waiting 0.00%, io waiting 0.42%
--- shard 17 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: rest started 30s late; cpu waiting 36.5%, load 29.51
test lane rest: ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/opencode: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/copydesk: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runnerproto: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/testci: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/containment: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/pi: its inputs changed
budget note: internal/equipo took 21.682s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/chat took 15.028s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/idtest took 43.961s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/release took 19.39s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/runner/containment took 51.526s, over the 15s its record on line 40 allows; reported only, timing fails on CI

receipt: test step 2m33.675s against a 60s target (the gate's other steps are not in this figure)
receipt: 25 packages ran, 36 cached, 18 without tests, 0 failed
receipt: slow package 1m9.953s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 54.572s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 53.757s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 51.526s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 43.961s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 26.18s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 22.95s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringOfflineGo
receipt: slow test 17s amadan.net/oficina/equipo/cmd/equipo-runner TestReleaseRunnerHasNoFakeWorker
receipt: slow test 12.37s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeP1OnlyOpenCodeReachable
receipt: slow test 11.88s amadan.net/oficina/equipo/internal/idtest TestIDCallbackGuardAndPendingNonce
machine: 32 CPUs, load 17.92, cpu waiting 8.69%, memory waiting 0.00%, io waiting 0.07%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserChat
=== RUN   TestBrowserChat
time=2026-11-20T14:28:44.106Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T14:28:44.106Z level=INFO msg="startup phase done" phase=state_lock took=143µs
time=2026-11-20T14:28:44.106Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T14:28:44.106Z level=INFO msg="startup phase done" phase=claim_roots took=161µs
time=2026-11-20T14:28:44.106Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T14:28:44.138Z level=INFO msg="startup phase done" phase=sweep took=31.914ms
time=2026-11-20T14:28:44.138Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T14:28:44.139Z level=INFO msg="startup phase done" phase=credentials took=163µs
time=2026-11-20T14:28:44.139Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T14:28:44.189Z level=INFO msg="startup phase done" phase=open_state took=50.553ms
time=2026-11-20T14:28:44.189Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T14:28:44.190Z level=INFO msg=connecting host=127.0.0.1:33645 protocol=28
time=2026-11-20T14:28:44.192Z level=INFO msg=connected host=127.0.0.1:33645 took=1.755ms
time=2026-11-20T14:28:44.193Z level=INFO msg="capabilities gathering"
time=2026-11-20T14:28:44.193Z level=INFO msg="capabilities gathered" took=780µs tags=linux,claude,go
time=2026-11-20T14:28:44.194Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T14:28:44.202Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T14:28:46.368Z level=INFO msg="connection checked" connection=claude-1 state=healthy
    browser_test.go:46: waiting for [...document.querySelectorAll('[equipo-message="incoming"] [equipo-markdown]:not([data-stream-text])')].some(e=>e.textContent.includes('fake coordinator')): context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserChat (6.26s)

--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
=== RUN   TestBrowserChatSendStaysOnPage
time=2026-11-20T14:28:50.382Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T14:28:50.383Z level=INFO msg="startup phase done" phase=state_lock took=575µs
time=2026-11-20T14:28:50.383Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T14:28:50.383Z level=INFO msg="startup phase done" phase=claim_roots took=188µs
time=2026-11-20T14:28:50.383Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T14:28:50.418Z level=INFO msg="startup phase done" phase=sweep took=35.065ms
time=2026-11-20T14:28:50.419Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T14:28:50.419Z level=INFO msg="startup phase done" phase=credentials took=145µs
time=2026-11-20T14:28:50.419Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T14:28:50.461Z level=INFO msg="startup phase done" phase=open_state took=42.032ms
time=2026-11-20T14:28:50.461Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T14:28:50.463Z level=INFO msg=connecting host=127.0.0.1:38019 protocol=28
time=2026-11-20T14:28:50.464Z level=INFO msg=connected host=127.0.0.1:38019 took=1.32ms
time=2026-11-20T14:28:50.465Z level=INFO msg="capabilities gathering"
time=2026-11-20T14:28:50.465Z level=INFO msg="capabilities gathered" took=721µs tags=linux,claude,go
time=2026-11-20T14:28:50.466Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T14:28:50.473Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T14:28:52.732Z level=INFO msg="connection checked" connection=claude-1 state=healthy
    browser_test.go:108: waiting for [...document.querySelectorAll('[equipo-message="incoming"] [equipo-markdown]:not([data-stream-text])')].some(e=>e.textContent.includes('fake coordinator')): context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserChatSendStaysOnPage (6.34s)

--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
=== RUN   TestBrowserDraftIsTheMessage
time=2026-11-20T14:28:56.757Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T14:28:56.757Z level=INFO msg="startup phase done" phase=state_lock took=65µs
time=2026-11-20T14:28:56.757Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T14:28:56.757Z level=INFO msg="startup phase done" phase=claim_roots took=84µs
time=2026-11-20T14:28:56.757Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T14:28:56.795Z level=INFO msg="startup phase done" phase=sweep took=38.176ms
time=2026-11-20T14:28:56.795Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T14:28:56.796Z level=INFO msg="startup phase done" phase=credentials took=122µs
time=2026-11-20T14:28:56.796Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T14:28:56.846Z level=INFO msg="startup phase done" phase=open_state took=50.42ms
time=2026-11-20T14:28:56.846Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T14:28:56.847Z level=INFO msg=connecting host=127.0.0.1:42227 protocol=28
time=2026-11-20T14:28:56.848Z level=INFO msg=connected host=127.0.0.1:42227 took=1.435ms
time=2026-11-20T14:28:56.849Z level=INFO msg="capabilities gathering"
time=2026-11-20T14:28:56.850Z level=INFO msg="capabilities gathered" took=1.35ms tags=linux,claude,go
time=2026-11-20T14:28:56.851Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T14:28:56.856Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T14:28:58.919Z level=INFO msg="connection checked" connection=claude-1 state=healthy
    browser_thinking_test.go:106: waiting for !!window.__m: context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserDraftIsTheMessage (8.26s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 49.478s
FAIL	amadan.net/oficina/equipo/internal/headless	49.793s


receipt: test step 51.113s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 49.478s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.55s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 8.26s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 7.99s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.34s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
receipt: slow test 6.26s amadan.net/oficina/equipo/internal/headless TestBrowserChat
rastrillo: budget test: go test failed
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' -v -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserDraftIsTheMessage$' -count=1 ./internal/headless   (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserChat browser-headless-chat 925bc74dee421a2862a637b435f03d70d313740a 6.26s 55.16
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
##############################################################################
FLAKE ./internal/headless:TestBrowserChatSendStaysOnPage browser-headless-chat 925bc74dee421a2862a637b435f03d70d313740a 6.34s 55.16
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
##############################################################################
FLAKE ./internal/headless:TestBrowserDraftIsTheMessage browser-headless-chat 925bc74dee421a2862a637b435f03d70d313740a 8.26s 55.16
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 50.41, cpu waiting 30.42%, memory waiting 0.00%, io waiting 0.28%
--- shard 19 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-work: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' ./internal/headless
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
=== RUN   TestBrowserRailFollowsWork
time=2026-11-20T14:28:40.842Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T14:28:40.842Z level=INFO msg="startup phase done" phase=state_lock took=119µs
time=2026-11-20T14:28:40.842Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T14:28:40.842Z level=INFO msg="startup phase done" phase=claim_roots took=121µs
time=2026-11-20T14:28:40.842Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T14:28:40.871Z level=INFO msg="startup phase done" phase=sweep took=28.599ms
time=2026-11-20T14:28:40.871Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T14:28:40.871Z level=INFO msg="startup phase done" phase=credentials took=204µs
time=2026-11-20T14:28:40.872Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T14:28:40.913Z level=INFO msg="startup phase done" phase=open_state took=41.875ms
time=2026-11-20T14:28:40.914Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T14:28:40.915Z level=INFO msg=connecting host=127.0.0.1:46601 protocol=28
time=2026-11-20T14:28:40.916Z level=INFO msg=connected host=127.0.0.1:46601 took=897µs
time=2026-11-20T14:28:40.917Z level=INFO msg="capabilities gathering"
time=2026-11-20T14:28:40.917Z level=INFO msg="capabilities gathered" took=625µs tags=linux,claude,go
time=2026-11-20T14:28:40.918Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T14:28:40.926Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T14:28:42.304Z level=INFO msg="connection checked" connection=claude-1 state=healthy
time=2026-11-20T14:28:51.656Z level=INFO msg="kept sessions" kept=1 bytes=2770 expired=0
time=2026-11-20T14:28:56.334Z level=INFO msg="kept sessions" kept=2 bytes=4922 expired=0
time=2026-11-20T14:28:57.087Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T14:28:57.087Z level=INFO msg="startup phase done" phase=state_lock took=63µs
time=2026-11-20T14:28:57.087Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T14:28:57.087Z level=INFO msg="startup phase done" phase=claim_roots took=83µs
time=2026-11-20T14:28:57.087Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T14:28:57.117Z level=INFO msg="startup phase done" phase=sweep took=29.491ms
time=2026-11-20T14:28:57.117Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T14:28:57.117Z level=INFO msg="startup phase done" phase=credentials took=209µs
time=2026-11-20T14:28:57.117Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T14:28:57.174Z level=INFO msg="startup phase done" phase=open_state took=57.178ms
time=2026-11-20T14:28:57.175Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T14:28:57.176Z level=INFO msg=connecting host=127.0.0.1:45921 protocol=28
time=2026-11-20T14:28:57.180Z level=INFO msg=connected host=127.0.0.1:45921 took=3.437ms
time=2026-11-20T14:28:57.180Z level=INFO msg="capabilities gathering"
time=2026-11-20T14:28:57.181Z level=INFO msg="capabilities gathered" took=723µs tags=linux,claude,go
time=2026-11-20T14:28:57.185Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T14:28:57.188Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T14:28:59.387Z level=INFO msg="connection checked" connection=claude-1 state=healthy
    browser_review_test.go:57: waiting for document.querySelector('#rail [data-specialist="engineering"]')?.dataset.state==='working' && document.querySelector('#rail [data-specialist="engineering"]').querySelector('[equipo-nav-task]')?.textContent==='Slow sidebar change' && document.querySelector('#nav-tasks [data-count]')?.textContent==='1': context deadline exceeded (last evaluation: <nil>)
--- FAIL: TestBrowserRailFollowsWork (22.53s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m37.319s
FAIL	amadan.net/oficina/equipo/internal/headless	97.653s


receipt: test step 1m38.857s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m37.319s amadan.net/oficina/equipo/internal/headless
receipt: slow test 27.81s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 22.53s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 14.45s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 11.19s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 10.87s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
rastrillo: budget test: go test failed
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' -v -run '^TestBrowserRailFollowsWork$' -count=1 ./internal/headless   (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserRailFollowsWork browser-headless-work 925bc74dee421a2862a637b435f03d70d313740a 22.53s 57.88
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 40.63, cpu waiting 24.22%, memory waiting 0.00%, io waiting 0.22%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless

receipt: test step 1m48.691s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m47.039s amadan.net/oficina/equipo/internal/headless
receipt: slow test 17.68s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 14.07s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 13.21s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 11.09s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.66s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 50.41, cpu waiting 30.42%, memory waiting 0.00%, io waiting 0.28%
--- shard 21 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-rest: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN   TestBrowserEmptyExplore
time=2026-11-20T14:29:32.322Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T14:29:32.322Z level=INFO msg="startup phase done" phase=state_lock took=145µs
time=2026-11-20T14:29:32.322Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T14:29:32.322Z level=INFO msg="startup phase done" phase=claim_roots took=96µs
time=2026-11-20T14:29:32.322Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T14:29:32.352Z level=INFO msg="startup phase done" phase=sweep took=29.237ms
time=2026-11-20T14:29:32.352Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T14:29:32.352Z level=INFO msg="startup phase done" phase=credentials took=118µs
time=2026-11-20T14:29:32.352Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T14:29:32.394Z level=INFO msg="startup phase done" phase=open_state took=42.164ms
time=2026-11-20T14:29:32.395Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T14:29:32.396Z level=INFO msg=connecting host=127.0.0.1:37001 protocol=28
time=2026-11-20T14:29:32.398Z level=INFO msg=connected host=127.0.0.1:37001 took=1.062ms
time=2026-11-20T14:29:32.398Z level=INFO msg="capabilities gathering"
time=2026-11-20T14:29:32.399Z level=INFO msg="capabilities gathered" took=505µs tags=linux,claude,go
time=2026-11-20T14:29:32.400Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T14:29:32.405Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T14:29:33.539Z level=INFO msg="connection checked" connection=claude-1 state=healthy
    browser_receipts_test.go:169: waiting for [...document.querySelectorAll('[equipo-markdown]:not([data-stream-text])')].some(e=>e.textContent.includes("I'm your coordinator")): context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserEmptyExplore (5.86s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m36.642s
FAIL	amadan.net/oficina/equipo/internal/headless	96.995s


receipt: test step 1m38.414s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m36.642s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.29s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 12.73s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 11.75s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 11.13s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 8.16s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserEmptyExplore$' -count=1 ./internal/headless   (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserEmptyExplore browser-headless-rest 925bc74dee421a2862a637b435f03d70d313740a 5.86s 57.88
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 50.41, cpu waiting 30.42%, memory waiting 0.00%, io waiting 0.28%
--- shard 22 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-rest: ./internal/equipo
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserPreviewBlocksNavigation)$' ./internal/equipo

receipt: test step 2.288s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 677ms amadan.net/oficina/equipo/internal/equipo
receipt: slow test 680ms amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewBlocksNavigation
browser lane browser-rest: ./internal/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor)$' ./internal/idtest

receipt: test step 2.836s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1.663s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 1.66s amadan.net/oficina/equipo/internal/idtest TestBrowserOficinaIDDoor
browser lane browser-rest: ./internal/plan3test
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestTeamsHierarchyBrowser)$' ./internal/plan3test

receipt: test step 3.392s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1.971s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 1.97s amadan.net/oficina/equipo/internal/plan3test TestTeamsHierarchyBrowser
browser lane browser-rest: ./internal/thintest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAccessEmojiByline|TestBrowserAccessFinalOutcomes|TestBrowserAccessRequest|TestBrowserAccessReview|TestBrowserActivitySubjects|TestBrowserAutonomySettings|TestBrowserCoordinatorQueue|TestBrowserEmptyConversation|TestBrowserHousekeeping|TestBrowserInnerGallery|TestBrowserInnerScreens|TestBrowserInstantThinking|TestBrowserInstantThinkingQueued|TestBrowserMachines|TestBrowserPhoneIndex|TestBrowserPlacementQuestionAndPending|TestBrowserProjectPlacement|TestBrowserProjectsList|TestBrowserReportActionFeedback|TestBrowserReportNextSteps|TestBrowserReportThread|TestBrowserRollup|TestBrowserRosterAlignment|TestBrowserRosterDecisionStates|TestBrowserRosterQuietDay|TestBrowserRosterReports|TestBrowserRosterSetAside|TestBrowserRosterSubchat|TestBrowserRosterThinking|TestBrowserRosterVisual|TestBrowserSettingsHousekeepingGroups|TestBrowserSettingsMenu|TestBrowserSettingsRail|TestBrowserSettingsSaveBar|TestBrowserSettingsShots|TestBrowserSettingsStayOnPage|TestBrowserSettingsTeams|TestBrowserShipsButtons|TestBrowserSpecialistRows|TestBrowserSpendFollowsAnswers|TestBrowserTaskRows|TestBrowserTeamPanel|TestBrowserThinkingCycles|TestBrowserThinkingLinesClear|TestBrowserThinkingSteady|TestBrowserThinkingWords|TestBrowserTokenRowEmail|TestBrowserTrackPulse|TestBrowserTrackStarCentre)$' ./internal/thintest

receipt: test step 3m25.828s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3m24.285s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 17.8s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.38s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.02s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.73s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 8.2s amadan.net/oficina/equipo/internal/thintest TestBrowserInnerScreens
machine: 32 CPUs, load 11.14, cpu waiting 5.27%, memory waiting 0.00%, io waiting 0.04%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless   (58s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.39s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.64s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 10.78s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 11.27s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 26.39s
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^C5_review_auth$|^TestHeadlessConnections$/^C5_review_failover$|^TestHeadlessConnections$/^C5_review_on_codex$|^TestHeadlessConnections$/^C5_review_other_family_first$' ./internal/headless   (71s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 17.22s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 23.13s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 12.66s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 15.96s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless   (24s)
ok ./internal/headless TestMixedVersions 22.24s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks   (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.79s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin   (1s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.06s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 62.13, cpu waiting 36.07%, memory waiting 0.00%, io waiting 0.53%
--- shard 24 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 24: make runner-host
python3 scripts/runner-prerequisites.py
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks

receipt: test step 11.827s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 3 without tests, 0 failed
receipt: slow package 7.998s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 187ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 77ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 5.69s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.81s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 380ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxToolchain
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run '^TestNamespace' -count=1 ./internal/runner/containment
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run '^TestNamespace' -count=1 ./internal/runner/containment

receipt: test step 3.395s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.885s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 300ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 200ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 21.98, cpu waiting 7.95%, memory waiting 0.00%, io waiting 1.36%
--- shard 25 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: runner-dead-references started 30s late; cpu waiting 36.5%, load 29.51
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2487 text files, 2846 matches, 0 failures
python3 scripts/ci-test.py check
lanes: 18 lanes and 5 browser lanes run every test once; 20-check@29
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o /dev/null ./cmd/equipo-runner
go vet ./...
go vet -tags testbuild ./internal/runner/thin ./internal/headless
GOOS=darwin GOARCH=arm64 go vet ./cmd/equipo-runner/... ./internal/runner/... ./internal/wire/... ./internal/release/...
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 88 directories within budget
CGO_ENABLED=0 go test ./internal/equipo -run '^TestMigrationModels$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipo	2.534s
machine: 32 CPUs, load 63.28, cpu waiting 36.11%, memory waiting 0.00%, io waiting 0.55%
--- shard 26 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: staticcheck started 30s late; cpu waiting 36.5%, load 29.51
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 52.22, cpu waiting 28.49%, memory waiting 0.00%, io waiting 0.80%
--- shard 27 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: govulncheck started 30s late; cpu waiting 36.5%, load 29.51
shard 27: make govulncheck
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
=== Symbol Results ===

No vulnerabilities found.

Your code is affected by 0 vulnerabilities.
This scan also found 0 vulnerabilities in packages you import and 5
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
machine: 32 CPUs, load 41.58, cpu waiting 20.96%, memory waiting 0.00%, io waiting 0.94%
--- shard 28 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: gitleaks started 30s late; cpu waiting 36.5%, load 29.51
shard 28: make gitleaks
2:28PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
2:29PM INF 1056 commits scanned.
2:29PM INF scanned ~60430306 bytes (60.43 MB) in 21.7s
2:29PM INF no leaks found
machine: 32 CPUs, load 55.16, cpu waiting 31.11%, memory waiting 0.00%, io waiting 0.74%
=== perf ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -require TestPerfScreens,TestPerfBoot -tags perf -count=1 -p 1 -parallel 1 -run '^TestPerf' ./...
perf: GET /: median 1.284ms, worst 1.324ms, budget 150ms
perf: GET /api/runner/protocol: median 81µs, worst 113µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 667µs, worst 733µs, budget 150ms
perf: GET /api/v1/accounts: median 468µs, worst 531µs, budget 150ms
perf: GET /api/v1/auth/devices: median 461µs, worst 509µs, budget 150ms
perf: GET /api/v1/budgets: median 550µs, worst 558µs, budget 150ms
perf: GET /api/v1/capabilities: median 267µs, worst 312µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.351ms, worst 1.413ms, budget 150ms
perf: GET /api/v1/connections: median 642µs, worst 711µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 603µs, worst 662µs, budget 150ms
perf: GET /api/v1/conversation: median 1.015ms, worst 1.097ms, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.63ms, worst 1.753ms, budget 150ms
perf: GET /api/v1/coordinator: median 2.086ms, worst 2.226ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 495µs, worst 532µs, budget 150ms
perf: GET /api/v1/journey: median 8.298ms, worst 8.579ms, budget 150ms
perf: GET /api/v1/me: median 470µs, worst 525µs, budget 150ms
perf: GET /api/v1/me/settings: median 544µs, worst 1.158ms, budget 150ms
perf: GET /api/v1/needs-you: median 7.657ms, worst 8.18ms, budget 150ms
perf: GET /api/v1/notifications: median 1.79ms, worst 1.844ms, budget 150ms
perf: GET /api/v1/onboarding: median 397µs, worst 447µs, budget 150ms
perf: GET /api/v1/people: median 460µs, worst 474µs, budget 150ms
perf: GET /api/v1/playbooks: median 598µs, worst 621µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 563µs, worst 587µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 871µs, worst 894µs, budget 150ms
perf: GET /api/v1/preferences: median 792µs, worst 889µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 477µs, worst 499µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 625µs, worst 660µs, budget 150ms
perf: GET /api/v1/roster: median 513µs, worst 574µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 427µs, worst 480µs, budget 150ms
perf: GET /api/v1/specialists: median 8.482ms, worst 8.62ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 8.367ms, worst 8.51ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 851µs, worst 899µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.233ms, worst 1.287ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 747µs, worst 893µs, budget 150ms
perf: GET /api/v1/teams: median 456µs, worst 469µs, budget 150ms
perf: GET /api/v1/templates: median 623µs, worst 653µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 473µs, worst 514µs, budget 150ms
perf: GET /auth/callback: median 70µs, worst 135µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.58ms, worst 3.661ms, budget 150ms
perf: GET /auth/verify: median 76µs, worst 103µs, budget 150ms
perf: GET /connections: median 3.97ms, worst 4.102ms, budget 150ms
perf: GET /conversation: median 8.024ms, worst 8.294ms, budget 150ms
perf: GET /conversation/connections: median 260µs, worst 312µs, budget 150ms
perf: GET /conversation/notebook: median 246µs, worst 298µs, budget 150ms
perf: GET /conversation/settings: median 4.205ms, worst 5.556ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 4.082ms, worst 4.199ms, budget 150ms
perf: GET /conversation/settings/connections: median 6.94ms, worst 7.152ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 6.954ms, worst 7.2ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.918ms, worst 4.089ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 4.445ms, worst 4.678ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.879ms, worst 5.023ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.873ms, worst 5.14ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.723ms, worst 3.835ms, budget 150ms
perf: GET /conversation/settings/thinking: median 4.587ms, worst 4.696ms, budget 150ms
perf: GET /housekeeping: median 4.206ms, worst 4.409ms, budget 150ms
perf: GET /invites/new: median 652µs, worst 682µs, budget 150ms
perf: GET /invites/{id}: median 692µs, worst 748µs, budget 150ms
perf: GET /jobs: median 3.689ms, worst 3.782ms, budget 150ms
perf: GET /jobs/{id}: median 4.924ms, worst 5.116ms, budget 150ms
perf: GET /journey: median 13.313ms, worst 13.771ms, budget 150ms
perf: GET /nav/rail: median 3.533ms, worst 3.748ms, budget 150ms
perf: GET /needs-you: median 12.608ms, worst 13.01ms, budget 150ms
perf: GET /onboarding: median 4.659ms, worst 4.811ms, budget 150ms
perf: GET /people: median 4.052ms, worst 7.315ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 5.918ms, worst 6.06ms, budget 150ms
perf: GET /playbooks: median 5.309ms, worst 5.342ms, budget 150ms
perf: GET /playbooks/new: median 5.379ms, worst 5.554ms, budget 150ms
perf: GET /playbooks/{id}: median 4.874ms, worst 5.026ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.959ms, worst 5.072ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 4.13ms, worst 4.335ms, budget 150ms
perf: GET /preferences: median 4.62ms, worst 4.785ms, budget 150ms
perf: GET /preferences/sources/{source}: median 4.515ms, worst 4.619ms, budget 150ms
perf: GET /projects: median 5.652ms, worst 5.893ms, budget 150ms
perf: GET /projects/accounts: median 3.918ms, worst 4.065ms, budget 150ms
perf: GET /projects/new: median 4.125ms, worst 5.985ms, budget 150ms
perf: GET /projects/{id}: median 11.305ms, worst 11.608ms, budget 150ms
perf: GET /projects/{id}/edit: median 4.105ms, worst 4.163ms, budget 150ms
perf: GET /runners/enrol: median 4.95ms, worst 5.107ms, budget 150ms
perf: GET /settings: median 3.639ms, worst 3.755ms, budget 150ms
perf: GET /settings/coordinator: median 5.922ms, worst 6.197ms, budget 150ms
perf: GET /settings/devices: median 3.527ms, worst 3.6ms, budget 150ms
perf: GET /settings/recovery: median 3.64ms, worst 3.743ms, budget 150ms
perf: GET /settings/recovery/release: median 3.734ms, worst 3.913ms, budget 150ms
perf: GET /settings/thinking: median 245µs, worst 266µs, budget 150ms
perf: GET /signin: median 310µs, worst 338µs, budget 150ms
perf: GET /specialists/new: median 3.685ms, worst 3.762ms, budget 150ms
perf: GET /specialists/{key}: median 12.173ms, worst 14.496ms, budget 150ms
perf: GET /specialists/{key}/edit: median 4.018ms, worst 4.124ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 4.066ms, worst 4.191ms, budget 150ms
perf: GET /tasks: median 5.575ms, worst 5.841ms, budget 150ms
perf: GET /tasks/new: median 3.555ms, worst 3.62ms, budget 150ms
perf: GET /tasks/{id}: median 6.049ms, worst 6.215ms, budget 150ms
perf: GET /tasks/{id}/merge: median 5.236ms, worst 5.356ms, budget 150ms
perf: GET /tasks/{id}/move: median 5.054ms, worst 5.185ms, budget 150ms
perf: GET /tasks/{id}/plan: median 6.274ms, worst 6.454ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.743ms, worst 1.777ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 6.09ms, worst 6.295ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 5.302ms, worst 5.538ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4.919ms, worst 4.992ms, budget 150ms
perf: GET /tasks/{id}/thread: median 8.71ms, worst 9.013ms, budget 150ms
perf: GET /team/{specialist}: median 4.752ms, worst 4.852ms, budget 150ms
perf: GET /teams: median 10.856ms, worst 11.141ms, budget 150ms
perf: GET /templates: median 3.684ms, worst 3.734ms, budget 150ms
perf: GET /usage: median 4.455ms, worst 4.682ms, budget 150ms
perf: GET /work: median 3.36ms, worst 5.816ms, budget 150ms
perf: cold boot: median 266ms of [264.887221ms 265.803055ms 266.92242ms], budget 500ms

receipt: test step 42.438s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 84 without tests, 0 failed
receipt: slow package 9.283s amadan.net/oficina/equipo/internal/equipotest
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-runner
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-tool-proxy
receipt: slow package 0s amadan.net/oficina/equipo/internal/advice
receipt: slow package 0s amadan.net/oficina/equipo/internal/attach
receipt: slow test 8.43s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 850ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 4.75 GiB in 26308 files
ci-box: module cache /home/ci/work/repos/oficina__equipo/cache/go-mod: 0.84 GiB in 27348 files
ci-box: build cache over 4.0 GiB: dropped 2.14 GiB this job did not read, kept 2.61 GiB
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 1df51253..6f9b79f4 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,7 +14,7 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 21493 - Merge main conversation starters and work status with native push configuration; measured 21493/3385 source/test lines.
+size internal/equipo 21508 - Native identity session callback and device registration wiring; measured 21508/3385 source/test lines.
size internal/wire 6768 - Native slice 2 push registrations and set aside, with main integrated; measured 6768/2972 source/test lines.
size internal/equipotest - 12013 Task 21 repairs historical migration and conversation fixtures after Plan 3; measured 0/12013 source/test lines.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
@@ -30,7 +30,7 @@ size internal/runner/provider 5603 - Fable follow-up: base and diagnostic gates,
time internal/plan3test 300s Initial cap for combined browser and runner acceptance; measure at both usable stops.
-size internal/plan3test - 11446 Plan 3 release-boundary and copy-inventory contracts in one package, and native slice 2 push registration lifetime; measured 940/11446 source/test lines.
+size internal/plan3test - 11852 Native identity route, transaction, revocation and loopback TLS contracts; measured 940/11852 source/test lines.
time internal/runner/forge 20s Plan 3 CI repair measured 10.527s for the full package (controller CI 10.407s).
time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full package (controller CI 10.709s);
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json
index 6320e411..09598f6a 100644
--- a/docs/api/equipo-v1.openapi.json
+++ b/docs/api/equipo-v1.openapi.json
@@ -13607,6 +13607,155 @@
"x-rejectUnknownFields": true
}
}
+ },
+ "/auth/devices/native": {
+ "post": {
+ "operationId": "post_auth_devices_native",
+ "description": "Register a device using only its own live home-assertion-native session cookie and same-origin request evidence (send the exact instance Origin). JSON only. Idempotency-Key is not required; each success creates a new credential. The credential expires seven days after the source session was minted, and is revoked when that session is deleted. Paired credentials retain thirty days. public_key is canonical unpadded base64url of the 32-byte Curve25519 signing public key; label is 1–128 UTF-8 bytes without NUL, CR or LF.",
+ "security": [
+ {
+ "browserSession": []
+ }
+ ],
+ "parameters": [],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/BeginDeviceInput"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "JSON response; Cache-Control: no-store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PersonCredential"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "unauthenticated",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "forbidden",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "422": {
+ "description": "invalid_input",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "unavailable",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/native/oficina-id": {
+ "post": {
+ "operationId": "post_native_oficina_id",
+ "description": "Exchange an assertion and canonical 43-character verifier for a native session. JSON only; Origin and Sec-Fetch-Site headers refused; no cookies set. Only explicitly linked active roster members are admitted. Every unlinked subject, including choice:new, gets byte-identical 403 {\"state\":\"unknown\"}. No allocation or 409 choose in this slice. expires_at is Unix seconds. Errors: 400 invalid, 401 failed, 503 unavailable.",
+ "security": [],
+ "parameters": [],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/NativeRequest"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "JSON response; Cache-Control: no-store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/NativeSession"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "JSON response; Cache-Control: no-store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/NativeState"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "JSON response; Cache-Control: no-store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/NativeState"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "JSON response; Cache-Control: no-store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/NativeState"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "JSON response; Cache-Control: no-store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/NativeState"
+ }
+ }
+ }
+ }
+ },
+ "servers": [
+ {
+ "url": "/"
+ }
+ ]
+ }
}
},
"components": {
@@ -15029,20 +15178,17 @@
}
},
"BeginDeviceInput": {
- "additionalProperties": false,
+ "type": "object",
"properties": {
- "label": {
+ "public_key": {
"type": "string"
},
- "public_key": {
+ "label": {
"type": "string"
}
},
- "required": [
- "public_key",
- "label"
- ],
- "type": "object"
+ "additionalProperties": false,
+ "x-go-type": "personapi.BeginDeviceInput"
},
"ApproveDeviceInput": {
"additionalProperties": false,
@@ -16324,23 +16470,23 @@
"type": "object"
},
"PersonCredential": {
- "additionalProperties": false,
+ "type": "object",
"properties": {
- "audience": {
- "const": "equipo.person.v1"
+ "id": {
+ "type": "string"
},
- "expires_at": {
- "format": "date-time",
+ "token": {
"type": "string"
},
- "id": {
+ "audience": {
"type": "string"
},
"instance_id": {
"type": "string"
},
- "token": {
- "type": "string"
+ "expires_at": {
+ "type": "string",
+ "format": "date-time"
}
},
"required": [
@@ -16350,7 +16496,8 @@
"instance_id",
"expires_at"
],
- "type": "object"
+ "additionalProperties": false,
+ "x-go-type": "personapi.PersonCredential"
},
"Device": {
"additionalProperties": false,
@@ -23114,6 +23261,57 @@
},
"additionalProperties": false,
"x-go-type": "wire.SetCardVisibility"
+ },
+ "NativeRequest": {
+ "type": "object",
+ "properties": {
+ "assertion": {
+ "type": "string"
+ },
+ "verifier": {
+ "type": "string"
+ },
+ "choice": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "x-go-type": "oficinaid.NativeRequest"
+ },
+ "NativeSession": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "value": {
+ "type": "string"
+ },
+ "expires_at": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ "required": [
+ "name",
+ "value",
+ "expires_at"
+ ],
+ "additionalProperties": false,
+ "x-go-type": "oficinaid.NativeSession"
+ },
+ "NativeState": {
+ "type": "object",
+ "properties": {
+ "state": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "state"
+ ],
+ "additionalProperties": false,
+ "x-go-type": "oficinaid.NativeState"
}
},
"responses": {
diff --git a/docs/superpowers/plans/2026-11-20-native-id-server-evidence.md b/docs/superpowers/plans/2026-11-20-native-id-server-evidence.md
new file mode 100644
index 00000000..81490287
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-20-native-id-server-evidence.md
@@ -0,0 +1,467 @@
+# Native Oficina ID server verification
+
+Implementer: Codex GPT-6-Astra.
+
+Initial 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.
+
+Each 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.
+
+## native nonce
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/(verifier|web-nonce)$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.07s)
+--- FAIL: TestNativeExchangeGates/verifier (0.03s)
+native_test.go:142: status 200 want 401
+--- FAIL: TestNativeExchangeGates/web-nonce (0.04s)
+native_test.go:142: status 200 want 401
+```
+
+## pinned signature issuer audience and expiry
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/(audience|issuer|key|expired)$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.11s)
+--- FAIL: TestNativeExchangeGates/audience (0.03s)
+native_test.go:142: status 200 want 401
+--- FAIL: TestNativeExchangeGates/issuer (0.03s)
+native_test.go:142: status 403 want 401
+--- FAIL: TestNativeExchangeGates/key (0.03s)
+native_test.go:142: status 200 want 401
+```
+
+## Origin including empty
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/(origin|empty-origin)$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.11s)
+--- FAIL: TestNativeExchangeGates/origin (0.05s)
+native_test.go:142: status 200 want 400
+--- FAIL: TestNativeExchangeGates/empty-origin (0.06s)
+native_test.go:142: status 200 want 400
+```
+
+## fetch provenance
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/fetch$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.03s)
+--- FAIL: TestNativeExchangeGates/fetch (0.03s)
+native_test.go:142: status 200 want 400
+```
+
+## JSON media
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/json$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.03s)
+--- FAIL: TestNativeExchangeGates/json (0.03s)
+native_test.go:142: status 200 want 400
+```
+
+## unknown input fields
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/unknown-field$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.03s)
+--- FAIL: TestNativeExchangeGates/unknown-field (0.03s)
+native_test.go:142: status 200 want 400
+```
+
+## duplicate input fields
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/duplicate-field$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.04s)
+--- FAIL: TestNativeExchangeGates/duplicate-field (0.04s)
+native_test.go:142: status 200 want 400
+```
+
+## replay reservation
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/replay$|^TestNativeConcurrentExchange$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.03s)
+--- FAIL: TestNativeExchangeGates/replay (0.03s)
+native_test.go:142: status 200 want 401
+--- FAIL: TestNativeConcurrentExchange (0.04s)
+native_test.go:207: concurrent mints 8
+```
+
+## identical unknown including choice new
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeUnknownIsIdentical$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeUnknownIsIdentical (0.01s)
+native_test.go:169: unknown status: 409
+```
+
+## roster before replay reservation
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeUnknownIsIdentical$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeUnknownIsIdentical (0.02s)
+native_test.go:178: unknown allocated oficina_handoff_replay 1 <nil>
+```
+
+## roster unavailable
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/unavailable$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.02s)
+--- FAIL: TestNativeExchangeGates/unavailable (0.02s)
+native_test.go:142: status 403 want 503
+```
+
+## session epoch at mint
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeExchangeGates$/epoch$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeExchangeGates (0.02s)
+--- FAIL: TestNativeExchangeGates/epoch (0.02s)
+native_test.go:142: status 200 want 403
+```
+
+## reserve releases writer before mint
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeConcurrentExchange$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeConcurrentExchange (2.02s)
+native_test.go:200: concurrent status 503
+```
+
+## absolute seven days
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeSessionAbsoluteLifetime$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeSessionAbsoluteLifetime (0.02s)
+native_test.go:263: absolute native lifetime slid
+```
+
+## home derived method resolution
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeSessionAbsoluteLifetime$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeSessionAbsoluteLifetime (0.03s)
+native_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
+```
+
+## source session method
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeSessionOnRejectsLocal$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeSessionOnRejectsLocal (0.01s)
+native_test.go:285: local session authorized native device
+```
+
+## native unlink deletion
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/oficinaid -run ^TestNativeUnlinkDeletesSession$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestNativeUnlinkDeletesSession (0.02s)
+native_test.go:294: native sessions retained 1 <nil>
+```
+
+## device actor and source person
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/(actor|session-person)$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.46s)
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards/actor (0.45s)
+person_api_native_id_test.go:251: native device guard accepted actor
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards/session-person (0.01s)
+person_api_native_id_test.go:251: native device guard accepted session-person
+```
+
+## device source method
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/session-method$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.45s)
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards/session-method (0.45s)
+person_api_native_id_test.go:251: native device guard accepted session-method
+```
+
+## device source expiry
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/session-expiry$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.45s)
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards/session-expiry (0.45s)
+person_api_native_id_test.go:251: native device guard accepted session-expiry
+```
+
+## device transactional roster
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/roster$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.45s)
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards/roster (0.45s)
+person_api_native_id_test.go:251: native device guard accepted roster
+```
+
+## device expiry follows original session
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDevice$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDevice (0.47s)
+person_api_native_id_test.go:111: wrong owner, source, or expiry
+```
+
+## audit credential exclusion
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDevice$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDevice (0.46s)
+person_api_native_id_test.go:120: credential or label in audit
+```
+
+## audit failure rollback
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceTransactionGuards$/audit$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards (0.46s)
+--- FAIL: TestPersonAPINativeDeviceTransactionGuards/audit (0.46s)
+person_api_native_id_test.go:251: native device guard accepted audit
+```
+
+## device key length
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceGates$/key$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceGates (0.47s)
+--- FAIL: TestPersonAPINativeDeviceGates/key (0.00s)
+person_api_native_id_test.go:196: native HTTP 200, want 422
+```
+
+## device revocation cascade
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeSessionRevocation$/session$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeSessionRevocation (0.46s)
+--- FAIL: TestPersonAPINativeSessionRevocation/session (0.46s)
+person_api_native_id_test.go:281: native device remained live session
+```
+
+## push cleanup cascade
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeSessionRevocation$/session$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeSessionRevocation (0.46s)
+--- FAIL: TestPersonAPINativeSessionRevocation/session (0.46s)
+person_api_native_id_test.go:285: push secret survived push_registrations
+```
+
+## device same origin
+
+`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run ^TestPersonAPINativeDeviceGates$/no-origin$ -count=1 -timeout=15s`
+
+Caught:
+
+```text
+--- FAIL: TestPersonAPINativeDeviceGates (0.47s)
+--- FAIL: TestPersonAPINativeDeviceGates/no-origin (0.00s)
+person_api_native_id_test.go:196: native HTTP 200, want 403
+```
+
+## Scope and contracts
+
+Paul's clarification on 2026-11-20 limits this branch to existing explicit
+Oficina ID links. Every unlinked subject, even with `choice:"new"`, receives
+403 unknown. There is no allocation or 409 choice path. The approved spec's
+Order section records Home roster integration as follow-up work.
+
+`POST /native/oficina-id` accepts JSON `{assertion, verifier, choice?}`.
+`verifier` is canonical unpadded base64url of 32 random bytes (43 ASCII
+characters). Challenge hashes those ASCII characters; the nonce hashes the
+native context and decoded challenge, taking the first 16 bytes as Home's
+handoff protocol specifies. Only absent choice or `"new"` is accepted; it
+never allocates. Origin and Sec-Fetch-Site headers are refused, including an
+empty Origin. There are no cookies set. All answers are JSON and no-store:
+
+- 200: `{name, value, expires_at}`, with expiry in Unix seconds.
+- 400: `{"state":"invalid"}`.
+- 401: `{"state":"failed"}`.
+- 403: `{"state":"unknown"}`, byte-identical for every unknown subject.
+- 503: `{"state":"unavailable"}` for unavailable roster/storage.
+
+`POST /api/v1/auth/devices/native` accepts JSON `{public_key, label}` and the
+exchange session as a Cookie. Send `Origin: <instance origin>`. A device bearer,
+a web Oficina ID session, a local session, and mixed credentials cannot
+register a device. public_key is canonical unpadded base64url of the existing
+pairing protocol's 32-byte Curve25519 signing public key. label is 1–128 UTF-8
+bytes without NUL, CR or LF. No person or actor field is accepted.
+Idempotency-Key is not required: each success registers a new device.
+
+The 200 response is pairing's existing PersonCredential:
+`{id, token, audience, instance_id, expires_at}`. audience is
+`equipo.person.v1`; expires_at is an RFC3339 UTC timestamp, seven days after
+the source session's At, including when registration occurs days later.
+Errors use the existing `{code, copy_key, request_id, current_revision?}`
+envelope: 401 unauthenticated, 403 forbidden, 422 invalid_input and 503
+unavailable. Paired devices retain their existing 30-day expiry.
+
+The audit action `person_device.native` records the verified actor and device
+ID only. It has no token, session hash, public key or label. This adds no
+rendered interface text. Source session deletion revokes its native devices,
+clears pending credential responses and removes their push tokens and pending
+pushes. Unlink and roster deletion/address changes reach the same cascade.
+Home grant revocation alone has the native spec's disclosed offline residual:
+without instance session deletion, an already issued session and device may
+last to their absolute seven-day expiry.
+
+## Transaction and live evidence
+
+The handoff module is advanced to e03a01a1881c to reuse its verified native
+nonce and durable Reserve implementation; Rastrillo remains v0.30.3.
+Reserve commits its own short transaction before mintNative is invoked.
+The latter opens its own transaction and uses that handle for link resolution,
+current roster/epoch checks, the session insert and audit. No external hook
+or framework session writer is called with that writer held. With unlinked
+allocation deferred, there are no Admit, Unlinked or HomeOnly hooks here.
+
+TestNativeVerifierDoesNotWaitOnWriter holds the only connection in a write
+transaction and verifies a bad assertion returns without waiting on it.
+TestNativeConcurrentExchange performs successful exchanges with the pool
+limited to one connection; the mutation that holds a writer across the mint
+fails with 503 instead of wedging. It also proves only one of eight concurrent
+redemptions succeeds and replay survives a new Store. TestNativeConcurrentUnlink
+covers exchange racing unlink and replay after relink.
+
+TestPersonAPINativeLiveExchange runs a fake Home signing server and Equipo's
+production router on loopback HTTP/TLS listeners. It obtains an assertion,
+exchanges it, registers a device, and successfully reads the engine snapshot
+using only the resulting device bearer. Its source-session and credential
+expiries agree. Test cleanup closes both listeners and their databases.
+
+## Home follow-up, inspected read-only
+
+Inspected Home origin/main at 17cdcaff33452b49eb7bd38c999219a5bc49dcc4.
+No Home files were changed.
+
+- `internal/home/native_assert.go`: nativeAssert already accepts any exact
+ origin in consumers(), except the operator consumer, and calls shared
+ mintPolicy. Equipo requires no app-specific assert bypass or new audience
+ predicate. Its exact origin must be an active consumer.
+- `internal/home/consumer_registry.go`: consumers() is HOME_CONSUMERS plus
+ active consumer-table records. Registration must use the existing operator
+ flow; duplicate ID/origin entries in the environment and table fail closed.
+ Source inspection cannot attest to a deployed registry entry: the operator
+ must verify each Equipo consumer and its exact origin before rollout.
+- Add Equipo to `nativeTeamApps` in `internal/home/directory_native.go`, so
+ GET /api/native/teams can return it as the sixth native app.
+- Add the integrated app in `directoryApps()` in
+ `internal/home/directory_runtime.go`; this also supplies the allowed apps
+ for directorydata.Store and the directory roster source. Merely adding the
+ native filter entry is insufficient: AgentChoices also filters allowed apps.
+- Add Equipo to `directorydata.CanonicalOrigin` for the existing `oficina`
+ team and its `equipo` consumer at `https://equipo.oficina.works`.
+ Other teams use their registered `https://<label>.equipo.oficina.works`
+ route. The canonical rule also gates operator adoption planning.
+- Add the display catalog entry and any desired preview configuration in
+ `directory_catalog.go`; cover Equipo in chooser/catalog tests.
+- Extend TestNativeAssert for a registered Equipo audience and near-misses,
+ and TestNativeDirectoryTeams for a current member's live Equipo instance,
+ including pending/disabled and non-member exclusion. Keep unavailable
+ directory reads as errors, never empty team counts.
+- Paul still performs Alta adoption and Home confirmations to create the
+ membership and live team_instances records. This branch does not provision
+ or assert their existence, or create an unlinked person locally.
+
+## Restored verification
+
+All 28 mutations above failed their intended assertions and were restored.
+With `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`:
+
+- `go test ./internal/equipo ./internal/equipo/oficinaid ./internal/equipo/personapi ./internal/wire/wireschema -count=1`: passed.
+- `go test ./internal/plan3test -run TestPersonAPI -count=1`: passed, including both contract tests and all native route tests.
+- The app and integration size allowances are updated to the measured 21508
+ source lines and 11852 test lines, respectively, for the added wiring and
+ security/integration tests.
+- `make runner-dead-references lanes-check fmt-check budget migration-check`:
+ passed, with the Go 1.26.11 toolchain directory first on PATH.
+- `go vet ./internal/equipo ./internal/equipo/oficinaid ./internal/equipo/personapi ./internal/wire/wireschema ./internal/plan3test`: passed.
+- `make copy-release-check`: passed; no new rendered copy was introduced.
+- Reference scan after staging all new files: 2487 text files, 2846 matches,
+ zero failures.
diff --git a/docs/superpowers/specs/2026-11-20-equipo-native-oficina-id.md b/docs/superpowers/specs/2026-11-20-equipo-native-oficina-id.md
new file mode 100644
index 00000000..a8732ff6
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-20-equipo-native-oficina-id.md
@@ -0,0 +1,120 @@
+# Equipo's apps sign in with Oficina ID (spec, 2026-11-20)
+
+Status: APPROVED by Paul on 2026-11-20 with every recommendation (E1 session then
+device credential; E2 7 days, renewed silently; E3 pairing kept as a fallback;
+E4 Equipo joins Alta and the directory). Author: Claude (`claude-opus-5-5`).
+
+## Why
+
+Paul, 2026-11-20, on the pairing screen: "Ideally though we'd never have to
+type anything in ... it should just do 'Sign in' and it would know all the
+Oficina accounts I have access to." He chose to do this next, before the rest
+of slice 2 (notifications and Live Activities).
+
+Today Equipo's iPhone and Mac apps pair: you type the team's address, the app
+shows a code, you approve it in the browser, and the app gets a device
+credential (`equipo.person.v1` bearer, 30 days). Docs already signs in the
+way Paul wants, through Home's Oficina ID native slice
+(`home/docs/superpowers/specs/2026-11-14-oficina-id-native.md`, "the native
+spec") and rastrillo/native's shared kit (`RastrilloApple/OficinaID`): one
+Oficina ID on the device signs the next app straight in, with the person's
+teams from the directory.
+
+## What a person sees
+
+1. First Oficina app on the device: Equipo shows the kit's onboarding:
+ Welcome, then "Sign in with a passkey" or email and a 6-digit code.
+2. An Oficina ID already on the device (Docs signed in, say): no screen at
+ all. Equipo reads the identity, asks the directory for the person's teams
+ that have Equipo, and with one team is signed in; with several, the kit's
+ Team step; with none, the kit's zero-teams help.
+3. "Other ways to sign in…" keeps today's pairing (team address, code,
+ browser approval) for a team outside the directory or a self-hosted one.
+4. The account menu and Sign out are the kit's; signing out also revokes this
+ device's Equipo credential (as today).
+
+## How (the parts, in order)
+
+**1. Equipo server: the native exchange.** `POST <origin>/native/oficina-id
+{assertion, verifier, choice?}`, the contract the kit already calls
+(`OficinaIDService.exchange`) and the native spec defines in §7 and §8:
+verify the assertion (pinned Home keys, exact issuer and audience, the native
+nonce recomputed from the verifier); read the person's link; for a roster
+member with no link answer `409 {"state":"choose"}` and allocate only on
+`choice:"new"`; a non-member gets `403 {"state":"unknown"}` byte for byte the
+same as any unknown; roster unavailable is `503`; reserve the `jti` in its own
+short transaction; no hook and no session mint with the writer held; mint a
+session with method `home-assertion-native`, refused 7 days after its `At`.
+Equipo has its own Oficina ID package from slice 1
+(`internal/equipo/oficinaid`), not rastrillo's `connect`, so this is written
+there, following `connect.Bridge.NativeExchange` and its gates (native spec
+§13, "Assert and exchange") as the reference. JSON only, no cookies set,
+`Origin` refused.
+
+**2. Equipo server: a device credential from that session.**
+`POST /api/v1/auth/devices/native {public_key, label}` with the session the
+exchange minted (same-origin, JSON, the session's own person only): registers
+this device with its Curve25519 key, already approved, and answers with the
+same `DeviceCredential` pairing gives (`id`, `token`, `expires_at`). The
+engine's routes keep taking only device bearers, unchanged. The credential's
+lifetime follows the session's 7-day rule: it expires with the Oficina ID
+session it came from, and the app renews it silently (the kit's
+`renewIfNeeded` on foreground and after 24 hours, then this call again).
+Audit: device registered via Oficina ID, with no credential in it. Revoking
+the Oficina ID's sessions (unlink, Home's sign-out-all) revokes these devices.
+
+**3. Home: the directory lists Equipo.** The native spec's
+`GET /api/native/teams` lists "live instances of the five apps". Equipo
+becomes the sixth (`apps:[{app:"equipo", origin, consumer_id}]`), and Home's
+`assert` accepts each Equipo instance's origin as an audience (they are
+already consumers from slice 1 on the web; checked, not assumed).
+
+**4. Alta: Paul's teams have Equipo in the directory.** The directory's team
+`oficina` exists (Alta adoption, 2026-11-17/18, run on Paul's other Mac).
+Equipo's instance is added the same way Calendar's was (`alta-adopt activate
+--apps equipo`, then Home's confirms). This is an operator step for Paul;
+the runbook is `native-levelup/ALTA-ROLLOUT.md`.
+
+**5. Native: adopt the kit.** EquipoKit shows `OficinaOnboardingView` until
+`.signedIn`, then for the chosen team runs step 2 and keeps the device
+credential exactly as pairing does today (Keychain, `DeviceAccounts`); the
+rest of the app is unchanged. Pairing moves behind "Other ways to sign in…".
+Entitlements, as the kit requires: `keychain-access-groups` =
+`9U4A84C4WK.works.oficina.equipo` first, then `9U4A84C4WK.works.oficina.id`;
+the App Group (`9U4A84C4WK.works.oficina` on Mac, `group.works.oficina` on
+iOS); `webcredentials:id.oficina.works`. That means new provisioning profiles
+for iPhone and Mac (the Mac's Developer ID build must embed one), made through
+the App Store Connect API.
+
+## Decisions for Paul
+
+| | Decision | Recommendation |
+| --- | --- | --- |
+| E1 | How the app turns an Oficina ID into Equipo access | The kit's exchange as it is (a session), then one Equipo call that registers this device and returns the usual device credential. The kit stays shared and unchanged, and Equipo's API keeps one kind of credential. The alternative, Equipo's routes accepting the session cookie, would give Equipo a second credential type on every route. |
+| E2 | Lifetime of a device credential that came from Oficina ID | 7 days, renewed silently, matching the native spec's rule for Oficina ID sessions (yours, confirmed). Paired devices keep their 30 days. |
+| E3 | Pairing | Kept, behind "Other ways to sign in…", for teams outside the directory and self-hosted ones. |
+| E4 | Alta | Equipo joins Alta and the directory like the other apps; you run the adoption step on the Mac that holds Alta's operator state. |
+
+## Gates
+
+The native spec's §13 exchange gates, applied to Equipo's implementation;
+tests first with each guard broken on purpose; the device contract test and
+OpenAPI document cover the new route; a live run against a local Equipo with
+a fake Home (the kit's `FakeOficinaIDService` on the app side); one review
+(Fable, or Codex Astra while Fable is limited); Paul lands each branch per
+his slice 2 ruling.
+
+## Order
+
+1. Equipo server: exchange and device route (one branch).
+ Scope clarification approved 2026-11-20: this branch admits only an
+ Oficina ID already explicitly linked to an active Equipo roster member.
+ Every unlinked subject, including `choice:"new"`, receives the identical
+ `403 {"state":"unknown"}`. There is no 409 choice or allocation path here:
+ Equipo has no trusted Home roster mapping for an unlinked subject.
+ Follow-up: integrate Home's team roster for unlinked members, then build
+ the member choice and allocation path described in parts 1 and 2.
+2. Home: the directory and `assert` include Equipo (Home branch).
+3. Native: the kit, entitlements, profiles (one branch); TestFlight and Mac.
+4. Alta: Paul adopts Equipo for his teams.
+5. Then back to slice 2: the CARLOS push sender and the native push branch.
diff --git a/go.mod b/go.mod
index 4e3b2a2d..3008842c 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require github.com/coder/websocket v1.8.15
require (
amadan.net/oficina/home/connect v0.0.0-20261114000742-e9829fda431e
- amadan.net/oficina/home/handoff v0.0.0-20261114000742-e9829fda431e
+ amadan.net/oficina/home/handoff v0.0.0-20261114110939-e03a01a1881c
golang.org/x/crypto v0.53.0
)
diff --git a/go.sum b/go.sum
index 06116034..63132d3a 100644
--- a/go.sum
+++ b/go.sum
@@ -4,6 +4,8 @@ amadan.net/oficina/home/connect v0.0.0-20261114000742-e9829fda431e h1:7Yl4BgKcmo
amadan.net/oficina/home/connect v0.0.0-20261114000742-e9829fda431e/go.mod h1:7tsJ//7X4o5QkD068WoUGVDxj/e3ygZ2adF+PHhvBxE=
amadan.net/oficina/home/handoff v0.0.0-20261114000742-e9829fda431e h1:ce4x6+UxI/uKeGZrLfaPm6FyDAgqcSinl+8HBUw9dsI=
amadan.net/oficina/home/handoff v0.0.0-20261114000742-e9829fda431e/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
+amadan.net/oficina/home/handoff v0.0.0-20261114110939-e03a01a1881c h1:KxjjyIlEu3hY1G6l26IrI2PRcogOscpTeydRgNzimbA=
+amadan.net/oficina/home/handoff v0.0.0-20261114110939-e03a01a1881c/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
amadan.net/rastrillo/rastrillo v0.30.3 h1:PEZ/Og0ZF9OjIaqwYCxrRLXis1K3MRTA2lDaseeIP1s=
amadan.net/rastrillo/rastrillo v0.30.3/go.mod h1:K7Clrt14+25ruVupgRjlIhH2GQp/OdL9VoD8xPmkt0w=
amadan.net/rastrillo/rastrillo/money v0.1.0 h1:MxU4oqNrW8abxRTkgZBv24OYNpFnvonajNqeLIzmmaM=
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index 69ada63f..e25f6f45 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -5,9 +5,11 @@ import (
"amadan.net/oficina/equipo/internal/equipo/notifications"
"amadan.net/oficina/equipo/internal/equipo/oficina"
"amadan.net/oficina/equipo/internal/equipo/oficinaid"
+ "amadan.net/rastrillo/rastrillo/sessions"
"context"
"encoding/json"
"errors"
+ "gorm.io/gorm"
"log/slog"
"net/http"
"net/url"
@@ -233,6 +235,9 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
if e != nil {
return nil, e
}
+ store.personNativeSession = func(tx *gorm.DB, hash string) (sessions.Session, error) {
+ return storeID.NativeSessionOn(tx.Statement.Context, tx.Statement.ConnPool, hash, store.runnerClock.Now())
+ }
a.home = &oficinaid.HTTP{Store: storeID, Auth: authentication, Render: a.renderID}
}
// The live hub served the old always-on pages; the conversation now
@@ -246,7 +251,15 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
if !ok {
return personapi.PersonPrincipal{}, personapi.ErrUnauthenticated
}
- return personapi.PersonPrincipal{Address: id.Address, SessionEpoch: id.At.Unix()}, nil
+ p := personapi.PersonPrincipal{Address: id.Address, SessionEpoch: id.At.Unix()}
+ if string(id.Method) == oficinaid.NativeMethod {
+ c, err := r.Cookie(authentication.SessionCookie())
+ if err != nil {
+ return p, personapi.ErrUnauthenticated
+ }
+ p.SessionHash = sessions.HashToken(c.Value)
+ }
+ return p, nil
}
person := store.personAPIRouter()
a.Use(personapi.Dispatcher(cfg.Origin, runner, person, func(w http.ResponseWriter) { runnerFailure(w, ErrForbidden) }, a.home != nil))
diff --git a/internal/equipo/migrations/0098_native_device.sql b/internal/equipo/migrations/0098_native_device.sql
new file mode 100644
index 00000000..03749df9
--- /dev/null
+++ b/internal/equipo/migrations/0098_native_device.sql
@@ -0,0 +1,2 @@
+ALTER TABLE person_devices ADD COLUMN native_session_hash text;
+CREATE INDEX person_device_native_session ON person_devices(native_session_hash);
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index ac24d893..14961402 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -750,3 +750,6 @@ CREATE TABLE push_tasks (person text, task_id text, title text, tone text, stage
CREATE TABLE push_once (person text, key text, created_at datetime, PRIMARY KEY (person, key));
-- Keep CARLOS retry deadlines across drains, newly queued pushes and restarts.
CREATE TABLE push_holds (id text PRIMARY KEY, until datetime);
+
+ALTER TABLE person_devices ADD COLUMN native_session_hash text;
+CREATE INDEX person_device_native_session ON person_devices(native_session_hash);
diff --git a/internal/equipo/oficinaid/http.go b/internal/equipo/oficinaid/http.go
index a09d029d..4ea4d256 100644
--- a/internal/equipo/oficinaid/http.go
+++ b/internal/equipo/oficinaid/http.go
@@ -105,6 +105,7 @@ func (h *HTTP) guard(next http.HandlerFunc) http.HandlerFunc {
}
}
func (h *HTTP) Routes(r chi.Router) {
+ r.Post(NativePath, h.NativeExchange)
r.Get("/auth/home", h.guard(h.Start))
r.Handle("/auth/assertion", h.guard(h.Callback))
r.Get("/auth/finish", h.guard(h.Finish))
@@ -297,7 +298,7 @@ func (h *HTTP) Session(r *http.Request) (auth.Identity, bool) {
if !ok {
return auth.Identity{}, false
}
- if string(raw.Method) != Method {
+ if !IsHomeDerived(string(raw.Method)) {
return raw, true
}
sess, e := h.Store.Session(r.Context(), h.token(r), time.Now())
@@ -313,7 +314,7 @@ func (h *HTTP) Authenticate(next http.Handler) http.Handler {
h.fail(w, r, ErrRefused)
return
}
- if string(raw.Method) != Method {
+ if !IsHomeDerived(string(raw.Method)) {
next.ServeHTTP(w, r)
return
}
diff --git a/internal/equipo/oficinaid/link.go b/internal/equipo/oficinaid/link.go
index be2b8179..9778f808 100644
--- a/internal/equipo/oficinaid/link.go
+++ b/internal/equipo/oficinaid/link.go
@@ -167,7 +167,7 @@ func (s *Store) Unlink(ctx context.Context, proof, token string, now time.Time)
if e = tx.QueryRowContext(ctx, "SELECT 1 FROM equipo_id_reauth WHERE id_hash=? AND account_id=? AND session_hash=? AND purpose='unlink' AND ready=1 AND expires>?", sessions.HashToken(proof), local.PersonID, sessions.HashToken(token), high).Scan(&one); e != nil {
return ErrRefused
}
- if _, e = tx.ExecContext(ctx, "DELETE FROM sessions WHERE method=? AND subject IN (SELECT subject FROM home_identity_links WHERE issuer=? AND person_id=?)", Method, s.Config.Issuer, local.PersonID); e != nil {
+ if _, e = tx.ExecContext(ctx, "DELETE FROM sessions WHERE method IN (?,?) AND subject IN (SELECT subject FROM home_identity_links WHERE issuer=? AND person_id=?)", Method, NativeMethod, s.Config.Issuer, local.PersonID); e != nil {
return e
}
if _, e = tx.ExecContext(ctx, "DELETE FROM home_identity_links WHERE issuer=? AND person_id=?", s.Config.Issuer, local.PersonID); e != nil {
diff --git a/internal/equipo/oficinaid/migrations/0002_native_lifecycle.sql b/internal/equipo/oficinaid/migrations/0002_native_lifecycle.sql
new file mode 100644
index 00000000..967083c0
--- /dev/null
+++ b/internal/equipo/oficinaid/migrations/0002_native_lifecycle.sql
@@ -0,0 +1,10 @@
+-- Framework session hooks belong only in the boot schema.
+CREATE TRIGGER equipo_native_session_delete AFTER DELETE ON sessions BEGIN
+ UPDATE person_devices SET revoked_at=CURRENT_TIMESTAMP, revision=revision+1, result_cipher='', begin_cipher='' WHERE native_session_hash=OLD.token_hash AND revoked_at IS NULL;
+ DELETE FROM push_registrations WHERE credential IN (SELECT id FROM person_devices WHERE native_session_hash=OLD.token_hash);
+ DELETE FROM push_activities WHERE credential IN (SELECT id FROM person_devices WHERE native_session_hash=OLD.token_hash);
+ UPDATE push_outbox SET state='dropped',reason='forgotten',lease_until=NULL WHERE state='pending' AND credential IN (SELECT id FROM person_devices WHERE native_session_hash=OLD.token_hash);
+END;
+CREATE TRIGGER equipo_native_link_delete BEFORE DELETE ON home_identity_links BEGIN
+ DELETE FROM sessions WHERE method='home-assertion-native' AND subject=OLD.subject;
+END;
diff --git a/internal/equipo/oficinaid/native.go b/internal/equipo/oficinaid/native.go
new file mode 100644
index 00000000..450696d8
--- /dev/null
+++ b/internal/equipo/oficinaid/native.go
@@ -0,0 +1,144 @@
+package oficinaid
+
+import (
+ "context"
+ "crypto/subtle"
+ "database/sql"
+ "errors"
+ "io"
+ "mime"
+ "net/http"
+ "net/url"
+ "time"
+
+ "amadan.net/oficina/home/connect/linkstore"
+ "amadan.net/oficina/home/handoff"
+ "amadan.net/rastrillo/rastrillo/assertion"
+ "amadan.net/rastrillo/rastrillo/sessions"
+ json "github.com/go-json-experiment/json"
+)
+
+const NativeMethod = "home-assertion-native"
+const NativeLifetime = 7 * 24 * time.Hour
+const NativePath = "/native/oficina-id"
+
+func IsHomeDerived(method string) bool { return method == Method || method == NativeMethod }
+
+type NativeRequest struct {
+ Assertion string `json:"assertion"`
+ Verifier string `json:"verifier"`
+ Choice string `json:"choice,omitempty"`
+}
+type NativeState struct {
+ State string `json:"state"`
+}
+type NativeSession struct {
+ Name string `json:"name"`
+ Value string `json:"value"`
+ ExpiresAt int64 `json:"expires_at"`
+}
+
+func nativeAnswer(w http.ResponseWriter, status int, state string) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(status)
+ _, _ = io.WriteString(w, `{"state":"`+state+`"}`)
+}
+func nativeFailure(w http.ResponseWriter, err error) {
+ if errors.Is(err, linkstore.ErrRefused) || errors.Is(err, ErrUnlinked) {
+ nativeAnswer(w, 403, "unknown")
+ } else {
+ nativeAnswer(w, 503, "unavailable")
+ }
+}
+
+// NativeExchange accepts only existing explicit links. Equipo has no trusted
+// Home roster mapping for an unlinked subject, so choice never allocates.
+func (h *HTTP) NativeExchange(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ origin, _ := url.Parse(h.Store.Origin)
+ media, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
+ if r.Host != origin.Host || r.URL.RawQuery != "" || len(r.Header.Values("Origin")) != 0 || len(r.Header.Values("Sec-Fetch-Site")) != 0 || err != nil || media != "application/json" {
+ nativeAnswer(w, 400, "invalid")
+ return
+ }
+ body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 12*1024))
+ var in NativeRequest
+ if err != nil || json.Unmarshal(body, &in, json.RejectUnknownMembers(true)) != nil || in.Assertion == "" || len(in.Assertion) > 8192 || (in.Choice != "" && in.Choice != "new") {
+ nativeAnswer(w, 400, "invalid")
+ return
+ }
+ challenge, ok := handoff.NativeChallenge(in.Verifier)
+ if !ok {
+ nativeAnswer(w, 400, "invalid")
+ return
+ }
+ now := time.Now().UTC().Truncate(time.Second)
+ claims, err := h.Store.Exchange.Verify(in.Assertion, now)
+ nonce, _ := handoff.NativeNonce(challenge)
+ if err != nil || subtle.ConstantTimeCompare([]byte(nonce), []byte(claims.Nonce)) != 1 {
+ nativeAnswer(w, 401, "failed")
+ return
+ }
+ // Resolve before reserving: unknown subjects never spend replay capacity.
+ if _, _, err = h.Store.Links.Resolve(r.Context(), claims.Issuer, claims.Subject); err != nil {
+ nativeFailure(w, err)
+ return
+ }
+ // Reserve owns and commits its short transaction before mintNative is called.
+ if _, err = h.Store.Exchange.Reserve(r.Context(), in.Assertion, now); err != nil {
+ if errors.Is(err, handoff.ErrRefused) {
+ nativeAnswer(w, 401, "failed")
+ } else {
+ nativeAnswer(w, 503, "unavailable")
+ }
+ return
+ }
+ token, err := h.Store.mintNative(r.Context(), claims, now)
+ if err != nil {
+ nativeFailure(w, err)
+ return
+ }
+ out, _ := json.Marshal(NativeSession{Name: h.Auth.SessionCookie(), Value: token, ExpiresAt: now.Add(NativeLifetime).Unix()})
+ w.Header().Set("Content-Type", "application/json")
+ _, _ = w.Write(out)
+}
+
+// mintNative is invoked with no writer held. Its own transaction rechecks the
+// explicit link and roster and writes the session and audit through that handle.
+// It calls no external hooks or framework session writer while holding it.
+func (s *Store) mintNative(ctx context.Context, c assertion.Claims, now time.Time) (string, error) {
+ tx, err := s.begin(ctx, now)
+ if err != nil {
+ return "", err
+ }
+ defer tx.Rollback()
+ id, address, err := s.Links.ResolveOn(ctx, tx, c.Issuer, c.Subject)
+ if err != nil {
+ return "", err
+ }
+ var epoch int64
+ if err = tx.QueryRowContext(ctx, "SELECT session_epoch FROM members WHERE address=? AND active=1", address).Scan(&epoch); err != nil {
+ if errors.Is(err, sql.ErrNoRows) {
+ return "", ErrUnlinked
+ }
+ return "", err
+ }
+ if now.Unix() < epoch {
+ return "", ErrUnlinked
+ }
+ token, hash, err := sessions.NewToken()
+ if err != nil {
+ return "", err
+ }
+ _, err = tx.ExecContext(ctx, "INSERT INTO sessions(token_hash,subject,method,auth_time,created_at,expires_at) VALUES(?,?,?,?,?,?)", hash, c.Subject, NativeMethod, time.Unix(c.AuthTime, 0).UTC().Format(time.RFC3339), now.Format(time.RFC3339), now.Add(NativeLifetime).Format(time.RFC3339))
+ if err != nil {
+ return "", err
+ }
+ if err = s.audit(ctx, tx, id, "oficina_id.signin", now); err != nil {
+ return "", err
+ }
+ if err = tx.Commit(); err != nil {
+ return "", err
+ }
+ return token, nil
+}
diff --git a/internal/equipo/oficinaid/native_test.go b/internal/equipo/oficinaid/native_test.go
new file mode 100644
index 00000000..4ddfff9b
--- /dev/null
+++ b/internal/equipo/oficinaid/native_test.go
@@ -0,0 +1,348 @@
+package oficinaid
+
+import (
+ "amadan.net/rastrillo/rastrillo/sessions"
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/base64"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/assertion"
+ "amadan.net/rastrillo/rastrillo/auth"
+ "amadan.net/rastrillo/rastrillo/crypto"
+ "github.com/go-chi/chi/v5"
+)
+
+func nativeAssertion(t *testing.T, s *Store, k *crypto.Keypair, change func(*assertion.Claims)) (string, string) {
+ t.Helper()
+ verifier := base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{9}, 32))
+ challenge := sha256.Sum256([]byte(verifier))
+ nonce := sha256.Sum256(append([]byte("oficina-id/native/v1\x00"), challenge[:]...))
+ now := time.Now().Unix()
+ id, _ := assertion.RandomID()
+ c := assertion.Claims{Version: 1, KeyID: "k", Issuer: s.Config.Issuer, Audience: s.Origin, Subject: "pr_aaaaaaaaaaaaaaaaaaaaaaaaaa", ID: id, Nonce: base64.RawURLEncoding.EncodeToString(nonce[:16]), IssuedAt: now, ExpiresAt: now + 120, AuthTime: now}
+ if change != nil {
+ change(&c)
+ }
+ signed, err := assertion.Sign(k, c)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return signed, verifier
+}
+func nativeRouter(t *testing.T, s *Store) http.Handler {
+ t.Helper()
+ a, err := auth.New(auth.Config{DB: s.DB, Origin: s.Origin, InstanceKey: "test-identity-cookie-key", ProofOff: true})
+ if err != nil {
+ t.Fatal(err)
+ }
+ h := &HTTP{Store: s, Auth: a}
+ r := chi.NewRouter()
+ h.Routes(r)
+ return r
+}
+func nativePost(h http.Handler, body string, headers map[string]string) *httptest.ResponseRecorder {
+ r := httptest.NewRequest("POST", "https://equipo.example/native/oficina-id", bytes.NewBufferString(body))
+ ctx, cancel := context.WithTimeout(r.Context(), 2*time.Second)
+ defer cancel()
+ r = r.WithContext(ctx)
+ r.Header.Set("Content-Type", "application/json")
+ for k, v := range headers {
+ r.Header.Set(k, v)
+ }
+ w := httptest.NewRecorder()
+ h.ServeHTTP(w, r)
+ return w
+}
+func nativeBody(a, v string) string {
+ b, _ := json.Marshal(map[string]string{"assertion": a, "verifier": v})
+ return string(b)
+}
+func TestNativeExchangeGates(t *testing.T) {
+ for _, gate := range []string{"valid", "verifier", "web-nonce", "audience", "issuer", "key", "expired", "replay", "origin", "empty-origin", "fetch", "json", "unknown-field", "duplicate-field", "unknown", "removed", "epoch", "unavailable"} {
+ t.Run(gate, func(t *testing.T) {
+ s, k := fixture(t)
+ now := time.Now().Truncate(time.Second)
+ if gate != "unknown" {
+ establish(t, s, k, now)
+ }
+ if gate == "key" {
+ k, _ = crypto.Generate()
+ }
+ signed, v := nativeAssertion(t, s, k, func(c *assertion.Claims) {
+ switch gate {
+ case "web-nonce":
+ c.Nonce, _ = assertion.RandomID()
+ case "audience":
+ c.Audience = "https://other.example"
+ case "issuer":
+ c.Issuer = "https://other-id.example"
+ case "expired":
+ c.IssuedAt -= 200
+ c.ExpiresAt -= 200
+ c.AuthTime -= 200
+ }
+ })
+ if gate == "verifier" {
+ v = base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{8}, 32))
+ }
+ if gate == "epoch" {
+ if _, err := s.DB.Exec("UPDATE members SET session_epoch=?", time.Now().Add(time.Hour).Unix()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if gate == "removed" {
+ _, err := s.DB.Exec("UPDATE members SET active=0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ if gate == "unavailable" {
+ _, err := s.DB.Exec("DROP TABLE members")
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ body := nativeBody(signed, v)
+ headers := map[string]string{}
+ switch gate {
+ case "origin":
+ headers["Origin"] = s.Origin
+ case "empty-origin":
+ headers["Origin"] = ""
+ case "fetch":
+ headers["Sec-Fetch-Site"] = "none"
+ case "json":
+ headers["Content-Type"] = "text/plain"
+ case "unknown-field":
+ body = body[:len(body)-1] + `,"person":"other"}`
+ case "duplicate-field":
+ body = body[:len(body)-1] + `,"verifier":"` + v + `"}`
+ }
+ h := nativeRouter(t, s)
+ w := nativePost(h, body, headers)
+ if gate == "replay" {
+ if w.Code != 200 {
+ t.Fatalf("first status: %d", w.Code)
+ }
+ w = nativePost(h, body, headers)
+ }
+ want := 401
+ switch gate {
+ case "valid":
+ want = 200
+ case "origin", "empty-origin", "fetch", "json", "unknown-field", "duplicate-field":
+ want = 400
+ case "unknown", "removed", "epoch":
+ want = 403
+ case "unavailable":
+ want = 503
+ }
+ if w.Code != want {
+ t.Fatalf("status %d want %d", w.Code, want)
+ }
+ if w.Header().Get("Set-Cookie") != "" || w.Header().Get("Cache-Control") != "no-store" {
+ t.Fatal("response headers", w.Header())
+ }
+ if want == 403 && w.Body.String() != `{"state":"unknown"}` {
+ t.Fatal("unknown response", w.Body.String())
+ }
+ })
+ }
+}
+
+func TestNativeUnknownIsIdentical(t *testing.T) {
+ var reference *httptest.ResponseRecorder
+ for _, local := range []bool{false, true} {
+ for _, choice := range []bool{false, true} {
+ s, k := fixture(t)
+ if local {
+ seedLocal(t, s, "guest@example.invalid", time.Now())
+ }
+ signed, v := nativeAssertion(t, s, k, nil)
+ body := nativeBody(signed, v)
+ if choice {
+ body = body[:len(body)-1] + `,"choice":"new"}`
+ }
+ w := nativePost(nativeRouter(t, s), body, nil)
+ if w.Code != 403 || w.Body.String() != `{"state":"unknown"}` {
+ t.Fatalf("unknown status: %d", w.Code)
+ }
+ if reference != nil && !reflect.DeepEqual(w.Header(), reference.Header()) {
+ t.Fatal("unknown headers differ")
+ }
+ reference = w
+ for _, table := range []string{"equipo_id_accounts", "oficina_handoff_replay", "home_identity_links"} {
+ var n int
+ if err := s.DB.QueryRow("SELECT count(*) FROM " + table).Scan(&n); err != nil || n != 0 {
+ t.Fatal("unknown allocated", table, n, err)
+ }
+ }
+ }
+ }
+}
+func TestNativeConcurrentExchange(t *testing.T) {
+ s, k := fixture(t)
+ establish(t, s, k, time.Now().Truncate(time.Second))
+ signed, v := nativeAssertion(t, s, k, nil)
+ h := nativeRouter(t, s)
+ results := make(chan int, 8)
+ for range 8 {
+ go func() { results <- nativePost(h, nativeBody(signed, v), nil).Code }()
+ }
+ successes := 0
+ for range 8 {
+ select {
+ case status := <-results:
+ if status == 200 {
+ successes++
+ } else if status != 401 {
+ t.Fatal("concurrent status", status)
+ }
+ case <-time.After(3 * time.Second):
+ t.Fatal("writer held across reserve and mint")
+ }
+ }
+ if successes != 1 {
+ t.Fatal("concurrent mints", successes)
+ }
+ // A new Store over the same durable replay table also refuses the assertion.
+ reopened, err := New(s.DB, s.Origin, s.Config)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if w := nativePost(nativeRouter(t, reopened), nativeBody(signed, v), nil); w.Code != 401 {
+ t.Fatal("replay survived restart", w.Code)
+ }
+}
+func TestNativeVerifierDoesNotWaitOnWriter(t *testing.T) {
+ s, k := fixture(t)
+ signed, v := nativeAssertion(t, s, k, nil)
+ h := nativeRouter(t, s)
+ tx, err := s.DB.Begin()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer tx.Rollback()
+ if _, err = tx.Exec("UPDATE oficina_handoff_clock SET observed=observed WHERE id=1"); err != nil {
+ t.Fatal(err)
+ }
+ v = base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{1}, 32))
+ done := make(chan *httptest.ResponseRecorder, 1)
+ go func() { done <- nativePost(h, nativeBody(signed, v), nil) }()
+ select {
+ case w := <-done:
+ if w.Code != 401 {
+ t.Fatal("invalid verifier", w.Code)
+ }
+ case <-time.After(time.Second):
+ t.Fatal("verification waited on held single-connection writer")
+ }
+}
+func TestNativeSessionAbsoluteLifetime(t *testing.T) {
+ s, k := fixture(t)
+ now := time.Now().Truncate(time.Second)
+ establish(t, s, k, now)
+ signed, v := nativeAssertion(t, s, k, nil)
+ w := nativePost(nativeRouter(t, s), nativeBody(signed, v), nil)
+ if w.Code != 200 {
+ t.Fatal("status", w.Code)
+ }
+ var minted NativeSession
+ if err := json.Unmarshal(w.Body.Bytes(), &minted); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := s.DB.Exec("UPDATE sessions SET expires_at=? WHERE token_hash=?", now.Add(30*24*time.Hour).Format(time.RFC3339), sessions.HashToken(minted.Value)); err != nil {
+ t.Fatal(err)
+ }
+ before, err := s.Session(context.Background(), minted.Value, now.Add(NativeLifetime-time.Second))
+ if err != nil || before.Subject != "local-canary@example.invalid" || before.Method != NativeMethod {
+ t.Fatal("native resolution", before, err)
+ }
+ if _, err = s.Session(context.Background(), minted.Value, now.Add(NativeLifetime)); err == nil {
+ t.Fatal("absolute native lifetime slid")
+ }
+}
+
+func TestNativeConcurrentUnlink(t *testing.T) {
+ s, k := fixture(t)
+ now := time.Now().Truncate(time.Second)
+ local, _ := establish(t, s, k, now)
+ proof, err := s.BeginReauth(context.Background(), local, "unlink", now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fresh := seedLocal(t, s, "local-canary@example.invalid", now)
+ if _, _, err = s.CompleteReauth(context.Background(), proof, fresh, now); err != nil {
+ t.Fatal(err)
+ }
+ signed, v := nativeAssertion(t, s, k, nil)
+ h := nativeRouter(t, s)
+ done := make(chan *httptest.ResponseRecorder, 1)
+ go func() { done <- nativePost(h, nativeBody(signed, v), nil) }()
+ if err = s.Unlink(context.Background(), proof, fresh, now); err != nil {
+ t.Fatal(err)
+ }
+ w := <-done
+ if w.Code != 200 && w.Code != 403 {
+ t.Fatal("concurrent unlink", w.Code, w.Body)
+ }
+ if w.Code == 200 {
+ var out NativeSession
+ if err = json.Unmarshal(w.Body.Bytes(), &out); err != nil {
+ t.Fatal(err)
+ }
+ if _, err = s.Session(context.Background(), out.Value, now); err == nil {
+ t.Fatal("native session survived unlink")
+ }
+ }
+ var n int
+ if err = s.DB.QueryRow("SELECT count(*) FROM sessions WHERE method=?", NativeMethod).Scan(&n); err != nil || n != 0 {
+ t.Fatal("native sessions retained", n, err)
+ }
+ establish(t, s, k, now)
+ if w.Code == 200 && nativePost(h, nativeBody(signed, v), nil).Code != 401 {
+ t.Fatal("relink revived used assertion")
+ }
+}
+
+func TestNativeSessionOnRejectsLocal(t *testing.T) {
+ s, _ := fixture(t)
+ now := time.Now()
+ token := seedLocal(t, s, "local@example.invalid", now)
+ if _, err := s.NativeSessionOn(context.Background(), s.DB, sessions.HashToken(token), now); err == nil {
+ t.Fatal("local session authorized native device")
+ }
+}
+
+func TestNativeUnlinkDeletesSession(t *testing.T) {
+ s, k := fixture(t)
+ now := time.Now().Truncate(time.Second)
+ local, _ := establish(t, s, k, now)
+ signed, v := nativeAssertion(t, s, k, nil)
+ w := nativePost(nativeRouter(t, s), nativeBody(signed, v), nil)
+ if w.Code != 200 {
+ t.Fatal("mint status", w.Code)
+ }
+ proof, err := s.BeginReauth(context.Background(), local, "unlink", now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fresh := seedLocal(t, s, "local-canary@example.invalid", now)
+ if _, _, err = s.CompleteReauth(context.Background(), proof, fresh, now); err != nil {
+ t.Fatal(err)
+ }
+ if err = s.Unlink(context.Background(), proof, fresh, now); err != nil {
+ t.Fatal(err)
+ }
+ var n int
+ if err = s.DB.QueryRow("SELECT count(*) FROM sessions WHERE method=?", NativeMethod).Scan(&n); err != nil || n != 0 {
+ t.Fatal("native sessions retained", n, err)
+ }
+}
diff --git a/internal/equipo/oficinaid/signout.go b/internal/equipo/oficinaid/signout.go
index 41e895d1..0b2020d3 100644
--- a/internal/equipo/oficinaid/signout.go
+++ b/internal/equipo/oficinaid/signout.go
@@ -31,7 +31,7 @@ func (h *HTTP) signout(w http.ResponseWriter, r *http.Request) {
}
set(w, h.Auth.SessionCookie(), "", -1)
set(w, logoutCookie, "", -1)
- if method == Method {
+ if IsHomeDerived(method) {
sealed, e := h.Store.seal.Seal("signed-out", []byte(strconv.FormatInt(time.Now().Unix()+300, 10)))
if e == nil {
set(w, logoutCookie, base64.RawURLEncoding.EncodeToString(sealed), 300)
diff --git a/internal/equipo/oficinaid/store.go b/internal/equipo/oficinaid/store.go
index ab133daa..5373058b 100644
--- a/internal/equipo/oficinaid/store.go
+++ b/internal/equipo/oficinaid/store.go
@@ -146,12 +146,15 @@ func (s *Store) clock(ctx context.Context, tx *sql.Tx, now time.Time) (int64, er
}
func (s *Store) session(ctx context.Context, q linkstore.Queryer, token string, now time.Time) (sessions.Session, error) {
- var out sessions.Session
- var at, auth, expires string
if token == "" {
- return out, ErrRefused
+ return sessions.Session{}, ErrRefused
}
- e := q.QueryRowContext(ctx, "SELECT subject,method,auth_time,created_at,expires_at FROM sessions WHERE token_hash=?", sessions.HashToken(token)).Scan(&out.Subject, &out.Method, &auth, &at, &expires)
+ return s.sessionHash(ctx, q, sessions.HashToken(token), now)
+}
+func (s *Store) sessionHash(ctx context.Context, q linkstore.Queryer, hash string, now time.Time) (sessions.Session, error) {
+ var out sessions.Session
+ var at, auth, expires string
+ e := q.QueryRowContext(ctx, "SELECT subject,method,auth_time,created_at,expires_at FROM sessions WHERE token_hash=?", hash).Scan(&out.Subject, &out.Method, &auth, &at, &expires)
if e != nil {
return out, ErrRefused
}
@@ -170,7 +173,10 @@ func (s *Store) session(ctx context.Context, q linkstore.Queryer, token string,
}
}
address := out.Subject
- if out.Method == Method {
+ if out.Method == NativeMethod && !now.Before(out.At.Add(NativeLifetime)) {
+ return out, ErrRefused
+ }
+ if IsHomeDerived(out.Method) {
_, address, e = s.Links.ResolveOn(ctx, q, s.Config.Issuer, out.Subject)
if e != nil {
return out, ErrRefused
@@ -260,3 +266,12 @@ func (s *Store) audit(ctx context.Context, tx *sql.Tx, id int64, kind string, no
_, e := tx.ExecContext(ctx, "INSERT INTO audit_events(actor,kind,record_id,at) VALUES(?,?,?,?)", "local-account:"+strconv.FormatInt(id, 10), kind, strconv.FormatInt(id, 10), now.UTC())
return e
}
+
+// NativeSessionOn revalidates the source session using the caller's transaction.
+func (s *Store) NativeSessionOn(ctx context.Context, q linkstore.Queryer, hash string, now time.Time) (sessions.Session, error) {
+ sess, err := s.sessionHash(ctx, q, hash, now)
+ if err != nil || sess.Method != NativeMethod {
+ return sessions.Session{}, ErrRefused
+ }
+ return sess, nil
+}
diff --git a/internal/equipo/person_devices.go b/internal/equipo/person_devices.go
index 4809d95c..599aab37 100644
--- a/internal/equipo/person_devices.go
+++ b/internal/equipo/person_devices.go
@@ -13,7 +13,7 @@ type PersonDeviceProof = personapi.PersonDeviceProof
type PersonCredential = personapi.PersonCredential
func (s *Store) personDevices() *personapi.DeviceStore {
- return &personapi.DeviceStore{Write: s.write, Read: s.invitationRead, Member: memberAt, Instance: runnerInstance, Audit: appendAudit, Key: s.personKey, Origin: s.personOrigin, Now: s.runnerClock.Now, Revoked: push.ForgetCredential, Invalid: ErrInvalid, Forbidden: ErrForbidden, NotFound: ErrNotFound, Conflict: ErrConflict}
+ return &personapi.DeviceStore{NativeSession: s.personNativeSession, Write: s.write, Read: s.invitationRead, Member: memberAt, Instance: runnerInstance, Audit: appendAudit, Key: s.personKey, Origin: s.personOrigin, Now: s.runnerClock.Now, Revoked: push.ForgetCredential, Invalid: ErrInvalid, Forbidden: ErrForbidden, NotFound: ErrNotFound, Conflict: ErrConflict}
}
func (s *Store) BeginPersonDevice(ctx context.Context, key, label, request string) (PersonDeviceChallenge, error) {
return s.personDevices().Begin(ctx, key, label, request)
diff --git a/internal/equipo/personapi/auth.go b/internal/equipo/personapi/auth.go
index 7c265f68..7697fc07 100644
--- a/internal/equipo/personapi/auth.go
+++ b/internal/equipo/personapi/auth.go
@@ -87,7 +87,7 @@ func Dispatcher(origin string, runner, person chi.Routes, refuseRunner func(http
return func(next http.Handler) http.Handler {
var options []csrf.Option
if len(assertionCallback) == 1 && assertionCallback[0] {
- options = append(options, csrf.Exempt("/auth/assertion"))
+ options = append(options, csrf.Exempt("/auth/assertion"), csrf.Exempt("/native/oficina-id"))
}
browser := csrf.Protect(origin, options...)(next)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -168,6 +168,18 @@ func (auth Authenticator) AuthenticateRoute(r *http.Request, route Route) (Perso
return PersonPrincipal{}, auth.Forbidden
}
return PersonPrincipal{}, nil
+ case "native_device":
+ if len(r.Header.Values("Authorization")) != 0 {
+ return PersonPrincipal{}, ErrUnauthenticated
+ }
+ p, err := auth.Authenticate(r)
+ if err != nil {
+ return p, err
+ }
+ if p.SessionHash == "" || p.CredentialID != "" {
+ return PersonPrincipal{}, ErrUnauthenticated
+ }
+ return p, nil
case "approve_device", "accept_invite", "invite":
if route.Operation == "invite" && len(r.Header.Values("Authorization")) != 0 {
return auth.Authenticate(r)
diff --git a/internal/equipo/personapi/devices.go b/internal/equipo/personapi/devices.go
index 09db92ca..fd2d7580 100644
--- a/internal/equipo/personapi/devices.go
+++ b/internal/equipo/personapi/devices.go
@@ -17,6 +17,7 @@ import (
"unicode/utf8"
"amadan.net/oficina/equipo/internal/equipo/kernel"
+ "amadan.net/rastrillo/rastrillo/sessions"
"gorm.io/gorm"
)
@@ -63,6 +64,7 @@ type Device struct {
}
type DeviceRecord struct {
ID string `gorm:"primaryKey"`
+ NativeSessionHash string `gorm:"index:person_device_native_session"`
RequestHash string `gorm:"uniqueIndex:person_device_request"`
InputHash, PublicKey, Label, SecretHash, CodeHash, Challenge string
InstanceID, Person string
@@ -88,6 +90,7 @@ type DeviceRate struct {
func (DeviceRate) TableName() string { return "person_device_rates" }
type DeviceStore struct {
+ NativeSession func(*gorm.DB, string) (sessions.Session, error)
Write func(context.Context, func(*gorm.DB) error) error
Read func(context.Context, func(*gorm.DB) error) error
Member func(*gorm.DB, string) (kernel.Member, error)
diff --git a/internal/equipo/personapi/extended_mutations.go b/internal/equipo/personapi/extended_mutations.go
index 22aa0381..16359c2a 100644
--- a/internal/equipo/personapi/extended_mutations.go
+++ b/internal/equipo/personapi/extended_mutations.go
@@ -61,6 +61,10 @@ func (s *Native) apiAccountSetup(v runnerproto.AccountSetup) AccountSetup {
}
func (s *Native) Mutate(ctx context.Context, a kernel.Actor, op, id string, input any, m kernel.Mutation) (Result, error) {
switch op {
+ case "native_device":
+ v := input.(*BeginDeviceInput)
+ out, err := s.Devices().RegisterNative(ctx, a, v.PublicKey, v.Label)
+ return Result{Value: out, Revision: out.Revision}, err
case "begin_device":
v := input.(*BeginDeviceInput)
out, err := s.BeginPersonDevice(ctx, v.PublicKey, v.Label, m.RequestID)
diff --git a/internal/equipo/personapi/extended_routes.go b/internal/equipo/personapi/extended_routes.go
index 2048a691..cfaafcdb 100644
--- a/internal/equipo/personapi/extended_routes.go
+++ b/internal/equipo/personapi/extended_routes.go
@@ -8,6 +8,7 @@ import (
func init() {
Routes = append(Routes, []Route{
+ {"POST", "/auth/devices/native", "native_device", false, func() any { return &BeginDeviceInput{} }},
{"POST", "/auth/devices", "begin_device", false, func() any { return &BeginDeviceInput{} }},
{"POST", "/auth/devices/exchange", "exchange_device", false, func() any { return &PersonDeviceProof{} }},
{"POST", "/auth/devices/{id}/approve", "approve_device", true, func() any { return &ApproveDeviceInput{} }},
diff --git a/internal/equipo/personapi/handler.go b/internal/equipo/personapi/handler.go
index 33aacd4a..c4fde992 100644
--- a/internal/equipo/personapi/handler.go
+++ b/internal/equipo/personapi/handler.go
@@ -121,6 +121,10 @@ func (h *Handler) serve(route Route) http.Handler {
return
}
m, status := Mutation(r, route.Update)
+ if route.Operation == "native_device" && len(r.Header.Values("Idempotency-Key")) == 0 {
+ m = kernel.Mutation{}
+ status = 0
+ }
if status != 0 {
code := "invalid_input"
if status == 428 {
diff --git a/internal/equipo/personapi/native_device.go b/internal/equipo/personapi/native_device.go
new file mode 100644
index 00000000..7deae3aa
--- /dev/null
+++ b/internal/equipo/personapi/native_device.go
@@ -0,0 +1,52 @@
+package personapi
+
+import (
+ "context"
+ "crypto/rand"
+ "encoding/base64"
+ "strings"
+ "unicode/utf8"
+
+ "amadan.net/oficina/equipo/internal/equipo/kernel"
+ "amadan.net/oficina/equipo/internal/equipo/oficinaid"
+ "gorm.io/gorm"
+)
+
+// RegisterNative derives the person and lifetime from a live native session in
+// the write transaction. The caller can supply only its device key and label.
+func (s *DeviceStore) RegisterNative(ctx context.Context, a kernel.Actor, key, label string) (out PersonCredential, err error) {
+ p, ok := PrincipalFrom(ctx)
+ if !ok || p.Address == "" || p.Address != a.Address || p.CredentialID != "" || p.Pending || p.SessionHash == "" || s.NativeSession == nil {
+ return out, ErrUnauthenticated
+ }
+ raw, e := base64.RawURLEncoding.Strict().DecodeString(key)
+ if s.Key == "" || e != nil || len(raw) != 32 || base64.RawURLEncoding.EncodeToString(raw) != key || len(label) < 1 || len(label) > 128 || !utf8.ValidString(label) || strings.ContainsAny(label, "\x00\r\n") {
+ return out, s.Invalid
+ }
+ err = s.Write(WithoutRequest(ctx), func(tx *gorm.DB) error {
+ now := s.Now().UTC()
+ sess, e := s.NativeSession(tx, p.SessionHash)
+ if e != nil || sess.Method != oficinaid.NativeMethod || sess.Subject != a.Address || !now.Before(sess.At.Add(oficinaid.NativeLifetime)) {
+ return ErrUnauthenticated
+ }
+ if e = s.member(tx, sess.Subject, sess.At.Unix()); e != nil {
+ return e
+ }
+ instance, e := s.Instance(tx)
+ if e != nil {
+ return e
+ }
+ id := rand.Text()
+ token := PersonAudience + "." + rand.Text()
+ out = PersonCredential{ID: id, Token: token, Audience: PersonAudience, InstanceID: instance, ExpiresAt: sess.At.Add(oficinaid.NativeLifetime), Revision: 1}
+ row := DeviceRecord{ID: id, RequestHash: s.mac("native", id), PublicKey: key, Label: label, InstanceID: instance, Person: sess.Subject, SessionEpoch: sess.At.Unix(), Revision: 1, CreatedAt: now, ExpiresAt: out.ExpiresAt, ApprovedAt: &now, ExchangedAt: &now, TokenHash: s.mac(PersonAudience, token), TokenExpiresAt: out.ExpiresAt, NativeSessionHash: p.SessionHash}
+ if e = tx.Create(&row).Error; e != nil {
+ return e
+ }
+ return s.Audit(tx, kernel.Actor{Address: sess.Subject}, "person_device.native", id)
+ })
+ if err != nil {
+ out = PersonCredential{}
+ }
+ return
+}
diff --git a/internal/equipo/personapi/native_device_test.go b/internal/equipo/personapi/native_device_test.go
new file mode 100644
index 00000000..d87aebeb
--- /dev/null
+++ b/internal/equipo/personapi/native_device_test.go
@@ -0,0 +1,42 @@
+package personapi
+
+import (
+ "context"
+ "encoding/base64"
+ "errors"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/kernel"
+ "amadan.net/rastrillo/rastrillo/sessions"
+ "gorm.io/gorm"
+)
+
+func TestNativeDeviceRejectsUnverifiedPrincipal(t *testing.T) {
+ s := &DeviceStore{Invalid: errors.New("invalid"), NativeSession: func(*gorm.DB, string) (sessions.Session, error) {
+ t.Fatal("unverified session reached lookup")
+ return sessions.Session{}, nil
+ }, Now: time.Now}
+ key := base64.RawURLEncoding.EncodeToString(make([]byte, 32))
+ for _, p := range []PersonPrincipal{{}, {Address: "person", CredentialID: "paired", SessionHash: "hash"}, {Address: "person", Pending: true, SessionHash: "hash"}, {Address: "person"}} {
+ _, err := s.RegisterNative(WithVerifiedPrincipal(context.Background(), p), kernel.Actor{Address: p.Address}, key, "phone")
+ if !errors.Is(err, ErrUnauthenticated) {
+ t.Fatalf("accepted unverified principal: %v", err)
+ }
+ }
+}
+
+func TestNativeDeviceRouteRejectsBearer(t *testing.T) {
+ a := Authenticator{Origin: "https://equipo.example", Forbidden: errors.New("forbidden"), Cookie: func(*http.Request) (PersonPrincipal, error) {
+ return PersonPrincipal{Address: "person", SessionEpoch: 1, SessionHash: "hash"}, nil
+ }, Bearer: func(context.Context, string) (PersonPrincipal, error) {
+ return PersonPrincipal{Address: "person", SessionEpoch: 1, CredentialID: "paired", SessionHash: "hash"}, nil
+ }, Member: func(*http.Request, PersonPrincipal) error { return nil }}
+ r := httptest.NewRequest("POST", "https://equipo.example/api/v1/auth/devices/native", nil)
+ r.Header.Set("Authorization", "Bearer paired")
+ if _, err := a.AuthenticateRoute(r, Route{Operation: "native_device"}); !errors.Is(err, ErrUnauthenticated) {
+ t.Fatal("device bearer registered native credential", err)
+ }
+}
diff --git a/internal/equipo/personapi/types.go b/internal/equipo/personapi/types.go
index 3b1d6598..1a776bc3 100644
--- a/internal/equipo/personapi/types.go
+++ b/internal/equipo/personapi/types.go
@@ -16,6 +16,7 @@ import (
type PersonPrincipal struct {
Pending bool
Address, CredentialID string
+ SessionHash string
SessionEpoch int64
}
type VerifyPersonBearer func(context.Context, string) (PersonPrincipal, error)
diff --git a/internal/equipo/store.go b/internal/equipo/store.go
index f5d8e6fe..2e5c0072 100644
--- a/internal/equipo/store.go
+++ b/internal/equipo/store.go
@@ -2,6 +2,7 @@ package equipo
import (
"amadan.net/oficina/equipo/internal/release"
+ "amadan.net/rastrillo/rastrillo/sessions"
"context"
"errors"
"fmt"
@@ -61,17 +62,18 @@ type Store struct {
*PlanApplication
*InvitationApplication
*library.Application
- personBearer personapi.VerifyPersonBearer
- personCookie func(*http.Request) (personapi.PersonPrincipal, error)
- invitationKey string
- personOrigin string
- personKey string
- notifier JobNotifier
- db *db.DB
- execution *Execution
- runnerClock team.Clock
- verifiedIsolation []team.IsolationTuple
- chat thinChat
+ personBearer personapi.VerifyPersonBearer
+ personNativeSession func(*gorm.DB, string) (sessions.Session, error)
+ personCookie func(*http.Request) (personapi.PersonPrincipal, error)
+ invitationKey string
+ personOrigin string
+ personKey string
+ notifier JobNotifier
+ db *db.DB
+ execution *Execution
+ runnerClock team.Clock
+ verifiedIsolation []team.IsolationTuple
+ chat thinChat
// chatExecution is EQUIPO_EXECUTION_ENABLED: without it no runner
// receives coordinator turns.
chatExecution bool
diff --git a/internal/plan3test/person_api_contract_test.go b/internal/plan3test/person_api_contract_test.go
index 20777432..8eec2403 100644
--- a/internal/plan3test/person_api_contract_test.go
+++ b/internal/plan3test/person_api_contract_test.go
@@ -27,7 +27,7 @@ func personAPIRoutes() map[string]string {
"/coordinator": "GET PATCH", "/coordinator/reset": "POST", "/coordinator/retry": "POST", "/coordinator/limits": "PATCH",
}
for path, methods := range map[string]string{
- "/auth/devices": "GET POST", "/auth/devices/exchange": "POST", "/auth/devices/{id}/approve": "POST", "/auth/devices/{id}": "DELETE",
+ "/auth/devices/native": "POST", "/auth/devices": "GET POST", "/auth/devices/exchange": "POST", "/auth/devices/{id}/approve": "POST", "/auth/devices/{id}": "DELETE",
"/roster": "GET", "/roster/{address}": "PUT", "/budgets": "GET PUT",
"/teams": "GET", "/teams/links": "POST", "/teams/links/{id}": "PATCH DELETE",
"/accounts": "GET POST", "/projects": "GET POST", "/projects/{id}": "GET PATCH", "/projects/{id}/settings": "GET PATCH", "/projects/{id}/my-settings": "PATCH",
@@ -224,7 +224,7 @@ func personAPIContractCoverage(t *testing.T) {
key = true
}
}
- if !key {
+ if !key && path != "/auth/devices/native" {
t.Fatal("missing request key contract", method, path)
}
}
diff --git a/internal/plan3test/person_api_device_contract_test.go b/internal/plan3test/person_api_device_contract_test.go
index e71b7e96..18751758 100644
--- a/internal/plan3test/person_api_device_contract_test.go
+++ b/internal/plan3test/person_api_device_contract_test.go
@@ -95,7 +95,7 @@ func TestPersonAPIDeviceContract(t *testing.T) {
for _, methods := range paths {
documented += len(methods.(map[string]any))
}
- all := map[string]bool{}
+ all := map[string]bool{"POST /native/oficina-id": true}
for key := range engine {
all[key] = true
}
@@ -107,6 +107,22 @@ func TestPersonAPIDeviceContract(t *testing.T) {
if documented != len(all) {
t.Errorf("the document has %d operations; the person API and the engine serve %d", documented, len(all))
}
+ for key, spec := range wireschema.NativeOps {
+ method, path, _ := strings.Cut(key, " ")
+ op := paths[path].(map[string]any)[strings.ToLower(method)].(map[string]any)
+ deviceOperation(t, key, op, spec)
+ want := `[{"browserSession":[]}]`
+ if path == "/native/oficina-id" {
+ want = `[]`
+ if !reflect.DeepEqual(op["servers"], []any{map[string]any{"url": "/"}}) {
+ t.Error("exchange must use instance root")
+ }
+ }
+ security, _ := json.Marshal(op["security"])
+ if string(security) != want {
+ t.Error("native authentication contract", key, string(security))
+ }
+ }
for key := range wireschema.Ops {
if !engine[key] {
t.Errorf("%s is documented but the engine does not serve it", key)
diff --git a/internal/plan3test/person_api_migration_test.go b/internal/plan3test/person_api_migration_test.go
index 94c11709..c9ca6121 100644
--- a/internal/plan3test/person_api_migration_test.go
+++ b/internal/plan3test/person_api_migration_test.go
@@ -80,7 +80,7 @@ func TestPersonAPIDeviceMigrationUpgrade(t *testing.T) {
must(t, err)
old := &migrate.Set{}
for _, m := range equipo.BootSchema.All() {
- if m.ID != "equipo/0030_person_devices" && m.ID != "equipo/0030_person_devices_usage" && m.ID != "equipo/0031_notifications" && m.ID != "equipo/0033_plan_notifications" {
+ if m.ID != "equipo/0098_native_device" && m.ID != "equipo_identity/0002_native_lifecycle" && m.ID != "equipo/0030_person_devices" && m.ID != "equipo/0030_person_devices_usage" && m.ID != "equipo/0031_notifications" && m.ID != "equipo/0033_plan_notifications" {
old.Add(m)
}
}
@@ -92,7 +92,7 @@ func TestPersonAPIDeviceMigrationUpgrade(t *testing.T) {
must(t, err)
result, err := migrate.Apply(ctx, d, equipo.BootSchema)
must(t, err)
- if len(result.Applied) != 4 || result.Applied[0] != "equipo/0030_person_devices" || result.Applied[1] != "equipo/0030_person_devices_usage" || result.Applied[2] != "equipo/0031_notifications" {
+ if len(result.Applied) != 6 || result.Applied[0] != "equipo/0030_person_devices" || result.Applied[1] != "equipo/0030_person_devices_usage" || result.Applied[2] != "equipo/0031_notifications" {
t.Fatal(result.Applied)
}
f := newFixture(t)
diff --git a/internal/plan3test/person_api_native_id_test.go b/internal/plan3test/person_api_native_id_test.go
new file mode 100644
index 00000000..2ad500eb
--- /dev/null
+++ b/internal/plan3test/person_api_native_id_test.go
@@ -0,0 +1,390 @@
+package plan3test
+
+import (
+ "amadan.net/oficina/equipo/internal/equipo/kernel"
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/base64"
+ "encoding/json"
+ "errors"
+ "gorm.io/gorm"
+ "io"
+ "log/slog"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/equipo/oficinaid"
+ "amadan.net/oficina/equipo/internal/equipo/personapi"
+ "amadan.net/oficina/home/connect"
+ "amadan.net/oficina/home/handoff"
+ "amadan.net/rastrillo/rastrillo/assertion"
+ "amadan.net/rastrillo/rastrillo/crypto"
+ "amadan.net/rastrillo/rastrillo/mail"
+ "amadan.net/rastrillo/rastrillo/sessions"
+)
+
+const nativeOrigin = "https://equipo-staging.bds.oncarlos.com"
+const nativeSubject = "pr_aaaaaaaaaaaaaaaaaaaaaaaaaa"
+
+func nativeIDFixture(t *testing.T) (*fixture, *oficinaid.Store, string, *crypto.Keypair) {
+ t.Helper()
+ f := newFixture(t)
+ key, e := crypto.Generate()
+ must(t, e)
+ cfg := &connect.DecodedCredentials{Issuer: "https://id.example", ConsumerID: "equipo", Keys: map[string][]byte{"k": key.SignPub()}, DEK: bytes.Repeat([]byte{7}, 32)}
+ s, e := oficinaid.New(f.DB.Writer(), nativeOrigin, cfg)
+ must(t, e)
+ now := time.Now().UTC().Truncate(time.Second)
+ old := f.Cookies[owner.Address].Value
+ proof, e := s.BeginReauth(ctx, old, "link", now)
+ must(t, e)
+ fresh, hash, e := sessions.NewToken()
+ must(t, e)
+ f.exec(t, "INSERT INTO sessions(token_hash,subject,method,auth_time,created_at,expires_at) VALUES(?,?,?,?,?,?)", hash, owner.Address, "magiclink", now.Format(time.RFC3339), now.Format(time.RFC3339), now.Add(time.Hour).Format(time.RFC3339))
+ init, _, e := s.CompleteReauth(ctx, proof, fresh, now)
+ must(t, e)
+ secret, nonce, e := s.Exchange.StartFresh(ctx, "/account/home/confirm", "", now)
+ must(t, e)
+ must(t, s.Bind(ctx, init, fresh, nonce, now))
+ sign := func(nonce string) string {
+ id, e := assertion.RandomID()
+ must(t, e)
+ v, e := assertion.Sign(key, assertion.Claims{Version: 1, KeyID: "k", Issuer: cfg.Issuer, Audience: nativeOrigin, Subject: nativeSubject, ID: id, Nonce: nonce, IssuedAt: now.Unix(), ExpiresAt: now.Unix() + 120, AuthTime: now.Unix()})
+ must(t, e)
+ return v
+ }
+ receipt, e := s.Exchange.ReceivePending(ctx, sign(nonce), now)
+ must(t, e)
+ confirmation, _, e := s.Finish(ctx, secret, receipt, fresh, init, now)
+ must(t, e)
+ must(t, s.Confirm(ctx, confirmation, fresh, now))
+ logger := slog.New(slog.NewTextHandler(io.Discard, nil))
+ router, e := equipo.RouterWithStore(f.DB, equipo.Config{Origin: nativeOrigin, InstanceKey: "plan3-fixture", Home: cfg, AllowLoggedMail: true, Owners: []string{owner.Address}}, mail.Logged(logger), logger, f.Store)
+ must(t, e)
+ f.Handler = equipo.Mux(router)
+ verifier := base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{4}, 32))
+ challenge := sha256.Sum256([]byte(verifier))
+ nonce, _ = handoff.NativeNonce(base64.RawURLEncoding.EncodeToString(challenge[:]))
+ body, _ := json.Marshal(map[string]string{"assertion": sign(nonce), "verifier": verifier})
+ r := httptest.NewRequest("POST", nativeOrigin+oficinaid.NativePath, bytes.NewReader(body))
+ r.Header.Set("Content-Type", "application/json")
+ w := httptest.NewRecorder()
+ f.Handler.ServeHTTP(w, r)
+ expectNativeHTTP(t, w, 200)
+ minted := apiValue[oficinaid.NativeSession](t, w)
+ f.Cookies[owner.Address] = &http.Cookie{Name: minted.Name, Value: minted.Value}
+ return f, s, fresh, key
+}
+func nativeDevicePost(f *fixture, body string, edit func(*http.Request)) *httptest.ResponseRecorder {
+ r := httptest.NewRequest("POST", nativeOrigin+"/api/v1/auth/devices/native", strings.NewReader(body))
+ r.Header.Set("Content-Type", "application/json")
+ r.Header.Set("Origin", nativeOrigin)
+ r.AddCookie(f.Cookies[owner.Address])
+ if edit != nil {
+ edit(r)
+ }
+ w := httptest.NewRecorder()
+ f.Handler.ServeHTTP(w, r)
+ return w
+}
+func nativeDeviceBody() string {
+ return `{"public_key":"` + base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{3}, 32)) + `","label":"private-device-label"}`
+}
+func TestPersonAPINativeDevice(t *testing.T) {
+ f, s, fresh, _ := nativeIDFixture(t)
+ sourceAt := time.Now().UTC().Truncate(time.Second).Add(-2 * 24 * time.Hour)
+ f.exec(t, "UPDATE sessions SET created_at=?,expires_at=? WHERE token_hash=?", sourceAt.Format(time.RFC3339), sourceAt.Add(7*24*time.Hour).Format(time.RFC3339), sessions.HashToken(f.Cookies[owner.Address].Value))
+ w := nativeDevicePost(f, nativeDeviceBody(), nil)
+ expectNativeHTTP(t, w, 200)
+ credential := apiValue[personapi.PersonCredential](t, w)
+ var person, source, created string
+ must(t, f.DB.Writer().QueryRow("SELECT person,native_session_hash FROM person_devices WHERE id=?", credential.ID).Scan(&person, &source))
+ must(t, f.DB.Writer().QueryRow("SELECT created_at FROM sessions WHERE token_hash=?", source).Scan(&created))
+ at, e := time.Parse(time.RFC3339, created)
+ must(t, e)
+ if person != owner.Address || source != sessions.HashToken(f.Cookies[owner.Address].Value) || !credential.ExpiresAt.Equal(at.Add(7*24*time.Hour)) {
+ t.Fatal("wrong owner, source, or expiry")
+ }
+ if !strings.HasPrefix(credential.Token, personapi.PersonAudience+".") || credential.Audience != personapi.PersonAudience || credential.InstanceID == "" {
+ t.Fatal("credential contract")
+ }
+ var audit string
+ must(t, f.DB.Writer().QueryRow("SELECT group_concat(actor || kind || record_id) FROM audit_events").Scan(&audit))
+ for _, secret := range []string{credential.Token, source, f.Cookies[owner.Address].Value, "private-device-label"} {
+ if strings.Contains(audit, secret) {
+ t.Fatal("credential or label in audit")
+ }
+ }
+ if !strings.Contains(audit, "person_device.native") {
+ t.Fatal("missing native audit")
+ }
+ // Unlink uses the existing fresh local ceremony and cascades session deletion.
+ proof, e := s.BeginReauth(ctx, fresh, "unlink", time.Now())
+ must(t, e)
+ next, hash, e := sessions.NewToken()
+ must(t, e)
+ now := time.Now().UTC()
+ f.exec(t, "INSERT INTO sessions(token_hash,subject,method,auth_time,created_at,expires_at) VALUES(?,?,?,?,?,?)", hash, owner.Address, "magiclink", now.Format(time.RFC3339), now.Format(time.RFC3339), now.Add(time.Hour).Format(time.RFC3339))
+ _, _, e = s.CompleteReauth(ctx, proof, next, now)
+ must(t, e)
+ must(t, s.Unlink(ctx, proof, next, now))
+ if f.count(t, "SELECT count(*) FROM person_devices WHERE id=? AND revoked_at IS NOT NULL", credential.ID) != 1 {
+ t.Fatal("device survived unlink")
+ }
+ if f.count(t, "SELECT count(*) FROM sessions WHERE token_hash=?", source) != 0 {
+ t.Fatal("session survived unlink")
+ }
+}
+func TestPersonAPINativeDeviceGates(t *testing.T) {
+ f, _, _, _ := nativeIDFixture(t)
+ for _, gate := range []string{"own-person", "local-session", "web-session", "bearer", "no-origin", "cross-origin", "json", "key", "duplicate-cookie", "unknown-field", "removed", "expired", "revoked"} {
+ t.Run(gate, func(t *testing.T) {
+ token := f.Cookies[owner.Address].Value
+ hash := sessions.HashToken(token)
+ body := nativeDeviceBody()
+ want := 401
+ switch gate {
+ case "own-person", "unknown-field":
+ body = body[:len(body)-1] + `,"person":"peer@example.com"}`
+ want = 422
+ case "json", "key":
+ want = 422
+ case "no-origin", "cross-origin", "local-session":
+ want = 403
+ }
+ if gate == "key" {
+ body = `{"public_key":"` + base64.RawURLEncoding.EncodeToString(make([]byte, 31)) + `","label":"phone"}`
+ }
+ if gate == "local-session" || gate == "web-session" {
+ method := "magiclink"
+ if gate == "web-session" {
+ method = oficinaid.Method
+ }
+ f.exec(t, "UPDATE sessions SET method=? WHERE token_hash=?", method, hash)
+ defer f.exec(t, "UPDATE sessions SET method=? WHERE token_hash=?", oficinaid.NativeMethod, hash)
+ }
+ if gate == "removed" {
+ f.exec(t, "UPDATE members SET active=0 WHERE address=?", owner.Address)
+ defer f.exec(t, "UPDATE members SET active=1 WHERE address=?", owner.Address)
+ }
+ if gate == "expired" {
+ f.exec(t, "UPDATE sessions SET created_at=? WHERE token_hash=?", time.Now().Add(-8*24*time.Hour).Format(time.RFC3339), hash)
+ defer f.exec(t, "UPDATE sessions SET created_at=? WHERE token_hash=?", time.Now().Format(time.RFC3339), hash)
+ }
+ if gate == "revoked" {
+ f.exec(t, "DELETE FROM sessions WHERE token_hash=?", hash)
+ }
+ w := nativeDevicePost(f, body, func(r *http.Request) {
+ switch gate {
+ case "bearer":
+ r.Header.Set("Authorization", "Bearer device")
+ case "no-origin":
+ r.Header.Del("Origin")
+ case "cross-origin":
+ r.Header.Set("Origin", "https://other.example")
+ case "json":
+ r.Header.Set("Content-Type", "text/plain")
+ case "duplicate-cookie":
+ r.AddCookie(f.Cookies[owner.Address])
+ }
+ })
+ expectNativeHTTP(t, w, want)
+ if f.count(t, "SELECT count(*) FROM person_devices") != 0 {
+ t.Fatal("refused request allocated a device")
+ }
+ })
+ }
+}
+
+func TestPersonAPINativeDeviceTransactionGuards(t *testing.T) {
+ for _, gate := range []string{"actor", "session-person", "session-method", "session-expiry", "roster", "audit"} {
+ t.Run(gate, func(t *testing.T) {
+ f := newFixture(t)
+ now := time.Now().UTC()
+ p := personapi.PersonPrincipal{Address: owner.Address, SessionHash: "verified-hash", SessionEpoch: now.Unix()}
+ actor := owner
+ if gate == "actor" {
+ actor = peer
+ }
+ ds := &personapi.DeviceStore{Key: "fixture-native-device-key", Now: func() time.Time { return now }, Invalid: equipo.ErrInvalid, Forbidden: equipo.ErrForbidden,
+ Write: func(c context.Context, fn func(*gorm.DB) error) error {
+ return f.DB.G.WithContext(c).Transaction(func(tx *gorm.DB) error {
+ if gate == "roster" {
+ if e := tx.Exec("UPDATE members SET active=0 WHERE address=?", owner.Address).Error; e != nil {
+ return e
+ }
+ }
+ return fn(tx)
+ })
+ },
+ NativeSession: func(tx *gorm.DB, hash string) (sessions.Session, error) {
+ sess := sessions.Session{Subject: owner.Address, Method: oficinaid.NativeMethod, At: now}
+ if gate == "session-person" {
+ sess.Subject = peer.Address
+ }
+ if gate == "session-method" {
+ sess.Method = "magiclink"
+ }
+ if gate == "session-expiry" {
+ sess.At = now.Add(-8 * 24 * time.Hour)
+ }
+ return sess, nil
+ },
+ Member: func(tx *gorm.DB, person string) (kernel.Member, error) {
+ var m kernel.Member
+ e := tx.Where("address=?", person).Take(&m).Error
+ return m, e
+ },
+ Instance: func(*gorm.DB) (string, error) { return "instance", nil }, Audit: func(*gorm.DB, kernel.Actor, string, string) error {
+ if gate == "audit" {
+ return errors.New("audit unavailable")
+ }
+ return nil
+ }}
+ _, err := ds.RegisterNative(personapi.WithVerifiedPrincipal(ctx, p), actor, base64.RawURLEncoding.EncodeToString(make([]byte, 32)), "phone")
+ if err == nil {
+ t.Fatal("native device guard accepted", gate)
+ }
+ if f.count(t, "SELECT count(*) FROM person_devices") != 0 {
+ t.Fatal("failed transaction retained credential")
+ }
+ })
+ }
+}
+func TestPersonAPINativeSessionRevocation(t *testing.T) {
+ for _, action := range []string{"session", "link", "member", "address"} {
+ t.Run(action, func(t *testing.T) {
+ f, _, _, _ := nativeIDFixture(t)
+ w := nativeDevicePost(f, nativeDeviceBody(), nil)
+ expectNativeHTTP(t, w, 200)
+ credential := apiValue[personapi.PersonCredential](t, w)
+ // Pending pushes and tokens go away in the same transaction.
+ f.exec(t, "INSERT INTO push_registrations(credential,person,token) VALUES(?,?,?)", credential.ID, owner.Address, "sealed-canary")
+ f.exec(t, "INSERT INTO push_activities(credential,task_id,person,token) VALUES(?,?,?,?)", credential.ID, "task", owner.Address, "sealed-canary")
+ f.exec(t, "INSERT INTO push_outbox(id,credential,person,state) VALUES(?,?,?,?)", "native-push", credential.ID, owner.Address, "pending")
+ switch action {
+ case "session":
+ f.exec(t, "DELETE FROM sessions WHERE token_hash=?", sessions.HashToken(f.Cookies[owner.Address].Value))
+ case "link":
+ f.exec(t, "DELETE FROM home_identity_links WHERE subject=?", nativeSubject)
+ case "member":
+ f.exec(t, "DELETE FROM members WHERE address=?", owner.Address)
+ case "address":
+ f.exec(t, "UPDATE members SET address=? WHERE address=?", "renamed@example.invalid", owner.Address)
+ }
+ if f.count(t, "SELECT count(*) FROM person_devices WHERE id=? AND revoked_at IS NOT NULL", credential.ID) != 1 {
+ t.Fatal("native device remained live", action)
+ }
+ for _, table := range []string{"push_registrations", "push_activities"} {
+ if f.count(t, "SELECT count(*) FROM "+table+" WHERE credential=?", credential.ID) != 0 {
+ t.Fatal("push secret survived", table)
+ }
+ }
+ if f.count(t, "SELECT count(*) FROM push_outbox WHERE id='native-push' AND state='dropped'") != 1 {
+ t.Fatal("pending push survived")
+ }
+ })
+ }
+}
+
+func expectNativeHTTP(t *testing.T, w *httptest.ResponseRecorder, status int) {
+ t.Helper()
+ if w.Code != status {
+ t.Fatalf("native HTTP %d, want %d", w.Code, status)
+ }
+}
+
+func TestPersonAPINativeLiveExchange(t *testing.T) {
+ f, s, _, key := nativeIDFixture(t)
+ // Both listeners bind to loopback. Home is a signing fixture; the instance
+ // runs the production router and database over a real TLS connection.
+ fakeHome := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ var in struct {
+ Aud string `json:"aud"`
+ Challenge string `json:"challenge"`
+ }
+ if json.NewDecoder(r.Body).Decode(&in) != nil || in.Aud != nativeOrigin {
+ w.WriteHeader(400)
+ return
+ }
+ nonce, ok := handoff.NativeNonce(in.Challenge)
+ if !ok {
+ w.WriteHeader(400)
+ return
+ }
+ id, err := assertion.RandomID()
+ if err != nil {
+ w.WriteHeader(500)
+ return
+ }
+ now := time.Now().Unix()
+ signed, err := assertion.Sign(key, assertion.Claims{Version: 1, KeyID: "k", Issuer: s.Config.Issuer, Audience: in.Aud, Subject: nativeSubject, ID: id, Nonce: nonce, IssuedAt: now, ExpiresAt: now + 120, AuthTime: now})
+ if err != nil {
+ w.WriteHeader(500)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ _ = json.NewEncoder(w).Encode(map[string]string{"assertion": signed})
+ }))
+ defer fakeHome.Close()
+ instance := httptest.NewTLSServer(f.Handler)
+ defer instance.Close()
+ verifier := base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{12}, 32))
+ challenge := sha256.Sum256([]byte(verifier))
+ input, _ := json.Marshal(map[string]string{"aud": nativeOrigin, "challenge": base64.RawURLEncoding.EncodeToString(challenge[:])})
+ response, err := http.Post(fakeHome.URL+"/native/v1/assert", "application/json", bytes.NewReader(input))
+ must(t, err)
+ var asserted struct {
+ Assertion string `json:"assertion"`
+ }
+ must(t, json.NewDecoder(response.Body).Decode(&asserted))
+ response.Body.Close()
+ if response.StatusCode != 200 {
+ t.Fatal("fake Home status", response.StatusCode)
+ }
+ exchange, _ := json.Marshal(oficinaid.NativeRequest{Assertion: asserted.Assertion, Verifier: verifier})
+ req, err := http.NewRequest("POST", instance.URL+oficinaid.NativePath, bytes.NewReader(exchange))
+ must(t, err)
+ req.Host = strings.TrimPrefix(nativeOrigin, "https://")
+ req.Header.Set("Content-Type", "application/json")
+ response, err = instance.Client().Do(req)
+ must(t, err)
+ defer response.Body.Close()
+ if response.StatusCode != 200 || len(response.Cookies()) != 0 {
+ t.Fatal("live exchange status or cookie", response.StatusCode)
+ }
+ var minted oficinaid.NativeSession
+ must(t, json.NewDecoder(response.Body).Decode(&minted))
+ req, err = http.NewRequest("POST", instance.URL+"/api/v1/auth/devices/native", strings.NewReader(nativeDeviceBody()))
+ must(t, err)
+ req.Host = strings.TrimPrefix(nativeOrigin, "https://")
+ req.Header.Set("Content-Type", "application/json")
+ req.Header.Set("Origin", nativeOrigin)
+ req.AddCookie(&http.Cookie{Name: minted.Name, Value: minted.Value})
+ response, err = instance.Client().Do(req)
+ must(t, err)
+ defer response.Body.Close()
+ if response.StatusCode != 200 {
+ t.Fatal("live device status", response.StatusCode)
+ }
+ var credential personapi.PersonCredential
+ must(t, json.NewDecoder(response.Body).Decode(&credential))
+ if credential.Token == "" || credential.ExpiresAt.Unix() != minted.ExpiresAt {
+ t.Fatal("live native credential expiry")
+ }
+ req, err = http.NewRequest("GET", instance.URL+"/api/v1/snapshot", nil)
+ must(t, err)
+ req.Host = strings.TrimPrefix(nativeOrigin, "https://")
+ req.Header.Set("Authorization", "Bearer "+credential.Token)
+ response, err = instance.Client().Do(req)
+ must(t, err)
+ defer response.Body.Close()
+ if response.StatusCode != 200 {
+ t.Fatal("device engine status", response.StatusCode)
+ }
+}
diff --git a/internal/wire/wireschema/wireschema.go b/internal/wire/wireschema/wireschema.go
index 920fc4be..e9e19dce 100644
--- a/internal/wire/wireschema/wireschema.go
+++ b/internal/wire/wireschema/wireschema.go
@@ -17,6 +17,8 @@ import (
"strings"
"time"
+ "amadan.net/oficina/equipo/internal/equipo/oficinaid"
+ "amadan.net/oficina/equipo/internal/equipo/personapi"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -452,6 +454,24 @@ func (g *gen) fields(t reflect.Type, name string, props *ordered, required *[]st
}
}
+// NativeOps are the native sign-in routes, with their own authentication.
+// The exchange overrides the document's /api/v1 server with the instance root.
+var NativeOps = map[string]Op{
+ "POST /native/oficina-id": {oficinaid.NativeRequest{}, map[string]any{"200": oficinaid.NativeSession{}, "400": oficinaid.NativeState{}, "401": oficinaid.NativeState{}, "403": oficinaid.NativeState{}, "503": oficinaid.NativeState{}}},
+ "POST /auth/devices/native": {personapi.BeginDeviceInput{}, map[string]any{"200": personapi.PersonCredential{}}},
+}
+
+func allOps() map[string]Op {
+ all := map[string]Op{}
+ for k, v := range Ops {
+ all[k] = v
+ }
+ for k, v := range NativeOps {
+ all[k] = v
+ }
+ return all
+}
+
// Generate is every schema the device operations reach, by name, as
// the document writes it. It panics on an enum for a field no schema
// has.
@@ -484,7 +504,7 @@ func generate() map[string]*ordered {
// bodies' (in).
func build() (out, in *gen) {
out, in = newGen(), newGen()
- for _, op := range Ops {
+ for _, op := range allOps() {
for _, v := range op.Out {
if _, bytes := v.(Bytes); v != nil && !bytes {
out.ref(v)
@@ -493,7 +513,7 @@ func build() (out, in *gen) {
}
out.events()
in.input, in.outputs = true, out.types
- for _, op := range Ops {
+ for _, op := range allOps() {
if _, bytes := op.In.(Bytes); op.In != nil && !bytes {
in.ref(op.In)
}