Merge remote-tracking branch 'origin/main' into native/push
# Conflicts: # .rastrillo/budgets.txt
33 files changed,
+2,095
−48
.rastrillo/budgets.txt+2 −2docs/api/equipo-v1.openapi.json+219 −13docs/superpowers/plans/2026-11-20-native-id-server-evidence.md+512 −0docs/superpowers/specs/2026-11-20-equipo-native-oficina-id.md+120 −0go.mod+1 −1go.sum+2 −0internal/equipo/app.go+14 −1internal/equipo/migrations/0098_native_device.sql+2 −0internal/equipo/migrations/schema.sql+3 −0internal/equipo/oficinaid/http.go+3 −2internal/equipo/oficinaid/link.go+1 −1internal/equipo/oficinaid/migrations/0002_native_lifecycle.sql+10 −0internal/equipo/oficinaid/native.go+144 −0internal/equipo/oficinaid/native_test.go+348 −0internal/equipo/oficinaid/signout.go+1 −1internal/equipo/oficinaid/store.go+20 −5internal/equipo/person_devices.go+1 −1internal/equipo/personapi/auth.go+13 −1internal/equipo/personapi/device_browser.go+1 −1internal/equipo/personapi/devices.go+8 −0internal/equipo/personapi/extended_mutations.go+4 −0internal/equipo/personapi/extended_routes.go+1 −0internal/equipo/personapi/handler.go+4 −0internal/equipo/personapi/native_device.go+52 −0internal/equipo/personapi/native_device_test.go+75 −0internal/equipo/personapi/types.go+1 −0internal/equipo/store.go+13 −11internal/plan3test/person_api_contract_test.go+2 −2internal/plan3test/person_api_device_contract_test.go+17 −1internal/plan3test/person_api_migration_test.go+2 −2internal/plan3test/person_api_native_id_test.go+425 −0internal/wire/wireschema/wireschema.go+38 −2internal/wire/wireschema/wireschema_test.go+36 −1
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/native__push: 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.4s
ci-box: claude: fetched and verified in 3.7s
ci-box: codex: fetched and verified in 3.6s
ci-box: codex-code-mode-host: fetched and verified in 1.5s
ci-box: libwrap: fetched and verified in 0.4s
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 7.5s
ci-box: opencode: installed and verified in 2.2s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.5s
ci-box: clone deepened in 3.6s
ci-box: file times set from content: 2803 files, 184 directories
ci-box: ready in 17.4s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok amadan.net/oficina/equipo/internal/equipotest 0.244s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
1.1s
+ go list -export -test -tags testbuild -f ./...
0.6s
+ go list -export -test -tags browser,testbuild -f ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
0.3s
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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m20.501s 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 1m19.047s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m19.05s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 39.52, cpu waiting 21.39%, memory waiting 0.00%, io waiting 0.62%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m22.087s 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 1m20.473s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m20.47s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 37.40, cpu waiting 20.53%, memory waiting 0.00%, io waiting 0.58%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m23.482s 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 1m21.547s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m11.16s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.77s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.61s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 37.40, cpu waiting 20.53%, memory waiting 0.00%, io waiting 0.58%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m34.505s 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.977s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.19s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 35.93s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.37s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.48s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 34.96, cpu waiting 17.99%, memory waiting 0.00%, io waiting 0.49%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m35.967s 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 1m34.314s amadan.net/oficina/equipo/internal/headless
receipt: slow test 59.23s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.02s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 9.73s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 8.61s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.73s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 34.96, cpu waiting 17.47%, memory waiting 0.00%, io waiting 0.47%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 3m8.814s 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 3m6.882s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m45.79s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 23.94s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.47s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 8.06s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.32s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 9.33, cpu waiting 3.67%, memory waiting 0.00%, io waiting 0.09%
--- 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 266ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 2m4.115s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 7.82s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.7s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 5.77s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.51s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 2.49s amadan.net/oficina/equipo/internal/thintest TestResearchDoneFallsBack
machine: 32 CPUs, load 0.97, cpu waiting 0.00%, memory waiting 0.00%, io waiting 2.23%
--- 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
--- FAIL amadan.net/oficina/equipo/internal/thintest TestContractWorkerTaintIsSticky
=== RUN TestContractWorkerTaintIsSticky
placement_contract_test.go:552: waiting for send_pack: failed to get reader: context deadline exceeded
--- FAIL: TestContractWorkerTaintIsSticky (45.25s)
--- FAIL amadan.net/oficina/equipo/internal/thintest (package output)
FAIL
rastrillo-budget/v1 ran 2m2.49s
FAIL amadan.net/oficina/equipo/internal/thintest 122.789s
receipt: test step 2m3.804s 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 2m2.49s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 45.25s amadan.net/oficina/equipo/internal/thintest TestContractWorkerTaintIsSticky
receipt: slow test 8.88s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 4.81s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.39s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.29s amadan.net/oficina/equipo/internal/thintest TestContractPublishNameTaken
rastrillo: budget test: go test failed
exit status 1
+ go 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)' -v -run '^TestContractWorkerTaintIsSticky$' -count=1 ./internal/thintest (retry, once)
##############################################################################
FLAKE ./internal/thintest:TestContractWorkerTaintIsSticky thintest-contract 6fc77bc2c5b0d2399628ab5855e09b2705a89ad6 45.25s 22.49
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 21.01, cpu waiting 10.28%, memory waiting 0.00%, io waiting 0.27%
--- 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 4m29.198s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 4m42.127s 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 4m29.198s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.95s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.88s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.76s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.47s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 7s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.70, cpu waiting 0.79%, memory waiting 0.00%, io waiting 0.01%
--- 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 47.886s 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 46.792s amadan.net/oficina/equipo/internal/runner
receipt: slow test 26.76s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.02s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 36.01, cpu waiting 20.93%, memory waiting 0.00%, io waiting 1.06%
--- 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 47.323s 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 45.434s amadan.net/oficina/equipo/internal/runner
receipt: slow test 35.42s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 31.69s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.38s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.62s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 36.01, cpu waiting 20.93%, memory waiting 0.00%, io waiting 1.06%
--- 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 34.804s 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 33.992s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.33s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.12s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 1.94s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 31.89, cpu waiting 14.03%, memory waiting 0.00%, io waiting 1.34%
--- 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 28.9%, load 25.35
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
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m5.237s 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 1m3.164s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 27.03s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 26.93s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 25.03s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.43s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 22.27s amadan.net/oficina/equipo/internal/equipotest TestAuthorityFailureIsNotRevocation
machine: 32 CPUs, load 34.96, cpu waiting 17.47%, memory waiting 0.00%, io waiting 0.47%
--- 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 28.9%, load 25.35
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 672ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1m14.141s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 19.47s amadan.net/oficina/equipo/internal/equipotest TestProjectRejectsUnsafeBinding
receipt: slow test 19.38s amadan.net/oficina/equipo/internal/equipotest TestProjectOwnersAreMembers
receipt: slow test 19.38s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 19.38s amadan.net/oficina/equipo/internal/equipotest TestProjectConcurrentRetry
receipt: slow test 19.36s amadan.net/oficina/equipo/internal/equipotest TestProjectRequestActorAndUpdate
machine: 32 CPUs, load 25.35, cpu waiting 12.37%, memory waiting 0.00%, io waiting 1.38%
--- 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 28.9%, load 25.35
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
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m15.748s 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 1m3.77s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 14.64s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.14s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.11s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.1s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.06s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 30.74, cpu waiting 14.82%, memory waiting 0.00%, io waiting 0.40%
--- 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 28.9%, load 25.35
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 456ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1m6.267s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 24.58s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 24.54s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 24.14s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 22.65s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
receipt: slow test 22.55s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsConcurrentRevision
machine: 32 CPUs, load 25.35, cpu waiting 12.37%, memory waiting 0.00%, io waiting 1.38%
--- 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 28.9%, load 25.35
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 584ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 52.228s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.66s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.57s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.68s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.58s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.33s amadan.net/oficina/equipo/internal/plan3test TestInviteMigration
machine: 32 CPUs, load 25.35, cpu waiting 12.37%, memory waiting 0.00%, io waiting 1.38%
--- 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 28.9%, load 25.35
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/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/codex: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: 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 25.824s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/equipo/chat took 14.912s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/equipo/setup took 10.123s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/idtest took 47.87s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/release took 36.617s, 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 39.241s, over the 15s its record on line 40 allows; reported only, timing fails on CI
receipt: test step 2m17.704s against a 60s target (the gate's other steps are not in this figure)
receipt: 12 packages ran, 49 cached, 18 without tests, 0 failed
receipt: slow package 55.088s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 52.961s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 50.955s amadan.net/oficina/equipo/cmd/equipo-runner
receipt: slow package 47.87s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 39.241s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 45.77s amadan.net/oficina/equipo/cmd/equipo-runner TestReleaseRunnerHasNoFakeWorker
receipt: slow test 22.29s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 14.77s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringOfflineGo
receipt: slow test 14.1s amadan.net/oficina/equipo/internal/idtest TestIDCallbackGuardAndPendingNonce
receipt: slow test 9.54s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringMissingModuleCache
machine: 32 CPUs, load 12.19, cpu waiting 5.30%, memory waiting 0.00%, io waiting 0.13%
--- 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
receipt: test step 1m22.036s 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 1m20.618s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.26s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 15.06s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.26s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.88s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 5.74s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 37.40, cpu waiting 20.53%, memory waiting 0.00%, io waiting 0.58%
--- 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
receipt: test step 1m31.381s 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 1m29.938s amadan.net/oficina/equipo/internal/headless
receipt: slow test 26.18s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 22s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 14.02s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 10.16s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 7.9s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 34.96, cpu waiting 17.99%, memory waiting 0.00%, io waiting 0.49%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m40.369s 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 1m38.773s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.2s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.07s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 12.93s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 10.3s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.22s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 32.72, cpu waiting 15.81%, memory waiting 0.00%, io waiting 0.42%
--- 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
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN TestBrowserEmptyExplore
time=2026-11-20T15:25:44.493Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T15:25:44.493Z level=INFO msg="startup phase done" phase=state_lock took=74µs
time=2026-11-20T15:25:44.493Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T15:25:44.493Z level=INFO msg="startup phase done" phase=claim_roots took=77µs
time=2026-11-20T15:25:44.493Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T15:25:44.520Z level=INFO msg="startup phase done" phase=sweep took=26.603ms
time=2026-11-20T15:25:44.520Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T15:25:44.520Z level=INFO msg="startup phase done" phase=credentials took=105µs
time=2026-11-20T15:25:44.520Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T15:25:44.559Z level=INFO msg="startup phase done" phase=open_state took=38.6ms
time=2026-11-20T15:25:44.559Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T15:25:44.560Z level=INFO msg=connecting host=127.0.0.1:39675 protocol=28
time=2026-11-20T15:25:44.561Z level=INFO msg=connected host=127.0.0.1:39675 took=934µs
time=2026-11-20T15:25:44.561Z level=INFO msg="capabilities gathering"
time=2026-11-20T15:25:44.561Z level=INFO msg="capabilities gathered" took=437µs tags=linux,claude,go
time=2026-11-20T15:25:44.562Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T15:25:44.567Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T15:25:45.469Z 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: <nil>)
--- FAIL: TestBrowserEmptyExplore (5.75s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m26.453s
FAIL amadan.net/oficina/equipo/internal/headless 86.747s
receipt: test step 1m27.756s 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 1m26.453s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.09s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.21s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.38s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 10.31s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.96s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
rastrillo: budget test: go test failed
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 6fc77bc2c5b0d2399628ab5855e09b2705a89ad6 5.75s 36.00
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 32.72, cpu waiting 16.35%, memory waiting 0.00%, io waiting 0.44%
--- 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 285ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 647ms amadan.net/oficina/equipo/internal/equipo
receipt: slow test 650ms 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 209ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1.582s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 1.58s 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 215ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1.843s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 1.84s 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 316ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 3m22.471s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 17.59s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.33s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.05s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.61s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 8.46s amadan.net/oficina/equipo/internal/thintest TestBrowserInnerScreens
machine: 32 CPUs, load 5.86, cpu waiting 1.51%, memory waiting 0.00%, io waiting 2.21%
--- 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 (52s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.27s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.38s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.29s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.88s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.62s
+ 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 (62s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 12.80s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 13.96s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 20.48s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 12.90s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (21s)
ok ./internal/headless TestMixedVersions 19.88s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.77s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin (1s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 43.00, cpu waiting 21.94%, memory waiting 0.00%, io waiting 0.81%
--- 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 8.191s 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.174s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 229ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 70ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 3ms amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow test 5.1s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.67s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 300ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 230ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 80ms 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.104s 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.777s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 270ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 14.13, cpu waiting 4.50%, memory waiting 0.00%, io waiting 1.93%
--- 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 28.9%, load 25.35
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2516 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 35.74, cpu waiting 19.83%, memory waiting 0.00%, io waiting 1.13%
--- 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 28.9%, load 25.35
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 31.89, cpu waiting 12.37%, memory waiting 0.00%, io waiting 1.38%
--- 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 28.9%, load 25.35
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 31.89, cpu waiting 15.21%, memory waiting 0.00%, io waiting 1.29%
--- 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 28.9%, load 25.35
shard 28: make gitleaks
[90m3:25PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m3:25PM[0m [32mINF[0m [1m1064 commits scanned.[0m
[90m3:25PM[0m [32mINF[0m [1mscanned ~60605048 bytes (60.61 MB) in 13.7s[0m
[90m3:25PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 35.74, cpu waiting 19.83%, memory waiting 0.00%, io waiting 1.13%
=== 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.093ms, worst 1.19ms, budget 150ms
perf: GET /api/runner/protocol: median 87µs, worst 106µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 617µs, worst 686µs, budget 150ms
perf: GET /api/v1/accounts: median 434µs, worst 453µs, budget 150ms
perf: GET /api/v1/auth/devices: median 455µs, worst 507µs, budget 150ms
perf: GET /api/v1/budgets: median 489µs, worst 550µs, budget 150ms
perf: GET /api/v1/capabilities: median 252µs, worst 299µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.261ms, worst 1.309ms, budget 150ms
perf: GET /api/v1/connections: median 591µs, worst 617µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 542µs, worst 576µs, budget 150ms
perf: GET /api/v1/conversation: median 949µs, worst 999µs, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.509ms, worst 1.556ms, budget 150ms
perf: GET /api/v1/coordinator: median 1.851ms, worst 1.981ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 461µs, worst 498µs, budget 150ms
perf: GET /api/v1/journey: median 7.698ms, worst 10.499ms, budget 150ms
perf: GET /api/v1/me: median 426µs, worst 448µs, budget 150ms
perf: GET /api/v1/me/settings: median 500µs, worst 517µs, budget 150ms
perf: GET /api/v1/needs-you: median 7.178ms, worst 7.357ms, budget 150ms
perf: GET /api/v1/notifications: median 1.622ms, worst 1.672ms, budget 150ms
perf: GET /api/v1/onboarding: median 374µs, worst 407µs, budget 150ms
perf: GET /api/v1/people: median 440µs, worst 463µs, budget 150ms
perf: GET /api/v1/playbooks: median 574µs, worst 612µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 524µs, worst 552µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 821µs, worst 850µs, budget 150ms
perf: GET /api/v1/preferences: median 753µs, worst 767µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 444µs, worst 477µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 611µs, worst 650µs, budget 150ms
perf: GET /api/v1/roster: median 460µs, worst 508µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 409µs, worst 445µs, budget 150ms
perf: GET /api/v1/specialists: median 8.064ms, worst 8.226ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 8.024ms, worst 8.186ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 849µs, worst 903µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.096ms, worst 1.184ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 703µs, worst 741µs, budget 150ms
perf: GET /api/v1/teams: median 450µs, worst 478µs, budget 150ms
perf: GET /api/v1/templates: median 584µs, worst 627µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 454µs, worst 514µs, budget 150ms
perf: GET /auth/callback: median 70µs, worst 107µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.276ms, worst 3.347ms, budget 150ms
perf: GET /auth/verify: median 81µs, worst 99µs, budget 150ms
perf: GET /connections: median 3.698ms, worst 3.826ms, budget 150ms
perf: GET /conversation: median 7.394ms, worst 7.901ms, budget 150ms
perf: GET /conversation/connections: median 260µs, worst 321µs, budget 150ms
perf: GET /conversation/notebook: median 258µs, worst 306µs, budget 150ms
perf: GET /conversation/settings: median 4.072ms, worst 4.187ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 3.612ms, worst 3.688ms, budget 150ms
perf: GET /conversation/settings/connections: median 6.163ms, worst 6.342ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 6.352ms, worst 6.475ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.547ms, worst 3.625ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 4.031ms, worst 4.18ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.482ms, worst 4.55ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.373ms, worst 4.39ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.588ms, worst 5.168ms, budget 150ms
perf: GET /conversation/settings/thinking: median 4.085ms, worst 4.21ms, budget 150ms
perf: GET /housekeeping: median 3.717ms, worst 3.85ms, budget 150ms
perf: GET /invites/new: median 576µs, worst 596µs, budget 150ms
perf: GET /invites/{id}: median 609µs, worst 632µs, budget 150ms
perf: GET /jobs: median 3.276ms, worst 3.406ms, budget 150ms
perf: GET /jobs/{id}: median 4.337ms, worst 4.48ms, budget 150ms
perf: GET /journey: median 10.1ms, worst 10.389ms, budget 150ms
perf: GET /nav/rail: median 2.816ms, worst 2.971ms, budget 150ms
perf: GET /needs-you: median 9.895ms, worst 10.408ms, budget 150ms
perf: GET /onboarding: median 4.171ms, worst 5.044ms, budget 150ms
perf: GET /people: median 3.335ms, worst 3.505ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 4.499ms, worst 4.576ms, budget 150ms
perf: GET /playbooks: median 4.039ms, worst 4.178ms, budget 150ms
perf: GET /playbooks/new: median 4.163ms, worst 4.3ms, budget 150ms
perf: GET /playbooks/{id}: median 4.547ms, worst 4.714ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.426ms, worst 4.493ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 3.732ms, worst 3.903ms, budget 150ms
perf: GET /preferences: median 4.195ms, worst 4.348ms, budget 150ms
perf: GET /preferences/sources/{source}: median 4.115ms, worst 4.158ms, budget 150ms
perf: GET /projects: median 5.182ms, worst 5.609ms, budget 150ms
perf: GET /projects/accounts: median 3.786ms, worst 6.254ms, budget 150ms
perf: GET /projects/new: median 3.683ms, worst 3.792ms, budget 150ms
perf: GET /projects/{id}: median 10.49ms, worst 10.667ms, budget 150ms
perf: GET /projects/{id}/edit: median 3.725ms, worst 3.796ms, budget 150ms
perf: GET /runners/enrol: median 4.471ms, worst 4.615ms, budget 150ms
perf: GET /settings: median 3.487ms, worst 3.606ms, budget 150ms
perf: GET /settings/coordinator: median 5.498ms, worst 5.635ms, budget 150ms
perf: GET /settings/devices: median 3.286ms, worst 3.352ms, budget 150ms
perf: GET /settings/recovery: median 3.456ms, worst 3.548ms, budget 150ms
perf: GET /settings/recovery/release: median 3.583ms, worst 3.669ms, budget 150ms
perf: GET /settings/thinking: median 241µs, worst 264µs, budget 150ms
perf: GET /signin: median 324µs, worst 391µs, budget 150ms
perf: GET /specialists/new: median 3.542ms, worst 5.922ms, budget 150ms
perf: GET /specialists/{key}: median 10.912ms, worst 10.967ms, budget 150ms
perf: GET /specialists/{key}/edit: median 3.617ms, worst 3.708ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 3.732ms, worst 3.922ms, budget 150ms
perf: GET /tasks: median 5.168ms, worst 5.325ms, budget 150ms
perf: GET /tasks/new: median 3.188ms, worst 3.278ms, budget 150ms
perf: GET /tasks/{id}: median 5.563ms, worst 5.737ms, budget 150ms
perf: GET /tasks/{id}/merge: median 4.748ms, worst 4.93ms, budget 150ms
perf: GET /tasks/{id}/move: median 4.588ms, worst 4.763ms, budget 150ms
perf: GET /tasks/{id}/plan: median 6.122ms, worst 8.771ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.546ms, worst 1.661ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 5.377ms, worst 5.492ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 4.779ms, worst 5.006ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4.341ms, worst 4.46ms, budget 150ms
perf: GET /tasks/{id}/thread: median 8.016ms, worst 8.272ms, budget 150ms
perf: GET /team/{specialist}: median 4.236ms, worst 4.381ms, budget 150ms
perf: GET /teams: median 10.018ms, worst 10.377ms, budget 150ms
perf: GET /templates: median 3.368ms, worst 3.578ms, budget 150ms
perf: GET /usage: median 4.281ms, worst 4.517ms, budget 150ms
perf: GET /work: median 3.097ms, worst 3.155ms, budget 150ms
perf: cold boot: median 258ms of [257.760898ms 257.906915ms 259.715718ms], budget 500ms
receipt: test step 46.505s 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 8.839s 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.01s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 830ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 4.46 GiB in 25784 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.07 GiB this job did not read, kept 2.39 GiB
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 85c590ac..edf8fede 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, merged with native push configuration; measured 21508/3385 source/test lines. |
| size internal/wire 6771 - Native slice 2 push registrations and set aside, and the instance origin in Live Activity attributes; measured 6771/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 - 11887 Native identity route, transaction, revocation, loopback TLS and pairing-approval refusal contracts; measured 940/11887 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..7589969c 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,12 +15178,12 @@ |
| } |
| }, |
| "BeginDeviceInput": { |
| - "additionalProperties": false, |
| + "type": "object", |
| "properties": { |
| - "label": { |
| + "public_key": { |
| "type": "string" |
| }, |
| - "public_key": { |
| + "label": { |
| "type": "string" |
| } |
| }, |
| @@ -15042,7 +15191,8 @@ |
| "public_key", |
| "label" |
| ], |
| - "type": "object" |
| + "additionalProperties": false, |
| + "x-go-type": "personapi.BeginDeviceInput" |
| }, |
| "ApproveDeviceInput": { |
| "additionalProperties": false, |
| @@ -16324,23 +16474,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 +16500,8 @@ |
| "instance_id", |
| "expires_at" |
| ], |
| - "type": "object" |
| + "additionalProperties": false, |
| + "x-go-type": "personapi.PersonCredential" |
| }, |
| "Device": { |
| "additionalProperties": false, |
| @@ -23114,6 +23265,61 @@ |
| }, |
| "additionalProperties": false, |
| "x-go-type": "wire.SetCardVisibility" |
| + }, |
| + "NativeRequest": { |
| + "type": "object", |
| + "properties": { |
| + "assertion": { |
| + "type": "string" |
| + }, |
| + "verifier": { |
| + "type": "string" |
| + }, |
| + "choice": { |
| + "type": "string" |
| + } |
| + }, |
| + "required": [ |
| + "assertion", |
| + "verifier" |
| + ], |
| + "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..14899c20 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-20-native-id-server-evidence.md |
| @@ -0,0 +1,512 @@ |
| +# 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. |
| + |
| +## Review fixes (Astra review 1, by Claude) |
| + |
| +**P1. A native session could approve a paired device.** Pairing approval |
| +mints a 30-day credential, so a 7-day Oficina ID session could outlive |
| +itself through it. `DeviceStore.Approve` now refuses any principal with a |
| +`SessionHash` (`ErrForbidden`), and `DeviceBrowser.ApproveForm` refuses a |
| +native cookie before reaching approval. The person's web session still |
| +approves. |
| + |
| +- `personapi.TestNativeSessionNeverApprovesAPairedDevice` and |
| + `TestNativeSessionNeverApprovesFromTheBrowserForm` failed first ("native |
| + session reached the approval write", "native session reached approval"). |
| +- `plan3test.TestPersonAPINativeSessionNeverApprovesPairing` drives both |
| + routes with the minted native cookie (403 each, device stays unapproved), |
| + then approves with the person's web session (200). |
| +- Mutations: store guard to `if false` failed the store test and the |
| + end-to-end test (`native HTTP 200, want 403`); browser guard removed failed |
| + the browser-form test. Both restored. |
| + |
| +**P2. The native inputs lost `required`.** The generator writes input |
| +schemas with nothing required, which replaced the hand-written |
| +`BeginDeviceInput` (`public_key`, `label`). `wireschema.InputRequired` now |
| +names the fields the handlers refuse to go without, for `BeginDeviceInput` |
| +and `NativeRequest` (`assertion`, `verifier`), and panics on a name the |
| +type lacks. The document carries both lists. |
| + |
| +- `wireschema.TestNativeInputsRequireWhatTheirHandlersRequire` validates |
| + incomplete bodies (refused) and complete ones (accepted); it failed first |
| + on four bodies. |
| +- Mutation: dropping the required list failed that test and |
| + `TestPersonAPIDeviceContract`. Restored. |
| + |
| +`TestRequestBodies` (inputs require nothing) now exempts exactly the |
| +`InputRequired` names. |
| + |
| +Gates on macOS, with `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`: `fmt-check`, |
| +`gitleaks`, `budget` (plan3test raised to the measured 11887 test lines), |
| +`migration-check`, `copy-release-check`, `lanes-check` and |
| +`runner-dead-references` pass; `personapi`, `oficinaid`, `wireschema` and |
| +the `TestPersonAPI` contracts pass. `make test` here fails only where macOS |
| +cannot run it: the Linux runner packages, the browser tests (no Chromium), |
| +and `TestCoordinatorAcceptance3B` and `TestPublishCoreAuthorizationContract`, |
| +which fail the same way on main. `vet` and `staticcheck` stop at |
| +`internal/toolproxy` (`unix.O_PATH`, Linux only). CI on Linux is the gate. |
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/device_browser.go b/internal/equipo/personapi/device_browser.go| index 97372fa2..83d1ca66 100644 |
| --- a/internal/equipo/personapi/device_browser.go |
| +++ b/internal/equipo/personapi/device_browser.go |
| @@ -44,7 +44,7 @@ func (a *DeviceBrowser) Page(w http.ResponseWriter, r *http.Request) { |
| } |
| func (a *DeviceBrowser) ApproveForm(w http.ResponseWriter, r *http.Request) { |
| p, err := a.Cookie(r) |
| - if err != nil { |
| + if err != nil || p.SessionHash != "" { |
| a.Failure(w, r, a.Forbidden) |
| return |
| } |
diff --git a/internal/equipo/personapi/devices.go b/internal/equipo/personapi/devices.go| index 09db92ca..595057ef 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) |
| @@ -274,6 +277,11 @@ func (s *DeviceStore) Approve(ctx context.Context, a kernel.Actor, id, code stri |
| if !ok || p.Address == "" || p.Address != a.Address || p.CredentialID != "" || p.Pending { |
| return ErrUnauthenticated |
| } |
| + // An Oficina ID session's devices expire with it; approving a paired |
| + // device from one would mint a 30-day credential that outlives it. |
| + if p.SessionHash != "" { |
| + return s.Forbidden |
| + } |
| code = strings.ToUpper(strings.TrimSpace(code)) |
| if !m.Valid() { |
| return s.Invalid |
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..1f67e738 |
| --- /dev/null |
| +++ b/internal/equipo/personapi/native_device_test.go |
| @@ -0,0 +1,75 @@ |
| +package personapi |
| + |
| +import ( |
| + "context" |
| + "encoding/base64" |
| + "errors" |
| + "net/http" |
| + "net/http/httptest" |
| + "strings" |
| + "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) |
| + } |
| +} |
| + |
| +// A session from Oficina ID lives 7 days and its devices expire with it. |
| +// Approving a paired device would hand out a 30-day credential from it. |
| +func TestNativeSessionNeverApprovesAPairedDevice(t *testing.T) { |
| + forbidden := errors.New("forbidden") |
| + s := &DeviceStore{Invalid: errors.New("invalid"), Forbidden: forbidden, Now: time.Now, Write: func(context.Context, func(*gorm.DB) error) error { |
| + t.Fatal("native session reached the approval write") |
| + return nil |
| + }} |
| + p := PersonPrincipal{Address: "person", SessionEpoch: 1, SessionHash: "hash"} |
| + err := s.Approve(WithVerifiedPrincipal(context.Background(), p), kernel.Actor{Address: "person"}, "device", "ABCDEFGH", kernel.Mutation{RequestID: "request", Revision: 1}) |
| + if !errors.Is(err, forbidden) { |
| + t.Fatalf("native session approved a device: %v", err) |
| + } |
| +} |
| + |
| +func TestNativeSessionNeverApprovesFromTheBrowserForm(t *testing.T) { |
| + forbidden := errors.New("forbidden") |
| + var failed error |
| + b := &DeviceBrowser{Invalid: errors.New("invalid"), Forbidden: forbidden, Cookie: func(*http.Request) (PersonPrincipal, error) { |
| + return PersonPrincipal{Address: "person", SessionEpoch: 1, SessionHash: "hash"}, nil |
| + }, Approve: func(context.Context, kernel.Actor, string, string, kernel.Mutation) error { |
| + t.Fatal("native session reached approval") |
| + return nil |
| + }, Failure: func(_ http.ResponseWriter, _ *http.Request, err error) { failed = err }} |
| + r := httptest.NewRequest("POST", "https://equipo.example/auth/devices/device/approve", strings.NewReader("typed_code=ABCDEFGH&request_id=request&revision=1")) |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + b.ApproveForm(httptest.NewRecorder(), r) |
| + if !errors.Is(failed, forbidden) { |
| + t.Fatalf("native session approved from the browser: %v", failed) |
| + } |
| +} |
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..5248358a |
| --- /dev/null |
| +++ b/internal/plan3test/person_api_native_id_test.go |
| @@ -0,0 +1,425 @@ |
| +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) |
| + } |
| +} |
| + |
| +// A native session's devices expire with it (7 days). Approving a paired |
| +// device from it would mint a 30-day credential that outlives the session, so |
| +// both approval routes refuse it; the person's web session still approves. |
| +func TestPersonAPINativeSessionNeverApprovesPairing(t *testing.T) { |
| + f, _, fresh, _ := nativeIDFixture(t) |
| + pub := base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{5}, 32)) |
| + c, e := f.Store.BeginPersonDevice(ctx, pub, "paired phone", "native-approve-begin") |
| + must(t, e) |
| + native := f.Cookies[owner.Address] |
| + web := &http.Cookie{Name: native.Name, Value: fresh} |
| + approve := func(cookie *http.Cookie, form bool, key string) *httptest.ResponseRecorder { |
| + var r *http.Request |
| + if form { |
| + r = httptest.NewRequest("POST", nativeOrigin+"/auth/devices/"+c.ID+"/approve", strings.NewReader("typed_code="+c.UserCode+"&request_id="+key+"&revision=1")) |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + } else { |
| + r = httptest.NewRequest("POST", nativeOrigin+"/api/v1/auth/devices/"+c.ID+"/approve", strings.NewReader(`{"typed_code":"`+c.UserCode+`"}`)) |
| + r.Header.Set("Content-Type", "application/json") |
| + r.Header.Set("Idempotency-Key", key) |
| + r.Header.Set("If-Match", `"1"`) |
| + } |
| + r.Header.Set("Origin", nativeOrigin) |
| + r.AddCookie(cookie) |
| + w := httptest.NewRecorder() |
| + f.Handler.ServeHTTP(w, r) |
| + return w |
| + } |
| + expectNativeHTTP(t, approve(native, false, "native-api"), 403) |
| + expectNativeHTTP(t, approve(native, true, "native-form"), 403) |
| + if f.count(t, "SELECT count(*) FROM person_devices WHERE id=? AND approved_at IS NOT NULL", c.ID) != 0 { |
| + t.Fatal("native session approved a paired device") |
| + } |
| + expectNativeHTTP(t, approve(web, false, "web-api"), 200) |
| +} |
diff --git a/internal/wire/wireschema/wireschema.go b/internal/wire/wireschema/wireschema.go| index 920fc4be..14832ea4 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" |
| ) |
| @@ -396,6 +398,14 @@ func (g *gen) of(t reflect.Type) *ordered { |
| func (g *gen) object(t reflect.Type, name string) *ordered { |
| props, required := obj(), []string{} |
| g.fields(t, t.Name(), props, &required) |
| + if need, ok := InputRequired[name]; ok && g.input { |
| + for _, key := range need { |
| + if _, ok := props.vals[key]; !ok { |
| + panic("wireschema: " + name + " requires " + key + ", which it does not have") |
| + } |
| + } |
| + required = need |
| + } |
| s := obj("type", "object", "properties", props) |
| if len(required) > 0 { |
| s.set("required", required) |
| @@ -452,6 +462,32 @@ func (g *gen) fields(t reflect.Type, name string, props *ordered, required *[]st |
| } |
| } |
| +// InputRequired names, for the few request bodies whose handler refuses |
| +// a missing field, the fields it needs. Every other input requires |
| +// nothing (see gen). |
| +var InputRequired = map[string][]string{ |
| + "BeginDeviceInput": {"public_key", "label"}, |
| + "NativeRequest": {"assertion", "verifier"}, |
| +} |
| + |
| +// 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 +520,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 +529,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) |
| } |
diff --git a/internal/wire/wireschema/wireschema_test.go b/internal/wire/wireschema/wireschema_test.go| index a88f818b..6c66ec8b 100644 |
| --- a/internal/wire/wireschema/wireschema_test.go |
| +++ b/internal/wire/wireschema/wireschema_test.go |
| @@ -334,7 +334,7 @@ func TestRequestBodies(t *testing.T) { |
| if err := json.Unmarshal(s, &v); err != nil { |
| t.Fatal(err) |
| } |
| - if _, required := v["required"]; required && strings.HasSuffix(name, "Input") { |
| + if _, required := v["required"]; required && strings.HasSuffix(name, "Input") && InputRequired[name] == nil { |
| t.Errorf("%s requires fields", name) |
| } |
| } |
| @@ -605,3 +605,38 @@ func opName(v any) string { |
| } |
| return "map" |
| } |
| + |
| +// The native routes' handlers refuse a body missing these fields, so the |
| +// document must say so: an app built from it would otherwise send none. |
| +func TestNativeInputsRequireWhatTheirHandlersRequire(t *testing.T) { |
| + defs := map[string]any{} |
| + for name, raw := range Generate() { |
| + var s any |
| + if err := json.Unmarshal(raw, &s); err != nil { |
| + t.Fatal(err) |
| + } |
| + defs[name] = s |
| + } |
| + for name, cases := range map[string][]string{ |
| + "BeginDeviceInput": {`{}`, `{"label":"phone"}`, `{"public_key":"key"}`}, |
| + "NativeRequest": {`{}`, `{"verifier":"v"}`, `{"assertion":"a","choice":"new"}`}, |
| + } { |
| + s := map[string]any{"$ref": "#/components/schemas/" + name} |
| + for _, body := range cases { |
| + var v any |
| + if err := json.Unmarshal([]byte(body), &v); err != nil { |
| + t.Fatal(err) |
| + } |
| + if Validate(defs, v, s, name) == nil { |
| + t.Errorf("%s accepts %s", name, body) |
| + } |
| + } |
| + } |
| + for name, body := range map[string]string{"BeginDeviceInput": `{"public_key":"key","label":"phone"}`, "NativeRequest": `{"assertion":"a","verifier":"v"}`} { |
| + var v any |
| + _ = json.Unmarshal([]byte(body), &v) |
| + if err := Validate(defs, v, map[string]any{"$ref": "#/components/schemas/" + name}, name); err != nil { |
| + t.Errorf("%s refuses a complete body: %v", name, err) |
| + } |
| + } |
| +} |