hostedctl: launch intents and replay
Launch saves the exact LaunchSpec as a waiting intent (transaction 1) before the provider call, which runs outside any transaction with the attempt ID as client token; transaction 2 saves the Ref. A repeat of the same request returns the saved job; a changed one is ErrConflict. Replay re-checks the flag, image, audit freshness, stop request and stop time before every call that could create a VM; a stop or a passed stop time abandons the intent for good. RunAudit keeps the last network audit in memory; launches need a pass at most 5 minutes old.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+1,398
−0
docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md+38 −0internal/hostedctl/audit.go+77 −0internal/hostedctl/controller.go+5 −0internal/hostedctl/launch.go+616 −0internal/hostedctl/launch_test.go+646 −0internal/hostedctl/states.go+16 −0
CI passed — run details
CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/hosted-runners-1a: Type Size Avail | ext4 96G 85G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 85G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.7s
ci-box: codex: fetched and verified in 3.6s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.8s
ci-box: pi: installed and verified in 7.5s
ci-box: opencode: installed and verified in 1.9s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.6s
ci-box: clone deepened in 3.9s
ci-box: file times set from content: 2872 files, 192 directories
ci-box: ready in 17.2s
=== 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.248s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
1.1s
+ go list -export -test -tags testbuild -f ./...
0.8s
+ go list -export -test -tags browser,testbuild -f ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
0.3s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-11 02:51:11 +0000 UTC
go run github.com/zricethezav/gitleaks/v8@v8.30.1 version
version is set by build process
=== check ===
--- shard 0 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-work: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m21.184s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m19.511s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m19.51s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 37.55, cpu waiting 21.34%, memory waiting 0.00%, io waiting 0.53%
--- 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 1m23.404s 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.733s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m21.73s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 37.55, cpu waiting 20.87%, memory waiting 0.00%, io waiting 0.51%
--- 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 1m24.198s 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.075s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m11.51s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.73s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.83s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 37.55, cpu waiting 20.45%, memory waiting 0.00%, io waiting 0.49%
--- 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 1m19.859s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m18.234s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.75s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 20.43s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.56s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.49s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 39.51, cpu waiting 21.34%, memory waiting 0.00%, io waiting 0.53%
--- shard 4 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-guards: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m37.755s 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 1m36.014s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m0.15s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.18s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 9.93s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 8.87s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.88s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 32.12, cpu waiting 16.55%, memory waiting 0.00%, io waiting 0.39%
--- shard 5 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-rest: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$|^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$|^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$|^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$|^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 3m17.917s 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 3m15.919s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m44.76s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 24.12s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 20.6s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 8.13s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.34s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 7.53, cpu waiting 3.24%, memory waiting 0.00%, io waiting 0.07%
--- 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 1.11s 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 2m1.624s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 7.84s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.74s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 4.31s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
receipt: slow test 3.81s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.52s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
machine: 32 CPUs, load 8.97, cpu waiting 1.24%, memory waiting 0.00%, io waiting 1.96%
--- 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 1.097s 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 1m26.784s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.08s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 5.03s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.41s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.4s amadan.net/oficina/equipo/internal/thintest TestContractPreview
receipt: slow test 2.34s amadan.net/oficina/equipo/internal/thintest TestContractPublishNameTaken
machine: 32 CPUs, load 8.97, cpu waiting 0.03%, memory waiting 0.00%, io waiting 2.00%
--- 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 4m28.231s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 4m41.127s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 4m28.231s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.97s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.9s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.77s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.46s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 6.8s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.56, cpu waiting 0.79%, memory waiting 0.00%, io waiting 0.01%
--- shard 9 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-bug: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed
receipt: test step 47.214s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 46.164s amadan.net/oficina/equipo/internal/runner
receipt: slow test 26.13s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 37.40, cpu waiting 20.37%, memory waiting 0.00%, io waiting 0.94%
--- shard 10 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-plans: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed
receipt: test step 47.152s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 45.205s amadan.net/oficina/equipo/internal/runner
receipt: slow test 35.27s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 31.19s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.37s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.55s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 37.40, cpu waiting 20.59%, memory waiting 0.00%, io waiting 0.91%
--- 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.231s 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.329s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.63s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.11s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.17s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 27.47, cpu waiting 14.12%, memory waiting 0.00%, io waiting 1.15%
--- 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 26.5%, load 23.25
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m4.383s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m2.514s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.67s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 26.62s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 24.6s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.1s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 21.93s amadan.net/oficina/equipo/internal/equipotest TestAuthorityRejectsMismatchedTarget
machine: 32 CPUs, load 34.13, cpu waiting 17.65%, memory waiting 0.00%, io waiting 0.41%
--- 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 26.5%, load 23.25
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 1.253s 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 1m12.399s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 19.2s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 19.12s amadan.net/oficina/equipo/internal/equipotest TestProjectOwnersAreMembers
receipt: slow test 19.11s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 19.11s amadan.net/oficina/equipo/internal/equipotest TestProjectRetryAndRevision
receipt: slow test 19.08s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
machine: 32 CPUs, load 27.47, cpu waiting 10.96%, memory waiting 0.00%, io waiting 1.23%
--- 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 26.5%, load 23.25
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m15.453s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m3.508s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 14.6s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 12.72s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 9.72s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 9.68s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 6.61s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 29.71, cpu waiting 14.48%, memory waiting 0.00%, io waiting 0.34%
--- 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 26.5%, load 23.25
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 493ms 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 1m4.231s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 24.45s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 23.28s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 23.2s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 21.61s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsUpgrade
receipt: slow test 21.57s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
machine: 32 CPUs, load 27.47, cpu waiting 10.96%, memory waiting 0.00%, io waiting 1.23%
--- 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 26.5%, load 23.25
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 534ms 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 48.756s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.61s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.41s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.5s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.47s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.21s amadan.net/oficina/equipo/internal/plan3test TestPlanMigrationUpgrade
machine: 32 CPUs, load 23.25, cpu waiting 10.96%, memory waiting 0.00%, io waiting 1.23%
--- 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 26.5%, load 23.25
test lane rest: ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/hostedctl ./internal/hostedwire ./internal/idtest ./internal/isolatedjob ./internal/isolatedjob/awsjob ./internal/isolatedjob/guardfixture ./internal/isolatedjob/isolatedjobtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/hostedctl ./internal/hostedwire ./internal/idtest ./internal/isolatedjob ./internal/isolatedjob/awsjob ./internal/isolatedjob/guardfixture ./internal/isolatedjob/isolatedjobtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
cache miss: amadan.net/oficina/equipo/internal/isolatedjob: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/copydesk: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/opencode: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/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 45.275s, 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 12.529s, 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 39.84s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/release took 34.981s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/runner/containment took 39.786s, over the 15s its record on line 40 allows; reported only, timing fails on CI
receipt: test step 2m15.719s against a 60s target (the gate's other steps are not in this figure)
receipt: 13 packages ran, 52 cached, 20 without tests, 0 failed
receipt: slow package 53.373s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 51.406s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 45.275s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 39.84s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 39.786s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 22.15s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 15.27s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringOfflineGo
receipt: slow test 10.89s amadan.net/oficina/equipo/internal/idtest TestIDCallbackGuardAndPendingNonce
receipt: slow test 10.82s amadan.net/oficina/equipo/internal/equipo TestAgentReadRechecksIdentity
receipt: slow test 9.42s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringMissingModuleCache
machine: 32 CPUs, load 11.87, cpu waiting 5.35%, memory waiting 0.00%, io waiting 0.12%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m22.585s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m20.964s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.28s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 15.19s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.53s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.72s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 5.84s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 37.55, cpu waiting 20.87%, memory waiting 0.00%, io waiting 0.51%
--- 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 1m32.639s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m30.921s amadan.net/oficina/equipo/internal/headless
receipt: slow test 26.28s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 22.59s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 14.19s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 10.13s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 8.03s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 34.13, cpu waiting 17.65%, memory waiting 0.00%, io waiting 0.41%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m40.322s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m38.603s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.04s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.1s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 12.89s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 10.21s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.15s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 32.12, cpu waiting 16.01%, memory waiting 0.00%, io waiting 0.37%
--- shard 21 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-rest: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN TestBrowserEmptyExplore
time=2026-11-22T17:17:52.639Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-22T17:17:52.639Z level=INFO msg="startup phase done" phase=state_lock took=156µs
time=2026-11-22T17:17:52.639Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-22T17:17:52.639Z level=INFO msg="startup phase done" phase=claim_roots took=123µs
time=2026-11-22T17:17:52.639Z level=INFO msg="startup phase" phase=sweep
time=2026-11-22T17:17:52.669Z level=INFO msg="startup phase done" phase=sweep took=29.989ms
time=2026-11-22T17:17:52.669Z level=INFO msg="startup phase" phase=credentials
time=2026-11-22T17:17:52.669Z level=INFO msg="startup phase done" phase=credentials took=132µs
time=2026-11-22T17:17:52.669Z level=INFO msg="startup phase" phase=open_state
time=2026-11-22T17:17:52.710Z level=INFO msg="startup phase done" phase=open_state took=40.249ms
time=2026-11-22T17:17:52.710Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-22T17:17:52.711Z level=INFO msg=connecting host=127.0.0.1:34639 protocol=28
time=2026-11-22T17:17:52.712Z level=INFO msg=connected host=127.0.0.1:34639 took=817µs
time=2026-11-22T17:17:52.712Z level=INFO msg="capabilities gathering"
time=2026-11-22T17:17:52.712Z level=INFO msg="capabilities gathered" took=387µs tags=linux,claude,go
time=2026-11-22T17:17:52.713Z level=INFO msg="hello sent" protocol=28
time=2026-11-22T17:17:52.720Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-22T17:17:53.720Z level=INFO msg="connection checked" connection=claude-1 state=healthy
browser_receipts_test.go:169: waiting for [...document.querySelectorAll('[equipo-markdown]:not([data-stream-text])')].some(e=>e.textContent.includes("I'm your coordinator")): context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserEmptyExplore (5.79s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m27.356s
FAIL amadan.net/oficina/equipo/internal/headless 87.660s
rastrillo: budget test: go test failed
receipt: test step 1m28.792s 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 1m27.356s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.48s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.21s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.5s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 10.4s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 8.06s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserEmptyExplore$' -count=1 ./internal/headless (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserEmptyExplore browser-headless-rest e4b07130835fcce2efe5e1fc9716d6dcb99969f2 5.79s 36.06
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 32.12, cpu waiting 16.01%, memory waiting 0.00%, io waiting 0.37%
--- shard 22 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-rest: ./internal/equipo
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserPreviewBlocksNavigation)$' ./internal/equipo
receipt: test step 993ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 573ms amadan.net/oficina/equipo/internal/equipo
receipt: slow test 570ms amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewBlocksNavigation
browser lane browser-rest: ./internal/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor)$' ./internal/idtest
receipt: test step 779ms 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.673s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 1.67s 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 257ms 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.856s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 1.86s 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|TestBrowserPhoneIndex|TestBrowserPlacementQuestionAndPending|TestBrowserProjectPlacement|TestBrowserProjectsList|TestBrowserReportActionFeedback|TestBrowserReportNextSteps|TestBrowserReportThread|TestBrowserRollup|TestBrowserRosterAlignment|TestBrowserRosterDecisionStates|TestBrowserRosterQuietDay|TestBrowserRosterReports|TestBrowserRosterSetAside|TestBrowserRosterSubchat|TestBrowserRosterThinking|TestBrowserRosterVisual|TestBrowserSettingsHousekeepingGroups|TestBrowserSettingsMenu|TestBrowserSettingsRail|TestBrowserSettingsSaveBar|TestBrowserSettingsShots|TestBrowserSettingsStayOnPage|TestBrowserSettingsTeams|TestBrowserShipsButtons|TestBrowserSpecialistRows|TestBrowserSpendFollowsAnswers|TestBrowserTaskRows|TestBrowserTeamPanel|TestBrowserThinkingCycles|TestBrowserThinkingLinesClear|TestBrowserThinkingSteady|TestBrowserThinkingWords|TestBrowserTokenRowEmail|TestBrowserTrackPulse|TestBrowserTrackStarCentre|TestBrowserTryAgain)$' ./internal/thintest
receipt: test step 1.154s 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 3m20.199s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 17.52s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.35s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.02s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.55s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 7.93s amadan.net/oficina/equipo/internal/thintest TestBrowserInnerScreens
machine: 32 CPUs, load 8.97, cpu waiting 1.75%, memory waiting 0.00%, io waiting 1.90%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless (52s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.29s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.36s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.19s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.79s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.90s
+ 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 (63s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 12.80s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 14.12s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 20.48s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 13.15s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (22s)
ok ./internal/headless TestMixedVersions 20.04s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.82s
+ 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 40.85, cpu waiting 21.93%, memory waiting 0.00%, io waiting 0.72%
--- shard 24 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 24: make runner-host
python3 scripts/runner-prerequisites.py
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
receipt: test step 8.392s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 3 without tests, 0 failed
receipt: slow package 7.218s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 172ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 90ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 0s amadan.net/oficina/equipo/internal/runner/provider/gotoolchain
receipt: slow test 5.09s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.7s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 340ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 170ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 90ms amadan.net/oficina/equipo/internal/runner/provider/codex TestDirectJournalAdapterBarrier
CGO_ENABLED=0 EQUIPO_REQUIRE_USER_SESSION=1 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.058s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.754s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 270ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 16.01, cpu waiting 4.81%, memory waiting 0.00%, io waiting 1.66%
--- 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 26.5%, load 23.25
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2585 text files, 2854 matches, 0 failures
python3 scripts/ci-test.py check
lanes: 18 lanes and 5 browser lanes run every test once; 20-check@29
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o /dev/null ./cmd/equipo-runner
go vet ./...
go vet -tags testbuild ./internal/runner/thin ./internal/headless
GOOS=darwin GOARCH=arm64 go vet ./cmd/equipo-runner/... ./internal/runner/... ./internal/wire/... ./internal/release/...
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 94 directories within budget
CGO_ENABLED=0 go test ./internal/equipo -run '^TestMigrationModels$' -count=1
ok amadan.net/oficina/equipo/internal/equipo 2.561s
machine: 32 CPUs, load 35.08, cpu waiting 19.81%, memory waiting 0.00%, io waiting 0.97%
--- 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 26.5%, load 23.25
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 27.47, cpu waiting 12.46%, memory waiting 0.00%, io waiting 1.19%
--- 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 26.5%, load 23.25
shard 27: make govulncheck
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
=== Symbol Results ===
No vulnerabilities found.
Your code is affected by 0 vulnerabilities.
This scan also found 0 vulnerabilities in packages you import and 5
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
machine: 32 CPUs, load 31.52, cpu waiting 15.45%, memory waiting 0.00%, io waiting 1.11%
--- 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 26.5%, load 23.25
shard 28: make gitleaks
[90m5:17PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m5:17PM[0m [32mINF[0m [1m1117 commits scanned.[0m
[90m5:17PM[0m [32mINF[0m [1mscanned ~61604539 bytes (61.60 MB) in 13.9s[0m
[90m5:17PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 35.08, cpu waiting 19.81%, memory waiting 0.00%, io waiting 0.97%
=== 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.041ms, worst 1.091ms, budget 150ms
perf: GET /api/runner/protocol: median 84µs, worst 97µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 628µs, worst 657µs, budget 150ms
perf: GET /api/v1/accounts: median 436µs, worst 456µs, budget 150ms
perf: GET /api/v1/auth/devices: median 449µs, worst 501µs, budget 150ms
perf: GET /api/v1/budgets: median 509µs, worst 560µs, budget 150ms
perf: GET /api/v1/capabilities: median 243µs, worst 287µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.181ms, worst 1.317ms, budget 150ms
perf: GET /api/v1/connections: median 534µs, worst 609µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 524µs, worst 556µs, budget 150ms
perf: GET /api/v1/conversation: median 896µs, worst 939µs, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.405ms, worst 1.442ms, budget 150ms
perf: GET /api/v1/coordinator: median 2.004ms, worst 2.06ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 473µs, worst 514µs, budget 150ms
perf: GET /api/v1/journey: median 7.443ms, worst 7.771ms, budget 150ms
perf: GET /api/v1/me: median 420µs, worst 460µs, budget 150ms
perf: GET /api/v1/me/settings: median 529µs, worst 578µs, budget 150ms
perf: GET /api/v1/needs-you: median 7.193ms, worst 7.314ms, budget 150ms
perf: GET /api/v1/notifications: median 1.627ms, worst 1.73ms, budget 150ms
perf: GET /api/v1/onboarding: median 385µs, worst 431µs, budget 150ms
perf: GET /api/v1/people: median 455µs, worst 470µs, budget 150ms
perf: GET /api/v1/playbooks: median 592µs, worst 634µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 526µs, worst 559µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 843µs, worst 882µs, budget 150ms
perf: GET /api/v1/preferences: median 774µs, worst 804µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 454µs, worst 519µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 595µs, worst 639µs, budget 150ms
perf: GET /api/v1/roster: median 467µs, worst 518µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 415µs, worst 450µs, budget 150ms
perf: GET /api/v1/specialists: median 8.003ms, worst 8.23ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 7.875ms, worst 7.933ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 848µs, worst 904µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.16ms, worst 1.2ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 764µs, worst 785µs, budget 150ms
perf: GET /api/v1/teams: median 448µs, worst 500µs, budget 150ms
perf: GET /api/v1/templates: median 606µs, worst 648µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 451µs, worst 500µs, budget 150ms
perf: GET /auth/callback: median 86µs, worst 105µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.406ms, worst 3.525ms, budget 150ms
perf: GET /auth/verify: median 89µs, worst 110µs, budget 150ms
perf: GET /connections: median 3.82ms, worst 6.157ms, budget 150ms
perf: GET /conversation: median 7.431ms, worst 7.548ms, budget 150ms
perf: GET /conversation/connections: median 265µs, worst 285µs, budget 150ms
perf: GET /conversation/notebook: median 239µs, worst 257µs, budget 150ms
perf: GET /conversation/settings: median 3.875ms, worst 3.976ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 3.556ms, worst 3.6ms, budget 150ms
perf: GET /conversation/settings/connections: median 6.14ms, worst 6.229ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 6.269ms, worst 6.388ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.521ms, worst 3.593ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 4.125ms, worst 6.329ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.436ms, worst 4.614ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.292ms, worst 4.488ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.308ms, worst 3.425ms, budget 150ms
perf: GET /conversation/settings/thinking: median 3.783ms, worst 3.936ms, budget 150ms
perf: GET /housekeeping: median 3.65ms, worst 3.732ms, budget 150ms
perf: GET /invites/new: median 588µs, worst 639µs, budget 150ms
perf: GET /invites/{id}: median 614µs, worst 646µs, budget 150ms
perf: GET /jobs: median 3.152ms, worst 3.29ms, budget 150ms
perf: GET /jobs/{id}: median 4.276ms, worst 4.513ms, budget 150ms
perf: GET /journey: median 11.754ms, worst 12.366ms, budget 150ms
perf: GET /nav/rail: median 3.167ms, worst 5.177ms, budget 150ms
perf: GET /needs-you: median 11.756ms, worst 12.383ms, budget 150ms
perf: GET /onboarding: median 4.239ms, worst 4.312ms, budget 150ms
perf: GET /people: median 3.458ms, worst 3.617ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 5.067ms, worst 5.265ms, budget 150ms
perf: GET /playbooks: median 4.611ms, worst 4.634ms, budget 150ms
perf: GET /playbooks/new: median 4.722ms, worst 4.759ms, budget 150ms
perf: GET /playbooks/{id}: median 4.418ms, worst 4.572ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.406ms, worst 4.577ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 3.682ms, worst 4.107ms, budget 150ms
perf: GET /preferences: median 4.273ms, worst 7.855ms, budget 150ms
perf: GET /preferences/sources/{source}: median 4.088ms, worst 4.162ms, budget 150ms
perf: GET /projects: median 5.065ms, worst 5.147ms, budget 150ms
perf: GET /projects/accounts: median 3.464ms, worst 3.65ms, budget 150ms
perf: GET /projects/new: median 3.505ms, worst 3.569ms, budget 150ms
perf: GET /projects/{id}: median 10.165ms, worst 10.592ms, budget 150ms
perf: GET /projects/{id}/edit: median 3.575ms, worst 3.644ms, budget 150ms
perf: GET /runners/enrol: median 4.274ms, worst 4.321ms, budget 150ms
perf: GET /settings: median 3.307ms, worst 3.419ms, budget 150ms
perf: GET /settings/coordinator: median 5.414ms, worst 5.45ms, budget 150ms
perf: GET /settings/devices: median 3.323ms, worst 4.487ms, budget 150ms
perf: GET /settings/recovery: median 3.472ms, worst 3.594ms, budget 150ms
perf: GET /settings/recovery/release: median 3.336ms, worst 3.426ms, budget 150ms
perf: GET /settings/thinking: median 242µs, worst 268µs, budget 150ms
perf: GET /signin: median 314µs, worst 351µs, budget 150ms
perf: GET /specialists/new: median 3.248ms, worst 3.312ms, budget 150ms
perf: GET /specialists/{key}: median 10.594ms, worst 10.828ms, budget 150ms
perf: GET /specialists/{key}/edit: median 3.474ms, worst 3.552ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 3.591ms, worst 3.617ms, budget 150ms
perf: GET /tasks: median 5.006ms, worst 5.17ms, budget 150ms
perf: GET /tasks/new: median 3.123ms, worst 3.193ms, budget 150ms
perf: GET /tasks/{id}: median 5.285ms, worst 7.871ms, budget 150ms
perf: GET /tasks/{id}/merge: median 4.886ms, worst 5.155ms, budget 150ms
perf: GET /tasks/{id}/move: median 4.468ms, worst 4.582ms, budget 150ms
perf: GET /tasks/{id}/plan: median 5.561ms, worst 5.652ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.493ms, worst 1.545ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 4.995ms, worst 5.27ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 4.547ms, worst 4.646ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4.125ms, worst 4.155ms, budget 150ms
perf: GET /tasks/{id}/thread: median 7.806ms, worst 7.942ms, budget 150ms
perf: GET /team/{specialist}: median 4.158ms, worst 4.208ms, budget 150ms
perf: GET /teams: median 10.246ms, worst 13.362ms, budget 150ms
perf: GET /templates: median 3.381ms, worst 3.44ms, budget 150ms
perf: GET /usage: median 4.059ms, worst 4.161ms, budget 150ms
perf: GET /work: median 2.931ms, worst 3.051ms, budget 150ms
perf: cold boot: median 261ms of [258.400131ms 260.526401ms 262.106254ms], budget 500ms
receipt: test step 30.572s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 90 without tests, 0 failed
receipt: slow package 8.829s 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-runner
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-tool-proxy
receipt: slow package 0s amadan.net/oficina/equipo/internal/advice
receipt: slow test 7.99s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 840ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 3.99 GiB in 25099 files
ci-box: module cache /home/ci/work/repos/oficina__equipo/cache/go-mod: 0.90 GiB in 32632 files
diff --git a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md| index 4802fa30..fc402db0 100644 |
| --- a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md |
| +++ b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md |
| @@ -297,3 +297,41 @@ Controller ruling R15 (review r3, finding 3: database/sql can discard the connec |
| | Mutation | Command | Observed failure | Restored | |
| | --- | --- | --- | --- | |
| | R15 continue on a new connection (on a lost Conn: `s.conn, _ = s.db.Conn(ctx); return s.runTx(ctx, fn)`) | `go test ./internal/hostedctl -run '^TestStoreLostConnectionFailsStore$' -count=1` | `store_test.go:379: Tx on the Store whose connection was discarded = <nil>, want ErrStoreLost` | yes, passes | |
| + |
| +## Task 10 |
| + |
| +Launch intents and replay: `internal/hostedctl/{launch.go,audit.go,states.go,launch_test.go}`, plus `Config.Egress` and the in-memory audit result on `Controller` (controller.go). No schema change. |
| + |
| +- RED (stub with the names only): every new test failed on its assertion, for example `launch_test.go:201: Launch = not built`, `launch_test.go:495: Launch = (..., not built), want (zero view, hostedctl: hosted launches are disabled)`, `launch_test.go:637: Deadlines(0s, 8h0m0s) = (0s, 0s, 0s), want (8h0m0s, 7h15m0s, 7h50m0s)`. |
| +- GREEN: `go test ./internal/hostedctl -run 'TestLaunch|TestConcurrentLaunch|TestCrashBetween|TestThrottle|TestDeadlines' -count=1` ok 1.2 s; whole package `go test ./internal/hostedctl -count=1` ok 3.3 s on a5050ff9; the new tests once under `-race`: ok. |
| +- Mutations ran first with `-overlay` mapping Task 9's files to HEAD 94122cdc while its follow-up was mid-edit, then again with no overlay on a5050ff9 (the pinned connection): same outcomes and the same failure lines. Every command below is `go test ./internal/hostedctl -run '<test>' -count=1`; every row was restored and its test passed again. |
| + |
| +| Mutation | Test | Observed failure | Restored | |
| +| --- | --- | --- | --- | |
| +| M1 save the intent after the provider call | `^TestLaunchSavesIntentBeforeProvider$` | `launch_test.go:211: the provider was called before the launch intent was saved` | yes, passes | |
| +| M2 skip the image check in Launch (`if false && !c.cfg.Images[q.Image]`) | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting VMRef:vm-0001 ...}, <nil>), want (zero view, hostedctl: image is not in the allowlist)` | yes, passes | |
| +| M3 skip the Replaces check (`if false && q.Replaces != ""`) | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting VMRef:vm-0002 ...}, <nil>), want (zero view, hostedctl: replaced attempt is not proven stopped)` (3 rows) | yes, passes | |
| +| M4 replay without re-checking the gates (abandon check and `creatable` both skipped) | `^TestThrottleThenRefusal$` | `launch_test.go:590: provider launches = 2, want 1: a failed gate calls nothing` (every row) | yes, passes | |
| +| L1 Launch: flag gate dropped | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting ...}, <nil>), want (zero view, hostedctl: hosted launches are disabled)` | yes, passes | |
| +| L2 Launch: role gate dropped | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting ...}, <nil>), want (zero view, hostedctl: this key may not do that)` (operator role and no key ID) | yes, passes | |
| +| L3 Launch: audit gate dropped at the call site | `^TestLaunchRefusals$` | `launch_test.go:498: ... want (zero view, hostedctl: no passing network audit in the last 5 minutes)` (no audit, stale, failing, call fails) | yes, passes | |
| +| L4 stale audit accepted (`age > AuditMaxAge && false`, shared) | `^(TestLaunchRefusals\|TestThrottleThenRefusal)$` | `launch_test.go:498: ... want (zero view, hostedctl: no passing network audit ...)` and `launch_test.go:590: provider launches = 2, want 1` | yes, passes | |
| +| L4b audit age boundary `>=` | `^TestLaunchRefusals$` | `launch_test.go:493: Launch = (..., hostedctl: no passing network audit in the last 5 minutes: the last pass is 5m0s old), want it started` | yes, passes | |
| +| L5 failing audit accepted (`false && !s.passed`, shared) | `^(TestLaunchRefusals\|TestThrottleThenRefusal)$` | `launch_test.go:498: ... want (zero view, hostedctl: no passing network audit ...)` and `launch_test.go:590: provider launches = 2, want 1` | yes, passes | |
| +| L5b `!s.ran` dropped | `^TestLaunchRefusals$` | survives: equivalent, an audit that never ran also has `passed` false, so the next check refuses; only the message changes | n/a | |
| +| L6 Replaces: stop proof not required | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... VMRef:vm-0002 ...}, <nil>), want (zero view, hostedctl: replaced attempt is not proven stopped)` | yes, passes | |
| +| L6b Replaces: owner not checked (`if !found {`) | `^TestLaunchRefusals$` | same line, row "replaced attempt of another key" | yes, passes | |
| +| L7 instance code not checked | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting ...}, <nil>), want (zero view, isolatedjob: invalid request)` (empty and non-ASCII) | yes, passes | |
| +| L8 lifetime margin not checked | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... DeadlineIn:10m0s DrainIn:0s StopIn:0s}, <nil>), want (zero view, isolatedjob: invalid request)` | yes, passes | |
| +| R1 Replay: flag gate dropped | `^TestThrottleThenRefusal$` | `launch_test.go:590: provider launches = 2, want 1: a failed gate calls nothing` | yes, passes | |
| +| R2 Replay: image gate dropped | `^TestThrottleThenRefusal$` | same line, row "image removed" | yes, passes | |
| +| R3 Replay: audit gate dropped at the call site (`return nil`) | `^TestThrottleThenRefusal$` | same line, rows "stale audit" and "failing audit" | yes, passes | |
| +| R4 Replay: stop request ignored | `^TestThrottleThenRefusal$` | same line, row "stop requested" | yes, passes | |
| +| R5 Replay: stop time ignored | `^TestThrottleThenRefusal$` | same line, row "stop time passed" | yes, passes | |
| +| R5b Replay: stop time boundary `>` | `^TestThrottleThenRefusal$` | same line, row "stop time passed" (exactly at `stop_t`) | yes, passes | |
| +| R6 Replay lists abandoned intents too | `^TestThrottleThenRefusal$` | survives alone: `replayOne` re-reads the row and skips anything not waiting | n/a | |
| +| R6c R6 plus the re-read skip dropped | `^TestThrottleThenRefusal$` | `launch_test.go:604: Replay after abandoning = hostedctl: abandon att-1: 0 rows (<nil>)` | yes, passes | |
| +| X1 a repeat of a saved intent calls the provider | `^TestConcurrentLaunchSameAttempt$` | `launch_test.go:352: Launch 0 = hostedctl: launch att-1: isolatedjob: conflict: attempt att-1 was launched with a different spec` | yes, passes | |
| +| X2 replay sends a changed spec (bootstrap plus one byte) | `^TestCrashBetweenLaunchAndSave$` | `launch_test.go:401: Replay = hostedctl: launch att-1: isolatedjob: conflict: attempt att-1 was launched with a different spec` | yes, passes | |
| +| X3 a throttle returned as an error | `^TestThrottleWaitsThenReplays$` | `launch_test.go:522: throttled Launch = (zero view, hostedctl: launch att-1: isolatedjob: throttled: fake launch), want a waiting view with a launch ID and no error` | yes, passes | |
| +| X4 request hash ignores the key | `^TestLaunchConflictOnChangedRequest$` | `launch_test.go:312: changed Launch = ({... State:starting ...}, <nil>), want (zero view, ErrConflict)` | yes, passes | |
diff --git a/internal/hostedctl/audit.go b/internal/hostedctl/audit.go| new file mode 100644 |
| index 00000000..56ccd831 |
| --- /dev/null |
| +++ b/internal/hostedctl/audit.go |
| @@ -0,0 +1,77 @@ |
| +package hostedctl |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "sync" |
| + "time" |
| +) |
| + |
| +// AuditMaxAge is how old, in controller time, the last passing network audit |
| +// may be for a launch or a replay that could create a VM to go ahead. |
| +const AuditMaxAge = 5 * time.Minute |
| + |
| +// ErrNetworkAudit: no network audit has passed in the last AuditMaxAge, so |
| +// nothing may create a VM. |
| +var ErrNetworkAudit = errors.New("hostedctl: no passing network audit in the last 5 minutes") |
| + |
| +// auditState is the last network audit result, held in memory only (ruling |
| +// R2). A fresh controller has none, so launches fail closed until the first |
| +// audit passes. |
| +type auditState struct { |
| + mu sync.Mutex |
| + ran bool |
| + passed bool |
| + at T // controller time when the audit began |
| + reason string // why it failed; empty when it passed |
| +} |
| + |
| +// RunAudit reads the provider's network settings through the auditor, checks |
| +// them against Config.Egress, and records the result with the controller |
| +// time at which the audit began. It returns the failure, or nil when the |
| +// audit passes. The reaper (Task 13) calls it every pass and alerts; RunAudit |
| +// itself only records. |
| +func (c *Controller) RunAudit(ctx context.Context) error { |
| + at := c.store.Clock().Now() |
| + a, err := c.auditor.AuditNetwork(ctx) |
| + if err != nil { |
| + err = fmt.Errorf("hostedctl: network audit: %w", err) |
| + } else { |
| + err = a.OK(c.cfg.Egress) |
| + } |
| + c.audit.record(at, err) |
| + return err |
| +} |
| + |
| +// record keeps the result of the audit that began at at, unless an audit |
| +// that began later has already been recorded. |
| +func (s *auditState) record(at T, err error) { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + if s.ran && at < s.at { |
| + return |
| + } |
| + s.ran, s.at, s.passed, s.reason = true, at, err == nil, "" |
| + if err != nil { |
| + s.reason = err.Error() |
| + } |
| +} |
| + |
| +// check returns nil only when the last audit passed and began at most |
| +// AuditMaxAge before now. Otherwise it returns ErrNetworkAudit, wrapped with |
| +// the reason. |
| +func (s *auditState) check(now T) error { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + if !s.ran { |
| + return fmt.Errorf("%w: none has run yet", ErrNetworkAudit) |
| + } |
| + if !s.passed { |
| + return fmt.Errorf("%w: the last one failed: %s", ErrNetworkAudit, s.reason) |
| + } |
| + if age := time.Duration(now - s.at); age > AuditMaxAge { |
| + return fmt.Errorf("%w: the last pass is %v old", ErrNetworkAudit, age) |
| + } |
| + return nil |
| +} |
diff --git a/internal/hostedctl/controller.go b/internal/hostedctl/controller.go| index a354d330..cdad2c8f 100644 |
| --- a/internal/hostedctl/controller.go |
| +++ b/internal/hostedctl/controller.go |
| @@ -4,7 +4,9 @@ import ( |
| "context" |
| "errors" |
| "maps" |
| + "net/netip" |
| "reflect" |
| + "slices" |
| "amadan.net/oficina/equipo/internal/isolatedjob" |
| ) |
| @@ -24,6 +26,7 @@ type Alerter interface { |
| type Config struct { |
| Enabled bool // launches allowed; only EQUIPO_HOSTED_ENABLED=1 sets it |
| Images map[isolatedjob.ImageDigest]bool // image digests launches may use |
| + Egress []netip.AddrPort // the exact egress set the network audit expects |
| } |
| // Deps are the controller's collaborators. Every one is required. |
| @@ -41,6 +44,7 @@ type Controller struct { |
| runner isolatedjob.Runner |
| auditor isolatedjob.NetworkAuditor |
| alerter Alerter |
| + audit auditState // the last network audit result (audit.go) |
| } |
| // New builds a controller. It refuses a nil dependency, including a nil |
| @@ -64,6 +68,7 @@ func New(cfg Config, d Deps) (*Controller, error) { |
| return nil, err |
| } |
| cfg.Images = maps.Clone(cfg.Images) |
| + cfg.Egress = slices.Clone(cfg.Egress) |
| return &Controller{cfg: cfg, store: d.Store, runner: d.Runner, auditor: d.Auditor, alerter: d.Alerter}, nil |
| } |
diff --git a/internal/hostedctl/launch.go b/internal/hostedctl/launch.go| new file mode 100644 |
| index 00000000..4e4e1009 |
| --- /dev/null |
| +++ b/internal/hostedctl/launch.go |
| @@ -0,0 +1,616 @@ |
| +package hostedctl |
| + |
| +import ( |
| + "context" |
| + "crypto/rand" |
| + "crypto/sha256" |
| + "database/sql" |
| + "encoding/binary" |
| + "encoding/hex" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "math" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/hostedwire" |
| + "amadan.net/oficina/equipo/internal/isolatedjob" |
| +) |
| + |
| +var ( |
| + // ErrDisabled: launches are off (EQUIPO_HOSTED_ENABLED is not 1). |
| + ErrDisabled = errors.New("hostedctl: hosted launches are disabled") |
| + // ErrForbidden: the verified key's role may not make this call. |
| + ErrForbidden = errors.New("hostedctl: this key may not do that") |
| + // ErrImageNotAllowed: the image digest is not in Config.Images. |
| + ErrImageNotAllowed = errors.New("hostedctl: image is not in the allowlist") |
| + // ErrReplacementLive: the attempt named in Replaces is unknown, belongs |
| + // to another key, or has no stop proof yet. |
| + ErrReplacementLive = errors.New("hostedctl: replaced attempt is not proven stopped") |
| +) |
| + |
| +// DrainBefore and StopBefore place a job's drain and stop times before its |
| +// deadline (spec §3: draining at 7 h 15 min and a forced stop at 7 h 50 min |
| +// of an 8 hour lifetime). |
| +const ( |
| + DrainBefore = 45 * time.Minute |
| + StopBefore = 10 * time.Minute |
| +) |
| + |
| +// maxNameLen bounds TaskID and Account. |
| +const maxNameLen = 128 |
| + |
| +// purposeTask is jobs.purpose for a launch that runs a task attempt. |
| +const purposeTask = "task" |
| + |
| +// Audit actions written by Launch and Replay. |
| +const ( |
| + actionLaunchRefused = "launch_refused" |
| + actionLaunchIntent = "launch_intent" |
| + actionLaunchRepeated = "launch_repeated" |
| + actionLaunchStarted = "launch_started" |
| + actionLaunchThrottled = "launch_throttled" |
| + actionLaunchFailed = "launch_failed" |
| + actionReplayStarted = "replay_started" |
| + actionReplayThrottled = "replay_throttled" |
| + actionReplayFailed = "replay_failed" |
| + actionReplayAbandoned = "replay_abandoned" |
| + actionVMAfterAbandon = "vm_after_abandon" |
| +) |
| + |
| +// LaunchRequest asks for one VM for one task attempt. InstanceCode is a |
| +// secret: it goes into the VM's bootstrap and the saved spec, and nowhere |
| +// else. |
| +type LaunchRequest struct { |
| + AttemptID, TaskID, Account, Replaces string |
| + Image isolatedjob.ImageDigest |
| + Size isolatedjob.Size |
| + MaxLifetime time.Duration |
| + InstanceCode string |
| +} |
| + |
| +// JobView is the controller's view of one attempt. The *In fields count down |
| +// in controller time from the moment the view was read, and are zero once |
| +// passed. |
| +type JobView struct { |
| + AttemptID, LaunchID, State string |
| + VMRef isolatedjob.Ref |
| + Epoch int64 |
| + DeadlineIn, DrainIn, StopIn time.Duration |
| +} |
| + |
| +// Deadlines returns a job's deadline (launched plus lifetime), its drain |
| +// time (DrainBefore the deadline) and its stop time (StopBefore the |
| +// deadline). Drain and stop are never before launched; a negative lifetime |
| +// counts as zero and the deadline saturates rather than overflow. |
| +func Deadlines(launched T, lifetime time.Duration) (deadline, drain, stop T) { |
| + lifetime = max(lifetime, 0) |
| + deadline = launched + T(lifetime) |
| + if deadline < launched { |
| + deadline = T(math.MaxInt64) |
| + } |
| + drain = max(launched, deadline-T(DrainBefore)) |
| + stop = max(launched, deadline-T(StopBefore)) |
| + return deadline, drain, stop |
| +} |
| + |
| +// Launch saves a launch intent for q and then asks the provider for the VM. |
| +// |
| +// In order it refuses: launches switched off (ErrDisabled); a key without |
| +// RoleInstance (ErrForbidden); a malformed request (isolatedjob.ErrInvalid, |
| +// or ErrBootstrapTooLarge; a lifetime of StopBefore or less is malformed); an image outside Config.Images |
| +// (ErrImageNotAllowed); no passing network audit begun within AuditMaxAge |
| +// (ErrNetworkAudit). Each refusal is audited and creates nothing. |
| +// |
| +// Transaction 1 then looks up q.AttemptID. A job saved for the same request |
| +// by the same key is returned as it stands, with no provider call; a |
| +// different request, or another key, gives isolatedjob.ErrConflict. A new |
| +// attempt naming Replaces needs that attempt to exist, belong to by and |
| +// carry stop proof (ErrReplacementLive). Otherwise the intent is saved as |
| +// JobWaiting with the exact LaunchSpec, a fresh launch ID and deadlines from |
| +// the current controller time. |
| +// |
| +// The provider call runs outside any transaction, with the attempt ID as |
| +// its client token. On success transaction 2 saves the Ref and JobStarting. |
| +// A throttle returns the JobWaiting view and a nil error: the intent is |
| +// saved and Replay launches it once the provider allows. Any other provider |
| +// error, a lost reply included, returns the error with a zero view; the |
| +// intent stays JobWaiting for Replay, which re-sends the same spec, so a VM |
| +// the lost call created is found again rather than doubled. |
| +func (c *Controller) Launch(ctx context.Context, by hostedwire.KeyID, key hostedwire.VerifyKey, q LaunchRequest) (JobView, error) { |
| + if !c.cfg.Enabled { |
| + return c.refuse(ctx, by, q, ErrDisabled) |
| + } |
| + if by == "" || key.Role != hostedwire.RoleInstance { |
| + return c.refuse(ctx, by, q, fmt.Errorf("%w: launch needs an instance key", ErrForbidden)) |
| + } |
| + spec, launchID, err := c.newSpec(q) |
| + if err != nil { |
| + return c.refuse(ctx, by, q, err) |
| + } |
| + if !c.cfg.Images[q.Image] { |
| + return c.refuse(ctx, by, q, fmt.Errorf("%w: %s", ErrImageNotAllowed, q.Image)) |
| + } |
| + if err := c.audit.check(c.store.Clock().Now()); err != nil { |
| + return c.refuse(ctx, by, q, err) |
| + } |
| + |
| + view, created, err := c.saveIntent(ctx, by, q, spec, launchID) |
| + if err != nil || !created { |
| + return view, err |
| + } |
| + ref, perr := c.runner.Launch(ctx, spec) |
| + // Record the answer even if the caller has gone: a VM may now exist. |
| + return c.settle(context.WithoutCancel(ctx), by, q.AttemptID, ref, perr, false) |
| +} |
| + |
| +// refuse audits a refusal that came before any transaction, in a short |
| +// transaction of its own, and returns err. The row names the request's |
| +// attempt, task and account, never its instance code. |
| +func (c *Controller) refuse(ctx context.Context, by hostedwire.KeyID, q LaunchRequest, err error) (JobView, error) { |
| + aerr := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + return appendAudit(tx, Audit{Actor: by, Account: q.Account, Task: q.TaskID, Attempt: q.AttemptID, |
| + Action: actionLaunchRefused, Reason: err.Error(), At: c.store.Clock().Now()}) |
| + }) |
| + if aerr != nil { |
| + return JobView{}, errors.Join(err, aerr) |
| + } |
| + return JobView{}, err |
| +} |
| + |
| +// newSpec checks q's fields and builds the LaunchSpec the provider will get, |
| +// with a fresh launch ID in its bootstrap. The spec is validated against the |
| +// runner's limits. |
| +func (c *Controller) newSpec(q LaunchRequest) (isolatedjob.LaunchSpec, string, error) { |
| + switch { |
| + case !printableASCII(q.TaskID, maxNameLen): |
| + return isolatedjob.LaunchSpec{}, "", fmt.Errorf("%w: task id must be 1 to %d printable ASCII characters", isolatedjob.ErrInvalid, maxNameLen) |
| + case !printableASCII(q.Account, maxNameLen): |
| + return isolatedjob.LaunchSpec{}, "", fmt.Errorf("%w: account must be 1 to %d printable ASCII characters", isolatedjob.ErrInvalid, maxNameLen) |
| + case q.Replaces != "" && !printableASCII(q.Replaces, maxNameLen): |
| + return isolatedjob.LaunchSpec{}, "", fmt.Errorf("%w: replaced attempt id must be printable ASCII", isolatedjob.ErrInvalid) |
| + case q.MaxLifetime <= StopBefore: |
| + // Its stop time would be reached at launch, so any Replay would |
| + // abandon it while the provider call is in flight. |
| + return isolatedjob.LaunchSpec{}, "", fmt.Errorf("%w: lifetime %v must be more than %v", isolatedjob.ErrInvalid, q.MaxLifetime, StopBefore) |
| + case !printableASCII(q.InstanceCode, math.MaxInt): |
| + // The text never repeats the code. |
| + return isolatedjob.LaunchSpec{}, "", fmt.Errorf("%w: instance code must be one or more printable ASCII characters", isolatedjob.ErrInvalid) |
| + } |
| + launchID, err := newLaunchID() |
| + if err != nil { |
| + return isolatedjob.LaunchSpec{}, "", err |
| + } |
| + boot, err := json.Marshal(hostedwire.Bootstrap{Version: hostedwire.BootstrapVersion, LaunchID: launchID, InstanceCode: q.InstanceCode}) |
| + if err != nil { |
| + return isolatedjob.LaunchSpec{}, "", fmt.Errorf("hostedctl: encode bootstrap: %w", err) |
| + } |
| + spec := isolatedjob.LaunchSpec{AttemptID: q.AttemptID, Image: q.Image, Size: q.Size, MaxLifetime: q.MaxLifetime, Bootstrap: boot} |
| + if err := spec.Validate(c.runner.Limits()); err != nil { |
| + return isolatedjob.LaunchSpec{}, "", err |
| + } |
| + return spec, launchID, nil |
| +} |
| + |
| +// printableASCII reports whether s is 1 to n bytes, each from ' ' to '~'. |
| +// The AWS adapter refuses payloads that are not ASCII. |
| +func printableASCII(s string, n int) bool { |
| + if len(s) == 0 || len(s) > n { |
| + return false |
| + } |
| + for i := 0; i < len(s); i++ { |
| + if s[i] < 0x20 || s[i] > 0x7e { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +// newLaunchID returns 128 random bits as 32 lower-case hex digits. |
| +func newLaunchID() (string, error) { |
| + var b [16]byte |
| + if _, err := rand.Read(b[:]); err != nil { |
| + return "", fmt.Errorf("hostedctl: launch id: %w", err) |
| + } |
| + return hex.EncodeToString(b[:]), nil |
| +} |
| + |
| +// requestHash is the SHA-256, in hex, of a canonical encoding of q and by: |
| +// each field as its length (uvarint) and then its bytes, in a fixed order. |
| +// It decides whether a repeated launch is the same request. |
| +func requestHash(by hostedwire.KeyID, q LaunchRequest) string { |
| + h := sha256.New() |
| + field := func(s string) { |
| + _, _ = h.Write(binary.AppendUvarint(nil, uint64(len(s)))) |
| + _, _ = h.Write([]byte(s)) |
| + } |
| + field("hostedctl launch request v1") |
| + field(string(by)) |
| + field(q.AttemptID) |
| + field(q.TaskID) |
| + field(q.Account) |
| + field(q.Replaces) |
| + field(string(q.Image)) |
| + field(string(q.Size)) |
| + field(fmt.Sprint(int64(q.MaxLifetime))) |
| + field(q.InstanceCode) |
| + return hex.EncodeToString(h.Sum(nil)) |
| +} |
| + |
| +// storedSpec is the layout of jobs.spec_json: the exact LaunchSpec sent to |
| +// the provider, so a replay re-sends identical bytes. |
| +type storedSpec struct { |
| + AttemptID string `json:"attempt_id"` |
| + Image isolatedjob.ImageDigest `json:"image"` |
| + Size isolatedjob.Size `json:"size"` |
| + MaxLifetimeNS int64 `json:"max_lifetime_ns"` |
| + Bootstrap []byte `json:"bootstrap"` |
| +} |
| + |
| +func encodeSpec(s isolatedjob.LaunchSpec) (string, error) { |
| + b, err := json.Marshal(storedSpec{AttemptID: s.AttemptID, Image: s.Image, Size: s.Size, |
| + MaxLifetimeNS: int64(s.MaxLifetime), Bootstrap: s.Bootstrap}) |
| + if err != nil { |
| + return "", fmt.Errorf("hostedctl: encode launch spec: %w", err) |
| + } |
| + return string(b), nil |
| +} |
| + |
| +// decodeSpec reads a saved spec and checks it is the one for attempt. |
| +func decodeSpec(text, attempt string) (isolatedjob.LaunchSpec, error) { |
| + var s storedSpec |
| + if err := json.Unmarshal([]byte(text), &s); err != nil { |
| + return isolatedjob.LaunchSpec{}, fmt.Errorf("hostedctl: saved spec for %s is unreadable: %w", attempt, err) |
| + } |
| + if s.AttemptID != attempt { |
| + return isolatedjob.LaunchSpec{}, fmt.Errorf("hostedctl: saved spec for %s names attempt %s", attempt, s.AttemptID) |
| + } |
| + return isolatedjob.LaunchSpec{AttemptID: s.AttemptID, Image: s.Image, Size: s.Size, |
| + MaxLifetime: time.Duration(s.MaxLifetimeNS), Bootstrap: s.Bootstrap}, nil |
| +} |
| + |
| +// saveIntent is transaction 1. It returns the existing job's view when the |
| +// same request was saved before (created false), or saves a new intent and |
| +// returns its view (created true). A conflict or a live replaced attempt is |
| +// audited, committed, and returned as the error. |
| +func (c *Controller) saveIntent(ctx context.Context, by hostedwire.KeyID, q LaunchRequest, spec isolatedjob.LaunchSpec, launchID string) (JobView, bool, error) { |
| + specJSON, err := encodeSpec(spec) |
| + if err != nil { |
| + return JobView{}, false, err |
| + } |
| + hash := requestHash(by, q) |
| + var view JobView |
| + var created bool |
| + var refusal error |
| + err = c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + view, created, refusal = JobView{}, false, nil |
| + now := c.store.Clock().Now() |
| + a := Audit{Actor: by, Account: q.Account, Task: q.TaskID, Attempt: q.AttemptID, At: now} |
| + j, found, err := loadJob(ctx, tx, q.AttemptID) |
| + if err != nil { |
| + return err |
| + } |
| + if found { |
| + if j.specSHA != hash { |
| + refusal = fmt.Errorf("%w: attempt %s was asked for with a different request", isolatedjob.ErrConflict, q.AttemptID) |
| + a.Action, a.Reason = actionLaunchRefused, refusal.Error() |
| + return appendAudit(tx, a) |
| + } |
| + view = j.view(now) |
| + a.Action, a.Reason = actionLaunchRepeated, "same request again; job is "+j.state |
| + return appendAudit(tx, a) |
| + } |
| + if q.Replaces != "" { |
| + if err := checkReplaces(ctx, tx, by, q.Replaces); err != nil { |
| + if !errors.Is(err, ErrReplacementLive) { |
| + return err // a lookup error denies and saves nothing |
| + } |
| + refusal = err |
| + a.Action, a.Reason = actionLaunchRefused, err.Error() |
| + return appendAudit(tx, a) |
| + } |
| + } |
| + deadline, drain, stop := Deadlines(now, spec.MaxLifetime) |
| + replaces := sql.NullString{String: q.Replaces, Valid: q.Replaces != ""} |
| + if _, err := tx.ExecContext(ctx, `INSERT INTO jobs (attempt_id, launch_id, task_id, account_id, actor_key, |
| + purpose, replaces_attempt, spec_json, spec_sha256, state, launched_t, deadline_t, drain_t, stop_t) |
| + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, |
| + q.AttemptID, launchID, q.TaskID, q.Account, string(by), purposeTask, replaces, specJSON, hash, |
| + JobWaiting, int64(now), int64(deadline), int64(drain), int64(stop)); err != nil { |
| + return fmt.Errorf("hostedctl: save launch intent: %w", err) |
| + } |
| + a.Action = actionLaunchIntent |
| + a.Reason = fmt.Sprintf("intent saved: launch %s, image %s, size %s, lifetime %v", launchID, spec.Image, spec.Size, spec.MaxLifetime) |
| + if err := appendAudit(tx, a); err != nil { |
| + return err |
| + } |
| + view = JobView{AttemptID: q.AttemptID, LaunchID: launchID, State: JobWaiting, |
| + DeadlineIn: until(now, deadline), DrainIn: until(now, drain), StopIn: until(now, stop)} |
| + created = true |
| + return nil |
| + }) |
| + if err != nil { |
| + return JobView{}, false, err |
| + } |
| + if refusal != nil { |
| + return JobView{}, false, refusal |
| + } |
| + return view, created, nil |
| +} |
| + |
| +// checkReplaces returns ErrReplacementLive unless attempt exists, was |
| +// launched by by and carries stop proof. An unknown attempt and another |
| +// key's attempt get the same message, so the refusal tells nobody whether |
| +// another key's attempt exists. |
| +func checkReplaces(ctx context.Context, tx *sql.Tx, by hostedwire.KeyID, attempt string) error { |
| + r, found, err := loadJob(ctx, tx, attempt) |
| + if err != nil { |
| + return err |
| + } |
| + if !found || r.actor != string(by) { |
| + return fmt.Errorf("%w: %s is not an attempt of this key", ErrReplacementLive, attempt) |
| + } |
| + if !r.stopProof.Valid { |
| + return fmt.Errorf("%w: %s has no stop proof", ErrReplacementLive, attempt) |
| + } |
| + return nil |
| +} |
| + |
| +// settle records what the provider said about a launch of attempt. actor is |
| +// the key that asked, or empty for Replay. A Ref is saved by transaction 2 |
| +// (saveRef). A throttle is audited and returns the waiting view with a nil |
| +// error. Any other error is audited, with a fixed reason since provider |
| +// text might echo the request, and returned. |
| +func (c *Controller) settle(ctx context.Context, actor hostedwire.KeyID, attempt string, ref isolatedjob.Ref, perr error, replay bool) (JobView, error) { |
| + if perr == nil && ref == "" { |
| + perr = errors.New("hostedctl: provider returned no VM ref") |
| + } |
| + if perr == nil { |
| + return c.saveRef(ctx, actor, attempt, ref, replay) |
| + } |
| + throttled := errors.Is(perr, isolatedjob.ErrThrottled) |
| + action, reason := actionLaunchFailed, "provider error; intent kept for replay" |
| + switch { |
| + case throttled && replay: |
| + action, reason = actionReplayThrottled, "provider throttled; intent kept for replay" |
| + case throttled: |
| + action, reason = actionLaunchThrottled, "provider throttled; intent kept for replay" |
| + case replay: |
| + action = actionReplayFailed |
| + } |
| + var view JobView |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + now := c.store.Clock().Now() |
| + j, found, err := loadJob(ctx, tx, attempt) |
| + if err != nil { |
| + return err |
| + } |
| + if !found { |
| + return fmt.Errorf("hostedctl: launch intent %s is missing", attempt) |
| + } |
| + view = j.view(now) |
| + return appendAudit(tx, Audit{Actor: actor, Account: j.account, Task: j.task, Attempt: attempt, |
| + Action: action, Reason: reason, At: now}) |
| + }) |
| + if throttled { |
| + if err != nil { |
| + return JobView{}, errors.Join(perr, err) |
| + } |
| + return view, nil |
| + } |
| + return JobView{}, errors.Join(fmt.Errorf("hostedctl: launch %s: %w", attempt, perr), err) |
| +} |
| + |
| +// saveRef is transaction 2: it saves ref for a waiting intent and moves it |
| +// to JobStarting. A ref already saved, by a concurrent call for the same |
| +// attempt, is left as it is. An intent abandoned while the call was in |
| +// flight keeps no ref: the VM is audited and left for the orphan reaper, |
| +// which finds no job owning it. |
| +func (c *Controller) saveRef(ctx context.Context, actor hostedwire.KeyID, attempt string, ref isolatedjob.Ref, replay bool) (JobView, error) { |
| + var view JobView |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + now := c.store.Clock().Now() |
| + j, found, err := loadJob(ctx, tx, attempt) |
| + if err != nil { |
| + return err |
| + } |
| + if !found { |
| + return fmt.Errorf("hostedctl: launch intent %s is missing", attempt) |
| + } |
| + a := Audit{Actor: actor, Account: j.account, Task: j.task, Attempt: attempt, At: now} |
| + switch { |
| + case j.ref.Valid && j.ref.String == string(ref): |
| + view = j.view(now) |
| + return nil |
| + case j.ref.Valid: |
| + return fmt.Errorf("hostedctl: attempt %s: provider returned VM %s but the job holds %s", attempt, ref, j.ref.String) |
| + case j.state == JobAbandoned: |
| + a.Action = actionVMAfterAbandon |
| + a.Reason = fmt.Sprintf("provider created VM %s after the intent was abandoned; left for the orphan reaper", ref) |
| + view = j.view(now) |
| + return appendAudit(tx, a) |
| + case j.state != JobWaiting: |
| + return fmt.Errorf("hostedctl: attempt %s is %s; VM %s not recorded", attempt, j.state, ref) |
| + } |
| + res, err := tx.ExecContext(ctx, `UPDATE jobs SET vm_ref = ?, state = ?, revision = revision + 1 |
| + WHERE attempt_id = ? AND vm_ref IS NULL AND state = ?`, string(ref), JobStarting, attempt, JobWaiting) |
| + if err != nil { |
| + return fmt.Errorf("hostedctl: save VM ref: %w", err) |
| + } |
| + if n, err := res.RowsAffected(); err != nil || n != 1 { |
| + return fmt.Errorf("hostedctl: save VM ref for %s: %d rows (%v)", attempt, n, err) |
| + } |
| + a.Action, a.Reason = actionLaunchStarted, fmt.Sprintf("provider started VM %s", ref) |
| + if replay { |
| + a.Action = actionReplayStarted |
| + } |
| + if err := appendAudit(tx, a); err != nil { |
| + return err |
| + } |
| + j.ref, j.state = sql.NullString{String: string(ref), Valid: true}, JobStarting |
| + view = j.view(now) |
| + return nil |
| + }) |
| + if err != nil { |
| + return JobView{}, err |
| + } |
| + return view, nil |
| +} |
| + |
| +// Replay launches every intent that has no Ref yet, in launch order, each |
| +// with its saved spec. Before each provider call it re-checks the gates: |
| +// |
| +// - a stop asked for, or the intent's stop time reached: the intent is |
| +// marked JobAbandoned and audited, and never replayed again; |
| +// - launches switched off, the image no longer allowed, or no passing |
| +// audit begun within AuditMaxAge: the intent stays JobWaiting for a later |
| +// pass, with no audit row, as nothing changed. |
| +// |
| +// A gate that fails makes no provider call. A throttle leaves the intent |
| +// waiting and is not an error. Replay returns the other failures joined; one |
| +// intent's failure does not stop the others. |
| +func (c *Controller) Replay(ctx context.Context) error { |
| + var pending []string |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + pending = pending[:0] |
| + rows, err := tx.QueryContext(ctx, `SELECT attempt_id FROM jobs WHERE state = ? AND vm_ref IS NULL |
| + ORDER BY launched_t, attempt_id`, JobWaiting) |
| + if err != nil { |
| + return fmt.Errorf("hostedctl: list launch intents: %w", err) |
| + } |
| + defer rows.Close() |
| + for rows.Next() { |
| + var id string |
| + if err := rows.Scan(&id); err != nil { |
| + return fmt.Errorf("hostedctl: list launch intents: %w", err) |
| + } |
| + pending = append(pending, id) |
| + } |
| + return rows.Err() |
| + }) |
| + if err != nil { |
| + return err |
| + } |
| + var errs []error |
| + for _, id := range pending { |
| + if err := ctx.Err(); err != nil { |
| + errs = append(errs, err) |
| + break |
| + } |
| + if err := c.replayOne(ctx, id); err != nil { |
| + errs = append(errs, err) |
| + } |
| + } |
| + return errors.Join(errs...) |
| +} |
| + |
| +// replayOne re-checks attempt's gates and, when every one passes, launches |
| +// its saved spec. The row is re-read in its own transaction, so an intent |
| +// settled since Replay listed it is skipped. |
| +func (c *Controller) replayOne(ctx context.Context, attempt string) error { |
| + var spec isolatedjob.LaunchSpec |
| + ready := false |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + ready = false |
| + j, found, err := loadJob(ctx, tx, attempt) |
| + if err != nil { |
| + return err |
| + } |
| + if !found || j.state != JobWaiting || j.ref.Valid { |
| + return nil |
| + } |
| + now := c.store.Clock().Now() |
| + if reason := abandonReason(j, now); reason != "" { |
| + res, err := tx.ExecContext(ctx, `UPDATE jobs SET state = ?, revision = revision + 1 |
| + WHERE attempt_id = ? AND state = ? AND vm_ref IS NULL`, JobAbandoned, attempt, JobWaiting) |
| + if err != nil { |
| + return fmt.Errorf("hostedctl: abandon %s: %w", attempt, err) |
| + } |
| + if n, err := res.RowsAffected(); err != nil || n != 1 { |
| + return fmt.Errorf("hostedctl: abandon %s: %d rows (%v)", attempt, n, err) |
| + } |
| + return appendAudit(tx, Audit{Account: j.account, Task: j.task, Attempt: attempt, |
| + Action: actionReplayAbandoned, Reason: reason, At: now}) |
| + } |
| + if spec, err = decodeSpec(j.specJSON, attempt); err != nil { |
| + return err |
| + } |
| + ready = true |
| + return nil |
| + }) |
| + if err != nil || !ready { |
| + return err |
| + } |
| + if c.creatable(spec.Image, c.store.Clock().Now()) != nil { |
| + return nil // transient: the intent waits for a later pass |
| + } |
| + ref, perr := c.runner.Launch(ctx, spec) |
| + _, err = c.settle(context.WithoutCancel(ctx), "", attempt, ref, perr, true) |
| + return err |
| +} |
| + |
| +// abandonReason returns why a waiting intent must never be launched, or "" |
| +// when nothing stops it: a stop was asked for, or its stop time has come. |
| +func abandonReason(j jobRow, now T) string { |
| + if j.stopRequested.Valid { |
| + return "stop asked for before the VM was launched" |
| + } |
| + if now >= T(j.stopT) { |
| + return fmt.Sprintf("stop time passed before the VM was launched (%v after it)", time.Duration(now-T(j.stopT))) |
| + } |
| + return "" |
| +} |
| + |
| +// creatable checks the gates Replay shares with Launch: launches on, the |
| +// image still allowed, and a passing audit begun within AuditMaxAge. |
| +func (c *Controller) creatable(img isolatedjob.ImageDigest, now T) error { |
| + if !c.cfg.Enabled { |
| + return ErrDisabled |
| + } |
| + if !c.cfg.Images[img] { |
| + return fmt.Errorf("%w: %s", ErrImageNotAllowed, img) |
| + } |
| + return c.audit.check(now) |
| +} |
| + |
| +// jobRow is the part of a jobs row that launches read. |
| +type jobRow struct { |
| + attempt, launchID, task, account, actor, state, specJSON, specSHA string |
| + ref sql.NullString |
| + launchedT, deadlineT, drainT, stopT, epoch int64 |
| + stopRequested sql.NullInt64 |
| + stopProof sql.NullString |
| +} |
| + |
| +// loadJob reads attempt's row inside tx. found is false when there is none. |
| +func loadJob(ctx context.Context, tx *sql.Tx, attempt string) (jobRow, bool, error) { |
| + var j jobRow |
| + err := tx.QueryRowContext(ctx, `SELECT attempt_id, launch_id, task_id, account_id, actor_key, state, |
| + spec_json, spec_sha256, vm_ref, launched_t, deadline_t, drain_t, stop_t, epoch, stop_requested_t, stop_proof_json |
| + FROM jobs WHERE attempt_id = ?`, attempt).Scan(&j.attempt, &j.launchID, &j.task, &j.account, &j.actor, &j.state, |
| + &j.specJSON, &j.specSHA, &j.ref, &j.launchedT, &j.deadlineT, &j.drainT, &j.stopT, &j.epoch, &j.stopRequested, &j.stopProof) |
| + switch { |
| + case errors.Is(err, sql.ErrNoRows): |
| + return jobRow{}, false, nil |
| + case err != nil: |
| + return jobRow{}, false, fmt.Errorf("hostedctl: read job %s: %w", attempt, err) |
| + } |
| + return j, true, nil |
| +} |
| + |
| +// view is the JobView of j at controller time now. |
| +func (j jobRow) view(now T) JobView { |
| + return JobView{ |
| + AttemptID: j.attempt, LaunchID: j.launchID, State: j.state, |
| + VMRef: isolatedjob.Ref(j.ref.String), Epoch: j.epoch, |
| + DeadlineIn: until(now, T(j.deadlineT)), DrainIn: until(now, T(j.drainT)), StopIn: until(now, T(j.stopT)), |
| + } |
| +} |
| + |
| +// until is how long from now to at, or zero once at has passed. |
| +func until(now, at T) time.Duration { |
| + if at <= now { |
| + return 0 |
| + } |
| + return time.Duration(at - now) |
| +} |
diff --git a/internal/hostedctl/launch_test.go b/internal/hostedctl/launch_test.go| new file mode 100644 |
| index 00000000..1761226c |
| --- /dev/null |
| +++ b/internal/hostedctl/launch_test.go |
| @@ -0,0 +1,646 @@ |
| +package hostedctl |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "database/sql" |
| + "encoding/json" |
| + "errors" |
| + "path/filepath" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/hostedwire" |
| + "amadan.net/oficina/equipo/internal/isolatedjob" |
| + "amadan.net/oficina/equipo/internal/isolatedjob/isolatedjobtest" |
| +) |
| + |
| +const ( |
| + imgA = isolatedjob.ImageDigest("sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") |
| + imgB = isolatedjob.ImageDigest("sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") |
| + imgOther = isolatedjob.ImageDigest("sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc") |
| + |
| + // testCode is the instance code every test request carries. It must |
| + // never appear in an audit row, an error or a JobView. |
| + testCode = "code-SECRET-4f2a9c" |
| +) |
| + |
| +var ( |
| + instKey = hostedwire.VerifyKey{Role: hostedwire.RoleInstance} |
| + opKey = hostedwire.VerifyKey{Role: hostedwire.RoleOperator} |
| +) |
| + |
| +// launchEnv is one controller over a fresh store and a fake provider, with a |
| +// passing network audit just run. |
| +type launchEnv struct { |
| + t *testing.T |
| + ctx context.Context |
| + path string |
| + clk *isolatedjobtest.FakeClock |
| + fake *isolatedjob.Fake |
| + run isolatedjob.Runner // what the controller calls; the fake unless a test wraps it |
| + cfg Config |
| + store *Store |
| + c *Controller |
| +} |
| + |
| +func newLaunchEnv(t *testing.T) *launchEnv { |
| + t.Helper() |
| + clk := isolatedjobtest.NewFakeClock(testWall) |
| + fake := isolatedjob.NewFake(clk, isolatedjob.SpikeLimits()) |
| + e := &launchEnv{ |
| + t: t, ctx: context.Background(), path: filepath.Join(t.TempDir(), "hosted.db"), |
| + clk: clk, fake: fake, run: fake, |
| + cfg: Config{Enabled: true, Images: map[isolatedjob.ImageDigest]bool{imgA: true, imgB: true}}, |
| + } |
| + e.store = openStore(t, e.path, clk) |
| + e.newController() |
| + e.audit() |
| + return e |
| +} |
| + |
| +// newController builds a controller over e.store with e.cfg and e.run. It |
| +// has no network audit until e.audit runs. |
| +func (e *launchEnv) newController() { |
| + e.t.Helper() |
| + c, err := New(e.cfg, Deps{Store: e.store, Runner: e.run, Auditor: e.fake, Alerter: &recordingAlerter{}}) |
| + if err != nil { |
| + e.t.Fatalf("New = %v", err) |
| + } |
| + e.c = c |
| +} |
| + |
| +// audit runs the network audit and wants it to pass. |
| +func (e *launchEnv) audit() { |
| + e.t.Helper() |
| + if err := e.c.RunAudit(e.ctx); err != nil { |
| + e.t.Fatalf("RunAudit = %v, want a pass", err) |
| + } |
| +} |
| + |
| +// reopen closes the store, as a controller that exits, then opens it again |
| +// and builds a new controller over the same fake provider. |
| +func (e *launchEnv) reopen() { |
| + e.t.Helper() |
| + if err := e.store.Close(); err != nil { |
| + e.t.Fatalf("Close = %v", err) |
| + } |
| + e.store = openStore(e.t, e.path, e.clk) |
| + e.newController() |
| +} |
| + |
| +func (e *launchEnv) exec(query string, args ...any) { |
| + e.t.Helper() |
| + if err := e.store.Tx(e.ctx, func(tx *sql.Tx) error { |
| + _, err := tx.ExecContext(e.ctx, query, args...) |
| + return err |
| + }); err != nil { |
| + e.t.Fatalf("%s = %v", query, err) |
| + } |
| +} |
| + |
| +// job reads one job row; ok is false when there is none. |
| +func (e *launchEnv) job(attempt string) (jobRow, bool) { |
| + e.t.Helper() |
| + var j jobRow |
| + var found bool |
| + if err := e.store.Tx(e.ctx, func(tx *sql.Tx) error { |
| + var err error |
| + j, found, err = loadJob(e.ctx, tx, attempt) |
| + return err |
| + }); err != nil { |
| + e.t.Fatalf("loadJob(%s) = %v", attempt, err) |
| + } |
| + return j, found |
| +} |
| + |
| +func (e *launchEnv) jobCount() int { |
| + e.t.Helper() |
| + var n int |
| + if err := e.store.Tx(e.ctx, func(tx *sql.Tx) error { |
| + return tx.QueryRowContext(e.ctx, `SELECT count(*) FROM jobs`).Scan(&n) |
| + }); err != nil { |
| + e.t.Fatal(err) |
| + } |
| + return n |
| +} |
| + |
| +// noCodeInAudit fails the test when any audit row holds the instance code. |
| +func (e *launchEnv) noCodeInAudit() { |
| + e.t.Helper() |
| + for _, a := range auditRows(e.t, e.store) { |
| + if strings.Contains(string(a.Actor)+a.Account+a.Task+a.Attempt+a.Action+a.Reason, testCode) { |
| + e.t.Fatalf("audit row %+v holds the instance code", a) |
| + } |
| + } |
| +} |
| + |
| +// lastAudit returns the newest audit row. |
| +func (e *launchEnv) lastAudit() Audit { |
| + e.t.Helper() |
| + rows := auditRows(e.t, e.store) |
| + if len(rows) == 0 { |
| + e.t.Fatal("no audit rows") |
| + } |
| + return rows[len(rows)-1] |
| +} |
| + |
| +func request(attempt string) LaunchRequest { |
| + return LaunchRequest{ |
| + AttemptID: attempt, TaskID: "task-1", Account: "acct-1", |
| + Image: imgA, Size: isolatedjob.SizeSmall, MaxLifetime: 2 * time.Hour, |
| + InstanceCode: testCode, |
| + } |
| +} |
| + |
| +// intentProbe wraps the fake provider. At each Launch it reads the job row |
| +// for the attempt from the store, as the provider is called, and records it. |
| +// Its read waits at most 2 s for the store's one connection, so a |
| +// transaction held across the provider call shows as an error, not a hang. |
| +type intentProbe struct { |
| + *isolatedjob.Fake |
| + store *Store |
| + seen []probeSeen |
| +} |
| + |
| +type probeSeen struct { |
| + spec isolatedjob.LaunchSpec |
| + row jobRow |
| + found bool |
| + err error |
| +} |
| + |
| +func (p *intentProbe) Launch(ctx context.Context, s isolatedjob.LaunchSpec) (isolatedjob.Ref, error) { |
| + rctx, cancel := context.WithTimeout(ctx, 2*time.Second) |
| + defer cancel() |
| + var got probeSeen |
| + got.spec = s |
| + got.err = p.store.Tx(rctx, func(tx *sql.Tx) error { |
| + var err error |
| + got.row, got.found, err = loadJob(rctx, tx, s.AttemptID) |
| + return err |
| + }) |
| + p.seen = append(p.seen, got) |
| + return p.Fake.Launch(ctx, s) |
| +} |
| + |
| +func TestLaunchSavesIntentBeforeProvider(t *testing.T) { |
| + e := newLaunchEnv(t) |
| + probe := &intentProbe{Fake: e.fake, store: e.store} |
| + e.run = probe |
| + e.newController() |
| + e.audit() |
| + e.clk.AdvanceMono(3 * time.Minute) |
| + launchedAt := e.store.Clock().Now() |
| + |
| + q := request("att-1") |
| + v, err := e.c.Launch(e.ctx, "inst-1", instKey, q) |
| + if err != nil { |
| + t.Fatalf("Launch = %v", err) |
| + } |
| + if len(probe.seen) != 1 { |
| + t.Fatalf("provider launches = %d, want 1", len(probe.seen)) |
| + } |
| + seen := probe.seen[0] |
| + if seen.err != nil { |
| + t.Fatalf("reading the store during the provider call = %v; a transaction is held across it", seen.err) |
| + } |
| + if !seen.found { |
| + t.Fatal("the provider was called before the launch intent was saved") |
| + } |
| + r := seen.row |
| + if r.state != JobWaiting || r.ref.Valid || r.actor != "inst-1" || r.task != "task-1" || r.account != "acct-1" { |
| + t.Fatalf("intent during the provider call = state %q ref %v actor %q task %q account %q, want waiting, no ref, inst-1, task-1, acct-1", |
| + r.state, r.ref, r.actor, r.task, r.account) |
| + } |
| + saved, err := decodeSpec(r.specJSON, "att-1") |
| + if err != nil { |
| + t.Fatalf("decode saved spec = %v", err) |
| + } |
| + if saved.AttemptID != seen.spec.AttemptID || saved.Image != seen.spec.Image || saved.Size != seen.spec.Size || |
| + saved.MaxLifetime != seen.spec.MaxLifetime || !bytes.Equal(saved.Bootstrap, seen.spec.Bootstrap) { |
| + t.Fatalf("saved spec %+v differs from the one sent %+v", saved, seen.spec) |
| + } |
| + var boot hostedwire.Bootstrap |
| + if err := json.Unmarshal(seen.spec.Bootstrap, &boot); err != nil { |
| + t.Fatalf("bootstrap is not JSON: %v", err) |
| + } |
| + if boot != (hostedwire.Bootstrap{Version: 1, LaunchID: v.LaunchID, InstanceCode: testCode}) || len(v.LaunchID) < 26 { |
| + t.Fatalf("bootstrap = %+v, want version 1, launch ID %q (26+ characters) and the instance code", boot, v.LaunchID) |
| + } |
| + wantDeadline, wantDrain, wantStop := Deadlines(launchedAt, 2*time.Hour) |
| + if T(r.launchedT) != launchedAt || T(r.deadlineT) != wantDeadline || T(r.drainT) != wantDrain || T(r.stopT) != wantStop { |
| + t.Fatalf("intent times = launched %d deadline %d drain %d stop %d, want %d %d %d %d", |
| + r.launchedT, r.deadlineT, r.drainT, r.stopT, launchedAt, wantDeadline, wantDrain, wantStop) |
| + } |
| + |
| + after, _ := e.job("att-1") |
| + if v.State != JobStarting || v.VMRef == "" || after.state != JobStarting || isolatedjob.Ref(after.ref.String) != v.VMRef { |
| + t.Fatalf("after Launch: view %+v, row state %q ref %v; want starting with the saved ref", v, after.state, after.ref) |
| + } |
| + if v.DeadlineIn != 2*time.Hour || v.DrainIn != 75*time.Minute || v.StopIn != 110*time.Minute { |
| + t.Fatalf("view countdowns = %v %v %v, want 2h 1h15m 1h50m", v.DeadlineIn, v.DrainIn, v.StopIn) |
| + } |
| + if strings.Contains(strings.Join([]string{v.AttemptID, v.LaunchID, v.State, string(v.VMRef)}, " "), testCode) { |
| + t.Fatalf("view %+v holds the instance code", v) |
| + } |
| + e.noCodeInAudit() |
| +} |
| + |
| +func TestLaunchIdempotentOnAttempt(t *testing.T) { |
| + e := newLaunchEnv(t) |
| + first, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")) |
| + if err != nil { |
| + t.Fatalf("first Launch = %v", err) |
| + } |
| + e.clk.AdvanceMono(10 * time.Minute) |
| + e.audit() |
| + second, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")) |
| + if err != nil { |
| + t.Fatalf("second Launch = %v", err) |
| + } |
| + if second.LaunchID != first.LaunchID || second.VMRef != first.VMRef || second.State != JobStarting { |
| + t.Fatalf("second view %+v, want the first's launch ID and ref %+v", second, first) |
| + } |
| + if second.DeadlineIn != first.DeadlineIn-10*time.Minute { |
| + t.Fatalf("second DeadlineIn = %v, want %v: deadlines never move", second.DeadlineIn, first.DeadlineIn-10*time.Minute) |
| + } |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay = %v", err) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 1 { |
| + t.Fatalf("provider launches = %d, want 1", n) |
| + } |
| + if n := e.jobCount(); n != 1 { |
| + t.Fatalf("job rows = %d, want 1", n) |
| + } |
| + if got := e.lastAudit(); got.Action != actionLaunchRepeated || got.Actor != "inst-1" || got.Attempt != "att-1" { |
| + t.Fatalf("last audit = %+v, want a %s row for inst-1 att-1", got, actionLaunchRepeated) |
| + } |
| + e.noCodeInAudit() |
| +} |
| + |
| +func TestLaunchConflictOnChangedRequest(t *testing.T) { |
| + cases := []struct { |
| + name string |
| + by hostedwire.KeyID |
| + change func(*LaunchRequest) |
| + }{ |
| + {"task", "inst-1", func(q *LaunchRequest) { q.TaskID = "task-2" }}, |
| + {"account", "inst-1", func(q *LaunchRequest) { q.Account = "acct-2" }}, |
| + {"image", "inst-1", func(q *LaunchRequest) { q.Image = imgB }}, |
| + {"size", "inst-1", func(q *LaunchRequest) { q.Size = isolatedjob.SizeLarge }}, |
| + {"lifetime", "inst-1", func(q *LaunchRequest) { q.MaxLifetime = 3 * time.Hour }}, |
| + {"instance code", "inst-1", func(q *LaunchRequest) { q.InstanceCode = "code-other" }}, |
| + {"another key", "inst-2", func(*LaunchRequest) {}}, |
| + } |
| + for _, tc := range cases { |
| + t.Run(tc.name, func(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + first, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")) |
| + if err != nil { |
| + t.Fatalf("first Launch = %v", err) |
| + } |
| + before, _ := e.job("att-1") |
| + q := request("att-1") |
| + tc.change(&q) |
| + v, err := e.c.Launch(e.ctx, tc.by, instKey, q) |
| + if !errors.Is(err, isolatedjob.ErrConflict) || v != (JobView{}) { |
| + t.Fatalf("changed Launch = (%+v, %v), want (zero view, ErrConflict)", v, err) |
| + } |
| + if strings.Contains(err.Error(), testCode) || strings.Contains(err.Error(), "code-other") { |
| + t.Fatalf("error %q holds an instance code", err) |
| + } |
| + after, _ := e.job("att-1") |
| + if after != before || after.launchID != first.LaunchID { |
| + t.Fatalf("job changed by a conflicting launch: %+v, want %+v", after, before) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 1 { |
| + t.Fatalf("provider launches = %d, want 1", n) |
| + } |
| + if got := e.lastAudit(); got.Action != actionLaunchRefused || got.Actor != tc.by || got.Attempt != "att-1" { |
| + t.Fatalf("last audit = %+v, want a %s row for %s att-1", got, actionLaunchRefused, tc.by) |
| + } |
| + e.noCodeInAudit() |
| + }) |
| + } |
| +} |
| + |
| +func TestConcurrentLaunchSameAttempt(t *testing.T) { |
| + e := newLaunchEnv(t) |
| + const n = 20 |
| + views := make([]JobView, n) |
| + errs := make([]error, n) |
| + start := make(chan struct{}) |
| + var wg sync.WaitGroup |
| + for i := range n { |
| + wg.Add(1) |
| + go func() { |
| + defer wg.Done() |
| + <-start |
| + views[i], errs[i] = e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")) |
| + }() |
| + } |
| + close(start) |
| + wg.Wait() |
| + |
| + for i, err := range errs { |
| + if err != nil { |
| + t.Fatalf("Launch %d = %v", i, err) |
| + } |
| + } |
| + j, _ := e.job("att-1") |
| + for i, v := range views { |
| + if v.LaunchID != j.launchID { |
| + t.Fatalf("view %d launch ID %q, want the one intent's %q", i, v.LaunchID, j.launchID) |
| + } |
| + if v.VMRef != "" && string(v.VMRef) != j.ref.String { |
| + t.Fatalf("view %d ref %q, want the saved %q", i, v.VMRef, j.ref.String) |
| + } |
| + } |
| + if j.state != JobStarting || !j.ref.Valid { |
| + t.Fatalf("job = state %q ref %v, want starting with a ref", j.state, j.ref) |
| + } |
| + if got := e.jobCount(); got != 1 { |
| + t.Fatalf("job rows = %d, want 1", got) |
| + } |
| + if live := e.fake.LiveByAttempt(); live["att-1"] != 1 || len(live) != 1 { |
| + t.Fatalf("live VMs = %v, want one for att-1", live) |
| + } |
| + if c := e.fake.Calls(isolatedjob.OpLaunch); c != 1 { |
| + t.Fatalf("provider launches = %d, want 1", c) |
| + } |
| +} |
| + |
| +func TestCrashBetweenLaunchAndSave(t *testing.T) { |
| + e := newLaunchEnv(t) |
| + e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultLostReply) |
| + v, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")) |
| + if !errors.Is(err, isolatedjob.ErrLostReply) { |
| + t.Fatalf("Launch with a lost reply = (%+v, %v), want ErrLostReply", v, err) |
| + } |
| + if live := e.fake.LiveByAttempt(); live["att-1"] != 1 { |
| + t.Fatalf("live VMs after the lost reply = %v, want one for att-1", live) |
| + } |
| + if j, ok := e.job("att-1"); !ok || j.state != JobWaiting || j.ref.Valid { |
| + t.Fatalf("job after the lost reply = %+v (found %v), want waiting with no ref", j, ok) |
| + } |
| + |
| + e.reopen() |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay before any audit = %v", err) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 1 { |
| + t.Fatalf("provider launches with no audit since the restart = %d, want 1", n) |
| + } |
| + e.audit() |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay = %v", err) |
| + } |
| + vms, err := e.fake.List(e.ctx) |
| + if err != nil || len(vms) != 1 { |
| + t.Fatalf("provider VMs = %v, %v; want exactly one", vms, err) |
| + } |
| + j, _ := e.job("att-1") |
| + if j.state != JobStarting || j.ref.String != string(vms[0].Ref) { |
| + t.Fatalf("job after Replay = state %q ref %v, want starting with %s", j.state, j.ref, vms[0].Ref) |
| + } |
| + if live := e.fake.LiveByAttempt(); live["att-1"] != 1 || len(live) != 1 { |
| + t.Fatalf("live VMs = %v, want one for att-1", live) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 2 { |
| + t.Fatalf("provider launches = %d, want 2 (the lost one and the replay)", n) |
| + } |
| + if got := e.lastAudit(); got.Action != actionReplayStarted || got.Actor != "" { |
| + t.Fatalf("last audit = %+v, want a %s row by the controller", got, actionReplayStarted) |
| + } |
| + e.noCodeInAudit() |
| +} |
| + |
| +func TestLaunchRefusals(t *testing.T) { |
| + // launchOld launches att-old for by and returns its ref. |
| + launchOld := func(e *launchEnv, by hostedwire.KeyID) { |
| + e.t.Helper() |
| + if _, err := e.c.Launch(e.ctx, by, instKey, request("att-old")); err != nil { |
| + e.t.Fatalf("Launch att-old = %v", err) |
| + } |
| + } |
| + proveStopped := func(e *launchEnv) { |
| + e.exec(`UPDATE jobs SET stop_proof_json = '{"state":"stopped"}' WHERE attempt_id = 'att-old'`) |
| + } |
| + replacing := func(q *LaunchRequest) { q.Replaces = "att-old" } |
| + cases := []struct { |
| + name string |
| + setup func(*launchEnv) |
| + by hostedwire.KeyID |
| + key hostedwire.VerifyKey |
| + edit func(*LaunchRequest) |
| + want error // nil: the launch goes ahead |
| + }{ |
| + {name: "flag off", setup: func(e *launchEnv) { e.cfg.Enabled = false; e.newController(); e.audit() }, want: ErrDisabled}, |
| + {name: "operator role", key: opKey, want: ErrForbidden}, |
| + {name: "no key ID", by: "-", want: ErrForbidden}, |
| + {name: "image not allowed", edit: func(q *LaunchRequest) { q.Image = imgOther }, want: ErrImageNotAllowed}, |
| + {name: "no audit yet", setup: func(e *launchEnv) { e.newController() }, want: ErrNetworkAudit}, |
| + {name: "stale audit", setup: func(e *launchEnv) { e.clk.AdvanceMono(AuditMaxAge + time.Nanosecond) }, want: ErrNetworkAudit}, |
| + {name: "audit exactly 5 min old", setup: func(e *launchEnv) { e.clk.AdvanceMono(AuditMaxAge) }}, |
| + {name: "failing audit", setup: func(e *launchEnv) { |
| + e.fake.SetAudit(isolatedjob.NetworkAudit{ResolverDisabled: true, IngressClosed: true}, nil) |
| + if err := e.c.RunAudit(e.ctx); err == nil { |
| + e.t.Fatal("RunAudit with a route out = nil, want a failure") |
| + } |
| + }, want: ErrNetworkAudit}, |
| + {name: "audit call fails", setup: func(e *launchEnv) { |
| + e.fake.SetAudit(isolatedjob.NetworkAudit{}, errors.New("api down")) |
| + _ = e.c.RunAudit(e.ctx) |
| + }, want: ErrNetworkAudit}, |
| + {name: "empty instance code", edit: func(q *LaunchRequest) { q.InstanceCode = "" }, want: isolatedjob.ErrInvalid}, |
| + {name: "non-ASCII instance code", edit: func(q *LaunchRequest) { q.InstanceCode = testCode + "é" }, want: isolatedjob.ErrInvalid}, |
| + {name: "empty task", edit: func(q *LaunchRequest) { q.TaskID = "" }, want: isolatedjob.ErrInvalid}, |
| + {name: "lifetime within the stop margin", edit: func(q *LaunchRequest) { q.MaxLifetime = StopBefore }, want: isolatedjob.ErrInvalid}, |
| + {name: "live replaced attempt", setup: func(e *launchEnv) { launchOld(e, "inst-1") }, edit: replacing, want: ErrReplacementLive}, |
| + {name: "replaced attempt unknown", edit: replacing, want: ErrReplacementLive}, |
| + {name: "replaced attempt of another key", setup: func(e *launchEnv) { launchOld(e, "inst-2"); proveStopped(e) }, edit: replacing, want: ErrReplacementLive}, |
| + {name: "replaced attempt proven stopped", setup: func(e *launchEnv) { launchOld(e, "inst-1"); proveStopped(e) }, edit: replacing}, |
| + } |
| + for _, tc := range cases { |
| + t.Run(tc.name, func(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + if tc.setup != nil { |
| + tc.setup(e) |
| + } |
| + by, key := tc.by, tc.key |
| + if by == "" { |
| + by = "inst-1" |
| + } else if by == "-" { |
| + by = "" |
| + } |
| + if key.Role == "" { |
| + key = instKey |
| + } |
| + q := request("att-1") |
| + if tc.edit != nil { |
| + tc.edit(&q) |
| + } |
| + callsBefore, rowsBefore := e.fake.Calls(isolatedjob.OpLaunch), e.jobCount() |
| + v, err := e.c.Launch(e.ctx, by, key, q) |
| + if tc.want == nil { |
| + if err != nil || v.State != JobStarting { |
| + t.Fatalf("Launch = (%+v, %v), want it started", v, err) |
| + } |
| + return |
| + } |
| + if !errors.Is(err, tc.want) || v != (JobView{}) { |
| + t.Fatalf("Launch = (%+v, %v), want (zero view, %v)", v, err, tc.want) |
| + } |
| + if strings.Contains(err.Error(), testCode) { |
| + t.Fatalf("error %q holds the instance code", err) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != callsBefore { |
| + t.Fatalf("provider launches = %d, want %d: a refusal calls nothing", n, callsBefore) |
| + } |
| + if n := e.jobCount(); n != rowsBefore { |
| + t.Fatalf("job rows = %d, want %d: a refusal saves no intent", n, rowsBefore) |
| + } |
| + if got := e.lastAudit(); got.Action != actionLaunchRefused || got.Actor != by || got.Attempt != "att-1" { |
| + t.Fatalf("last audit = %+v, want a %s row for %q att-1", got, actionLaunchRefused, by) |
| + } |
| + e.noCodeInAudit() |
| + }) |
| + } |
| +} |
| + |
| +func TestThrottleWaitsThenReplays(t *testing.T) { |
| + e := newLaunchEnv(t) |
| + e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle) |
| + v, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")) |
| + if err != nil || v.State != JobWaiting || v.VMRef != "" || v.LaunchID == "" { |
| + t.Fatalf("throttled Launch = (%+v, %v), want a waiting view with a launch ID and no error", v, err) |
| + } |
| + if live := e.fake.LiveByAttempt(); len(live) != 0 { |
| + t.Fatalf("live VMs after a throttle = %v, want none", live) |
| + } |
| + if got := e.lastAudit(); got.Action != actionLaunchThrottled { |
| + t.Fatalf("last audit = %+v, want %s", got, actionLaunchThrottled) |
| + } |
| + |
| + e.clk.AdvanceMono(time.Minute) |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay = %v", err) |
| + } |
| + j, _ := e.job("att-1") |
| + if j.state != JobStarting || !j.ref.Valid || j.launchID != v.LaunchID { |
| + t.Fatalf("job after Replay = %+v, want starting with a ref and launch ID %s", j, v.LaunchID) |
| + } |
| + if live := e.fake.LiveByAttempt(); live["att-1"] != 1 || len(live) != 1 { |
| + t.Fatalf("live VMs = %v, want one for att-1", live) |
| + } |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("second Replay = %v", err) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 2 { |
| + t.Fatalf("provider launches = %d, want 2: a saved ref is never replayed", n) |
| + } |
| + e.noCodeInAudit() |
| +} |
| + |
| +func TestThrottleThenRefusal(t *testing.T) { |
| + cases := []struct { |
| + name string |
| + refuse func(*launchEnv) |
| + restore func(*launchEnv) // nil when the refusal is permanent |
| + want string |
| + }{ |
| + {"flag off", func(e *launchEnv) { e.c.cfg.Enabled = false }, func(e *launchEnv) { e.c.cfg.Enabled = true }, JobWaiting}, |
| + {"image removed", func(e *launchEnv) { delete(e.c.cfg.Images, imgA) }, func(e *launchEnv) { e.c.cfg.Images[imgA] = true }, JobWaiting}, |
| + {"stale audit", func(e *launchEnv) { e.clk.AdvanceMono(AuditMaxAge + time.Nanosecond) }, func(e *launchEnv) { e.audit() }, JobWaiting}, |
| + {"failing audit", func(e *launchEnv) { |
| + e.fake.SetAudit(isolatedjob.NetworkAudit{ResolverDisabled: true, RouteOutAbsent: true}, nil) |
| + _ = e.c.RunAudit(e.ctx) |
| + }, func(e *launchEnv) { |
| + e.fake.SetAudit(isolatedjob.NetworkAudit{ResolverDisabled: true, IngressClosed: true, RouteOutAbsent: true}, nil) |
| + e.audit() |
| + }, JobWaiting}, |
| + {"stop requested", func(e *launchEnv) { |
| + e.exec(`UPDATE jobs SET stop_requested_t = ?, stop_reason = 'asked' WHERE attempt_id = 'att-1'`, int64(e.store.Clock().Now())) |
| + }, nil, JobAbandoned}, |
| + {"stop time passed", func(e *launchEnv) { |
| + e.clk.AdvanceMono(2*time.Hour - StopBefore) // exactly stop_t |
| + e.audit() |
| + }, nil, JobAbandoned}, |
| + } |
| + for _, tc := range cases { |
| + t.Run(tc.name, func(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle) |
| + if v, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")); err != nil || v.State != JobWaiting { |
| + t.Fatalf("throttled Launch = (%+v, %v), want waiting", v, err) |
| + } |
| + before, _ := e.job("att-1") |
| + tc.refuse(e) |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay = %v", err) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 1 { |
| + t.Fatalf("provider launches = %d, want 1: a failed gate calls nothing", n) |
| + } |
| + j, ok := e.job("att-1") |
| + if !ok || j.state != tc.want || j.ref.Valid || j.specJSON != before.specJSON || j.launchID != before.launchID { |
| + t.Fatalf("job after Replay = %+v (found %v), want it kept, %s, with no ref", j, ok, tc.want) |
| + } |
| + if tc.want == JobAbandoned { |
| + if got := e.lastAudit(); got.Action != actionReplayAbandoned || got.Attempt != "att-1" { |
| + t.Fatalf("last audit = %+v, want %s for att-1", got, actionReplayAbandoned) |
| + } |
| + // Abandoned is final: a later replay with every gate open |
| + // still calls nothing. |
| + e.audit() |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay after abandoning = %v", err) |
| + } |
| + if n := e.fake.Calls(isolatedjob.OpLaunch); n != 1 { |
| + t.Fatalf("provider launches after abandoning = %d, want 1", n) |
| + } |
| + return |
| + } |
| + // A transient refusal keeps the intent for a later replay. |
| + tc.restore(e) |
| + if err := e.c.Replay(e.ctx); err != nil { |
| + t.Fatalf("Replay once the gate passes = %v", err) |
| + } |
| + if j, _ := e.job("att-1"); j.state != JobStarting || !j.ref.Valid { |
| + t.Fatalf("job once the gate passes = state %q ref %v, want starting with a ref", j.state, j.ref) |
| + } |
| + if live := e.fake.LiveByAttempt(); live["att-1"] != 1 { |
| + t.Fatalf("live VMs = %v, want one for att-1", live) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestDeadlines(t *testing.T) { |
| + cases := []struct { |
| + launched T |
| + life time.Duration |
| + deadline, drain, stopTime T |
| + }{ |
| + {0, 8 * time.Hour, T(8 * time.Hour), T(7*time.Hour + 15*time.Minute), T(7*time.Hour + 50*time.Minute)}, |
| + {0, 15 * time.Minute, T(15 * time.Minute), 0, T(5 * time.Minute)}, |
| + {T(time.Hour), 15 * time.Minute, T(75 * time.Minute), T(time.Hour), T(65 * time.Minute)}, |
| + {T(time.Hour), 5 * time.Minute, T(65 * time.Minute), T(time.Hour), T(time.Hour)}, |
| + {T(time.Hour), 0, T(time.Hour), T(time.Hour), T(time.Hour)}, |
| + } |
| + for _, tc := range cases { |
| + d, dr, s := Deadlines(tc.launched, tc.life) |
| + if d != tc.deadline || dr != tc.drain || s != tc.stopTime { |
| + t.Errorf("Deadlines(%v, %v) = (%v, %v, %v), want (%v, %v, %v)", time.Duration(tc.launched), tc.life, |
| + time.Duration(d), time.Duration(dr), time.Duration(s), |
| + time.Duration(tc.deadline), time.Duration(tc.drain), time.Duration(tc.stopTime)) |
| + } |
| + } |
| +} |
diff --git a/internal/hostedctl/states.go b/internal/hostedctl/states.go| new file mode 100644 |
| index 00000000..39aadaad |
| --- /dev/null |
| +++ b/internal/hostedctl/states.go |
| @@ -0,0 +1,16 @@ |
| +package hostedctl |
| + |
| +// Job states, as stored in jobs.state and shown in JobView.State. Every state |
| +// the controller writes is named here; later tasks add theirs here too. |
| +const ( |
| + // JobWaiting: the launch intent is saved and has no VM Ref yet. Replay |
| + // may launch it once its gates pass. |
| + JobWaiting = "waiting" |
| + // JobStarting: the provider answered the launch; the Ref is saved. |
| + JobStarting = "starting" |
| + // JobAbandoned: the intent was given up before any VM Ref was saved (a |
| + // stop was asked for, or its stop time passed). It is never replayed |
| + // again; a VM an earlier lost reply created for it is an orphan for the |
| + // reaper. |
| + JobAbandoned = "abandoned" |
| +) |