Harden preview grants and use clock-independent lifetimes
24 files changed,
+786
−120
.rastrillo/budgets.txt+2 −2docs/api/equipo-v1.openapi.json+16 −2docs/superpowers/plans/2026-11-26-preview-pass.md+25 −8docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md+78 −8internal/equipo/migrations/0110_preview_device_task.sql+3 −0internal/equipo/preview_frames_fixture_test.go+18 −0internal/equipo/preview_pass.go+40 −14internal/equipo/preview_pass_attack_test.go+304 −0internal/equipo/preview_pass_browser_test.go+20 −1internal/equipo/preview_pass_delta_test.go+180 −0internal/equipo/preview_pass_fixture_test.go+20 −1internal/equipo/preview_pass_http.go+11 −15internal/equipo/preview_pass_http_test.go+4 −3internal/equipo/preview_pass_security_test.go+2 −2internal/equipo/preview_pass_store.go+7 −5internal/plan3test/preview_pass_contract_test.go+8 −1native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings+0 −22native/apple/Sources/EquipoKit/API/PreviewPass.swift+5 −1native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift+1 −0native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift+7 −5native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings+0 −22native/apple/Tests/EquipoKitTests/PreviewPassTests.swift+34 −5native/scripts/check-parity.py+1 −1native/scripts/strings.json+0 −2
CI failed — 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/preview__pass: Type Size Avail | ext4 96G 86G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 86G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.4s
ci-box: codex: fetched and verified in 3.5s
ci-box: codex-code-mode-host: fetched and verified in 1.4s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.4s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.9s
ci-box: pi: installed and verified in 7.5s
ci-box: opencode: installed and verified in 2.1s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.9s
ci-box: clone deepened in 4.8s
ci-box: file times set from content: 3112 files, 200 directories
ci-box: ready in 18.4s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok amadan.net/oficina/equipo/internal/equipotest 0.148s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
2.7s
+ go list -export -test -tags testbuild -f ./...
3.8s
+ go list -export -test -tags browser,testbuild -f ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
3.3s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-24 15:56:00 +0000 UTC
go run github.com/zricethezav/gitleaks/v8@v8.30.1 version
version is set by build process
=== check ===
--- shard 0 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-work: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' ./internal/headless
receipt: test step 1m17.031s 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 1m15.499s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m15.5s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 70.30, cpu waiting 40.87%, memory waiting 0.00%, io waiting 0.84%
--- shard 1 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-review: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$' ./internal/headless
receipt: test step 1m17.691s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m16.084s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m16.08s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 70.30, cpu waiting 40.87%, memory waiting 0.00%, io waiting 0.84%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless
receipt: test step 1m17.891s 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.183s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m6.59s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.33s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.26s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 70.30, cpu waiting 40.87%, memory waiting 0.00%, io waiting 0.84%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless
receipt: test step 1m14.723s 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 1m13.176s amadan.net/oficina/equipo/internal/headless
receipt: slow test 35.93s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 19.43s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.01s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
receipt: slow test 8.81s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
machine: 32 CPUs, load 68.49, cpu waiting 40.36%, memory waiting 0.00%, io waiting 0.87%
--- 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_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
receipt: test step 1m34.019s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m32.382s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m3.25s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.06s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 8.02s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 7.23s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 4.82s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 70.99, cpu waiting 41.22%, memory waiting 0.00%, io waiting 0.64%
--- 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_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
receipt: test step 2m46.171s 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 2m44.353s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m37.58s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 18.91s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 8.91s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 6.6s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
receipt: slow test 6.56s amadan.net/oficina/equipo/internal/headless TestHeadlessBatchAfterRefusedReply
machine: 32 CPUs, load 26.43, cpu waiting 13.70%, memory waiting 0.00%, io waiting 0.18%
--- 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 2m14.098s 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 2m12.452s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.63s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.73s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 3.99s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 3.92s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.65s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
machine: 32 CPUs, load 43.42, cpu waiting 23.15%, memory waiting 0.00%, io waiting 0.32%
--- 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 1m41.49s 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 1m40.03s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.16s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 5.03s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.7s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 3.06s amadan.net/oficina/equipo/internal/thintest TestContractPausedJob
receipt: slow test 2.4s amadan.net/oficina/equipo/internal/thintest TestContractRetryFailedPreviewAfterMerge
machine: 32 CPUs, load 64.31, cpu waiting 38.23%, memory waiting 0.00%, io waiting 0.56%
--- 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 4m48.24s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 5m2.18s 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 4m48.24s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 37.01s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.91s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.84s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.48s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 7.09s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 4.16, cpu waiting 1.42%, 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 51.991s 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 50.76s amadan.net/oficina/equipo/internal/runner
receipt: slow test 30.73s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 55.97, cpu waiting 32.50%, memory waiting 0.00%, io waiting 1.30%
--- 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 1m2.339s 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 1m0.322s amadan.net/oficina/equipo/internal/runner
receipt: slow test 50.25s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 45.73s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.42s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.63s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 65.84, cpu waiting 39.39%, memory waiting 0.00%, io waiting 1.06%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed
receipt: test step 36.469s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 35.455s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.13s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.48s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.11s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.91s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 41.85, cpu waiting 22.45%, memory waiting 0.00%, io waiting 1.64%
--- 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 40.3%, load 26.59
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
receipt: test step 1m9.136s 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 1m7.15s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 28.52s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 28.44s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 26.14s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 23.4s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelDuplicates
receipt: slow test 23.34s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
machine: 32 CPUs, load 68.43, cpu waiting 39.25%, memory waiting 0.00%, io waiting 0.58%
--- 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 40.3%, load 26.59
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 1m19.193s 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 1m17.324s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 20.72s amadan.net/oficina/equipo/internal/equipotest TestProjectRequestActorAndUpdate
receipt: slow test 20.67s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 20.67s amadan.net/oficina/equipo/internal/equipotest TestProjectBindingUniqueness
receipt: slow test 20.64s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 20.61s amadan.net/oficina/equipo/internal/equipotest TestProjectsSharedAndGrouped
machine: 32 CPUs, load 60.20, cpu waiting 33.83%, memory waiting 0.00%, io waiting 0.49%
--- 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 40.3%, load 26.59
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
receipt: test step 1m16.428s 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 1m10.852s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 15.62s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.43s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.49s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.35s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.39s amadan.net/oficina/equipo/internal/equipotest TestRosterProtectsLastOwner
machine: 32 CPUs, load 60.20, cpu waiting 34.94%, memory waiting 0.00%, io waiting 0.50%
--- 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 40.3%, load 26.59
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 1m9.217s 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 1m7.335s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.43s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 25.39s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 25.38s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 23.67s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
receipt: slow test 23.55s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsCurrentOwner
machine: 32 CPUs, load 68.43, cpu waiting 39.25%, memory waiting 0.00%, io waiting 0.58%
--- 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 40.3%, load 26.59
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 55.705s 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 53.691s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.83s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.49s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.76s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.63s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.33s amadan.net/oficina/equipo/internal/plan3test TestPlanMigrationUpgrade
machine: 32 CPUs, load 69.33, cpu waiting 41.02%, memory waiting 0.00%, io waiting 0.73%
--- 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 40.3%, load 26.59
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/door ./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/pause ./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/claude/realcli ./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/forgekey ./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/door ./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/pause ./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/claude/realcli ./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/forgekey ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude/realcli: its inputs changed
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/provider: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runnerproto: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/testci: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/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
--- FAIL amadan.net/oficina/equipo/internal/equipo TestConversationMigrationSnapshot
=== RUN TestConversationMigrationSnapshot
migrations_test.go:72: schema snapshot differs from ordered migrations [preview_grants: missing index idx_preview_grants_device_task preview_passes: missing index idx_preview_passes_device_task]
--- FAIL: TestConversationMigrationSnapshot (1.41s)
--- FAIL amadan.net/oficina/equipo/internal/equipo (package output)
FAIL
rastrillo-budget/v1 ran 2m21.367s
FAIL amadan.net/oficina/equipo/internal/equipo 142.289s
--- FAIL amadan.net/oficina/equipo/internal/runner/webread TestTimeouts
=== RUN TestTimeouts
fetch_test.go:537: s1: {Source:s1 Origin:paul Parent: URL:https://shop.example.com/slow-body Hops:[{URL:https://shop.example.com/slow-body Address:151.101.1.1 Status:200}] Address:151.101.1.1 Status:200 Type:text/plain Bytes:5 SHA256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 Millis:301 Reason: File:s001.txt}
--- FAIL: TestTimeouts (0.61s)
--- FAIL amadan.net/oficina/equipo/internal/runner/webread (package output)
FAIL
rastrillo-budget/v1 ran 1.222s
FAIL amadan.net/oficina/equipo/internal/runner/webread 1.244s
budget note: internal/equipo/chat took 24.074s, 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 1m54.933s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/release took 23.057s, 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 52.595s, over the 15s its record on line 40 allows; reported only, timing fails on CI
budget note: internal/runner/forge took 22.663s, over the 20s its record on line 35 allows; reported only, timing fails on CI
budget note: internal/runner/provider/claude/realcli took 11.594s, over the 10s the default allows; reported only, timing fails on CI
receipt: test step 2m35.283s against a 60s target (the gate's other steps are not in this figure)
receipt: 19 packages ran, 45 cached, 17 without tests, 2 failed
receipt: slow package 2m21.367s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 1m54.933s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 1m11.232s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 55.415s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 53.841s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 55.46s amadan.net/oficina/equipo/internal/idtest TestDoorRemembersOficinaID
receipt: slow test 47.79s amadan.net/oficina/equipo/internal/idtest TestDoorOficinaSettingsUnreadableIsNoLoop
receipt: slow test 47.47s amadan.net/oficina/equipo/internal/idtest TestDoorNeverJudgesANativeSession
receipt: slow test 47.24s amadan.net/oficina/equipo/internal/idtest TestDoorStepUpIsLocal
receipt: slow test 47.12s amadan.net/oficina/equipo/internal/idtest TestDoorForgetsOficinaIDForARefusedSession
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -v -run '^TestConversationMigrationSnapshot$' -count=1 ./internal/equipo (retry, once)
FAILED TWICE ./internal/equipo:TestConversationMigrationSnapshot rest
=== RUN TestConversationMigrationSnapshot
migrations_test.go:72: schema snapshot differs from ordered migrations [preview_grants: missing index idx_preview_grants_device_task preview_passes: missing index idx_preview_passes_device_task]
--- FAIL: TestConversationMigrationSnapshot (1.21s)
FAIL
rastrillo-budget/v1 ran 1.212s
FAIL amadan.net/oficina/equipo/internal/equipo 1.367s
FAIL
+ go test -tags testbuild -timeout 15m -v -run '^TestTimeouts$' -count=1 ./internal/runner/webread (retry, once)
##############################################################################
FLAKE ./internal/runner/webread:TestTimeouts rest b3adc1bffd4bc95f5720d7ab44e8ddf0537dd7c1 0.61s 19.47
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 19.47, cpu waiting 9.19%, memory waiting 0.00%, io waiting 0.12%
make: *** [Makefile:113: ci-shard] Error 1
amadan: step check shard 17 of 29 failed: exit status 2
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
receipt: test step 1m24.116s 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 1m22.527s amadan.net/oficina/equipo/internal/headless
receipt: slow test 38.44s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.77s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.44s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.49s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.18s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 70.75, cpu waiting 41.02%, memory waiting 0.00%, io waiting 0.73%
--- shard 19 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-work: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' ./internal/headless
receipt: test step 1m32.203s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m30.508s amadan.net/oficina/equipo/internal/headless
receipt: slow test 27.42s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 22.23s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 12.81s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 9.98s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
receipt: slow test 9.36s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
machine: 32 CPUs, load 70.99, cpu waiting 41.22%, memory waiting 0.00%, io waiting 0.64%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
receipt: test step 1m52.339s 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 1m50.728s amadan.net/oficina/equipo/internal/headless
receipt: slow test 13.47s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.35s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 12.17s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 11.28s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsSignInEmail
receipt: slow test 11.03s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
machine: 32 CPUs, load 56.58, cpu waiting 31.75%, memory waiting 0.00%, io waiting 0.45%
--- 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|TestBrowserConnectionsSignInEmail|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
receipt: test step 1m31.82s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m30.34s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.02s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.61s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 11.16s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 9.76s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.68s amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
machine: 32 CPUs, load 70.99, cpu waiting 41.22%, memory waiting 0.00%, io waiting 0.64%
--- 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|TestBrowserPreviewPassExchange)$' ./internal/equipo
receipt: test step 3.825s 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.477s amadan.net/oficina/equipo/internal/equipo
receipt: slow test 1.85s amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewPassExchange
receipt: slow test 630ms 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|TestBrowserSmartDoor)$' ./internal/idtest
budget note: internal/idtest took 10.693s, over the 10s the default allows; reported only, timing fails on CI
receipt: test step 12.158s 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 10.693s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 8.39s amadan.net/oficina/equipo/internal/idtest TestBrowserSmartDoor
receipt: slow test 2.3s amadan.net/oficina/equipo/internal/idtest TestBrowserOficinaIDDoor
browser lane browser-rest: ./internal/plan3test
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestTeamsHierarchyBrowser)$' ./internal/plan3test
receipt: test step 3.784s 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.128s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 2.13s 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|TestBrowserEndedNoteStaysGone|TestBrowserHousekeeping|TestBrowserInnerGallery|TestBrowserInnerScreens|TestBrowserInstantThinking|TestBrowserInstantThinkingQueued|TestBrowserMachines|TestBrowserPausedWork|TestBrowserPhoneIndex|TestBrowserPlacementQuestionAndPending|TestBrowserProjectPlacement|TestBrowserProjectsList|TestBrowserReportActionFeedback|TestBrowserReportNextSteps|TestBrowserReportThread|TestBrowserRhythm|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|TestBrowserTryAgain)$' ./internal/thintest
receipt: test step 3m41.707s 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 3m40.026s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 24.28s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.45s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.07s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.82s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.36s amadan.net/oficina/equipo/internal/thintest TestBrowserRhythm
machine: 32 CPUs, load 9.66, cpu waiting 3.74%, memory waiting 0.00%, io waiting 0.04%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless (51s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 4.86s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.26s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 8.08s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 8.76s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 26.48s
+ 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 12.10s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 11.56s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 10.14s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 18.49s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (21s)
ok ./internal/headless TestMixedVersions 19.05s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.79s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin (1s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 55.97, cpu waiting 35.27%, memory waiting 0.00%, io waiting 1.21%
--- shard 24 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 24: make runner-host
python3 scripts/runner-prerequisites.py
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
receipt: test step 11.583s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 4 without tests, 0 failed
receipt: slow package 7.511s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 189ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 113ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 2ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow test 5.3s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.76s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 330ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/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.597s 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 3.197s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 300ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 200ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 130ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceKillsDetachedChildren
receipt: slow test 130ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
machine: 32 CPUs, load 22.24, cpu waiting 8.26%, memory waiting 0.00%, io waiting 2.37%
--- 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 40.3%, load 26.59
shard 25: make runner-dead-references lanes-check build vet fmt-check spacing budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2824 text files, 3228 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 tool fiesta spacing -skip tokens.css internal/equipo/static
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 92 directories within budget
CGO_ENABLED=0 go test ./internal/equipo -run '^TestMigrationModels$' -count=1
ok amadan.net/oficina/equipo/internal/equipo 2.556s
machine: 32 CPUs, load 69.06, cpu waiting 39.67%, 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 40.3%, load 26.59
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 45.63, cpu waiting 27.00%, memory waiting 0.00%, io waiting 1.48%
--- 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 40.3%, load 30.78
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 10
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
machine: 32 CPUs, load 41.85, cpu waiting 23.97%, memory waiting 0.00%, io waiting 1.59%
--- 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 40.3%, load 26.59
shard 28: make gitleaks
[90m1:15PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m1:15PM[0m [32mINF[0m [1m1187 commits scanned.[0m
[90m1:15PM[0m [32mINF[0m [1mscanned ~66934387 bytes (66.93 MB) in 23.6s[0m
[90m1:15PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 55.97, cpu waiting 34.06%, memory waiting 0.00%, io waiting 1.25%
amadan: job failed at step check shard 17 of 29 — its output is above, not at the tail of this log
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 31d1dcb6..546de20f 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -14,7 +14,7 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr |
| time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI. |
| time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage. |
| -size internal/equipo 23214 - Native preview pass issuance, bound wrapper grants, Retry/timeline and honest no-access merge copy; measured 23214 source lines (2026-11-26). |
| +size internal/equipo 23238 - Native preview pass issuance, bound wrapper grants, Retry/timeline and honest no-access merge copy; measured 23238 source lines (2026-11-26). |
| size internal/wire 7199 - Protocol 31 display facts, shared path validation, native task evidence fields and merge credential reasons; measured 7199 source lines (2026-11-26). |
| size internal/equipotest - 12017 Task 21 repairs historical migration and conversation fixtures after Plan 3, and the Rastrillo upgrade contract comparing served assets with what Assets serves; measured 0/12017 source/test lines. |
| time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded); |
| @@ -30,7 +30,7 @@ size internal/runner/provider 5731 - Fable follow-up: base and diagnostic gates, |
| time internal/plan3test 300s Initial cap for combined browser and runner acceptance; measure at both usable stops. |
| -size internal/plan3test - 11969 Preview pass device contract plus paused-work, Assistant, stuck-task, merge credential and no-access release inventory; measured 11969 test lines (2026-11-26). |
| +size internal/plan3test - 11976 Preview pass device contract plus paused-work, Assistant, stuck-task, merge credential and no-access release inventory; measured 11976 test lines (2026-11-26). |
| time internal/runner/forge 20s Plan 3 CI repair measured 10.527s for the full package (controller CI 10.407s). |
| time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full package (controller CI 10.709s); |
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json| index 08dcd8f1..0e042779 100644 |
| --- a/docs/api/equipo-v1.openapi.json |
| +++ b/docs/api/equipo-v1.openapi.json |
| @@ -14250,7 +14250,7 @@ |
| "post": { |
| "operationId": "post_tasks_id_preview_pass", |
| "summary": "Mint a one-use preview pass", |
| - "description": "Device bearer only. Returns an opaque 32-byte pass bound to the current person, device, task, candidate and preview deployment. Expires in at most 60 seconds. Exchange only by POST body at /native/preview/exchange on the instance origin; never put the pass in a URL. The exchange issues a host-only, Secure, HttpOnly, SameSite=Strict cookie scoped to GET /tasks/{id}/preview, expiring at grant_expires_at (at most 15 minutes, no renewal). No general browser sign-in. Unknown or wrong bindings are indistinguishable; valid-bound stale and expired states use preview_changed and preview_expired. Both device and IP are rate limited.", |
| + "description": "Device bearer only. Returns an opaque 32-byte pass bound to the current person, device, task, candidate and preview deployment. Expires in at most 60 seconds. Exchange only by POST body at /native/preview/exchange on the instance origin; never put the pass in a URL. The exchange issues a host-only, Secure, HttpOnly, SameSite=Strict __Host-equipo-preview-{id} cookie with Path=/, server-authorized only for GET /tasks/{id}/preview, expiring at grant_expires_at (at most 15 minutes, no renewal). No general browser sign-in. Unknown or wrong bindings are indistinguishable; valid-bound stale and expired states use preview_changed and preview_expired. Both device and IP are rate limited.", |
| "security": [ |
| { |
| "personBearer": [] |
| @@ -24268,7 +24268,9 @@ |
| "required": [ |
| "pass", |
| "expires_at", |
| - "grant_expires_at" |
| + "grant_expires_at", |
| + "expires_in", |
| + "grant_expires_in" |
| ], |
| "properties": { |
| "pass": { |
| @@ -24282,6 +24284,18 @@ |
| "grant_expires_at": { |
| "type": "string", |
| "format": "date-time" |
| + }, |
| + "expires_in": { |
| + "type": "integer", |
| + "minimum": 1, |
| + "maximum": 60, |
| + "description": "Whole seconds from server mint time, rounded down. Subtract elapsed request time before starting the local deadline. Absolute timestamps do not constrain the device clock." |
| + }, |
| + "grant_expires_in": { |
| + "type": "integer", |
| + "minimum": 1, |
| + "maximum": 900, |
| + "description": "Whole seconds from server mint time, rounded down; at least expires_in. Subtract elapsed request time. Never renew or extend this deadline." |
| } |
| } |
| }, |
diff --git a/docs/superpowers/plans/2026-11-26-preview-pass.md b/docs/superpowers/plans/2026-11-26-preview-pass.md| index 06da9953..5165aad9 100644 |
| --- a/docs/superpowers/plans/2026-11-26-preview-pass.md |
| +++ b/docs/superpowers/plans/2026-11-26-preview-pass.md |
| @@ -14,7 +14,7 @@ that the existing wrapper would refuse. Do not mint authority to approve an |
| unsafe preview; an already approved preview keeps the wrapper's warning. |
| Return an opaque, cryptographically random 32-byte base64url pass and an |
| -RFC 3339 UTC expiry, never a raw preview address. Store only its SHA-256 hash, |
| +RFC 3339 UTC expiry and bounded whole-second lifetimes from mint time, never a raw preview address. Native subtracts elapsed request time and uses only these lifetimes for its local deadlines, independent of server/device clock skew. Store only its SHA-256 hash, |
| with a separate non-secret audit ID. Bind the record to this instance, person, |
| device credential and session epoch, task ID, candidate SHA, Preview step ID |
| and attempt, and a fingerprint of that deployment (URL, digest, expiry and |
| @@ -41,8 +41,8 @@ have one winner. A known expired or stale pass is terminal, with no grant. |
| DB or audit failures cannot issue a cookie. A lost exchange response requires |
| a new pass; replay does not reproduce a grant. |
| -Success sets a host-only `__Secure-equipo-preview` cookie, Secure, HttpOnly, |
| -SameSite=Strict, with Path `/tasks/{id}/preview`, and redirects with 303 to |
| +Success sets a host-only `__Host-equipo-preview-{taskID}` cookie, Secure, HttpOnly, |
| +SameSite=Strict, with Path `/`, and redirects with 303 to |
| that exact wrapper URL constructed by the server. No caller-provided redirect. |
| The cookie contains a fresh opaque secret, stored hashed. Its lifetime is at |
| most 15 minutes, capped by the device and preview expiries, without sliding |
| @@ -50,12 +50,12 @@ renewal. All exchange/wrapper responses use no-store and no-referrer. |
| This is an ordinary cookie-based browser session with restricted authority, |
| implemented as an app-owned preview grant. It must not create a general |
| -Rastrillo/Oficina ID sign-in session. Cookie Path is only delivery scoping: |
| -server checks also permit exactly GET of the bound task's wrapper. No task |
| +Rastrillo/Oficina ID sign-in session. The host prefix prevents sibling-domain cookie planting: |
| +server checks permit exactly GET of the bound task's wrapper. No task |
| page, API, event stream, attachment, other task, unsafe-preview POST or other |
| mutation accepts it. General session authentication never recognizes this |
| cookie. Keep normal browser sign-in behavior for requests without a preview |
| -grant; an invalid grant must not fall through to a broader signed-in session. |
| +grant. Only a well-formed grant secret under this task’s cookie name selects the restricted lane; junk and other tasks’ cookies are ignored. Once selected, an invalid or expired grant cannot fall through to a broader signed-in session. |
| ## Wrapper, expiry and candidate changes |
| @@ -118,7 +118,24 @@ protocol change is needed. |
| Pass and grant lookups are indexed exact hash matches. Unknown, consumed and |
| wrong-binding requests share the same generic refusal; stale/expired copy is |
| available only after the capability's identity and submitted context validate. |
| -Device and IP limits apply separately. Any preview-cookie presence selects the |
| -restricted lane, even malformed or expired cookies alongside a general session. |
| +Device and IP limits apply separately. A well-formed secret in this task’s Host-prefixed cookie selects the restricted lane, even if unknown or expired alongside a general session. Junk cannot select the lane. |
| Host-only scope and a different iframe cookie host are tested in a real browser. |
| Dismissal, expiry, sign-out and account replacement drop both native resources. |
| + |
| +## Security review refinements, 2026-11-26 |
| + |
| +The server returns expires_in (1–60) and grant_expires_in (1–900), rounded down |
| +from the mint clock. Absolute timestamps are audit/display metadata. Native |
| +subtracts the full elapsed request duration before starting either local |
| +lifetime; it never adds transit time or renews a grant. |
| + |
| +A terminal known pass is consumed and a refused grant is deleted in the same |
| +transaction as its one refusal audit. Replays do not add refusal audits. Expired |
| +rows are pruned after exchange and read too, allowing a first bound expired |
| +request to receive its reviewed words. Both tables have composite device/task |
| +indexes in additive migration 0110. |
| + |
| +Child frames may navigate to about:blank, about:srcdoc, blob: and data: inside |
| +the wrapper sandbox. These schemes remain forbidden for the main frame. Link |
| +previews are disabled. A real nested-frame fixture checks srcdoc and blob |
| +loading through the wrapper in the browser lane and the iPhone simulator. |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md b/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md| index 3d6ea90b..d7fbba90 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md |
| @@ -9,9 +9,11 @@ A device tap mints a 32-byte pass through the device bearer API. A dedicated |
| non-persistent WKWebView posts it in a bounded form body to the instance. The |
| single-use exchange issues a separate, hashed, task-bound browser grant and |
| redirects to the existing preview wrapper. It creates no general sign-in. |
| -The host-only Secure/HttpOnly/SameSite=Strict cookie is scoped to that wrapper |
| -path. Server authority permits only its exact GET. Invalid cookies do not fall |
| -through to the ordinary signed-in browser, including on unsafe-preview POST. |
| +The per-task __Host-equipo-preview-{taskID} cookie is host-only, Secure, |
| +HttpOnly and SameSite=Strict with Path=/. Server authority permits only the |
| +bound wrapper's exact GET. Only a well-formed secret under that task's name |
| +selects the restricted lane; junk and other tasks' cookies are ignored. Once |
| +selected, invalid grants never fall through to ordinary browser sign-in. |
| Pass lifetime is at most 60 seconds; grant lifetime is at most 15 minutes, |
| capped by the originating credential and preview. Reads never extend it. |
| @@ -30,14 +32,16 @@ revalidation checks the task and reloads only the same bound wrapper. |
| No runner protocol change. The additive app-owned tables are in Models and the |
| migration snapshot. The device endpoint and response are in OpenAPI. Existing |
| -browser sign-in continues for requests that have no preview cookie. |
| +browser sign-in continues when no well-formed grant selects the restricted lane. |
| ## Copy |
| -Reused the reviewed web `evidence.candidate_changed` and `question.expired` |
| -byte-identically under parity. Imported the two already-reviewed stop reasons |
| -missing on this base (`merge_credential`, `amadan_unreachable`) to restore the |
| -existing parity gate. No new copy. |
| +Luna approved api.preview_changed and api.preview_expired on 2026-11-26. |
| +Both are marked in copy.go and imported byte-identically under native parity. |
| +The wrapper retains evidence.candidate_changed and question.expired; the unused |
| +native copies of those keys are removed. The original import also restored two |
| +already-reviewed stop reasons missing on the base: merge_credential and |
| +amadan_unreachable. No copy questions remain. |
| ## Test-first evidence |
| @@ -176,3 +180,69 @@ Plan 3 inventory, following its existing explicit key/date acceptance checks. |
| `go test ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1` passed |
| after reproducing the missing-row failure. Test size is 11969 lines. No runtime |
| or native code changed in this inventory correction. |
| + |
| +## Security review delta |
| + |
| +The server returns expires_in and grant_expires_in, rounded down from its mint |
| +clock and bounded to 1–60 and 1–900 seconds. Native ignores absolute timestamps |
| +for enforcement. It subtracts the full monotonic request elapsed time before |
| +starting its local timer; tests use device clocks five minutes ahead and behind, |
| +7.25 seconds of travel, and a pass that expires before receipt. No deadline |
| +slides or gains transit time. |
| + |
| +Host-prefixed per-task cookies prevent sibling-domain planting. Junk and another |
| +task's cookie do not select the restricted lane. Well-formed unknown, expired, |
| +duplicate or refused capabilities cannot fall through to ambient browser auth. |
| +Terminal passes are consumed and grants deleted atomically with one refusal |
| +audit. Replays add no refusal audit. Exchange and read prune expired rows too. |
| +Migration 0110 adds the two composite credential/task indexes without changing |
| +0109. Audit-failure tests prove token retirement rolls back with its audit. |
| + |
| +The child-frame policy permits only about:blank, about:srcdoc, blob: and data: |
| +in addition to the existing HTTPS child policy; main-frame rules are unchanged. |
| +Link previews are disabled. The real browser test now checks nested srcdoc and |
| +blob contents. The iPhone screenshot iphone-preview-frames.png uses the actual |
| +mint/exchange/wrapper and a local HTTPS child fixture. Only the disposable |
| +simulator trusts the local test certificate; production TLS handling is intact. |
| +The fixture initially checked before WebKit's dynamic blob finished; its bounded |
| +five-second content wait now reports ok=true, with all four frame types visible. |
| + |
| +Test-first: preview-delta-go-red.log and preview-delta-native-red.log show the |
| +original implementations failing the new behavior. All 25 delta mutations were |
| +killed by named assertions: relative pass/grant mapping and floor; Host cookie |
| +prefix/root path; junk/other-task lane selection; replay audit; terminal pass |
| +consumption and grant deletion; exchange/read pruning and cutoff; both composite |
| +indexes; device-clock comparison; transit extension and expiry; lifetime bounds |
| +and ordering; child-only schemes, blocked child schemes and unknown about pages; |
| +link previews. Individual logs and results are in the review mutation folders. |
| +One Swift run omitted per-assertion details, but the named child-scheme test |
| +failed with four issues; the result classifier was corrected, not the test. |
| + |
| +Fable's supplied attacks are retained in preview_pass_attack_test.go. Adaptation |
| +is limited to the per-task Host cookie, relative-lifetime checks and making the |
| +log-only duplicate-cookie check assert refusal for two well-formed values. |
| +All five groups passed: 29 path/method tricks; 13 changes between wrapper reads; |
| +secret-at-rest scanning across every database table; 13 exchange-header cases; |
| +grant replacement and bearer/cookie separation. No intended-behavior failure |
| +was found. Command: GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test -p 1 |
| +./internal/equipo -run '^TestReview' -count=1 -v (25.692s). |
| + |
| +The preceding published head ffa46f5a passed Linux CI including TestPerfScreens |
| +and TestPerfBoot. The review delta requires a new exact-head green verdict, |
| +including that same perf lane, before handoff. |
| + |
| +Final local review checks: native/scripts/check-native.sh passed 379 tests in |
| +50 suites (one existing known issue), 334 parity strings and both app builds. |
| +The first attempt hit the existing markdown stream test's three-second wait |
| +under heavy shared-machine load; the unchanged test passed on the full retry. |
| +The final combined preview, Fable attack, browser exchange, API copy and Plan 3 |
| +contract run passed in all three packages. Build, Linux-target vet, staticcheck |
| +v0.7.0 with GOOS=linux GOARCH=amd64, fmt-check, size budgets, migration-model |
| +check, copy-release-check and lane coverage passed. Staticcheck and perf used a |
| +private cloned GOCACHE, without modifying or clearing the shared cache. |
| + |
| +The full macOS make perf invocation reached both performance tests, which passed, |
| +but exited for the existing Linux-only toolproxy unix.O_PATH build error in |
| +three unrelated packages. The focused equipotest performance budget invocation |
| +uses the same required screen/boot tests; the full Linux CI perf lane remains |
| +the final gate. |
diff --git a/internal/equipo/migrations/0110_preview_device_task.sql b/internal/equipo/migrations/0110_preview_device_task.sql| new file mode 100644 |
| index 00000000..556bf9dc |
| --- /dev/null |
| +++ b/internal/equipo/migrations/0110_preview_device_task.sql |
| @@ -0,0 +1,3 @@ |
| +-- Replace pending passes and active grants by indexed device/task identity. |
| +CREATE INDEX idx_preview_passes_device_task ON preview_passes(credential, task_id); |
| +CREATE INDEX idx_preview_grants_device_task ON preview_grants(credential, task_id); |
diff --git a/internal/equipo/preview_frames_fixture_test.go b/internal/equipo/preview_frames_fixture_test.go| new file mode 100644 |
| index 00000000..2ece9328 |
| --- /dev/null |
| +++ b/internal/equipo/preview_frames_fixture_test.go |
| @@ -0,0 +1,18 @@ |
| +package equipo |
| + |
| +// The fixture deliberately exercises child navigations inside the real wrapper. |
| +// These labels are test content, never product copy. |
| +const previewFramesFixture = `<!doctype html><meta name="viewport" content="width=device-width"><style>body{font:18px system-ui;padding:16px;background:#f6faf7;color:#173b26}iframe{display:block;border:1px solid #aac6b3;width:100%;height:64px;margin:12px 0}h1{font-size:24px}</style><h1>Preview frame checks</h1><p id="status">Loading frames</p><iframe id="srcdoc" srcdoc="<p>srcdoc frame loaded</p>"></iframe><iframe id="blob"></iframe><iframe id="data" src="data:text/html,%3Cp%3Edata%20frame%20loaded%3C/p%3E"></iframe><iframe id="blank" src="about:blank"></iframe><script> |
| +const blob = URL.createObjectURL(new Blob(['<p>blob frame loaded</p>'], {type:'text/html'})); |
| +document.querySelector('#blob').src = blob; |
| +window.addEventListener('load',()=>{ |
| + document.querySelector('#blank').contentDocument.body.textContent='about:blank frame loaded'; |
| + const deadline=performance.now()+5000; |
| + const check=()=>{ |
| + const ok = document.querySelector('#srcdoc').contentDocument?.body?.textContent.includes('srcdoc frame loaded') && document.querySelector('#blob').contentDocument?.body?.textContent.includes('blob frame loaded'); |
| + if(!ok && performance.now()<deadline){setTimeout(check,25);return} |
| + document.querySelector('#status').textContent=ok?'srcdoc and blob verified':'Frame check failed'; |
| + fetch('/frames-result?ok='+Boolean(ok)); |
| + }; |
| + check(); |
| +});</script>` |
diff --git a/internal/equipo/preview_pass.go b/internal/equipo/preview_pass.go| index 75727255..b8f93815 100644 |
| --- a/internal/equipo/preview_pass.go |
| +++ b/internal/equipo/preview_pass.go |
| @@ -16,6 +16,8 @@ var ErrPreviewChanged = errors.New("preview candidate changed") |
| type previewPass struct { |
| Pass string `json:"pass"` |
| + ExpiresIn int `json:"expires_in"` |
| + GrantExpiresIn int `json:"grant_expires_in"` |
| ExpiresAt time.Time `json:"expires_at"` |
| GrantExpiresAt time.Time `json:"grant_expires_at"` |
| } |
| @@ -70,6 +72,11 @@ func (s *Store) mintPreviewPass(ctx context.Context, p PersonPrincipal, taskID, |
| grantExpiry = minPreviewTime(grantExpiry, *step.Preview.ExpiresAt) |
| } |
| out = previewPass{Pass: runnerSecret(), ExpiresAt: minPreviewTime(now.Add(time.Minute), grantExpiry), GrantExpiresAt: grantExpiry} |
| + out.ExpiresIn = int(out.ExpiresAt.Sub(now) / time.Second) |
| + out.GrantExpiresIn = int(grantExpiry.Sub(now) / time.Second) |
| + if out.ExpiresIn < 1 || out.GrantExpiresIn < 1 { |
| + return deny(ErrPreviewExpired) |
| + } |
| if e = s.prunePreviews(tx); e != nil { |
| return e |
| } |
| @@ -96,7 +103,12 @@ func (s *Store) exchangePreviewPass(ctx context.Context, token, taskID, candidat |
| var refusal error |
| // Browser exchange authenticates only this pass; no ambient principal grants access. |
| ctx = personapi.WithVerifiedPrincipal(ctx, PersonPrincipal{}) |
| - err = s.write(ctx, func(tx *gorm.DB) error { |
| + err = s.write(ctx, func(tx *gorm.DB) (transactionError error) { |
| + defer func() { |
| + if transactionError == nil { |
| + transactionError = s.prunePreviews(tx) |
| + } |
| + }() |
| ok, e := s.previewRate(tx, "exchange", ip, "") |
| if e != nil { |
| return e |
| @@ -127,14 +139,9 @@ func (s *Store) exchangePreviewPass(ctx context.Context, token, taskID, candidat |
| refusal = ErrPreviewAccess |
| return nil |
| } |
| - if row.ConsumedAt != nil || row.Binding.TaskID != taskID || row.Binding.Candidate != candidate { |
| - refusal = ErrPreviewAccess |
| - return previewRefusal(tx, row.Binding, row.ID, refusal) |
| - } |
| - task, e := s.previewTask(tx, row.Binding) |
| - if e != nil { |
| + if row.ConsumedAt != nil { |
| refusal = ErrPreviewAccess |
| - return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + return nil |
| } |
| now := s.runnerClock.Now().UTC() |
| consumed := tx.Model(&previewPassRecord{}).Where("hash = ? AND consumed_at IS NULL", hash).Select("consumed_at").Updates(map[string]any{"consumed_at": now}) |
| @@ -145,6 +152,15 @@ func (s *Store) exchangePreviewPass(ctx context.Context, token, taskID, candidat |
| refusal = ErrPreviewAccess |
| return nil |
| } |
| + if row.Binding.TaskID != taskID || row.Binding.Candidate != candidate { |
| + refusal = ErrPreviewAccess |
| + return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + } |
| + task, e := s.previewTask(tx, row.Binding) |
| + if e != nil { |
| + refusal = ErrPreviewAccess |
| + return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + } |
| refusal = s.validatePreview(task, row.Binding) |
| if refusal == nil && (!now.Before(row.ExpiresAt) || !now.Before(row.GrantExpiresAt)) { |
| refusal = ErrPreviewExpired |
| @@ -175,7 +191,12 @@ func (s *Store) exchangePreviewPass(ctx context.Context, token, taskID, candidat |
| func (s *Store) readPreviewGrant(ctx context.Context, token, taskID, ip string) (out wire.Task, err error) { |
| var refusal error |
| ctx = personapi.WithVerifiedPrincipal(ctx, PersonPrincipal{}) |
| - err = s.write(ctx, func(tx *gorm.DB) error { |
| + err = s.write(ctx, func(tx *gorm.DB) (transactionError error) { |
| + defer func() { |
| + if transactionError == nil { |
| + transactionError = s.prunePreviews(tx) |
| + } |
| + }() |
| ok, e := s.previewRate(tx, "read", ip, "") |
| if e != nil { |
| return e |
| @@ -205,21 +226,26 @@ func (s *Store) readPreviewGrant(ctx context.Context, token, taskID, ip string) |
| refusal = ErrPreviewAccess |
| return nil |
| } |
| + deny := func(reason error) error { |
| + refusal = reason |
| + if e := tx.Where("hash = ?", hash).Delete(&previewGrantRecord{}).Error; e != nil { |
| + return e |
| + } |
| + return previewRefusal(tx, row.Binding, row.ID, reason) |
| + } |
| if row.Binding.TaskID != taskID { |
| - refusal = ErrPreviewAccess |
| - return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + return deny(ErrPreviewAccess) |
| } |
| task, e := s.previewTask(tx, row.Binding) |
| if e != nil { |
| - refusal = ErrPreviewAccess |
| - return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + return deny(ErrPreviewAccess) |
| } |
| refusal = s.validatePreview(task, row.Binding) |
| if refusal == nil && !s.runnerClock.Now().Before(row.ExpiresAt) { |
| refusal = ErrPreviewExpired |
| } |
| if refusal != nil { |
| - return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + return deny(refusal) |
| } |
| out = task |
| return nil |
diff --git a/internal/equipo/preview_pass_attack_test.go b/internal/equipo/preview_pass_attack_test.go| new file mode 100644 |
| index 00000000..8acaf340 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_attack_test.go |
| @@ -0,0 +1,304 @@ |
| +package equipo |
| + |
| +// Adversarial cases supplied by Fable, retained as permanent regressions. |
| +// Adapted to the approved per-task Host cookie and relative lifetime contract. |
| + |
| +import ( |
| + "database/sql" |
| + "encoding/hex" |
| + "encoding/json" |
| + "fmt" |
| + "net/http" |
| + "net/http/httptest" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/rastrillo/rastrillo/sessions" |
| + "gorm.io/gorm" |
| +) |
| + |
| +func reviewFlow(t *testing.T, r *previewPassRig, h http.Handler) (previewPass, *http.Cookie) { |
| + t.Helper() |
| + minted := agentRequest(h, "POST", "/api/v1/tasks/tk_preview/preview-pass", `{"candidate_sha":"`+passCandidate+`"}`, r.credential.Token) |
| + if minted.Code != 201 { |
| + t.Fatalf("mint: %d %s", minted.Code, minted.Body) |
| + } |
| + var pass previewPass |
| + if e := json.Unmarshal(minted.Body.Bytes(), &pass); e != nil { |
| + t.Fatal(e) |
| + } |
| + if pass.ExpiresIn < 1 || pass.ExpiresIn > 60 || pass.GrantExpiresIn < pass.ExpiresIn || pass.GrantExpiresIn > 900 { |
| + t.Fatal("unbounded relative lifetime") |
| + } |
| + w := httptest.NewRecorder() |
| + h.ServeHTTP(w, passExchangeRequest(pass.Pass, "tk_preview", passCandidate)) |
| + if w.Code != 303 { |
| + t.Fatalf("exchange: %d %s", w.Code, w.Body) |
| + } |
| + return pass, w.Result().Cookies()[0] |
| +} |
| + |
| +func reviewGet(h http.Handler, method, path string, cookie *http.Cookie) *httptest.ResponseRecorder { |
| + req := httptest.NewRequest(method, "https://equipo.example"+path, nil) |
| + if cookie != nil { |
| + req.AddCookie(cookie) |
| + } |
| + if method != "GET" && method != "HEAD" { |
| + req.Header.Set("Origin", "https://equipo.example") |
| + } |
| + w := httptest.NewRecorder() |
| + h.ServeHTTP(w, req) |
| + return w |
| +} |
| + |
| +func TestReviewPathTricks(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + _, cookie := reviewFlow(t, r, h) |
| + if w := reviewGet(h, "GET", "/tasks/tk_preview/preview", cookie); w.Code != 200 { |
| + t.Fatalf("baseline %d", w.Code) |
| + } |
| + for _, c := range []struct{ method, path string }{ |
| + {"GET", "/tasks/tk_preview/preview/"}, |
| + {"GET", "/tasks/tk_preview/preview/.."}, |
| + {"GET", "/tasks/tk_preview/preview/../../tk_preview"}, |
| + {"GET", "/tasks/tk_preview/preview/../rendered-change"}, |
| + {"GET", "/tasks/tk_preview/preview-evil"}, |
| + {"GET", "/tasks/tk_preview%2Fpreview"}, |
| + {"GET", "/tasks/tk%5Fpreview/preview"}, |
| + {"GET", "/tasks/tk_preview/preview%2F..%2F..%2Ftk_preview"}, |
| + {"GET", "/tasks/tk_preview/preview?x=1"}, |
| + {"GET", "/tasks/tk_preview/preview;x"}, |
| + {"GET", "//tasks/tk_preview/preview"}, |
| + {"GET", "/tasks/tk_preview/./preview"}, |
| + {"GET", "/tasks/tk_preview/%70review"}, |
| + {"GET", "/tasks/tk_preview/preview%00"}, |
| + {"GET", "/tasks/tk_preview/rendered-change"}, |
| + {"GET", "/tasks/tk_preview/files/x"}, |
| + {"GET", "/tasks/tk_preview/move"}, |
| + {"GET", "/tasks"}, |
| + {"GET", "/conversation"}, |
| + {"GET", "/live"}, |
| + {"GET", "/api/v1/me"}, |
| + {"GET", "/api/v1/tasks"}, |
| + {"GET", "/api/v1/tasks/tk_preview"}, |
| + {"POST", "/api/v1/tasks/tk_preview/preview-pass"}, |
| + {"POST", "/tasks/tk_preview/preview"}, |
| + {"POST", "/tasks/tk_preview/notes"}, |
| + {"HEAD", "/tasks/tk_preview/preview"}, |
| + {"PUT", "/tasks/tk_preview/preview"}, |
| + {"DELETE", "/tasks/tk_preview/preview"}, |
| + } { |
| + w := reviewGet(h, c.method, c.path, cookie) |
| + leaked := strings.Contains(w.Body.String(), "eq-preview.example.test") || strings.Contains(w.Body.String(), "<iframe") |
| + t.Logf("%-6s %-55s -> %d leaked=%v loc=%q", c.method, c.path, w.Code, leaked, w.Header().Get("Location")) |
| + if (w.Code >= 200 && w.Code < 300) || leaked { |
| + t.Errorf("grant escaped: %s %s -> %d", c.method, c.path, w.Code) |
| + } |
| + } |
| +} |
| + |
| +func TestReviewStateChangesBetweenWrapperReads(t *testing.T) { |
| + for _, kind := range []string{"epoch", "revoked", "device-expired", "native-session", "member", "member-removed", "redeploy-url", "redeploy-digest", "unsafe", "final", "candidate", "new-preview-step", "task-deleted"} { |
| + t.Run(kind, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + _, cookie := reviewFlow(t, r, h) |
| + if w := reviewGet(h, "GET", "/tasks/tk_preview/preview", cookie); w.Code != 200 { |
| + t.Fatalf("baseline %d", w.Code) |
| + } |
| + exec := func(q string, args ...any) { |
| + t.Helper() |
| + if _, e := r.s.db.Writer().Exec(q, args...); e != nil { |
| + t.Fatal(e) |
| + } |
| + } |
| + switch kind { |
| + case "epoch": |
| + exec("UPDATE members SET session_epoch=?", r.clock.Now().Add(time.Second).Unix()) |
| + case "revoked": |
| + exec("UPDATE person_devices SET revoked_at=?", r.clock.Now()) |
| + case "device-expired": |
| + exec("UPDATE person_devices SET token_expires_at=?", r.clock.Now()) |
| + case "native-session": |
| + r.s.personNativeSession = func(*gorm.DB, string) (sessions.Session, error) { return sessions.Session{}, sql.ErrNoRows } |
| + case "member": |
| + exec("UPDATE members SET active=0") |
| + case "member-removed": |
| + exec("DELETE FROM members") |
| + case "redeploy-url": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.url','https://eq-other.example.test/') WHERE id='preview_step'") |
| + case "redeploy-digest": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.digest',?) WHERE id='preview_step'", strings.Repeat("b", 64)) |
| + case "unsafe": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.unsafe',json('true')) WHERE id='preview_step'") |
| + case "final": |
| + exec("UPDATE chat_tasks SET stage='done'") |
| + case "candidate": |
| + exec("UPDATE chat_steps SET candidate_sha=? WHERE id='eng_preview'", strings.Repeat("2", 40)) |
| + case "new-preview-step": |
| + exec("INSERT INTO chat_steps(id,task_id,idx,specialist,state,attempt,candidate_sha,revision) VALUES('preview_step2','tk_preview',2,'preview','running',1,?,1)", passCandidate) |
| + case "task-deleted": |
| + exec("DELETE FROM chat_tasks WHERE id='tk_preview'") |
| + } |
| + w := reviewGet(h, "GET", "/tasks/tk_preview/preview", cookie) |
| + t.Logf("%s -> %d", kind, w.Code) |
| + if w.Code < 400 || strings.Contains(w.Body.String(), "<iframe") { |
| + t.Errorf("%s: wrapper still served: %d", kind, w.Code) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestReviewSecretsNeverAtRest(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + pass, cookie := reviewFlow(t, r, h) |
| + _ = reviewGet(h, "GET", "/tasks/tk_preview/preview", cookie) |
| + _ = reviewGet(h, "GET", "/tasks/tk_other/preview", cookie) |
| + // replay and wrong binding, to exercise refusal audits |
| + w := httptest.NewRecorder() |
| + h.ServeHTTP(w, passExchangeRequest(pass.Pass, "tk_preview", passCandidate)) |
| + db := r.s.db.Reader() |
| + rows, e := db.Query("SELECT name FROM sqlite_master WHERE type='table'") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + var tables []string |
| + for rows.Next() { |
| + var n string |
| + _ = rows.Scan(&n) |
| + tables = append(tables, n) |
| + } |
| + rows.Close() |
| + needles := []string{pass.Pass, cookie.Value} |
| + for _, n := range []string{pass.Pass, cookie.Value} { |
| + needles = append(needles, hex.EncodeToString([]byte(n))) |
| + } |
| + for _, table := range tables { |
| + cols, e := db.Query("SELECT name FROM pragma_table_info('" + table + "')") |
| + if e != nil { |
| + continue |
| + } |
| + var names []string |
| + for cols.Next() { |
| + var n string |
| + _ = cols.Scan(&n) |
| + names = append(names, n) |
| + } |
| + cols.Close() |
| + for _, col := range names { |
| + for i, needle := range needles { |
| + var count int |
| + q := fmt.Sprintf(`SELECT count(*) FROM "%s" WHERE instr(CAST("%s" AS text), ?) > 0 OR instr(lower(hex("%s")), ?) > 0`, table, col, col) |
| + if e := db.QueryRow(q, needle, needle).Scan(&count); e != nil { |
| + continue |
| + } |
| + if count > 0 { |
| + t.Errorf("secret %d at rest in %s.%s", i, table, col) |
| + } |
| + } |
| + } |
| + } |
| + t.Logf("scanned %d tables", len(tables)) |
| +} |
| + |
| +func TestReviewExchangeHeaders(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + for _, c := range []struct { |
| + name string |
| + set func(*http.Request) |
| + ok bool |
| + }{ |
| + {"no-evidence", func(q *http.Request) { q.Header.Del("Origin") }, false}, |
| + {"origin-null", func(q *http.Request) { q.Header.Set("Origin", "null") }, false}, |
| + {"same-site", func(q *http.Request) { q.Header.Set("Sec-Fetch-Site", "same-site") }, false}, |
| + {"same-site-no-origin", func(q *http.Request) { q.Header.Del("Origin"); q.Header.Set("Sec-Fetch-Site", "same-site") }, false}, |
| + {"cross-site-good-origin", func(q *http.Request) { q.Header.Set("Sec-Fetch-Site", "cross-site") }, false}, |
| + {"none-no-origin", func(q *http.Request) { q.Header.Del("Origin"); q.Header.Set("Sec-Fetch-Site", "none") }, true}, |
| + {"none-evil-origin", func(q *http.Request) { |
| + q.Header.Set("Origin", "https://evil.example") |
| + q.Header.Set("Sec-Fetch-Site", "none") |
| + }, false}, |
| + {"two-origins", func(q *http.Request) { q.Header.Add("Origin", "https://evil.example") }, false}, |
| + {"origin-case", func(q *http.Request) { q.Header.Set("Origin", "https://EQUIPO.example") }, false}, |
| + {"origin-port", func(q *http.Request) { q.Header.Set("Origin", "https://equipo.example:443") }, false}, |
| + {"cookie-session-junk", func(q *http.Request) { q.Header.Set("Cookie", "x=y") }, true}, |
| + {"charset", func(q *http.Request) { |
| + q.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") |
| + }, true}, |
| + {"multipart", func(q *http.Request) { q.Header.Set("Content-Type", "multipart/form-data; boundary=x") }, false}, |
| + } { |
| + p := r.mint(t) |
| + r.clock.Advance(7 * time.Second) // stay inside the 10/min mint limit |
| + q := passExchangeRequest(p.Pass, "tk_preview", passCandidate) |
| + c.set(q) |
| + w := httptest.NewRecorder() |
| + h.ServeHTTP(w, q) |
| + t.Logf("%-24s -> %d cookie=%v", c.name, w.Code, w.Header().Get("Set-Cookie") != "") |
| + if (w.Code == 303) != c.ok { |
| + t.Errorf("%s: got %d", c.name, w.Code) |
| + } |
| + if w.Code != 303 && w.Header().Get("Set-Cookie") != "" { |
| + t.Errorf("%s: cookie on refusal", c.name) |
| + } |
| + if strings.Contains(w.Body.String(), p.Pass) || strings.Contains(w.Header().Get("Location"), p.Pass) { |
| + t.Errorf("%s: pass reflected", c.name) |
| + } |
| + } |
| +} |
| + |
| +func TestReviewNewGrantReplacesOldAndMintNeedsDeviceBearer(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + _, first := reviewFlow(t, r, h) |
| + _, second := reviewFlow(t, r, h) |
| + if w := reviewGet(h, "GET", "/tasks/tk_preview/preview", first); w.Code == 200 { |
| + t.Errorf("old grant still live after a new presentation") |
| + } |
| + if w := reviewGet(h, "GET", "/tasks/tk_preview/preview", second); w.Code != 200 { |
| + t.Errorf("new grant refused %d", w.Code) |
| + } |
| + // both cookies at once: restricted lane, refused |
| + req := httptest.NewRequest("GET", "https://equipo.example/tasks/tk_preview/preview", nil) |
| + req.Header.Set("Cookie", second.Name+"="+first.Value+"; "+second.Name+"="+second.Value) |
| + w := httptest.NewRecorder() |
| + h.ServeHTTP(w, req) |
| + t.Logf("tossed duplicate cookie -> %d", w.Code) |
| + if w.Code != 404 { |
| + t.Fatal("duplicate capabilities accepted", w.Code) |
| + } |
| + // the preview cookie cannot mint |
| + req = httptest.NewRequest("POST", "https://equipo.example/api/v1/tasks/tk_preview/preview-pass", strings.NewReader(`{"candidate_sha":"`+passCandidate+`"}`)) |
| + req.Header.Set("Content-Type", "application/json") |
| + req.Header.Set("Origin", "https://equipo.example") |
| + req.AddCookie(second) |
| + w = httptest.NewRecorder() |
| + h.ServeHTTP(w, req) |
| + if w.Code == 201 { |
| + t.Errorf("cookie minted a pass") |
| + } |
| + // bearer + cookie together |
| + req = httptest.NewRequest("POST", "https://equipo.example/api/v1/tasks/tk_preview/preview-pass", strings.NewReader(`{"candidate_sha":"`+passCandidate+`"}`)) |
| + req.Header.Set("Content-Type", "application/json") |
| + req.Header.Set("Authorization", "Bearer "+r.credential.Token) |
| + req.AddCookie(second) |
| + w = httptest.NewRecorder() |
| + h.ServeHTTP(w, req) |
| + t.Logf("bearer+cookie mint -> %d", w.Code) |
| + if w.Code == 201 { |
| + t.Errorf("bearer with cookie minted a pass") |
| + } |
| + // the grant secret is not a pass, and the pass is not a grant |
| + p := r.mint(t) |
| + if w := reviewGet(h, "GET", "/tasks/tk_preview/preview", &http.Cookie{Name: second.Name, Value: p.Pass}); w.Code == 200 { |
| + t.Errorf("pass accepted as grant cookie") |
| + } |
| + w = httptest.NewRecorder() |
| + h.ServeHTTP(w, passExchangeRequest(second.Value, "tk_preview", passCandidate)) |
| + if w.Code == 303 { |
| + t.Errorf("grant secret accepted as pass") |
| + } |
| +} |
diff --git a/internal/equipo/preview_pass_browser_test.go b/internal/equipo/preview_pass_browser_test.go| index 07ebf575..9093d153 100644 |
| --- a/internal/equipo/preview_pass_browser_test.go |
| +++ b/internal/equipo/preview_pass_browser_test.go |
| @@ -27,7 +27,12 @@ func TestBrowserPreviewPassExchange(t *testing.T) { |
| case childRequests <- r.Clone(context.Background()): |
| default: |
| } |
| - fmt.Fprint(w, `<h1>Candidate preview</h1>`) |
| + if r.URL.Path == "/frames-result" { |
| + w.WriteHeader(204) |
| + return |
| + } |
| + w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| + fmt.Fprint(w, previewFramesFixture) |
| })) |
| defer child.Close() |
| // Cookies do not distinguish ports. Different hosts are essential here. |
| @@ -92,6 +97,20 @@ func TestBrowserPreviewPassExchange(t *testing.T) { |
| case <-ctx.Done(): |
| t.Fatal("wrapper iframe never loaded") |
| } |
| + verified := false |
| + for !verified { |
| + select { |
| + case request := <-childRequests: |
| + if request.URL.Path == "/frames-result" { |
| + if request.URL.Query().Get("ok") != "true" { |
| + t.Fatal("srcdoc/blob fixture failed") |
| + } |
| + verified = true |
| + } |
| + case <-ctx.Done(): |
| + t.Fatal("srcdoc/blob frame results missing") |
| + } |
| + } |
| location, err := chromedp.Run(ctx, chromedp.Evaluate[string](`location.href`)) |
| if err != nil || location != parentURL+"/tasks/tk_preview/preview" { |
| t.Fatalf("location=%q err=%v", location, err) |
diff --git a/internal/equipo/preview_pass_delta_test.go b/internal/equipo/preview_pass_delta_test.go| new file mode 100644 |
| index 00000000..d2877ce9 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_delta_test.go |
| @@ -0,0 +1,180 @@ |
| +package equipo |
| + |
| +import ( |
| + "encoding/json" |
| + "errors" |
| + "net/http" |
| + "net/http/httptest" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/go-chi/chi/v5" |
| +) |
| + |
| +func TestPreviewRelativeLifetimes(t *testing.T) { |
| + for _, seconds := range []int{900, 123, 30} { |
| + t.Run(time.Duration(seconds).String(), func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + if _, e := r.s.db.Writer().Exec("UPDATE person_devices SET token_expires_at=? WHERE id=?", r.clock.Now().Add(time.Duration(seconds)*time.Second+999*time.Millisecond), r.credential.ID); e != nil { |
| + t.Fatal(e) |
| + } |
| + p := r.mint(t) |
| + raw, _ := json.Marshal(p) |
| + var fields map[string]any |
| + if e := json.Unmarshal(raw, &fields); e != nil { |
| + t.Fatal(e) |
| + } |
| + if fields["expires_in"] != float64(min(60, seconds)) || fields["grant_expires_in"] != float64(seconds) { |
| + t.Fatalf("relative deadlines: %s", raw) |
| + } |
| + }) |
| + } |
| +} |
| +func TestPreviewJunkAndOtherTaskCookiesDoNotSelectRestrictedLane(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + app := &application{store: r.s, origin: r.s.personOrigin} |
| + for _, cookie := range []string{ |
| + "__Host-equipo-preview-tk_preview=junk", |
| + "__Host-equipo-preview-tk_other=" + strings.Repeat("A", 43), |
| + "__Secure-equipo-preview=junk", |
| + } { |
| + route := chi.NewRouter() |
| + route.Get("/tasks/{id}/preview", app.previewGrantOrBrowser(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(204) })).ServeHTTP) |
| + req := httptest.NewRequest("GET", "https://equipo.example/tasks/tk_preview/preview", nil) |
| + req.Header.Set("Cookie", cookie) |
| + w := httptest.NewRecorder() |
| + route.ServeHTTP(w, req) |
| + if w.Code != 204 { |
| + t.Fatalf("planted cookie blocked browser: %q: %d", cookie, w.Code) |
| + } |
| + } |
| +} |
| +func TestPreviewTerminalRefusalsAuditOnce(t *testing.T) { |
| + for _, mode := range []string{"pass", "grant"} { |
| + for _, reason := range []string{"revoked", "member", "epoch", "stale"} { |
| + t.Run(mode+"/"+reason, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + token := p.Pass |
| + if mode == "grant" { |
| + g, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + token = g.Secret |
| + } |
| + query := "UPDATE person_devices SET revoked_at=CURRENT_TIMESTAMP" |
| + switch reason { |
| + case "member": |
| + query = "UPDATE members SET active=0" |
| + case "epoch": |
| + query = "UPDATE members SET session_epoch=session_epoch+86400" |
| + case "stale": |
| + query = "UPDATE chat_steps SET attempt=2 WHERE id='preview_step'" |
| + } |
| + if _, e := r.s.db.Writer().Exec(query); e != nil { |
| + t.Fatal(e) |
| + } |
| + for i := 0; i < 3; i++ { |
| + var e error |
| + if mode == "pass" { |
| + _, e = r.s.exchangePreviewPass(r.ctx, token, "tk_preview", passCandidate, "192.0.2.1") |
| + } else { |
| + _, e = r.s.readPreviewGrant(r.ctx, token, "tk_preview", "192.0.2.1") |
| + } |
| + if e == nil { |
| + t.Fatal("accepted dead token") |
| + } |
| + if i > 0 && !errors.Is(e, ErrPreviewAccess) { |
| + t.Fatal("repeated identifiable refusal", e) |
| + } |
| + } |
| + var audits int |
| + if e := r.s.db.Reader().QueryRow("SELECT count(*) FROM audit_events WHERE kind='preview.pass.refused'").Scan(&audits); e != nil || audits != 1 { |
| + t.Fatal("terminal refusal audit count", audits, e) |
| + } |
| + query = "SELECT count(*) FROM preview_passes WHERE consumed_at IS NULL" |
| + if mode == "grant" { |
| + query = "SELECT count(*) FROM preview_grants" |
| + } |
| + var active int |
| + if e := r.s.db.Reader().QueryRow(query).Scan(&active); e != nil || active != 0 { |
| + t.Fatal("dead token retained", active, e) |
| + } |
| + }) |
| + } |
| + } |
| +} |
| +func TestPreviewPrunesWithoutAnotherMint(t *testing.T) { |
| + for _, operation := range []string{"exchange", "read"} { |
| + t.Run(operation, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + if _, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1"); e != nil { |
| + t.Fatal(e) |
| + } |
| + r.clock.Advance(16 * time.Minute) |
| + if operation == "exchange" { |
| + _, _ = r.s.exchangePreviewPass(r.ctx, strings.Repeat("A", 43), "tk_preview", passCandidate, "192.0.2.1") |
| + } else { |
| + _, _ = r.s.readPreviewGrant(r.ctx, strings.Repeat("A", 43), "tk_preview", "192.0.2.1") |
| + } |
| + for _, table := range []string{"preview_passes", "preview_grants"} { |
| + var n int |
| + if e := r.s.db.Reader().QueryRow("SELECT count(*) FROM " + table).Scan(&n); e != nil || n != 0 { |
| + t.Fatal("expired rows retained", table, n, e) |
| + } |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestPreviewTerminalAuditRollback(t *testing.T) { |
| + for _, mode := range []string{"pass", "grant"} { |
| + t.Run(mode, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + token := p.Pass |
| + if mode == "grant" { |
| + g, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + token = g.Secret |
| + } |
| + if _, e := r.s.db.Writer().Exec("UPDATE chat_steps SET attempt=2 WHERE id='preview_step'"); e != nil { |
| + t.Fatal(e) |
| + } |
| + if _, e := r.s.db.Writer().Exec(`CREATE TRIGGER deny_preview_refusal BEFORE INSERT ON audit_events WHEN NEW.kind='preview.pass.refused' BEGIN SELECT RAISE(ABORT,'fixture'); END`); e != nil { |
| + t.Fatal(e) |
| + } |
| + var e error |
| + if mode == "pass" { |
| + _, e = r.s.exchangePreviewPass(r.ctx, token, "tk_preview", passCandidate, "192.0.2.1") |
| + } else { |
| + _, e = r.s.readPreviewGrant(r.ctx, token, "tk_preview", "192.0.2.1") |
| + } |
| + if e == nil { |
| + t.Fatal("accepted without audit") |
| + } |
| + query := "SELECT count(*) FROM preview_passes WHERE consumed_at IS NULL" |
| + if mode == "grant" { |
| + query = "SELECT count(*) FROM preview_grants" |
| + } |
| + var count int |
| + if e := r.s.db.Reader().QueryRow(query).Scan(&count); e != nil || count != 1 { |
| + t.Fatal("non-transactional terminal change", count, e) |
| + } |
| + }) |
| + } |
| +} |
| +func TestPreviewDeviceTaskIndexes(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + for _, table := range []string{"preview_passes", "preview_grants"} { |
| + var definition string |
| + if e := r.s.db.Reader().QueryRow("SELECT sql FROM sqlite_master WHERE type='index' AND name=?", "idx_"+table+"_device_task").Scan(&definition); e != nil || !strings.Contains(definition, "(credential, task_id)") { |
| + t.Fatal("missing composite index", table, definition, e) |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/preview_pass_fixture_test.go b/internal/equipo/preview_pass_fixture_test.go| index ffdc3bf8..7b364dc4 100644 |
| --- a/internal/equipo/preview_pass_fixture_test.go |
| +++ b/internal/equipo/preview_pass_fixture_test.go |
| @@ -4,8 +4,10 @@ package equipo |
| import ( |
| "encoding/json" |
| + "encoding/pem" |
| "net" |
| "net/http" |
| + "net/http/httptest" |
| "os" |
| "testing" |
| "time" |
| @@ -25,7 +27,24 @@ func TestPreviewScreenshotServer(t *testing.T) { |
| r := newPreviewPassRigAt(t, time.Now().UTC().Truncate(time.Second)) |
| r.s.runnerClock = team.RealClock{} |
| r.s.personOrigin = origin |
| - if _, e := r.s.db.Writer().Exec("UPDATE chat_steps SET preview=json_set(preview,'$.url','https://example.com/') WHERE id='preview_step'"); e != nil { |
| + previewURL := "https://example.com/" |
| + if certPath := os.Getenv("EQUIPO_PREVIEW_CHILD_CERT"); certPath != "" { |
| + child := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { |
| + if req.URL.Path == "/frames-result" { |
| + _ = os.WriteFile(certPath+".result", []byte(req.URL.RawQuery), 0600) |
| + w.WriteHeader(204) |
| + return |
| + } |
| + w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| + _, _ = w.Write([]byte(previewFramesFixture)) |
| + })) |
| + defer child.Close() |
| + if e := os.WriteFile(certPath, pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: child.Certificate().Raw}), 0600); e != nil { |
| + t.Fatal(e) |
| + } |
| + previewURL = child.URL + "/" |
| + } |
| + if _, e := r.s.db.Writer().Exec("UPDATE chat_steps SET preview=json_set(preview,'$.url',?) WHERE id='preview_step'", previewURL); e != nil { |
| t.Fatal(e) |
| } |
| if _, e := r.s.db.Writer().Exec("UPDATE chat_tasks SET title='Review the example page',brief='Check the page in the sandboxed preview before merging.' WHERE id='tk_preview'"); e != nil { |
diff --git a/internal/equipo/preview_pass_http.go b/internal/equipo/preview_pass_http.go| index 5ff57c91..fba148f7 100644 |
| --- a/internal/equipo/preview_pass_http.go |
| +++ b/internal/equipo/preview_pass_http.go |
| @@ -9,7 +9,6 @@ import ( |
| "mime" |
| "net/http" |
| "regexp" |
| - "strings" |
| "time" |
| "amadan.net/oficina/equipo/internal/equipo/personapi" |
| @@ -19,7 +18,7 @@ import ( |
| "github.com/go-chi/chi/v5" |
| ) |
| -const previewCookie = "__Secure-equipo-preview" |
| +const previewCookie = "__Host-equipo-preview-" |
| var previewTaskID = regexp.MustCompile(`^[A-Za-z0-9_-]{1,128}$`) |
| var previewCandidate = regexp.MustCompile(`^[0-9a-f]{40}$`) |
| @@ -132,39 +131,36 @@ func (a *application) exchangePreviewHTTP(w http.ResponseWriter, r *http.Request |
| previewErrorPage(w, ErrPreviewExpired) |
| return |
| } |
| - http.SetCookie(w, &http.Cookie{Name: previewCookie, Value: grant.Secret, Path: path, Secure: true, HttpOnly: true, SameSite: http.SameSiteStrictMode, MaxAge: left, Expires: grant.ExpiresAt}) |
| + http.SetCookie(w, &http.Cookie{Name: previewCookie + grant.TaskID, Value: grant.Secret, Path: "/", Secure: true, HttpOnly: true, SameSite: http.SameSiteStrictMode, MaxAge: left, Expires: grant.ExpiresAt}) |
| w.Header().Set("Location", path) |
| w.WriteHeader(http.StatusSeeOther) |
| } |
| -// Presence is checked independently of cookie parsing. Malformed and duplicate |
| -// grant cookies must not restore the broader authority of an ambient session. |
| -func hasPreviewCookie(r *http.Request) bool { |
| - for _, header := range r.Header.Values("Cookie") { |
| - for _, part := range strings.Split(header, ";") { |
| - name, _, _ := strings.Cut(part, "=") |
| - if strings.TrimSpace(name) == previewCookie { |
| - return true |
| - } |
| +// Only this task's well-formed capability selects the restricted lane. |
| +// Junk and other tasks' cookies do not block ordinary browser access. |
| +func hasPreviewCookie(r *http.Request, taskID string) bool { |
| + for _, cookie := range r.Cookies() { |
| + if cookie.Name == previewCookie+taskID && previewHash(cookie.Value) != "" { |
| + return true |
| } |
| } |
| return false |
| } |
| func (a *application) previewGrantOrBrowser(next http.Handler) http.Handler { |
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| - if !hasPreviewCookie(r) { |
| + taskID := chi.URLParam(r, "id") |
| + if !hasPreviewCookie(r, taskID) { |
| next.ServeHTTP(w, r) |
| return |
| } |
| var value string |
| count := 0 |
| for _, c := range r.Cookies() { |
| - if c.Name == previewCookie { |
| + if c.Name == previewCookie+taskID && previewHash(c.Value) != "" { |
| value = c.Value |
| count++ |
| } |
| } |
| - taskID := chi.URLParam(r, "id") |
| if count != 1 || r.Method != "GET" || r.URL.RawQuery != "" || !previewTaskID.MatchString(taskID) || r.URL.EscapedPath() != "/tasks/"+taskID+"/preview" { |
| previewErrorPage(w, ErrPreviewAccess) |
| return |
diff --git a/internal/equipo/preview_pass_http_test.go b/internal/equipo/preview_pass_http_test.go| index 3236d9b3..b7aadef8 100644 |
| --- a/internal/equipo/preview_pass_http_test.go |
| +++ b/internal/equipo/preview_pass_http_test.go |
| @@ -60,7 +60,7 @@ func TestPreviewPassHTTPFlowAndIsolation(t *testing.T) { |
| t.Fatal("cookies", cookies) |
| } |
| cookie := cookies[0] |
| - if cookie.Name != "__Secure-equipo-preview" || cookie.Domain != "" || cookie.Path != "/tasks/tk_preview/preview" || !cookie.HttpOnly || !cookie.Secure || cookie.SameSite != http.SameSiteStrictMode || cookie.MaxAge != 900 { |
| + if cookie.Name != "__Host-equipo-preview-tk_preview" || cookie.Domain != "" || cookie.Path != "/" || !cookie.HttpOnly || !cookie.Secure || cookie.SameSite != http.SameSiteStrictMode || cookie.MaxAge != 900 { |
| t.Fatalf("cookie attributes: %+v", cookie) |
| } |
| for _, route := range []struct { |
| @@ -93,7 +93,8 @@ func TestPreviewCookiePresenceNeverFallsThrough(t *testing.T) { |
| // Even an otherwise valid browser session must not rescue a refused grant. |
| normal := 0 |
| app := &application{store: r.s, origin: r.s.personOrigin} |
| - for _, raw := range []string{"__Secure-equipo-preview=invalid", "__Secure-equipo-preview=", "__Secure-equipo-preview=\"broken", "__Secure-equipo-preview=a; __Secure-equipo-preview=b"} { |
| + secret := strings.Repeat("A", 43) |
| + for _, raw := range []string{"__Host-equipo-preview-tk_preview=" + secret, "__Host-equipo-preview-tk_preview=" + secret + "; __Host-equipo-preview-tk_preview=" + secret} { |
| route := chi.NewRouter() |
| route.Get("/tasks/{id}/preview", app.previewGrantOrBrowser(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { normal++; w.WriteHeader(200) })).ServeHTTP) |
| req := httptest.NewRequest("GET", "https://equipo.example/tasks/tk_preview/preview", nil) |
| @@ -170,7 +171,7 @@ func TestPreviewExpiredCookieAndUnsafePOSTNeverFallThrough(t *testing.T) { |
| ctx := chi.NewRouteContext() |
| ctx.URLParams.Add("id", "tk_preview") |
| req = req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, ctx)) |
| - req.Header.Set("Cookie", previewCookie+"="+grant.Secret+"; normal-session=valid-browser-session") |
| + req.Header.Set("Cookie", previewCookie+"tk_preview="+grant.Secret+"; normal-session=valid-browser-session") |
| out := httptest.NewRecorder() |
| handler.ServeHTTP(out, req) |
| if out.Code < 400 || calls != 0 { |
diff --git a/internal/equipo/preview_pass_security_test.go b/internal/equipo/preview_pass_security_test.go| index e28744dc..a35740da 100644 |
| --- a/internal/equipo/preview_pass_security_test.go |
| +++ b/internal/equipo/preview_pass_security_test.go |
| @@ -267,8 +267,8 @@ func TestPreviewKnownRefusalsAreAuditedAndDeviceLimited(t *testing.T) { |
| t.Fatal("known refusals bypassed device rate", err) |
| } |
| var count int |
| - if err := r.s.db.Reader().QueryRow("SELECT count(*) FROM audit_events WHERE kind='preview.pass.refused'").Scan(&count); err != nil || count != 10 { |
| - t.Fatal("known refusals missing audit", count, err) |
| + if err := r.s.db.Reader().QueryRow("SELECT count(*) FROM audit_events WHERE kind='preview.pass.refused'").Scan(&count); err != nil || count != 1 { |
| + t.Fatal("known refusal must be audited once", count, err) |
| } |
| } |
| func TestPreviewStaleMintHasRefusalAudit(t *testing.T) { |
diff --git a/internal/equipo/preview_pass_store.go b/internal/equipo/preview_pass_store.go| index 1dfcd1f8..0286de4f 100644 |
| --- a/internal/equipo/preview_pass_store.go |
| +++ b/internal/equipo/preview_pass_store.go |
| @@ -18,8 +18,10 @@ import ( |
| ) |
| type previewBinding struct { |
| - Instance, Person, Credential, TaskID, Candidate, StepID, Fingerprint string |
| - Epoch, Attempt int64 |
| + Instance, Person, Candidate, StepID, Fingerprint string |
| + Credential string `gorm:"index:,composite:device_task,priority:1"` |
| + TaskID string `gorm:"index:,composite:device_task,priority:2"` |
| + Epoch, Attempt int64 |
| } |
| type previewPassRecord struct { |
| Hash string `gorm:"primaryKey"` |
| @@ -136,11 +138,11 @@ func (s *Store) previewRate(tx *gorm.DB, kind, ip, device string) (bool, error) |
| } |
| func (s *Store) prunePreviews(tx *gorm.DB) error { |
| // Indexed expiry predicates; no secret lookup ever scans these tables. |
| - cutoff := s.runnerClock.Now().Add(-time.Hour) |
| - if err := tx.Where("expires_at < ?", cutoff).Delete(&previewPassRecord{}).Error; err != nil { |
| + cutoff := s.runnerClock.Now() |
| + if err := tx.Where("expires_at <= ?", cutoff).Delete(&previewPassRecord{}).Error; err != nil { |
| return err |
| } |
| - return tx.Where("expires_at < ?", cutoff).Delete(&previewGrantRecord{}).Error |
| + return tx.Where("expires_at <= ?", cutoff).Delete(&previewGrantRecord{}).Error |
| } |
| func minPreviewTime(a, b time.Time) time.Time { |
| if b.Before(a) { |
diff --git a/internal/plan3test/preview_pass_contract_test.go b/internal/plan3test/preview_pass_contract_test.go| index c75ea563..910dc39a 100644 |
| --- a/internal/plan3test/preview_pass_contract_test.go |
| +++ b/internal/plan3test/preview_pass_contract_test.go |
| @@ -41,7 +41,14 @@ func TestPreviewPassContract(t *testing.T) { |
| t.Fatal("missing created response") |
| } |
| schema := doc["components"].(map[string]any)["schemas"].(map[string]any)["PreviewPass"].(map[string]any) |
| - if schema["additionalProperties"] != false || len(schema["required"].([]any)) != 3 || len(schema["properties"].(map[string]any)) != 3 { |
| + if schema["additionalProperties"] != false || len(schema["required"].([]any)) != 5 || len(schema["properties"].(map[string]any)) != 5 { |
| t.Fatal("unexpected pass representation") |
| } |
| + for name, maximum := range map[string]float64{"expires_in": 60, "grant_expires_in": 900} { |
| + field := schema["properties"].(map[string]any)[name].(map[string]any) |
| + if field["type"] != "integer" || field["minimum"] != float64(1) || field["maximum"] != maximum { |
| + t.Fatal("relative lifetime bounds", name, field) |
| + } |
| + } |
| + |
| } |
diff --git a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings| index 54f43c02..47e4b98f 100644 |
| --- a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings |
| @@ -1236,17 +1236,6 @@ |
| } |
| } |
| }, |
| - "evidence.candidate_changed": { |
| - "extractionState": "manual", |
| - "localizations": { |
| - "en": { |
| - "stringUnit": { |
| - "state": "translated", |
| - "value": "The change has been updated. Review it again." |
| - } |
| - } |
| - } |
| - }, |
| "fact.branch": { |
| "extractionState": "manual", |
| "localizations": { |
| @@ -2683,17 +2672,6 @@ |
| } |
| } |
| }, |
| - "question.expired": { |
| - "extractionState": "manual", |
| - "localizations": { |
| - "en": { |
| - "stringUnit": { |
| - "state": "translated", |
| - "value": "Expired" |
| - } |
| - } |
| - } |
| - }, |
| "read.failed": { |
| "extractionState": "manual", |
| "localizations": { |
diff --git a/native/apple/Sources/EquipoKit/API/PreviewPass.swift b/native/apple/Sources/EquipoKit/API/PreviewPass.swift| index c3ac5ee4..2c2d6f85 100644 |
| --- a/native/apple/Sources/EquipoKit/API/PreviewPass.swift |
| +++ b/native/apple/Sources/EquipoKit/API/PreviewPass.swift |
| @@ -2,6 +2,8 @@ import Foundation |
| struct PreviewPass: Codable, Sendable { |
| let pass: String |
| + let expiresIn: Int |
| + let grantExpiresIn: Int |
| let expiresAt: Date |
| let grantExpiresAt: Date |
| } |
| @@ -44,7 +46,9 @@ struct PreviewDestination: Equatable, Sendable { |
| url.host?.lowercased().trimmingCharacters(in: CharacterSet(charactersIn: ".")) |
| } |
| func allows(_ request: URLRequest, mainFrame: Bool, initial: Bool) -> Bool { |
| - guard let url = request.url, url.user == nil, url.password == nil, url.scheme == "https" else { return false } |
| + guard let url = request.url, url.user == nil, url.password == nil else { return false } |
| + if !mainFrame && (url.absoluteString == "about:blank" || url.absoluteString == "about:srcdoc" || url.scheme == "blob" || url.scheme == "data") { return true } |
| + guard url.scheme == "https" else { return false } |
| if !mainFrame { |
| // The response's frame-src CSP pins the preview origin. Never let a |
| // child navigate onto the Equipo cookie host (ports do not isolate cookies). |
diff --git a/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift b/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift| index 0429698e..b017ad6e 100644 |
| --- a/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift |
| +++ b/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift |
| @@ -16,6 +16,7 @@ import WebKit |
| let web = WKWebView(frame: .zero, configuration: configuration) |
| web.navigationDelegate = self; web.uiDelegate = self |
| web.allowsBackForwardNavigationGestures = false |
| + web.allowsLinkPreview = false |
| dataStore = store; webView = web |
| web.load(request) |
| } |
diff --git a/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift b/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift| index 8b946120..d776dd6a 100644 |
| --- a/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift |
| +++ b/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift |
| @@ -56,16 +56,18 @@ import Observation |
| do { |
| let pass = try await client.previewPass(task: task.id, candidate: task.candidateSha) |
| guard valid, generation == operation else { return } |
| - let received = now.addingTimeInterval(elapsedSince(started)) |
| + let elapsed = elapsedSince(started) |
| + let received = now.addingTimeInterval(elapsed) |
| // Never extend a server deadline by the time spent minting. |
| guard pass.pass.range(of: #"^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]\z"#, options: .regularExpression) != nil, |
| - pass.expiresAt > received, pass.expiresAt <= received.addingTimeInterval(60), |
| - pass.grantExpiresAt >= pass.expiresAt, pass.grantExpiresAt <= received.addingTimeInterval(900) else { |
| + (1...60).contains(pass.expiresIn), (1...900).contains(pass.grantExpiresIn), |
| + pass.grantExpiresIn >= pass.expiresIn, elapsed.isFinite, elapsed >= 0, |
| + Double(pass.expiresIn) > elapsed else { |
| throw EquipoAPIError.undecodable |
| } |
| - page = Page(binding: binding, expiry: pass.grantExpiresAt, resource: makeBrowser(destination, destination.exchange(pass: pass.pass))) |
| + let interval = Double(pass.grantExpiresIn) - elapsed |
| + page = Page(binding: binding, expiry: received.addingTimeInterval(interval), resource: makeBrowser(destination, destination.exchange(pass: pass.pass))) |
| busy = false |
| - let interval = pass.grantExpiresAt.timeIntervalSince(received) |
| timer = Task { [weak self] in |
| do { try await Task.sleep(for: .seconds(interval)) } catch { return } |
| guard let self, self.generation == operation else { return } |
diff --git a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings| index 54f43c02..47e4b98f 100644 |
| --- a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings |
| @@ -1236,17 +1236,6 @@ |
| } |
| } |
| }, |
| - "evidence.candidate_changed": { |
| - "extractionState": "manual", |
| - "localizations": { |
| - "en": { |
| - "stringUnit": { |
| - "state": "translated", |
| - "value": "The change has been updated. Review it again." |
| - } |
| - } |
| - } |
| - }, |
| "fact.branch": { |
| "extractionState": "manual", |
| "localizations": { |
| @@ -2683,17 +2672,6 @@ |
| } |
| } |
| }, |
| - "question.expired": { |
| - "extractionState": "manual", |
| - "localizations": { |
| - "en": { |
| - "stringUnit": { |
| - "state": "translated", |
| - "value": "Expired" |
| - } |
| - } |
| - } |
| - }, |
| "read.failed": { |
| "extractionState": "manual", |
| "localizations": { |
diff --git a/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift b/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift| index 7e4fa920..4beae351 100644 |
| --- a/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift |
| +++ b/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift |
| @@ -57,13 +57,42 @@ import Testing |
| } |
| } |
| @Test func expiredOrOverlongResponsesNeverCreateAWebView() async throws { |
| - for times in [(0.0, 900.0), (61, 900), (60, 901), (60, 0)] { |
| + for times in [(0.0, 900.0), (61, 900), (60, 901), (60, 0), (60, 30)] { |
| let browser = FakePreviewBrowser(), model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in browser }) |
| let server = ScriptedTransport(); Self.answer(server, passLife: times.0, grantLife: times.1) |
| await model.open(client: EquipoClient(transport: server, token: "t"), task: try Self.task(), now: Self.now) |
| #expect(model.page == nil); #expect(model.failure != nil) |
| } |
| } |
| + @Test func relativeLifetimesIgnoreDeviceClockAndSubtractTravelTime() async throws { |
| + for skew in [-300.0, 300.0] { |
| + let server = ScriptedTransport(), browser = FakePreviewBrowser() |
| + let model = PreviewPresentation(elapsedSince: { _ in 7.25 }, makeBrowser: { _, _ in browser }) |
| + Self.answer(server) |
| + let start = Self.now.addingTimeInterval(skew) |
| + await model.open(client: EquipoClient(transport: server, token: "t"), task: try Self.task(), now: start) |
| + let page = try #require(model.page) |
| + #expect(page.expiry == start.addingTimeInterval(900)) |
| + model.checkExpiry(now: start.addingTimeInterval(900)) |
| + #expect(model.page == nil) |
| + } |
| + let server = ScriptedTransport(), model = PreviewPresentation(elapsedSince: { _ in 60 }, makeBrowser: { _, _ in FakePreviewBrowser() }) |
| + Self.answer(server) |
| + await model.open(client: EquipoClient(transport: server, token: "t"), task: try Self.task(), now: Self.now.addingTimeInterval(-300)) |
| + #expect(model.page == nil) |
| + } |
| + @Test func localFrameSchemesAreChildOnly() throws { |
| + let destination = try Self.destination() |
| + for address in ["about:blank", "about:srcdoc", "blob:https://preview.example/id", "data:text/html,hello"] { |
| + let request = URLRequest(url: try #require(URL(string: address))) |
| + #expect(destination.allows(request, mainFrame: false, initial: false)) |
| + #expect(!destination.allows(request, mainFrame: true, initial: true)) |
| + #expect(!destination.allows(request, mainFrame: true, initial: false)) |
| + } |
| + for address in ["about:config", "javascript:alert(1)", "file:///etc/passwd", "http://preview.example"] { |
| + #expect(!destination.allows(URLRequest(url: URL(string: address)!), mainFrame: false, initial: false)) |
| + } |
| + } |
| @Test func latestPreviewMustMatchTheCurrentCandidate() throws { |
| var task = try Self.task(), old = task.steps![0] |
| old.id = "old-preview"; old.candidateSha = String(repeating: "2", count: 40) |
| @@ -101,9 +130,8 @@ import Testing |
| } |
| static func answer(_ server: ScriptedTransport, passLife: Double = 60, grantLife: Double = 900, passValue: String = PreviewPassTests.pass) { |
| - let response = PreviewPass(pass: passValue, expiresAt: now.addingTimeInterval(passLife), grantExpiresAt: now.addingTimeInterval(grantLife)) |
| - let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601 |
| - server.on("POST /tasks/tk_preview/preview-pass", .success(APIResponse(status: 201, data: try! encoder.encode(response)))) |
| + let response: [String: Any] = ["pass": passValue, "expires_at": "2026-11-26T12:01:00Z", "grant_expires_at": "2026-11-26T12:15:00Z", "expires_in": passLife, "grant_expires_in": grantLife] |
| + server.on("POST /tasks/tk_preview/preview-pass", .success(APIResponse(status: 201, data: try! JSONSerialization.data(withJSONObject: response)))) |
| } |
| } |
| @MainActor final class FakePreviewBrowser: PreviewBrowserResource { |
| @@ -120,6 +148,7 @@ import Testing |
| #expect(!store.isPersistent) |
| #expect(view.configuration.userContentController.userScripts.isEmpty) |
| #expect(!view.configuration.preferences.javaScriptCanOpenWindowsAutomatically) |
| + #expect(!view.allowsLinkPreview) |
| browser.close() |
| #expect(browser.webView == nil); #expect(browser.dataStore == nil) |
| #expect(view.navigationDelegate == nil); #expect(view.uiDelegate == nil) |
| @@ -216,7 +245,7 @@ actor DelayedPreviewTransport: EquipoTransport { |
| return await withCheckedContinuation { continuations.append($0) } |
| } |
| func complete() { |
| - for continuation in continuations { continuation.resume(returning: APIResponse(status: 201, data: Data("{\"pass\":\"\(String(repeating: "A", count: 43))\",\"expires_at\":\"2026-11-26T12:01:00Z\",\"grant_expires_at\":\"2026-11-26T12:15:00Z\"}".utf8))) |
| + for continuation in continuations { continuation.resume(returning: APIResponse(status: 201, data: Data("{\"pass\":\"\(String(repeating: "A", count: 43))\",\"expires_at\":\"2026-11-26T12:01:00Z\",\"grant_expires_at\":\"2026-11-26T12:15:00Z\",\"expires_in\":60,\"grant_expires_in\":900}".utf8))) |
| } |
| continuations = [] |
| } |
diff --git a/native/scripts/check-parity.py b/native/scripts/check-parity.py| index e0be86b9..af5e9096 100755 |
| --- a/native/scripts/check-parity.py |
| +++ b/native/scripts/check-parity.py |
| @@ -22,7 +22,7 @@ for key in sorted(set(re.findall(r'"(work\.reason\.[^"]+)":', copy))): |
| if key not in strings: |
| problems.append(f'{key}: native must carry every reviewed stop reason') |
| for key, text in sorted(strings.items()): |
| - if not key.startswith(('evidence.candidate_changed', 'question.expired', 'chat.day.today', 'runner.verdict.skipped', 'work.', 'placement.', 'chat.card.', 'chat.paste.', 'chat.attach.', 'work.tl.', 'roster.', 'projects.', 'work.star.', 'api.', 'nav.projects', 'chat.connections.connected', 'counts.unavailable', 'team.close', 'work.pause.', 'work.reason.', 'work.needs.', 'chat.held.', 'work.hold.', 'work.stage.', 'time.', 'work.hold.run_now', 'work.recover')): |
| + if not key.startswith(('chat.day.today', 'runner.verdict.skipped', 'work.', 'placement.', 'chat.card.', 'chat.paste.', 'chat.attach.', 'work.tl.', 'roster.', 'projects.', 'work.star.', 'api.', 'nav.projects', 'chat.connections.connected', 'counts.unavailable', 'team.close', 'work.pause.', 'work.reason.', 'work.needs.', 'chat.held.', 'work.hold.', 'work.stage.', 'time.', 'work.hold.run_now', 'work.recover')): |
| continue |
| found = re.findall(r'"' + re.escape(key) + r'":\s*"((?:[^"\\]|\\.)*)"', copy) |
| if len(found) != 1: |
diff --git a/native/scripts/strings.json b/native/scripts/strings.json| index 089e4f38..80aa2cf9 100644 |
| --- a/native/scripts/strings.json |
| +++ b/native/scripts/strings.json |
| @@ -501,8 +501,6 @@ |
| "native.needs.done_at": "Done at %@", |
| "work.merged": "Merged into %@ at %@", |
| "native.needs.merged_at": "Merged into %1$@ at %2$@", |
| - "evidence.candidate_changed": "The change has been updated. Review it again.", |
| - "question.expired": "Expired", |
| "api.preview_changed": "The change has been updated. Review it again.", |
| "api.preview_expired": "This preview expired. Open it again." |
| } |