hostedctl: leaked-VM reaper and network audit loop
Reap runs one pass: checkpoint, Replay, Refresh, recorded jobs by saved Ref (drain mark, deadline stop, unknown-state count and alert), orphans on a complete List only (10 min grace in controller time, expired at once for sightings before a restart, then a replay, a fresh List and a re-read of saved Refs before the stop), and the network audit with one alert per failing run. Loop runs it every interval; LastReap keeps the last result. New nullable jobs.drain_marked_t; refreshOne records its Get for the unknown count; TestRestartDowntimeExceedsWallDelta gains the orphan clause (R1).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+1,387
−2
docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md+44 −0internal/hostedctl/controller.go+1 −0internal/hostedctl/reaper.go+681 −0internal/hostedctl/reaper_test.go+641 −0internal/hostedctl/refresh.go+1 −0internal/hostedctl/schema/0001_jobs.sql+1 −0internal/hostedctl/stop_test.go+18 −2
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 86G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 86G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.2s
ci-box: codex: fetched and verified in 3.4s
ci-box: codex-code-mode-host: fetched and verified in 1.7s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 10.0s
ci-box: pi: installed and verified in 7.5s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.5s
ci-box: clone deepened in 3.9s
ci-box: file times set from content: 2883 files, 192 directories
ci-box: ready in 17.5s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok amadan.net/oficina/equipo/internal/equipotest 0.250s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
1.2s
+ go list -export -test -tags testbuild -f ./...
1.1s
+ 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 1m23.003s 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.294s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m21.29s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 33.20, cpu waiting 21.74%, memory waiting 0.00%, io waiting 0.52%
--- 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 1m24.449s 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.755s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m22.75s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 33.20, cpu waiting 21.35%, memory waiting 0.00%, io waiting 0.50%
--- 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 1m26.155s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m24.051s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m13.36s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.87s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.82s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 33.90, cpu waiting 20.82%, memory waiting 0.00%, io waiting 0.48%
--- 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 1m20.605s 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.905s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.95s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 20.79s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.59s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.57s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 34.43, cpu waiting 22.00%, 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 1m38.608s 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.819s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m0.25s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.4s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 10.24s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 8.93s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.99s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 30.58, cpu waiting 17.37%, 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 3m13.145s 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 3m11.011s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m47.31s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 24.88s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.85s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 8.29s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.46s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 7.84, cpu waiting 3.66%, 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.104s 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 6.74, cpu waiting 1.37%, memory waiting 0.00%, io waiting 1.98%
--- 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.146s 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 6.74, cpu waiting 0.13%, memory waiting 0.00%, io waiting 2.02%
--- 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 4m32.657s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 4m45.737s 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 4m32.657s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.98s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.93s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.81s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.48s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 7.2s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.20, cpu waiting 0.76%, 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 48.302s 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 47.176s amadan.net/oficina/equipo/internal/runner
receipt: slow test 27.15s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 34.52, cpu waiting 21.10%, memory waiting 0.00%, io waiting 0.92%
--- 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.788s 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.84s amadan.net/oficina/equipo/internal/runner
receipt: slow test 35.83s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 32.44s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.37s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.62s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 34.52, cpu waiting 21.10%, memory waiting 0.00%, io waiting 0.92%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed
receipt: test step 34.889s 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.049s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.27s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.12s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.13s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 25.91, cpu waiting 14.30%, memory waiting 0.00%, io waiting 1.16%
--- shard 12 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-a started 30s late; cpu waiting 27.6%, load 19.37
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed
receipt: test step 1m5.31s 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.457s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.83s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 26.82s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 24.79s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.25s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 22.1s amadan.net/oficina/equipo/internal/equipotest TestAuthorityUsesLiveRoster
machine: 32 CPUs, load 32.63, cpu waiting 18.50%, memory waiting 0.00%, io waiting 0.42%
--- shard 13 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-e started 30s late; cpu waiting 27.6%, load 19.37
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.384s 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 25.91, cpu waiting 11.33%, memory waiting 0.00%, io waiting 1.24%
--- shard 14 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-r started 30s late; cpu waiting 27.6%, load 19.37
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 1m16.595s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m4.458s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 14.38s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 9.95s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 9.88s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 6.85s amadan.net/oficina/equipo/internal/equipotest TestRosterProtectsLastOwner
machine: 32 CPUs, load 26.18, cpu waiting 15.21%, 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 27.6%, load 19.37
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 555ms 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 25.91, cpu waiting 11.33%, memory waiting 0.00%, io waiting 1.24%
--- shard 16 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: plan3test started 30s late; cpu waiting 27.6%, load 19.37
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 591ms 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 25.91, cpu waiting 11.33%, memory waiting 0.00%, io waiting 1.24%
--- shard 17 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: rest started 30s late; cpu waiting 27.6%, load 19.37
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/claude: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: 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 40.878s, over the 15s its record on line 40 allows; reported only, timing fails on CI
receipt: test step 2m18.769s 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 54.784s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 53.409s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 45.275s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 40.878s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 39.84s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 22.04s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 15.77s 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.81s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringMissingModuleCache
machine: 32 CPUs, load 11.15, cpu waiting 5.28%, memory waiting 0.00%, io waiting 0.11%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed
receipt: test step 1m23.259s 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.67s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.34s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 15.16s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.73s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 8.02s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 5.96s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 33.20, cpu waiting 21.35%, memory waiting 0.00%, io waiting 0.50%
--- 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 1m34.848s 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 1m33.042s amadan.net/oficina/equipo/internal/headless
receipt: slow test 26.63s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 23.45s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 14.29s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 10.49s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 8.22s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 32.63, cpu waiting 18.50%, memory waiting 0.00%, io waiting 0.42%
--- 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 1m41.342s 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 1m39.603s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.2s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.44s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 13.09s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 10.31s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.15s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 28.29, cpu waiting 16.26%, 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
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN TestBrowserEmptyExplore
time=2026-11-22T18:33:00.081Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-22T18:33:00.081Z level=INFO msg="startup phase done" phase=state_lock took=269µs
time=2026-11-22T18:33:00.081Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-22T18:33:00.081Z level=INFO msg="startup phase done" phase=claim_roots took=103µs
time=2026-11-22T18:33:00.081Z level=INFO msg="startup phase" phase=sweep
time=2026-11-22T18:33:00.109Z level=INFO msg="startup phase done" phase=sweep took=28.251ms
time=2026-11-22T18:33:00.109Z level=INFO msg="startup phase" phase=credentials
time=2026-11-22T18:33:00.110Z level=INFO msg="startup phase done" phase=credentials took=199µs
time=2026-11-22T18:33:00.110Z level=INFO msg="startup phase" phase=open_state
time=2026-11-22T18:33:00.152Z level=INFO msg="startup phase done" phase=open_state took=42.246ms
time=2026-11-22T18:33:00.152Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-22T18:33:00.154Z level=INFO msg=connecting host=127.0.0.1:34373 protocol=28
time=2026-11-22T18:33:00.155Z level=INFO msg=connected host=127.0.0.1:34373 took=962µs
time=2026-11-22T18:33:00.155Z level=INFO msg="capabilities gathering"
time=2026-11-22T18:33:00.155Z level=INFO msg="capabilities gathered" took=711µs tags=linux,claude,go
time=2026-11-22T18:33:00.156Z level=INFO msg="hello sent" protocol=28
time=2026-11-22T18:33:00.161Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-22T18:33:01.203Z 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.88s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m28.155s
FAIL amadan.net/oficina/equipo/internal/headless 88.470s
receipt: test step 1m29.678s 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 1m28.155s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.42s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.37s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.59s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 10.44s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 7.98s 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 8d91a60ac06e26b9e855f63afd39e6790d692a85 5.88s 33.90
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 30.58, cpu waiting 16.81%, memory waiting 0.00%, io waiting 0.38%
--- shard 22 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-rest: ./internal/equipo
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserPreviewBlocksNavigation)$' ./internal/equipo
receipt: test step 1.092s 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 839ms 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 206ms 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.209s 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 6.74, cpu waiting 1.88%, memory waiting 0.00%, io waiting 1.92%
--- 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 (53s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.41s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.36s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.57s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 10.00s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.77s
+ 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 (64s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 13.05s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 14.46s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 20.80s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 13.33s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (22s)
ok ./internal/headless TestMixedVersions 20.35s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (1s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.77s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin (1s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 36.53, cpu waiting 22.33%, memory waiting 0.00%, io waiting 0.70%
--- 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.674s 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.482s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 182ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 72ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 5.35s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.72s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 310ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 180ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 80ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxToolchain
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.067s 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 280ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 180ms 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 12.04, cpu waiting 4.92%, memory waiting 0.00%, io waiting 1.68%
--- shard 25 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: runner-dead-references started 30s late; cpu waiting 27.6%, load 19.37
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2596 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.582s
machine: 32 CPUs, load 33.09, cpu waiting 20.11%, memory waiting 0.00%, io waiting 0.98%
--- shard 26 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: staticcheck started 30s late; cpu waiting 28.1%, load 19.37
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 25.91, cpu waiting 12.75%, memory waiting 0.00%, io waiting 1.20%
--- shard 27 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: govulncheck started 30s late; cpu waiting 27.6%, load 19.37
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 30.48, cpu waiting 15.63%, memory waiting 0.00%, io waiting 1.12%
--- 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 27.6%, load 19.37
shard 28: make gitleaks
[90m6:32PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m6:32PM[0m [32mINF[0m [1m1125 commits scanned.[0m
[90m6:32PM[0m [32mINF[0m [1mscanned ~61883643 bytes (61.88 MB) in 14.2s[0m
[90m6:32PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 33.09, cpu waiting 20.11%, memory waiting 0.00%, io waiting 0.98%
=== 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.199ms, worst 1.239ms, budget 150ms
perf: GET /api/runner/protocol: median 92µs, worst 110µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 596µs, worst 708µs, budget 150ms
perf: GET /api/v1/accounts: median 438µs, worst 464µs, budget 150ms
perf: GET /api/v1/auth/devices: median 467µs, worst 488µs, budget 150ms
perf: GET /api/v1/budgets: median 514µs, worst 548µs, budget 150ms
perf: GET /api/v1/capabilities: median 255µs, worst 269µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.316ms, worst 1.434ms, budget 150ms
perf: GET /api/v1/connections: median 645µs, worst 682µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 661µs, worst 677µs, budget 150ms
perf: GET /api/v1/conversation: median 1.112ms, worst 1.215ms, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.744ms, worst 1.815ms, budget 150ms
perf: GET /api/v1/coordinator: median 1.976ms, worst 2.088ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 472µs, worst 502µs, budget 150ms
perf: GET /api/v1/journey: median 7.885ms, worst 8.172ms, budget 150ms
perf: GET /api/v1/me: median 454µs, worst 510µs, budget 150ms
perf: GET /api/v1/me/settings: median 551µs, worst 580µs, budget 150ms
perf: GET /api/v1/needs-you: median 7.72ms, worst 7.901ms, budget 150ms
perf: GET /api/v1/notifications: median 1.841ms, worst 1.862ms, budget 150ms
perf: GET /api/v1/onboarding: median 434µs, worst 477µs, budget 150ms
perf: GET /api/v1/people: median 465µs, worst 505µs, budget 150ms
perf: GET /api/v1/playbooks: median 648µs, worst 672µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 573µs, worst 609µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 943µs, worst 954µs, budget 150ms
perf: GET /api/v1/preferences: median 843µs, worst 912µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 502µs, worst 547µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 658µs, worst 698µs, budget 150ms
perf: GET /api/v1/roster: median 522µs, worst 579µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 472µs, worst 531µs, budget 150ms
perf: GET /api/v1/specialists: median 8.715ms, worst 8.924ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 8.464ms, worst 8.613ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 952µs, worst 1.022ms, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.274ms, worst 1.382ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 805µs, worst 885µs, budget 150ms
perf: GET /api/v1/teams: median 477µs, worst 543µs, budget 150ms
perf: GET /api/v1/templates: median 667µs, worst 717µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 509µs, worst 525µs, budget 150ms
perf: GET /auth/callback: median 87µs, worst 110µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.675ms, worst 6.286ms, budget 150ms
perf: GET /auth/verify: median 79µs, worst 114µs, budget 150ms
perf: GET /connections: median 3.958ms, worst 4.163ms, budget 150ms
perf: GET /conversation: median 7.826ms, worst 7.957ms, budget 150ms
perf: GET /conversation/connections: median 263µs, worst 325µs, budget 150ms
perf: GET /conversation/notebook: median 238µs, worst 260µs, budget 150ms
perf: GET /conversation/settings: median 4.251ms, worst 4.375ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 3.94ms, worst 4.093ms, budget 150ms
perf: GET /conversation/settings/connections: median 6.682ms, worst 6.768ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 6.692ms, worst 6.885ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.941ms, worst 4.145ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 4.543ms, worst 4.809ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.712ms, worst 4.861ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.71ms, worst 4.792ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.484ms, worst 3.626ms, budget 150ms
perf: GET /conversation/settings/thinking: median 4.045ms, worst 4.19ms, budget 150ms
perf: GET /housekeeping: median 3.825ms, worst 3.9ms, budget 150ms
perf: GET /invites/new: median 614µs, worst 652µs, budget 150ms
perf: GET /invites/{id}: median 642µs, worst 700µs, budget 150ms
perf: GET /jobs: median 3.438ms, worst 3.492ms, budget 150ms
perf: GET /jobs/{id}: median 4.684ms, worst 4.777ms, budget 150ms
perf: GET /journey: median 12.964ms, worst 15.537ms, budget 150ms
perf: GET /nav/rail: median 3.482ms, worst 3.681ms, budget 150ms
perf: GET /needs-you: median 12.616ms, worst 13.174ms, budget 150ms
perf: GET /onboarding: median 4.474ms, worst 4.603ms, budget 150ms
perf: GET /people: median 3.866ms, worst 3.936ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 5.453ms, worst 5.664ms, budget 150ms
perf: GET /playbooks: median 4.941ms, worst 4.98ms, budget 150ms
perf: GET /playbooks/new: median 5.249ms, worst 5.387ms, budget 150ms
perf: GET /playbooks/{id}: median 4.85ms, worst 4.988ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.709ms, worst 4.781ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 4.049ms, worst 7.286ms, budget 150ms
perf: GET /preferences: median 4.755ms, worst 4.94ms, budget 150ms
perf: GET /preferences/sources/{source}: median 4.485ms, worst 4.559ms, budget 150ms
perf: GET /projects: median 5.645ms, worst 5.78ms, budget 150ms
perf: GET /projects/accounts: median 3.885ms, worst 3.979ms, budget 150ms
perf: GET /projects/new: median 3.922ms, worst 4.049ms, budget 150ms
perf: GET /projects/{id}: median 10.987ms, worst 11.256ms, budget 150ms
perf: GET /projects/{id}/edit: median 4.049ms, worst 4.204ms, budget 150ms
perf: GET /runners/enrol: median 4.894ms, worst 5.069ms, budget 150ms
perf: GET /settings: median 3.632ms, worst 3.7ms, budget 150ms
perf: GET /settings/coordinator: median 6.069ms, worst 9.105ms, budget 150ms
perf: GET /settings/devices: median 3.544ms, worst 3.729ms, budget 150ms
perf: GET /settings/recovery: median 3.682ms, worst 3.769ms, budget 150ms
perf: GET /settings/recovery/release: median 3.744ms, worst 3.848ms, budget 150ms
perf: GET /settings/thinking: median 245µs, worst 264µs, budget 150ms
perf: GET /signin: median 335µs, worst 346µs, budget 150ms
perf: GET /specialists/new: median 3.633ms, worst 3.719ms, budget 150ms
perf: GET /specialists/{key}: median 11.331ms, worst 11.515ms, budget 150ms
perf: GET /specialists/{key}/edit: median 3.83ms, worst 3.969ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 3.956ms, worst 4.003ms, budget 150ms
perf: GET /tasks: median 5.479ms, worst 5.714ms, budget 150ms
perf: GET /tasks/new: median 3.467ms, worst 3.597ms, budget 150ms
perf: GET /tasks/{id}: median 6.085ms, worst 8.669ms, budget 150ms
perf: GET /tasks/{id}/merge: median 5.203ms, worst 5.292ms, budget 150ms
perf: GET /tasks/{id}/move: median 4.965ms, worst 5.061ms, budget 150ms
perf: GET /tasks/{id}/plan: median 6.048ms, worst 6.257ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.579ms, worst 1.637ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 5.595ms, worst 5.714ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 5.07ms, worst 5.278ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4.538ms, worst 4.703ms, budget 150ms
perf: GET /tasks/{id}/thread: median 8.326ms, worst 8.589ms, budget 150ms
perf: GET /team/{specialist}: median 4.424ms, worst 4.495ms, budget 150ms
perf: GET /teams: median 10.529ms, worst 11.158ms, budget 150ms
perf: GET /templates: median 3.54ms, worst 3.574ms, budget 150ms
perf: GET /usage: median 4.418ms, worst 4.483ms, budget 150ms
perf: GET /work: median 3.213ms, worst 3.285ms, budget 150ms
perf: cold boot: median 269ms of [267.604473ms 269.432386ms 273.287203ms], budget 500ms
receipt: test step 33.466s 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 9.211s amadan.net/oficina/equipo/internal/equipotest
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-runner
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-tool-proxy
receipt: slow package 0s amadan.net/oficina/equipo/internal/advice
receipt: slow package 0s amadan.net/oficina/equipo/internal/attach
receipt: slow test 8.35s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 860ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 3.44 GiB in 23031 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 e53639a8..e6d4bf6f 100644 |
| --- a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md |
| +++ b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md |
| @@ -523,3 +523,47 @@ added to states.go. No schema change. |
| | F2e Reopen past the stop time | `^TestResumePastDeadlineRefused$` | `resume_test.go:368: Reopen at the stop time = <nil>, want ErrPastDeadline` | yes, passes | |
| | F2f a pending operation past the stop time left pending | `^TestResumePastDeadlineRefused$` | `resume_test.go:356: job "resuming" at epoch 0, ops [{op-1 pending ...}] ...; want ... [{op-1 failed ...}], 1` | yes, passes | |
| | F3 proof leaves a pending resume (writeProof's call removed) | `^TestResumeFailedByProof$` | all three subtests (ends on its own, gone confirmed, instance stops it): `resume_test.go:517: job "stopped" at epoch 0, ops [{op-1 pending ...}] ...; want "stopped" at 0, [{op-1 failed ...}], 1` | yes, passes | |
| + |
| +## Task 13 |
| + |
| +The reaper pass and loop in `internal/hostedctl/reaper.go`, tests in `reaper_test.go`. `Reap(ctx) |
| +(ReapReport, error)`, `Loop(ctx, every) error`, `LastReap() (ReapResult, bool)`, `ReapInterval`, |
| +`OrphanGrace`, `UnknownAlertPasses = 3`, alert kinds `orphan_stopped`, `unknown_state`, |
| +`audit_failed`. A pass, one at a time: checkpoint; Replay; Refresh; recorded jobs by saved Ref |
| +(drain mark, deadline stop with reason `deadline`, unknown count and alert); orphans on a complete |
| +List only (`unmatched_vms`, 10 min grace in controller time, expired at once for sightings before a |
| +restart, then a recheck: audit if none fresh, Replay, List, re-read saved Refs, stop with reason |
| +`orphan`, no proof); the network audit (one alert per failing run). Alerts are queued and delivered |
| +at the end of the pass; one the Alerter refuses stays queued and its error joins the pass error. |
| + |
| +Shared-file edits: `schema/0001_jobs.sql` adds nullable `jobs.drain_marked_t` (rulings); |
| +`controller.go` adds the `reap reapState` field; `refresh.go` adds one line in `refreshOne` after |
| +the Get (`c.reap.observeGet`) so the reaper counts unknown reads without a second Get; |
| +`stop_test.go` extends `TestRestartDowntimeExceedsWallDelta` with the orphan clause (R1): an orphan |
| +seen just before the exit is stopped on the first pass after it. Its wall move is now 5 min (was 10 |
| +min) so the controller time since the sighting stays under the grace. |
| + |
| +- RED (compile-only stubs): all 14 tests fail, e.g. `reaper_test.go:165: Reap = (..., stub)`, |
| + `reaper_test.go:546: pass 0: audit_failed alerts [], want one`, `stop_test.go:765: Reap = (..., stub)`. |
| +- GREEN: `go test ./internal/hostedctl -run 'TestReap|TestOrphanGrace|TestUnknownStateRetried|TestFailingAudit' -count=1` |
| + ok 0.47 s (that pattern misses `TestIncompleteListSkipsOrphansOnly` and |
| + `TestDeadlineEnforcedDuringIncompleteLists`; with them and `TestRestartDowntimeExceedsWallDelta` |
| + ok 0.74 s, and ok under `-race`); whole package `-v` ok 3.25 s, 83 tests, load average 3 to 6; |
| + vet, gofmt, staticcheck v0.7.0 clean; `make budget` within; dead-reference scan 0 failures. |
| +- Mutations ran with `go test -overlay` over mutated copies under `$TMPDIR`; the tree was never |
| + edited, so "restored" is the unmutated run passing. |
| + |
| +| Mutation | Test | Observed failure | Restored | |
| +| --- | --- | --- | --- | |
| +| M1 orphans processed from an incomplete List | `^TestIncompleteListSkipsOrphansOnly$` | `reaper_test.go:304: pass with an incomplete list: report {Skipped:false ... OrphansSeen:1 OrphansStopped:1 ...}, want orphans skipped` | yes, passes | |
| +| M2 deadline stops skipped on an incomplete List | `^TestDeadlineEnforcedDuringIncompleteLists$` | `reaper_test.go:348: at the stop time: report {Skipped:true ... Stopped:0 ...} requested {0 false} reason { false}; want a deadline stop` | yes, passes | |
| +| M3 recheck dropped (stop without the fresh List and table read) | `^TestReapRechecksOwnership$` | `reaper_test.go:237: pass at 10 min: report {... Replayed:1 ... OrphansSeen:2 OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| +| M3b whole recheck dropped (no replay, List or table read) | `^TestReapRechecksOwnership$` | `reaper_test.go:237: pass at 10 min: report {... Replayed:0 ... OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| +| M4 wall time for the grace | `^TestReaperUnderRollback$` | `reaper_test.go:434: at 10 min of elapsed time, wall clock 2 h back: report {... OrphansSeen:1 OrphansStopped:0 ...}, want the orphan stopped` | yes, passes | |
| +| M5 no restart clause in the grace | `^(TestOrphanGraceExpiresAfterRestart\|TestRestartDowntimeExceedsWallDelta)$` | `reaper_test.go:469: first pass after the restart: report {... OrphansSeen:2 OrphansStopped:0 ...}, want one orphan stopped and one replayed`; `stop_test.go:805: first reaper pass after the restart: report {... OrphansStopped:0 ...}, want the orphan stopped` | yes, passes | |
| +| M6 abandoned intents' VMs not reaped (no expiry while a Ref-less job is unproven) | `^TestReapStopsAbandonedIntentVM$` | `reaper_test.go:269: at 10 min: report {... OrphansSeen:1 OrphansStopped:0 ...}, want the abandoned intent's VM stopped` | yes, passes | |
| +| M7 audit_failed alerted every pass | `^TestFailingAuditBlocksLaunchAndAlertsOnce$` | `reaper_test.go:546: pass 1: audit_failed alerts [{Kind:audit_failed ...} {Kind:audit_failed ...}], want one` | yes, passes | |
| +| M8 no stop re-sent on an unknown read (refreshOne) | `^TestUnknownStateRetriedAndAlerted$` | `reaper_test.go:521: pass 1: provider stops [vm-0001], want 2, all to vm-0001` | yes, passes | |
| +| M9 unknown_state alerted every pass | `^TestUnknownStateRetriedAndAlerted$` | `reaper_test.go:524: pass 4: unknown_state alerts [... 4 alerts ...], want 2` | yes, passes | |
| +| M10 orphans before the replay | `^TestReapReplaysIntentFirst$` | `reaper_test.go:152: report {... Replayed:1 ... OrphansSeen:1 ...}, want one replayed and no orphans` | yes, passes | |
| +| M11 recheck without running a missing audit | `^TestOrphanGraceExpiresAfterRestart$` | `reaper_test.go:469: first pass after the restart: report {... Replayed:0 ... OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
diff --git a/internal/hostedctl/controller.go b/internal/hostedctl/controller.go| index 2ed8cf1e..2126dff0 100644 |
| --- a/internal/hostedctl/controller.go |
| +++ b/internal/hostedctl/controller.go |
| @@ -47,6 +47,7 @@ type Controller struct { |
| audit auditState // the last network audit result (audit.go) |
| rebased rebasedSet // jobs re-based after a restart (refresh.go) |
| attempts attemptLocks // per-attempt locks (attemptlock.go) |
| + reap reapState // the reaper's in-memory state (reaper.go) |
| } |
| // New builds a controller. It refuses a nil dependency, including a nil |
diff --git a/internal/hostedctl/reaper.go b/internal/hostedctl/reaper.go| new file mode 100644 |
| index 00000000..156a377d |
| --- /dev/null |
| +++ b/internal/hostedctl/reaper.go |
| @@ -0,0 +1,681 @@ |
| +package hostedctl |
| + |
| +import ( |
| + "context" |
| + "database/sql" |
| + "errors" |
| + "fmt" |
| + "sync" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/isolatedjob" |
| +) |
| + |
| +// ReapInterval is how often Loop runs a reaper pass unless told otherwise |
| +// (spec §10). |
| +const ReapInterval = 60 * time.Second |
| + |
| +// OrphanGrace is how long, in controller time, a listed VM that matches no |
| +// job is left alone before the reaper rechecks its ownership and stops it |
| +// (spec §10). After a restart, an orphan first seen before Open has used up |
| +// its grace: the downtime is unknown, so the time since the sighting is too. |
| +const OrphanGrace = 10 * time.Minute |
| + |
| +// UnknownAlertPasses is how many reaper passes in a row a job's VM must read |
| +// unknown before the reaper raises an unknown_state alert for it. |
| +const UnknownAlertPasses = 3 |
| + |
| +// Alert kinds the reaper raises. Details name VMs, attempts, tasks and |
| +// accounts, never credentials. |
| +const ( |
| + // AlertOrphanStopped: the reaper stopped a VM that matched no job. |
| + AlertOrphanStopped = "orphan_stopped" |
| + // AlertUnknownState: a job's VM read unknown on UnknownAlertPasses |
| + // passes in a row. Raised once per run of unknown reads. |
| + AlertUnknownState = "unknown_state" |
| + // AlertAuditFailed: the network audit failed, so launches are refused. |
| + // Raised once per run of failed audits. |
| + AlertAuditFailed = "audit_failed" |
| +) |
| + |
| +// Stop reasons the reaper sends to the provider. |
| +const ( |
| + reasonDeadline = "deadline" // the job reached its stop time |
| + reasonOrphan = "orphan" // the VM matched no job |
| +) |
| + |
| +// Audit actions written by the reaper. |
| +const ( |
| + actionDeadlineDrain = "deadline_drain" |
| + actionOrphanSeen = "orphan_seen" |
| + actionOrphanStopped = "orphan_stopped" |
| + actionOrphanStopFailed = "orphan_stop_failed" |
| + actionUnknownState = "unknown_state" |
| + actionNetworkAuditFailed = "network_audit_failed" |
| + actionNetworkAuditPassed = "network_audit_passed" |
| +) |
| + |
| +// ReapReport counts what one reaper pass did. |
| +type ReapReport struct { |
| + // Skipped: orphan processing was skipped because a List was incomplete |
| + // or failed: the whole step on the first List, or the stops on the |
| + // recheck's List. The pass's other steps ran. |
| + Skipped bool |
| + // Replayed: launch intents that gained a VM Ref in the pass's replays. |
| + Replayed int |
| + // Drained: jobs given their drain mark in this pass. |
| + Drained int |
| + // Stopped: jobs whose deadline stop this pass asked for. |
| + Stopped int |
| + // OrphansSeen: listed VMs, not terminal, that match no job's saved Ref. |
| + OrphansSeen int |
| + // OrphansStopped: orphans the provider was asked to stop in this pass. |
| + OrphansStopped int |
| + // Unknown: jobs whose VM read unknown in this pass's Refresh. |
| + Unknown int |
| +} |
| + |
| +// ReapResult is one finished pass: its report, its error and the controller |
| +// time at which it finished. |
| +type ReapResult struct { |
| + Report ReapReport |
| + Err error |
| + At T |
| +} |
| + |
| +// reapState is the reaper's in-memory state. A restart starts it afresh: |
| +// alerts held back by an Alerter failure are lost, and running episodes |
| +// alert again. |
| +type reapState struct { |
| + pass sync.Mutex // held for a whole pass: one pass at a time |
| + |
| + mu sync.Mutex |
| + observed map[string]bool // attempt -> Refresh's latest Get read unknown; absent: no answer since the last pass |
| + last ReapResult |
| + ran bool |
| + |
| + // Used only under pass. |
| + unknownRuns map[string]int // attempt -> passes in a row its VM read unknown |
| + unknownAlerted map[string]bool // attempt -> its current run was alerted |
| + orphanAlerted map[isolatedjob.Ref]bool |
| + auditFailing bool // an audit_failed episode is open |
| + queued []Alert // alerts not yet delivered, oldest first |
| +} |
| + |
| +// observeGet records what Refresh's Get said about attempt's VM, for the |
| +// reaper's unknown-state count. A state that is neither live nor terminal |
| +// counts as unknown; a not-found is a known answer; any other error says |
| +// nothing. |
| +func (s *reapState) observeGet(attempt string, st isolatedjob.State, err error) { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + if s.observed == nil { |
| + s.observed = map[string]bool{} |
| + } |
| + switch { |
| + case err == nil: |
| + s.observed[attempt] = !st.Live() && !st.Terminal() |
| + case errors.Is(err, isolatedjob.ErrNotFound): |
| + s.observed[attempt] = false |
| + default: |
| + delete(s.observed, attempt) |
| + } |
| +} |
| + |
| +// takeObserved returns and forgets the latest observation for attempt. ok |
| +// is false when there is none. |
| +func (s *reapState) takeObserved(attempt string) (unknown, ok bool) { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + unknown, ok = s.observed[attempt] |
| + delete(s.observed, attempt) |
| + return unknown, ok |
| +} |
| + |
| +// raise queues a for delivery at the end of the pass. The caller holds pass. |
| +func (s *reapState) raise(a Alert) { s.queued = append(s.queued, a) } |
| + |
| +// LastReap returns the last finished pass, and false when none has finished. |
| +// Task 15's metrics read it. |
| +func (c *Controller) LastReap() (ReapResult, bool) { |
| + c.reap.mu.Lock() |
| + defer c.reap.mu.Unlock() |
| + return c.reap.last, c.reap.ran |
| +} |
| + |
| +// Loop runs Reap at once and then every `every` (ReapInterval when every is |
| +// not positive) until ctx is done, one pass at a time. A pass's error never |
| +// ends the loop; it is kept for LastReap, and the last pass's error is |
| +// returned when ctx is done. |
| +func (c *Controller) Loop(ctx context.Context, every time.Duration) error { |
| + if every <= 0 { |
| + every = ReapInterval |
| + } |
| + tick := time.NewTicker(every) |
| + defer tick.Stop() |
| + var last error |
| + for { |
| + if ctx.Err() != nil { |
| + return last |
| + } |
| + _, last = c.Reap(ctx) |
| + select { |
| + case <-ctx.Done(): |
| + return last |
| + case <-tick.C: |
| + } |
| + } |
| +} |
| + |
| +// Reap runs one reaper pass (spec §10). Passes run one at a time. In order: |
| +// |
| +// 1. Checkpoint controller time. A failure ends the pass: the store is |
| +// needed for everything after it. |
| +// 2. Replay launch intents, with their gates (Replay), so a VM a lost |
| +// launch reply made is claimed before anything looks for orphans. |
| +// 3. Refresh. |
| +// 4. Recorded jobs, by their saved Ref, whatever List returns: a job past |
| +// its drain time gets its drain mark (a notice; no pause), a job past |
| +// its stop time gets a deadline stop, and a VM that read unknown is |
| +// counted and, after UnknownAlertPasses passes, alerted (Refresh has |
| +// already sent a requested stop again). See reapJob and trackUnknown. |
| +// 5. Orphans, only on a complete List (reapOrphans): VMs that match no |
| +// job's saved Ref are recorded in unmatched_vms and stopped once |
| +// OrphanGrace has passed and a recheck still finds them unclaimed. |
| +// 6. The network audit (RunAudit). While it fails, launches are refused; |
| +// an audit_failed alert goes out when a run of failures begins. |
| +// |
| +// Then the pass's alerts are delivered. A step's failure, an Alerter's |
| +// included, does not stop the steps after it; the pass returns every |
| +// failure joined, and keeps its result for LastReap. |
| +func (c *Controller) Reap(ctx context.Context) (ReapReport, error) { |
| + c.reap.pass.Lock() |
| + defer c.reap.pass.Unlock() |
| + var rep ReapReport |
| + err := c.reapPass(ctx, &rep) |
| + c.reap.mu.Lock() |
| + c.reap.last, c.reap.ran = ReapResult{Report: rep, Err: err, At: c.store.Clock().Now()}, true |
| + c.reap.mu.Unlock() |
| + return rep, err |
| +} |
| + |
| +func (c *Controller) reapPass(ctx context.Context, rep *ReapReport) error { |
| + if err := c.store.Checkpoint(ctx); err != nil { |
| + return fmt.Errorf("hostedctl: reap: clock checkpoint: %w", err) |
| + } |
| + var errs []error |
| + n, err := c.replayCounted(ctx) |
| + rep.Replayed += n |
| + errs = append(errs, err) |
| + errs = append(errs, c.Refresh(ctx)) |
| + errs = append(errs, c.reapJobs(ctx, rep)) |
| + errs = append(errs, c.reapOrphans(ctx, rep)) |
| + errs = append(errs, c.reapAudit(ctx)) |
| + errs = append(errs, c.sendAlerts(ctx)) |
| + return errors.Join(errs...) |
| +} |
| + |
| +// replayCounted runs Replay when an intent is waiting and returns how many |
| +// of the intents waiting before it hold a VM Ref after it. |
| +func (c *Controller) replayCounted(ctx context.Context) (int, error) { |
| + var waiting []string |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + var err error |
| + waiting, err = textColumn(ctx, tx, `SELECT attempt_id FROM jobs WHERE state = ? AND vm_ref IS NULL`, JobWaiting) |
| + return err |
| + }) |
| + if err != nil || len(waiting) == 0 { |
| + return 0, err |
| + } |
| + rerr := c.Replay(ctx) |
| + n := 0 |
| + err = c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + n = 0 |
| + for _, id := range waiting { |
| + j, found, err := loadJob(ctx, tx, id) |
| + if err != nil { |
| + return err |
| + } |
| + if found && j.ref.Valid { |
| + n++ |
| + } |
| + } |
| + return nil |
| + }) |
| + return n, errors.Join(rerr, err) |
| +} |
| + |
| +// reapJobs is step 4: every job with a saved Ref and no proof, in launch |
| +// order. It reads no List, so an incomplete one never holds up a deadline. |
| +func (c *Controller) reapJobs(ctx context.Context, rep *ReapReport) error { |
| + var ids []string |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + var err error |
| + ids, err = textColumn(ctx, tx, `SELECT attempt_id FROM jobs WHERE vm_ref IS NOT NULL AND stop_proof_json IS NULL |
| + ORDER BY launched_t, attempt_id`) |
| + return err |
| + }) |
| + if err != nil { |
| + return err |
| + } |
| + var errs []error |
| + for _, id := range ids { |
| + if err := ctx.Err(); err != nil { |
| + errs = append(errs, err) |
| + break |
| + } |
| + j, err := c.reapJob(ctx, id, rep) |
| + errs = append(errs, err, c.trackUnknown(ctx, id, j, rep)) |
| + } |
| + c.forgetUnknowns(ids) |
| + return errors.Join(errs...) |
| +} |
| + |
| +// reapJob handles one recorded job under its attempt lock. A job with a stop |
| +// asked for, or proof, is left to Refresh. Otherwise, by controller time: |
| +// |
| +// - at or past its stop time, it gets a stop with the reason "deadline": |
| +// the request is recorded first (requestStop), then the provider stop is |
| +// sent and the VM read (driveStop). Refresh proves it on a later pass; |
| +// - at or past its drain time and not yet marked, drain_marked_t is set |
| +// and audited. This is the notice before the stop; it opens no pause |
| +// generation and leaves the job's state alone. |
| +// |
| +// It returns the job as read, zero when it is gone. |
| +func (c *Controller) reapJob(ctx context.Context, attempt string, rep *ReapReport) (jobRow, error) { |
| + defer c.lockAttempt(attempt)() |
| + var j jobRow |
| + marked, stop := false, false |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + marked, stop = false, false |
| + var found bool |
| + var err error |
| + if j, found, err = loadJob(ctx, tx, attempt); err != nil || !found { |
| + return err |
| + } |
| + if !j.ref.Valid || j.stopProof.Valid || j.stopRequested.Valid { |
| + return nil |
| + } |
| + now := c.store.Clock().Now() |
| + if now >= T(j.stopT) { |
| + stop = true |
| + return nil |
| + } |
| + if now < T(j.drainT) { |
| + return nil |
| + } |
| + res, err := tx.ExecContext(ctx, `UPDATE jobs SET drain_marked_t = ?, revision = revision + 1 |
| + WHERE attempt_id = ? AND drain_marked_t IS NULL`, int64(now), attempt) |
| + if err != nil { |
| + return fmt.Errorf("hostedctl: mark drain of %s: %w", attempt, err) |
| + } |
| + n, err := res.RowsAffected() |
| + if err != nil { |
| + return fmt.Errorf("hostedctl: mark drain of %s: %w", attempt, err) |
| + } |
| + if n == 0 { |
| + return nil // marked on an earlier pass |
| + } |
| + marked = true |
| + return appendAudit(tx, Audit{Account: j.account, Task: j.task, Attempt: attempt, Action: actionDeadlineDrain, |
| + Reason: fmt.Sprintf("drain time reached; VM %s is stopped in %v", j.ref.String, time.Duration(T(j.stopT)-now)), At: now}) |
| + }) |
| + if err != nil { |
| + return j, err |
| + } |
| + if marked { |
| + rep.Drained++ |
| + } |
| + if !stop { |
| + return j, nil |
| + } |
| + r, err := c.requestStop(context.WithoutCancel(ctx), "", attempt, reasonDeadline, false) |
| + if err != nil { |
| + return j, err |
| + } |
| + rep.Stopped++ |
| + if r.proof != nil { |
| + return j, nil |
| + } |
| + if _, err := c.driveStop(ctx, "", r); err != nil && !errors.Is(err, ErrStopPending) && !errors.Is(err, ErrStateUnknown) { |
| + return j, err |
| + } |
| + return j, nil |
| +} |
| + |
| +// trackUnknown counts attempt's run of unknown reads from this pass's |
| +// Refresh. A known state, or a not-found, ends the run. When the run reaches |
| +// UnknownAlertPasses one unknown_state alert is raised and audited; the |
| +// next comes only after a known read ends the run and a new one reaches the |
| +// count. A stop asked for is sent again by Refresh on every unknown read |
| +// (refreshOne), so it is not sent again here. |
| +func (c *Controller) trackUnknown(ctx context.Context, attempt string, j jobRow, rep *ReapReport) error { |
| + unknown, ok := c.reap.takeObserved(attempt) |
| + if !ok { |
| + return nil |
| + } |
| + s := &c.reap |
| + if !unknown { |
| + delete(s.unknownRuns, attempt) |
| + delete(s.unknownAlerted, attempt) |
| + return nil |
| + } |
| + rep.Unknown++ |
| + if s.unknownRuns == nil { |
| + s.unknownRuns, s.unknownAlerted = map[string]int{}, map[string]bool{} |
| + } |
| + s.unknownRuns[attempt]++ |
| + if s.unknownRuns[attempt] < UnknownAlertPasses || s.unknownAlerted[attempt] { |
| + return nil |
| + } |
| + s.unknownAlerted[attempt] = true |
| + then := "no stop has been asked for" |
| + if j.stopRequested.Valid { |
| + then = "its stop is sent again each pass" |
| + } |
| + detail := fmt.Sprintf("VM %s of attempt %s (task %s, account %s) read unknown on %d passes in a row; %s", |
| + j.ref.String, attempt, j.task, j.account, s.unknownRuns[attempt], then) |
| + now := c.store.Clock().Now() |
| + s.raise(Alert{Kind: AlertUnknownState, Detail: detail, At: now}) |
| + return c.store.Tx(context.WithoutCancel(ctx), func(tx *sql.Tx) error { |
| + return appendAudit(tx, Audit{Account: j.account, Task: j.task, Attempt: attempt, Action: actionUnknownState, |
| + Reason: detail, At: now}) |
| + }) |
| +} |
| + |
| +// forgetUnknowns drops the unknown-read runs of attempts no longer in ids |
| +// (proven, or gone) and any observation not taken this pass. |
| +func (c *Controller) forgetUnknowns(ids []string) { |
| + keep := make(map[string]bool, len(ids)) |
| + for _, id := range ids { |
| + keep[id] = true |
| + } |
| + for id := range c.reap.unknownRuns { |
| + if !keep[id] { |
| + delete(c.reap.unknownRuns, id) |
| + delete(c.reap.unknownAlerted, id) |
| + } |
| + } |
| + c.reap.mu.Lock() |
| + clear(c.reap.observed) |
| + c.reap.mu.Unlock() |
| +} |
| + |
| +// orphan is a listed VM that matches no job, with when it was first seen. |
| +type orphan struct { |
| + ref isolatedjob.Ref |
| + firstSeen T |
| +} |
| + |
| +// reapOrphans is step 5. It needs a complete List: an incomplete one (or any |
| +// List error) skips this step alone, with nothing recorded or stopped, even |
| +// if the answer carried VMs. With a complete List, trackOrphans updates |
| +// unmatched_vms, and the orphans whose grace is over go to recheckOrphans. |
| +func (c *Controller) reapOrphans(ctx context.Context, rep *ReapReport) error { |
| + vms, err := c.runner.List(ctx) |
| + if err != nil { |
| + rep.Skipped = true |
| + if errors.Is(err, isolatedjob.ErrIncomplete) { |
| + return nil |
| + } |
| + return fmt.Errorf("hostedctl: reap: list VMs: %w", err) |
| + } |
| + expired, err := c.trackOrphans(context.WithoutCancel(ctx), vms, rep) |
| + if err != nil || len(expired) == 0 { |
| + return err |
| + } |
| + return c.recheckOrphans(ctx, expired, rep) |
| +} |
| + |
| +// trackOrphans records, in one transaction, every listed VM that is not |
| +// terminal (unknown counts as possibly live) and is not a saved Ref of any |
| +// job. That includes a VM made for an intent that was abandoned, which |
| +// never gets a Ref. A first sighting is inserted into unmatched_vms with the |
| +// current controller time and audited; a row whose VM is no longer such a |
| +// VM (gone, terminal or now matched) is deleted. It returns the orphans |
| +// whose grace is over (graceOver), leaving out those already stopping. |
| +func (c *Controller) trackOrphans(ctx context.Context, vms []isolatedjob.Job, rep *ReapReport) ([]orphan, error) { |
| + var expired []orphan |
| + live := map[isolatedjob.Ref]bool{} |
| + err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + expired = expired[:0] |
| + clear(live) |
| + saved, err := savedRefs(ctx, tx) |
| + if err != nil { |
| + return err |
| + } |
| + known, err := unmatchedVMs(ctx, tx) |
| + if err != nil { |
| + return err |
| + } |
| + now := c.store.Clock().Now() |
| + for _, vm := range vms { |
| + if vm.State.Terminal() || saved[vm.Ref] || live[vm.Ref] { |
| + continue |
| + } |
| + live[vm.Ref] = true |
| + first, ok := known[vm.Ref] |
| + if !ok { |
| + first = now |
| + if _, err := tx.ExecContext(ctx, `INSERT INTO unmatched_vms (vm_ref, first_seen_t) VALUES (?, ?)`, |
| + string(vm.Ref), int64(now)); err != nil { |
| + return fmt.Errorf("hostedctl: record unmatched VM %s: %w", vm.Ref, err) |
| + } |
| + if err := appendAudit(tx, Audit{Action: actionOrphanSeen, At: now, Reason: fmt.Sprintf( |
| + "VM %s (%s) matches no job; it is stopped after %v unless a job claims it", vm.Ref, vm.State, OrphanGrace)}); err != nil { |
| + return err |
| + } |
| + } |
| + if vm.State != isolatedjob.StateStopping && c.graceOver(first, now) { |
| + expired = append(expired, orphan{ref: vm.Ref, firstSeen: first}) |
| + } |
| + } |
| + for ref := range known { |
| + if live[ref] { |
| + continue |
| + } |
| + if _, err := tx.ExecContext(ctx, `DELETE FROM unmatched_vms WHERE vm_ref = ?`, string(ref)); err != nil { |
| + return fmt.Errorf("hostedctl: forget unmatched VM %s: %w", ref, err) |
| + } |
| + } |
| + return nil |
| + }) |
| + if err != nil { |
| + return nil, err |
| + } |
| + rep.OrphansSeen = len(live) |
| + for ref := range c.reap.orphanAlerted { |
| + if !live[ref] { |
| + delete(c.reap.orphanAlerted, ref) |
| + } |
| + } |
| + return expired, nil |
| +} |
| + |
| +// graceOver reports whether an orphan first seen at first has had its |
| +// grace at controller time now: OrphanGrace has passed, or it was first |
| +// seen before this process opened the store after a restart, as the |
| +// downtime since is unknown. |
| +func (c *Controller) graceOver(first, now T) bool { |
| + return now-first >= T(OrphanGrace) || (c.store.Restarted() && first < c.store.OpenedAt()) |
| +} |
| + |
| +// recheckOrphans makes sure each orphan whose grace is over is still |
| +// nobody's before it is stopped: |
| +// |
| +// 1. Replay again, so a waiting intent whose lost launch reply made the VM |
| +// claims it through its client token. A controller with no fresh |
| +// passing audit (a fresh one has none until step 6) runs the audit |
| +// first, or Replay would create nothing and so claim nothing. |
| +// 2. List again. It must be complete; otherwise nothing is stopped. |
| +// 3. Read the saved Refs again, after the List, so a Ref saved while the |
| +// List ran is seen. |
| +// |
| +// Only an orphan still listed, not terminal, not stopping and still |
| +// unmatched is stopped (stopOrphan). |
| +func (c *Controller) recheckOrphans(ctx context.Context, expired []orphan, rep *ReapReport) error { |
| + if c.audit.check(c.store.Clock().Now()) != nil { |
| + _ = c.RunAudit(ctx) // a failure is reported and alerted by step 6 |
| + } |
| + n, rerr := c.replayCounted(ctx) |
| + rep.Replayed += n |
| + vms, err := c.runner.List(ctx) |
| + if err != nil { |
| + rep.Skipped = true |
| + if errors.Is(err, isolatedjob.ErrIncomplete) { |
| + return rerr |
| + } |
| + return errors.Join(rerr, fmt.Errorf("hostedctl: reap: list VMs for the ownership recheck: %w", err)) |
| + } |
| + var saved map[isolatedjob.Ref]bool |
| + if err := c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + var err error |
| + saved, err = savedRefs(ctx, tx) |
| + return err |
| + }); err != nil { |
| + return errors.Join(rerr, err) |
| + } |
| + listed := make(map[isolatedjob.Ref]isolatedjob.State, len(vms)) |
| + for _, vm := range vms { |
| + listed[vm.Ref] = vm.State |
| + } |
| + errs := []error{rerr} |
| + for _, o := range expired { |
| + st, ok := listed[o.ref] |
| + if !ok || st.Terminal() || st == isolatedjob.StateStopping || saved[o.ref] { |
| + continue |
| + } |
| + errs = append(errs, c.stopOrphan(ctx, o, rep)) |
| + } |
| + return errors.Join(errs...) |
| +} |
| + |
| +// stopOrphan sends the provider stop for an orphan, with the reason |
| +// "orphan", then audits it and raises one orphan_stopped alert per VM. No |
| +// job owns the VM, so no proof is recorded. A failed stop call is audited |
| +// and returned; the next pass rechecks and sends it again. |
| +func (c *Controller) stopOrphan(ctx context.Context, o orphan, rep *ReapReport) error { |
| + now := c.store.Clock().Now() |
| + why := fmt.Sprintf("matched no job for %v", time.Duration(now-o.firstSeen)) |
| + if now-o.firstSeen < T(OrphanGrace) { |
| + why = "matched no job since before the controller restarted (downtime unknown, so its grace counts as over)" |
| + } |
| + perr := c.runner.Stop(ctx, o.ref, reasonOrphan) |
| + rec := context.WithoutCancel(ctx) |
| + if perr != nil && !errors.Is(perr, isolatedjob.ErrNotFound) { |
| + aerr := c.auditReaper(rec, actionOrphanStopFailed, |
| + fmt.Sprintf("VM %s %s; the provider stop call failed and is sent again next pass", o.ref, why)) |
| + return errors.Join(fmt.Errorf("hostedctl: reap: stop orphan VM %s: %w", o.ref, perr), aerr) |
| + } |
| + rep.OrphansStopped++ |
| + reason := fmt.Sprintf("VM %s %s and was still unclaimed after a replay and a fresh list; provider stop sent", o.ref, why) |
| + if !c.reap.orphanAlerted[o.ref] { |
| + if c.reap.orphanAlerted == nil { |
| + c.reap.orphanAlerted = map[isolatedjob.Ref]bool{} |
| + } |
| + c.reap.orphanAlerted[o.ref] = true |
| + c.reap.raise(Alert{Kind: AlertOrphanStopped, Detail: reason, At: now}) |
| + } |
| + return c.auditReaper(rec, actionOrphanStopped, reason) |
| +} |
| + |
| +// reapAudit is step 6: RunAudit, which records the result the launch gates |
| +// read. When a run of failures begins it audits the failure and raises one |
| +// audit_failed alert; the first pass after the run ends audits that. |
| +// A failing audit is returned. An audit cut short by ctx starts no run. |
| +func (c *Controller) reapAudit(ctx context.Context) error { |
| + err := c.RunAudit(ctx) |
| + rec := context.WithoutCancel(ctx) |
| + switch { |
| + case err == nil && !c.reap.auditFailing: |
| + return nil |
| + case err == nil: |
| + c.reap.auditFailing = false |
| + return c.auditReaper(rec, actionNetworkAuditPassed, "network audit passes again; launches may go ahead") |
| + case c.reap.auditFailing || ctx.Err() != nil: |
| + return err |
| + } |
| + c.reap.auditFailing = true |
| + c.reap.raise(Alert{Kind: AlertAuditFailed, At: c.store.Clock().Now(), |
| + Detail: "network audit failed; launches are refused until it passes: " + err.Error()}) |
| + return errors.Join(err, c.auditReaper(rec, actionNetworkAuditFailed, "launches refused: "+err.Error())) |
| +} |
| + |
| +// sendAlerts delivers the queued alerts in order. One the Alerter refuses |
| +// stays queued for the next pass, and its error is returned. |
| +func (c *Controller) sendAlerts(ctx context.Context) error { |
| + var errs []error |
| + keep := c.reap.queued[:0] |
| + for _, a := range c.reap.queued { |
| + if err := c.alerter.Alert(ctx, a); err != nil { |
| + keep = append(keep, a) |
| + errs = append(errs, fmt.Errorf("hostedctl: deliver %s alert: %w", a.Kind, err)) |
| + } |
| + } |
| + clear(c.reap.queued[len(keep):]) |
| + c.reap.queued = keep |
| + return errors.Join(errs...) |
| +} |
| + |
| +// auditReaper writes one audit row by the controller about no attempt. |
| +func (c *Controller) auditReaper(ctx context.Context, action, reason string) error { |
| + return c.store.Tx(ctx, func(tx *sql.Tx) error { |
| + return appendAudit(tx, Audit{Action: action, Reason: reason, At: c.store.Clock().Now()}) |
| + }) |
| +} |
| + |
| +// savedRefs reads every VM Ref saved on a job, proven or not. |
| +func savedRefs(ctx context.Context, tx *sql.Tx) (map[isolatedjob.Ref]bool, error) { |
| + ids, err := textColumn(ctx, tx, `SELECT vm_ref FROM jobs WHERE vm_ref IS NOT NULL`) |
| + if err != nil { |
| + return nil, err |
| + } |
| + out := make(map[isolatedjob.Ref]bool, len(ids)) |
| + for _, r := range ids { |
| + out[isolatedjob.Ref(r)] = true |
| + } |
| + return out, nil |
| +} |
| + |
| +// unmatchedVMs reads unmatched_vms. |
| +func unmatchedVMs(ctx context.Context, tx *sql.Tx) (map[isolatedjob.Ref]T, error) { |
| + rows, err := tx.QueryContext(ctx, `SELECT vm_ref, first_seen_t FROM unmatched_vms`) |
| + if err != nil { |
| + return nil, fmt.Errorf("hostedctl: read unmatched VMs: %w", err) |
| + } |
| + defer rows.Close() |
| + out := map[isolatedjob.Ref]T{} |
| + for rows.Next() { |
| + var ref string |
| + var first int64 |
| + if err := rows.Scan(&ref, &first); err != nil { |
| + return nil, fmt.Errorf("hostedctl: read unmatched VMs: %w", err) |
| + } |
| + out[isolatedjob.Ref(ref)] = T(first) |
| + } |
| + if err := rows.Err(); err != nil { |
| + return nil, fmt.Errorf("hostedctl: read unmatched VMs: %w", err) |
| + } |
| + return out, nil |
| +} |
| + |
| +// textColumn runs a query returning one text column and collects it. |
| +func textColumn(ctx context.Context, tx *sql.Tx, query string, args ...any) ([]string, error) { |
| + rows, err := tx.QueryContext(ctx, query, args...) |
| + if err != nil { |
| + return nil, fmt.Errorf("hostedctl: reap: query: %w", err) |
| + } |
| + defer rows.Close() |
| + var out []string |
| + for rows.Next() { |
| + var s string |
| + if err := rows.Scan(&s); err != nil { |
| + return nil, fmt.Errorf("hostedctl: reap: query: %w", err) |
| + } |
| + out = append(out, s) |
| + } |
| + if err := rows.Err(); err != nil { |
| + return nil, fmt.Errorf("hostedctl: reap: query: %w", err) |
| + } |
| + return out, nil |
| +} |
diff --git a/internal/hostedctl/reaper_test.go b/internal/hostedctl/reaper_test.go| new file mode 100644 |
| index 00000000..eb52f6c4 |
| --- /dev/null |
| +++ b/internal/hostedctl/reaper_test.go |
| @@ -0,0 +1,641 @@ |
| +package hostedctl |
| + |
| +import ( |
| + "context" |
| + "database/sql" |
| + "errors" |
| + "fmt" |
| + "slices" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/isolatedjob" |
| +) |
| + |
| +// reap runs one reaper pass and wants it to succeed. |
| +func (e *launchEnv) reap() ReapReport { |
| + e.t.Helper() |
| + r, err := e.c.Reap(e.ctx) |
| + if err != nil { |
| + e.t.Fatalf("Reap = (%+v, %v)", r, err) |
| + } |
| + return r |
| +} |
| + |
| +// alerts returns the alerts of kind the current controller has delivered. |
| +func (e *launchEnv) alerts(kind string) []Alert { |
| + e.t.Helper() |
| + var out []Alert |
| + for _, a := range e.c.alerter.(*recordingAlerter).got { |
| + if a.Kind == kind { |
| + out = append(out, a) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// unmatched reads unmatched_vms: each Ref with its first_seen_t. |
| +func (e *launchEnv) unmatched() map[isolatedjob.Ref]T { |
| + e.t.Helper() |
| + out := map[isolatedjob.Ref]T{} |
| + if err := e.store.Tx(e.ctx, func(tx *sql.Tx) error { |
| + rows, err := tx.QueryContext(e.ctx, `SELECT vm_ref, first_seen_t FROM unmatched_vms`) |
| + if err != nil { |
| + return err |
| + } |
| + defer rows.Close() |
| + for rows.Next() { |
| + var ref string |
| + var at int64 |
| + if err := rows.Scan(&ref, &at); err != nil { |
| + return err |
| + } |
| + out[isolatedjob.Ref(ref)] = T(at) |
| + } |
| + return rows.Err() |
| + }); err != nil { |
| + e.t.Fatalf("read unmatched_vms = %v", err) |
| + } |
| + return out |
| +} |
| + |
| +// drainMark reads attempt's drain_marked_t. |
| +func (e *launchEnv) drainMark(attempt string) sql.NullInt64 { |
| + e.t.Helper() |
| + var m sql.NullInt64 |
| + if err := e.store.Tx(e.ctx, func(tx *sql.Tx) error { |
| + return tx.QueryRowContext(e.ctx, `SELECT drain_marked_t FROM jobs WHERE attempt_id = ?`, attempt).Scan(&m) |
| + }); err != nil { |
| + e.t.Fatalf("read drain_marked_t of %s = %v", attempt, err) |
| + } |
| + return m |
| +} |
| + |
| +// plant adds a running VM no job owns and returns its Ref. |
| +func (e *launchEnv) plant(name string) isolatedjob.Ref { |
| + return e.fake.Plant(isolatedjob.LaunchSpec{AttemptID: name}) |
| +} |
| + |
| +// lostLaunch launches attempt with its provider reply lost: the provider |
| +// makes the VM, the intent stays waiting with no Ref. It returns the VM's |
| +// Ref, read from the provider. |
| +func (e *launchEnv) lostLaunch(attempt string) isolatedjob.Ref { |
| + e.t.Helper() |
| + before := map[isolatedjob.Ref]bool{} |
| + vms, _ := e.fake.List(e.ctx) |
| + for _, vm := range vms { |
| + before[vm.Ref] = true |
| + } |
| + e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultLostReply) |
| + if _, err := e.c.Launch(e.ctx, "inst-1", instKey, request(attempt)); !errors.Is(err, ErrProviderLaunch) { |
| + e.t.Fatalf("Launch(%s) with a lost reply = %v, want ErrProviderLaunch", attempt, err) |
| + } |
| + if j, _ := e.job(attempt); j.state != JobWaiting || j.ref.Valid { |
| + e.t.Fatalf("%s after a lost reply: state %q ref %v; want waiting with no ref", attempt, j.state, j.ref) |
| + } |
| + vms, _ = e.fake.List(e.ctx) |
| + for _, vm := range vms { |
| + if !before[vm.Ref] { |
| + return vm.Ref |
| + } |
| + } |
| + e.t.Fatalf("the lost launch of %s made no VM", attempt) |
| + return "" |
| +} |
| + |
| +// wantStops fails the test unless the provider stops so far are want. |
| +func (e *launchEnv) wantStops(want ...isolatedjob.Ref) { |
| + e.t.Helper() |
| + if got := e.fake.StopsIssued(); !slices.Equal(got, want) { |
| + e.t.Fatalf("provider stops = %v, want %v", got, want) |
| + } |
| +} |
| + |
| +// partialList wraps the provider. While armed, List returns everything the |
| +// provider holds together with ErrIncomplete, as an adapter that stopped |
| +// paging part way might: an incomplete answer may still carry VMs, and none |
| +// of them may be acted on. |
| +type partialList struct { |
| + *isolatedjob.Fake |
| + mu sync.Mutex |
| + armed int |
| +} |
| + |
| +func (p *partialList) incomplete(n int) { |
| + p.mu.Lock() |
| + defer p.mu.Unlock() |
| + p.armed += n |
| +} |
| + |
| +func (p *partialList) List(ctx context.Context) ([]isolatedjob.Job, error) { |
| + vms, err := p.Fake.List(ctx) |
| + p.mu.Lock() |
| + defer p.mu.Unlock() |
| + if err == nil && p.armed > 0 { |
| + p.armed-- |
| + return vms, fmt.Errorf("%w: test stopped paging", isolatedjob.ErrIncomplete) |
| + } |
| + return vms, err |
| +} |
| + |
| +func TestReapReplaysIntentFirst(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + ref := e.lostLaunch("att-1") |
| + |
| + r := e.reap() |
| + if j, _ := e.job("att-1"); !j.ref.Valid || isolatedjob.Ref(j.ref.String) != ref || j.state != JobStarting { |
| + t.Fatalf("att-1 after a pass: ref %v state %q; want %s claimed by the replay, starting", j.ref, j.state, ref) |
| + } |
| + if r.Replayed != 1 || r.OrphansSeen != 0 || r.OrphansStopped != 0 { |
| + t.Fatalf("report %+v, want one replayed and no orphans", r) |
| + } |
| + if u := e.unmatched(); len(u) != 0 { |
| + t.Fatalf("unmatched_vms = %v; the intent's VM was taken for an orphan before the replay", u) |
| + } |
| + e.wantStops() |
| +} |
| + |
| +func TestReapStopsOrphanAfterTenMinutes(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + stray := e.plant("stray-1") |
| + |
| + r := e.reap() |
| + seen := e.store.Clock().Now() |
| + if r.OrphansSeen != 1 || r.OrphansStopped != 0 { |
| + t.Fatalf("first pass: report %+v, want one orphan seen and none stopped", r) |
| + } |
| + if u := e.unmatched(); len(u) != 1 || u[stray] != seen { |
| + t.Fatalf("unmatched_vms = %v, want %s first seen at %d", u, stray, seen) |
| + } |
| + if !e.hasAudit("", "", actionOrphanSeen, string(stray)) { |
| + t.Fatal("no orphan_seen audit row") |
| + } |
| + |
| + e.clk.AdvanceMono(OrphanGrace - time.Second) |
| + if r := e.reap(); r.OrphansSeen != 1 || r.OrphansStopped != 0 { |
| + t.Fatalf("at 9 min 59 s: report %+v, want the orphan seen and not stopped", r) |
| + } |
| + e.wantStops() |
| + |
| + e.clk.AdvanceMono(time.Second) |
| + if r := e.reap(); r.OrphansStopped != 1 { |
| + t.Fatalf("at 10 min: report %+v, want the orphan stopped", r) |
| + } |
| + e.wantStops(stray) |
| + if a := e.alerts(AlertOrphanStopped); len(a) != 1 { |
| + t.Fatalf("orphan_stopped alerts = %+v, want one", a) |
| + } |
| + if !e.hasAudit("", "", actionOrphanStopped, string(stray)) { |
| + t.Fatal("no orphan_stopped audit row") |
| + } |
| + |
| + // Stopping, then stopped: no second stop or alert, and the row goes once |
| + // the VM is terminal. |
| + if r := e.reap(); r.OrphansStopped != 0 { |
| + t.Fatalf("pass with the orphan stopping: report %+v, want no second stop", r) |
| + } |
| + e.fake.Tick() |
| + if r := e.reap(); r.OrphansSeen != 0 { |
| + t.Fatalf("pass with the orphan stopped: report %+v, want no orphan", r) |
| + } |
| + if u := e.unmatched(); len(u) != 0 { |
| + t.Fatalf("unmatched_vms after the orphan stopped = %v, want empty", u) |
| + } |
| + e.wantStops(stray) |
| + if a := e.alerts(AlertOrphanStopped); len(a) != 1 { |
| + t.Fatalf("orphan_stopped alerts = %+v, want still one", a) |
| + } |
| +} |
| + |
| +func TestReapRechecksOwnership(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + ref := e.lostLaunch("att-1") |
| + stray := e.plant("stray-1") |
| + |
| + // Every pass's own replay is throttled, so the intent's VM stays |
| + // unlinked and looks like an orphan for the whole grace. Passes run each |
| + // minute, so each one's audit keeps the next replay's gate open. |
| + for i := 0; i <= 10; i++ { |
| + if i > 0 { |
| + e.clk.AdvanceMono(time.Minute) |
| + } |
| + e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle) |
| + r := e.reap() |
| + if i < 10 { |
| + if r.OrphansSeen != 2 || r.OrphansStopped != 0 || r.Replayed != 0 { |
| + t.Fatalf("pass %d: report %+v, want two orphans seen, none stopped, none replayed", i, r) |
| + } |
| + continue |
| + } |
| + // At 10 min the recheck replays again (no throttle this time), and |
| + // the intent claims its VM before anything is stopped. |
| + if r.OrphansStopped != 1 || r.Replayed != 1 { |
| + t.Fatalf("pass at 10 min: report %+v, want one orphan stopped and one replayed", r) |
| + } |
| + } |
| + e.wantStops(stray) |
| + if j, _ := e.job("att-1"); isolatedjob.Ref(j.ref.String) != ref || j.state != JobStarting { |
| + t.Fatalf("att-1: ref %v state %q; want %s claimed, starting", j.ref, j.state, ref) |
| + } |
| + if e.hasAudit("", "", actionOrphanStopped, string(ref)) { |
| + t.Fatal("the claimed VM was audited as a stopped orphan") |
| + } |
| + e.reap() |
| + if u := e.unmatched(); len(u) != 1 || u[stray] != 0 { |
| + t.Fatalf("unmatched_vms after the claim = %v, want only %s, first seen at 0", u, stray) |
| + } |
| +} |
| + |
| +func TestReapStopsAbandonedIntentVM(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + ref := e.lostLaunch("att-1") |
| + if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "done"); !errors.Is(err, ErrStopPending) { |
| + t.Fatalf("Stop of an intent with no ref = %v, want ErrStopPending", err) |
| + } |
| + if j, _ := e.job("att-1"); j.state != JobAbandoned { |
| + t.Fatalf("att-1 after Stop is %q, want abandoned", j.state) |
| + } |
| + |
| + if r := e.reap(); r.OrphansSeen != 1 { |
| + t.Fatalf("first pass: report %+v, want the abandoned intent's VM seen as an orphan", r) |
| + } |
| + e.clk.AdvanceMono(OrphanGrace) |
| + if r := e.reap(); r.OrphansStopped != 1 { |
| + t.Fatalf("at 10 min: report %+v, want the abandoned intent's VM stopped", r) |
| + } |
| + e.wantStops(ref) |
| + if s := e.stopCols("att-1"); s.proof.Valid { |
| + t.Fatal("att-1 has proof while its VM is still stopping") |
| + } |
| + |
| + // Once the VM is terminal, Refresh's complete List proves the intent. |
| + e.fake.Tick() |
| + e.reap() |
| + if w := e.wireProof("att-1"); w.VMRef != "" || w.State != isolatedjob.StateStopped { |
| + t.Fatalf("proof for att-1 = %+v, want stopped with no ref", w) |
| + } |
| +} |
| + |
| +func TestIncompleteListSkipsOrphansOnly(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + pl := &partialList{Fake: e.fake} |
| + e.run = pl |
| + e.newController() |
| + e.audit() |
| + e.launchWith("att-1", DrainBefore+OrphanGrace) // drain time at 10 min |
| + e.fake.Tick() |
| + stray := e.plant("stray-1") |
| + |
| + if r := e.reap(); r.OrphansSeen != 1 || r.Skipped { |
| + t.Fatalf("first pass: report %+v, want one orphan seen", r) |
| + } |
| + seen := e.unmatched()[stray] |
| + |
| + e.clk.AdvanceMono(OrphanGrace) |
| + pl.incomplete(1) |
| + r := e.reap() |
| + if !r.Skipped || r.OrphansStopped != 0 { |
| + t.Fatalf("pass with an incomplete list: report %+v, want orphans skipped", r) |
| + } |
| + e.wantStops() |
| + if u := e.unmatched(); len(u) != 1 || u[stray] != seen { |
| + t.Fatalf("unmatched_vms after an incomplete list = %v, want %s still first seen at %d", u, stray, seen) |
| + } |
| + // The other steps ran. |
| + if r.Drained != 1 || !e.drainMark("att-1").Valid { |
| + t.Fatalf("pass with an incomplete list: report %+v, drain mark %v; want att-1 drained", r, e.drainMark("att-1")) |
| + } |
| + if err := e.c.audit.check(e.store.Clock().Now()); err != nil { |
| + t.Fatalf("audit after the pass = %v, want a fresh pass", err) |
| + } |
| + |
| + e.clk.AdvanceMono(time.Minute) |
| + if r := e.reap(); r.Skipped || r.OrphansStopped != 1 { |
| + t.Fatalf("pass with a complete list: report %+v, want the orphan stopped", r) |
| + } |
| + e.wantStops(stray) |
| +} |
| + |
| +func TestDeadlineEnforcedDuringIncompleteLists(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + ref := e.launchWith("att-1", time.Hour) |
| + e.fake.Tick() |
| + stopT := T(e.stopCols("att-1").stop) |
| + e.clk.AdvanceMono(time.Duration(stopT-e.store.Clock().Now()) - time.Minute) |
| + |
| + for i := range 3 { |
| + e.fake.Inject(isolatedjob.OpList, isolatedjob.FaultIncompleteList) |
| + r := e.reap() |
| + if !r.Skipped { |
| + t.Fatalf("pass %d: report %+v, want orphans skipped", i, r) |
| + } |
| + s := e.stopCols("att-1") |
| + switch i { |
| + case 0: |
| + if r.Stopped != 0 || s.requested.Valid { |
| + t.Fatalf("a minute before the stop time: report %+v requested %v; want no stop", r, s.requested) |
| + } |
| + e.wantStops() |
| + case 1: |
| + if r.Stopped != 1 || !s.requested.Valid || s.reason.String != reasonDeadline { |
| + t.Fatalf("at the stop time: report %+v requested %v reason %v; want a deadline stop", r, s.requested, s.reason) |
| + } |
| + e.wantStops(ref) |
| + case 2: |
| + if w := e.wireProof("att-1"); w.VMRef != ref || w.State != isolatedjob.StateStopped || s.state != JobStopped { |
| + t.Fatalf("after the stop: proof %+v state %q; want stopped %s", w, s.state, ref) |
| + } |
| + } |
| + e.clk.AdvanceMono(time.Minute) |
| + e.fake.Tick() |
| + } |
| +} |
| + |
| +func TestReapDrainsThenStops(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + ref := e.launchWith("att-1", time.Hour) |
| + e.fake.Tick() |
| + s := e.stopCols("att-1") |
| + to := func(at int64) { e.clk.AdvanceMono(time.Duration(T(at) - e.store.Clock().Now())) } |
| + |
| + to(s.drain - int64(time.Second)) |
| + if r := e.reap(); r.Drained != 0 || e.drainMark("att-1").Valid { |
| + t.Fatalf("a second before the drain time: report %+v mark %v; want no drain", r, e.drainMark("att-1")) |
| + } |
| + to(s.drain) |
| + if r := e.reap(); r.Drained != 1 || r.Stopped != 0 { |
| + t.Fatalf("at the drain time: report %+v, want one drained, none stopped", r) |
| + } |
| + if m := e.drainMark("att-1"); !m.Valid || m.Int64 != s.drain { |
| + t.Fatalf("drain_marked_t = %v, want %d", m, s.drain) |
| + } |
| + if !e.hasAudit("", "att-1", actionDeadlineDrain, "") { |
| + t.Fatal("no deadline_drain audit row") |
| + } |
| + // The mark is a notice only: no pause generation, no state change. |
| + if p := e.pauseCols("att-1"); p.state != JobRunning || p.gen != 0 { |
| + t.Fatalf("after the drain mark: state %q generation %d; want running, 0", p.state, p.gen) |
| + } |
| + if r := e.reap(); r.Drained != 0 { |
| + t.Fatalf("second pass past the drain time: report %+v, want no second drain", r) |
| + } |
| + |
| + to(s.stop - int64(time.Second)) |
| + if r := e.reap(); r.Stopped != 0 { |
| + t.Fatalf("a second before the stop time: report %+v, want no stop", r) |
| + } |
| + e.wantStops() |
| + to(s.stop) |
| + if r := e.reap(); r.Stopped != 1 { |
| + t.Fatalf("at the stop time: report %+v, want one stopped", r) |
| + } |
| + e.wantStops(ref) |
| + if c := e.stopCols("att-1"); !c.requested.Valid || c.reason.String != reasonDeadline { |
| + t.Fatalf("after the deadline stop: requested %v reason %v; want %s", c.requested, c.reason, reasonDeadline) |
| + } |
| + if !e.hasAudit("", "att-1", actionStopRequested, reasonDeadline) { |
| + t.Fatal("no stop_requested audit row by the controller") |
| + } |
| + if r := e.reap(); r.Stopped != 0 { |
| + t.Fatalf("pass after the deadline stop: report %+v, want no second request", r) |
| + } |
| + e.fake.Tick() |
| + e.reap() |
| + if w := e.wireProof("att-1"); w.VMRef != ref || w.State != isolatedjob.StateStopped { |
| + t.Fatalf("proof = %+v, want stopped %s", w, ref) |
| + } |
| +} |
| + |
| +func TestReaperUnderRollback(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + stray := e.plant("stray-1") |
| + e.reap() |
| + seen := e.unmatched()[stray] |
| + |
| + // Five minutes in, the wall clock goes back two hours. |
| + e.clk.AdvanceMono(5 * time.Minute) |
| + e.clk.SetWall(testWall.Add(-2 * time.Hour)) |
| + e.reap() |
| + e.clk.AdvanceMono(5*time.Minute - time.Second) |
| + if r := e.reap(); r.OrphansStopped != 0 { |
| + t.Fatalf("at 9 min 59 s of elapsed time: report %+v, want no stop", r) |
| + } |
| + e.clk.AdvanceMono(time.Second) |
| + if r := e.reap(); r.OrphansStopped != 1 { |
| + t.Fatalf("at 10 min of elapsed time, wall clock 2 h back: report %+v, want the orphan stopped", r) |
| + } |
| + e.wantStops(stray) |
| + if got := e.store.Clock().Now() - seen; got != T(OrphanGrace) { |
| + t.Fatalf("controller time since the sighting = %v, want %v", time.Duration(got), OrphanGrace) |
| + } |
| +} |
| + |
| +func TestOrphanGraceExpiresAfterRestart(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + stray := e.plant("stray-1") |
| + ref := e.lostLaunch("att-1") |
| + e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle) // this pass's replay |
| + if r := e.reap(); r.OrphansSeen != 2 || r.Replayed != 0 { |
| + t.Fatalf("first pass: report %+v, want two orphans seen, none replayed", r) |
| + } |
| + seen := e.unmatched() |
| + |
| + // 30 min of real downtime; the wall clock says 2 min. |
| + e.clk.AdvanceMono(time.Minute) |
| + e.down() |
| + e.clk.AdvanceMono(30 * time.Minute) |
| + e.clk.SetWall(testWall.Add(2 * time.Minute)) |
| + e.up() |
| + e.clk.AdvanceMono(time.Second) |
| + if got := e.store.Clock().Now() - seen[stray]; got >= T(OrphanGrace) { |
| + t.Fatalf("controller time since the sighting = %v; the test needs it under the grace", time.Duration(got)) |
| + } |
| + |
| + // The new controller has no audit yet. Both sightings predate the |
| + // restart, so their grace has run out; the recheck still applies: the |
| + // waiting intent claims its VM, and only the stray is stopped. |
| + r := e.reap() |
| + if r.OrphansStopped != 1 || r.Replayed != 1 { |
| + t.Fatalf("first pass after the restart: report %+v, want one orphan stopped and one replayed", r) |
| + } |
| + e.wantStops(stray) |
| + if j, _ := e.job("att-1"); isolatedjob.Ref(j.ref.String) != ref { |
| + t.Fatalf("att-1 ref %v, want %s claimed by the recheck", j.ref, ref) |
| + } |
| + |
| + // A VM first seen after the restart gets the full grace. |
| + late := e.plant("stray-2") |
| + e.reap() |
| + e.clk.AdvanceMono(OrphanGrace - time.Second) |
| + e.reap() |
| + e.wantStops(stray) |
| + e.clk.AdvanceMono(time.Second) |
| + e.reap() |
| + e.wantStops(stray, late) |
| +} |
| + |
| +func TestUnknownStateRetriedAndAlerted(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + ref1 := e.launchWith("att-1", 2*time.Hour) |
| + e.launchWith("att-2", 2*time.Hour) |
| + e.fake.Tick() |
| + if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "done"); !errors.Is(err, ErrStopPending) { |
| + t.Fatalf("Stop = %v, want ErrStopPending", err) |
| + } |
| + e.wantStops(ref1) |
| + stops := 1 |
| + |
| + // unknown is how many of att-1, att-2 (in that order) read unknown. |
| + pass := func(n, unknown, wantAlerts int) { |
| + t.Helper() |
| + for range unknown { |
| + e.fake.Inject(isolatedjob.OpGet, isolatedjob.FaultUnknownState) |
| + } |
| + e.clk.AdvanceMono(ReapInterval) |
| + r := e.reap() |
| + if r.Unknown != unknown { |
| + t.Fatalf("pass %d: report %+v, want %d unknown", n, r, unknown) |
| + } |
| + if unknown > 0 { |
| + stops++ // att-1 has a stop asked for: sent again |
| + } |
| + got := e.fake.StopsIssued() |
| + if len(got) != stops || slices.ContainsFunc(got, func(r isolatedjob.Ref) bool { return r != ref1 }) { |
| + t.Fatalf("pass %d: provider stops %v, want %d, all to %s", n, got, stops, ref1) |
| + } |
| + if a := e.alerts(AlertUnknownState); len(a) != wantAlerts { |
| + t.Fatalf("pass %d: unknown_state alerts %+v, want %d", n, a, wantAlerts) |
| + } |
| + } |
| + pass(1, 2, 0) |
| + pass(2, 2, 0) |
| + pass(3, 2, 2) // three in a row: one alert for each job |
| + pass(4, 2, 2) // once per episode |
| + pass(5, 0, 2) // a known state ends both episodes |
| + pass(6, 1, 2) |
| + pass(7, 1, 2) |
| + pass(8, 1, 3) // a new episode for att-1 |
| + if !e.hasAudit("", "att-1", actionUnknownState, "") { |
| + t.Fatal("no unknown_state audit row for att-1") |
| + } |
| +} |
| + |
| +func TestFailingAuditBlocksLaunchAndAlertsOnce(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + bad := isolatedjob.NetworkAudit{IngressClosed: true, RouteOutAbsent: true} // resolver on |
| + good := isolatedjob.NetworkAudit{ResolverDisabled: true, IngressClosed: true, RouteOutAbsent: true} |
| + |
| + e.fake.SetAudit(bad, nil) |
| + for i := range 2 { |
| + if _, err := e.c.Reap(e.ctx); err == nil { |
| + t.Fatalf("pass %d with a failing audit = nil, want the audit failure", i) |
| + } |
| + if a := e.alerts(AlertAuditFailed); len(a) != 1 { |
| + t.Fatalf("pass %d: audit_failed alerts %+v, want one", i, a) |
| + } |
| + if _, err := e.c.Launch(e.ctx, "inst-1", instKey, request(fmt.Sprintf("att-%d", i))); !errors.Is(err, ErrNetworkAudit) { |
| + t.Fatalf("Launch during a failing audit = %v, want ErrNetworkAudit", err) |
| + } |
| + } |
| + if !e.hasAudit("", "", actionNetworkAuditFailed, "resolver enabled") { |
| + t.Fatal("no network_audit_failed audit row") |
| + } |
| + |
| + e.fake.SetAudit(good, nil) |
| + e.reap() |
| + if !e.hasAudit("", "", actionNetworkAuditPassed, "") { |
| + t.Fatal("no network_audit_passed audit row when the episode ended") |
| + } |
| + if v, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-ok")); err != nil || v.VMRef == "" { |
| + t.Fatalf("Launch after the audit passed = (%+v, %v), want a VM", v, err) |
| + } |
| + |
| + e.fake.SetAudit(bad, nil) |
| + if _, err := e.c.Reap(e.ctx); err == nil { |
| + t.Fatal("pass with the audit failing again = nil") |
| + } |
| + if a := e.alerts(AlertAuditFailed); len(a) != 2 { |
| + t.Fatalf("audit_failed alerts after a second episode = %+v, want two", a) |
| + } |
| +} |
| + |
| +// An alert the Alerter refuses is kept and sent on a later pass; the |
| +// pass's other steps still run. |
| +func TestReapAlertRetriedAfterAlerterError(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + rec := e.c.alerter.(*recordingAlerter) |
| + stray := e.plant("stray-1") |
| + e.reap() |
| + e.clk.AdvanceMono(OrphanGrace) |
| + down := errors.New("pager down") |
| + rec.fail = down |
| + r, err := e.c.Reap(e.ctx) |
| + if !errors.Is(err, down) || r.OrphansStopped != 1 { |
| + t.Fatalf("pass with the alerter down = (%+v, %v), want the orphan stopped and the alerter error", r, err) |
| + } |
| + e.wantStops(stray) |
| + rec.fail = nil |
| + e.reap() |
| + if a := e.alerts(AlertOrphanStopped); len(a) != 1 { |
| + t.Fatalf("orphan_stopped alerts after the alerter came back = %+v, want one", a) |
| + } |
| +} |
| + |
| +// countingList signals every List call, so a test can watch Loop's passes. |
| +type countingList struct { |
| + *isolatedjob.Fake |
| + calls chan struct{} |
| +} |
| + |
| +func (c *countingList) List(ctx context.Context) ([]isolatedjob.Job, error) { |
| + select { |
| + case c.calls <- struct{}{}: |
| + default: |
| + } |
| + return c.Fake.List(ctx) |
| +} |
| + |
| +func TestReapLoopRunsPassesUntilDone(t *testing.T) { |
| + t.Parallel() |
| + e := newLaunchEnv(t) |
| + cl := &countingList{Fake: e.fake, calls: make(chan struct{}, 1)} |
| + e.run = cl |
| + e.newController() |
| + e.plant("stray-1") |
| + |
| + ctx, cancel := context.WithCancel(e.ctx) |
| + done := make(chan error, 1) |
| + go func() { done <- e.c.Loop(ctx, time.Millisecond) }() |
| + for i := range 2 { |
| + select { |
| + case <-cl.calls: |
| + case <-time.After(5 * time.Second): |
| + t.Fatalf("Loop ran %d passes in 5 s, want 2", i) |
| + } |
| + } |
| + cancel() |
| + select { |
| + case <-done: |
| + case <-time.After(5 * time.Second): |
| + t.Fatal("Loop did not return after its context was cancelled") |
| + } |
| + if _, ok := e.c.LastReap(); !ok { |
| + t.Fatal("LastReap after two passes reports none finished") |
| + } |
| + if u := e.unmatched(); len(u) != 1 { |
| + t.Fatalf("unmatched_vms after Loop's passes = %v, want the orphan recorded", u) |
| + } |
| +} |
diff --git a/internal/hostedctl/refresh.go b/internal/hostedctl/refresh.go| index 278f40fd..5722646f 100644 |
| --- a/internal/hostedctl/refresh.go |
| +++ b/internal/hostedctl/refresh.go |
| @@ -179,6 +179,7 @@ func (c *Controller) refreshOne(ctx context.Context, attempt string) error { |
| before := c.store.Clock().Now() |
| job, gerr := c.runner.Get(ctx, ref) |
| at := c.store.Clock().Now() |
| + c.reap.observeGet(attempt, job.State, gerr) // for the reaper's unknown-state count |
| rec := context.WithoutCancel(ctx) |
| switch { |
| case errors.Is(gerr, isolatedjob.ErrNotFound): |
diff --git a/internal/hostedctl/schema/0001_jobs.sql b/internal/hostedctl/schema/0001_jobs.sql| index e9e3f4ba..7ad194a1 100644 |
| --- a/internal/hostedctl/schema/0001_jobs.sql |
| +++ b/internal/hostedctl/schema/0001_jobs.sql |
| @@ -30,6 +30,7 @@ CREATE TABLE jobs ( |
| stop_proof_json TEXT, -- absent until a stop is proven |
| notfound_since_t INTEGER, -- first not-found from Get since the VM was last seen live; absent otherwise |
| last_dispatch_t INTEGER, -- when the last provider launch call for this attempt was about to be made |
| + drain_marked_t INTEGER, -- when the reaper found the job past drain_t; absent until then |
| revision INTEGER NOT NULL DEFAULT 0 |
| ); |
diff --git a/internal/hostedctl/stop_test.go b/internal/hostedctl/stop_test.go| index 74616e5a..e3814ee4 100644 |
| --- a/internal/hostedctl/stop_test.go |
| +++ b/internal/hostedctl/stop_test.go |
| @@ -760,11 +760,15 @@ func TestRestartDowntimeExceedsWallDelta(t *testing.T) { |
| e.launchWith("att-2", life) |
| e.fake.Tick() |
| old2 := e.stopCols("att-2") |
| + // An orphan the reaper first sees just before the exit (ruling R1). |
| + stray := e.plant("stray-1") |
| + e.reap() |
| + strayAt := e.unmatched()[stray] |
| - // Two hours of real downtime; the wall clock reads only 10 min on. |
| + // Two hours of real downtime; the wall clock reads only 5 min on. |
| e.down() |
| e.clk.AdvanceMono(2 * time.Hour) |
| - e.clk.SetWall(testWall.Add(10 * time.Minute)) |
| + e.clk.SetWall(testWall.Add(5 * time.Minute)) |
| e.up() |
| now := e.store.Clock().Now() |
| @@ -791,6 +795,18 @@ func TestRestartDowntimeExceedsWallDelta(t *testing.T) { |
| if got := e.fake.StopsIssued(); !slices.Equal(got, []isolatedjob.Ref{ref1}) { |
| t.Fatalf("provider stops = %v, want only %s", got, ref1) |
| } |
| + |
| + // The orphan's grace is expired too: the controller time since its |
| + // sighting understates the downtime, so the first pass stops it. |
| + if got := e.store.Clock().Now() - strayAt; got >= T(OrphanGrace) { |
| + t.Fatalf("controller time since the orphan's sighting = %v; the test needs it under the grace", time.Duration(got)) |
| + } |
| + if r := e.reap(); r.OrphansStopped != 1 { |
| + t.Fatalf("first reaper pass after the restart: report %+v, want the orphan stopped", r) |
| + } |
| + if got := e.fake.StopsIssued(); !slices.Equal(got, []isolatedjob.Ref{ref1, stray}) { |
| + t.Fatalf("provider stops = %v, want %s then the orphan %s", got, ref1, stray) |
| + } |
| } |
| func TestRestartStopsWhenElapsedUnknown(t *testing.T) { |