Bind native sign-in work to one lifetime
Co-Authored-By: Codex GPT-6-Astra <noreply@openai.com>
16 files changed,
+703
−129
native/OFICINA-ID-REPORT.md+111 −0native/apple/Sources/EquipoKit/OficinaID/EquipoOficinaID.swift+103 −52native/apple/Sources/EquipoKit/OficinaID/EquipoRenewingTransport.swift+4 −0native/apple/Sources/EquipoKit/Pairing/DeviceAccount.swift+29 −12native/apple/Sources/EquipoKit/Pairing/Pairing.swift+71 −16native/apple/Sources/EquipoKit/Push/PushRegistrar.swift+12 −8native/apple/Sources/EquipoKit/Session/EquipoSession.swift+38 −16native/apple/Sources/EquipoKit/Session/SignInLifetime.swift+67 −0native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift+38 −16native/apple/Tests/EquipoKitTests/OficinaIDTests.swift+154 −7native/apple/Tests/EquipoKitTests/PushTests.swift+14 −0native/apple/Tests/EquipoKitTests/SessionTests.swift+1 −1native/apple/Tests/EquipoKitTests/SetAsideTests.swift+1 −1native/apple/Tests/EquipoKitTests/SignInLifetimeTests.swift+27 −0native/scripts/check-native.sh+1 −0native/scripts/check-sign-in-lifetime.py+32 −0
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__oficina-id: Type Size Avail | ext4 96G 87G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 87G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.7s
ci-box: codex: fetched and verified in 3.4s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 10.0s
ci-box: pi: installed and verified in 7.5s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.8s
ci-box: clone deepened in 3.4s
ci-box: file times set from content: 2814 files, 185 directories
ci-box: ready in 16.9s
=== 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.247s
=== 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.2s
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 1m19.692s 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 1m18.154s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m18.15s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 45.54, cpu waiting 21.56%, memory waiting 0.00%, io waiting 0.58%
--- 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 1m21.609s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m19.975s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m19.97s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 43.58, cpu waiting 21.56%, 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.157s 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.111s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m10.7s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.76s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.65s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 43.58, cpu waiting 21.08%, memory waiting 0.00%, io waiting 0.56%
--- 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 1m18.442s 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 1m16.896s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.14s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 20.01s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.34s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.4s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 45.54, cpu waiting 21.78%, memory waiting 0.00%, io waiting 0.60%
--- 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.868s 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.156s amadan.net/oficina/equipo/internal/headless
receipt: slow test 59.31s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.89s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 9.68s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 8.54s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.74s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 39.10, cpu waiting 17.16%, memory waiting 0.00%, io waiting 0.44%
--- 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 3m15.545s 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 3m13.458s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m43.03s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 23.84s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 20.47s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 8.06s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.29s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 10.79, cpu waiting 3.38%, memory waiting 0.00%, io waiting 0.08%
--- 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 387ms 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 2m2.804s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 8.14s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.79s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 3.81s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.61s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 2.56s amadan.net/oficina/equipo/internal/thintest TestResearchDoneFallsBack
machine: 32 CPUs, load 1.21, cpu waiting 0.07%, memory waiting 0.00%, io waiting 2.19%
--- shard 7 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest-contract: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest
receipt: test step 386ms 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 1m25.558s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.2s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 5.1s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.49s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.44s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotNow
receipt: slow test 2.37s amadan.net/oficina/equipo/internal/thintest TestContractPreview
machine: 32 CPUs, load 1.21, cpu waiting 0.07%, memory waiting 0.00%, io waiting 2.19%
--- 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 4m30.044s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 4m43.052s 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 4m30.044s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.96s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.95s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.77s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.45s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 6.99s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 3.22, cpu waiting 0.77%, 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.841s 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.689s amadan.net/oficina/equipo/internal/runner
receipt: slow test 26.66s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 44.13, cpu waiting 21.95%, memory waiting 0.00%, io waiting 1.00%
--- 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.91s 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.951s amadan.net/oficina/equipo/internal/runner
receipt: slow test 35.9s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 32.48s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.39s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.64s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 44.13, cpu waiting 21.95%, memory waiting 0.00%, io waiting 1.00%
--- 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.974s 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 34.119s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.72s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.11s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 1.9s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 31.52, cpu waiting 15.54%, memory waiting 0.00%, io waiting 1.22%
--- 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 27.6%, load 26.43
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 1m4.41s 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 1m2.625s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.59s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 26.5s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 24.66s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.13s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 21.75s amadan.net/oficina/equipo/internal/equipotest TestAuthorityUsesLiveRoster
machine: 32 CPUs, load 39.10, cpu waiting 17.71%, memory waiting 0.00%, io waiting 0.46%
--- 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 27.6%, load 26.43
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 451ms 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 1m15.284s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 20.04s amadan.net/oficina/equipo/internal/equipotest TestProjectConcurrentRetry
receipt: slow test 20.04s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 20s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 20s amadan.net/oficina/equipo/internal/equipotest TestProjectRequestActorAndUpdate
receipt: slow test 19.89s amadan.net/oficina/equipo/internal/equipotest TestProjectsAccountRevisionAndValidation
machine: 32 CPUs, load 26.43, cpu waiting 11.33%, memory waiting 0.00%, io waiting 1.35%
--- 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 27.6%, load 26.43
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.698s 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 1m4.036s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 14.76s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.16s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.14s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.1s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.03s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 34.48, cpu waiting 14.56%, memory waiting 0.00%, io waiting 0.37%
--- 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 27.6%, load 26.43
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 515ms 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.827s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 25.88s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 24.88s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 24.85s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 23.08s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsCurrentOwner
receipt: slow test 23.04s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsUpgrade
machine: 32 CPUs, load 26.43, cpu waiting 11.33%, memory waiting 0.00%, io waiting 1.35%
--- 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 27.6%, load 26.43
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 694ms 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 53.424s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.82s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.59s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.72s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.57s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.27s amadan.net/oficina/equipo/internal/plan3test TestInviteMigration
machine: 32 CPUs, load 31.52, cpu waiting 11.33%, memory waiting 0.00%, io waiting 1.35%
--- 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 27.6%, load 26.43
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/copydesk: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/opencode: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude: 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 28.353s, 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 15.717s, 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 12.903s, 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 44.976s, 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 19.39s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/runner/containment took 39.193s, over the 15s its record on line 40 allows; reported only, timing fails on CI
receipt: test step 2m14.812s 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 54.08s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 52.396s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 44.976s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 39.193s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 37.344s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow test 21.52s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 21.19s amadan.net/oficina/equipo/cmd/equipo-runner TestReleaseRunnerHasNoFakeWorker
receipt: slow test 14.94s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringOfflineGo
receipt: slow test 12.6s amadan.net/oficina/equipo/internal/idtest TestIDCallbackGuardAndPendingNonce
receipt: slow test 9.12s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringMissingModuleCache
machine: 32 CPUs, load 13.99, cpu waiting 5.40%, 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m22.326s 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.739s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.48s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 15.08s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.09s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.62s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.03s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 43.58, cpu waiting 21.08%, memory waiting 0.00%, io waiting 0.56%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m30.999s 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.368s amadan.net/oficina/equipo/internal/headless
receipt: slow test 25.95s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 22.09s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 13.81s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 10s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 7.78s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 39.10, cpu waiting 18.28%, memory waiting 0.00%, io waiting 0.47%
--- 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 1m39.857s 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.412s amadan.net/oficina/equipo/internal/headless
receipt: slow test 13.71s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.26s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 12.91s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 10.26s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.16s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 34.48, cpu waiting 16.06%, memory waiting 0.00%, io waiting 0.41%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserCopyContinue
=== RUN TestBrowserCopyContinue
time=2026-11-20T21:16:32.684Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T21:16:32.684Z level=INFO msg="startup phase done" phase=state_lock took=214µs
time=2026-11-20T21:16:32.684Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T21:16:32.684Z level=INFO msg="startup phase done" phase=claim_roots took=158µs
time=2026-11-20T21:16:32.684Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T21:16:32.736Z level=INFO msg="startup phase done" phase=sweep took=51.319ms
time=2026-11-20T21:16:32.736Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T21:16:32.736Z level=INFO msg="startup phase done" phase=credentials took=244µs
time=2026-11-20T21:16:32.736Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T21:16:32.790Z level=INFO msg="startup phase done" phase=open_state took=53.801ms
time=2026-11-20T21:16:32.791Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T21:16:32.791Z level=INFO msg=connecting host=127.0.0.1:44855 protocol=28
time=2026-11-20T21:16:32.794Z level=INFO msg=connected host=127.0.0.1:44855 took=2.534ms
time=2026-11-20T21:16:32.794Z level=INFO msg="capabilities gathering"
time=2026-11-20T21:16:32.797Z level=INFO msg="capabilities gathered" took=2.834ms tags=linux,claude,go
time=2026-11-20T21:16:32.797Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T21:16:32.805Z level=INFO msg=welcome protocol=28 role=primary generation=1
browser_copy_test.go:93: continue did not reach Checks: 0 <nil>
--- FAIL: TestBrowserCopyContinue (1.88s)
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN TestBrowserEmptyExplore
time=2026-11-20T21:17:03.594Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-20T21:17:03.594Z level=INFO msg="startup phase done" phase=state_lock took=67µs
time=2026-11-20T21:17:03.594Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-20T21:17:03.594Z level=INFO msg="startup phase done" phase=claim_roots took=90µs
time=2026-11-20T21:17:03.594Z level=INFO msg="startup phase" phase=sweep
time=2026-11-20T21:17:03.631Z level=INFO msg="startup phase done" phase=sweep took=36.976ms
time=2026-11-20T21:17:03.631Z level=INFO msg="startup phase" phase=credentials
time=2026-11-20T21:17:03.631Z level=INFO msg="startup phase done" phase=credentials took=103µs
time=2026-11-20T21:17:03.631Z level=INFO msg="startup phase" phase=open_state
time=2026-11-20T21:17:03.671Z level=INFO msg="startup phase done" phase=open_state took=39.857ms
time=2026-11-20T21:17:03.671Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-20T21:17:03.672Z level=INFO msg=connecting host=127.0.0.1:40059 protocol=28
time=2026-11-20T21:17:03.674Z level=INFO msg=connected host=127.0.0.1:40059 took=1.16ms
time=2026-11-20T21:17:03.674Z level=INFO msg="capabilities gathering"
time=2026-11-20T21:17:03.674Z level=INFO msg="capabilities gathered" took=634µs tags=linux,claude,go
time=2026-11-20T21:17:03.675Z level=INFO msg="hello sent" protocol=28
time=2026-11-20T21:17:03.679Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-20T21:17:04.665Z level=INFO msg="connection checked" connection=claude-1 state=healthy
browser_receipts_test.go:169: waiting for [...document.querySelectorAll('[equipo-markdown]:not([data-stream-text])')].some(e=>e.textContent.includes("I'm your coordinator")): context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserEmptyExplore (5.78s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m26.07s
FAIL amadan.net/oficina/equipo/internal/headless 86.336s
receipt: test step 1m27.446s 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.07s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 10.94s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.41s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 10.36s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 7.88s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserCopyContinue$|^TestBrowserEmptyExplore$' -count=1 ./internal/headless (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserCopyContinue browser-headless-rest c763f4afd4fb01d1200388d574d75fe0287e2e3f 1.88s 41.29
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
##############################################################################
FLAKE ./internal/headless:TestBrowserEmptyExplore browser-headless-rest c763f4afd4fb01d1200388d574d75fe0287e2e3f 5.78s 41.29
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 36.61, cpu waiting 16.06%, memory waiting 0.00%, io waiting 0.41%
--- 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 306ms 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 573ms amadan.net/oficina/equipo/internal/equipo
receipt: slow test 570ms 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 223ms 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.697s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 1.7s 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 213ms 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.893s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 1.89s 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 309ms 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 3m25.942s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 17.9s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.35s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.07s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.74s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 8.26s amadan.net/oficina/equipo/internal/thintest TestBrowserInnerScreens
machine: 32 CPUs, load 7.04, cpu waiting 1.31%, memory waiting 0.00%, io waiting 2.15%
--- 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.25s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.25s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.20s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.99s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.82s
+ 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 (54s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 14.13s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 12.52s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 11.12s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 13.86s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (22s)
ok ./internal/headless TestMixedVersions 20.29s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (1s)
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.06s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 42.28, cpu waiting 22.40%, memory waiting 0.00%, io waiting 0.90%
--- 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.318s 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.146s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 176ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 74ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 4ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 0s amadan.net/oficina/equipo/internal/runner/provider/gotoolchain
receipt: slow test 5.13s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.65s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 270ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 170ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 70ms amadan.net/oficina/equipo/internal/runner/provider/codex TestDirectJournalAdapterBarrier
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.026s 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.714s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 280ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 15.73, cpu waiting 4.23%, memory waiting 0.00%, io waiting 1.88%
--- 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 27.6%, load 26.43
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2527 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.509s
machine: 32 CPUs, load 44.13, cpu waiting 21.40%, memory waiting 0.00%, io waiting 1.03%
--- 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 27.6%, load 26.43
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 31.52, cpu waiting 12.86%, memory waiting 0.00%, io waiting 1.30%
--- 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 27.6%, load 26.43
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 35.65, cpu waiting 15.54%, memory waiting 0.00%, io waiting 1.22%
--- 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.6%, load 26.43
shard 28: make gitleaks
[90m9:16PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m9:16PM[0m [32mINF[0m [1m1067 commits scanned.[0m
[90m9:16PM[0m [32mINF[0m [1mscanned ~60717073 bytes (60.72 MB) in 14.1s[0m
[90m9:16PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 43.36, cpu waiting 20.74%, memory waiting 0.00%, io waiting 1.06%
=== 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.061ms, worst 1.286ms, budget 150ms
perf: GET /api/runner/protocol: median 78µs, worst 124µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 596µs, worst 666µs, budget 150ms
perf: GET /api/v1/accounts: median 441µs, worst 470µs, budget 150ms
perf: GET /api/v1/auth/devices: median 459µs, worst 478µs, budget 150ms
perf: GET /api/v1/budgets: median 522µs, worst 548µs, budget 150ms
perf: GET /api/v1/capabilities: median 273µs, worst 298µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.275ms, worst 1.332ms, budget 150ms
perf: GET /api/v1/connections: median 564µs, worst 598µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 543µs, worst 574µs, budget 150ms
perf: GET /api/v1/conversation: median 907µs, worst 950µs, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.384ms, worst 1.471ms, budget 150ms
perf: GET /api/v1/coordinator: median 1.718ms, worst 1.772ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 460µs, worst 468µs, budget 150ms
perf: GET /api/v1/journey: median 7.469ms, worst 7.684ms, budget 150ms
perf: GET /api/v1/me: median 452µs, worst 502µs, budget 150ms
perf: GET /api/v1/me/settings: median 533µs, worst 571µs, budget 150ms
perf: GET /api/v1/needs-you: median 7.189ms, worst 7.339ms, budget 150ms
perf: GET /api/v1/notifications: median 1.62ms, worst 1.7ms, budget 150ms
perf: GET /api/v1/onboarding: median 385µs, worst 433µs, budget 150ms
perf: GET /api/v1/people: median 432µs, worst 472µs, budget 150ms
perf: GET /api/v1/playbooks: median 582µs, worst 615µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 530µs, worst 564µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 810µs, worst 870µs, budget 150ms
perf: GET /api/v1/preferences: median 748µs, worst 813µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 480µs, worst 511µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 583µs, worst 632µs, budget 150ms
perf: GET /api/v1/roster: median 453µs, worst 530µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 425µs, worst 464µs, budget 150ms
perf: GET /api/v1/specialists: median 8.293ms, worst 8.461ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 7.923ms, worst 8.02ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 858µs, worst 906µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.173ms, worst 1.23ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 701µs, worst 758µs, budget 150ms
perf: GET /api/v1/teams: median 432µs, worst 526µs, budget 150ms
perf: GET /api/v1/templates: median 609µs, worst 633µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 468µs, worst 510µs, budget 150ms
perf: GET /auth/callback: median 87µs, worst 102µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.418ms, worst 3.568ms, budget 150ms
perf: GET /auth/verify: median 87µs, worst 115µs, budget 150ms
perf: GET /connections: median 3.946ms, worst 4.747ms, budget 150ms
perf: GET /conversation: median 7.701ms, worst 7.953ms, budget 150ms
perf: GET /conversation/connections: median 255µs, worst 275µs, budget 150ms
perf: GET /conversation/notebook: median 252µs, worst 268µs, budget 150ms
perf: GET /conversation/settings: median 3.949ms, worst 4.051ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 3.603ms, worst 3.667ms, budget 150ms
perf: GET /conversation/settings/connections: median 6.256ms, worst 6.481ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 6.479ms, worst 6.609ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.641ms, worst 3.752ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 4.209ms, worst 6.912ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.519ms, worst 4.618ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.343ms, worst 4.497ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.393ms, worst 3.659ms, budget 150ms
perf: GET /conversation/settings/thinking: median 3.999ms, worst 4.192ms, budget 150ms
perf: GET /housekeeping: median 3.745ms, worst 3.866ms, budget 150ms
perf: GET /invites/new: median 575µs, worst 628µs, budget 150ms
perf: GET /invites/{id}: median 603µs, worst 622µs, budget 150ms
perf: GET /jobs: median 3.214ms, worst 3.277ms, budget 150ms
perf: GET /jobs/{id}: median 4.552ms, worst 4.696ms, budget 150ms
perf: GET /journey: median 10.333ms, worst 11.044ms, budget 150ms
perf: GET /nav/rail: median 2.979ms, worst 3.12ms, budget 150ms
perf: GET /needs-you: median 10.23ms, worst 10.61ms, budget 150ms
perf: GET /onboarding: median 4.093ms, worst 4.346ms, budget 150ms
perf: GET /people: median 3.419ms, worst 3.468ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 5.339ms, worst 5.486ms, budget 150ms
perf: GET /playbooks: median 4.875ms, worst 4.97ms, budget 150ms
perf: GET /playbooks/new: median 4.958ms, worst 5.153ms, budget 150ms
perf: GET /playbooks/{id}: median 4.496ms, worst 4.606ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.644ms, worst 4.885ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 3.957ms, worst 4.059ms, budget 150ms
perf: GET /preferences: median 4.434ms, worst 4.491ms, budget 150ms
perf: GET /preferences/sources/{source}: median 4.259ms, worst 4.438ms, budget 150ms
perf: GET /projects: median 5.072ms, worst 5.184ms, budget 150ms
perf: GET /projects/accounts: median 3.535ms, worst 3.623ms, budget 150ms
perf: GET /projects/new: median 3.515ms, worst 3.596ms, budget 150ms
perf: GET /projects/{id}: median 10.407ms, worst 10.927ms, budget 150ms
perf: GET /projects/{id}/edit: median 3.571ms, worst 3.682ms, budget 150ms
perf: GET /runners/enrol: median 4.674ms, worst 4.832ms, budget 150ms
perf: GET /settings: median 3.392ms, worst 3.531ms, budget 150ms
perf: GET /settings/coordinator: median 5.724ms, worst 7.706ms, budget 150ms
perf: GET /settings/devices: median 3.334ms, worst 3.531ms, budget 150ms
perf: GET /settings/recovery: median 3.571ms, worst 3.768ms, budget 150ms
perf: GET /settings/recovery/release: median 3.495ms, worst 3.592ms, budget 150ms
perf: GET /settings/thinking: median 254µs, worst 259µs, budget 150ms
perf: GET /signin: median 328µs, worst 365µs, budget 150ms
perf: GET /specialists/new: median 3.466ms, worst 3.565ms, budget 150ms
perf: GET /specialists/{key}: median 10.873ms, worst 11.082ms, budget 150ms
perf: GET /specialists/{key}/edit: median 3.643ms, worst 3.71ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 3.728ms, worst 3.822ms, budget 150ms
perf: GET /tasks: median 5.091ms, worst 5.26ms, budget 150ms
perf: GET /tasks/new: median 3.146ms, worst 3.286ms, budget 150ms
perf: GET /tasks/{id}: median 5.57ms, worst 8.199ms, budget 150ms
perf: GET /tasks/{id}/merge: median 5.181ms, worst 5.265ms, budget 150ms
perf: GET /tasks/{id}/move: median 4.69ms, worst 4.859ms, budget 150ms
perf: GET /tasks/{id}/plan: median 5.846ms, worst 6.307ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.565ms, worst 1.638ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 5.267ms, worst 5.408ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 4.93ms, worst 5ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4.418ms, worst 4.588ms, budget 150ms
perf: GET /tasks/{id}/thread: median 8.278ms, worst 8.429ms, budget 150ms
perf: GET /team/{specialist}: median 4.278ms, worst 4.434ms, budget 150ms
perf: GET /teams: median 10.363ms, worst 11.043ms, budget 150ms
perf: GET /templates: median 3.362ms, worst 3.497ms, budget 150ms
perf: GET /usage: median 4.077ms, worst 4.216ms, budget 150ms
perf: GET /work: median 3.065ms, worst 3.216ms, budget 150ms
perf: cold boot: median 259ms of [257.600266ms 258.526525ms 260.950796ms], budget 500ms
receipt: test step 30.291s 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.89s 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.06s 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: 2.64 GiB in 19802 files
ci-box: module cache /home/ci/work/repos/oficina__equipo/cache/go-mod: 0.84 GiB in 27348 files
diff --git a/native/OFICINA-ID-REPORT.md b/native/OFICINA-ID-REPORT.md| index 02b32549..8f4f05b0 100644 |
| --- a/native/OFICINA-ID-REPORT.md |
| +++ b/native/OFICINA-ID-REPORT.md |
| @@ -282,3 +282,114 @@ Flagged rows: |
| | `oficina.retry` | Duplicates the sign-in kit's “Try again” label. | |
| Changed: 3. Flagged: 3. Left alone: 2. |
| + |
| + |
| +## Shared sign-in lifetime review |
| + |
| +Astra's re-review of `f90cf412` found two further crossings of the sign-in |
| +boundary: cancelled pairing could persist a late exchange or `/me` answer, |
| +and a departed card-answer retry could borrow the bearer of a later sign-in |
| +to the same identity and team. |
| + |
| +Before implementation, the new reproductions failed with 19 assertions across |
| +two tests (the pairing test has four cases: exchange or `/me`, each with and |
| +without signing out after switching to Oficina ID). The persistence source |
| +check also failed because there was no common guarded commit boundary. |
| + |
| +`SignInLifetime` now represents authority for one sign-in. `SignInLifetimes` |
| +is shared through `DeviceAccounts` by pairing, Oficina ID and the app model. |
| +Beginning another sign-in ends the previous token. Pairing captures its token |
| +synchronously when Start is tapped, before scheduling its task. An approved |
| +pairing hands that same token to the conversation. Native renewal retains its |
| +token; identity/team/origin changes, cancellation, replacement and sign-out end |
| +it. A token cannot be reactivated. |
| + |
| +Every Equipo-owned write of a device, private key, account index or sign-in |
| +route goes through `DeviceAccounts.commit`. The raw store is private. Commit |
| +requires the captured token to be both active and the current token. Its check |
| +and writes are synchronous on MainActor. Removal also matches the saved private |
| +key, so cleanup cannot remove another sign-in's saved account at the same |
| +origin. The pinned kit continues to own its shared identity store and its own |
| +epoch checks; Equipo does not write that store directly. |
| + |
| +Bound async flows: |
| + |
| +- Pairing start, challenge retries, exchange polling, credential persistence, |
| + authenticated `/me`, and metadata persistence. |
| +- Native startup/restore, selection callbacks, Home renewal, rejection recovery, |
| + native device registration and credential installation. |
| +- Snapshot/task/Needs you refresh, metadata persistence, stream setup and |
| + consumption, reconnects and queued refreshes. |
| +- Message and thread sends, waiting-message delivery, card answers, Set aside |
| + and Undo retries, and turn cancellation. |
| +- Retained clients and credential providers. Both the transport and its provider |
| + capture the original token; matching the same identity/team after another |
| + sign-in cannot authorize them. |
| +- Session renewal/adoption, foreground continuation and push attachment. Push |
| + registration passes also retain the lifetime alongside their existing |
| + generation check. A queued old attachment cannot replace the new session. |
| + |
| +A scene's daily clock is an app-level scheduler: each renewal it starts captures |
| +the then-current token, while an already running renewal retains its original |
| +token. Old registration/renewal tasks cannot clear a newer task's coalescing |
| +slot because those slots have distinct task IDs. |
| + |
| +Late pairing exchanges and native device mints are decoded so their abandoned |
| +credentials can be revoked best effort. Revocation is the sole network cleanup |
| +allowed after a lifetime ends: `DeviceRevocation` uses only the abandoned |
| +credential, never a current credential provider, and never persists anything. |
| +Cancelling after a pairing credential arrived also schedules revocation at once. |
| + |
| +Additional regressions cover cancellation without a replacement sign-in, |
| +ended/foreign persistence tokens, late transport responses and later requests, |
| +both write retry loops stopping without a sleep, a retained provider refusing a |
| +later sign-in's bearer, late push attachment, and abandoned native revocation. |
| +`check-sign-in-lifetime.py` is part of the native gate. It rejects raw store or |
| +Keychain writes outside the approved boundary and rejects an unguarded commit. |
| + |
| +Mutation commands use `swift test --package-path native/apple --filter` with |
| +the listed regression, or `python3 native/scripts/check-sign-in-lifetime.py`. |
| +Each mutation must produce an assertion failure, not a compiler error, and is |
| +restored before the gate: |
| + |
| +| Mutation | Regression | |
| +| --- | --- | |
| +| Pairing cancellation leaves token active | cancellingPairingAloneEndsItsLifetime | |
| +| New lifetime leaves previous token active | endedTransportRefusesLateResponsesAndNewRequests | |
| +| Commit skips lifetime validation | endedOrForeignLifetimesCannotPersistAnything | |
| +| Provider ignores captured lifetime | departedWriteCannotRetryWithALaterSignInsBearer | |
| +| Answer/visibility retries ignore ended lifetime | endedWriteLoopsDoNotWaitOrRetry | |
| +| Abandoned pairing is not revoked | cancelledPairingCannotOverwriteNativeSignIn | |
| +| Abandoned native device is not revoked | lateRenewalCannotRestoreSignedOutDevice | |
| +| Push attach accepts an ended lifetime | lateAttachCannotReplaceTheNextSignIn | |
| +| Transport ignores lifetime | endedTransportRefusesLateResponsesAndNewRequests | |
| +| Source has unguarded commit | check-sign-in-lifetime.py | |
| +| Source adds raw secret-store write | check-sign-in-lifetime.py | |
| +| Source adds another writer inside DeviceAccounts | check-sign-in-lifetime.py | |
| +| Native sign-out leaves onboarding token active | signOutBeforeRegistrationEndsThePendingLifetime | |
| +| App sign-out leaves onboarding token active | signOutBeforeRegistrationEndsThePendingLifetime | |
| +| Session removal ends the gate before forgetting | signingOutAfterTheSessionEndsStillForgetsItsCredential | |
| + |
| +The early sign-out regression first failed at both entry points, then passed. |
| +Cancellation-alone also tests signing out while pairing is pending, ensuring |
| +its staged key is removed before the token ends. All fifteen deliberate |
| +mutations failed their assertions and were restored. Evidence is in the ignored |
| +`native/build/logs/lifetime-*` logs, including the two mutation result files. |
| + |
| +No user-facing strings changed in this review. Luna's approved copy above is |
| +unchanged. Signed-device and shared-Keychain launch checks remain with the |
| +controller; this work does not touch actual profiles, identities or Keychains. |
| + |
| +The final audit also reproduced sign-out after session removal: ending the token |
| +before forgetting could correctly reject the later cleanup write. Session removal, |
| +account switching and pairing fallback now forget through the still-valid token, |
| +then end it. Terminal engine authentication failure likewise removes its saved |
| +credential before invalidation. No stale-token exception was added to commit. |
| + |
| + |
| +Final lifetime gate: `native/scripts/check-native.sh` passed with 128 tests in |
| +15 Swift suites, both native builds, the lifetime persistence scan, 7 fixtures, |
| +169 strings, 23 parity entries and a clean reference scan. The loopback native |
| +exchange test passed again. The existing push sign-out regression also passes: |
| +notification cleanup still runs when sessionEnded is called with no session, |
| +while a nested coordinator callback is handled only once. |
diff --git a/native/apple/Sources/EquipoKit/OficinaID/EquipoOficinaID.swift b/native/apple/Sources/EquipoKit/OficinaID/EquipoOficinaID.swift| index b968ea84..7f768ee5 100644 |
| --- a/native/apple/Sources/EquipoKit/OficinaID/EquipoOficinaID.swift |
| +++ b/native/apple/Sources/EquipoKit/OficinaID/EquipoOficinaID.swift |
| @@ -13,18 +13,19 @@ public final class EquipoOficinaID { |
| public private(set) var busy = false |
| public private(set) var account: DeviceAccount? |
| public var suspended = false |
| - @ObservationIgnored var onAccount: ((DeviceAccount, EquipoTransport) -> Void)? |
| + @ObservationIgnored var onAccount: ((DeviceAccount, EquipoTransport, SignInLifetime) -> Void)? |
| @ObservationIgnored var onLeave: (() -> Void)? |
| @ObservationIgnored private var watch: AnyCancellable? |
| - @ObservationIgnored private var registration: (OficinaSignedIn, Task<Void, Never>)? |
| + @ObservationIgnored private var registration: (state: OficinaSignedIn, lifetime: SignInLifetime, id: UUID, task: Task<Void, Never>)? |
| @ObservationIgnored public private(set) var cleanup: Task<Void, Never>? |
| - @ObservationIgnored private var renewal: Task<Void, Never>? |
| + @ObservationIgnored private var renewal: (id: UUID, task: Task<Void, Never>)? |
| private let accounts: DeviceAccounts |
| private let makeTransport: @Sendable (URL) -> EquipoTransport |
| private let label: () -> String |
| private let now: @Sendable () -> Date |
| private var started = false |
| - private var epoch = 0 |
| + private var lifetime: SignInLifetime? |
| + private var selected: String? |
| private var lastRejection: Date? |
| private var identityID: String? |
| @@ -42,6 +43,7 @@ public final class EquipoOficinaID { |
| now: @escaping @Sendable () -> Date = Date.init, label: @escaping () -> String) { |
| self.model = model; self.accounts = accounts; self.makeTransport = makeTransport |
| self.now = now; self.label = label |
| + lifetime = accounts.lifetimes.current |
| watch = model.$step.sink { [weak self] step in |
| self?.stepChanged(step) |
| } |
| @@ -51,17 +53,20 @@ public final class EquipoOficinaID { |
| guard !started else { return } |
| started = true |
| if suspended { model.suspendStraightIn() } |
| + let lifetime = accounts.lifetimes.current |
| await model.start() |
| + guard lifetime.isActive else { return } |
| // Another app may have signed this identity out while Equipo was |
| // closed. A successful negative lookup removes its background bearer; |
| // an unreadable Keychain leaves it alone. |
| for saved in accounts.all() { |
| if let identity = saved.oficinaIdentity, (try? model.store.hasIdentity(identity)) == false { |
| - accounts.remove(saved.origin) |
| + try? accounts.commit(.remove(saved), lifetime: lifetime) |
| Task { await self.revoke(saved) } |
| } |
| } |
| await model.refreshTeams() |
| + guard lifetime.isActive else { return } |
| await synchronize() |
| } |
| @@ -73,41 +78,62 @@ public final class EquipoOficinaID { |
| forget(identityID) |
| } |
| switch step { |
| - case .signedIn: |
| - Task { [weak self] in await self?.synchronize() } |
| + case .signedIn(let state): |
| + guard !suspended else { return } |
| + let selection = state.identity.id + "|" + state.team.sqid + "|" + state.origin.absoluteString |
| + if selected != nil && selected != selection || lifetime?.isActive != true || lifetime !== accounts.lifetimes.current { |
| + onLeave?() |
| + lifetime?.end() |
| + registration?.task.cancel(); registration = nil |
| + renewal?.task.cancel(); renewal = nil |
| + lastRejection = nil; busy = false |
| + lifetime = accounts.lifetimes.begin() |
| + } |
| + selected = selection |
| + guard let lifetime else { return } |
| + Task { [weak self] in |
| + guard lifetime.isActive else { return } |
| + await self?.synchronize() |
| + } |
| case .loading, .unavailable: break // Keep the conversation over an outage. |
| default: |
| - if account != nil { epoch += 1; account = nil; onLeave?() } |
| + if selected != nil { |
| + onLeave?() |
| + lifetime?.end(); lifetime = nil; selected = nil |
| + account = nil |
| + } |
| } |
| } |
| /// Also called after model actions, so their callers can await the bridge. |
| public func synchronize() async { |
| - guard !suspended, case .signedIn(let state) = model.step else { return } |
| + guard !suspended, let lifetime, lifetime.isActive, case .signedIn(let state) = model.step else { return } |
| identityID = state.identity.id |
| - if let registration, registration.0 == state { await registration.1.value; return } |
| - let epoch = self.epoch |
| + if let registration, registration.state == state, registration.lifetime === lifetime { |
| + await registration.task.value; return |
| + } |
| + let id = UUID() |
| let waiting = Task { [weak self] in |
| guard let self else { return } |
| - await self.register(state, epoch: epoch) |
| + await self.register(state, lifetime: lifetime) |
| } |
| - registration = (state, waiting) |
| + registration = (state, lifetime, id, waiting) |
| await waiting.value |
| - if registration?.0 == state { registration = nil } |
| + if registration?.id == id { registration = nil } |
| } |
| - private func register(_ state: OficinaSignedIn, epoch: Int) async { |
| + private func register(_ state: OficinaSignedIn, lifetime: SignInLifetime) async { |
| let hash = Self.hash(state.session.value) |
| if let saved = accounts.all().first(where: { |
| $0.origin == state.origin && $0.oficinaIdentity == state.identity.id && $0.oficinaTeam == state.team.sqid |
| && $0.oficinaSessionHash == hash && $0.isUsable(now: now()) |
| }) { |
| - guard current(state, epoch: epoch) else { return } |
| - install(saved) |
| + guard current(state, lifetime: lifetime) else { return } |
| + install(saved, lifetime: lifetime) |
| return |
| } |
| busy = true; error = nil |
| - defer { busy = false } |
| + defer { if self.lifetime === lifetime { busy = false } } |
| // Fresh Curve25519 signing key, exactly as pairing creates one. |
| var next = DeviceAccount.new(origin: state.origin, label: label()) |
| next.oficinaIdentity = state.identity.id |
| @@ -116,117 +142,142 @@ public final class EquipoOficinaID { |
| next.teamName = state.team.name |
| let previous = accounts.all().first { $0.origin == state.origin } |
| do { |
| + try lifetime.check() |
| let body = try EquipoJSON.encoder.encode(["public_key": try next.publicKey(), "label": next.label]) |
| let transport = makeTransport(state.origin) |
| next.credential = try await EquipoClient(transport: transport, token: nil).send( |
| APIRequest("POST", "/auth/devices/native", body: body, nativeSession: state.session)) |
| - guard current(state, epoch: epoch) else { await revoke(next); return } |
| - do { try accounts.save(next) } |
| + guard current(state, lifetime: lifetime) else { await revoke(next); return } |
| + do { try accounts.commit(.save(next), lifetime: lifetime) } |
| catch { await revoke(next); throw error } |
| - install(next) |
| + install(next, lifetime: lifetime) |
| if let previous, previous.credential?.id != next.credential?.id { |
| Task { await self.revoke(previous) } |
| } |
| } catch { |
| - guard current(state, epoch: epoch) else { return } |
| + guard current(state, lifetime: lifetime) else { return } |
| self.error = String(localized: "oficina.device_failed", bundle: .module) |
| if let api = error as? EquipoAPIError, api.status == 401 || api.status == 403, |
| lastRejection.map({ now().timeIntervalSince($0) >= 60 }) ?? true { |
| lastRejection = now() |
| await model.refreshTeams(maxAge: 0) |
| - guard current(state, epoch: epoch) else { return } |
| + guard current(state, lifetime: lifetime) else { return } |
| await model.sessionRejected() |
| // A new kit session gets a new registration. Never await our |
| // own in-flight registration when Home left the step unchanged. |
| - if model.step != .signedIn(state) { await synchronize() } |
| + if lifetime.isActive, model.step != .signedIn(state) { await synchronize() } |
| } |
| } |
| } |
| - private func current(_ state: OficinaSignedIn, epoch: Int) -> Bool { |
| - !suspended && self.epoch == epoch && model.step == .signedIn(state) |
| + private func current(_ state: OficinaSignedIn, lifetime: SignInLifetime) -> Bool { |
| + !suspended && lifetime.isActive && self.lifetime === lifetime && model.step == .signedIn(state) |
| } |
| - private func install(_ next: DeviceAccount) { |
| + private func install(_ next: DeviceAccount, lifetime: SignInLifetime) { |
| + guard lifetime.isActive else { return } |
| error = nil |
| guard account != next else { return } |
| account = next |
| let origin = next.origin, identity = next.oficinaIdentity, team = next.oficinaTeam |
| - let transport = EquipoRenewingTransport(inner: makeTransport(origin), credential: { [weak self] in |
| - guard let self, !self.suspended, self.model.identity?.id == identity, |
| + let transport = EquipoRenewingTransport(inner: makeTransport(origin), lifetime: lifetime, credential: { [weak self] in |
| + guard let self, lifetime.isActive, self.lifetime === lifetime, !self.suspended, self.model.identity?.id == identity, |
| let current = self.account, current.origin == origin, current.oficinaTeam == team else { return nil } |
| return current.credential?.token |
| - }, rejected: { [weak self] in await self?.rejected() }) |
| - onAccount?(next, transport) |
| + }, rejected: { [weak self] in |
| + guard lifetime.isActive else { return } |
| + await self?.rejected() |
| + }) |
| + onAccount?(next, transport, lifetime) |
| } |
| public func renewIfNeeded() async { |
| - guard !suspended else { return } |
| - if let renewal { await renewal.value; return } |
| + guard !suspended, let lifetime, lifetime.isActive else { return } |
| + if let renewal { await renewal.task.value; return } |
| + let id = UUID() |
| let task = Task { |
| + guard lifetime.isActive else { return } |
| if case .unavailable = model.step { await model.retry() } |
| else { await model.renewIfNeeded() } |
| + guard lifetime.isActive else { return } |
| await synchronize() |
| } |
| - renewal = task |
| + renewal = (id, task) |
| await task.value |
| - renewal = nil |
| + if renewal?.id == id { renewal = nil } |
| } |
| - /// Coalesced and limited to once a minute, including a refused re-mint. |
| - /// A sustained 403 must not create a loop of Home assertions. |
| + /// Coalesced and limited to once a minute within the same sign-in. |
| func rejected() async { |
| - guard !suspended else { return } |
| - if let renewal { await renewal.value; return } |
| + guard !suspended, let lifetime, lifetime.isActive else { return } |
| + if let renewal { await renewal.task.value; return } |
| if let lastRejection, now().timeIntervalSince(lastRejection) < 60 { return } |
| lastRejection = now() |
| + let id = UUID() |
| let task = Task { |
| + guard lifetime.isActive else { return } |
| await model.refreshTeams(maxAge: 0) |
| + guard lifetime.isActive else { return } |
| if case .unavailable = model.step { await model.retry() } |
| else { await model.sessionRejected() } |
| + guard lifetime.isActive else { return } |
| await synchronize() |
| } |
| - renewal = task |
| + renewal = (id, task) |
| await task.value |
| - renewal = nil |
| + if renewal?.id == id { renewal = nil } |
| } |
| /// Leave Equipo's native account locally before any network cleanup. |
| /// The kit may also reach this through Use another or another app's sign-out. |
| private func forget(_ identity: String) { |
| - epoch += 1 |
| - registration?.1.cancel(); registration = nil |
| - renewal?.cancel(); renewal = nil |
| + registration?.task.cancel(); registration = nil |
| + renewal?.task.cancel(); renewal = nil |
| + let removalLifetime = accounts.lifetimes.current |
| let old = accounts.all().filter { $0.oficinaIdentity == identity } |
| - for account in old { accounts.remove(account.origin) } |
| + for account in old { try? accounts.commit(.remove(account), lifetime: removalLifetime) } |
| + lifetime?.end(); lifetime = nil; selected = nil |
| + busy = false |
| account = nil; error = nil; lastRejection = nil |
| onLeave?() |
| cleanup = Task { for account in old { await self.revoke(account) } } |
| } |
| + /// The app removes the conversation while this lifetime still owns its |
| + /// persistence. Forget first; ending the token closes the write gate. |
| + func sessionEnded(lifetime: SignInLifetime) { |
| + guard self.lifetime === lifetime, lifetime.isActive, let identityID else { return } |
| + forget(identityID) |
| + } |
| + |
| public func signOut() { |
| if let identityID { self.identityID = nil; forget(identityID) } |
| + lifetime?.end(); lifetime = nil; selected = nil |
| model.signOut() |
| } |
| public func pause() { |
| - suspended = true; epoch += 1 |
| + suspended = true |
| + if let identityID { forget(identityID) } |
| + lifetime?.end(); lifetime = nil; selected = nil |
| + registration?.task.cancel(); registration = nil |
| + renewal?.task.cancel(); renewal = nil |
| model.suspendStraightIn() |
| - account = nil |
| + account = nil; busy = false; lastRejection = nil |
| } |
| public func resume() async { |
| suspended = false |
| + let lifetime = accounts.lifetimes.begin() |
| + self.lifetime = lifetime |
| + try? accounts.commit(.route("oficina"), lifetime: lifetime) |
| await model.resumeStraightIn() |
| + guard lifetime.isActive else { return } |
| await synchronize() |
| } |
| private func revoke(_ account: DeviceAccount) async { |
| - let client = EquipoClient(transport: makeTransport(account.origin), token: account.credential?.token) |
| - if let id = account.credential?.id, let page = try? await client.devices(), |
| - let device = page.items.first(where: { $0.id == id }) { |
| - _ = try? await client.revokeDevice(id, EquipoClient.empty(ifMatch: device.revision)) |
| - } |
| + await DeviceRevocation.revoke(account, transport: makeTransport(account.origin)) |
| } |
| private static func hash(_ value: String) -> String { Base64URL.encode(Data(SHA256.hash(data: Data(value.utf8)))) } |
diff --git a/native/apple/Sources/EquipoKit/OficinaID/EquipoRenewingTransport.swift b/native/apple/Sources/EquipoKit/OficinaID/EquipoRenewingTransport.swift| index 979574fa..5a65889b 100644 |
| --- a/native/apple/Sources/EquipoKit/OficinaID/EquipoRenewingTransport.swift |
| +++ b/native/apple/Sources/EquipoKit/OficinaID/EquipoRenewingTransport.swift |
| @@ -4,11 +4,13 @@ import Foundation |
| /// retained by a conversation across renewal. Cookies never reach the engine. |
| struct EquipoRenewingTransport: EquipoTransport { |
| let inner: EquipoTransport |
| + let lifetime: SignInLifetime |
| let credential: @MainActor @Sendable () -> String? |
| let rejected: @MainActor @Sendable () async -> Void |
| var origin: URL { inner.origin } |
| private func authorized(_ request: APIRequest) async throws -> APIRequest { |
| + try await lifetime.check() |
| guard let token = await credential() else { throw EquipoAPIError.signedOut } |
| var request = request |
| request.bearer = token |
| @@ -19,6 +21,7 @@ struct EquipoRenewingTransport: EquipoTransport { |
| let first = try await authorized(request) |
| let response = try await inner.send(first) |
| guard response.status == 401 || response.status == 403 else { return response } |
| + try await lifetime.check() |
| await rejected() |
| let retry = try await authorized(request) |
| guard retry.bearer != first.bearer else { |
| @@ -36,6 +39,7 @@ struct EquipoRenewingTransport: EquipoTransport { |
| let first = try await authorized(request) |
| do { return try await inner.lines(first) } |
| catch let error as EquipoAPIError where error.status == 401 || error.status == 403 { |
| + try await lifetime.check() |
| await rejected() |
| let retry = try await authorized(request) |
| guard retry.bearer != first.bearer else { |
diff --git a/native/apple/Sources/EquipoKit/Pairing/DeviceAccount.swift b/native/apple/Sources/EquipoKit/Pairing/DeviceAccount.swift| index 750737e3..bab1b818 100644 |
| --- a/native/apple/Sources/EquipoKit/Pairing/DeviceAccount.swift |
| +++ b/native/apple/Sources/EquipoKit/Pairing/DeviceAccount.swift |
| @@ -30,23 +30,40 @@ public struct DeviceAccount: Codable, Sendable, Equatable { |
| /// The paired teams on this device. Slice 1 uses one; the store keeps the |
| /// list shape so several teams can follow. |
| public struct DeviceAccounts: Sendable { |
| - let store: SecretStore |
| + private let store: SecretStore |
| static let index = "accounts" |
| - public init(store: SecretStore) { self.store = store } |
| + public let lifetimes: SignInLifetimes |
| + @MainActor public init(store: SecretStore) { self.store = store; lifetimes = SignInLifetimes() } |
| + var signInRoute: String? { store.read("signin.route").flatMap { String(data: $0, encoding: .utf8) } } |
| + |
| + public enum Change { |
| + case save(DeviceAccount) |
| + case remove(DeviceAccount) |
| + case route(String) |
| + } |
| public func all() -> [DeviceAccount] { |
| let origins = (store.read(Self.index).flatMap { try? JSONDecoder().decode([URL].self, from: $0) }) ?? [] |
| return origins.compactMap { origin in store.read(origin.absoluteString).flatMap { try? JSONDecoder().decode(DeviceAccount.self, from: $0) } } |
| } |
| - public func save(_ account: DeviceAccount) throws { |
| - try store.write(try JSONEncoder().encode(account), account: account.origin.absoluteString) |
| - var origins = all().map(\.origin) |
| - if !origins.contains(account.origin) { origins.append(account.origin) } |
| - try store.write(try JSONEncoder().encode(origins), account: Self.index) |
| - } |
| - public func remove(_ origin: URL) { |
| - store.remove(origin.absoluteString) |
| - let origins = all().map(\.origin).filter { $0 != origin } |
| - try? store.write((try? JSONEncoder().encode(origins)) ?? Data("[]".utf8), account: Self.index) |
| + /// Every device, private key, index and route write passes this boundary. |
| + /// Check and write are synchronous on MainActor, so ending a lifetime |
| + /// cannot interleave with persistence. Removal also matches the saved key. |
| + @MainActor public func commit(_ change: Change, lifetime: SignInLifetime) throws { |
| + try lifetimes.require(lifetime) |
| + switch change { |
| + case .save(let account): |
| + try store.write(try JSONEncoder().encode(account), account: account.origin.absoluteString) |
| + var origins = all().map(\.origin) |
| + if !origins.contains(account.origin) { origins.append(account.origin) } |
| + try store.write(try JSONEncoder().encode(origins), account: Self.index) |
| + case .remove(let account): |
| + guard all().contains(where: { $0.origin == account.origin && $0.keySeed == account.keySeed }) else { return } |
| + store.remove(account.origin.absoluteString) |
| + let origins = all().map(\.origin).filter { $0 != account.origin } |
| + try store.write(try JSONEncoder().encode(origins), account: Self.index) |
| + case .route(let route): |
| + try store.write(Data(route.utf8), account: "signin.route") |
| + } |
| } |
| } |
diff --git a/native/apple/Sources/EquipoKit/Pairing/Pairing.swift b/native/apple/Sources/EquipoKit/Pairing/Pairing.swift| index 502034d1..6c77d81f 100644 |
| --- a/native/apple/Sources/EquipoKit/Pairing/Pairing.swift |
| +++ b/native/apple/Sources/EquipoKit/Pairing/Pairing.swift |
| @@ -29,6 +29,10 @@ public final class PairingModel { |
| private let sleep: @Sendable (Duration) async throws -> Void |
| private let now: @Sendable () -> Date |
| private var task: Task<Void, Never>? |
| + private(set) var lifetime: SignInLifetime? |
| + private var pendingAccount: DeviceAccount? |
| + private var retiring: Set<Data> = [] |
| + public private(set) var cleanup: Task<Void, Never>? |
| /// The floor the API sets; the server enforces it too. |
| public static let minimumInterval: Duration = .seconds(5) |
| @@ -62,44 +66,83 @@ public final class PairingModel { |
| } |
| public func start(origin: URL, label: String) { |
| - task?.cancel() |
| - task = Task { await run(origin: origin, label: label) } |
| + let lifetime = begin() |
| + task = Task { await run(origin: origin, label: label, lifetime: lifetime) } |
| + } |
| + |
| + private func begin() -> SignInLifetime { |
| + cancel() |
| + let lifetime = accounts.lifetimes.begin() |
| + self.lifetime = lifetime |
| + return lifetime |
| + } |
| + |
| + /// Transfers this exact lifetime to the conversation without ending it. |
| + func handoff() -> SignInLifetime? { |
| + guard let lifetime, lifetime.isActive else { return nil } |
| + self.lifetime = nil; pendingAccount = nil; task = nil |
| + return lifetime |
| + } |
| + |
| + public func cancel() { |
| + if let lifetime { |
| + if let pendingAccount { |
| + try? accounts.commit(.remove(pendingAccount), lifetime: lifetime) |
| + retire(pendingAccount) |
| + } |
| + lifetime.end() |
| + } |
| + task?.cancel(); task = nil; lifetime = nil |
| + pendingAccount = nil; account = nil; step = .enterTeam |
| } |
| - public func cancel() { task?.cancel(); task = nil; step = .enterTeam } |
| func run(origin: URL, label: String) async { |
| + await run(origin: origin, label: label, lifetime: begin()) |
| + } |
| + |
| + private func run(origin: URL, label: String, lifetime: SignInLifetime) async { |
| + guard lifetime.isActive else { return } |
| step = .requesting |
| - // The key is saved before the server hears of it, so a crash after |
| - // the challenge never strands a credential bound to a lost key. |
| var account = accounts.all().first { $0.origin == origin && $0.credential == nil } ?? .new(origin: origin, label: label) |
| + pendingAccount = account |
| do { |
| - try accounts.save(account) |
| + try accounts.commit(.save(account), lifetime: lifetime) |
| let client = EquipoClient(transport: makeTransport(origin), token: nil) |
| let begin = try PendingWrite.json(["public_key": try account.publicKey(), "label": label]) |
| - let challenge: DeviceChallenge = try await retrying { try await client.beginDevice(begin) } |
| + let challenge: DeviceChallenge = try await retrying(lifetime: lifetime) { try await client.beginDevice(begin) } |
| + try lifetime.check() |
| guard let verification = URL(string: challenge.verificationUri), Self.verificationIsTrusted(verification, origin: origin) else { |
| throw PairingError.badChallenge |
| } |
| step = .waiting(code: challenge.userCode, verification: verification, expires: challenge.expiresAt) |
| let proof = try PendingWrite.json(DeviceProof.body(for: challenge, key: try account.signingKey(), nonce: DeviceProof.nonce())) |
| var interval = max(Self.minimumInterval, .seconds(challenge.pollIntervalSeconds)) |
| - while !Task.isCancelled { |
| + while lifetime.isActive && !Task.isCancelled { |
| if now() >= challenge.expiresAt { step = .expired; return } |
| try await sleep(interval) |
| + try lifetime.check() |
| do { |
| - let credential = try await client.exchangeDevice(proof) |
| - account.credential = credential |
| - // The server now holds a live device: keep it before anything else can fail. |
| - try accounts.save(account) |
| + // Decode a late minted credential before checking the |
| + // lifetime so it can be revoked with its own bearer. |
| + account.credential = try await client.exchangeDevice(proof) |
| + guard lifetime.isActive else { retire(account); return } |
| + do { try accounts.commit(.save(account), lifetime: lifetime) } |
| + catch { retire(account); throw error } |
| + pendingAccount = account |
| self.account = account |
| - if let me = try? await EquipoClient(transport: makeTransport(origin), token: credential.token).me() { |
| + let transport = LifetimeTransport(inner: makeTransport(origin), lifetime: lifetime) |
| + let me = try? await EquipoClient(transport: transport, token: account.credential?.token).me() |
| + guard lifetime.isActive else { retire(account); return } |
| + if let me { |
| account.teamName = me.teamName; account.address = me.person.address |
| - try? accounts.save(account) |
| + try accounts.commit(.save(account), lifetime: lifetime) |
| + pendingAccount = account |
| self.account = account |
| } |
| step = .approved(teamName: account.teamName ?? origin.host ?? "") |
| return |
| } catch let error as EquipoAPIError { |
| + try lifetime.check() |
| switch error.code { |
| case "authorization_pending": continue |
| case "slow_down": interval += .seconds(5) |
| @@ -113,20 +156,32 @@ public final class PairingModel { |
| } catch is CancellationError { |
| return |
| } catch let error as EquipoAPIError { |
| + guard lifetime.isActive else { return } |
| step = .failed(Self.describe(error)) |
| } catch { |
| + guard lifetime.isActive else { return } |
| step = .failed(String(localized: "pairing.failed", bundle: .module)) |
| } |
| } |
| - private func retrying<T: Sendable>(_ attempt: @Sendable () async throws -> T) async throws -> T { |
| + private func retrying<T: Sendable>(lifetime: SignInLifetime, _ attempt: @Sendable () async throws -> T) async throws -> T { |
| var tries = 0 |
| while true { |
| + try lifetime.check() |
| do { return try await attempt() } |
| - catch EquipoAPIError.offline where tries < 2 { tries += 1; try await sleep(.seconds(2)) } |
| + catch EquipoAPIError.offline where tries < 2 { |
| + try lifetime.check() |
| + tries += 1; try await sleep(.seconds(2)) |
| + } |
| } |
| } |
| + private func retire(_ account: DeviceAccount) { |
| + guard account.credential != nil, retiring.insert(account.keySeed).inserted else { return } |
| + let transport = makeTransport(account.origin) |
| + cleanup = Task { await DeviceRevocation.revoke(account, transport: transport) } |
| + } |
| + |
| static func describe(_ error: EquipoAPIError) -> String { |
| switch error { |
| case .offline: return String(localized: "pairing.offline", bundle: .module) |
diff --git a/native/apple/Sources/EquipoKit/Push/PushRegistrar.swift b/native/apple/Sources/EquipoKit/Push/PushRegistrar.swift| index 9743851b..c9754d3a 100644 |
| --- a/native/apple/Sources/EquipoKit/Push/PushRegistrar.swift |
| +++ b/native/apple/Sources/EquipoKit/Push/PushRegistrar.swift |
| @@ -14,6 +14,7 @@ public final class PushRegistrar { |
| public private(set) var startToken: String? |
| private var client: EquipoClient? |
| + private var lifetime: SignInLifetime? |
| /// The registration the current session's server has, by bearer. |
| private var accepted: (bearer: String, body: PushRegistrationBody)? |
| /// A registration the server refused as invalid: not sent again as is. |
| @@ -43,8 +44,9 @@ public final class PushRegistrar { |
| /// The paired session's client, or nil once there is none. A new one |
| /// is a new credential: everything is registered with it again. |
| - public func attach(_ client: EquipoClient?) async { |
| - if client?.token != self.client?.token { |
| + public func attach(_ client: EquipoClient?, lifetime: SignInLifetime? = nil) async { |
| + guard lifetime?.isActive != false else { return } |
| + if client?.token != self.client?.token || lifetime !== self.lifetime { |
| generation += 1 |
| // Another session (another team, a new credential, or none): it |
| // keeps only the activities its own instance started. At launch |
| @@ -59,6 +61,7 @@ public final class PushRegistrar { |
| onSessionChanged?() |
| } |
| self.client = client |
| + self.lifetime = lifetime |
| await sync() |
| } |
| @@ -111,16 +114,17 @@ public final class PushRegistrar { |
| } |
| private func pass() async { |
| - guard let client, let bearer = client.token else { return } |
| + let lifetime = self.lifetime |
| + guard lifetime?.isActive != false, let client, let bearer = client.token else { return } |
| let generation = self.generation |
| if let body, !(accepted?.bearer == bearer && accepted?.body == body), !(refused?.bearer == bearer && refused?.body == body) { |
| do { |
| let write = try PendingWrite.json(body) |
| _ = try await client.registerPush(write) |
| - guard generation == self.generation else { return } |
| + guard lifetime?.isActive != false, generation == self.generation else { return } |
| accepted = (bearer, body) |
| } catch let error as EquipoAPIError { |
| - guard generation == self.generation else { return } |
| + guard lifetime?.isActive != false, generation == self.generation else { return } |
| // A refusal is final for this body; anything else waits for the next sync. |
| if let status = error.status, status == 400 || status == 422 { refused = (bearer, body) } |
| return |
| @@ -131,13 +135,13 @@ public final class PushRegistrar { |
| for (task, token) in activities.sorted(by: { $0.key < $1.key }) |
| .filter({ Self.same($0.value.origin, client.origin) }).map({ ($0.key, $0.value.token) }) |
| where acceptedActivities[task] != token && closedActivities[task] != token { |
| - guard generation == self.generation else { return } |
| + guard lifetime?.isActive != false, generation == self.generation else { return } |
| do { |
| try await client.registerActivity(try PendingWrite.json(ActivityTokenBody(taskId: task, token: token))) |
| - guard generation == self.generation else { return } |
| + guard lifetime?.isActive != false, generation == self.generation else { return } |
| acceptedActivities[task] = token |
| } catch let error as EquipoAPIError { |
| - guard generation == self.generation else { return } |
| + guard lifetime?.isActive != false, generation == self.generation else { return } |
| // Ended, or not this person's task: the server will never take it, |
| // and the activity ends here too. |
| if error.status == 404 || error.status == 409 || error.status == 400 { |
diff --git a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift| index 31a35943..024e6ea6 100644 |
| --- a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift |
| +++ b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift |
| @@ -24,7 +24,8 @@ public final class EquipoSession { |
| /// A departing session can never become current again, even if a read |
| /// or credential renewal ignores cancellation and completes later. |
| - private(set) var isInvalidated = false |
| + public let lifetime: SignInLifetime |
| + var isInvalidated: Bool { !lifetime.isActive } |
| public private(set) var status: Status = .loading |
| public private(set) var account: DeviceAccount |
| public private(set) var me: ThinMe? |
| @@ -45,6 +46,7 @@ public final class EquipoSession { |
| public private(set) var client: EquipoClient |
| private let accounts: DeviceAccounts |
| + private var revocationTransport: EquipoTransport |
| private let runner = CoalescedRunner() |
| private var live: Task<Void, Never>? |
| /// Reads asked for by the stream: one runs at a time, and a burst |
| @@ -58,12 +60,16 @@ public final class EquipoSession { |
| private var unsettledVisibility: [String: PendingWrite] = [:] |
| private let sleep: @Sendable (Duration) async throws -> Void |
| - public init(account: DeviceAccount, accounts: DeviceAccounts, transport: EquipoTransport? = nil, |
| + public init(account: DeviceAccount, accounts: DeviceAccounts, transport: EquipoTransport? = nil, lifetime: SignInLifetime? = nil, |
| sleep: @escaping @Sendable (Duration) async throws -> Void = { try await Task.sleep(for: $0) }) { |
| self.account = account |
| self.accounts = accounts |
| self.sleep = sleep |
| - self.client = EquipoClient(transport: transport ?? URLSessionTransport(origin: account.origin), token: account.credential?.token) |
| + let lifetime = lifetime ?? accounts.lifetimes.current |
| + self.lifetime = lifetime |
| + let transport = transport ?? URLSessionTransport(origin: account.origin) |
| + self.revocationTransport = transport |
| + self.client = EquipoClient(transport: LifetimeTransport(inner: transport, lifetime: lifetime), token: account.credential?.token) |
| if !account.isUsable() { status = .signedOut } |
| } |
| @@ -128,7 +134,7 @@ public final class EquipoSession { |
| stopping.formIntersection(liveIDs) |
| if account.teamName != snapshot.me.teamName { |
| account.teamName = snapshot.me.teamName; account.address = snapshot.me.address |
| - try? accounts.save(account) |
| + try? accounts.commit(.save(account), lifetime: lifetime) |
| } |
| } |
| @@ -151,6 +157,7 @@ public final class EquipoSession { |
| while !Task.isCancelled { |
| guard let self, self.status != .signedOut else { return } |
| if self.status == .loading { await self.refresh() } |
| + guard self.lifetime.isActive else { return } |
| do { |
| let lines = try await self.client.events(after: self.cursor) |
| backoff = Backoff() |
| @@ -174,7 +181,7 @@ public final class EquipoSession { |
| /// a change to something the screens show reads them again; the rest |
| /// (runners, connections, pings) is not this app's. |
| func handle(_ line: String) async { |
| - guard line.hasPrefix("data:") else { return } |
| + guard lifetime.isActive, line.hasPrefix("data:") else { return } |
| let json = Data(line.dropFirst(5).trimmingCharacters(in: .whitespaces).utf8) |
| guard let event = try? EquipoJSON.decoder.decode(EventEnvelope.self, from: json) else { return } |
| if let c = event.cursor { cursor = max(cursor, c) } |
| @@ -190,6 +197,7 @@ public final class EquipoSession { |
| /// Reads again soon, without holding up the stream. |
| func requestRefresh() { |
| + guard lifetime.isActive else { return } |
| if pendingRead != nil { readAgain = true; return } |
| pendingRead = Task { [weak self] in |
| guard let self else { return } |
| @@ -240,7 +248,7 @@ public final class EquipoSession { |
| public func send(_ text: String, inThreadOf taskID: String? = nil) async { |
| let text = text.trimmingCharacters(in: .whitespacesAndNewlines) |
| - guard !text.isEmpty, let write = try? EquipoClient.message(text) else { return } |
| + guard lifetime.isActive, !text.isEmpty, let write = try? EquipoClient.message(text) else { return } |
| outgoing.append(Outgoing(id: write.key, text: text, taskID: taskID, state: .sending, write: write)) |
| await deliver(write.key) |
| } |
| @@ -249,12 +257,13 @@ public final class EquipoSession { |
| public func retry(_ id: String) async { await deliver(id) } |
| private func deliver(_ id: String) async { |
| - guard let index = outgoing.firstIndex(where: { $0.id == id }) else { return } |
| + guard lifetime.isActive, let index = outgoing.firstIndex(where: { $0.id == id }) else { return } |
| outgoing[index].state = .sending |
| let item = outgoing[index] |
| do { |
| if let taskID = item.taskID { |
| let entry = try await client.postThread(task: taskID, item.write) |
| + guard lifetime.isActive else { return } |
| if let i = tasks.firstIndex(where: { $0.id == taskID }) { |
| var thread = tasks[i].thread ?? [] |
| if !thread.contains(where: { $0.id == entry.id }) { thread.append(entry) } |
| @@ -262,15 +271,18 @@ public final class EquipoSession { |
| } |
| } else { |
| let sent = try await client.send(item.write) |
| + guard lifetime.isActive else { return } |
| messages = Self.merge(messages, [sent.message]) |
| turns = Self.merge(turns, [sent.turn]) |
| } |
| outgoing.removeAll { $0.id == id } |
| await refresh() |
| } catch let error as EquipoAPIError { |
| + guard lifetime.isActive else { return } |
| if error.endsSession { endSession(); return } |
| if let i = outgoing.firstIndex(where: { $0.id == id }) { outgoing[i].state = error == .offline ? .waiting : .failed } |
| } catch { |
| + guard lifetime.isActive else { return } |
| // Cancelled on the way: it may yet be sent, as itself. |
| if let i = outgoing.firstIndex(where: { $0.id == id }) { outgoing[i].state = error is CancellationError ? .waiting : .failed } |
| } |
| @@ -289,19 +301,23 @@ public final class EquipoSession { |
| /// Answers a card as the person saw it, bound to that revision. A lost |
| /// answer is retried as itself; a stale one is never sent again. |
| public func answer(_ card: ThinCard, choice: String, note: String? = nil) async -> AnswerOutcome { |
| + guard lifetime.isActive else { return .failed } |
| guard card.isOpen else { return .changed } |
| let slot = "\(card.id)#\(card.revision)#\(choice)#\(note ?? "")" |
| guard let write = unsettledAnswers[slot] ?? (try? EquipoClient.answer(choice, note: note, to: card)) else { return .failed } |
| unsettledAnswers[slot] = write |
| var attempts = 0 |
| while true { |
| + guard lifetime.isActive else { return .failed } |
| do { |
| let answered = try await client.answer(card: card.id, write) |
| + guard lifetime.isActive else { return .failed } |
| unsettledAnswers[slot] = nil |
| cards = Self.merge(cards, [answered.card]) |
| await refresh() |
| return .answered |
| } catch let error as EquipoAPIError { |
| + guard lifetime.isActive else { return .failed } |
| if error == .offline, attempts < 2 { attempts += 1; try? await sleep(.seconds(2)); continue } |
| // Offline: it may have landed; keep it to send again as itself. |
| if error != .offline { unsettledAnswers[slot] = nil } |
| @@ -318,18 +334,22 @@ public final class EquipoSession { |
| /// card stays in Needs you. `.answered` means the server took it; a |
| /// card that changed is shown as it is now and never sent again. |
| public func setAside(_ card: ThinCard, _ aside: Bool) async -> AnswerOutcome { |
| + guard lifetime.isActive else { return .failed } |
| guard Feed.canSetAside(card) else { return .changed } |
| let slot = "\(card.id)#\(card.revision)#\(aside)" |
| guard let write = unsettledVisibility[slot] ?? (try? EquipoClient.visibility(aside: aside, of: card)) else { return .failed } |
| unsettledVisibility[slot] = write |
| var attempts = 0 |
| while true { |
| + guard lifetime.isActive else { return .failed } |
| do { |
| let updated = try await client.setVisibility(card: card.id, write) |
| + guard lifetime.isActive else { return .failed } |
| unsettledVisibility[slot] = nil |
| cards = Self.merge(cards, [updated]) |
| return .answered |
| } catch let error as EquipoAPIError { |
| + guard lifetime.isActive else { return .failed } |
| if error == .offline, attempts < 2 { attempts += 1; try? await sleep(.seconds(2)); continue } |
| // Offline: it may have landed; keep it to send again as itself. |
| if error != .offline { unsettledVisibility[slot] = nil } |
| @@ -345,9 +365,11 @@ public final class EquipoSession { |
| /// Says whether the server took it; on false, Stop is offered again. |
| @discardableResult |
| public func stop(_ turn: ThinTurn) async -> Bool { |
| + guard lifetime.isActive else { return false } |
| guard !stopping.contains(turn.id) else { return true } |
| stopping.insert(turn.id) |
| do { try await client.cancelTurn(turn.id) } catch { stopping.remove(turn.id); return false } |
| + guard lifetime.isActive else { return false } |
| await refresh() |
| return true |
| } |
| @@ -357,18 +379,22 @@ public final class EquipoSession { |
| func renew(_ account: DeviceAccount, transport: EquipoTransport) { |
| guard !isInvalidated else { return } |
| self.account = account |
| - client = EquipoClient(transport: transport, token: account.credential?.token) |
| + revocationTransport = transport |
| + client = EquipoClient(transport: LifetimeTransport(inner: transport, lifetime: lifetime), token: account.credential?.token) |
| if status == .signedOut { status = .loading } |
| } |
| // MARK: Signing out |
| - private func endSession() { invalidate() } |
| + private func endSession() { |
| + try? accounts.commit(.remove(account), lifetime: lifetime) |
| + invalidate() |
| + } |
| /// Called before the app releases this session. Cancellation alone does |
| /// not prevent a completed network response from reaching persistence. |
| func invalidate() { |
| - isInvalidated = true |
| + lifetime.end() |
| status = .signedOut |
| stopLive() |
| pendingRead?.cancel(); pendingRead = nil |
| @@ -377,13 +403,9 @@ public final class EquipoSession { |
| /// Forgets this device immediately, then revokes it best effort. No |
| /// late cleanup may remove a newly signed-in account at the same origin. |
| public func signOut() async { |
| + try? accounts.commit(.remove(account), lifetime: lifetime) |
| invalidate() |
| - accounts.remove(origin) |
| - let client = self.client |
| - if let id = account.credential?.id, let page = try? await client.devices(), |
| - let device = page.items.first(where: { $0.id == id }) { |
| - _ = try? await client.revokeDevice(id, EquipoClient.empty(ifMatch: device.revision)) |
| - } |
| + await DeviceRevocation.revoke(account, transport: revocationTransport) |
| } |
| } |
diff --git a/native/apple/Sources/EquipoKit/Session/SignInLifetime.swift b/native/apple/Sources/EquipoKit/Session/SignInLifetime.swift| new file mode 100644 |
| index 00000000..fbe915e7 |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/Session/SignInLifetime.swift |
| @@ -0,0 +1,67 @@ |
| +import Foundation |
| + |
| +/// Authority for one sign-in, shared by every task it starts. Renewal keeps |
| +/// the same lifetime; sign-out, switching accounts and cancellation end it. |
| +@MainActor public final class SignInLifetime { |
| + public private(set) var isActive = true |
| + public func end() { isActive = false } |
| + func check() throws { guard isActive else { throw CancellationError() } } |
| +} |
| + |
| +/// One current sign-in across pairing and Oficina ID. A stale task cannot |
| +/// acquire a replacement token; only an explicit sign-in transition begins one. |
| +@MainActor public final class SignInLifetimes { |
| + public private(set) var current = SignInLifetime() |
| + @discardableResult public func begin() -> SignInLifetime { |
| + current.end() |
| + current = SignInLifetime() |
| + return current |
| + } |
| + func require(_ lifetime: SignInLifetime) throws { |
| + try lifetime.check() |
| + guard current === lifetime else { throw CancellationError() } |
| + } |
| +} |
| + |
| +/// Engine traffic is confined to its original lifetime, including clients |
| +/// retained by views, retries and push registration after the session leaves. |
| +struct LifetimeTransport: EquipoTransport { |
| + let inner: EquipoTransport |
| + let lifetime: SignInLifetime |
| + var origin: URL { inner.origin } |
| + func send(_ request: APIRequest) async throws -> APIResponse { |
| + try await lifetime.check() |
| + let response = try await inner.send(request) |
| + try await lifetime.check() |
| + return response |
| + } |
| + func lines(_ request: APIRequest) async throws -> AsyncThrowingStream<String, Error> { |
| + try await lifetime.check() |
| + let stream = try await inner.lines(request) |
| + try await lifetime.check() |
| + return AsyncThrowingStream { continuation in |
| + let task = Task { |
| + do { |
| + for try await line in stream { |
| + try await lifetime.check() |
| + continuation.yield(line) |
| + } |
| + continuation.finish() |
| + } catch { continuation.finish(throwing: error) } |
| + } |
| + continuation.onTermination = { _ in task.cancel() } |
| + } |
| + } |
| +} |
| + |
| +/// The only traffic allowed after a lifetime ends: best-effort revocation |
| +/// with the abandoned credential itself. Never consults a current bearer. |
| +enum DeviceRevocation { |
| + static func revoke(_ account: DeviceAccount, transport: EquipoTransport) async { |
| + let client = EquipoClient(transport: transport, token: account.credential?.token) |
| + if let id = account.credential?.id, let page = try? await client.devices(), |
| + let device = page.items.first(where: { $0.id == id }) { |
| + _ = try? await client.revokeDevice(id, EquipoClient.empty(ifMatch: device.revision)) |
| + } |
| + } |
| +} |
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift b/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift| index 995d1336..98bfd060 100644 |
| --- a/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift |
| +++ b/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift |
| @@ -15,7 +15,8 @@ public final class EquipoAppModel { |
| public private(set) var showingPairing: Bool |
| private var started = false |
| private var isForeground = false |
| - private static let routeKey = "signin.route" |
| + private var endingSession = false |
| + private let makeTransport: @Sendable (URL) -> EquipoTransport |
| /// Set when the server ended the session, so pairing can say why. |
| public private(set) var endedTeam: String? |
| /// Where a tapped notification or Live Activity asked to go, until the |
| @@ -32,10 +33,11 @@ public final class EquipoAppModel { |
| push: PushRegistrar = PushRegistrar(), oficinaModel: OficinaIDModel? = nil, |
| makeTransport: @escaping @Sendable (URL) -> EquipoTransport = { URLSessionTransport(origin: $0) }, |
| now: @escaping @Sendable () -> Date = Date.init, deviceLabel: (() -> String)? = nil) { |
| + self.makeTransport = makeTransport |
| accounts = DeviceAccounts(store: store) |
| pairing = PairingModel(accounts: accounts, makeTransport: makeTransport) |
| let old = accounts.all().first { $0.oficinaIdentity == nil && $0.isUsable() } |
| - let route = store.read(Self.routeKey).flatMap { String(data: $0, encoding: .utf8) } |
| + let route = accounts.signInRoute |
| showingPairing = route.map { $0 == "pairing" } ?? (old != nil) |
| oficina = EquipoOficinaID(model: oficinaModel ?? .live(configuration: EquipoOficinaID.configuration, |
| appGroup: EquipoOficinaID.appGroup), |
| @@ -47,7 +49,7 @@ public final class EquipoAppModel { |
| liveActivities = LiveActivities(registrar: push) |
| #endif |
| oficina.suspended = showingPairing |
| - oficina.onAccount = { [weak self] account, transport in self?.adopt(account, transport: transport) } |
| + oficina.onAccount = { [weak self] account, transport, lifetime in self?.adopt(account, transport: transport, lifetime: lifetime) } |
| oficina.onLeave = { [weak self] in |
| guard let self, !self.showingPairing else { return } |
| self.sessionEnded() |
| @@ -55,7 +57,7 @@ public final class EquipoAppModel { |
| if showingPairing, let account = old { |
| // Written again so a slice 1 credential becomes readable after |
| // first unlock, for Live Activity tokens sent in the background. |
| - try? accounts.save(account) |
| + try? accounts.commit(.save(account), lifetime: accounts.lifetimes.current) |
| session = EquipoSession(account: account, accounts: accounts, transport: makeTransport(account.origin)) |
| sessionStarted() |
| } |
| @@ -81,36 +83,38 @@ public final class EquipoAppModel { |
| public func otherWays() { |
| showingPairing = true |
| - try? accounts.store.write(Data("pairing".utf8), account: Self.routeKey) |
| oficina.pause() |
| session?.invalidate(); session = nil |
| pairing.cancel() |
| + let lifetime = accounts.lifetimes.begin() |
| + try? accounts.commit(.route("pairing"), lifetime: lifetime) |
| forgetPushes() |
| } |
| public func useOficinaID() async { |
| showingPairing = false |
| - try? accounts.store.write(Data("oficina".utf8), account: Self.routeKey) |
| pairing.cancel() |
| await oficina.resume() |
| } |
| /// After pairing approves this device. |
| public func paired() { |
| - guard let account = pairing.account else { return } |
| - adopt(account) |
| + guard let account = pairing.account, let lifetime = pairing.handoff() else { return } |
| + adopt(account, transport: makeTransport(account.origin), lifetime: lifetime) |
| foreground() |
| } |
| - func adopt(_ account: DeviceAccount, transport: EquipoTransport? = nil) { |
| + func adopt(_ account: DeviceAccount, transport: EquipoTransport? = nil, lifetime: SignInLifetime? = nil) { |
| + let lifetime = lifetime ?? (session == nil ? accounts.lifetimes.current : accounts.lifetimes.begin()) |
| + guard lifetime.isActive else { return } |
| endedTeam = nil |
| - if let session, !session.isInvalidated, account.oficinaIdentity != nil, |
| + if let session, session.lifetime === lifetime, !session.isInvalidated, account.oficinaIdentity != nil, |
| session.account.oficinaIdentity == account.oficinaIdentity, |
| session.account.oficinaTeam == account.oficinaTeam, session.origin == account.origin, let transport { |
| session.renew(account, transport: transport) |
| } else { |
| session?.invalidate() |
| - session = EquipoSession(account: account, accounts: accounts, transport: transport) |
| + session = EquipoSession(account: account, accounts: accounts, transport: transport, lifetime: lifetime) |
| } |
| sessionStarted() |
| } |
| @@ -120,16 +124,27 @@ public final class EquipoAppModel { |
| private func sessionStarted() { |
| if isForeground { session?.startLive() } |
| notifications?.askAndRegister() |
| - let client = session?.client |
| + guard let session else { return } |
| + let client = session.client, lifetime = session.lifetime |
| let push = self.push |
| - Task { await push.attach(client) } |
| + Task { |
| + guard lifetime.isActive else { return } |
| + await push.attach(client, lifetime: lifetime) |
| + } |
| } |
| /// The server ended the session (revoked, removed or expired): pair again. |
| public func sessionEnded() { |
| - endedTeam = session?.teamName |
| - session?.invalidate() |
| + guard !endingSession else { return } |
| + endingSession = true |
| + defer { endingSession = false } |
| + let departing = session |
| + endedTeam = departing?.teamName |
| session = nil |
| + // Remove through the still-current lifetime before ending it. The |
| + // coordinator's onLeave can call back here; session is already nil. |
| + if let departing, departing.account.oficinaIdentity != nil { oficina.sessionEnded(lifetime: departing.lifetime) } |
| + departing?.invalidate() |
| pairing.cancel() |
| forgetPushes() |
| } |
| @@ -143,6 +158,7 @@ public final class EquipoAppModel { |
| session = nil |
| endedTeam = nil |
| pairing.cancel() |
| + if departing == nil { accounts.lifetimes.current.end() } |
| forgetPushes() |
| await departing?.signOut() |
| } |
| @@ -150,7 +166,10 @@ public final class EquipoAppModel { |
| /// No team: nothing more is registered, no badge, no task on the Lock Screen. |
| private func forgetPushes() { |
| let push = self.push |
| - Task { await push.attach(nil) } |
| + Task { [weak self] in |
| + guard self?.session == nil else { return } |
| + await push.attach(nil) |
| + } |
| notifications?.setBadge(0) |
| // Even if the server never heard of the sign-out, this device stops |
| // receiving the team's notifications; pairing again registers anew. |
| @@ -175,9 +194,12 @@ public final class EquipoAppModel { |
| NativeConnectivity.shared.foregrounded() |
| let push = self.push |
| Task { await push.sync() } |
| + let lifetime = accounts.lifetimes.current |
| Task { |
| await start() |
| + guard lifetime.isActive else { return } |
| await oficina.renewIfNeeded() |
| + guard lifetime.isActive else { return } |
| if isForeground { session?.startLive() } |
| } |
| } |
diff --git a/native/apple/Tests/EquipoKitTests/OficinaIDTests.swift b/native/apple/Tests/EquipoKitTests/OficinaIDTests.swift| index 0c4647af..493f6e17 100644 |
| --- a/native/apple/Tests/EquipoKitTests/OficinaIDTests.swift |
| +++ b/native/apple/Tests/EquipoKitTests/OficinaIDTests.swift |
| @@ -285,7 +285,7 @@ private final class IDClock: @unchecked Sendable { |
| f.app.otherWays() |
| var paired = DeviceAccount.new(origin: f.transport.origin, label: "Paired") |
| paired.credential = try Fixture.decode("device-credential") |
| - try f.app.accounts.save(paired) |
| + try f.app.accounts.commit(.save(paired), lifetime: f.app.accounts.lifetimes.current) |
| f.app.adopt(paired, transport: f.transport) |
| f.model.signOut() |
| #expect(f.app.session?.account == paired) |
| @@ -365,6 +365,7 @@ private final class IDClock: @unchecked Sendable { |
| let departed = try #require(f.app.session) |
| let oldAccount = departed.account |
| f.clock.advance(86401) |
| + await held.nativeToken("ABANDONED") |
| await held.hold("/auth/devices/native") |
| let renewal = Task { await f.app.oficina.renewIfNeeded() } |
| await held.waitUntilEntered() |
| @@ -375,6 +376,7 @@ private final class IDClock: @unchecked Sendable { |
| #expect(f.app.accounts.all().isEmpty) |
| #expect(f.app.oficina.account == nil) |
| #expect(f.model.identity == nil) |
| + #expect(await held.sent("DELETE /auth/devices/dev_01JD5Z4Q2X").contains { $0.bearer == "equipo.person.v1.ABANDONED" }) |
| // Even a queued adoption and direct metadata update cannot reopen |
| // the departed session or save its private key again. |
| departed.renew(oldAccount, transport: held) |
| @@ -396,7 +398,7 @@ private final class IDClock: @unchecked Sendable { |
| case "replacement": |
| var next = departed.account |
| next.oficinaTeam = "replacement" |
| - try f.app.accounts.save(next) |
| + try f.app.accounts.commit(.save(next), lifetime: f.app.accounts.lifetimes.current) |
| f.app.adopt(next, transport: held) |
| default: f.app.sessionEnded() |
| } |
| @@ -413,7 +415,7 @@ private final class IDClock: @unchecked Sendable { |
| let accounts = DeviceAccounts(store: MemorySecretStore()) |
| var old = DeviceAccount.new(origin: held.origin, label: "Old phone") |
| old.credential = try Fixture.decode("device-credential") |
| - try accounts.save(old) |
| + try accounts.commit(.save(old), lifetime: accounts.lifetimes.current) |
| let departed = EquipoSession(account: old, accounts: accounts, transport: held) |
| await held.hold("/auth/devices") |
| let signOut = Task { await departed.signOut() } |
| @@ -422,7 +424,8 @@ private final class IDClock: @unchecked Sendable { |
| #expect(accounts.all().isEmpty) |
| var replacement = old |
| replacement.keySeed = DeviceAccount.new(origin: held.origin, label: "New phone").keySeed |
| - try accounts.save(replacement) |
| + accounts.lifetimes.begin() |
| + try accounts.commit(.save(replacement), lifetime: accounts.lifetimes.current) |
| await held.release() |
| await signOut.value |
| #expect(accounts.all() == [replacement]) |
| @@ -445,11 +448,142 @@ private final class IDClock: @unchecked Sendable { |
| #expect(f.app.session === original) |
| } |
| + @Test(arguments: ["/auth/devices/exchange", "/me"], [false, true]) |
| + func cancelledPairingCannotOverwriteNativeSignIn(_ boundary: String, _ signOut: Bool) async throws { |
| + let held = HeldEquipoRead() |
| + let f = IDFixture(held: held) |
| + try await f.seedIdentity() |
| + f.app.otherWays(); await f.app.start() |
| + await held.hold(boundary) |
| + f.app.pairing.start(origin: held.origin, label: "Abandoned pairing") |
| + await held.waitUntilEntered() |
| + await held.nativeToken("NEW_SIGN_IN") |
| + await f.app.useOficinaID() |
| + let native = try #require(f.app.session?.account) |
| + if signOut { await f.app.signOut(); await f.app.oficina.cleanup?.value } |
| + await held.release() |
| + // Wait for the abandoned pairing's network cleanup as well as /me. |
| + for _ in 0..<200 { |
| + if await held.sent("DELETE /auth/devices/dev_01JD5Z4Q2X").contains(where: { $0.bearer == "equipo.person.v1.TOKENFIXTURE" }) { break } |
| + try await Task.sleep(for: .milliseconds(5)) |
| + } |
| + #expect(f.app.accounts.all() == (signOut ? [] : [native])) |
| + #expect(f.app.pairing.account == nil) |
| + #expect(f.app.pairing.step == .enterTeam) |
| + #expect(await held.sent("DELETE /auth/devices/dev_01JD5Z4Q2X").contains { $0.bearer == "equipo.person.v1.TOKENFIXTURE" }) |
| + } |
| + |
| + @Test func departedWriteCannotRetryWithALaterSignInsBearer() async throws { |
| + let held = HeldEquipoRead() |
| + let f = IDFixture(held: held); await f.signIn() |
| + let departed = try #require(f.app.session) |
| + let outer = try #require(departed.client.transport as? LifetimeTransport) |
| + let renewing = try #require(outer.inner as? EquipoRenewingTransport) |
| + let snapshot: Snapshot = try Fixture.decode("thin/snapshot") |
| + let card = try #require(snapshot.cards?.first { $0.isOpen }) |
| + let route = "POST /cards/\(card.id)/answer" |
| + await held.answerFailure(route) |
| + await held.hold("/cards/\(card.id)/answer") |
| + let answer = Task { await departed.answer(card, choice: "wait_mac") } |
| + await held.waitUntilEntered() |
| + await f.app.signOut() |
| + await f.app.oficina.cleanup?.value |
| + await f.model.cleanup?.value |
| + await held.nativeToken("NEW_SIGN_IN") |
| + await f.signIn() |
| + #expect(f.app.session?.account.credential?.token == "equipo.person.v1.NEW_SIGN_IN") |
| + #expect(renewing.credential() == nil) |
| + await held.release() |
| + #expect(await answer.value == .failed) |
| + #expect(await held.sent(route).count == 1) |
| + // A retained client is also bound, independently of the write loop. |
| + _ = try? await departed.client.me() |
| + #expect(await held.sent("GET /me").isEmpty) |
| + } |
| + |
| + @Test(arguments: [false, true]) |
| + func endedWriteLoopsDoNotWaitOrRetry(_ aside: Bool) async throws { |
| + let held = HeldEquipoRead() |
| + let f = IDFixture(held: held); await f.signIn() |
| + let current = try #require(f.app.session) |
| + let sleeps = Sleeps() |
| + let worker = EquipoSession(account: current.account, accounts: f.app.accounts, |
| + transport: current.client.transport, lifetime: current.lifetime, sleep: sleeps.sleep) |
| + let snapshot: Snapshot = try Fixture.decode("thin/snapshot") |
| + let card = try #require(snapshot.cards?.first { $0.kind == "merge" && $0.isOpen }) |
| + let path = "/cards/\(card.id)/" + (aside ? "visibility" : "answer") |
| + await held.answerFailure("POST " + path) |
| + await held.hold(path) |
| + let write = Task { aside ? await worker.setAside(card, true) : await worker.answer(card, choice: "wait_mac") } |
| + await held.waitUntilEntered() |
| + await f.app.signOut() |
| + await held.release() |
| + #expect(await write.value == .failed) |
| + #expect(sleeps.waits.isEmpty) |
| + #expect(await held.sent("POST " + path).count == 1) |
| + } |
| + |
| + @Test func endedTransportRefusesLateResponsesAndNewRequests() async throws { |
| + let held = HeldEquipoRead() |
| + let lifetimes = SignInLifetimes() |
| + let lifetime = lifetimes.current |
| + let transport = LifetimeTransport(inner: held, lifetime: lifetime) |
| + await held.hold("/me") |
| + let read = Task { try await transport.send(APIRequest("GET", "/me", bearer: "old")) } |
| + await held.waitUntilEntered() |
| + lifetimes.begin() |
| + await held.release() |
| + var rejected = false |
| + do { _ = try await read.value } catch is CancellationError { rejected = true } |
| + #expect(rejected) |
| + _ = try? await transport.send(APIRequest("GET", "/snapshot", bearer: "old")) |
| + #expect(await held.sent("GET /snapshot").isEmpty) |
| + } |
| + |
| + @Test(arguments: [false, true]) |
| + func cancellingPairingAloneEndsItsLifetime(_ signOut: Bool) async throws { |
| + let held = HeldEquipoRead() |
| + let f = IDFixture(held: held) |
| + f.app.otherWays(); await f.app.start() |
| + await held.hold("/auth/devices/exchange") |
| + f.app.pairing.start(origin: held.origin, label: "Cancelled") |
| + await held.waitUntilEntered() |
| + let lifetime = try #require(f.app.pairing.lifetime) |
| + if signOut { await f.app.signOut() } else { f.app.pairing.cancel() } |
| + #expect(!lifetime.isActive) |
| + await held.release() |
| + for _ in 0..<200 { |
| + if !(await held.sent("DELETE /auth/devices/dev_01JD5Z4Q2X")).isEmpty { break } |
| + try await Task.sleep(for: .milliseconds(5)) |
| + } |
| + #expect(f.app.accounts.all().isEmpty) |
| + #expect(f.app.pairing.step == .enterTeam) |
| + #expect(await held.sent("DELETE /auth/devices/dev_01JD5Z4Q2X").count == 1) |
| + } |
| + |
| + @Test(arguments: [false, true]) |
| + func signOutBeforeRegistrationEndsThePendingLifetime(_ throughKit: Bool) async { |
| + let f = IDFixture() |
| + let lifetime = f.app.accounts.lifetimes.current |
| + if throughKit { f.app.oficina.signOut() } else { await f.app.signOut() } |
| + #expect(!lifetime.isActive) |
| + #expect(f.app.accounts.all().isEmpty) |
| + } |
| + |
| + @Test func signingOutAfterTheSessionEndsStillForgetsItsCredential() async throws { |
| + let f = IDFixture(); await f.signIn() |
| + f.app.sessionEnded() |
| + await f.app.signOut() |
| + #expect(f.app.accounts.all().isEmpty) |
| + await f.app.oficina.cleanup?.value |
| + #expect(f.transport.sent("DELETE /auth/devices/dev_01JD5Z4Q2X").count == 1) |
| + } |
| + |
| @Test func oldSavedPairingStillLoadsWithoutOficinaID() throws { |
| let f = IDFixture() |
| var account = DeviceAccount.new(origin: f.transport.origin, label: "Old phone") |
| account.credential = try Fixture.decode("device-credential") |
| - try f.app.accounts.save(account) |
| + try f.app.accounts.commit(.save(account), lifetime: f.app.accounts.lifetimes.current) |
| let relaunched = EquipoAppModel(store: f.secrets, push: PushRegistrar(environment: nil), oficinaModel: f.model) |
| #expect(relaunched.session?.account == account) |
| #expect(relaunched.showingPairing) |
| @@ -497,6 +631,9 @@ private actor HeldEquipoRead: EquipoTransport { |
| private var continuation: CheckedContinuation<Void, Never>? |
| init() { |
| script.on("POST /auth/devices/native", fixture: "device-credential") |
| + script.on("POST /auth/devices", fixture: "device-challenge") |
| + script.on("POST /auth/devices/exchange", fixture: "device-credential") |
| + script.on("GET /me", fixture: "me") |
| script.on("GET /auth/devices", fixture: "devices") |
| script.on("DELETE /auth/devices/dev_01JD5Z4Q2X", fixture: "ack") |
| script.on("GET /snapshot", fixture: "thin/snapshot") |
| @@ -505,14 +642,24 @@ private actor HeldEquipoRead: EquipoTransport { |
| } |
| func hold(_ path: String) { self.path = path; entered = false } |
| func send(_ request: APIRequest) async throws -> APIResponse { |
| - let response = try await script.send(request) |
| + let response: Result<APIResponse, Error> |
| + do { response = .success(try await script.send(request)) } |
| + catch { response = .failure(error) } |
| if request.path == path { |
| path = nil |
| entered = true |
| await withCheckedContinuation { continuation = $0 } |
| } |
| - return response |
| + return try response.get() |
| + } |
| + func nativeToken(_ value: String) { |
| + let data = String(decoding: Fixture.data("device-credential"), as: UTF8.self).replacingOccurrences(of: "TOKENFIXTURE", with: value) |
| + script.replace("POST /auth/devices/native", with: .success(APIResponse(status: 200, data: Data(data.utf8)))) |
| + } |
| + func answerFailure(_ route: String) { |
| + script.on(route, .failure(.offline), .success(APIResponse(status: 200, data: Fixture.data("thin/answered")))) |
| } |
| + func sent(_ route: String) -> [APIRequest] { script.sent(route) } |
| func lines(_ request: APIRequest) async throws -> AsyncThrowingStream<String, Error> { throw EquipoAPIError.offline } |
| func waitUntilEntered() async { while !entered { await Task.yield() } } |
| func release() { continuation?.resume(); continuation = nil } |
diff --git a/native/apple/Tests/EquipoKitTests/PushTests.swift b/native/apple/Tests/EquipoKitTests/PushTests.swift| index 8b2d372a..86b31235 100644 |
| --- a/native/apple/Tests/EquipoKitTests/PushTests.swift |
| +++ b/native/apple/Tests/EquipoKitTests/PushTests.swift |
| @@ -25,6 +25,20 @@ private func json(_ request: APIRequest) throws -> [String: String] { |
| } |
| @MainActor @Suite struct PushRegistrationTests { |
| + @Test func lateAttachCannotReplaceTheNextSignIn() async throws { |
| + let t = ScriptedTransport(); registered(t) |
| + let r = PushRegistrar(environment: .production, platform: .ios) |
| + let lifetimes = SignInLifetimes() |
| + let old = lifetimes.current |
| + await r.deviceTokenChanged(deviceToken) |
| + let next = lifetimes.begin() |
| + await r.attach(client(t, "new-sign-in"), lifetime: next) |
| + let generation = r.generation |
| + await r.attach(client(t, "old-sign-in"), lifetime: old) |
| + #expect(r.generation == generation) |
| + #expect(t.sent("POST /push-registrations").map(\.bearer) == ["new-sign-in"]) |
| + } |
| + |
| @Test func theBodyIsTheServersShapeInLowercaseHex() throws { |
| let body = PushRegistrationBody(token: PushToken.hex(deviceToken), environment: .production, platform: .ios, startToken: PushToken.hex(startToken)) |
| let sent = try JSONSerialization.jsonObject(with: try EquipoJSON.encoder.encode(body)) as! [String: String] |
diff --git a/native/apple/Tests/EquipoKitTests/SessionTests.swift b/native/apple/Tests/EquipoKitTests/SessionTests.swift| index c6ae99cc..e9fcc784 100644 |
| --- a/native/apple/Tests/EquipoKitTests/SessionTests.swift |
| +++ b/native/apple/Tests/EquipoKitTests/SessionTests.swift |
| @@ -6,7 +6,7 @@ import Testing |
| var account = DeviceAccount.new(origin: t.origin, label: "Test") |
| account.credential = try Fixture.decode("device-credential") |
| let accounts = DeviceAccounts(store: store) |
| - try accounts.save(account) |
| + try accounts.commit(.save(account), lifetime: accounts.lifetimes.current) |
| return EquipoSession(account: account, accounts: accounts, transport: t, sleep: { _ in }) |
| } |
diff --git a/native/apple/Tests/EquipoKitTests/SetAsideTests.swift b/native/apple/Tests/EquipoKitTests/SetAsideTests.swift| index c3d341b8..de942556 100644 |
| --- a/native/apple/Tests/EquipoKitTests/SetAsideTests.swift |
| +++ b/native/apple/Tests/EquipoKitTests/SetAsideTests.swift |
| @@ -16,7 +16,7 @@ import Testing |
| var account = DeviceAccount.new(origin: t.origin, label: "Test") |
| account.credential = try Fixture.decode("device-credential") |
| let accounts = DeviceAccounts(store: MemorySecretStore()) |
| - try accounts.save(account) |
| + try accounts.commit(.save(account), lifetime: accounts.lifetimes.current) |
| let s = EquipoSession(account: account, accounts: accounts, transport: t, sleep: { _ in }) |
| await s.refresh() |
| return s |
diff --git a/native/apple/Tests/EquipoKitTests/SignInLifetimeTests.swift b/native/apple/Tests/EquipoKitTests/SignInLifetimeTests.swift| new file mode 100644 |
| index 00000000..ecc02e61 |
| --- /dev/null |
| +++ b/native/apple/Tests/EquipoKitTests/SignInLifetimeTests.swift |
| @@ -0,0 +1,27 @@ |
| +import Foundation |
| +import Testing |
| +@testable import EquipoKit |
| + |
| +@MainActor @Suite struct SignInLifetimeTests { |
| + @Test func endedOrForeignLifetimesCannotPersistAnything() throws { |
| + let store = MemorySecretStore() |
| + let accounts = DeviceAccounts(store: store) |
| + let old = accounts.lifetimes.current |
| + var account = DeviceAccount.new(origin: URL(string: "https://example.test")!, label: "Test") |
| + account.credential = try Fixture.decode("device-credential") |
| + try accounts.commit(.save(account), lifetime: old) |
| + old.end() |
| + let before = store.accounts.sorted().map { store.read($0) } |
| + for token in [old, SignInLifetimes().current] { |
| + for change in [DeviceAccounts.Change.save(account), .remove(account), .route("pairing")] { |
| + #expect(throws: CancellationError.self) { try accounts.commit(change, lifetime: token) } |
| + } |
| + } |
| + #expect(store.accounts.sorted().map { store.read($0) } == before) |
| + let next = accounts.lifetimes.begin() |
| + #expect(!old.isActive) |
| + #expect(next !== old) |
| + try accounts.commit(.remove(account), lifetime: next) |
| + #expect(accounts.all().isEmpty) |
| + } |
| +} |
diff --git a/native/scripts/check-native.sh b/native/scripts/check-native.sh| index e3b191ca..af401099 100755 |
| --- a/native/scripts/check-native.sh |
| +++ b/native/scripts/check-native.sh |
| @@ -7,6 +7,7 @@ cd "$(dirname "$0")/.." |
| logs=build/logs; mkdir -p "$logs" |
| swift package --package-path apple resolve |
| python3 scripts/check-oficina-id.py |
| +python3 scripts/check-sign-in-lifetime.py |
| python3 scripts/check-fixtures.py |
| python3 scripts/check-strings.py |
| python3 scripts/check-parity.py |
diff --git a/native/scripts/check-sign-in-lifetime.py b/native/scripts/check-sign-in-lifetime.py| new file mode 100644 |
| index 00000000..f7d770c5 |
| --- /dev/null |
| +++ b/native/scripts/check-sign-in-lifetime.py |
| @@ -0,0 +1,32 @@ |
| +#!/usr/bin/env python3 |
| +"""Equipo's only device/Keychain mutation boundary is lifetime-guarded commit.""" |
| +from pathlib import Path |
| +import re |
| + |
| +root = Path(__file__).resolve().parents[1] |
| +sources = root / 'apple/Sources/EquipoKit' |
| +account = sources / 'Pairing/DeviceAccount.swift' |
| +text = account.read_text() |
| +assert 'func commit(' in text, 'DeviceAccounts must expose one guarded commit function' |
| +start = text.index('{', text.index('func commit(')) |
| +depth = 1 |
| +end = start + 1 |
| +while depth: |
| + depth += (text[end] == '{') - (text[end] == '}') |
| + end += 1 |
| +commit = text[start:end] |
| +outside = text[:start] + text[end:] |
| +assert not re.search(r'store\.(?:write|remove)\s*\(', outside), 'persistence outside commit' |
| +assert 'try lifetimes.require(lifetime)' in commit, 'commit must reject an ended or foreign lifetime' |
| +assert commit.index('try lifetimes.require(lifetime)') < commit.index('store.write('), 'guard must precede persistence' |
| +for path in [*sources.rglob('*.swift'), *(root / 'ios').rglob('*.swift'), *(root / 'macos').rglob('*.swift')]: |
| + value = path.read_text() |
| + if path != account: |
| + assert not re.search(r'\b(?:accounts|self\.accounts)\.(?:save|remove)\s*\(', value), f'unguarded account write: {path}' |
| + assert not re.search(r'\.write\s*\(', value), f'raw secret-store write: {path}' |
| + assert not re.search(r'\b\w*(?:store|Store)\.remove\s*\(', value), f'raw secret-store removal: {path}' |
| + if path.name != 'SecretStore.swift': |
| + assert not re.search(r'\bSecItem(?:Add|Update|Delete)\s*\(', value), f'raw Keychain write: {path}' |
| +assert 'private let store: SecretStore' in text, 'raw store must stay private' |
| +assert not re.search(r'func (?:save|remove)\(', text), 'do not add a persistence bypass' |
| +print('Sign-in lifetime: device and Keychain writes use the guarded commit') |