Merge branch 'preview/pass' into main
45 files changed,
+3,307
−33
.rastrillo/budgets.txt+4 −3docs/api/equipo-v1.openapi.json+124 −1docs/superpowers/plans/2026-11-26-preview-pass.md+141 −0docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+2 −0docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md+261 −0internal/equipo/app.go+4 −2internal/equipo/chat/tasks.go+19 −9internal/equipo/copy.go+2 −0internal/equipo/migrations/0109_preview_passes.sql+14 −0internal/equipo/migrations/0110_preview_device_task.sql+3 −0internal/equipo/migrations/schema.sql+19 −0internal/equipo/person_api.go+1 −0internal/equipo/personapi/preview_error_test.go+29 −0internal/equipo/preview_frames_fixture_test.go+18 −0internal/equipo/preview_pass.go+266 −0internal/equipo/preview_pass_attack_test.go+304 −0internal/equipo/preview_pass_browser_test.go+141 −0internal/equipo/preview_pass_delta_test.go+180 −0internal/equipo/preview_pass_fixture_test.go+74 −0internal/equipo/preview_pass_http.go+188 −0internal/equipo/preview_pass_http_test.go+181 −0internal/equipo/preview_pass_models.go+3 −0internal/equipo/preview_pass_security_test.go+283 −0internal/equipo/preview_pass_store.go+164 −0internal/equipo/preview_pass_test.go+168 −0internal/equipo/preview_wrapper.go+3 −6internal/plan3test/person_api_contract_test.go+4 −0internal/plan3test/person_api_device_contract_test.go+1 −1internal/plan3test/plan3_release_test.go+3 −1internal/plan3test/preview_pass_contract_test.go+54 −0native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings+24 −0native/apple/Sources/EquipoKit/API/PreviewPass.swift+60 −0native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift+5 −1native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift+88 −0native/apple/Sources/EquipoKit/Preview/PreviewFixture.swift+49 −0native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift+114 −0native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings+24 −0native/apple/Sources/EquipoKit/Session/EquipoSession.swift+3 −0native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift+5 −1native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift+16 −1native/apple/Sources/EquipoMac/EquipoMacApp.swift+3 −2native/apple/Tests/EquipoKitTests/PreviewPassTests.swift+252 −0native/ios/Sources/EquipoPhoneApp.swift+2 −1native/scripts/check-strings.py+1 −1native/scripts/strings.json+3 −3
CI passed — run details
CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/design__assistant-attachments: 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 2.0s
ci-box: codex: fetched and verified in 4.7s
ci-box: codex-code-mode-host: fetched and verified in 1.6s
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 10.0s
ci-box: pi: installed and verified in 7.6s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.8s
ci-box: clone deepened in 4.5s
ci-box: file times set from content: 3112 files, 200 directories
ci-box: ready in 19.5s
=== 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.150s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
1.3s
+ go list -export -test -tags testbuild -f ./...
0.7s
+ go list -export -test -tags browser,testbuild -f ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
0.3s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m12.267s 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.555s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m10.55s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 43.08, cpu waiting 25.64%, memory waiting 0.00%, io waiting 0.57%
--- shard 1 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-review: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m12.734s 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.958s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m10.96s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 43.08, cpu waiting 25.64%, memory waiting 0.00%, io waiting 0.57%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m12.913s 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.789s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m1.95s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 4.76s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.08s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 43.08, cpu waiting 25.64%, memory waiting 0.00%, io waiting 0.57%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m25.944s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m24.141s amadan.net/oficina/equipo/internal/headless
receipt: slow test 33.27s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 33.06s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 8.98s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 8.82s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 38.92, cpu waiting 24.30%, memory waiting 0.00%, io waiting 0.45%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m28.131s 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 1m26.275s amadan.net/oficina/equipo/internal/headless
receipt: slow test 56.79s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.39s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 8.03s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 7.42s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 4.64s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 37.56, cpu waiting 23.73%, memory waiting 0.00%, io waiting 0.43%
--- 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
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 2m42.819s 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 2m40.613s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m31.45s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 19.88s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.46s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 6.82s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
receipt: slow test 6.78s amadan.net/oficina/equipo/internal/headless TestHeadlessBatchAfterRefusedReply
machine: 32 CPUs, load 14.13, cpu waiting 7.18%, memory waiting 0.00%, io waiting 0.12%
--- 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 411ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 2m8.492s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.71s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.75s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 4.87s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 3.84s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 2.6s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
machine: 32 CPUs, load 0.97, cpu waiting 0.06%, memory waiting 0.00%, io waiting 1.87%
--- 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 448ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1m38.444s 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.51s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 3.99s amadan.net/oficina/equipo/internal/thintest TestContractPausedJob
receipt: slow test 2.37s amadan.net/oficina/equipo/internal/thintest TestContractRetryFailedPreviewAfterMerge
machine: 32 CPUs, load 0.97, cpu waiting 0.06%, memory waiting 0.00%, io waiting 1.87%
--- 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 4m47.924s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 5m2.398s 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 4m47.924s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 37.07s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.93s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.9s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.54s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 7.6s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.00, cpu waiting 0.69%, memory waiting 0.00%, io waiting 0.02%
--- 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 52.004s 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.766s 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 38.69, cpu waiting 26.20%, memory waiting 0.00%, io waiting 0.80%
--- 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 53.796s 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 51.741s amadan.net/oficina/equipo/internal/runner
receipt: slow test 41.59s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 37.79s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.38s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.76s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 38.69, cpu waiting 26.26%, memory waiting 0.00%, io waiting 0.77%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed
receipt: test step 35.98s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 34.988s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.28s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.13s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.61s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.62s amadan.net/oficina/equipo/internal/runner TestCoordinatorTransientRefusalKeepsServing
machine: 32 CPUs, load 28.66, cpu waiting 18.13%, memory waiting 0.00%, io waiting 1.04%
--- 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 34.4%, load 22.01
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m10.181s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m8.063s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 29.69s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 29.58s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 27.29s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 24.5s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 24.27s amadan.net/oficina/equipo/internal/equipotest TestAuthorityRejectsMismatchedTarget
machine: 32 CPUs, load 33.93, cpu waiting 19.74%, memory waiting 0.00%, io waiting 0.35%
--- 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 34.4%, load 22.01
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 561ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1m16.611s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 20.64s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 20.58s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 20.58s amadan.net/oficina/equipo/internal/equipotest TestProjectOwnersAreMembers
receipt: slow test 20.54s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 20.47s amadan.net/oficina/equipo/internal/equipotest TestProjectRetryAndRevision
machine: 32 CPUs, load 22.01, cpu waiting 13.66%, memory waiting 0.00%, io waiting 1.15%
--- 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 34.4%, load 22.01
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m22.637s 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 1m9.33s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 15.32s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.75s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.67s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 10.67s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 7.61s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 28.95, cpu waiting 16.31%, memory waiting 0.00%, io waiting 0.29%
--- 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 34.4%, load 22.01
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 517ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1m7.226s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 25.93s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 25.28s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 25.19s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 23.44s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
receipt: slow test 23.31s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsUpgrade
machine: 32 CPUs, load 22.01, cpu waiting 13.66%, memory waiting 0.00%, io waiting 1.15%
--- 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 34.4%, load 22.01
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 793ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 52.744s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.68s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.49s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.79s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.57s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.28s amadan.net/oficina/equipo/internal/plan3test TestPersonAPIMigrationUpgrade
machine: 32 CPUs, load 22.01, cpu waiting 13.66%, memory waiting 0.00%, io waiting 1.15%
--- 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 34.4%, load 22.01
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/runner/webread: 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/idtest: 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/provider/claude: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/codex: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/containment: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/pi: its inputs changed
budget note: internal/equipo took 2m16.88s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/equipo/chat took 18.267s, 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 1m46.442s, 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 43.432s, over the 15s its record on line 40 allows; reported only, timing fails on CI
receipt: test step 2m23.239s against a 60s target (the gate's other steps are not in this figure)
receipt: 13 packages ran, 53 cached, 17 without tests, 0 failed
receipt: slow package 2m16.88s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 1m46.442s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 1m0.222s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 56.921s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 43.432s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 57.48s amadan.net/oficina/equipo/internal/idtest TestDoorRemembersOficinaID
receipt: slow test 49.61s amadan.net/oficina/equipo/internal/idtest TestDoorForgetsOficinaIDForARefusedSession
receipt: slow test 49.25s amadan.net/oficina/equipo/internal/idtest TestDoorNeverJudgesANativeSession
receipt: slow test 49.2s amadan.net/oficina/equipo/internal/idtest TestDoorOficinaSettingsUnreadableIsNoLoop
receipt: slow test 49.14s amadan.net/oficina/equipo/internal/idtest TestDoorStepUpIsLocal
machine: 32 CPUs, load 12.11, cpu waiting 5.88%, memory waiting 0.00%, io waiting 0.09%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m23.109s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m21.38s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.57s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.76s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.33s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.63s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 5.5s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 38.92, cpu waiting 24.68%, memory waiting 0.00%, io waiting 0.46%
--- shard 19 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-work: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m23.986s 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.087s amadan.net/oficina/equipo/internal/headless
receipt: slow test 24.93s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 19.5s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 12.59s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 8.86s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 7.4s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 38.92, cpu waiting 24.68%, memory waiting 0.00%, io waiting 0.46%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m50.37s 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 1m48.69s amadan.net/oficina/equipo/internal/headless
receipt: slow test 13.5s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 12.66s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 12.21s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 11.21s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsSignInEmail
receipt: slow test 10.75s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
machine: 32 CPUs, load 30.43, cpu waiting 16.31%, memory waiting 0.00%, io waiting 0.29%
--- 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
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
=== RUN TestBrowserThinkingAndCards
time=2026-11-26T13:47:51.428Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-26T13:47:51.428Z level=INFO msg="startup phase done" phase=state_lock took=76µs
time=2026-11-26T13:47:51.428Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-26T13:47:51.429Z level=INFO msg="startup phase done" phase=claim_roots took=179µs
time=2026-11-26T13:47:51.429Z level=INFO msg="startup phase" phase=sweep
time=2026-11-26T13:47:51.463Z level=INFO msg="startup phase done" phase=sweep took=34.31ms
time=2026-11-26T13:47:51.463Z level=INFO msg="startup phase" phase=credentials
time=2026-11-26T13:47:51.463Z level=INFO msg="startup phase done" phase=credentials took=96µs
time=2026-11-26T13:47:51.463Z level=INFO msg="startup phase" phase=open_state
time=2026-11-26T13:47:51.505Z level=INFO msg="startup phase done" phase=open_state took=41.364ms
time=2026-11-26T13:47:51.505Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-26T13:47:51.506Z level=INFO msg=connecting host=127.0.0.1:34957 protocol=31
time=2026-11-26T13:47:51.507Z level=INFO msg=connected host=127.0.0.1:34957 took=1.079ms
time=2026-11-26T13:47:51.507Z level=INFO msg="capabilities gathering"
time=2026-11-26T13:47:51.508Z level=INFO msg="capabilities gathered" took=623µs tags=linux,claude,go
time=2026-11-26T13:47:51.509Z level=INFO msg="hello sent" protocol=31
time=2026-11-26T13:47:51.514Z level=INFO msg=welcome protocol=31 role=primary generation=1
time=2026-11-26T13:47:52.555Z level=INFO msg="connection checked" connection=claude-1 state=healthy
browser_cards_test.go:66: waiting for (()=>{const l=document.querySelector('[equipo-thinking] [equipo-activity]');return !!l && l.textContent==='Adding oficina/sample…'})(): context deadline exceeded (last evaluation: <nil>)
--- FAIL: TestBrowserThinkingAndCards (7.09s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m17.641s
FAIL amadan.net/oficina/equipo/internal/headless 77.835s
receipt: test step 1m19.174s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m17.641s amadan.net/oficina/equipo/internal/headless
receipt: slow test 11.14s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 9.71s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 9.51s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.24s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
receipt: slow test 7.22s amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|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$' -v -run '^TestBrowserThinkingAndCards$' -count=1 ./internal/headless (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserThinkingAndCards browser-headless-rest 478e0055ec8ce5ba0637dafd746f57ca670aee45 7.09s 40.91
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 35.83, cpu waiting 20.99%, memory waiting 0.00%, io waiting 0.38%
--- 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 299ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 2.335s amadan.net/oficina/equipo/internal/equipo
receipt: slow test 1.76s amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewPassExchange
receipt: slow test 570ms amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewBlocksNavigation
browser lane browser-rest: ./internal/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor|TestBrowserSmartDoor)$' ./internal/idtest
budget note: internal/idtest took 10.849s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
receipt: test step 238ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 10.849s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 8.75s amadan.net/oficina/equipo/internal/idtest TestBrowserSmartDoor
receipt: slow test 2.09s 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 230ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1.972s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 1.97s amadan.net/oficina/equipo/internal/plan3test TestTeamsHierarchyBrowser
browser lane browser-rest: ./internal/thintest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAccessEmojiByline|TestBrowserAccessFinalOutcomes|TestBrowserAccessRequest|TestBrowserAccessReview|TestBrowserActivitySubjects|TestBrowserAutonomySettings|TestBrowserCoordinatorQueue|TestBrowserEmptyConversation|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 352ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 3m34.303s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 23.19s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.41s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.08s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.73s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.08s amadan.net/oficina/equipo/internal/thintest TestBrowserRhythm
machine: 32 CPUs, load 4.25, cpu waiting 1.30%, memory waiting 0.00%, io waiting 1.84%
--- 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 (50s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 4.86s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.44s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 7.99s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 8.68s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 25.08s
+ 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 (50s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 11.82s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 10.90s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 10.33s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 14.67s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (20s)
ok ./internal/headless TestMixedVersions 18.22s
+ 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 37.27, cpu waiting 25.80%, memory waiting 0.00%, io waiting 0.82%
--- 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 9.084s 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.789s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 186ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 75ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 3ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 0s amadan.net/oficina/equipo/internal/runner/provider/claude/realcli
receipt: slow test 5.59s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.74s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 350ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 90ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxToolchain
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run '^TestNamespace' -count=1 ./internal/runner/containment
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run '^TestNamespace' -count=1 ./internal/runner/containment
receipt: test step 3.545s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3.089s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 340ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 200ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicy
machine: 32 CPUs, load 10.88, cpu waiting 6.37%, memory waiting 0.00%, io waiting 1.51%
--- 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 34.4%, load 22.01
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.670s
machine: 32 CPUs, load 37.27, cpu waiting 25.12%, memory waiting 0.00%, io waiting 0.85%
--- 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 34.4%, load 22.01
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 28.66, cpu waiting 15.02%, memory waiting 0.00%, io waiting 1.12%
--- 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 34.4%, load 22.01
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 30.13, cpu waiting 19.27%, memory waiting 0.00%, io waiting 1.01%
--- 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 34.4%, load 22.01
shard 28: make gitleaks
[90m1:48PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m1:48PM[0m [32mINF[0m [1m1188 commits scanned.[0m
[90m1:48PM[0m [32mINF[0m [1mscanned ~66935310 bytes (66.94 MB) in 16s[0m
[90m1:48PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 33.64, cpu waiting 24.28%, memory waiting 0.00%, io waiting 0.88%
=== perf ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -require TestPerfScreens,TestPerfBoot -tags perf -count=1 -p 1 -parallel 1 -run '^TestPerf' ./...
perf: GET /: median 1.569ms, worst 1.607ms, budget 150ms
perf: GET /api/runner/protocol: median 72µs, worst 97µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 598µs, worst 646µs, budget 150ms
perf: GET /api/v1/accounts: median 524µs, worst 564µs, budget 150ms
perf: GET /api/v1/auth/devices: median 471µs, worst 517µs, budget 150ms
perf: GET /api/v1/budgets: median 526µs, worst 585µs, budget 150ms
perf: GET /api/v1/capabilities: median 274µs, worst 318µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.569ms, worst 1.894ms, budget 150ms
perf: GET /api/v1/connections: median 840µs, worst 914µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 652µs, worst 744µs, budget 150ms
perf: GET /api/v1/conversation: median 960µs, worst 1.101ms, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.626ms, worst 1.818ms, budget 150ms
perf: GET /api/v1/coordinator: median 1.889ms, worst 1.97ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 478µs, worst 543µs, budget 150ms
perf: GET /api/v1/journey: median 10.302ms, worst 11.086ms, budget 150ms
perf: GET /api/v1/me: median 509µs, worst 576µs, budget 150ms
perf: GET /api/v1/me/settings: median 597µs, worst 631µs, budget 150ms
perf: GET /api/v1/needs-you: median 10.156ms, worst 11.069ms, budget 150ms
perf: GET /api/v1/notifications: median 1.901ms, worst 2.13ms, budget 150ms
perf: GET /api/v1/onboarding: median 423µs, worst 513µs, budget 150ms
perf: GET /api/v1/people: median 502µs, worst 583µs, budget 150ms
perf: GET /api/v1/playbooks: median 688µs, worst 735µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 614µs, worst 647µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 1.02ms, worst 1.038ms, budget 150ms
perf: GET /api/v1/preferences: median 924µs, worst 1.143ms, budget 150ms
perf: GET /api/v1/projects/{id}: median 536µs, worst 559µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 742µs, worst 1.084ms, budget 150ms
perf: GET /api/v1/roster: median 627µs, worst 2.01ms, budget 150ms
perf: GET /api/v1/runners/{id}: median 656µs, worst 697µs, budget 150ms
perf: GET /api/v1/specialists: median 9.33ms, worst 9.807ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 9.066ms, worst 10.532ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 910µs, worst 962µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.664ms, worst 1.808ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 873µs, worst 923µs, budget 150ms
perf: GET /api/v1/teams: median 465µs, worst 484µs, budget 150ms
perf: GET /api/v1/templates: median 626µs, worst 668µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 475µs, worst 531µs, budget 150ms
perf: GET /auth/callback: median 78µs, worst 107µs, budget 150ms
perf: GET /auth/devices/{id}: median 4.394ms, worst 4.75ms, budget 150ms
perf: GET /auth/verify: median 84µs, worst 106µs, budget 150ms
perf: GET /connections: median 4.771ms, worst 4.877ms, budget 150ms
perf: GET /conversation: median 9.62ms, worst 10.223ms, budget 150ms
perf: GET /conversation/connections: median 289µs, worst 316µs, budget 150ms
perf: GET /conversation/notebook: median 321µs, worst 429µs, budget 150ms
perf: GET /conversation/settings: median 5.349ms, worst 5.511ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 5.212ms, worst 5.57ms, budget 150ms
perf: GET /conversation/settings/connections: median 8.05ms, worst 13.103ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 8.522ms, worst 9.468ms, budget 150ms
perf: GET /conversation/settings/copy: median 5.094ms, worst 5.25ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 5.278ms, worst 5.363ms, budget 150ms
perf: GET /conversation/settings/machines: median 5.849ms, worst 6.049ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 5.965ms, worst 6.101ms, budget 150ms
perf: GET /conversation/settings/notebook: median 4.549ms, worst 5.131ms, budget 150ms
perf: GET /conversation/settings/thinking: median 5.035ms, worst 5.306ms, budget 150ms
perf: GET /housekeeping: median 4.831ms, worst 5.411ms, budget 150ms
perf: GET /invites/new: median 670µs, worst 845µs, budget 150ms
perf: GET /invites/{id}: median 703µs, worst 735µs, budget 150ms
perf: GET /jobs: median 4.881ms, worst 7.969ms, budget 150ms
perf: GET /jobs/{id}: median 6.423ms, worst 6.897ms, budget 150ms
perf: GET /journey: median 12.632ms, worst 13.414ms, budget 150ms
perf: GET /nav/rail: median 3.982ms, worst 4.416ms, budget 150ms
perf: GET /needs-you: median 11.706ms, worst 12.499ms, budget 150ms
perf: GET /onboarding: median 5.118ms, worst 5.264ms, budget 150ms
perf: GET /people: median 4.501ms, worst 4.808ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 5.841ms, worst 6.059ms, budget 150ms
perf: GET /playbooks: median 5.459ms, worst 5.565ms, budget 150ms
perf: GET /playbooks/new: median 5.764ms, worst 7.631ms, budget 150ms
perf: GET /playbooks/{id}: median 6.378ms, worst 6.629ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 6.22ms, worst 6.45ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 5.307ms, worst 5.411ms, budget 150ms
perf: GET /preferences: median 5.609ms, worst 6.358ms, budget 150ms
perf: GET /preferences/sources/{source}: median 5.477ms, worst 6.214ms, budget 150ms
perf: GET /projects: median 7.338ms, worst 7.885ms, budget 150ms
perf: GET /projects/accounts: median 4.859ms, worst 5.202ms, budget 150ms
perf: GET /projects/new: median 4.926ms, worst 5.017ms, budget 150ms
perf: GET /projects/{id}: median 14.791ms, worst 17.115ms, budget 150ms
perf: GET /projects/{id}/edit: median 5.427ms, worst 5.775ms, budget 150ms
perf: GET /runners/enrol: median 5.955ms, worst 6.156ms, budget 150ms
perf: GET /settings: median 4.65ms, worst 4.769ms, budget 150ms
perf: GET /settings/coordinator: median 7.179ms, worst 7.679ms, budget 150ms
perf: GET /settings/devices: median 4.423ms, worst 4.809ms, budget 150ms
perf: GET /settings/recovery: median 4.388ms, worst 4.607ms, budget 150ms
perf: GET /settings/recovery/release: median 4.587ms, worst 4.979ms, budget 150ms
perf: GET /settings/thinking: median 258µs, worst 267µs, budget 150ms
perf: GET /signed-out: median 283µs, worst 333µs, budget 150ms
perf: GET /signin: median 331µs, worst 376µs, budget 150ms
perf: GET /specialists/new: median 4.232ms, worst 4.619ms, budget 150ms
perf: GET /specialists/{key}: median 13.85ms, worst 14.444ms, budget 150ms
perf: GET /specialists/{key}/edit: median 4.922ms, worst 8.529ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 5.004ms, worst 5.413ms, budget 150ms
perf: GET /tasks: median 7.881ms, worst 8.59ms, budget 150ms
perf: GET /tasks/new: median 4.333ms, worst 4.469ms, budget 150ms
perf: GET /tasks/{id}: median 8.077ms, worst 9.138ms, budget 150ms
perf: GET /tasks/{id}/merge: median 6.802ms, worst 6.952ms, budget 150ms
perf: GET /tasks/{id}/move: median 6.075ms, worst 7.828ms, budget 150ms
perf: GET /tasks/{id}/plan: median 7.277ms, worst 8.484ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.946ms, worst 2.157ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 7.72ms, worst 8.194ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 6.312ms, worst 7.782ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 5.69ms, worst 8.044ms, budget 150ms
perf: GET /tasks/{id}/thread: median 9.564ms, worst 9.878ms, budget 150ms
perf: GET /team/{specialist}: median 5.768ms, worst 5.963ms, budget 150ms
perf: GET /teams: median 13.149ms, worst 14.726ms, budget 150ms
perf: GET /templates: median 4.534ms, worst 4.612ms, budget 150ms
perf: GET /usage: median 5.648ms, worst 6.495ms, budget 150ms
perf: GET /work: median 4.051ms, worst 4.708ms, budget 150ms
perf: GET /auth/devices/{id}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /connections: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/autonomy: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/connections: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/connections/add: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/copy: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/housekeeping: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/machines: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/machines/add: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/notebook: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /conversation/settings/thinking: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /housekeeping: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /invites/new: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /invites/{id}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /jobs: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /jobs/{id}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /journey: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /nav/rail: 0 bytes of framework CSS and JS, gzipped; 16000-byte budget
perf: GET /needs-you: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /onboarding: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /people: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /playbook-suggestions/{suggestion}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /playbooks: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /playbooks/new: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /playbooks/{id}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /playbooks/{id}/edit: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /playbooks/{id}/template-diff: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /preferences: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /preferences/sources/{source}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /projects: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /projects/accounts: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /projects/new: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /projects/{id}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /projects/{id}/edit: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /runners/enrol: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /settings: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /settings/coordinator: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /settings/devices: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /settings/recovery: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /settings/recovery/release: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /signed-out: 30270 bytes of framework CSS and JS, gzipped; 40000-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /specialists/new: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /specialists/{key}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /specialists/{key}/edit: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /specialists/{key}/template-diff: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/new: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/merge: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/move: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/plan: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/preview: 25954 bytes of framework CSS and JS, gzipped; 40000-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/questions/{question}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/rendered-change: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /tasks/{id}/thread: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /team/{specialist}: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /teams: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /templates: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /usage: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: GET /work: 57416 bytes of framework CSS and JS, gzipped; 60600-byte budget; it links the whole tokens.css: add Assets: assets to ui.PagesConfig (PagesConfig.Assets) in render.go, and in the layout use {{path $ pageStylesheet}} in place of static/tokens.css and replace the busy.js, live.js, light.js and anchor.js tags and the neededScripts line (or the select.js, calendar.js and datetime.js tags) with {{range pageScripts}}, keeping rastrillo.js and shell.js
perf: cold boot: median 174ms of [173.265115ms 173.780897ms 178.23196ms], budget 500ms
receipt: test step 38.473s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 88 without tests, 0 failed
receipt: slow package 11.499s amadan.net/oficina/equipo/internal/equipotest
receipt: slow package 1ms amadan.net/oficina/equipo/internal/wire/wireschema
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-runner
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-tool-proxy
receipt: slow test 10.91s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 590ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 3.10 GiB in 23145 files
ci-box: module cache /home/ci/work/repos/oficina__equipo/cache/go-mod: 1.15 GiB in 40997 files
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 2ff5580d..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 22615 - Stuck tasks' Retry and timeline, merge_credential and amadan_unreachable copy, no-access merges ask no retry (2026-11-26); measured 22615 source lines. |
| +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 - 11916 Paused-work, Assistant, stuck-task, merge credential and no-access strings in the release inventory (2026-11-26); measured 11916 test lines. |
| +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); |
| @@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device |
| perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen. |
| -size internal/equipo/chat 34974 9873 Detail-only file facts, hosted projection, completion time, no-access merges; measured 34974/9873 (2026-11-26). |
| +size internal/equipo/chat 34984 9873 Detail-only file facts, hosted projection, completion time, no-access merges and transactional preview task reads; measured 34984/9873 (2026-11-26). |
| perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}. |
| perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}. |
| perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections. |
| @@ -76,3 +76,4 @@ size internal/thintest - 35229 Protocol 31 facts and detail-only contracts, stuc |
| perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}. |
| perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage. |
| perf GET /api/v1/advice skip Thin v1 person API: bearer-only JSON for devices; the browser reads advice through /usage and /conversation. |
| +perf GET /native/preview/exchange skip Rejects GET with 404; only a same-origin, body-only POST can consume a preview pass. |
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json| index 38eca460..0e042779 100644 |
| --- a/docs/api/equipo-v1.openapi.json |
| +++ b/docs/api/equipo-v1.openapi.json |
| @@ -14245,6 +14245,90 @@ |
| "x-rejectUnknownFields": true |
| } |
| } |
| + }, |
| + "/tasks/{id}/preview-pass": { |
| + "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 __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": [] |
| + } |
| + ], |
| + "parameters": [ |
| + { |
| + "name": "id", |
| + "in": "path", |
| + "required": true, |
| + "schema": { |
| + "type": "string", |
| + "minLength": 1 |
| + } |
| + } |
| + ], |
| + "responses": { |
| + "401": { |
| + "$ref": "#/components/responses/unauthenticated" |
| + }, |
| + "default": { |
| + "description": "An error, with one of the codes in `Error`", |
| + "headers": { |
| + "Cache-Control": { |
| + "schema": { |
| + "const": "no-store" |
| + } |
| + } |
| + }, |
| + "content": { |
| + "application/json": { |
| + "schema": { |
| + "$ref": "#/components/schemas/Error" |
| + } |
| + } |
| + } |
| + }, |
| + "201": { |
| + "description": "Created", |
| + "headers": { |
| + "Cache-Control": { |
| + "schema": { |
| + "const": "no-store" |
| + } |
| + } |
| + }, |
| + "content": { |
| + "application/json": { |
| + "schema": { |
| + "$ref": "#/components/schemas/PreviewPass" |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "requestBody": { |
| + "required": true, |
| + "content": { |
| + "application/json": { |
| + "schema": { |
| + "type": "object", |
| + "additionalProperties": false, |
| + "required": [ |
| + "candidate_sha" |
| + ], |
| + "properties": { |
| + "candidate_sha": { |
| + "type": "string", |
| + "pattern": "^[0-9a-f]{40}$" |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "x-maxBytes": 4096, |
| + "x-rejectUnknownFields": true |
| + } |
| + } |
| } |
| }, |
| "components": { |
| @@ -14306,7 +14390,9 @@ |
| "question_ended", |
| "host_not_allowed", |
| "already_running", |
| - "offer_changed" |
| + "offer_changed", |
| + "preview_changed", |
| + "preview_expired" |
| ] |
| }, |
| "copy_key": { |
| @@ -24176,6 +24262,43 @@ |
| "additionalProperties": false, |
| "x-go-type": "wire.StepHosted" |
| }, |
| + "PreviewPass": { |
| + "type": "object", |
| + "additionalProperties": false, |
| + "required": [ |
| + "pass", |
| + "expires_at", |
| + "grant_expires_at", |
| + "expires_in", |
| + "grant_expires_in" |
| + ], |
| + "properties": { |
| + "pass": { |
| + "type": "string", |
| + "pattern": "^[A-Za-z0-9_-]{43}$" |
| + }, |
| + "expires_at": { |
| + "type": "string", |
| + "format": "date-time" |
| + }, |
| + "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." |
| + } |
| + } |
| + }, |
| "ChangeFiles": { |
| "type": "object", |
| "properties": { |
diff --git a/docs/superpowers/plans/2026-11-26-preview-pass.md b/docs/superpowers/plans/2026-11-26-preview-pass.md| new file mode 100644 |
| index 00000000..5165aad9 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-26-preview-pass.md |
| @@ -0,0 +1,141 @@ |
| +# Device preview pass |
| + |
| +Approved by the controller, 2026-11-26. Branch `preview/pass`, main `7c113ac8`. |
| +No implementation changes precede this note. |
| + |
| +## Contract and binding |
| + |
| +A tap on Preview calls bearer-authenticated |
| +`POST /api/v1/tasks/{id}/preview-pass` with the candidate SHA the person saw. |
| +Use the same current-person and task-read authority as `GET /tasks/{id}`, |
| +including team visibility. Recheck the active roster and originating device |
| +credential inside the write transaction. Refuse a stale candidate or a preview |
| +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 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 |
| +unsafe flag). The fingerprint prevents a redeployment of the same candidate |
| +from silently changing what the pass opens. The pass expires after 60 seconds, |
| +or earlier if the device credential or preview expires. Use the injected |
| +server clock throughout. A pass is a bearer capability; its person binding |
| +comes from minting, not a second sign-in or a submitted address at exchange. |
| + |
| +## Exchange and browser session |
| + |
| +The native web view POSTs the pass to the fixed same-origin path |
| +`/native/preview/exchange`. No pass in a URL, fragment, redirect, HTML or logs. |
| +The request has a bounded form body and the configured Origin; it passes the |
| +existing same-origin CSRF checks. There is no wildcard CSRF exemption and no |
| +GET exchange. Reject conflicting Origin/Referer/fetch-site headers, unexpected |
| +fields, and any device Authorization header here. A browser session cookie |
| +alone cannot mint or exchange a pass. |
| + |
| +In one transaction, hash and find the pass, conditionally consume it once, |
| +recheck membership/device/session epoch and the full preview binding, create a |
| +fresh random browser grant, and append the audit event. Concurrent exchanges |
| +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 `__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 |
| +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. 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. 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 |
| + |
| +Share the existing `previewWrapper` renderer and preview eligibility checks. |
| +Keep its CSP, iframe sandbox (`allow-scripts allow-same-origin`), origin |
| +validation, header warnings and referrer policy. Never load the raw origin as |
| +the top-level document. Each wrapper request rechecks the originating device, |
| +current roster, task visibility, expiry and exact deployment binding. It does |
| +not switch to a newer candidate. Candidate changes return 409 with the reviewed |
| +`evidence.candidate_changed` words; expired passes/grants/previews show the |
| +reviewed `question.expired` label. Other failures use existing reviewed words. |
| + |
| +Native drops the web view at expiry, sign-out or a task update that changes the |
| +binding, and revalidates when returning to the foreground. A new tap can mint |
| +a new pass. Server expiry prevents further wrapper reads; it cannot retract |
| +HTML already delivered to a browser or revoke the preview origin itself. |
| + |
| +## Native choice |
| + |
| +Use a dedicated WKWebView sheet on both platforms with a fresh |
| +`WKWebsiteDataStore.nonPersistent()` per presentation. WKWebView accepts a |
| +URLRequest, allowing the POST-body exchange, and isolates this cookie from |
| +ordinary browser sign-ins. Load the actual server response, not an HTML string |
| +or a native proxy, so the wrapper's response headers and iframe remain intact. |
| +SFSafariViewController's URL initializer is less suitable for this exchange. |
| + |
| +Extend the allowlisted opener with a typed preview destination: exact session |
| +origin plus the fixed exchange and wrapper paths for a validated task ID. |
| +Allow only those top-level navigations; reject unexpected redirects, popups, |
| +downloads and custom schemes. Keep the preview within its sandboxed child |
| +frame. No injected scripts, native script-message bridge, relaxed TLS, device |
| +bearer in WebKit, or automatic opening of blocked links. Test subframe loading |
| +separately so the navigation policy does not accidentally block the preview. |
| + |
| +Apple references: [WKWebView request loading](https://developer.apple.com/documentation/webkit/wkwebview/load(_:)-5siv6), |
| +[nonpersistent storage](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/nonpersistent()), |
| +[Safari view controller](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/). |
| + |
| +## Storage, audit and proof |
| + |
| +Add app-owned pass/grant tables via additive migration and register them in |
| +Models/Schema; do not modify framework session tables. Bound issuance per |
| +person/device/task, rate-limit exchange, and prune expired records. Audit mint, |
| +exchange and identifiable refusals with actor/task/non-secret grant ID and |
| +reason, transactionally; never include secrets, cookies, preview URLs or body |
| +contents. Unknown-token refusals remain generic and rate-limited. |
| + |
| +Test first and mutate: task visibility, revoked member/device/backing native |
| +session, person/instance/task/candidate/deployment binding, exact expiry, |
| +concurrent single use and replay, failed-audit rollback, cookie attributes, |
| +GET-only route isolation, CSRF/redirect refusal, wrapper sandbox/CSP and raw |
| +origin refusal. Native fake-server tests cover request/expiry, stale candidate, |
| +allowlist, redirects, foreground revalidation and sign-out. Browser tests cover |
| +the real exchange-to-wrapper flow. Add OpenAPI contracts and a perf-budget |
| +record for any new GET, then native and Go gates and Linux CI. No runner |
| +protocol change is needed. |
| + |
| +## Approved refinements |
| + |
| +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. 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-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index e3b15798..be78a21d 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -6902,6 +6902,8 @@ records remain unchanged. |
| | `docs/api/equipo-v1.md / Talk to the Assistant: paused jobs` | Each job has one `job` card, updated in place as the work goes on, so the same card `id` comes again in `card` events with a higher `revision`. Its `question` is the job’s title, `result` its short status, `detail` adds one sentence, and `started_at` gives the start time. Its state is `working`, `asking`, `ready`, `done`, `stopped` or `paused`. A paused job waits and will carry on by itself, for example when a plan’s limit resets. Its `result` says when that will be, in your time zone, such as “Paused until 21:00”, or says “Paused” if the time is unknown. Its `detail` explains why it paused and when it will carry on. A paused card has `carry_on: true` when “Carry on now” is available because another of your plans has room at no extra cost; otherwise `carry_on` is left out. To carry on, call `POST /api/v1/assistant/cards/{id}/carry_on` with the card’s revision and a key of your choosing, 1 to 128 bytes:<br><br>```json<br>{"revision":7,"idempotency_key":"<a new key for each tap>"}<br>```<br><br>The answer is `200` with the card as it is now in `card`; the same key again gives the same answer. A stale revision is `409 card_stale`, a card that is not paused is `409 not_paused`, and a paused card without `carry_on` is `409 carry_on_unavailable`. Each `409` body carries the card as it is now in `card`.<br><br>A job card takes no answer: answering one is `404 not_found`. Its links may include something to try, the published site, and the job's page in Equipo. A go-ahead or Publish card for a job carries `job`, the job card's `id`. `job`, `detail` and `started_at` are left out when they do not apply.<br><br>`paused` is sent only to a client that asks for it: add `job_states=paused` to `GET /api/v1/assistant/snapshot` and `GET /api/v1/assistant/events`. Without it a paused job card comes as `working`, with the same `result` and `detail` and no `carry_on`.<br><br>Times in `result` and `detail` use your time zone. Equipo uses `Europe/Dublin` unless you set a different one. Set it with `PUT /api/v1/assistant/time-zone` and an IANA time-zone name:<br><br>```json<br>{"time_zone":"Europe/Madrid"}<br>```<br><br>The response is `200` with `time_zone`. If Equipo does not recognise the time zone, the response is `422 invalid_input`. A device can set its time zone with `PUT /api/v1/time-zone`. | Paused job cards, carry_on and the time zone for Base (spec 2026-11-24; Luna, with the controller's Equipo correction) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| | `docs/api/equipo-v1.md / Talk to the Assistant: only_if_unset` | To set the person's time zone only if they haven't set one, add `"only_if_unset": true`. The response's `time_zone` is the one in effect. | Base's team zone never overrides the person's own (controller ruling, 2026-11-24) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| | `api.already_running` | A request to run this work is already in progress. | A second Run now for the same hold (paused work review S2) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| +| `api.preview_changed` | The change has been updated. Review it again. | Native preview when the candidate changed | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) | |
| +| `api.preview_expired` | This preview expired. Open it again. | Native preview after pass or grant expiry | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) | |
| | `api.offer_changed` | The option to run this work has changed. Check the current option, then try again. | A Run now tap whose offer changed since the page was drawn (paused work re-review R1) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| | `work.pause.run_now_may_bill` | This may use a plan that bills per use. | Under plain Run it now anyway, for an older runner, when a pay-per-use connection could take it (re-review R1) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| | `chat.merge.retry_offer` | Merging %s didn’t go through. Try the merge again? | Copy specialist | Runtime; COPY APPROVED (Paul, 2026-11-25, copy-review 6haczxo74hoyyuf7xkojgqd27e, unchanged) | |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md b/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md| new file mode 100644 |
| index 00000000..536522a0 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-preview-pass.md |
| @@ -0,0 +1,261 @@ |
| +# Preview pass controller report |
| + |
| +Branch: `preview/pass`. Base: `7c113ac8`. Design approved by the controller on |
| +2026-11-26 in `2026-11-26-preview-pass.md`. |
| + |
| +## Delivered behavior |
| + |
| +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 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. |
| +The transaction rechecks the roster, device, backing native session, task, |
| +candidate, step attempt and deployment fingerprint. Secret lookup uses an exact |
| +indexed SHA-256 hash. The tested query plan and executed SQL both pin that down. |
| +Issuance and exchange are limited by device and IP; unknown tokens consume the |
| +IP allowance. Cookie values and pass bodies do not enter audit records. |
| + |
| +The shared renderer preserves its CSP, sandbox and referrer policy. The native |
| +sheet allows only the fixed POST exchange and exact GET wrapper as main-frame |
| +navigation; no popups, downloads, custom schemes or device bearer enter it. |
| +Each presentation owns a new non-persistent WebKit store. Dismissal, expiry, |
| +changed deployment, sign-out and account replacement dispose it. Foreground |
| +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 when no well-formed grant selects the restricted lane. |
| + |
| +## 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 |
| + |
| +Initial store stubs refused all mint requests: `go test ./internal/equipo -run |
| +'^TestPreview' -count=1` failed the new single-use/lifetime and binding tests. |
| +Initial HTTP stubs left the mint route absent and allowed normal-session |
| +fall-through: the HTTP tests failed on 401 mint and 200 invalid-cookie fallback. |
| +Native stubs failed nine assertions across the first four tests. Implementation |
| +then passed those tests. Evidence is retained in `site/build/slice6/validation`. |
| + |
| +The real Chromium browser lane posts a pass, follows the 303, loads the wrapper |
| +and its iframe, then proves replay returns 404. The actual iframe request has |
| +no Cookie, Authorization or Referer. Test-only TLS trust is confined to Chromium |
| +for the two local HTTPS test servers; production WebKit has no TLS override. |
| + |
| +## Mutations |
| + |
| +33 server guards and 19 native guards were broken deliberately, tested, and |
| +restored. All 52 logical mutations were killed by assertions, not compile errors. |
| +The scripts, individual test logs and result JSON are retained in the validation |
| +folder. Each server invocation uses `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0` and |
| +`go test ./internal/equipo -run <named test/subtest> -count=1`. Native mutations |
| +use `swift test --package-path native/apple --filter 'Preview(Pass|Lifecycle)Tests'`. |
| + |
| +Server: pass and grant duration; both indexed hash lookups; task and candidate |
| +binding; pass and grant expiry; hashed storage; revoked device and native |
| +session; instance, attempt, current candidate and deployment fingerprint; |
| +iframe cookie host and canonical trailing-dot host; Preview step candidate; |
| +final task; preview and device expiry caps; device and IP rate limits; Secure, |
| +HttpOnly and Strict cookie flags; no ambient-session fallback; GET-only grant; |
| +bounded exchange body; transactional audit; known refusal audit and device |
| +limit; single-use consumption. |
| + |
| +Native: private store; releasing web view, store and browser; session invalidation |
| +and permanent invalidation; exact expiry boundary; observed deployment change; |
| +foreground binding check; late-response generation; busy guard; pass alphabet; |
| +pass expiry and grant maximum; newest Preview selection; HTTPS; exact wrapper |
| +origin; GET-only wrapper; iframe cookie-host refusal. |
| + |
| +Initial survivors led to stronger tests: query SQL is checked as well as the |
| +query plan; the device check is tested independently of task authority; the |
| +body-bound test uses valid form padding; permanent model invalidation is tested |
| +with an otherwise usable client (session invalidation also disables its client). |
| +Initial mutation filters/targets were corrected to hit the intended |
| +subtest or occurrence. No surviving mutation is counted as killed. |
| + |
| +## Validation |
| + |
| +- Pre-merge native gate passed: 359 tests in 48 suites, one existing known issue; |
| + 334 web-parity strings, security scripts, fixtures and both platform builds. |
| + Recorded in `preview-native-final-gate.log`. |
| +- `GOOS=linux GOARCH=amd64 make build` passed, including the Darwin runner build. |
| +- `GOOS=linux GOARCH=amd64 make vet` passed, including the Make target's Darwin |
| + runner check. The ordinary Mac all-package build hits the existing Linux-only |
| + toolproxy `unix.O_PATH` use. Linux hub CI is the authoritative full gate. |
| +- `make fmt-check budget spacing copy-release-check migration-check` passed; |
| + `PATH="$(GOTOOLCHAIN=go1.26.11 go env GOROOT)/bin:$PATH"` used for gofmt. |
| + Size records name the new code and measured totals. |
| +- Host-built staticcheck v0.7.0 with `GOOS=linux GOARCH=amd64`, tags |
| + `browser,perf,testbuild`, passed. Host-built govulncheck v1.8.0 targeting Linux |
| + found no reachable vulnerabilities. `make gitleaks` found no leaks. |
| +- `make lanes-check` passed: 18 regular and 5 browser lanes cover every test. |
| +- Preview store/HTTP/security tests passed, as did the device/OpenAPI contract |
| + and migration tests. Final targeted and browser logs are retained. |
| +- The Make perf harness, targeted to `./internal/equipotest` on Mac, passed: |
| + wrapper median 1.041 ms, worst 1.125 ms against 150 ms; cold boot median |
| + 154 ms against 500 ms. The new GET exchange refusal has an explicit skip record. |
| +- An initial validation attempt lost files from the shared Go cache. On the |
| + controller's instruction, retried without clearing it. The retry passed. |
| + |
| +## Native captures and limitations |
| + |
| +`iphone-preview.png` and `mac-preview.png` are captured from the branch's built |
| +apps against the tagged manual Go fixture, using the actual bearer mint, |
| +POST-body exchange, wrapper cookie, shared wrapper and iframe. The external |
| +example page is disposable fixture content. The server is loopback-only behind |
| +a temporary HTTPS tailnet port. The fixture config contains a disposable test |
| +credential, stays private, and is deleted at teardown. It is not committed or |
| +archived. No production account or credential is used. The Mac image is the live |
| +sheet, captured with AppKit. Its header uses the app palette background so |
| +bitmap exports preserve the same readable surface as the window. |
| + |
| +The iframe's external service remains responsible for its own availability. |
| +Grant expiry prevents new wrapper reads; it cannot retract HTML already |
| +received by an arbitrary browser. Native disposes the delivered view at expiry. |
| +The pass does not approve an unsafe preview or confer any merge authority. |
| + |
| +Final commit and Linux CI verdict are sent to the controller after pushing; |
| +no merge, deployment or release is performed. |
| + |
| + |
| +## Main integration before publication |
| + |
| +Normally merged main `088e5863` after `2469eaa8`, as requested. Kept the |
| +Changed files tab and its explicit detail-only projection. The transactional |
| +`TaskAt` read shares authority and opts out of file facts; `TaskDetail` still |
| +opts in. Retained the new native load result and preview invalidation together. |
| +Moved the preview tables to migration 0109 after main's 0108 change-files field. |
| +Combined budget reasons and remeasured 23204 app source, 34984/9873 chat |
| +source/tests, and 11967 plan contract test lines. Re-ran validation on the merge. |
| + |
| +The merged native gate passed: 377 tests in 50 suites, one existing known issue, |
| +334 web-parity strings, and both builds (`preview-native-merged-gate.log`). |
| +Merged preview/visibility contracts, migration, copy, lane coverage and browser |
| +exchange checks passed. Changed-files projection tests passed on the merge. |
| + |
| +## CI copy-guard correction |
| + |
| +Linux CI at f149ba60 rejected the computed API error code in the mint handler |
| +with TestAPIErrorCopyKeys. Reproduced locally using |
| +`GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo -run '^TestAPIErrorCopyKeys$' -count=1`. |
| +The HTTP error branches now name their codes literally. The scanner is unchanged |
| +from main. The person API uses its ordinary api.<code> lookup. Luna approved |
| +api.preview_changed and api.preview_expired on 2026-11-26; they are marked in |
| +copy.go and imported byte-identically into both native catalogs under parity. |
| +Native errors and lifecycle expiry use these words; the wrapper retains its |
| +reviewed web words. |
| + |
| +TestPreviewErrorCopyKeys failed for both old runtime mappings, and the native |
| +staleAndExpiredWordsComeFromReviewedCatalog test failed with the old native keys. |
| +Both pass after switching to the approved API keys. TestAPIErrorCopyKeys failed |
| +without the two catalog entries, then passed. The scanner remains unchanged. |
| + |
| +The source budget was remeasured at 23214 lines. The initial Linux run's |
| +TestContractRetryAccountActions, TestTimeouts and TestBrowserCopyContinue |
| +failures each passed its automatic retry. The preview browser lane passed. |
| + |
| +Approved-copy validation: TestAPIErrorCopyKeys and all TestPreview tests passed |
| +in the app and person API packages; make copy-release-check, fmt-check and |
| +budget passed. The native gate passed 377 tests in 50 suites (one existing |
| +known issue), 336 parity strings, and both app builds. |
| + |
| +CI at 7bd80b29 passed the API copy scanner but identified the missing two review |
| +inventory rows. Added the exact approved text and Luna/date provenance to the |
| +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. |
| + |
| +## Migration snapshot correction |
| + |
| +Fable identified that migration 0110's indexes were missing from schema.sql. |
| +The narrow TestConversationMigrationSnapshot reproduced both missing-index |
| +errors. Appended 0110 to the snapshot's existing additive SQL, then the same |
| +unchanged test passed (1.530s). Command: GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11 |
| +CGO_ENABLED=0 go test -p 1 ./internal/equipo |
| +-run '^TestConversationMigrationSnapshot$' -count=1. No full local suite or |
| +simulator was started while the machine was critically loaded. |
| + |
| +The focused performance budget check on b3adc1bf passed TestPerfScreens and |
| +TestPerfBoot with zero failures. Evidence is archived with the review logs. |
diff --git a/internal/equipo/app.go b/internal/equipo/app.go| index fca880fe..0de853b4 100644 |
| --- a/internal/equipo/app.go |
| +++ b/internal/equipo/app.go |
| @@ -285,6 +285,10 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg |
| w.Header().Set("Cache-Control", "no-store") |
| _ = json.NewEncoder(w).Encode(wire.RunnerProtocol{Protocol: wire.ProtocolCurrent}) |
| }) |
| + a.Post("/native/preview/exchange", a.exchangePreviewHTTP) |
| + a.Get("/native/preview/exchange", a.exchangePreviewHTTP) |
| + a.Get("/tasks/{id}/preview", a.previewGrantOrBrowser(a.requireMember(http.HandlerFunc(a.previewPage))).ServeHTTP) |
| + a.Post("/tasks/{id}/preview", a.previewGrantOrBrowser(a.requireMember(http.HandlerFunc(a.allowUnsafePreview))).ServeHTTP) |
| a.Post("/auth/begin", a.auth.Begin) |
| a.Get("/auth/callback", a.rememberSignIn(a.auth.Callback)) |
| a.Get("/auth/verify", a.rememberSignIn(a.auth.Verify)) |
| @@ -335,8 +339,6 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg |
| r.Post("/conversation/tasks/{id}/merge", a.workTaskMerge) |
| r.Get("/tasks/new", a.taskForm) |
| r.Get("/tasks/{id}", a.taskDetail) |
| - r.Get("/tasks/{id}/preview", a.previewPage) |
| - r.Post("/tasks/{id}/preview", a.allowUnsafePreview) |
| r.Get("/tasks/{id}/rendered-change", a.renderedPage) |
| r.Get("/tasks/{id}/rendered-change/{hash}.png", a.renderedImage) |
| r.Get("/tasks/{id}/files/{file}", a.workTaskFile) |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index 0d7e1aec..07865566 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -1958,20 +1958,30 @@ func (s *Store) TaskDetail(ctx context.Context, person, id string) (wire.Task, e |
| func (s *Store) readTaskView(ctx context.Context, person, id string, options taskViewOptions) (out wire.Task, err error) { |
| err = s.read(ctx, func(tx *gorm.DB) error { |
| - if err := s.authority.CurrentPerson(ctx, tx); err != nil { |
| - return err |
| - } |
| - t := &txn{s: s, db: tx} |
| - k, err := t.loadTask(id) |
| - if err != nil { |
| - return err |
| - } |
| - out, err = t.taskViewWith(k, options) |
| + out, err = s.taskAt(ctx, tx, id, options) |
| return err |
| }) |
| return out, err |
| } |
| +// TaskAt uses task-read authority on the caller's transaction. Preview grants |
| +// need that same read atomically with their credential and single-use checks. |
| +func (s *Store) TaskAt(ctx context.Context, tx *gorm.DB, id string) (wire.Task, error) { |
| + return s.taskAt(ctx, tx, id, taskViewOptions{}) |
| +} |
| + |
| +func (s *Store) taskAt(ctx context.Context, tx *gorm.DB, id string, options taskViewOptions) (wire.Task, error) { |
| + if err := s.authority.CurrentPerson(ctx, tx); err != nil { |
| + return wire.Task{}, err |
| + } |
| + t := &txn{s: s, db: tx} |
| + k, err := t.loadTask(id) |
| + if err != nil { |
| + return wire.Task{}, err |
| + } |
| + return t.taskViewWith(k, options) |
| +} |
| + |
| // CancelTask is POST /tasks/{id}/cancel: owners only. |
| func (s *Store) CancelTask(ctx context.Context, person, id string) (attempt int64, err error) { |
| err = s.tx(ctx, func(t *txn) error { |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index fc169758..b9dbb521 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -2412,6 +2412,8 @@ var pageCopy = map[string]string{ |
| "time.when_in": "%s (%s)", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) |
| "api.not_paused": "This work is not paused now. Check its latest status.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) |
| "api.already_running": "A request to run this work is already in progress.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) |
| + "api.preview_changed": "The change has been updated. Review it again.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) |
| + "api.preview_expired": "This preview expired. Open it again.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) |
| "api.offer_changed": "The option to run this work has changed. Check the current option, then try again.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) |
| "work.pause.run_now_may_bill": "This may use a plan that bills per use.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) |
diff --git a/internal/equipo/migrations/0109_preview_passes.sql b/internal/equipo/migrations/0109_preview_passes.sql| new file mode 100644 |
| index 00000000..8fae413b |
| --- /dev/null |
| +++ b/internal/equipo/migrations/0109_preview_passes.sql |
| @@ -0,0 +1,14 @@ |
| +-- Device passes and wrapper-only grants never create a general sign-in session. |
| +CREATE TABLE preview_passes ( |
| + hash text PRIMARY KEY, id text, instance text, person text, credential text, |
| + task_id text, candidate text, step_id text, fingerprint text, |
| + epoch integer, attempt integer, expires_at datetime, grant_expires_at datetime, |
| + consumed_at datetime |
| +); |
| +CREATE INDEX preview_pass_expiry ON preview_passes(expires_at); |
| +CREATE TABLE preview_grants ( |
| + hash text PRIMARY KEY, id text, instance text, person text, credential text, |
| + task_id text, candidate text, step_id text, fingerprint text, |
| + epoch integer, attempt integer, expires_at datetime |
| +); |
| +CREATE INDEX preview_grant_expiry ON preview_grants(expires_at); |
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/migrations/schema.sql b/internal/equipo/migrations/schema.sql| index 7cd610ab..fdf32512 100644 |
| --- a/internal/equipo/migrations/schema.sql |
| +++ b/internal/equipo/migrations/schema.sql |
| @@ -780,3 +780,22 @@ ALTER TABLE chat_steps ADD COLUMN coordinator_attempt integer; |
| -- Bounded Engineering file-list facts, never merge authority. |
| ALTER TABLE chat_steps ADD COLUMN change_files text; |
| + |
| +-- Device passes and wrapper-only grants never create a general sign-in session. |
| +CREATE TABLE preview_passes ( |
| + hash text PRIMARY KEY, id text, instance text, person text, credential text, |
| + task_id text, candidate text, step_id text, fingerprint text, |
| + epoch integer, attempt integer, expires_at datetime, grant_expires_at datetime, |
| + consumed_at datetime |
| +); |
| +CREATE INDEX preview_pass_expiry ON preview_passes(expires_at); |
| +CREATE TABLE preview_grants ( |
| + hash text PRIMARY KEY, id text, instance text, person text, credential text, |
| + task_id text, candidate text, step_id text, fingerprint text, |
| + epoch integer, attempt integer, expires_at datetime |
| +); |
| +CREATE INDEX preview_grant_expiry ON preview_grants(expires_at); |
| + |
| +-- 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/person_api.go b/internal/equipo/person_api.go| index cc04f5ae..2112891d 100644 |
| --- a/internal/equipo/person_api.go |
| +++ b/internal/equipo/person_api.go |
| @@ -49,6 +49,7 @@ func (s *Store) personAPIRouter() chi.Router { |
| c := s.chatHTTP(auth.Authenticate, h.Failure) |
| c.Old = old |
| c.Mount(r) |
| + r.Post("/tasks/{id}/preview-pass", s.mintPreviewHTTP(auth)) |
| return r |
| } |
| func (s *Store) personAPIReader(a Actor) *conversation.Application { |
diff --git a/internal/equipo/personapi/preview_error_test.go b/internal/equipo/personapi/preview_error_test.go| new file mode 100644 |
| index 00000000..c88ad082 |
| --- /dev/null |
| +++ b/internal/equipo/personapi/preview_error_test.go |
| @@ -0,0 +1,29 @@ |
| +package personapi |
| + |
| +import ( |
| + "encoding/json" |
| + "net/http/httptest" |
| + "testing" |
| +) |
| + |
| +func TestPreviewErrorCopyKeys(t *testing.T) { |
| + for _, tc := range []struct { |
| + code, key string |
| + status int |
| + }{ |
| + {"preview_changed", "api.preview_changed", 409}, |
| + {"preview_expired", "api.preview_expired", 410}, |
| + } { |
| + t.Run(tc.code, func(t *testing.T) { |
| + w := httptest.NewRecorder() |
| + WriteError(w, httptest.NewRequest("POST", "/api/v1/tasks/task/preview-pass", nil), tc.status, tc.code, nil) |
| + var got Error |
| + if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil { |
| + t.Fatal(err) |
| + } |
| + if w.Code != tc.status || got.Code != tc.code || got.CopyKey != tc.key { |
| + t.Fatalf("preview error: status %d, %+v", w.Code, got) |
| + } |
| + }) |
| + } |
| +} |
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| new file mode 100644 |
| index 00000000..b8f93815 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass.go |
| @@ -0,0 +1,266 @@ |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/personapi" |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "gorm.io/gorm" |
| +) |
| + |
| +var ErrPreviewAccess = errors.New("preview access refused") |
| +var ErrPreviewExpired = errors.New("preview access expired") |
| +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"` |
| +} |
| +type previewGrant struct { |
| + Secret string |
| + ExpiresAt time.Time |
| + TaskID string |
| +} |
| + |
| +func (s *Store) mintPreviewPass(ctx context.Context, p PersonPrincipal, taskID, candidate, ip string) (out previewPass, err error) { |
| + if !previewPrincipal(ctx, p) { |
| + return out, ErrPreviewAccess |
| + } |
| + var refusal error |
| + err = s.write(ctx, func(tx *gorm.DB) error { |
| + ok, e := s.previewRate(tx, "mint", ip, p.CredentialID) |
| + if e != nil { |
| + return e |
| + } |
| + if !ok { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + device, e := s.previewDevice(tx, p) |
| + if e != nil { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + task, e := s.Chat().TaskAt(ctx, tx, taskID) |
| + if e != nil { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + deny := func(reason error) error { |
| + refusal = reason |
| + return previewRefusal(tx, previewBinding{Person: p.Address, TaskID: taskID}, "mint", reason) |
| + } |
| + if candidate == "" || candidate != task.CandidateSHA { |
| + return deny(ErrPreviewChanged) |
| + } |
| + step, fingerprint, e := s.previewDeployment(task) |
| + if e != nil { |
| + return deny(ErrPreviewAccess) |
| + } |
| + binding := previewBinding{Instance: device.InstanceID, Person: p.Address, Credential: p.CredentialID, Epoch: p.SessionEpoch, TaskID: taskID, Candidate: candidate, StepID: step.ID, Attempt: step.Attempt, Fingerprint: fingerprint} |
| + if e = s.validatePreview(task, binding); e != nil { |
| + return deny(e) |
| + } |
| + now := s.runnerClock.Now().UTC() |
| + grantExpiry := minPreviewTime(now.Add(15*time.Minute), device.TokenExpiresAt) |
| + if step.Preview.ExpiresAt != nil { |
| + 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 |
| + } |
| + // One pending pass per device/task; another tap replaces an unexchanged pass. |
| + if e = tx.Model(&previewPassRecord{}).Where("credential = ? AND task_id = ? AND consumed_at IS NULL", p.CredentialID, taskID).Select("consumed_at").Updates(map[string]any{"consumed_at": now}).Error; e != nil { |
| + return e |
| + } |
| + row := previewPassRecord{Hash: previewHash(out.Pass), ID: runnerSecret(), Binding: binding, ExpiresAt: out.ExpiresAt, GrantExpiresAt: grantExpiry} |
| + if e = tx.Create(&row).Error; e != nil { |
| + return e |
| + } |
| + return appendAudit(tx, Actor{Address: p.Address}, "preview.pass.mint", row.ID+":"+taskID) |
| + }) |
| + if err == nil { |
| + err = refusal |
| + } |
| + if err != nil { |
| + out = previewPass{} |
| + } |
| + return |
| +} |
| + |
| +func (s *Store) exchangePreviewPass(ctx context.Context, token, taskID, candidate, ip string) (out previewGrant, err error) { |
| + 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) (transactionError error) { |
| + defer func() { |
| + if transactionError == nil { |
| + transactionError = s.prunePreviews(tx) |
| + } |
| + }() |
| + ok, e := s.previewRate(tx, "exchange", ip, "") |
| + if e != nil { |
| + return e |
| + } |
| + if !ok { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + hash := previewHash(token) |
| + if hash == "" { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + var row previewPassRecord |
| + if e = tx.Where("hash = ?", hash).First(&row).Error; e != nil { |
| + if errors.Is(e, gorm.ErrRecordNotFound) { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + return e |
| + } |
| + // Device rate is separate from IP: a new source address cannot evade it. |
| + ok, e = runnerRateAt(tx, "preview:exchange:device:"+row.Binding.Credential, s.runnerClock.Now(), time.Minute, 10) |
| + if e != nil { |
| + return e |
| + } |
| + if !ok { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + if row.ConsumedAt != nil { |
| + refusal = ErrPreviewAccess |
| + 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}) |
| + if consumed.Error != nil { |
| + return consumed.Error |
| + } |
| + if consumed.RowsAffected != 1 { |
| + 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 |
| + } |
| + if refusal != nil { |
| + return previewRefusal(tx, row.Binding, row.ID, refusal) |
| + } |
| + out = previewGrant{Secret: runnerSecret(), TaskID: taskID, ExpiresAt: row.GrantExpiresAt} |
| + // Only the current presentation for this device/task retains a grant. |
| + if e = tx.Where("credential = ? AND task_id = ?", row.Binding.Credential, taskID).Delete(&previewGrantRecord{}).Error; e != nil { |
| + return e |
| + } |
| + grant := previewGrantRecord{Hash: previewHash(out.Secret), ID: runnerSecret(), Binding: row.Binding, ExpiresAt: out.ExpiresAt} |
| + if e = tx.Create(&grant).Error; e != nil { |
| + return e |
| + } |
| + return appendAudit(tx, Actor{Address: row.Binding.Person}, "preview.pass.exchange", grant.ID+":"+taskID) |
| + }) |
| + if err == nil { |
| + err = refusal |
| + } |
| + if err != nil { |
| + out = previewGrant{} |
| + } |
| + return |
| +} |
| + |
| +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) (transactionError error) { |
| + defer func() { |
| + if transactionError == nil { |
| + transactionError = s.prunePreviews(tx) |
| + } |
| + }() |
| + ok, e := s.previewRate(tx, "read", ip, "") |
| + if e != nil { |
| + return e |
| + } |
| + if !ok { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + hash := previewHash(token) |
| + if hash == "" { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + var row previewGrantRecord |
| + if e = tx.Where("hash = ?", hash).First(&row).Error; e != nil { |
| + if errors.Is(e, gorm.ErrRecordNotFound) { |
| + refusal = ErrPreviewAccess |
| + return nil |
| + } |
| + return e |
| + } |
| + ok, e = runnerRateAt(tx, "preview:read:device:"+row.Binding.Credential, s.runnerClock.Now(), time.Minute, 120) |
| + if e != nil { |
| + return e |
| + } |
| + if !ok { |
| + 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 { |
| + return deny(ErrPreviewAccess) |
| + } |
| + task, e := s.previewTask(tx, row.Binding) |
| + if e != nil { |
| + return deny(ErrPreviewAccess) |
| + } |
| + refusal = s.validatePreview(task, row.Binding) |
| + if refusal == nil && !s.runnerClock.Now().Before(row.ExpiresAt) { |
| + refusal = ErrPreviewExpired |
| + } |
| + if refusal != nil { |
| + return deny(refusal) |
| + } |
| + out = task |
| + return nil |
| + }) |
| + if err == nil { |
| + err = refusal |
| + } |
| + if err != nil { |
| + out = wire.Task{} |
| + } |
| + return |
| +} |
| + |
| +// Audit only hashed-record identities, never submitted identity or credential text. |
| +func previewRefusal(tx *gorm.DB, binding previewBinding, id string, reason error) error { |
| + _, code, _ := previewError(reason) |
| + return appendAudit(tx, Actor{Address: binding.Person}, "preview.pass.refused", id+":"+binding.TaskID+":"+code) |
| +} |
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| new file mode 100644 |
| index 00000000..9093d153 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_browser_test.go |
| @@ -0,0 +1,141 @@ |
| +//go:build browser |
| + |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "net/http" |
| + "net/http/httptest" |
| + "net/url" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "github.com/chromedp/chromedp" |
| +) |
| + |
| +// Real POST, CSRF, one-use exchange, 303, browser cookie jar, wrapper CSP and |
| +// child-frame request. No browser authentication bypass or injected grant. |
| +func TestBrowserPreviewPassExchange(t *testing.T) { |
| + rig := newPreviewPassRig(t) |
| + childRequests := make(chan *http.Request, 10) |
| + child := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + select { |
| + case childRequests <- r.Clone(context.Background()): |
| + default: |
| + } |
| + 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. |
| + childURL := strings.Replace(child.URL, "127.0.0.1", "localhost", 1) |
| + var stored map[string]any |
| + var preview string |
| + if err := rig.s.db.Reader().QueryRow("SELECT preview FROM chat_steps WHERE id = ?", "preview_step").Scan(&preview); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := json.Unmarshal([]byte(preview), &stored); err != nil { |
| + t.Fatal(err) |
| + } |
| + stored["url"] = childURL + "/" |
| + data, _ := json.Marshal(stored) |
| + if _, err := rig.s.db.Writer().Exec("UPDATE chat_steps SET preview = ? WHERE id = ?", string(data), "preview_step"); err != nil { |
| + t.Fatal(err) |
| + } |
| + exchangeCodes := make(chan int, 8) |
| + var handler http.Handler |
| + parent := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + if r.URL.Path == "/native/preview/exchange" { |
| + recorder := httptest.NewRecorder() |
| + handler.ServeHTTP(recorder, r) |
| + for k, values := range recorder.Header() { |
| + for _, v := range values { |
| + w.Header().Add(k, v) |
| + } |
| + } |
| + w.WriteHeader(recorder.Code) |
| + _, _ = w.Write(recorder.Body.Bytes()) |
| + exchangeCodes <- recorder.Code |
| + } else { |
| + handler.ServeHTTP(w, r) |
| + } |
| + })) |
| + defer parent.Close() |
| + parentURL := strings.Replace(parent.URL, "127.0.0.1", "equipo.example", 1) |
| + rig.s.personOrigin = parentURL |
| + handler = Mux(previewPassRouter(t, rig)) |
| + pass := rig.mint(t) |
| + form := url.Values{"pass": {pass.Pass}, "task": {"tk_preview"}, "candidate": {strings.Repeat("1", 40)}}.Encode() |
| + opts := append(chromedp.DefaultExecAllocatorOptions[:], chromedp.ExecPath(harness.ChromePath(t)), chromedp.NoSandbox, chromedp.Flag("host-resolver-rules", "MAP equipo.example 127.0.0.1"), chromedp.Flag("no-proxy-server", true), chromedp.Flag("ignore-certificate-errors", true), chromedp.UserDataDir(t.TempDir())) |
| + alloc, stop := chromedp.NewExecAllocator(context.Background(), opts...) |
| + defer stop() |
| + ctx, cancel := chromedp.NewContext(alloc) |
| + defer cancel() |
| + ctx, timeout := context.WithTimeout(ctx, 30*time.Second) |
| + defer timeout() |
| + // Load a same-origin public page, then submit a body-only form as WebKit does. |
| + if _, err := chromedp.Run(ctx, chromedp.Navigate(parentURL+"/")); err != nil { |
| + t.Fatal(err) |
| + } |
| + script := fmt.Sprintf(`(()=>{const f=document.createElement('form');f.method='POST';f.action='/native/preview/exchange';for(const [name,value] of new URLSearchParams(%q)){const i=document.createElement('input');i.name=name;i.value=value;f.append(i)}document.body.append(f);f.submit()})()`, form) |
| + if _, err := chromedp.Run(ctx, chromedp.Evaluate[any](script)); err != nil { |
| + t.Fatal(err) |
| + } |
| + select { |
| + case r := <-childRequests: |
| + if r.Header.Get("Cookie") != "" || r.Header.Get("Authorization") != "" || r.Header.Get("Referer") != "" { |
| + t.Fatalf("preview received Equipo authority: %v", r.Header) |
| + } |
| + 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) |
| + } |
| + sandbox, err := chromedp.Run(ctx, chromedp.Evaluate[string](`document.querySelector('iframe').getAttribute('sandbox')`)) |
| + if err != nil || sandbox != "allow-scripts allow-same-origin" { |
| + t.Fatalf("sandbox=%q err=%v", sandbox, err) |
| + } |
| + if code := <-exchangeCodes; code != 303 { |
| + t.Fatalf("exchange status %d", code) |
| + } |
| + // Reuse is refused by the actual browser route. Start from a public |
| + // page, since the wrapper deliberately prohibits injected scripts. |
| + if _, err = chromedp.Run(ctx, chromedp.Navigate(parentURL+"/")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err = chromedp.Run(ctx, chromedp.Evaluate[any](script)); err != nil { |
| + t.Fatal(err) |
| + } |
| + select { |
| + case code := <-exchangeCodes: |
| + if code != 404 { |
| + t.Fatalf("replay status %d", code) |
| + } |
| + case <-ctx.Done(): |
| + t.Fatal("replay did not reach exchange") |
| + } |
| +} |
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| new file mode 100644 |
| index 00000000..7b364dc4 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_fixture_test.go |
| @@ -0,0 +1,74 @@ |
| +//go:build previewfixture |
| + |
| +package equipo |
| + |
| +import ( |
| + "encoding/json" |
| + "encoding/pem" |
| + "net" |
| + "net/http" |
| + "net/http/httptest" |
| + "os" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| +) |
| + |
| +// Manual native screenshot fixture. Real routes, fresh temporary database and |
| +// device credential; only the deployed example page is external. No production |
| +// team or credential is read. The config is private and deleted on teardown. |
| +func TestPreviewScreenshotServer(t *testing.T) { |
| + path := os.Getenv("EQUIPO_PREVIEW_CONFIG") |
| + origin := os.Getenv("EQUIPO_PREVIEW_ORIGIN") |
| + if path == "" || origin == "" { |
| + t.Skip("manual screenshot fixture") |
| + } |
| + r := newPreviewPassRigAt(t, time.Now().UTC().Truncate(time.Second)) |
| + r.s.runnerClock = team.RealClock{} |
| + r.s.personOrigin = origin |
| + 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 { |
| + t.Fatal(e) |
| + } |
| + h := previewPassRouter(t, r) |
| + listener, e := net.Listen("tcp", "127.0.0.1:18146") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + server := &http.Server{Handler: Mux(h), ReadHeaderTimeout: 5 * time.Second} |
| + defer server.Close() |
| + defer CloseLive(h) |
| + go func() { _ = server.Serve(listener) }() |
| + data, _ := json.Marshal(map[string]string{"origin": origin, "token": r.credential.Token}) |
| + if e = os.WriteFile(path, data, 0600); e != nil { |
| + t.Fatal(e) |
| + } |
| + defer os.Remove(path) |
| + ticker := time.NewTicker(time.Second) |
| + defer ticker.Stop() |
| + for range ticker.C { |
| + if _, e := os.Stat(path + ".stop"); e == nil { |
| + return |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/preview_pass_http.go b/internal/equipo/preview_pass_http.go| new file mode 100644 |
| index 00000000..fba148f7 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_http.go |
| @@ -0,0 +1,188 @@ |
| +package equipo |
| + |
| +import ( |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "html" |
| + "io" |
| + "mime" |
| + "net/http" |
| + "regexp" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/personapi" |
| + "amadan.net/rastrillo/rastrillo/carlos" |
| + "amadan.net/rastrillo/rastrillo/clientip" |
| + "amadan.net/rastrillo/rastrillo/csrf" |
| + "github.com/go-chi/chi/v5" |
| +) |
| + |
| +const previewCookie = "__Host-equipo-preview-" |
| + |
| +var previewTaskID = regexp.MustCompile(`^[A-Za-z0-9_-]{1,128}$`) |
| +var previewCandidate = regexp.MustCompile(`^[0-9a-f]{40}$`) |
| + |
| +func previewIP(r *http.Request) string { |
| + hops := 0 |
| + if carlos.Running() { |
| + hops = clientip.DefaultHops |
| + } |
| + return clientip.From(r, hops) |
| +} |
| +func previewHeaders(w http.ResponseWriter) { |
| + w.Header().Set("Cache-Control", "no-store") |
| + w.Header().Set("Referrer-Policy", "no-referrer") |
| + w.Header().Set("X-Content-Type-Options", "nosniff") |
| +} |
| +func previewError(err error) (int, string, string) { |
| + switch { |
| + case errors.Is(err, ErrPreviewChanged): |
| + return 409, "preview_changed", "evidence.candidate_changed" |
| + case errors.Is(err, ErrPreviewExpired): |
| + return 410, "preview_expired", "question.expired" |
| + case errors.Is(err, ErrUnavailable): |
| + return 503, "unavailable", "api.unavailable" |
| + default: |
| + return 404, "not_found", "api.not_found" |
| + } |
| +} |
| +func previewErrorPage(w http.ResponseWriter, err error) { |
| + status, _, key := previewError(err) |
| + previewHeaders(w) |
| + w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| + w.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; font-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'") |
| + w.WriteHeader(status) |
| + fmt.Fprintf(w, `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><link rel="stylesheet" href="/static/tokens.css"><link rel="stylesheet" href="/static/theme.css"><title>%s</title><p>%s</p></html>`, html.EscapeString(copyText("preview.wrapper_title")), html.EscapeString(copyText(key))) |
| +} |
| +func (s *Store) mintPreviewHTTP(auth personapi.Authenticator) http.HandlerFunc { |
| + return func(w http.ResponseWriter, r *http.Request) { |
| + previewHeaders(w) |
| + if len(r.Header.Values("Authorization")) == 0 { |
| + personapi.WriteError(w, r, 401, "unauthenticated", nil) |
| + return |
| + } |
| + p, e := auth.Authenticate(r) |
| + if e != nil { |
| + personapi.WriteError(w, r, 401, "unauthenticated", nil) |
| + return |
| + } |
| + var input struct { |
| + Candidate string `json:"candidate_sha"` |
| + } |
| + r.Body = http.MaxBytesReader(w, r.Body, 4096) |
| + decoder := json.NewDecoder(r.Body) |
| + decoder.DisallowUnknownFields() |
| + var extra any |
| + if r.URL.RawQuery != "" || decoder.Decode(&input) != nil || decoder.Decode(&extra) != io.EOF || !previewCandidate.MatchString(input.Candidate) || !previewTaskID.MatchString(chi.URLParam(r, "id")) { |
| + personapi.WriteError(w, r, 422, "invalid_input", nil) |
| + return |
| + } |
| + out, e := s.mintPreviewPass(personapi.WithVerifiedPrincipal(r.Context(), p), p, chi.URLParam(r, "id"), input.Candidate, previewIP(r)) |
| + if e != nil { |
| + switch { |
| + case errors.Is(e, ErrPreviewChanged): |
| + personapi.WriteError(w, r, 409, "preview_changed", nil) |
| + case errors.Is(e, ErrPreviewExpired): |
| + personapi.WriteError(w, r, 410, "preview_expired", nil) |
| + case errors.Is(e, ErrUnavailable): |
| + personapi.WriteError(w, r, 503, "unavailable", nil) |
| + default: |
| + personapi.WriteError(w, r, 404, "not_found", nil) |
| + } |
| + return |
| + } |
| + w.Header().Set("Content-Type", "application/json") |
| + w.WriteHeader(201) |
| + _ = json.NewEncoder(w).Encode(out) |
| + } |
| +} |
| +func (a *application) exchangePreviewHTTP(w http.ResponseWriter, r *http.Request) { |
| + previewHeaders(w) |
| + kind, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type")) |
| + if r.Method != "POST" || r.URL.RawQuery != "" || len(r.Header.Values("Authorization")) != 0 || !personapi.OriginAllowed(r, a.origin) || !csrf.SameOrigin(r, a.origin) || kind != "application/x-www-form-urlencoded" { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + r.Body = http.MaxBytesReader(w, r.Body, 4096) |
| + if r.ParseForm() != nil || len(r.PostForm) != 3 { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + for _, key := range []string{"pass", "task", "candidate"} { |
| + if len(r.PostForm[key]) != 1 { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + } |
| + task, candidate := r.PostForm.Get("task"), r.PostForm.Get("candidate") |
| + if !previewTaskID.MatchString(task) || !previewCandidate.MatchString(candidate) { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + grant, e := a.store.exchangePreviewPass(r.Context(), r.PostForm.Get("pass"), task, candidate, previewIP(r)) |
| + if e != nil { |
| + previewErrorPage(w, e) |
| + return |
| + } |
| + path := "/tasks/" + grant.TaskID + "/preview" |
| + left := int(grant.ExpiresAt.Sub(a.store.runnerClock.Now()) / time.Second) |
| + if left <= 0 { |
| + previewErrorPage(w, ErrPreviewExpired) |
| + return |
| + } |
| + 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) |
| +} |
| + |
| +// 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) { |
| + 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+taskID && previewHash(c.Value) != "" { |
| + value = c.Value |
| + count++ |
| + } |
| + } |
| + if count != 1 || r.Method != "GET" || r.URL.RawQuery != "" || !previewTaskID.MatchString(taskID) || r.URL.EscapedPath() != "/tasks/"+taskID+"/preview" { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + task, e := a.store.readPreviewGrant(r.Context(), value, taskID, previewIP(r)) |
| + if e != nil { |
| + previewErrorPage(w, e) |
| + return |
| + } |
| + step, _, e := a.store.previewDeployment(task) |
| + if e != nil { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + policy, page, e := previewWrapper(step.Preview.URL, step.Preview.Unsafe) |
| + if e != nil { |
| + previewErrorPage(w, ErrPreviewAccess) |
| + return |
| + } |
| + previewHeaders(w) |
| + w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| + w.Header().Set("Content-Security-Policy", policy) |
| + _, _ = io.WriteString(w, page) |
| + }) |
| +} |
diff --git a/internal/equipo/preview_pass_http_test.go b/internal/equipo/preview_pass_http_test.go| new file mode 100644 |
| index 00000000..b7aadef8 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_http_test.go |
| @@ -0,0 +1,181 @@ |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "io" |
| + "net/http" |
| + "net/http/httptest" |
| + "net/url" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/go-chi/chi/v5" |
| +) |
| + |
| +func previewPassRouter(t *testing.T, r *previewPassRig) http.Handler { |
| + t.Helper() |
| + env := agentEnv(t) |
| + cfg, e := LoadConfig(func(k string) string { return env[k] }) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + cfg.Origin = r.s.personOrigin |
| + // Keep the fixture's verified native session while using the actual app router. |
| + session := r.s.personNativeSession |
| + h, e := RouterWithStore(r.s.db, cfg, agentMail{}, nil, r.s) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + r.s.personNativeSession = session |
| + t.Cleanup(func() { CloseLive(h) }) |
| + return h |
| +} |
| +func passExchangeRequest(token, task, candidate string) *http.Request { |
| + form := url.Values{"pass": {token}, "task": {task}, "candidate": {candidate}} |
| + r := httptest.NewRequest("POST", "https://equipo.example/native/preview/exchange", strings.NewReader(form.Encode())) |
| + r.Header.Set("Origin", "https://equipo.example") |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + return r |
| +} |
| +func TestPreviewPassHTTPFlowAndIsolation(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + 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) |
| + } |
| + w := httptest.NewRecorder() |
| + h.ServeHTTP(w, passExchangeRequest(pass.Pass, "tk_preview", passCandidate)) |
| + if w.Code != 303 || w.Header().Get("Location") != "/tasks/tk_preview/preview" { |
| + t.Fatalf("exchange: %d %v %s", w.Code, w.Header(), w.Body) |
| + } |
| + cookies := w.Result().Cookies() |
| + if len(cookies) != 1 { |
| + t.Fatal("cookies", cookies) |
| + } |
| + cookie := cookies[0] |
| + 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 { |
| + method, path string |
| + allowed bool |
| + }{{"GET", "/tasks/tk_preview/preview", true}, {"POST", "/tasks/tk_preview/preview", false}, {"GET", "/tasks/tk_other/preview", false}, {"GET", "/tasks/tk_preview", false}, {"GET", "/api/v1/tasks/tk_preview", false}, {"GET", "/api/v1/events", false}, {"GET", "/api/v1/attachments/nope", false}} { |
| + req := httptest.NewRequest(route.method, "https://equipo.example"+route.path, nil) |
| + req.AddCookie(cookie) |
| + req.Header.Set("Origin", "https://equipo.example") |
| + answer := httptest.NewRecorder() |
| + h.ServeHTTP(answer, req) |
| + if route.allowed { |
| + if answer.Code != 200 || !strings.Contains(answer.Header().Get("Content-Security-Policy"), "frame-src https://eq-preview.example.test;") || !strings.Contains(answer.Body.String(), `sandbox="allow-scripts allow-same-origin"`) { |
| + t.Fatalf("wrapper %d %s", answer.Code, answer.Body) |
| + } |
| + } else if answer.Code >= 200 && answer.Code < 300 { |
| + t.Fatalf("grant escaped scope: %s %s", route.method, route.path) |
| + } |
| + } |
| + for _, input := range []struct{ token, task, candidate string }{{pass.Pass, "tk_preview", passCandidate}, {strings.Repeat("a", 43), "tk_preview", passCandidate}, {pass.Pass, "tk_other", passCandidate}} { |
| + w = httptest.NewRecorder() |
| + h.ServeHTTP(w, passExchangeRequest(input.token, input.task, input.candidate)) |
| + if w.Code != 404 || strings.Contains(w.Body.String(), pass.Pass) { |
| + t.Fatalf("observable refusal: %d %s", w.Code, w.Body) |
| + } |
| + } |
| +} |
| +func TestPreviewCookiePresenceNeverFallsThrough(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + // Even an otherwise valid browser session must not rescue a refused grant. |
| + normal := 0 |
| + app := &application{store: r.s, origin: r.s.personOrigin} |
| + 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) |
| + req.Header.Set("Cookie", raw+"; normal-session=valid") |
| + w := httptest.NewRecorder() |
| + route.ServeHTTP(w, req) |
| + if w.Code != 404 { |
| + t.Fatalf("invalid cookie %q: %d", raw, w.Code) |
| + } |
| + } |
| + if normal != 0 { |
| + t.Fatal("fell through to normal sign-in", normal) |
| + } |
| +} |
| + |
| +func TestPreviewExchangeRejectsConflictingContext(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + h := previewPassRouter(t, r) |
| + p := r.mint(t) |
| + changes := []struct { |
| + name string |
| + change func(*http.Request) |
| + }{ |
| + {"query", func(q *http.Request) { q.URL.RawQuery = "redirect=https://evil.example" }}, |
| + {"origin", func(q *http.Request) { q.Header.Set("Origin", "https://evil.example") }}, |
| + {"referer", func(q *http.Request) { q.Header.Set("Referer", "https://evil.example/") }}, |
| + {"fetch-site", func(q *http.Request) { q.Header.Set("Sec-Fetch-Site", "cross-site") }}, |
| + {"bearer", func(q *http.Request) { q.Header.Set("Authorization", "Bearer "+r.credential.Token) }}, |
| + {"type", func(q *http.Request) { q.Header.Set("Content-Type", "text/plain") }}, |
| + {"get", func(q *http.Request) { q.Method = "GET" }}, |
| + {"extra", func(q *http.Request) { |
| + q.Body = io.NopCloser(strings.NewReader("pass=" + p.Pass + "&task=tk_preview&candidate=" + passCandidate + "&redirect=x")) |
| + }}, |
| + {"duplicate", func(q *http.Request) { |
| + q.Body = io.NopCloser(strings.NewReader("pass=" + p.Pass + "&pass=" + p.Pass + "&task=tk_preview&candidate=" + passCandidate)) |
| + }}, |
| + {"bound", func(q *http.Request) { |
| + q.Body = io.NopCloser(strings.NewReader("pass=" + p.Pass + "&task=tk_preview&candidate=" + passCandidate + strings.Repeat("&", 4096))) |
| + }}, |
| + } |
| + for _, tt := range changes { |
| + t.Run(tt.name, func(t *testing.T) { |
| + request := passExchangeRequest(p.Pass, "tk_preview", passCandidate) |
| + tt.change(request) |
| + response := httptest.NewRecorder() |
| + h.ServeHTTP(response, request) |
| + if response.Code < 400 || response.Header().Get("Set-Cookie") != "" || response.Header().Get("Location") != "" { |
| + t.Fatalf("accepted conflicting context: %d %v", response.Code, response.Header()) |
| + } |
| + }) |
| + } |
| + response := httptest.NewRecorder() |
| + h.ServeHTTP(response, passExchangeRequest(p.Pass, "tk_preview", passCandidate)) |
| + if response.Code != 303 { |
| + t.Fatalf("refused requests consumed pass: %d %s", response.Code, response.Body) |
| + } |
| +} |
| + |
| +func TestPreviewExpiredCookieAndUnsafePOSTNeverFallThrough(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + pass := r.mint(t) |
| + grant, err := r.s.exchangePreviewPass(r.ctx, pass.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + app := &application{store: r.s, origin: r.s.personOrigin} |
| + calls := 0 |
| + handler := app.previewGrantOrBrowser(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { calls++; w.WriteHeader(200) })) |
| + for _, method := range []string{"POST", "GET"} { |
| + if method == "GET" { |
| + r.clock.Advance(15 * time.Minute) |
| + } |
| + req := httptest.NewRequest(method, "https://equipo.example/tasks/tk_preview/preview", nil) |
| + ctx := chi.NewRouteContext() |
| + ctx.URLParams.Add("id", "tk_preview") |
| + req = req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, ctx)) |
| + 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 { |
| + t.Fatalf("%s grant fell through: code=%d calls=%d", method, out.Code, calls) |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/preview_pass_models.go b/internal/equipo/preview_pass_models.go| new file mode 100644 |
| index 00000000..4bd6ec13 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_models.go |
| @@ -0,0 +1,3 @@ |
| +package equipo |
| + |
| +func init() { Models = append(Models, &previewPassRecord{}, &previewGrantRecord{}) } |
diff --git a/internal/equipo/preview_pass_security_test.go b/internal/equipo/preview_pass_security_test.go| new file mode 100644 |
| index 00000000..a35740da |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_security_test.go |
| @@ -0,0 +1,283 @@ |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "gorm.io/gorm" |
| +) |
| + |
| +func TestPreviewSecretsAreHashedAndIndexed(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + var lookups []string |
| + if err := r.s.db.G.Callback().Query().After("gorm:query").Register("preview_exact_hash", func(tx *gorm.DB) { |
| + if tx.Statement.Table == "preview_passes" || tx.Statement.Table == "preview_grants" { |
| + lookups = append(lookups, tx.Statement.SQL.String()) |
| + } |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + p := r.mint(t) |
| + g, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + if _, err := r.s.readPreviewGrant(r.ctx, g.Secret, "tk_preview", "192.0.2.1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(lookups) != 2 { |
| + t.Fatal("unexpected secret lookups", len(lookups)) |
| + } |
| + for _, query := range lookups { |
| + if !strings.Contains(query, "WHERE hash = ?") { |
| + t.Fatal("secret lookup is not an exact hash predicate") |
| + } |
| + } |
| + for _, item := range []struct{ table, secret string }{{"preview_passes", p.Pass}, {"preview_grants", g.Secret}} { |
| + var hash string |
| + if e := r.s.db.Reader().QueryRow("SELECT hash FROM " + item.table).Scan(&hash); e != nil { |
| + t.Fatal(e) |
| + } |
| + if hash != previewHash(item.secret) || hash == item.secret || len(hash) != 64 { |
| + t.Fatal("plaintext or wrong hash") |
| + } |
| + var a, b, c int |
| + var plan string |
| + if e := r.s.db.Reader().QueryRow("EXPLAIN QUERY PLAN SELECT * FROM "+item.table+" WHERE hash = ?", hash).Scan(&a, &b, &c, &plan); e != nil { |
| + t.Fatal(e) |
| + } |
| + if !strings.Contains(plan, "SEARCH") || !strings.Contains(plan, "INDEX") || !strings.Contains(plan, "hash=?") { |
| + t.Fatal("unindexed lookup", plan) |
| + } |
| + } |
| + rows, e := r.s.db.Reader().Query("SELECT record_id FROM audit_events WHERE kind LIKE 'preview.%'") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + defer rows.Close() |
| + count := 0 |
| + for rows.Next() { |
| + var id string |
| + if e = rows.Scan(&id); e != nil { |
| + t.Fatal(e) |
| + } |
| + count++ |
| + if strings.Contains(id, p.Pass) || strings.Contains(id, g.Secret) || strings.Contains(id, "https://") { |
| + t.Fatal("audit contains credential or URL") |
| + } |
| + } |
| + if count != 2 { |
| + t.Fatal("missing audit", count) |
| + } |
| +} |
| +func TestPreviewPassAuditFailureRollsBackExchange(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + _, e := r.s.db.Writer().Exec(`CREATE TRIGGER deny_preview_audit BEFORE INSERT ON audit_events WHEN NEW.kind = 'preview.pass.exchange' BEGIN SELECT RAISE(ABORT, 'fixture'); END`) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + g, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if e == nil || g.Secret != "" { |
| + t.Fatal("issued grant without audit") |
| + } |
| + var grants int |
| + if e = r.s.db.Reader().QueryRow("SELECT count(*) FROM preview_grants").Scan(&grants); e != nil || grants != 0 { |
| + t.Fatal("grant survived rollback", e, grants) |
| + } |
| + if _, e = r.s.db.Writer().Exec("DROP TRIGGER deny_preview_audit"); e != nil { |
| + t.Fatal(e) |
| + } |
| + if _, e = r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1"); e != nil { |
| + t.Fatal("failed transaction consumed pass", e) |
| + } |
| +} |
| +func TestPreviewPassRatesCannotBeEvadedByChangingIP(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + for i := 0; i < 10; i++ { |
| + if _, e := r.s.mintPreviewPass(r.ctx, r.principal, "tk_preview", passCandidate, fmt.Sprintf("192.0.2.%d", i)); e != nil { |
| + t.Fatal(e) |
| + } |
| + } |
| + if _, e := r.s.mintPreviewPass(r.ctx, r.principal, "tk_preview", passCandidate, "198.51.100.1"); !errors.Is(e, ErrPreviewAccess) { |
| + t.Fatal("device mint limit", e) |
| + } |
| + r.clock.Advance(time.Minute) |
| + p := r.mint(t) |
| + if _, e := r.s.db.Writer().Exec("UPDATE members SET active=0"); e != nil { |
| + t.Fatal(e) |
| + } |
| + for i := 0; i < 10; i++ { |
| + _, _ = r.s.exchangePreviewPass(context.Background(), p.Pass, "tk_preview", passCandidate, fmt.Sprintf("192.0.2.%d", i)) |
| + } |
| + if _, e := r.s.db.Writer().Exec("UPDATE members SET active=1"); e != nil { |
| + t.Fatal(e) |
| + } |
| + if _, e := r.s.exchangePreviewPass(context.Background(), p.Pass, "tk_preview", passCandidate, "198.51.100.1"); !errors.Is(e, ErrPreviewAccess) { |
| + t.Fatal("device exchange limit", e) |
| + } |
| +} |
| +func TestPreviewPassUnknownTokensCountAgainstIPLimit(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + for range 30 { |
| + _, _ = r.s.exchangePreviewPass(context.Background(), "invalid", "tk_preview", passCandidate, "198.51.100.2") |
| + } |
| + if _, e := r.s.exchangePreviewPass(context.Background(), p.Pass, "tk_preview", passCandidate, "198.51.100.2"); !errors.Is(e, ErrPreviewAccess) { |
| + t.Fatal("unknown tokens evaded IP limit", e) |
| + } |
| + if _, e := r.s.exchangePreviewPass(context.Background(), p.Pass, "tk_preview", passCandidate, "198.51.100.3"); e != nil { |
| + t.Fatal("IP limit blocked different IP", e) |
| + } |
| +} |
| +func TestPreviewGrantBindingAndNoSlidingExpiry(t *testing.T) { |
| + for _, field := range []string{"instance", "person", "credential", "epoch", "task_id", "candidate", "step_id", "attempt", "fingerprint"} { |
| + t.Run(field, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + g, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + r.clock.Advance(14 * time.Minute) |
| + if _, e = r.s.readPreviewGrant(r.ctx, g.Secret, "tk_preview", "192.0.2.1"); e != nil { |
| + t.Fatal(e) |
| + } |
| + var expires time.Time |
| + if e = r.s.db.Reader().QueryRow("SELECT expires_at FROM preview_grants").Scan(&expires); e != nil { |
| + t.Fatal(e) |
| + } |
| + if !expires.Equal(g.ExpiresAt) { |
| + t.Fatal("sliding expiry") |
| + } |
| + value := any("different") |
| + if field == "epoch" || field == "attempt" { |
| + value = int64(99) |
| + } |
| + if e = r.s.write(context.Background(), func(tx *gorm.DB) error { |
| + return tx.Model(&previewGrantRecord{}).Where("hash = ?", previewHash(g.Secret)).Select(field).Updates(map[string]any{field: value}).Error |
| + }); e != nil { |
| + t.Fatal(e) |
| + } |
| + if _, e = r.s.readPreviewGrant(r.ctx, g.Secret, "tk_preview", "192.0.2.1"); e == nil { |
| + t.Fatal("ignored binding", field) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestPreviewPassCapsAndDeploymentEligibility(t *testing.T) { |
| + for _, kind := range []string{"preview-cap", "device-cap", "same-host", "same-host-dot", "unsafe-pending", "preview-candidate", "preview-expired", "final", "unknown-grant", "revoked-grant", "audit-read"} { |
| + t.Run(kind, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + 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 "preview-cap": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.expires_at',?) WHERE id='preview_step'", r.clock.Now().Add(30*time.Second).Format(time.RFC3339)) |
| + case "device-cap": |
| + exec("UPDATE person_devices SET token_expires_at=?", r.clock.Now().Add(30*time.Second)) |
| + case "same-host": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.url','https://equipo.example:8443/') WHERE id='preview_step'") |
| + case "same-host-dot": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.url','https://equipo.example.:8443/') WHERE id='preview_step'") |
| + case "unsafe-pending": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.outcome','failed'),reason='preview_headers' WHERE id='preview_step'") |
| + case "preview-candidate": |
| + exec("UPDATE chat_steps SET candidate_sha=? WHERE id='preview_step'", strings.Repeat("2", 40)) |
| + case "preview-expired": |
| + exec("UPDATE chat_steps SET preview=json_set(preview,'$.expires_at',?) WHERE id='preview_step'", r.clock.Now().Format(time.RFC3339)) |
| + case "final": |
| + exec("UPDATE chat_tasks SET stage='done'") |
| + } |
| + p, e := r.s.mintPreviewPass(r.ctx, r.principal, "tk_preview", passCandidate, "192.0.2.1") |
| + switch kind { |
| + case "same-host", "same-host-dot", "unsafe-pending", "preview-candidate", "preview-expired", "final": |
| + if e == nil || p.Pass != "" { |
| + t.Fatal("ineligible preview minted", kind) |
| + } |
| + return |
| + } |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + if strings.HasSuffix(kind, "-cap") && (!p.ExpiresAt.Equal(r.clock.Now().Add(30*time.Second)) || !p.GrantExpiresAt.Equal(p.ExpiresAt)) { |
| + t.Fatal("expiry cap lost") |
| + } |
| + grant, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + switch kind { |
| + case "unknown-grant": |
| + grant.Secret = strings.Repeat("A", 43) |
| + case "revoked-grant": |
| + exec("UPDATE members SET active=0") |
| + case "audit-read": |
| + r.clock.Advance(15 * time.Minute) |
| + default: |
| + return |
| + } |
| + if task, e := r.s.readPreviewGrant(r.ctx, grant.Secret, "tk_preview", "192.0.2.1"); e == nil || task.ID != "" { |
| + t.Fatal("invalid grant read succeeded") |
| + } |
| + if kind == "audit-read" { |
| + var count int |
| + if e := r.s.db.Reader().QueryRow("SELECT count(*) FROM audit_events WHERE kind='preview.pass.refused'").Scan(&count); e != nil || count != 1 { |
| + t.Fatal("missing refusal audit", count, e) |
| + } |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestPreviewDeviceGuardBeforeTaskRead(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + if _, err := r.s.db.Writer().Exec("UPDATE person_devices SET revoked_at=?", r.clock.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + var refused error |
| + err := r.s.write(context.Background(), func(tx *gorm.DB) error { _, refused = r.s.previewDevice(tx, r.principal); return nil }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !errors.Is(refused, ErrPreviewAccess) { |
| + t.Fatal("device helper accepted revoked credential") |
| + } |
| +} |
| + |
| +func TestPreviewKnownRefusalsAreAuditedAndDeviceLimited(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + pass := r.mint(t) |
| + for i := 0; i < 10; i++ { |
| + _, err := r.s.exchangePreviewPass(r.ctx, pass.Pass, "tk_other", passCandidate, fmt.Sprintf("198.51.100.%d", i)) |
| + if !errors.Is(err, ErrPreviewAccess) { |
| + t.Fatal("wrong binding accepted", err) |
| + } |
| + } |
| + if _, err := r.s.exchangePreviewPass(r.ctx, pass.Pass, "tk_preview", passCandidate, "203.0.113.1"); !errors.Is(err, ErrPreviewAccess) { |
| + 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 != 1 { |
| + t.Fatal("known refusal must be audited once", count, err) |
| + } |
| +} |
| +func TestPreviewStaleMintHasRefusalAudit(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + if _, err := r.s.mintPreviewPass(r.ctx, r.principal, "tk_preview", strings.Repeat("2", 40), "192.0.2.1"); !errors.Is(err, ErrPreviewChanged) { |
| + t.Fatal(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 != 1 { |
| + t.Fatal("stale mint missing audit", count, err) |
| + } |
| +} |
diff --git a/internal/equipo/preview_pass_store.go b/internal/equipo/preview_pass_store.go| new file mode 100644 |
| index 00000000..0286de4f |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_store.go |
| @@ -0,0 +1,164 @@ |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "encoding/base64" |
| + "encoding/hex" |
| + "encoding/json" |
| + "net/url" |
| + "strings" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/oficinaid" |
| + "amadan.net/oficina/equipo/internal/equipo/personapi" |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "golang.org/x/net/idna" |
| + "gorm.io/gorm" |
| +) |
| + |
| +type previewBinding struct { |
| + 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"` |
| + ID string |
| + Binding previewBinding `gorm:"embedded"` |
| + ExpiresAt time.Time `gorm:"index:preview_pass_expiry"` |
| + GrantExpiresAt time.Time |
| + ConsumedAt *time.Time |
| +} |
| + |
| +func (previewPassRecord) TableName() string { return "preview_passes" } |
| + |
| +type previewGrantRecord struct { |
| + Hash string `gorm:"primaryKey"` |
| + ID string |
| + Binding previewBinding `gorm:"embedded"` |
| + ExpiresAt time.Time `gorm:"index:preview_grant_expiry"` |
| +} |
| + |
| +func (previewGrantRecord) TableName() string { return "preview_grants" } |
| + |
| +func previewHash(secret string) string { |
| + raw, err := base64.RawURLEncoding.Strict().DecodeString(secret) |
| + if err != nil || len(raw) != 32 || base64.RawURLEncoding.EncodeToString(raw) != secret { |
| + return "" |
| + } |
| + sum := sha256.Sum256(raw) |
| + return hex.EncodeToString(sum[:]) |
| +} |
| +func (s *Store) previewDevice(tx *gorm.DB, p PersonPrincipal) (personapi.DeviceRecord, error) { |
| + var row personapi.DeviceRecord |
| + if p.CredentialID == "" || p.Address == "" || p.Pending { |
| + return row, ErrPreviewAccess |
| + } |
| + current, err := s.personDevices().VerifyAt(tx, p.CredentialID, "") |
| + if err != nil || current.Address != p.Address || current.SessionEpoch != p.SessionEpoch { |
| + return row, ErrPreviewAccess |
| + } |
| + if err = tx.Where("id = ?", p.CredentialID).First(&row).Error; err != nil { |
| + return row, ErrPreviewAccess |
| + } |
| + if row.NativeSessionHash != "" { |
| + if s.personNativeSession == nil { |
| + return row, ErrPreviewAccess |
| + } |
| + sess, e := s.personNativeSession(tx, row.NativeSessionHash) |
| + if e != nil || sess.Subject != p.Address || string(sess.Method) != oficinaid.NativeMethod || sess.At.Unix() != p.SessionEpoch || !s.runnerClock.Now().Before(sess.At.Add(oficinaid.NativeLifetime)) { |
| + return row, ErrPreviewAccess |
| + } |
| + } |
| + return row, nil |
| +} |
| +func (s *Store) previewTask(tx *gorm.DB, b previewBinding) (wire.Task, error) { |
| + p := PersonPrincipal{Address: b.Person, CredentialID: b.Credential, SessionEpoch: b.Epoch} |
| + device, err := s.previewDevice(tx, p) |
| + if err != nil || device.InstanceID != b.Instance { |
| + return wire.Task{}, ErrPreviewAccess |
| + } |
| + task, err := s.Chat().TaskAt(personapi.WithVerifiedPrincipal(tx.Statement.Context, p), tx, b.TaskID) |
| + if err != nil { |
| + return wire.Task{}, ErrPreviewAccess |
| + } |
| + return task, nil |
| +} |
| +func selectedPreview(task wire.Task) (wire.Step, bool) { |
| + for i := len(task.Steps) - 1; i >= 0; i-- { |
| + if task.Steps[i].Specialist == wire.SpecialistPreview { |
| + return task.Steps[i], true |
| + } |
| + } |
| + return wire.Step{}, false |
| +} |
| +func (s *Store) previewDeployment(task wire.Task) (wire.Step, string, error) { |
| + step, ok := selectedPreview(task) |
| + if !ok || step.Preview == nil || step.Preview.Outcome != wire.PreviewDeployed || step.Preview.URL == "" { |
| + return step, "", ErrPreviewAccess |
| + } |
| + p := step.Preview |
| + u, e := url.Parse(p.URL) |
| + own, ownErr := url.Parse(s.personOrigin) |
| + if e != nil || ownErr != nil || canonicalPreviewHost(u.Hostname()) == "" || canonicalPreviewHost(u.Hostname()) == canonicalPreviewHost(own.Hostname()) { |
| + return step, "", ErrPreviewAccess |
| + } |
| + if _, _, err := previewWrapper(p.URL, p.Unsafe); err != nil { |
| + return step, "", ErrPreviewAccess |
| + } |
| + raw, _ := json.Marshal(p) |
| + sum := sha256.Sum256(raw) |
| + return step, hex.EncodeToString(sum[:]), nil |
| +} |
| +func (s *Store) validatePreview(task wire.Task, b previewBinding) error { |
| + step, fingerprint, err := s.previewDeployment(task) |
| + if task.CandidateSHA != b.Candidate || err != nil || step.CandidateSHA != b.Candidate || step.ID != b.StepID || step.Attempt != b.Attempt || fingerprint != b.Fingerprint { |
| + return ErrPreviewChanged |
| + } |
| + if (step.Preview.ExpiresAt != nil && !s.runnerClock.Now().Before(*step.Preview.ExpiresAt)) || (strings.HasPrefix(step.Preview.App, "eq-") && wire.FinalStage(task.Stage)) { |
| + return ErrPreviewExpired |
| + } |
| + return nil |
| +} |
| +func (s *Store) previewRate(tx *gorm.DB, kind, ip, device string) (bool, error) { |
| + limit := 10 |
| + if kind == "read" { |
| + limit = 120 |
| + } |
| + ok, e := runnerRateAt(tx, "preview:"+kind+":ip:"+runnerHash(s.personKey, ip), s.runnerClock.Now(), time.Minute, limit*3) |
| + if e != nil || !ok { |
| + return ok, e |
| + } |
| + if device != "" { |
| + return runnerRateAt(tx, "preview:"+kind+":device:"+device, s.runnerClock.Now(), time.Minute, limit) |
| + } |
| + return true, nil |
| +} |
| +func (s *Store) prunePreviews(tx *gorm.DB) error { |
| + // Indexed expiry predicates; no secret lookup ever scans these tables. |
| + 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 |
| +} |
| +func minPreviewTime(a, b time.Time) time.Time { |
| + if b.Before(a) { |
| + return b |
| + } |
| + return a |
| +} |
| +func previewPrincipal(ctx context.Context, p PersonPrincipal) bool { |
| + actual, ok := personapi.PrincipalFrom(ctx) |
| + return ok && actual.Address == p.Address && actual.CredentialID == p.CredentialID && actual.SessionEpoch == p.SessionEpoch |
| +} |
| + |
| +func canonicalPreviewHost(host string) string { |
| + ascii, err := idna.Lookup.ToASCII(strings.TrimSuffix(host, ".")) |
| + if err != nil { |
| + return "" |
| + } |
| + return strings.ToLower(ascii) |
| +} |
diff --git a/internal/equipo/preview_pass_test.go b/internal/equipo/preview_pass_test.go| new file mode 100644 |
| index 00000000..647dff09 |
| --- /dev/null |
| +++ b/internal/equipo/preview_pass_test.go |
| @@ -0,0 +1,168 @@ |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + "encoding/base64" |
| + "encoding/json" |
| + "errors" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/oficinaid" |
| + "amadan.net/oficina/equipo/internal/equipo/personapi" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "amadan.net/rastrillo/rastrillo/sessions" |
| + "gorm.io/gorm" |
| +) |
| + |
| +const passCandidate = "1111111111111111111111111111111111111111" |
| + |
| +type previewPassRig struct { |
| + s *Store |
| + clock *team.FakeClock |
| + principal PersonPrincipal |
| + credential PersonCredential |
| + ctx context.Context |
| +} |
| + |
| +func newPreviewPassRig(t *testing.T) *previewPassRig { |
| + return newPreviewPassRigAt(t, time.Date(2026, 11, 26, 12, 0, 0, 0, time.UTC)) |
| +} |
| +func newPreviewPassRigAt(t *testing.T, now time.Time) *previewPassRig { |
| + t.Helper() |
| + s, cfg, _ := agentFixture(t) |
| + clock := team.NewFakeClock(now) |
| + s.runnerClock = clock |
| + s.personOrigin = cfg.Origin |
| + s.personKey = cfg.InstanceKey |
| + if _, err := s.db.Writer().Exec("UPDATE members SET session_epoch=?", now.Add(-time.Hour).Unix()); err != nil { |
| + t.Fatal(err) |
| + } |
| + s.personNativeSession = func(*gorm.DB, string) (sessions.Session, error) { |
| + return sessions.Session{Subject: cfg.Owners[0], At: now, Method: oficinaid.NativeMethod}, nil |
| + } |
| + p := PersonPrincipal{Address: cfg.Owners[0], SessionEpoch: now.Unix(), SessionHash: "native-test-session"} |
| + cred, err := s.personDevices().RegisterNative(personapi.WithVerifiedPrincipal(context.Background(), p), Actor{Address: p.Address}, base64.RawURLEncoding.EncodeToString(make([]byte, 32)), "Phone") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + p.CredentialID = cred.ID |
| + p.SessionHash = "" |
| + ctx := personapi.WithVerifiedPrincipal(context.Background(), p) |
| + exec := func(q string, args ...any) { |
| + t.Helper() |
| + if _, e := s.db.Writer().Exec(q, args...); e != nil { |
| + t.Fatal(e) |
| + } |
| + } |
| + exec("INSERT INTO chat_projects(id,repo,state,title) VALUES('p_preview','oficina/equipo','active','Equipo')") |
| + exec("INSERT INTO chat_tasks(id,project_id,title,stage,creator,revision) VALUES('tk_preview','p_preview','Preview','in_review',?,1)", p.Address) |
| + exec("INSERT INTO chat_steps(id,task_id,idx,specialist,state,attempt,candidate_sha,pushed,terminated,revision) VALUES('eng_preview','tk_preview',0,'engineering','done',1,?,1,1,1)", passCandidate) |
| + expiry := now.Add(time.Hour) |
| + result, _ := json.Marshal(wire.PreviewResult{Phase: wire.PreviewDone, Outcome: wire.PreviewDeployed, URL: "https://eq-preview.example.test/", App: "eq-preview", Digest: strings.Repeat("a", 64), ExpiresAt: &expiry}) |
| + exec("INSERT INTO chat_steps(id,task_id,idx,specialist,state,attempt,candidate_sha,preview,revision) VALUES('preview_step','tk_preview',1,'preview','done',1,?,?,1)", passCandidate, string(result)) |
| + return &previewPassRig{s, clock, p, cred, ctx} |
| +} |
| +func (r *previewPassRig) mint(t *testing.T) previewPass { |
| + t.Helper() |
| + p, e := r.s.mintPreviewPass(r.ctx, r.principal, "tk_preview", passCandidate, "192.0.2.1") |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + return p |
| +} |
| +func TestPreviewPassSingleUseAndLifetime(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + raw, e := base64.RawURLEncoding.DecodeString(p.Pass) |
| + if e != nil || len(raw) != 32 { |
| + t.Fatal("pass is not 32 random bytes") |
| + } |
| + if !p.ExpiresAt.Equal(r.clock.Now().Add(time.Minute)) || !p.GrantExpiresAt.Equal(r.clock.Now().Add(15*time.Minute)) { |
| + t.Fatal("wrong lifetimes", p.ExpiresAt, p.GrantExpiresAt) |
| + } |
| + var wg sync.WaitGroup |
| + results := make(chan error, 2) |
| + grants := make(chan previewGrant, 2) |
| + for range 2 { |
| + wg.Go(func() { |
| + g, e := r.s.exchangePreviewPass(r.ctx, p.Pass, "tk_preview", passCandidate, "192.0.2.1") |
| + results <- e |
| + grants <- g |
| + }) |
| + } |
| + wg.Wait() |
| + close(results) |
| + close(grants) |
| + wins := 0 |
| + for e := range results { |
| + if e == nil { |
| + wins++ |
| + } else if !errors.Is(e, ErrPreviewAccess) { |
| + t.Fatal(e) |
| + } |
| + } |
| + if wins != 1 { |
| + t.Fatal("exchange winners", wins) |
| + } |
| + for g := range grants { |
| + if g.Secret == "" { |
| + continue |
| + } |
| + if g.Secret == p.Pass { |
| + t.Fatal("grant reused pass") |
| + } |
| + if _, e := r.s.readPreviewGrant(r.ctx, g.Secret, "tk_preview", "192.0.2.1"); e != nil { |
| + t.Fatal(e) |
| + } |
| + r.clock.Advance(15 * time.Minute) |
| + if _, e := r.s.readPreviewGrant(r.ctx, g.Secret, "tk_preview", "192.0.2.1"); !errors.Is(e, ErrPreviewExpired) { |
| + t.Fatal("expiry", e) |
| + } |
| + } |
| +} |
| +func TestPreviewPassRefusals(t *testing.T) { |
| + for _, kind := range []string{"unknown", "task", "candidate", "expired", "revoked", "member", "session", "redeployed", "moved"} { |
| + t.Run(kind, func(t *testing.T) { |
| + r := newPreviewPassRig(t) |
| + p := r.mint(t) |
| + token, task, candidate := p.Pass, "tk_preview", passCandidate |
| + want := ErrPreviewAccess |
| + 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 "unknown": |
| + token = base64.RawURLEncoding.EncodeToString(make([]byte, 32)) |
| + case "task": |
| + task = "tk_other" |
| + case "candidate": |
| + candidate = strings.Repeat("2", 40) |
| + case "expired": |
| + r.clock.Advance(time.Minute) |
| + want = ErrPreviewExpired |
| + case "revoked": |
| + exec("UPDATE person_devices SET revoked_at=? WHERE id=?", r.clock.Now(), r.credential.ID) |
| + case "member": |
| + exec("UPDATE members SET active=0") |
| + case "session": |
| + r.s.personNativeSession = func(*gorm.DB, string) (sessions.Session, error) { return sessions.Session{}, errors.New("revoked") } |
| + case "redeployed": |
| + exec("UPDATE chat_steps SET attempt=2 WHERE id='preview_step'") |
| + want = ErrPreviewChanged |
| + case "moved": |
| + exec("UPDATE chat_steps SET candidate_sha=? WHERE id='eng_preview'", strings.Repeat("2", 40)) |
| + want = ErrPreviewChanged |
| + } |
| + if _, e := r.s.exchangePreviewPass(r.ctx, token, task, candidate, "192.0.2.1"); !errors.Is(e, want) { |
| + t.Fatalf("got %v, want %v", e, want) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/equipo/preview_wrapper.go b/internal/equipo/preview_wrapper.go| index 68dbf881..a4c42989 100644 |
| --- a/internal/equipo/preview_wrapper.go |
| +++ b/internal/equipo/preview_wrapper.go |
| @@ -9,7 +9,6 @@ import ( |
| "net/url" |
| "strconv" |
| "strings" |
| - "time" |
| "amadan.net/oficina/equipo/internal/wire" |
| "github.com/go-chi/chi/v5" |
| @@ -51,11 +50,9 @@ func (a *application) previewPage(w http.ResponseWriter, r *http.Request) { |
| continue |
| } |
| if p != nil && p.Outcome == wire.PreviewDeployed && p.URL != "" { |
| - if u, err := url.Parse(p.URL); err == nil && strings.EqualFold(u.Host, r.Host) { |
| - a.failure(w, r, ErrForbidden) |
| - return |
| - } |
| - if (p.ExpiresAt != nil && !time.Now().Before(*p.ExpiresAt)) || (strings.HasPrefix(p.App, "eq-") && wire.FinalStage(task.Stage)) || step.CandidateSHA != task.CandidateSHA { |
| + selected, fingerprint, err := a.store.previewDeployment(task) |
| + binding := previewBinding{Candidate: task.CandidateSHA, StepID: selected.ID, Attempt: selected.Attempt, Fingerprint: fingerprint} |
| + if err != nil || a.store.validatePreview(task, binding) != nil { |
| http.NotFound(w, r) |
| return |
| } |
diff --git a/internal/plan3test/person_api_contract_test.go b/internal/plan3test/person_api_contract_test.go| index 1b8ac088..ec839338 100644 |
| --- a/internal/plan3test/person_api_contract_test.go |
| +++ b/internal/plan3test/person_api_contract_test.go |
| @@ -84,6 +84,10 @@ func personAPIContractCoverage(t *testing.T) { |
| } |
| } |
| must(t, chi.Walk(f.Store.PersonAPIHandler().(chi.Routes), func(method, path string, _ http.Handler, _ ...func(http.Handler) http.Handler) error { |
| + // The app-owned preview capability has a separate contract test. |
| + if method == "POST" && path == "/tasks/{id}/preview-pass" { |
| + return nil |
| + } |
| if thin[method+" "+path] { |
| return nil |
| } |
diff --git a/internal/plan3test/person_api_device_contract_test.go b/internal/plan3test/person_api_device_contract_test.go| index 18751758..b8bdfc83 100644 |
| --- a/internal/plan3test/person_api_device_contract_test.go |
| +++ b/internal/plan3test/person_api_device_contract_test.go |
| @@ -95,7 +95,7 @@ func TestPersonAPIDeviceContract(t *testing.T) { |
| for _, methods := range paths { |
| documented += len(methods.(map[string]any)) |
| } |
| - all := map[string]bool{"POST /native/oficina-id": true} |
| + all := map[string]bool{"POST /native/oficina-id": true, "POST /tasks/{id}/preview-pass": true} |
| for key := range engine { |
| all[key] = true |
| } |
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go| index 7707fb82..e8eaf021 100644 |
| --- a/internal/plan3test/plan3_release_test.go |
| +++ b/internal/plan3test/plan3_release_test.go |
| @@ -208,6 +208,8 @@ func plan3CopyInventory(t *testing.T) { |
| acceptedGitHubEgress := key == "CopyGitHubEgress" && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-23)") |
| acceptedForgeSeam := key == "work.reason.proposal_failed" && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-23)") |
| // Luna's reviews of the paused-work strings and API prose (2026-11-24). |
| + // Luna's two native preview API error verdicts, controller 2026-11-26. |
| + acceptedPreview := slices.Contains([]string{"api.preview_changed", "api.preview_expired"}, key) && strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26)" |
| acceptedPaused := slices.Contains(pausedCopyKeys, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24)") |
| // Luna's review of the new team's grant card line (hub #48). |
| acceptedNewTeamCard := key == "chat.card.access_first" && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24)") |
| @@ -215,7 +217,7 @@ func plan3CopyInventory(t *testing.T) { |
| acceptedProjects := slices.Contains([]string{"projects.amadan", "projects.yours", "projects.can_add", "projects.add_reachable", "projects.names", "projects.names_hint", "projects.details", "projects.title", "projects.description", "projects.save", "projects.context", "projects.found", "projects.selected", "projects.owner_add", "projects.selection_lost", "projects.other", "projects.name_question", "projects.personal_names", "projects.forget_name", "docs/api/equipo-v1.md / Projects and starting a request"}, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-22)") |
| acceptedAgentAccess := slices.Contains([]string{"copyAgentConfig", "copyAgentForbidden", "copyAgentNotFound", "copyAgentUnavailable", "copyAgentTooLarge", "copyAgentInvalid", "copyAgentMedia", "copyAgentUnauthenticated", "agent.equipo_projects_list", "agent.equipo_tasks_list", "agent.equipo_task_get", "agent.equipo_needs_you", "docs/api/equipo-v1.md / Delegated read-only operations"}, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-20)") |
| acceptedCopy := strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED BY DELEGATION (Copy, record-bound) sha256:"+copydesk.Hash(rows[key]) |
| - if !approvedNoAccess && !approvedMergeCredential && !approvedStuckTasks && !acceptedPaused && !acceptedNewTeamCard && !acceptedGitHubEgress && !acceptedForgeSeam && !acceptedAPIErrors && !acceptedNativeProjects && !acceptedInjection && !acceptedMail && !acceptedPush && !acceptedAgentAccess && !acceptedProjects && !acceptedCardNames && !acceptedAccess && !acceptedPlacementEdges && !acceptedPlacement && !acceptedReportActions && !acceptedRoster && !acceptedCopy && !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedAll && !acceptedGuide && !acceptedRound2 && !acceptedStarter && !acceptedDelegation && !approvedPublish && !approvedAssistant && !approvedJobs && !approvedOficina && !approvedFailedReplies && !approvedStopReasons { |
| + if !acceptedPreview && !approvedNoAccess && !approvedMergeCredential && !approvedStuckTasks && !acceptedPaused && !acceptedNewTeamCard && !acceptedGitHubEgress && !acceptedForgeSeam && !acceptedAPIErrors && !acceptedNativeProjects && !acceptedInjection && !acceptedMail && !acceptedPush && !acceptedAgentAccess && !acceptedProjects && !acceptedCardNames && !acceptedAccess && !acceptedPlacementEdges && !acceptedPlacement && !acceptedReportActions && !acceptedRoster && !acceptedCopy && !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedAll && !acceptedGuide && !acceptedRound2 && !acceptedStarter && !acceptedDelegation && !approvedPublish && !approvedAssistant && !approvedJobs && !approvedOficina && !approvedFailedReplies && !approvedStopReasons { |
| t.Fatal("entry has no copy review status or applicable acceptance", key) |
| } |
| } |
diff --git a/internal/plan3test/preview_pass_contract_test.go b/internal/plan3test/preview_pass_contract_test.go| new file mode 100644 |
| index 00000000..910dc39a |
| --- /dev/null |
| +++ b/internal/plan3test/preview_pass_contract_test.go |
| @@ -0,0 +1,54 @@ |
| +package plan3test |
| + |
| +import ( |
| + "encoding/json" |
| + "net/http" |
| + "os" |
| + "testing" |
| + |
| + "github.com/go-chi/chi/v5" |
| +) |
| + |
| +func TestPreviewPassContract(t *testing.T) { |
| + f := newFixture(t) |
| + found := false |
| + must(t, chi.Walk(f.Store.PersonAPIHandler().(chi.Routes), func(method, path string, _ http.Handler, _ ...func(http.Handler) http.Handler) error { |
| + if method == "POST" && path == "/tasks/{id}/preview-pass" { |
| + found = true |
| + } |
| + return nil |
| + })) |
| + if !found { |
| + t.Fatal("preview pass route missing") |
| + } |
| + raw, err := os.ReadFile("../../docs/api/equipo-v1.openapi.json") |
| + must(t, err) |
| + var doc map[string]any |
| + must(t, json.Unmarshal(raw, &doc)) |
| + op := doc["paths"].(map[string]any)["/tasks/{id}/preview-pass"].(map[string]any)["post"].(map[string]any) |
| + if op["operationId"] != "post_tasks_id_preview_pass" { |
| + t.Fatal("wrong operation") |
| + } |
| + security := op["security"].([]any) |
| + if len(security) != 1 || security[0].(map[string]any)["personBearer"] == nil { |
| + t.Fatal("pass must be device-only") |
| + } |
| + request := op["requestBody"].(map[string]any) |
| + if request["x-maxBytes"] != float64(4096) || request["x-rejectUnknownFields"] != true { |
| + t.Fatal("unbounded pass input") |
| + } |
| + if op["responses"].(map[string]any)["201"] == nil { |
| + 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)) != 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 137d5935..47e4b98f 100644 |
| --- a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings |
| @@ -365,6 +365,30 @@ |
| } |
| } |
| }, |
| + "api.preview_changed": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "The change has been updated. Review it again." |
| + } |
| + } |
| + } |
| + }, |
| + "api.preview_expired": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "This preview expired. Open it again." |
| + } |
| + } |
| + } |
| + }, |
| "api.question_ended": { |
| "extractionState": "manual", |
| "localizations": { |
diff --git a/native/apple/Sources/EquipoKit/API/PreviewPass.swift b/native/apple/Sources/EquipoKit/API/PreviewPass.swift| new file mode 100644 |
| index 00000000..2c2d6f85 |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/API/PreviewPass.swift |
| @@ -0,0 +1,60 @@ |
| +import Foundation |
| + |
| +struct PreviewPass: Codable, Sendable { |
| + let pass: String |
| + let expiresIn: Int |
| + let grantExpiresIn: Int |
| + let expiresAt: Date |
| + let grantExpiresAt: Date |
| +} |
| +extension EquipoClient { |
| + func previewPass(task: String, candidate: String) async throws -> PreviewPass { |
| + try await post("/tasks/\(escape(task))/preview-pass", try .json(["candidate_sha": candidate])) |
| + } |
| +} |
| + |
| +struct PreviewDestination: Equatable, Sendable { |
| + let origin: URL |
| + let taskID: String |
| + let candidate: String |
| + let wrapper: URL |
| + let exchangeURL: URL |
| + init?(origin: URL, taskID: String, candidate: String) { |
| + guard origin.scheme == "https", origin.host != nil, origin.user == nil, origin.password == nil, |
| + taskID.range(of: #"^[A-Za-z0-9_-]{1,128}\z"#, options: .regularExpression) != nil, |
| + candidate.range(of: #"^[0-9a-f]{40}\z"#, options: .regularExpression) != nil, |
| + var parts = URLComponents(url: origin, resolvingAgainstBaseURL: false) else { return nil } |
| + parts.path = ""; parts.query = nil; parts.fragment = nil |
| + guard let base = parts.url else { return nil } |
| + self.origin = base; self.taskID = taskID; self.candidate = candidate |
| + parts.path = "/tasks/\(taskID)/preview" |
| + guard let wrapper = parts.url else { return nil }; self.wrapper = wrapper |
| + parts.path = "/native/preview/exchange" |
| + guard let exchange = parts.url else { return nil }; self.exchangeURL = exchange |
| + } |
| + func exchange(pass: String) -> URLRequest { |
| + var request = URLRequest(url: exchangeURL) |
| + request.httpMethod = "POST" |
| + request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") |
| + request.setValue(origin.absoluteString, forHTTPHeaderField: "Origin") |
| + // Every value uses a validated ASCII alphabet, never arbitrary URL text. |
| + request.httpBody = Data("pass=\(pass)&task=\(taskID)&candidate=\(candidate)".utf8) |
| + request.cachePolicy = .reloadIgnoringLocalCacheData |
| + return request |
| + } |
| + private static func cookieHost(_ url: URL) -> String? { |
| + 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 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). |
| + return Self.cookieHost(url) != Self.cookieHost(origin) |
| + } |
| + if initial && request.httpMethod == "POST" && url == exchangeURL { return true } |
| + return request.httpMethod == "GET" && url == wrapper |
| + } |
| +} |
diff --git a/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift b/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift| index 46cdf2e4..3c5777c0 100644 |
| --- a/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift |
| +++ b/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift |
| @@ -44,7 +44,11 @@ import Observation |
| return TaskActionRules(task: task, viewer: session.me?.address ?? "", owner: session.me?.role == "owner", cards: session.cards) |
| } |
| @discardableResult func load() async -> (any Error)? { |
| - do { loaded = try await session.client.task(taskID); readFailure = nil; return nil } |
| + do { |
| + loaded = try await session.client.task(taskID); readFailure = nil |
| + if let loaded { session.previews.observe([loaded]) } |
| + return nil |
| + } |
| catch { readFailure = StoppedWorkActions.logFailure(error); return error } |
| } |
| func beginMove() async { |
diff --git a/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift b/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift| new file mode 100644 |
| index 00000000..b017ad6e |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/Preview/PreviewBrowser.swift |
| @@ -0,0 +1,88 @@ |
| +import SwiftUI |
| +import WebKit |
| + |
| +@MainActor final class PreviewBrowser: NSObject, PreviewBrowserResource, WKNavigationDelegate, WKUIDelegate { |
| + private(set) var webView: WKWebView? |
| + private(set) var dataStore: WKWebsiteDataStore? |
| + private let destination: PreviewDestination |
| + private var initial = true |
| + init(destination: PreviewDestination, request: URLRequest) { |
| + self.destination = destination |
| + super.init() |
| + let configuration = WKWebViewConfiguration() |
| + let store = WKWebsiteDataStore.nonPersistent() |
| + configuration.websiteDataStore = store |
| + configuration.preferences.javaScriptCanOpenWindowsAutomatically = false |
| + 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) |
| + } |
| + func close() { |
| + webView?.stopLoading(); webView?.navigationDelegate = nil; webView?.uiDelegate = nil |
| + webView?.removeFromSuperview(); webView = nil |
| + dataStore?.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), modifiedSince: .distantPast) {} |
| + dataStore = nil |
| + } |
| + func reload() { webView?.load(URLRequest(url: destination.wrapper)) } |
| + func webView(_ webView: WKWebView, decidePolicyFor action: WKNavigationAction, decisionHandler: @escaping @MainActor (WKNavigationActionPolicy) -> Void) { |
| + guard let frame = action.targetFrame, !action.shouldPerformDownload else { decisionHandler(.cancel); return } |
| + let allowed = destination.allows(action.request, mainFrame: frame.isMainFrame, initial: initial) |
| + if frame.isMainFrame { initial = false } |
| + decisionHandler(allowed ? .allow : .cancel) |
| + } |
| + func webView(_ webView: WKWebView, decidePolicyFor response: WKNavigationResponse, decisionHandler: @escaping @MainActor (WKNavigationResponsePolicy) -> Void) { |
| + guard response.canShowMIMEType, let url = response.response.url else { decisionHandler(.cancel); return } |
| + // Initial exchange errors are HTML at the exchange URL. Its successful |
| + // response redirects to the exact wrapper; no other top document loads. |
| + let allowed = !response.isForMainFrame || url == destination.wrapper || url == destination.exchangeURL |
| + decisionHandler(allowed ? .allow : .cancel) |
| + } |
| + func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for action: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { nil } |
| +} |
| + |
| +struct PreviewSheetPresenter: ViewModifier { |
| + let session: EquipoSession |
| + func body(content: Content) -> some View { |
| + content.sheet(isPresented: Binding(get: { session.previews.page != nil }, set: { if !$0 { session.previews.dismiss() } })) { |
| + if let page = session.previews.page, let browser = page.resource as? PreviewBrowser, let web = browser.webView { |
| + PreviewSheetContent(web: web, dismiss: session.previews.dismiss) |
| + #if os(macOS) |
| + .frame(minWidth: 640, minHeight: 520) |
| + #endif |
| + .onDisappear { session.previews.dismiss() } |
| + } |
| + } |
| + } |
| +} |
| +struct PreviewSheetContent: View { |
| + let web: WKWebView |
| + let dismiss: () -> Void |
| + var body: some View { |
| + VStack(spacing: 0) { |
| + HStack { |
| + Text(EquipoStrings.text("work.specialist.preview")).font(.headline) |
| + Spacer() |
| + Button(EquipoStrings.text("team.close"), action: dismiss).frame(minHeight: 44) |
| + }.padding(.horizontal) |
| + Divider() |
| + PreviewWebView(web: web) |
| + }.background(Palette.background) |
| + } |
| +} |
| + |
| +#if os(iOS) |
| +private struct PreviewWebView: UIViewRepresentable { |
| + let web: WKWebView |
| + func makeUIView(context: Context) -> WKWebView { web } |
| + func updateUIView(_ view: WKWebView, context: Context) {} |
| +} |
| +#else |
| +private struct PreviewWebView: NSViewRepresentable { |
| + let web: WKWebView |
| + func makeNSView(context: Context) -> WKWebView { web } |
| + func updateNSView(_ view: WKWebView, context: Context) {} |
| +} |
| +#endif |
diff --git a/native/apple/Sources/EquipoKit/Preview/PreviewFixture.swift b/native/apple/Sources/EquipoKit/Preview/PreviewFixture.swift| new file mode 100644 |
| index 00000000..42ddf49f |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/Preview/PreviewFixture.swift |
| @@ -0,0 +1,49 @@ |
| +#if DEBUG |
| +import SwiftUI |
| +#if os(macOS) |
| +import AppKit |
| +#endif |
| + |
| +/// Production task screen and private WebKit sheet against the manual Go |
| +/// screenshot fixture. The private config contains only a disposable test bearer. |
| +public struct PreviewFixture: View { |
| + @State private var session: EquipoSession? |
| + public init() {} |
| + public var body: some View { |
| + Group { |
| + if let session { |
| + NavigationStack { TaskScreen(session: session, taskID: "tk_preview") } |
| + } else { ProgressView() } |
| + } |
| + .preferredColorScheme(.light) |
| + .task { |
| + guard let path = ProcessInfo.processInfo.environment["EQUIPO_PREVIEW_FIXTURE"], |
| + let data = try? Data(contentsOf: URL(fileURLWithPath: path)), |
| + let config = try? JSONDecoder().decode([String: String].self, from: data), |
| + let origin = config["origin"].flatMap(URL.init(string:)), let token = config["token"] else { return } |
| + var account = DeviceAccount.new(origin: origin, label: "Preview fixture") |
| + account.credential = DeviceCredential(id: "fixture", token: token, audience: "equipo.person.v1", instanceId: "fixture", expiresAt: .distantFuture) |
| + let session = EquipoSession(account: account, accounts: DeviceAccounts(store: MemorySecretStore())) |
| + self.session = session |
| + await session.refresh() |
| + if let task = try? await session.client.task("tk_preview") { |
| + await session.previews.open(client: session.client, task: task) |
| + #if os(macOS) |
| + if let capture = ProcessInfo.processInfo.environment["EQUIPO_FIXTURE_CAPTURE"] { |
| + try? await Task.sleep(for: .seconds(5)) |
| + if let window = NSApp.windows.first(where: { $0.isSheet }), let view = window.contentView { |
| + view.layoutSubtreeIfNeeded(); window.displayIfNeeded() |
| + if let bitmap = view.bitmapImageRepForCachingDisplay(in: view.bounds) { |
| + view.cacheDisplay(in: view.bounds, to: bitmap) |
| + if let data = bitmap.representation(using: .png, properties: [:]) { |
| + _ = FileManager.default.createFile(atPath: capture, contents: data) |
| + } |
| + } |
| + } |
| + } |
| + #endif |
| + } |
| + } |
| + } |
| +} |
| +#endif |
diff --git a/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift b/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift| new file mode 100644 |
| index 00000000..d776dd6a |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/Preview/PreviewPresentation.swift |
| @@ -0,0 +1,114 @@ |
| +import Foundation |
| +import Observation |
| + |
| +@MainActor protocol PreviewBrowserResource: AnyObject { |
| + func close() |
| + func reload() |
| +} |
| + |
| +/// One task-bound browser, owned by the signed-in session. Every terminal |
| +/// transition releases the web view and its private data store together. |
| +@MainActor @Observable final class PreviewPresentation { |
| + struct Binding: Equatable { |
| + let taskID: String |
| + let candidate: String |
| + let step: String |
| + let attempt: Int64? |
| + let deployment: ThinPreviewResult |
| + init?(_ task: ThinTask) { |
| + guard let step = task.steps?.last(where: { $0.specialist == "preview" }), |
| + step.candidateSha == task.candidateSha, let preview = step.preview, |
| + preview.outcome == "deployed", preview.url != nil else { return nil } |
| + taskID = task.id; candidate = task.candidateSha; self.step = step.id |
| + attempt = step.attempt; deployment = preview |
| + } |
| + } |
| + struct Page: Identifiable { |
| + let id = UUID() |
| + let binding: Binding |
| + let expiry: Date |
| + let resource: any PreviewBrowserResource |
| + } |
| + private(set) var page: Page? |
| + private(set) var busy = false |
| + private(set) var failure: String? |
| + private(set) var taskID: String? |
| + private var generation = UUID() |
| + private var valid = true |
| + private var timer: Task<Void, Never>? |
| + private let makeBrowser: @MainActor (PreviewDestination, URLRequest) -> any PreviewBrowserResource |
| + private let elapsedSince: @MainActor (ContinuousClock.Instant) -> TimeInterval |
| + init(elapsedSince: @escaping @MainActor (ContinuousClock.Instant) -> TimeInterval = { started in |
| + let elapsed = started.duration(to: .now).components |
| + return Double(elapsed.seconds) + Double(elapsed.attoseconds) / 1e18 |
| + }, makeBrowser: @escaping @MainActor (PreviewDestination, URLRequest) -> any PreviewBrowserResource = { PreviewBrowser(destination: $0, request: $1) }) { |
| + self.makeBrowser = makeBrowser; self.elapsedSince = elapsedSince |
| + } |
| + func open(client: EquipoClient, task: ThinTask, now: Date = Date()) async { |
| + guard valid, !busy else { return } |
| + dismiss(); taskID = task.id; failure = nil |
| + guard let binding = Binding(task), let destination = PreviewDestination(origin: client.origin, taskID: task.id, candidate: task.candidateSha) else { |
| + failure = EquipoStrings.text("read.failed_title"); return |
| + } |
| + busy = true |
| + let operation = generation |
| + let started = ContinuousClock.now |
| + do { |
| + let pass = try await client.previewPass(task: task.id, candidate: task.candidateSha) |
| + guard valid, generation == operation else { return } |
| + 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, |
| + (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 |
| + } |
| + let interval = Double(pass.grantExpiresIn) - elapsed |
| + page = Page(binding: binding, expiry: received.addingTimeInterval(interval), resource: makeBrowser(destination, destination.exchange(pass: pass.pass))) |
| + busy = false |
| + timer = Task { [weak self] in |
| + do { try await Task.sleep(for: .seconds(interval)) } catch { return } |
| + guard let self, self.generation == operation else { return } |
| + self.expire() |
| + } |
| + } catch { |
| + guard valid, generation == operation else { return } |
| + busy = false |
| + if let error = error as? EquipoAPIError, error.code == "preview_changed" { |
| + failure = EquipoStrings.text("api.preview_changed") |
| + } else if let error = error as? EquipoAPIError, error.code == "preview_expired" { |
| + failure = EquipoStrings.text("api.preview_expired") |
| + } else { failure = StoppedWorkActions.logFailure(error) } |
| + } |
| + } |
| + func dismiss() { |
| + generation = UUID(); timer?.cancel(); timer = nil |
| + page?.resource.close(); page = nil; busy = false |
| + } |
| + func invalidate() { valid = false; dismiss() } |
| + func background() { checkExpiry() } |
| + func checkExpiry(now: Date = Date()) { |
| + if let page, now >= page.expiry { expire() } |
| + } |
| + private func expire() { dismiss(); failure = EquipoStrings.text("api.preview_expired") } |
| + func observe(_ tasks: [ThinTask]) { |
| + guard let page, let task = tasks.first(where: { $0.id == page.binding.taskID }) else { return } |
| + if Binding(task) != page.binding { |
| + dismiss(); failure = EquipoStrings.text("api.preview_changed") |
| + } |
| + } |
| + func foreground(client: EquipoClient, now: Date = Date()) async { |
| + checkExpiry(now: now) |
| + guard let page else { return } |
| + do { |
| + let task = try await client.task(page.binding.taskID) |
| + guard self.page?.id == page.id else { return } |
| + observe([task]); self.page?.resource.reload() |
| + } catch { |
| + guard self.page?.id == page.id else { return } |
| + dismiss(); failure = StoppedWorkActions.logFailure(error) |
| + } |
| + } |
| +} |
diff --git a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings| index 137d5935..47e4b98f 100644 |
| --- a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings |
| @@ -365,6 +365,30 @@ |
| } |
| } |
| }, |
| + "api.preview_changed": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "The change has been updated. Review it again." |
| + } |
| + } |
| + } |
| + }, |
| + "api.preview_expired": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "This preview expired. Open it again." |
| + } |
| + } |
| + } |
| + }, |
| "api.question_ended": { |
| "extractionState": "manual", |
| "localizations": { |
diff --git a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift| index ccdc6a45..6427c5df 100644 |
| --- a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift |
| +++ b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift |
| @@ -30,6 +30,7 @@ public final class EquipoSession { |
| /// or credential renewal ignores cancellation and completes later. |
| public let lifetime: SignInLifetime |
| let settings = SettingsPresentation() |
| + let previews = PreviewPresentation() |
| public let markdown = MarkdownTranscript() |
| private var questionDrafts: [String: QuestionAnswerDraft] = [:] |
| /// The zone this session told Equipo (paused work): sent once, and again |
| @@ -152,6 +153,7 @@ public final class EquipoSession { |
| guard !isInvalidated else { return } |
| apply(snapshot, projectGeneration: projectGeneration) |
| tasks = taskList.items ?? [] |
| + previews.observe(tasks) |
| needsYou = needsList.items ?? [] |
| status = .ready |
| refreshFailed = false |
| @@ -521,6 +523,7 @@ public final class EquipoSession { |
| /// not prevent a completed network response from reaching persistence. |
| func invalidate() { |
| lifetime.end() |
| + previews.invalidate() |
| attachments.clear() |
| markdown.removeAll() |
| status = .signedOut |
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift b/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift| index 85bcf1c8..ce1cbcaa 100644 |
| --- a/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift |
| +++ b/native/apple/Sources/EquipoKit/UI/Screens/AppModel.swift |
| @@ -192,6 +192,10 @@ public final class EquipoAppModel { |
| public func foreground() { |
| isForeground = true |
| + if let session { |
| + session.previews.checkExpiry() |
| + Task { await session.previews.foreground(client: session.client) } |
| + } |
| NativeConnectivity.shared.foregrounded() |
| let push = self.push |
| Task { await push.sync() } |
| @@ -204,5 +208,5 @@ public final class EquipoAppModel { |
| if isForeground { session?.startLive() } |
| } |
| } |
| - public func background() { isForeground = false; session?.stopLive() } |
| + public func background() { isForeground = false; session?.previews.background(); session?.stopLive() } |
| } |
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift b/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift| index e580547b..108c7441 100644 |
| --- a/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift |
| +++ b/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift |
| @@ -55,7 +55,7 @@ public struct TaskScreen: View { |
| } |
| } |
| webEvidence(task, preview: false) |
| - case .preview: webEvidence(task, preview: true) |
| + case .preview: previewEvidence(task) |
| } |
| }.padding(16).frame(maxWidth: 760).frame(maxWidth: .infinity, alignment: .topLeading) |
| } |
| @@ -81,6 +81,8 @@ public struct TaskScreen: View { |
| .refreshable { await model.session.refresh(); await model.load() } |
| .sheet(item: $model.confirmation) { confirm in TaskConfirmationSheet(model: model, confirmation: confirm) } |
| .sheet(isPresented: $model.moving) { TaskMoveSheet(model: model) } |
| + .modifier(PreviewSheetPresenter(session: model.session)) |
| + .onDisappear { model.session.previews.dismiss() } |
| .onChange(of: model.decision.card?.id) { model.directionNote = "" } |
| } |
| @@ -123,6 +125,19 @@ public struct TaskScreen: View { |
| Text(verbatim: value).font(.system(.caption, design: .monospaced)).textSelection(.enabled) |
| } |
| } |
| + private func previewEvidence(_ task: ThinTask) -> some View { |
| + VStack(alignment: .leading, spacing: 12) { |
| + if model.session.previews.taskID == task.id, let failure = model.session.previews.failure { |
| + Text(failure).foregroundStyle(Palette.negative) |
| + } |
| + if PreviewPresentation.Binding(task) != nil { |
| + Button(EquipoStrings.text("work.specialist.preview")) { |
| + Task { await model.session.previews.open(client: model.session.client, task: task) } |
| + }.buttonStyle(.bordered).disabled(model.session.previews.busy) |
| + if model.session.previews.busy { ProgressView().accessibilityLabel(EquipoStrings.text("work.specialist.preview")) } |
| + } else { webEvidence(task, preview: true) } |
| + } |
| + } |
| private func webEvidence(_ task: ThinTask, preview: Bool) -> some View { |
| Button { |
| if preview { model.session.settings.open(origin: model.session.origin, path: "/tasks/\(task.id)/preview") } |
diff --git a/native/apple/Sources/EquipoMac/EquipoMacApp.swift b/native/apple/Sources/EquipoMac/EquipoMacApp.swift| index 76ff8087..cebc01f4 100644 |
| --- a/native/apple/Sources/EquipoMac/EquipoMacApp.swift |
| +++ b/native/apple/Sources/EquipoMac/EquipoMacApp.swift |
| @@ -19,7 +19,7 @@ import SwiftUI |
| #if DEBUG |
| // Offline fixture captures must run this build, without an updater |
| // replacing it with a published app during the capture. |
| - if ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_ATTACHMENTS_FIXTURE"] != nil { return nil } |
| + if ProcessInfo.processInfo.environment["EQUIPO_PREVIEW_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_ATTACHMENTS_FIXTURE"] != nil { return nil } |
| #endif |
| return NativeUpdater(policy: .quiet) |
| }() |
| @@ -29,7 +29,8 @@ import SwiftUI |
| WindowGroup(EquipoStrings.text("app.name")) { |
| Group { |
| #if DEBUG |
| - if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil { MacNeedsFixture() } |
| + if ProcessInfo.processInfo.environment["EQUIPO_PREVIEW_FIXTURE"] != nil { PreviewFixture() } |
| + else if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil { MacNeedsFixture() } |
| else if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"]?.hasPrefix("conversation-") == true { StoppedConversationFixture() } |
| else if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil { StoppedWorkFixture() } |
| else if ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] != nil { TaskViewFixture() } |
diff --git a/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift b/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift| new file mode 100644 |
| index 00000000..4beae351 |
| --- /dev/null |
| +++ b/native/apple/Tests/EquipoKitTests/PreviewPassTests.swift |
| @@ -0,0 +1,252 @@ |
| +import Foundation |
| +import Testing |
| +@testable import EquipoKit |
| + |
| +@MainActor @Suite struct PreviewPassTests { |
| + static let now = Date(timeIntervalSince1970: 1_795_694_400) |
| + static let sha = String(repeating: "1", count: 40) |
| + static let pass = String(repeating: "A", count: 43) |
| + static func destination() throws -> PreviewDestination { |
| + try #require(PreviewDestination(origin: URL(string: "https://team.example/old?q=1#x")!, taskID: "tk_preview", candidate: sha)) |
| + } |
| + @Test func exactAllowlistAndBodyOnlySecret() throws { |
| + let d = try Self.destination(), request = d.exchange(pass: Self.pass) |
| + #expect(request.url?.absoluteString == "https://team.example/native/preview/exchange") |
| + #expect(request.httpMethod == "POST") |
| + #expect(request.value(forHTTPHeaderField: "Authorization") == nil) |
| + #expect(request.value(forHTTPHeaderField: "Cookie") == nil) |
| + #expect(request.value(forHTTPHeaderField: "Origin") == "https://team.example") |
| + #expect(String(data: try #require(request.httpBody), encoding: .utf8) == "pass=\(Self.pass)&task=tk_preview&candidate=\(Self.sha)") |
| + #expect(d.allows(request, mainFrame: true, initial: true)) |
| + #expect(!d.allows(request, mainFrame: true, initial: false)) |
| + #expect(d.allows(URLRequest(url: d.wrapper), mainFrame: true, initial: false)) |
| + for url in ["https://evil.example/tasks/tk_preview/preview", "https://team.example/tasks/other/preview", "https://team.example/tasks/tk_preview/preview?x=1", "https://team.example/tasks/tk_preview/preview#x", "https://user@team.example/tasks/tk_preview/preview", "https://team.example/native/preview/exchange", "https://team.example/evil", "http://team.example/tasks/tk_preview/preview"] { |
| + #expect(!d.allows(URLRequest(url: URL(string: url)!), mainFrame: true, initial: false)) |
| + } |
| + var post = URLRequest(url: d.wrapper); post.httpMethod = "POST" |
| + #expect(!d.allows(post, mainFrame: true, initial: false)) |
| + #expect(d.allows(URLRequest(url: URL(string: "https://preview.example/")!), mainFrame: false, initial: false)) |
| + #expect(!d.allows(URLRequest(url: d.wrapper), mainFrame: false, initial: false)) |
| + #expect(!d.allows(URLRequest(url: URL(string: "https://team.example.:8443/")!), mainFrame: false, initial: false)) |
| + for candidate in ["", String(repeating: "a", count: 39), String(repeating: "a", count: 41), String(repeating: "G", count: 40)] { |
| + #expect(PreviewDestination(origin: d.origin, taskID: "t", candidate: candidate) == nil) |
| + } |
| + for id in ["../x", "a/b", "a?x", "", String(repeating: "a", count: 129)] { |
| + #expect(PreviewDestination(origin: d.origin, taskID: id, candidate: Self.sha) == nil) |
| + } |
| + #expect(PreviewDestination(origin: URL(string: "http://team.example")!, taskID: "t", candidate: Self.sha) == nil) |
| + } |
| + @Test func lifecycleDisposesOnDismissExpiryInvalidationAndCandidateChange() async throws { |
| + for action in ["dismiss", "expiry", "invalidate", "candidate"] { |
| + let browser = FakePreviewBrowser(), model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in browser }) |
| + let server = ScriptedTransport(), task = try Self.task() |
| + Self.answer(server) |
| + await model.open(client: EquipoClient(transport: server, token: "device-bearer"), task: task, now: Self.now) |
| + #expect(model.page != nil) |
| + let request = try #require(server.sent("POST /tasks/\(task.id)/preview-pass").first) |
| + #expect(request.bearer == "device-bearer") |
| + #expect(try JSONSerialization.jsonObject(with: #require(request.body)) as? [String: String] == ["candidate_sha": Self.sha]) |
| + switch action { |
| + case "dismiss": model.dismiss() |
| + case "expiry": model.background(); model.checkExpiry(now: Self.now.addingTimeInterval(900)) |
| + case "candidate": var changed = task; changed.candidateSha = String(repeating: "2", count: 40); model.observe([changed]) |
| + default: model.invalidate() |
| + } |
| + #expect(model.page == nil) |
| + #expect(browser.closed == 1) |
| + } |
| + } |
| + @Test func expiredOrOverlongResponsesNeverCreateAWebView() async throws { |
| + 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) |
| + task.steps = [old] + task.steps! |
| + #expect(PreviewPresentation.Binding(task)?.step == "preview") |
| + task.steps![1].preview = nil |
| + #expect(PreviewPresentation.Binding(task) == nil) |
| + } |
| + @Test func malformedPassCannotEnterTheFormBody() async throws { |
| + for token in ["", String(repeating: "A", count: 42) + "B", "x&task=other", String(repeating: "A", count: 44)] { |
| + let server = ScriptedTransport(), model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in FakePreviewBrowser() }) |
| + Self.answer(server, passValue: token) |
| + await model.open(client: EquipoClient(transport: server, token: "device"), task: try Self.task(), now: Self.now) |
| + #expect(model.page == nil); #expect(model.failure != nil) |
| + } |
| + } |
| + @Test func staleAndExpiredWordsComeFromReviewedCatalog() async throws { |
| + for (status, code, key) in [(409, "preview_changed", "api.preview_changed"), (410, "preview_expired", "api.preview_expired")] { |
| + let server = ScriptedTransport(), model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in FakePreviewBrowser() }) |
| + let task = try Self.task() |
| + server.on("POST /tasks/\(task.id)/preview-pass", .success(APIResponse(status: status, data: Data("{\"code\":\"\(code)\",\"copy_key\":\"\(key)\",\"request_id\":\"r\"}".utf8)))) |
| + await model.open(client: EquipoClient(transport: server, token: "t"), task: task, now: Self.now) |
| + #expect(model.page == nil); #expect(model.failure == EquipoStrings.text(String.LocalizationValue(key))) |
| + } |
| + } |
| + static func task() throws -> ThinTask { |
| + var task: ThinTask = try Fixture.decode("thin/task") |
| + task.id = "tk_preview"; task.candidateSha = sha |
| + var step = task.steps![0] |
| + step.id = "preview"; step.specialist = "preview"; step.state = "done" |
| + step.candidateSha = sha; step.attempt = 1 |
| + step.preview = ThinPreviewResult(url: "https://preview.example/", digest: "d", expiresAt: now.addingTimeInterval(3600), outcome: "deployed") |
| + task.steps = [step] |
| + return task |
| + } |
| + |
| + static func answer(_ server: ScriptedTransport, passLife: Double = 60, grantLife: Double = 900, passValue: String = PreviewPassTests.pass) { |
| + 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 { |
| + var closed = 0 |
| + func close() { closed += 1 } |
| + func reload() {} |
| +} |
| + |
| +@MainActor @Suite struct PreviewLifecycleTests { |
| + @Test func actualBrowserUsesAndDropsPrivateStore() throws { |
| + let destination = try PreviewPassTests.destination() |
| + let browser = PreviewBrowser(destination: destination, request: destination.exchange(pass: PreviewPassTests.pass)) |
| + let view = try #require(browser.webView), store = try #require(browser.dataStore) |
| + #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) |
| + } |
| + @Test func signOutAndAccountSwitchDisposeTheOwnedBrowser() async throws { |
| + for switching in [false, true] { |
| + let server = ScriptedTransport(), app = EquipoAppModel(store: MemorySecretStore(), makeTransport: { _ in server }) |
| + var account = DeviceAccount.new(origin: server.origin, label: "First") |
| + account.credential = DeviceCredential(id: "device", token: "device", audience: "equipo.person.v1", instanceId: "instance", expiresAt: .distantFuture) |
| + app.adopt(account, transport: server) |
| + let session = try #require(app.session) |
| + PreviewPassTests.answer(server) |
| + await session.previews.open(client: session.client, task: try PreviewPassTests.task(), now: PreviewPassTests.now) |
| + let browser = try #require(session.previews.page?.resource as? PreviewBrowser) |
| + if switching { |
| + let next = DeviceAccount.new(origin: URL(string: "https://second.example")!, label: "Second") |
| + app.adopt(next, transport: ScriptedTransport(origin: next.origin)) |
| + } else { await session.signOut() } |
| + #expect(session.previews.page == nil) |
| + #expect(browser.webView == nil); #expect(browser.dataStore == nil) |
| + PreviewPassTests.answer(server) |
| + await session.previews.open(client: session.client, task: try PreviewPassTests.task(), now: PreviewPassTests.now) |
| + #expect(session.previews.page == nil) |
| + } |
| + } |
| + @Test func invalidatedPresentationCannotMintAgain() async throws { |
| + let server = ScriptedTransport(), browser = FakePreviewBrowser() |
| + let model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in browser }) |
| + PreviewPassTests.answer(server) |
| + model.invalidate() |
| + await model.open(client: EquipoClient(transport: server, token: "device"), task: try PreviewPassTests.task(), now: PreviewPassTests.now) |
| + #expect(model.page == nil) |
| + #expect(server.sent("POST /tasks/tk_preview/preview-pass").isEmpty) |
| + } |
| + @Test func backgroundBeyondExpiryCannotReloadDeliveredHTML() async throws { |
| + let server = ScriptedTransport(), browser = FakePreviewBrowser() |
| + let model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in browser }) |
| + PreviewPassTests.answer(server) |
| + let client = EquipoClient(transport: server, token: "device") |
| + await model.open(client: client, task: try PreviewPassTests.task(), now: PreviewPassTests.now) |
| + await model.foreground(client: client, now: PreviewPassTests.now.addingTimeInterval(900)) |
| + #expect(model.page == nil); #expect(browser.closed == 1) |
| + #expect(server.sent("GET /tasks/tk_preview").isEmpty) |
| + #expect(model.failure == EquipoStrings.text("api.preview_expired")) |
| + } |
| + @Test func foregroundRefusesChangedOrRevokedTask() async throws { |
| + for revoked in [false, true] { |
| + let server = ScriptedTransport(), browser = FakePreviewBrowser() |
| + let model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in browser }) |
| + PreviewPassTests.answer(server) |
| + let client = EquipoClient(transport: server, token: "device") |
| + var task = try PreviewPassTests.task() |
| + await model.open(client: client, task: task, now: PreviewPassTests.now) |
| + task.steps![0].attempt = 2 |
| + let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601 |
| + server.on("GET /tasks/tk_preview", .success(APIResponse(status: revoked ? 401 : 200, data: revoked ? Data() : try encoder.encode(task)))) |
| + await model.foreground(client: client, now: PreviewPassTests.now.addingTimeInterval(1)) |
| + #expect(model.page == nil); #expect(browser.closed == 1) |
| + } |
| + } |
| + @Test func doubleTapMintsOnlyOnePass() async throws { |
| + let server = DelayedPreviewTransport(), model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in FakePreviewBrowser() }) |
| + let task = try PreviewPassTests.task(), client = EquipoClient(transport: server, token: "device") |
| + let first = Task { await model.open(client: client, task: task, now: PreviewPassTests.now) } |
| + while !(await server.waiting) { await Task.yield() } |
| + let second = Task { await model.open(client: client, task: task, now: PreviewPassTests.now) } |
| + for _ in 0..<20 { await Task.yield() } |
| + #expect(await server.calls == 1) |
| + await server.complete(); await first.value; await second.value |
| + model.dismiss() |
| + } |
| + @Test func lateMintCannotRestoreDismissedOrInvalidatedSheet() async throws { |
| + for invalidate in [false, true] { |
| + let server = DelayedPreviewTransport(), browser = FakePreviewBrowser() |
| + let model = PreviewPresentation(elapsedSince: { _ in 0 }, makeBrowser: { _, _ in browser }) |
| + let task = try PreviewPassTests.task() |
| + let opening = Task { await model.open(client: EquipoClient(transport: server, token: "device"), task: task, now: PreviewPassTests.now) } |
| + while !(await server.waiting) { await Task.yield() } |
| + if invalidate { model.invalidate() } else { model.dismiss() } |
| + await server.complete() |
| + await opening.value |
| + #expect(model.page == nil); #expect(!model.busy) |
| + } |
| + } |
| +} |
| +actor DelayedPreviewTransport: EquipoTransport { |
| + func lines(_ request: APIRequest) async throws -> AsyncThrowingStream<String, Error> { throw EquipoAPIError.offline } |
| + nonisolated let origin = URL(string: "https://team.example")! |
| + var calls = 0 |
| + var waiting: Bool { !continuations.isEmpty } |
| + var continuations: [CheckedContinuation<APIResponse, Never>] = [] |
| + func send(_ request: APIRequest) async throws -> APIResponse { |
| + calls += 1 |
| + 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\",\"expires_in\":60,\"grant_expires_in\":900}".utf8))) |
| + } |
| + continuations = [] |
| + } |
| +} |
diff --git a/native/ios/Sources/EquipoPhoneApp.swift b/native/ios/Sources/EquipoPhoneApp.swift| index aaef4355..11b79cc6 100644 |
| --- a/native/ios/Sources/EquipoPhoneApp.swift |
| +++ b/native/ios/Sources/EquipoPhoneApp.swift |
| @@ -7,7 +7,8 @@ struct EquipoPhoneApp: App { |
| var body: some Scene { |
| WindowGroup { |
| #if DEBUG |
| - if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil { PhoneNeedsFixture() } |
| + if ProcessInfo.processInfo.environment["EQUIPO_PREVIEW_FIXTURE"] != nil { PreviewFixture() } |
| + else if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil { PhoneNeedsFixture() } |
| else if ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] != nil { TaskViewFixture() } |
| else if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil { StoppedWorkFixture() } |
| else { PhoneRoot(model: delegate.model) } |
diff --git a/native/scripts/check-strings.py b/native/scripts/check-strings.py| index dfdd26d7..b8a05da1 100755 |
| --- a/native/scripts/check-strings.py |
| +++ b/native/scripts/check-strings.py |
| @@ -18,7 +18,7 @@ plurals = json.loads((native / 'scripts/plurals.json').read_text()) |
| def catalog(): |
| return {'sourceLanguage': 'en', 'version': '1.0', 'strings': { |
| - k: {**({'comment': 'COPY APPROVED: Luna, 2026-11-26.'} if k.startswith('native.changes.') else {}), 'extractionState': 'manual', 'localizations': {'en': plurals.get(k, {'stringUnit': {'state': 'translated', 'value': v}})}} |
| + k: {**({'comment': 'COPY APPROVED: Luna, 2026-11-26.'} if k.startswith('native.changes.') or k in ('api.preview_changed', 'api.preview_expired') else {}), 'extractionState': 'manual', 'localizations': {'en': plurals.get(k, {'stringUnit': {'state': 'translated', 'value': v}})}} |
| for k, v in sorted(source.items())}} |
| def used_keys(): |
diff --git a/native/scripts/strings.json b/native/scripts/strings.json| index 028b1e50..80aa2cf9 100644 |
| --- a/native/scripts/strings.json |
| +++ b/native/scripts/strings.json |
| @@ -409,7 +409,6 @@ |
| "work.reason.account_unavailable": "no model account was ready", |
| "work.reason.amadan_ci_failed": "Amadan's own CI did not pass", |
| "work.reason.amadan_ci_pending": "Amadan's own CI had not finished", |
| - "work.reason.amadan_unreachable": "Amadan could not be reached to confirm Equipo may merge here", |
| "work.reason.base_checks_failed": "the base version's checks failed", |
| "work.reason.base_gate_unavailable": "the check files from the base version could not be loaded", |
| "work.reason.branch_moved": "the branch moved on Amadan", |
| @@ -425,7 +424,6 @@ |
| "work.reason.limited": "its model account reached its limit", |
| "work.reason.machine_removed": "the machine was removed mid-step", |
| "work.reason.merge_conflict": "it conflicts with the default branch", |
| - "work.reason.merge_credential": "the runner has no Amadan credential for this repository", |
| "work.reason.merge_failed": "Amadan did not merge it", |
| "work.reason.merge_forbidden": "Equipo may not merge in this repository", |
| "work.reason.merge_not_authorized": "my rules require me to ask before merging", |
| @@ -502,5 +500,7 @@ |
| "native.needs.finished_today": "Finished today", |
| "native.needs.done_at": "Done at %@", |
| "work.merged": "Merged into %@ at %@", |
| - "native.needs.merged_at": "Merged into %1$@ at %2$@" |
| + "native.needs.merged_at": "Merged into %1$@ at %2$@", |
| + "api.preview_changed": "The change has been updated. Review it again.", |
| + "api.preview_expired": "This preview expired. Open it again." |
| } |