oficina / equipo Public

hostedctl: serialise attempts, fence proof after dispatch and restart

Review r1 of Task 11, rulings R18 to R20. A per-attempt lock
(lockAttempt) now covers launch dispatch, Stop, Refresh's reconcile and
re-base, and Ref-less proof, so a Stop waits for a launch in flight and
a live read clears a held not-found before restart handling. A new
last_dispatch_t is written before every provider launch; Ref-less proof
waits two minutes past the stop, the last dispatch and the controller
start, and not-found pairs count only after Open. A pre-restart job
whose Get fails three passes in a row is stopped as elapsed_unknown.
Probes and slow-provider wrappers check transaction boundaries and the
exact start-versus-end timing mutations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev fd6a8ce813b598481428946fe1dbf34559531d95 parent c9b9307
9 files changed, +901 −75
  • docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md +32 −0
  • internal/hostedctl/attemptlock.go +53 −0
  • internal/hostedctl/controller.go +8 −7
  • internal/hostedctl/launch.go +6 −0
  • internal/hostedctl/refresh.go +123 −36
  • internal/hostedctl/refresh_test.go +550 −0
  • internal/hostedctl/schema/0001_jobs.sql +1 −0
  • internal/hostedctl/stop.go +10 −2
  • internal/hostedctl/stop_test.go +118 −30

CI cancelled — superseded by a newer push — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/hosted-runners-1a: Type  Size Avail | ext4   96G   85G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   85G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 2.0s
ci-box: codex: fetched and verified in 3.6s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.9s
ci-box: pi: installed and verified in 7.5s
ci-box: opencode: installed and verified in 1.9s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.9s
ci-box: clone deepened in 3.8s
ci-box: file times set from content: 2877 files, 192 directories
ci-box: ready in 17.3s
=== 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.244s
=== 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  ./...
  0.9s
+ go list -export -test -tags browser,testbuild -f  ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
  0.3s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-11 02:51:11 +0000 UTC

go run github.com/zricethezav/gitleaks/v8@v8.30.1 version
version is set by build process
=== check ===
--- shard 0 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-work: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m21.899s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m20.325s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m20.32s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 32.34, cpu waiting 21.22%, memory waiting 0.00%, io waiting 0.57%
--- shard 1 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-review: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m23.224s 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.464s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m21.46s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 30.95, cpu waiting 20.82%, memory waiting 0.00%, io waiting 0.55%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m24.924s 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.779s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m12.15s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.76s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.87s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 30.95, cpu waiting 20.27%, memory waiting 0.00%, io waiting 0.53%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m19.378s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m17.773s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.07s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 20.58s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.49s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.63s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 32.34, cpu waiting 21.22%, memory waiting 0.00%, io waiting 0.57%
--- shard 4 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-guards: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m37.802s 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.078s amadan.net/oficina/equipo/internal/headless
receipt: slow test 59.93s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.34s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 10.03s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 9.01s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.77s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 26.16, cpu waiting 16.40%, memory waiting 0.00%, io waiting 0.42%
--- 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

amadan: job cancelled — a newer push superseded it
--- 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.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 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 0.55, cpu waiting 0.19%, memory waiting 0.00%, io waiting 2.17%
--- 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.115s 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 0.55, cpu waiting 0.19%, memory waiting 0.00%, io waiting 2.17%
--- 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

amadan: job cancelled — a newer push superseded it
--- shard 9 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-bug: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 47.354s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 46.187s amadan.net/oficina/equipo/internal/runner
receipt: slow test 26.16s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 31.96, cpu waiting 19.92%, memory waiting 0.00%, io waiting 1.01%
--- 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 46.823s 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 44.808s amadan.net/oficina/equipo/internal/runner
receipt: slow test 34.89s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 30.19s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.37s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.53s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 31.96, cpu waiting 19.92%, memory waiting 0.00%, io waiting 1.01%
--- 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.028s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.11s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.27s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.11s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.16s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.63s amadan.net/oficina/equipo/internal/runner TestCoordinatorTransientRefusalKeepsServing
machine: 32 CPUs, load 23.88, cpu waiting 14.34%, memory waiting 0.00%, io waiting 1.23%
--- shard 12 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-a started 30s late; cpu waiting 26.9%, load 16.90
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed

receipt: test step 1m4.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 1m2.206s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.44s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 26.37s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 24.45s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.06s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 21.85s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfiguration
machine: 32 CPUs, load 28.18, cpu waiting 17.50%, memory waiting 0.00%, io waiting 0.45%
--- 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 28.1%, load 16.90
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.38s 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 16.90, cpu waiting 11.40%, memory waiting 0.00%, io waiting 1.31%
--- shard 14 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-r started 30s late; cpu waiting 26.9%, load 16.90
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed

receipt: test step 1m15.818s 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.925s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 14.72s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 12.98s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 9.89s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 9.88s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 6.82s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 24.31, cpu waiting 14.39%, memory waiting 0.00%, io waiting 0.36%
--- shard 15 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-rest started 30s late; cpu waiting 26.9%, load 16.90
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 362ms 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 16.90, cpu waiting 11.40%, memory waiting 0.00%, io waiting 1.31%
--- 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 28.1%, load 16.90
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 576ms 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 16.90, cpu waiting 11.40%, memory waiting 0.00%, io waiting 1.31%
--- shard 17 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: rest started 30s late; cpu waiting 26.9%, load 16.90
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/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/codex: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/containment: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/pi: its inputs changed
--- FAIL amadan.net/oficina/equipo/internal/runner/webread TestTimeouts
=== RUN   TestTimeouts
    fetch_test.go:537: s1: {Source:s1 Origin:paul Parent: URL:https://shop.example.com/slow-body Hops:[{URL:https://shop.example.com/slow-body Address:151.101.1.1 Status:200}] Address:151.101.1.1 Status:200 Type:text/plain Bytes:5 SHA256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 Millis:300 Reason: File:s001.txt}
--- FAIL: TestTimeouts (0.61s)

--- FAIL amadan.net/oficina/equipo/internal/runner/webread (package output)
FAIL
rastrillo-budget/v1 ran 1.29s
FAIL	amadan.net/oficina/equipo/internal/runner/webread	1.297s

budget note: internal/equipo took 45.275s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/equipo/chat took 12.529s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/idtest took 39.84s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/release took 34.981s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/runner/containment took 39.853s, over the 15s its record on line 40 allows; reported only, timing fails on CI

receipt: test step 2m16.725s against a 60s target (the gate's other steps are not in this figure)
receipt: 12 packages ran, 52 cached, 20 without tests, 1 failed
receipt: slow package 52.773s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 51.81s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 45.275s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 39.853s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 39.84s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 22.15s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 14.69s 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 10.02s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringMissingModuleCache
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -v -run '^TestTimeouts$' -count=1 ./internal/runner/webread   (retry, once)
##############################################################################
FLAKE ./internal/runner/webread:TestTimeouts rest fd6a8ce813b598481428946fe1dbf34559531d95 0.61s 10.82
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 10.82, cpu waiting 5.14%, memory waiting 0.00%, io waiting 0.12%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m22.379s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m20.88s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.33s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 15.23s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.53s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.8s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 5.47s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 30.95, cpu waiting 20.82%, memory waiting 0.00%, io waiting 0.55%
--- shard 19 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-work: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m32.92s 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 1m31.081s amadan.net/oficina/equipo/internal/headless
receipt: slow test 25.94s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 23.15s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 14.02s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 10.2s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 8.02s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 28.18, cpu waiting 18.02%, memory waiting 0.00%, io waiting 0.46%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m40.42s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m38.937s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.06s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.2s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 12.95s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 10.18s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.16s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 26.16, cpu waiting 15.38%, memory waiting 0.00%, io waiting 0.39%
--- 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 TestBrowserCopyContinue
=== RUN   TestBrowserCopyContinue
time=2026-11-22T17:54:48.424Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-22T17:54:48.424Z level=INFO msg="startup phase done" phase=state_lock took=393µs
time=2026-11-22T17:54:48.426Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-22T17:54:48.426Z level=INFO msg="startup phase done" phase=claim_roots took=256µs
time=2026-11-22T17:54:48.426Z level=INFO msg="startup phase" phase=sweep
time=2026-11-22T17:54:48.463Z level=INFO msg="startup phase done" phase=sweep took=36.897ms
time=2026-11-22T17:54:48.463Z level=INFO msg="startup phase" phase=credentials
time=2026-11-22T17:54:48.463Z level=INFO msg="startup phase done" phase=credentials took=114µs
time=2026-11-22T17:54:48.463Z level=INFO msg="startup phase" phase=open_state
time=2026-11-22T17:54:48.505Z level=INFO msg="startup phase done" phase=open_state took=41.963ms
time=2026-11-22T17:54:48.506Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-22T17:54:48.507Z level=INFO msg=connecting host=127.0.0.1:33587 protocol=28
time=2026-11-22T17:54:48.508Z level=INFO msg=connected host=127.0.0.1:33587 took=920µs
time=2026-11-22T17:54:48.508Z level=INFO msg="capabilities gathering"
time=2026-11-22T17:54:48.509Z level=INFO msg="capabilities gathered" took=410µs tags=linux,claude,go
time=2026-11-22T17:54:48.511Z level=INFO msg="hello sent" protocol=28
time=2026-11-22T17:54:48.514Z level=INFO msg=welcome protocol=28 role=primary generation=1
    browser_copy_test.go:93: continue did not reach Checks: 0 <nil>
--- FAIL: TestBrowserCopyContinue (1.88s)

--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN   TestBrowserEmptyExplore
time=2026-11-22T17:55:20.028Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-22T17:55:20.028Z level=INFO msg="startup phase done" phase=state_lock took=229µs
time=2026-11-22T17:55:20.028Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-22T17:55:20.028Z level=INFO msg="startup phase done" phase=claim_roots took=183µs
time=2026-11-22T17:55:20.028Z level=INFO msg="startup phase" phase=sweep
time=2026-11-22T17:55:20.059Z level=INFO msg="startup phase done" phase=sweep took=31.044ms
time=2026-11-22T17:55:20.059Z level=INFO msg="startup phase" phase=credentials
time=2026-11-22T17:55:20.059Z level=INFO msg="startup phase done" phase=credentials took=110µs
time=2026-11-22T17:55:20.059Z level=INFO msg="startup phase" phase=open_state
time=2026-11-22T17:55:20.101Z level=INFO msg="startup phase done" phase=open_state took=41.927ms
time=2026-11-22T17:55:20.102Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-22T17:55:20.103Z level=INFO msg=connecting host=127.0.0.1:44307 protocol=28
time=2026-11-22T17:55:20.104Z level=INFO msg=connected host=127.0.0.1:44307 took=896µs
time=2026-11-22T17:55:20.104Z level=INFO msg="capabilities gathering"
time=2026-11-22T17:55:20.105Z level=INFO msg="capabilities gathered" took=556µs tags=linux,claude,go
time=2026-11-22T17:55:20.107Z level=INFO msg="hello sent" protocol=28
time=2026-11-22T17:55:20.114Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-22T17:55:21.105Z 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.81s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m27.574s
FAIL	amadan.net/oficina/equipo/internal/headless	87.875s


receipt: test step 1m29.086s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m27.574s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.08s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.33s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.57s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 10.42s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 7.99s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserCopyContinue$|^TestBrowserEmptyExplore$' -count=1 ./internal/headless   (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserCopyContinue browser-headless-rest fd6a8ce813b598481428946fe1dbf34559531d95 1.88s 29.67
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
##############################################################################
FLAKE ./internal/headless:TestBrowserEmptyExplore browser-headless-rest fd6a8ce813b598481428946fe1dbf34559531d95 5.81s 29.67
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 26.16, cpu waiting 15.87%, memory waiting 0.00%, io waiting 0.40%
--- 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.075s 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 833ms 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 244ms 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.052s 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 3.70, cpu waiting 1.84%, memory waiting 0.00%, io waiting 2.03%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless   (52s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.34s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.35s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.37s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.70s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.78s
+ 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   (71s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 11.77s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 23.44s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 20.51s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 13.33s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless   (21s)
ok ./internal/headless TestMixedVersions 19.73s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks   (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.79s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin   (1s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 32.87, cpu waiting 22.11%, memory waiting 0.00%, io waiting 0.67%
--- 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.176s 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 6.994s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 168ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 61ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 6ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/gotoolchain
receipt: slow test 4.94s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.65s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 310ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 170ms 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.138s 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.811s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 270ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 190ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 4.93, cpu waiting 4.15%, memory waiting 0.00%, io waiting 1.84%
--- 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 28.1%, load 16.90
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2590 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.520s
machine: 32 CPUs, load 31.96, cpu waiting 18.82%, memory waiting 0.00%, io waiting 1.08%
--- shard 26 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: staticcheck started 30s late; cpu waiting 26.9%, load 16.90
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 16.90, cpu waiting 12.83%, memory waiting 0.00%, io waiting 1.27%
--- 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 28.1%, load 16.90
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 23.88, cpu waiting 15.70%, memory waiting 0.00%, io waiting 1.19%
--- shard 28 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: gitleaks started 30s late; cpu waiting 26.9%, load 16.90
shard 28: make gitleaks
5:54PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
5:54PM INF 1121 commits scanned.
5:54PM INF scanned ~61736642 bytes (61.74 MB) in 13.5s
5:54PM INF no leaks found
machine: 32 CPUs, load 31.96, cpu waiting 18.82%, memory waiting 0.00%, io waiting 1.08%
diff --git a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
index 0c6e01b6..c87fc390 100644
--- a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
+++ b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
@@ -410,3 +410,35 @@ GetMicrovm is eventually consistent, so one not-found is no longer proof. New nu
| N4 boundary `>` NotFoundConfirm | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:353: Stop on a not-found 1m0s after the first = (..., ... VM vm-0001 not found once; proof needs a second not-found 1m0s later), want {... State:stopped ObservedAt:120000000000}` | yes, passes |
| N5 gap measured to the second Get's end | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:342: Stop on a second not-found under 1m0s later = <nil>, want ErrStopPending` | yes, passes |
| N6 every not-found restarts the wait | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:345: notfound_since_t moved to 119999999999 on a second not-found, want 60000000000 kept` | yes, passes |
+
+### Task 11 fix round 1 (review r1, rulings R18 to R20)
+
+Changes: `attemptlock.go` (new: `func (c *Controller) lockAttempt(id string) func()`, reference-counted per-attempt mutexes; Controller field `attempts`). The lock is held by Launch's and Replay's `dispatch` (launch.go, one line), by Stop after its refusals, by Refresh's per-job reconcile and re-base, and by each Ref-less proof write; never taken inside a store transaction. Refresh saves a live state (clearing `notfound_since_t`) before any restart handling. New nullable `jobs.last_dispatch_t` (schema/0001_jobs.sql), written by `markDispatch` in its own transaction right before every provider Launch call (launch.go, three lines). Ref-less proof needs a complete List begun ReflessProofDelay after max(stop request, last dispatch, OpenedAt); a not-found pair counts only when the first is after OpenedAt (strictly) after a restart. R20: a pre-restart job whose Get fails is retried; on the RestartGetTries (3rd) failed pass in a row it is stopped as elapsed_unknown (stop request saved first), the Get error still returned. Finding 8 (stop reason limit) deferred, as ruled.
+
+- Order note: in this round the code and the new tests were written together; each test's guard is shown by a mutation that removes the fix (rows below), not by a separate RED run.
+- Task 12's uncommitted files (pause.go, pause_test.go, resume.go, resume_test.go) did not compile while this ran. Every run below used `go test -overlay` mapping them to an empty `package hostedctl` file.
+- GREEN: `go test ./internal/hostedctl -run 'TestStop|TestUnknownState|TestLostStop|TestRestart' -count=1` ok; whole package ok 7.5 s (load average 7 to 10); the targeted tests under `-race`: ok.
+- Corrected evidence for M10b, N5 and M12 (review finding 6): the earlier rows used different mutations (`at+1`) or no reaching test. The exact mutations now fail against tests whose wrappers move the clock during Get and List and list an unlinked VM in an unknown state (rows below); M12 is no longer unreachable.
+
+| Mutation | Test | Observed failure | Restored |
+| --- | --- | --- | --- |
+| F1 Stop without the attempt lock | `^TestStopWaitsForDispatch$` | `refresh_test.go:167: Stop returned (... att-1 has no VM ref yet ...) while the launch call was in flight; it must wait for the answer` (both subtests) | yes, passes |
+| F2 dispatch without the attempt lock | `^TestStopWaitsForDispatch$` | same line, both subtests | yes, passes |
+| F3a Refresh reconcile without the attempt lock | `^TestRestartOverlappingRefresh$` | `refresh_test.go:426: after two overlapping passes: re-based true, stopped true; want exactly one` | yes, passes |
+| F3b same mutation | `^TestStopNotFoundRacesLiveRead$` | `refresh_test.go:349: after a not-found and a live read: state "running" notfound_since_t {0 true}; want running and no not-found held` | yes, passes |
+| F4 live state saved after the restart handling (the old order) | `^TestStopNotFoundClearedBeforeRestartStop$` | `refresh_test.go:387: notfound_since_t 2000000000 kept after a live read` | yes, passes |
+| F5 a pre-open not-found counts | `^TestRestartWallJump$` | `refresh_test.go:500: Stop on a not-found after the wall jump = <nil>, want ErrStopPending: the first one is from before Open` and `refresh_test.go:529` | yes, passes |
+| F5b pre-open boundary `>=` OpenedAt | `^TestRestartWallJump$` | `refresh_test.go:529: Stop on a not-found paired with one saved at OpenedAt = <nil>, want ErrStopPending` | yes, passes |
+| F6 Ref-less wait ignores OpenedAt | `^TestRestartWallJump$` | `refresh_test.go:544: proof {"attempt_id":"att-1","vm_ref":"","state":"stopped","observed_at_ns":601000000000} 1 s after a restart` | yes, passes |
+| F7 Ref-less wait ignores the last dispatch | `^TestStopIntentWithoutRefFences$` | `refresh_test.go:254: proof {...} from a list begun 1m30s after the last dispatch` | yes, passes |
+| F8 no dispatch mark | `^(TestStopWaitsForDispatch\|TestStopIntentWithoutRefFences)$` | `refresh_test.go:154: last_dispatch_t during the provider call = {0 false}, want 0` | yes, passes |
+| F9 stop after the first failed Get | `^TestRestartRetriesFailedGet$` | `refresh_test.go:465: pass 1: stopped after 1 failed reads, want 3 first` | yes, passes |
+| F10 never stop on failed Gets | `^TestRestartRetriesFailedGet$` | `refresh_test.go:469: pass 3: requested {0 false} reason { false}; want a stop for elapsed_unknown` | yes, passes |
+| M10b exact: `at` for `start` in the Ref-less wait | `^TestStopIntentWithoutRefFences$` | `refresh_test.go:271: proof {... "observed_at_ns":130000000000} from a list begun 1m40s after the request` | yes, passes |
+| N5 exact: `at` for `before` in the not-found gap | `^TestStopNotFoundSlowGet$` | `refresh_test.go:319: Stop on a not-found Get begun 55s after the first ended = <nil>, want ErrStopPending` | yes, passes |
+| M12 exact: Ref-less check counts only `Live()` VMs | `^TestStopIntentWithoutRefFences$` | `refresh_test.go:289: proof {...} while the list shows an unlinked VM in an unknown state` | yes, passes |
+| TX1 Stop's provider stop inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:220: provider stop (call 0): a store read waited 2 s; a transaction is held across the provider call` | yes, passes |
+| TX2 Stop's provider get inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:220: provider get (call 1): a store read waited 2 s; ...` | yes, passes |
+| TX3 Refresh's get inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:252: provider get (call 2): a store read waited 2 s; ...` | yes, passes |
+| TX4 Refresh's list inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:252: provider list (call 3): a store read waited 2 s; ...` | yes, passes |
+| N1, M1, M5 rechecked | `^TestStopNotFoundThenRunning$`, `^TestStopProofNeedsTerminalState$`, `^TestRestartDowntimeExceedsWallDelta$` | `stop_test.go:473: after one not-found: proof {...}; want no proof and a since time`; `stop_test.go:272: Stop while the VM is stopping = <nil>, want ErrStopPending`; `stop_test.go:778: att-1 with no age: requested {0 false} ...` | yes, passes |
diff --git a/internal/hostedctl/attemptlock.go b/internal/hostedctl/attemptlock.go
new file mode 100644
index 00000000..62cd0aa7
--- /dev/null
+++ b/internal/hostedctl/attemptlock.go
@@ -0,0 +1,53 @@
+package hostedctl
+
+import "sync"
+
+// attemptLocks serialises the controller's operations on one attempt
+// (ruling R18). One controller owns a database (R11), so an in-memory lock
+// is enough.
+type attemptLocks struct {
+ mu sync.Mutex
+ m map[string]*attemptLock
+}
+
+type attemptLock struct {
+ mu sync.Mutex
+ users int // holders and waiters; the entry goes when it reaches zero
+}
+
+// lockAttempt takes attempt id's lock and returns the function that
+// releases it. Every operation on one attempt runs under it, held across
+// its provider calls: Launch's and Replay's dispatch, Stop, Refresh's
+// per-job reconcile and re-base, and the pause, resume and reaper actions.
+//
+// Never call it inside a store transaction, and never hold two attempts'
+// locks at once: a transaction may be waiting for the lock's holder, which
+// needs the store to finish. An entry lives only while someone holds or
+// waits for it, so unknown attempt IDs leave nothing behind.
+func (c *Controller) lockAttempt(id string) func() {
+ l := &c.attempts
+ l.mu.Lock()
+ if l.m == nil {
+ l.m = map[string]*attemptLock{}
+ }
+ e := l.m[id]
+ if e == nil {
+ e = &attemptLock{}
+ l.m[id] = e
+ }
+ e.users++
+ l.mu.Unlock()
+
+ e.mu.Lock()
+ var once sync.Once
+ return func() {
+ once.Do(func() {
+ e.mu.Unlock()
+ l.mu.Lock()
+ if e.users--; e.users == 0 {
+ delete(l.m, id)
+ }
+ l.mu.Unlock()
+ })
+ }
+}
diff --git a/internal/hostedctl/controller.go b/internal/hostedctl/controller.go
index 73dbf75e..2ed8cf1e 100644
--- a/internal/hostedctl/controller.go
+++ b/internal/hostedctl/controller.go
@@ -39,13 +39,14 @@ type Deps struct {
// Controller owns the job table and the VMs launched for it.
type Controller struct {
- cfg Config
- store *Store
- runner isolatedjob.Runner
- auditor isolatedjob.NetworkAuditor
- alerter Alerter
- audit auditState // the last network audit result (audit.go)
- rebased rebasedSet // jobs re-based after a restart (refresh.go)
+ cfg Config
+ store *Store
+ runner isolatedjob.Runner
+ auditor isolatedjob.NetworkAuditor
+ alerter Alerter
+ 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)
}
// New builds a controller. It refuses a nil dependency, including a nil
diff --git a/internal/hostedctl/launch.go b/internal/hostedctl/launch.go
index 2719c2f0..4ca70816 100644
--- a/internal/hostedctl/launch.go
+++ b/internal/hostedctl/launch.go
@@ -413,6 +413,9 @@ func checkReplaces(ctx context.Context, tx *sql.Tx, by hostedwire.KeyID, attempt
// (creatable); a failure is returned as gate with the waiting view and no
// provider call. Otherwise it calls the provider and settles the answer.
func (c *Controller) dispatch(ctx context.Context, actor hostedwire.KeyID, attempt string, replay bool) (view JobView, gate, err error) {
+ // The attempt's lock (R18) is held from the gate check to the settled
+ // answer, so a Stop cannot land between them.
+ defer c.lockAttempt(attempt)()
var spec isolatedjob.LaunchSpec
ready := false
err = c.store.Tx(ctx, func(tx *sql.Tx) error {
@@ -463,6 +466,9 @@ func (c *Controller) dispatch(ctx context.Context, actor hostedwire.KeyID, attem
if gate := c.creatable(spec.Image, c.store.Clock().Now()); gate != nil {
return view, gate, nil
}
+ if err := c.markDispatch(ctx, attempt); err != nil {
+ return JobView{}, nil, err
+ }
ref, perr := c.runner.Launch(ctx, spec)
// Record the answer even if the caller has gone: a VM may now exist.
view, err = c.settle(context.WithoutCancel(ctx), actor, attempt, ref, perr, replay)
diff --git a/internal/hostedctl/refresh.go b/internal/hostedctl/refresh.go
index 94584733..51701773 100644
--- a/internal/hostedctl/refresh.go
+++ b/internal/hostedctl/refresh.go
@@ -11,17 +11,42 @@ import (
"amadan.net/oficina/equipo/internal/isolatedjob"
)
-// ReflessProofDelay is how long, in controller time, after the stop request
-// a List must start before it can prove that a job with no VM Ref has no VM.
-// A launch whose reply was lost may still be landing until then.
+// ReflessProofDelay is how long, in controller time, a List must start after
+// the stop request, the last launch dispatch and this process's Open before
+// it can prove that a job with no VM Ref has no VM (R19). A launch whose
+// reply was lost may still be landing until then.
const ReflessProofDelay = 2 * time.Minute
+// RestartGetTries is how many Refresh passes in a row may fail to read a
+// pre-restart job's VM before the controller stops it as elapsed_unknown
+// (R20).
+const RestartGetTries = 3
+
// rebasedSet holds the jobs whose elapsed time Refresh has settled since this
// controller started: re-based on the provider's age, or stopped because the
// provider gave none. Each pre-restart job is settled once per process.
type rebasedSet struct {
- mu sync.Mutex
- done map[string]bool
+ mu sync.Mutex
+ done map[string]bool
+ fails map[string]int // consecutive Refresh passes whose Get failed
+}
+
+// failGet counts one more failed Get for attempt and returns the count.
+func (s *rebasedSet) failGet(attempt string) int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if s.fails == nil {
+ s.fails = map[string]int{}
+ }
+ s.fails[attempt]++
+ return s.fails[attempt]
+}
+
+// readOK ends attempt's run of failed Gets.
+func (s *rebasedSet) readOK(attempt string) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ delete(s.fails, attempt)
}
func (s *rebasedSet) has(attempt string) bool {
@@ -50,20 +75,29 @@ func (s *rebasedSet) add(attempt string) {
// with no live Get between (see notFound); the first is recorded and the
// job left pending. A job with no stop request ended on its own and gets
// the stop reason "ended", so replacements may go ahead;
+// - a live state is saved as the job's state first, which also clears
+// any first not-found (before anything below can return);
// - after a restart, a job launched at or before Store.OpenedAt has an
// untrusted elapsed time (the wall delta Open used says nothing about
// the real downtime). Once per process, with a provider age, its
// launched_t becomes min(launched_t, T before the Get minus the age) and
// its deadline, drain and stop times are recomputed with Deadlines, each
// only ever moved earlier. With no age, the controller stops it with the
-// reason "elapsed_unknown";
+// reason "elapsed_unknown". A Get that fails leaves it unsettled for the
+// next pass; after RestartGetTries failed passes in a row it is stopped
+// as elapsed_unknown too (R20), the Get error still returned;
// - an unknown state is left as it is;
-// - a live state is saved as the job's state, and a job with a stop
-// request whose VM is not yet stopping gets the provider stop again.
+// - a job with a stop request whose VM is live and not yet stopping gets
+// the provider stop again.
+//
+// Each job is reconciled under its attempt lock (R18), so the restart
+// check and its settling are one step, and no other operation on the job
+// interleaves with its provider calls.
//
// Then, when a job with no VM Ref is abandoned and has a stop request, one
-// List: if it is complete, started at least ReflessProofDelay after that
-// request, and shows no VM that is not terminal and not a saved Ref of some
+// List: if it is complete, started at least ReflessProofDelay after the
+// latest of that request, the job's last launch dispatch and OpenedAt, and
+// shows no VM that is not terminal and not a saved Ref of some
// job, the job gets proof with an empty VMRef and state stopped. Until then
// it stays pending; the orphan reaper stops any such VM.
func (c *Controller) Refresh(ctx context.Context) error {
@@ -115,6 +149,7 @@ func (c *Controller) Refresh(ctx context.Context) error {
// refreshOne reconciles one job with a VM Ref; see Refresh.
func (c *Controller) refreshOne(ctx context.Context, attempt string) error {
+ defer c.lockAttempt(attempt)()
var j jobRow
var reason sql.NullString
found := false
@@ -143,12 +178,24 @@ func (c *Controller) refreshOne(ctx context.Context, attempt string) error {
_, _, err := c.notFound(rec, "", attempt, ref, before, at, "refresh: provider holds no such VM")
return err
case gerr != nil:
- return fmt.Errorf("hostedctl: refresh %s: read VM %s: %w", attempt, ref, gerr)
+ err := fmt.Errorf("hostedctl: refresh %s: read VM %s: %w", attempt, ref, gerr)
+ if !untrusted || c.rebased.failGet(attempt) < RestartGetTries {
+ return err
+ }
+ return errors.Join(err, c.stopElapsedUnknown(ctx, attempt))
case job.State.Terminal():
_, err := c.recordProof(rec, "", attempt, StopProof{AttemptID: attempt, VMRef: ref,
State: job.State, ObservedAt: at}, "refresh: provider reports the VM "+string(job.State))
return err
}
+ c.rebased.readOK(attempt)
+ if job.State.Live() {
+ // First, so a live sighting clears any first not-found even when
+ // the restart handling below stops the job.
+ if err := c.mirrorState(rec, attempt, job.State); err != nil {
+ return err
+ }
+ }
if untrusted {
if !job.AgeKnown || job.ProviderAge < 0 {
@@ -162,9 +209,6 @@ func (c *Controller) refreshOne(ctx context.Context, attempt string) error {
if !job.State.Live() {
return nil // unknown: neither proof nor a state worth saving
}
- if err := c.mirrorState(rec, attempt, job.State); err != nil {
- return err
- }
if j.stopRequested.Valid && job.State != isolatedjob.StateStopping {
if perr := c.runner.Stop(ctx, ref, reason.String); perr != nil && !errors.Is(perr, isolatedjob.ErrNotFound) {
r := stopReq{attempt: attempt, account: j.account, task: j.task, ref: ref}
@@ -176,7 +220,8 @@ func (c *Controller) refreshOne(ctx context.Context, attempt string) error {
}
// stopElapsedUnknown is the controller's own stop of a pre-restart job the
-// provider gave no age for. Once the request is recorded the job counts as
+// provider gave no age for, or whose VM it could not read RestartGetTries
+// passes in a row. The caller holds the attempt's lock. Once the request is recorded the job counts as
// settled; a pending or unknown result is left for the next Refresh.
func (c *Controller) stopElapsedUnknown(ctx context.Context, attempt string) error {
r, err := c.requestStop(context.WithoutCancel(ctx), "", attempt, reasonElapsedUnknown, false)
@@ -225,6 +270,8 @@ func (c *Controller) rebase(ctx context.Context, attempt string, cand T, age tim
// proveRefless issues proof for abandoned, stop-requested jobs with no VM
// Ref; see Refresh. An incomplete List proves nothing and is not an error.
+// The List and the check for unlinked VMs come first; then each job is
+// settled under its attempt lock in a transaction of its own.
func (c *Controller) proveRefless(ctx context.Context) error {
start := c.store.Clock().Now()
vms, err := c.runner.List(ctx)
@@ -236,7 +283,9 @@ func (c *Controller) proveRefless(ctx context.Context) error {
return fmt.Errorf("hostedctl: list VMs for stop proof: %w", err)
}
ctx = context.WithoutCancel(ctx) // record what the list showed even if the caller has gone
- return c.store.Tx(ctx, func(tx *sql.Tx) error {
+ var ids []string
+ err = c.store.Tx(ctx, func(tx *sql.Tx) error {
+ ids = ids[:0]
saved := map[isolatedjob.Ref]bool{}
rows, err := tx.QueryContext(ctx, `SELECT vm_ref FROM jobs WHERE vm_ref IS NOT NULL`)
if err != nil {
@@ -256,11 +305,9 @@ func (c *Controller) proveRefless(ctx context.Context) error {
for _, vm := range vms {
// An unknown state may be a live VM, so only terminal ones pass.
if !vm.State.Terminal() && !saved[vm.Ref] {
- return nil
+ return nil // ids stays empty: no proof this pass
}
}
-
- var ids []string
rows, err = tx.QueryContext(ctx, `SELECT attempt_id FROM jobs WHERE vm_ref IS NULL AND state = ?
AND stop_requested_t IS NOT NULL AND stop_proof_json IS NULL ORDER BY attempt_id`, JobAbandoned)
if err != nil {
@@ -277,23 +324,63 @@ func (c *Controller) proveRefless(ctx context.Context) error {
if err := errors.Join(rows.Err(), rows.Close()); err != nil {
return fmt.Errorf("hostedctl: list jobs without a VM ref: %w", err)
}
- for _, id := range ids {
- j, found, err := loadJob(ctx, tx, id)
- if err != nil {
- return err
- }
- if !found || j.ref.Valid || !j.stopRequested.Valid || j.stopProof.Valid {
- continue
- }
- if start-T(j.stopRequested.Int64) < T(ReflessProofDelay) {
- continue
- }
- p := StopProof{AttemptID: id, State: isolatedjob.StateStopped, ObservedAt: at}
- if err := writeProof(ctx, tx, "", j, p, fmt.Sprintf(
- "a complete list begun %v after the stop request shows no VM outside the job table",
- time.Duration(start-T(j.stopRequested.Int64)))); err != nil {
- return err
- }
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+ var errs []error
+ for _, id := range ids {
+ if err := c.proveReflessOne(ctx, id, start, at); err != nil {
+ errs = append(errs, err)
+ }
+ }
+ return errors.Join(errs...)
+}
+
+// proveReflessOne saves proof for one Ref-less job when the List that began
+// at start began at least ReflessProofDelay after the latest of its stop
+// request, its last launch dispatch and OpenedAt.
+func (c *Controller) proveReflessOne(ctx context.Context, attempt string, start, at T) error {
+ defer c.lockAttempt(attempt)()
+ return c.store.Tx(ctx, func(tx *sql.Tx) error {
+ j, found, err := loadJob(ctx, tx, attempt)
+ if err != nil {
+ return err
+ }
+ if !found || j.ref.Valid || j.state != JobAbandoned || !j.stopRequested.Valid || j.stopProof.Valid {
+ return nil
+ }
+ var dispatched sql.NullInt64
+ if err := tx.QueryRowContext(ctx, `SELECT last_dispatch_t FROM jobs WHERE attempt_id = ?`, attempt).Scan(&dispatched); err != nil {
+ return fmt.Errorf("hostedctl: read last_dispatch_t of %s: %w", attempt, err)
+ }
+ since := max(T(j.stopRequested.Int64), c.store.OpenedAt())
+ if dispatched.Valid {
+ since = max(since, T(dispatched.Int64))
+ }
+ if start-since < T(ReflessProofDelay) {
+ return nil
+ }
+ p := StopProof{AttemptID: attempt, State: isolatedjob.StateStopped, ObservedAt: at}
+ return writeProof(ctx, tx, "", j, p, fmt.Sprintf(
+ "a complete list begun %v after the stop request, the last dispatch and the controller start shows no VM outside the job table",
+ time.Duration(start-since)))
+ })
+}
+
+// markDispatch records, just before a provider launch call, that one is
+// about to be made for attempt (R19). Ref-less proof waits
+// ReflessProofDelay past it, so a VM the call creates late is still seen.
+func (c *Controller) markDispatch(ctx context.Context, attempt string) error {
+ return c.store.Tx(ctx, func(tx *sql.Tx) error {
+ res, err := tx.ExecContext(ctx, `UPDATE jobs SET last_dispatch_t = ?, revision = revision + 1
+ WHERE attempt_id = ?`, int64(c.store.Clock().Now()), attempt)
+ if err != nil {
+ return fmt.Errorf("hostedctl: record dispatch of %s: %w", attempt, err)
+ }
+ if n, err := res.RowsAffected(); err != nil || n != 1 {
+ return fmt.Errorf("hostedctl: record dispatch of %s: %d rows (%v)", attempt, n, err)
}
return nil
})
diff --git a/internal/hostedctl/refresh_test.go b/internal/hostedctl/refresh_test.go
new file mode 100644
index 00000000..ec53afd5
--- /dev/null
+++ b/internal/hostedctl/refresh_test.go
@@ -0,0 +1,550 @@
+package hostedctl
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "slices"
+ "sync"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/isolatedjob"
+ "amadan.net/oficina/equipo/internal/isolatedjob/isolatedjobtest"
+)
+
+// slowRunner wraps the fake provider. Each Get and List moves the fake
+// clock on by getDelay or listDelay while it runs, so the controller time
+// before a call and after it differ. List also returns extra, as VMs the
+// provider holds that no job knows.
+type slowRunner struct {
+ *isolatedjob.Fake
+ clk *isolatedjobtest.FakeClock
+ getDelay, listDelay time.Duration
+ mu sync.Mutex
+ extra []isolatedjob.Job
+}
+
+func (r *slowRunner) Get(ctx context.Context, ref isolatedjob.Ref) (isolatedjob.Job, error) {
+ r.clk.AdvanceMono(r.getDelay)
+ return r.Fake.Get(ctx, ref)
+}
+
+func (r *slowRunner) List(ctx context.Context) ([]isolatedjob.Job, error) {
+ r.clk.AdvanceMono(r.listDelay)
+ jobs, err := r.Fake.List(ctx)
+ if err != nil {
+ return nil, err
+ }
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ return append(jobs, r.extra...), nil
+}
+
+func (r *slowRunner) setExtra(jobs ...isolatedjob.Job) {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ r.extra = jobs
+}
+
+// gatedGet wraps the fake provider's Get. Call n (counting from 1) answers
+// what answer(n) gives. Call 1 is held until call 2 begins, plus 200 ms for
+// call 2's caller to finish, or 300 ms when no call 2 comes; so two
+// overlapping callers interleave unless something serialises them.
+type gatedGet struct {
+ *isolatedjob.Fake
+ answer func(ctx context.Context, n int, ref isolatedjob.Ref) (isolatedjob.Job, error)
+ mu sync.Mutex
+ n int
+ second chan struct{}
+}
+
+func newGatedGet(f *isolatedjob.Fake, answer func(context.Context, int, isolatedjob.Ref) (isolatedjob.Job, error)) *gatedGet {
+ return &gatedGet{Fake: f, answer: answer, second: make(chan struct{})}
+}
+
+func (g *gatedGet) Get(ctx context.Context, ref isolatedjob.Ref) (isolatedjob.Job, error) {
+ g.mu.Lock()
+ g.n++
+ n := g.n
+ g.mu.Unlock()
+ switch n {
+ case 1:
+ select {
+ case <-g.second:
+ time.Sleep(200 * time.Millisecond)
+ case <-time.After(300 * time.Millisecond):
+ }
+ case 2:
+ close(g.second)
+ }
+ return g.answer(ctx, n, ref)
+}
+
+func notFoundAnswer(ref isolatedjob.Ref) (isolatedjob.Job, error) {
+ return isolatedjob.Job{}, fmt.Errorf("%w: %s (stale read)", isolatedjob.ErrNotFound, ref)
+}
+
+// twice runs f twice at once and waits for both.
+func twice(f func() error) [2]error {
+ var out [2]error
+ var wg sync.WaitGroup
+ for i := range 2 {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ out[i] = f()
+ }()
+ }
+ wg.Wait()
+ return out
+}
+
+// blockLaunch wraps the fake provider's Launch. Once armed, the next
+// Launch signals entered and waits for release before reaching the fake.
+type blockLaunch struct {
+ *isolatedjob.Fake
+ armed atomic.Bool
+ entered chan struct{}
+ release chan struct{}
+}
+
+func (b *blockLaunch) Launch(ctx context.Context, s isolatedjob.LaunchSpec) (isolatedjob.Ref, error) {
+ if b.armed.CompareAndSwap(true, false) {
+ close(b.entered)
+ <-b.release
+ }
+ return b.Fake.Launch(ctx, s)
+}
+
+// TestStopWaitsForDispatch: a Stop that arrives while a launch dispatch is
+// between its gate check and the provider's answer waits for the answer
+// (R18), so proof for a job with no Ref can never be issued while a
+// dispatched launch may still create its VM.
+func TestStopWaitsForDispatch(t *testing.T) {
+ type result struct {
+ err error
+ }
+ run := func(t *testing.T, viaReplay bool, fault isolatedjob.Fault) (*launchEnv, chan result) {
+ e := newLaunchEnv(t)
+ bl := &blockLaunch{Fake: e.fake, entered: make(chan struct{}), release: make(chan struct{})}
+ e.run = bl
+ e.newController()
+ e.audit()
+
+ launched := make(chan error, 1)
+ if viaReplay {
+ e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle)
+ if _, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")); err != nil {
+ t.Fatalf("throttled Launch = %v", err)
+ }
+ bl.armed.Store(true)
+ go func() { launched <- e.c.Replay(e.ctx) }()
+ } else {
+ bl.armed.Store(true)
+ go func() {
+ _, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1"))
+ launched <- err
+ }()
+ }
+ <-bl.entered // past every gate; the provider call is in flight
+ dispatchedAt := e.store.Clock().Now()
+ if s := e.stopCols("att-1"); !s.lastDispatch.Valid || T(s.lastDispatch.Int64) != dispatchedAt {
+ t.Fatalf("last_dispatch_t during the provider call = %v, want %d", s.lastDispatch, dispatchedAt)
+ }
+ if fault != "" {
+ e.fake.Inject(isolatedjob.OpLaunch, fault)
+ }
+
+ stopped := make(chan result, 1)
+ go func() {
+ _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done")
+ stopped <- result{err}
+ }()
+ select {
+ case r := <-stopped:
+ t.Fatalf("Stop returned (%v) while the launch call was in flight; it must wait for the answer", r.err)
+ case <-time.After(200 * time.Millisecond):
+ }
+
+ // However long the call takes, nothing proves the attempt stopped.
+ e.clk.AdvanceMono(3 * time.Minute)
+ // Refresh may wait for the attempt's lock; it must not prove anything
+ // either way.
+ refreshed := make(chan error, 1)
+ go func() { refreshed <- e.c.Refresh(e.ctx) }()
+ done := false
+ select {
+ case <-refreshed:
+ done = true
+ case <-time.After(300 * time.Millisecond):
+ }
+ close(bl.release)
+ if err := <-launched; viaReplay && err != nil && fault == "" {
+ t.Fatalf("Replay = %v", err)
+ }
+ if !done {
+ <-refreshed
+ }
+ return e, stopped
+ }
+
+ t.Run("replay paused after its gate check, launch reply lost", func(t *testing.T) {
+ e, stopped := run(t, true, isolatedjob.FaultLostReply)
+ if r := <-stopped; !errors.Is(r.err, ErrStopPending) {
+ t.Fatalf("Stop after the dispatch settled = %v, want ErrStopPending", r.err)
+ }
+ e.clk.AdvanceMono(3 * time.Minute)
+ e.refresh()
+ if s := e.stopCols("att-1"); s.proof.Valid && e.fake.LiveByAttempt()["att-1"] > 0 {
+ t.Fatalf("proof %s while the dispatched launch's VM is live", s.proof.String)
+ }
+ if e.fake.LiveByAttempt()["att-1"] != 1 {
+ t.Fatal("the lost launch made no VM; the test needs one")
+ }
+ })
+ t.Run("delayed provider launch", func(t *testing.T) {
+ e, stopped := run(t, false, "")
+ if r := <-stopped; !errors.Is(r.err, ErrStopPending) {
+ t.Fatalf("Stop after the launch answered = %v, want ErrStopPending (the VM is stopping)", r.err)
+ }
+ s := e.stopCols("att-1")
+ if s.proof.Valid {
+ t.Fatalf("proof %s for a VM that is only stopping", s.proof.String)
+ }
+ if v, err := e.c.Get(e.ctx, "inst-1", "att-1"); err != nil || v.VMRef == "" {
+ t.Fatalf("Get after the delayed launch = (%+v, %v), want the job to hold its VM ref", v, err)
+ }
+ })
+}
+
+// TestStopIntentWithoutRefFences: Ref-less proof waits ReflessProofDelay
+// after the last dispatch as well as the stop request (R19), and the List
+// that proves it is judged by when it began and by every VM it shows that
+// is not terminal.
+func TestStopIntentWithoutRefFences(t *testing.T) {
+ stopIntent := func(t *testing.T, e *launchEnv) T {
+ t.Helper()
+ e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle)
+ if _, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")); err != nil {
+ t.Fatalf("throttled Launch = %v", err)
+ }
+ asked := e.store.Clock().Now()
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop of an intent with no Ref = %v, want ErrStopPending", err)
+ }
+ return asked
+ }
+ t.Run("proof waits past the last dispatch", func(t *testing.T) {
+ e := newLaunchEnv(t)
+ e.clk.AdvanceMono(time.Minute)
+ at := e.store.Clock().Now()
+ asked := stopIntent(t, e)
+ if s := e.stopCols("att-1"); !s.lastDispatch.Valid || T(s.lastDispatch.Int64) != at {
+ t.Fatalf("last_dispatch_t after a throttled launch = %v, want %d", s.lastDispatch, at)
+ }
+ // A dispatch that crossed the stop request (a crash mid-call, or a
+ // path without the attempt lock) leaves a later mark.
+ dispatched := asked + T(time.Minute)
+ e.exec(`UPDATE jobs SET last_dispatch_t = ? WHERE attempt_id = 'att-1'`, int64(dispatched))
+ e.clk.AdvanceMono(ReflessProofDelay + 30*time.Second)
+ e.refresh()
+ if s := e.stopCols("att-1"); s.proof.Valid {
+ t.Fatalf("proof %s from a list begun %v after the last dispatch",
+ s.proof.String, time.Duration(e.store.Clock().Now()-dispatched))
+ }
+ e.clk.AdvanceMono(30 * time.Second)
+ e.refresh()
+ e.wireProof("att-1")
+ })
+ t.Run("slow list is judged by its start", func(t *testing.T) {
+ e := newLaunchEnv(t)
+ slow := &slowRunner{Fake: e.fake, clk: e.clk, listDelay: 30 * time.Second}
+ e.run = slow
+ e.newController()
+ e.audit()
+ asked := stopIntent(t, e)
+ e.clk.AdvanceMono(ReflessProofDelay - 20*time.Second)
+ e.refresh() // begins 20 s early, ends 10 s late
+ if s := e.stopCols("att-1"); s.proof.Valid {
+ t.Fatalf("proof %s from a list begun %v after the request", s.proof.String, ReflessProofDelay-20*time.Second)
+ }
+ e.refresh() // begins 10 s late
+ if w := e.wireProof("att-1"); T(w.ObservedAt) != asked+T(ReflessProofDelay+40*time.Second) {
+ t.Fatalf("proof observed at %d, want the end of the second list, %d", w.ObservedAt, asked+T(ReflessProofDelay+40*time.Second))
+ }
+ })
+ t.Run("an unknown-state VM outside the table blocks proof", func(t *testing.T) {
+ e := newLaunchEnv(t)
+ slow := &slowRunner{Fake: e.fake, clk: e.clk}
+ slow.setExtra(isolatedjob.Job{Ref: "vm-ghost", State: isolatedjob.StateUnknown})
+ e.run = slow
+ e.newController()
+ e.audit()
+ stopIntent(t, e)
+ e.clk.AdvanceMono(ReflessProofDelay + time.Minute)
+ e.refresh()
+ if s := e.stopCols("att-1"); s.proof.Valid {
+ t.Fatalf("proof %s while the list shows an unlinked VM in an unknown state", s.proof.String)
+ }
+ slow.setExtra(isolatedjob.Job{Ref: "vm-ghost", State: isolatedjob.StateStopped})
+ e.refresh()
+ e.wireProof("att-1")
+ })
+}
+
+// TestStopNotFoundSlowGet: the NotFoundConfirm gap runs from the end of the
+// first not-found Get to the start of the second, so slow calls cannot
+// shrink it.
+func TestStopNotFoundSlowGet(t *testing.T) {
+ e := newLaunchEnv(t)
+ slow := &slowRunner{Fake: e.fake, clk: e.clk, getDelay: 10 * time.Second}
+ e.run = slow
+ e.newController()
+ e.audit()
+ ref := e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ e.fake.Vanish(ref)
+
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop on the first not-found = %v, want ErrStopPending", err)
+ }
+ first := T(e.stopCols("att-1").notFoundSince.Int64)
+ if first != e.store.Clock().Now() {
+ t.Fatalf("notfound_since_t = %d, want the end of the Get, %d", first, e.store.Clock().Now())
+ }
+ e.clk.AdvanceMono(NotFoundConfirm - 5*time.Second)
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop on a not-found Get begun %v after the first ended = %v, want ErrStopPending",
+ NotFoundConfirm-5*time.Second, err)
+ }
+ e.clk.AdvanceMono(time.Second) // the next Get begins NotFoundConfirm + 6 s after the first ended
+ if p, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); err != nil || p.VMRef != ref {
+ t.Fatalf("Stop on a confirming not-found = (%+v, %v), want proof", p, err)
+ }
+}
+
+// TestStopNotFoundRacesLiveRead: a not-found that a Refresh read before a
+// live read by another Refresh must not be saved after it (R18).
+func TestStopNotFoundRacesLiveRead(t *testing.T) {
+ e := newLaunchEnv(t)
+ e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ gg := newGatedGet(e.fake, func(ctx context.Context, n int, ref isolatedjob.Ref) (isolatedjob.Job, error) {
+ if n == 1 {
+ return notFoundAnswer(ref)
+ }
+ return e.fake.Get(ctx, ref)
+ })
+ e.run = gg
+ e.newController()
+
+ for i, err := range twice(func() error { return e.c.Refresh(e.ctx) }) {
+ if err != nil {
+ t.Fatalf("Refresh %d = %v", i, err)
+ }
+ }
+ if s := e.stopCols("att-1"); s.notFoundSince.Valid || s.state != JobRunning {
+ t.Fatalf("after a not-found and a live read: state %q notfound_since_t %v; want running and no not-found held",
+ s.state, s.notFoundSince)
+ }
+}
+
+// TestStopNotFoundClearedBeforeRestartStop: a live read clears a held
+// not-found even when the restart handling then stops the job and returns.
+func TestStopNotFoundClearedBeforeRestartStop(t *testing.T) {
+ e := newLaunchEnv(t)
+ flaky := &notFoundOnce{Fake: e.fake}
+ e.run = flaky
+ e.newController()
+ e.audit()
+ e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ e.down()
+ e.clk.AdvanceMono(time.Minute)
+ e.up()
+ e.clk.AdvanceMono(time.Second)
+
+ // The creator asks for a stop; the VM is stopping. Then one not-found.
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop = %v, want ErrStopPending", err)
+ }
+ e.clk.AdvanceMono(time.Second)
+ flaky.n = 1
+ e.refresh()
+ if s := e.stopCols("att-1"); !s.notFoundSince.Valid {
+ t.Fatal("no not-found held after a not-found read")
+ }
+
+ // A live read with no age: the job is stopped as elapsed_unknown, and the
+ // Get inside that stop fails, so only the first live read can clear it.
+ e.clk.AdvanceMono(30 * time.Second)
+ e.fake.Inject(isolatedjob.OpGet, isolatedjob.FaultAgeUnknown)
+ e.fake.Inject(isolatedjob.OpGet, isolatedjob.FaultThrottle)
+ _ = e.c.Refresh(e.ctx)
+ if s := e.stopCols("att-1"); s.notFoundSince.Valid {
+ t.Fatalf("notfound_since_t %d kept after a live read", s.notFoundSince.Int64)
+ }
+ e.clk.AdvanceMono(40 * time.Second)
+ flaky.n = 1
+ e.refresh()
+ if s := e.stopCols("att-1"); s.proof.Valid {
+ t.Fatalf("proof %s from not-founds with a live read between", s.proof.String)
+ }
+}
+
+// TestRestartOverlappingRefresh: two Refresh passes at once settle a
+// pre-restart job once (R18): never both re-based and stopped. A second
+// restart settles it again.
+func TestRestartOverlappingRefresh(t *testing.T) {
+ e := newLaunchEnv(t)
+ e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ e.down()
+ e.clk.AdvanceMono(10 * time.Minute)
+ e.clk.SetWall(testWall.Add(10 * time.Minute))
+ gg := newGatedGet(e.fake, func(ctx context.Context, n int, ref isolatedjob.Ref) (isolatedjob.Job, error) {
+ j, err := e.fake.Get(ctx, ref)
+ if n >= 2 {
+ j.ProviderAge, j.AgeKnown = 0, false
+ }
+ return j, err
+ })
+ e.run = gg
+ e.up()
+ e.clk.AdvanceMono(time.Second)
+
+ for i, err := range twice(func() error { return e.c.Refresh(e.ctx) }) {
+ if err != nil {
+ t.Fatalf("Refresh %d = %v", i, err)
+ }
+ }
+ rebased := e.hasAudit("", "att-1", actionRestartRebased, "")
+ stopped := e.stopCols("att-1").requested.Valid
+ if rebased == stopped {
+ t.Fatalf("after two overlapping passes: re-based %v, stopped %v; want exactly one", rebased, stopped)
+ }
+
+ // A second restart: the new process settles the job again; with no age
+ // it is stopped.
+ if !stopped {
+ e.run = e.fake
+ e.down()
+ e.clk.AdvanceMono(time.Minute)
+ e.up()
+ e.clk.AdvanceMono(time.Second)
+ e.fake.Inject(isolatedjob.OpGet, isolatedjob.FaultAgeUnknown)
+ e.refresh()
+ if s := e.stopCols("att-1"); s.reason.String != reasonElapsedUnknown {
+ t.Fatalf("after a second restart with no age: reason %v, want %s", s.reason, reasonElapsedUnknown)
+ }
+ }
+}
+
+// TestRestartRetriesFailedGet: a pre-restart job whose Get fails is retried;
+// after RestartGetTries failed passes in a row it is stopped as
+// elapsed_unknown, the stop request saved first (R20).
+func TestRestartRetriesFailedGet(t *testing.T) {
+ e := newLaunchEnv(t)
+ ref := e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ e.down()
+ e.clk.AdvanceMono(10 * time.Minute)
+ e.up()
+ e.clk.AdvanceMono(time.Second)
+
+ for pass := 1; pass <= RestartGetTries; pass++ {
+ e.fake.Inject(isolatedjob.OpGet, isolatedjob.FaultThrottle)
+ err := e.c.Refresh(e.ctx)
+ if !errors.Is(err, isolatedjob.ErrThrottled) {
+ t.Fatalf("pass %d: Refresh = %v, want the Get error", pass, err)
+ }
+ s := e.stopCols("att-1")
+ if pass < RestartGetTries && (s.requested.Valid || len(e.fake.StopsIssued()) != 0) {
+ t.Fatalf("pass %d: stopped after %d failed reads, want %d first", pass, pass, RestartGetTries)
+ }
+ if pass == RestartGetTries {
+ if s.reason.String != reasonElapsedUnknown || !s.requested.Valid {
+ t.Fatalf("pass %d: requested %v reason %v; want a stop for %s", pass, s.requested, s.reason, reasonElapsedUnknown)
+ }
+ if got := e.fake.StopsIssued(); !slices.Equal(got, []isolatedjob.Ref{ref}) {
+ t.Fatalf("provider stops = %v, want %s", got, ref)
+ }
+ }
+ e.clk.AdvanceMono(time.Minute)
+ }
+}
+
+// TestRestartWallJump: a forward wall jump across a restart with almost no
+// real downtime gives neither proof path any trusted time (R19).
+func TestRestartWallJump(t *testing.T) {
+ jump := func(e *launchEnv) {
+ e.down()
+ e.clk.AdvanceMono(time.Second)
+ e.clk.SetWall(testWall.Add(10 * time.Minute))
+ e.up()
+ e.clk.AdvanceMono(time.Second)
+ }
+ t.Run("not-found pair", func(t *testing.T) {
+ e := newLaunchEnv(t)
+ ref := e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ e.fake.Vanish(ref)
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop on the first not-found = %v, want ErrStopPending", err)
+ }
+ jump(e)
+ now := e.store.Clock().Now()
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop on a not-found after the wall jump = %v, want ErrStopPending: the first one is from before Open", err)
+ }
+ if s := e.stopCols("att-1"); T(s.notFoundSince.Int64) != now {
+ t.Fatalf("notfound_since_t = %v, want it restarted at %d", s.notFoundSince, now)
+ }
+ e.clk.AdvanceMono(NotFoundConfirm)
+ if p, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); err != nil || p.VMRef != ref {
+ t.Fatalf("Stop on a confirming not-found = (%+v, %v), want proof", p, err)
+ }
+ })
+ t.Run("not-found saved at the restored time", func(t *testing.T) {
+ // With the wall clock behind the checkpoint, T restores to the
+ // checkpoint, so a not-found saved just before the exit equals
+ // OpenedAt. It is from before Open and does not count.
+ e := newLaunchEnv(t)
+ ref := e.launchWith("att-1", 2*time.Hour)
+ e.fake.Tick()
+ e.fake.Vanish(ref)
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop on the first not-found = %v, want ErrStopPending", err)
+ }
+ e.down()
+ e.clk.SetWall(testWall.Add(-time.Hour))
+ e.up()
+ if s := e.stopCols("att-1"); T(s.notFoundSince.Int64) != e.store.OpenedAt() {
+ t.Fatalf("notfound_since_t %d, OpenedAt %d; the test needs them equal", s.notFoundSince.Int64, e.store.OpenedAt())
+ }
+ e.clk.AdvanceMono(NotFoundConfirm + time.Second)
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop on a not-found paired with one saved at OpenedAt = %v, want ErrStopPending", err)
+ }
+ })
+ t.Run("ref-less list", func(t *testing.T) {
+ e := newLaunchEnv(t)
+ e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle)
+ if _, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-1")); err != nil {
+ t.Fatalf("throttled Launch = %v", err)
+ }
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop = %v, want ErrStopPending", err)
+ }
+ jump(e)
+ e.refresh()
+ if s := e.stopCols("att-1"); s.proof.Valid {
+ t.Fatalf("proof %s 1 s after a restart", s.proof.String)
+ }
+ e.clk.AdvanceMono(ReflessProofDelay)
+ e.refresh()
+ e.wireProof("att-1")
+ })
+}
diff --git a/internal/hostedctl/schema/0001_jobs.sql b/internal/hostedctl/schema/0001_jobs.sql
index 71104f75..e9e3f4ba 100644
--- a/internal/hostedctl/schema/0001_jobs.sql
+++ b/internal/hostedctl/schema/0001_jobs.sql
@@ -29,6 +29,7 @@ CREATE TABLE jobs (
stop_reason TEXT,
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
revision INTEGER NOT NULL DEFAULT 0
);
diff --git a/internal/hostedctl/stop.go b/internal/hostedctl/stop.go
index edc73eda..62291f0d 100644
--- a/internal/hostedctl/stop.go
+++ b/internal/hostedctl/stop.go
@@ -130,6 +130,9 @@ func (c *Controller) Get(ctx context.Context, by hostedwire.KeyID, attemptID str
// Stop asks for attempt's VM to stop and returns proof once it has.
//
+// Everything after the refusals runs under the attempt's lock (R18), so a
+// Stop waits for a launch dispatch in flight to settle.
+//
// Only an instance key (RoleInstance) that launched attempt may stop it;
// anyone else, an unknown attempt, or a malformed attempt ID or reason
// (1 to 128 printable ASCII characters) gets an error and an audit row and
@@ -166,6 +169,7 @@ func (c *Controller) Stop(ctx context.Context, by hostedwire.KeyID, key hostedwi
case !printableASCII(reason, maxNameLen):
return StopProof{}, c.refuseStop(ctx, by, attemptID, fmt.Errorf("%w: stop reason must be 1 to %d printable ASCII characters", isolatedjob.ErrInvalid, maxNameLen))
}
+ defer c.lockAttempt(attemptID)()
r, err := c.requestStop(ctx, by, attemptID, reason, true)
if err != nil {
return StopProof{}, err
@@ -315,7 +319,8 @@ func (c *Controller) auditStop(ctx context.Context, actor hostedwire.KeyID, r st
// notFound handles a not-found answer from Runner.Get for attempt's VM ref,
// read between controller times before and at. The answer is proof only
// when notfound_since_t holds an earlier not-found that came after the stop
-// request (if any) and is at least NotFoundConfirm before this Get began;
+// request (if any) and after this process's Open (R19), and is at least
+// NotFoundConfirm before this Get began;
// any live Get in between has cleared it (mirrorState). Otherwise, when no
// such first not-found is held, at is recorded as the first one. proven
// reports whether p is proof; a job that already holds proof returns it.
@@ -342,7 +347,10 @@ func (c *Controller) notFound(ctx context.Context, actor hostedwire.KeyID, attem
if err := tx.QueryRowContext(ctx, `SELECT notfound_since_t FROM jobs WHERE attempt_id = ?`, attempt).Scan(&since); err != nil {
return fmt.Errorf("hostedctl: read notfound_since_t of %s: %w", attempt, err)
}
- first := since.Valid && (!j.stopRequested.Valid || since.Int64 >= j.stopRequested.Int64)
+ // The first not-found must follow the stop request, if any, and this
+ // process's Open: the time across a restart is untrusted (R19).
+ first := since.Valid && (!j.stopRequested.Valid || since.Int64 >= j.stopRequested.Int64) &&
+ (!c.store.Restarted() || T(since.Int64) > c.store.OpenedAt())
if first && before-T(since.Int64) >= T(NotFoundConfirm) {
out, proven = StopProof{AttemptID: attempt, VMRef: ref, State: isolatedjob.StateStopped, ObservedAt: at}, true
return writeProof(ctx, tx, actor, j, out, fmt.Sprintf("%s; not found twice, %v apart",
diff --git a/internal/hostedctl/stop_test.go b/internal/hostedctl/stop_test.go
index d3ab510b..6dc470e4 100644
--- a/internal/hostedctl/stop_test.go
+++ b/internal/hostedctl/stop_test.go
@@ -8,6 +8,7 @@ import (
"fmt"
"slices"
"strings"
+ "sync"
"testing"
"time"
@@ -19,6 +20,7 @@ import (
type stopCols struct {
state string
requested, notFoundSince sql.NullInt64
+ lastDispatch sql.NullInt64
reason, proof sql.NullString
launched, deadline, drain, stop int64
}
@@ -27,9 +29,9 @@ func (e *launchEnv) stopCols(attempt string) stopCols {
e.t.Helper()
var s stopCols
if err := e.store.Tx(e.ctx, func(tx *sql.Tx) error {
- return tx.QueryRowContext(e.ctx, `SELECT state, stop_requested_t, notfound_since_t, stop_reason, stop_proof_json,
+ return tx.QueryRowContext(e.ctx, `SELECT state, stop_requested_t, notfound_since_t, last_dispatch_t, stop_reason, stop_proof_json,
launched_t, deadline_t, drain_t, stop_t FROM jobs WHERE attempt_id = ?`, attempt).Scan(
- &s.state, &s.requested, &s.notFoundSince, &s.reason, &s.proof, &s.launched, &s.deadline, &s.drain, &s.stop)
+ &s.state, &s.requested, &s.notFoundSince, &s.lastDispatch, &s.reason, &s.proof, &s.launched, &s.deadline, &s.drain, &s.stop)
}); err != nil {
e.t.Fatalf("read stop columns of %s = %v", attempt, err)
}
@@ -108,41 +110,101 @@ func (e *launchEnv) hasAudit(actor hostedwire.KeyID, attempt, action, reasonPart
return false
}
-// stopProbe wraps the fake provider. It records the order of Stop and Get
-// calls and, at each Stop, reads the job's stop columns from the store. The
-// read waits at most 2 s, so a transaction held across the call shows as an
-// error, not a hang.
+// stopProbe wraps the fake provider. At each Stop, Get and List it reads
+// the store from another goroutine, as the provider is called, the way
+// intentProbe does: a read still blocked after 2 s means a transaction is
+// held across the provider call, and the call then fails with
+// errProbeBlocked instead of hanging. join waits for every read.
type stopProbe struct {
*isolatedjob.Fake
- store *Store
- ops []isolatedjob.Op
- atStop []probeStop
+ store *Store
+ mu sync.Mutex
+ ops []isolatedjob.Op
+ reads []*probeRead
}
-type probeStop struct {
- requested sql.NullInt64
- reason sql.NullString
+type probeRead struct {
+ op isolatedjob.Op
+ requested sql.NullInt64 // the job's stop_requested_t, at Stop and Get
+ reason sql.NullString // the job's stop_reason, at Stop and Get
err error
+ blocked bool
+ done chan struct{}
+}
+
+// read starts the store read for op on ref ("" for List) and reports
+// whether it finished within 2 s.
+func (p *stopProbe) read(op isolatedjob.Op, ref isolatedjob.Ref) bool {
+ r := &probeRead{op: op, done: make(chan struct{})}
+ p.mu.Lock()
+ p.ops = append(p.ops, op)
+ p.reads = append(p.reads, r)
+ p.mu.Unlock()
+ go func() {
+ defer close(r.done)
+ ctx := context.Background()
+ r.err = p.store.Tx(ctx, func(tx *sql.Tx) error {
+ if ref == "" {
+ var n int
+ return tx.QueryRowContext(ctx, `SELECT count(*) FROM jobs`).Scan(&n)
+ }
+ return tx.QueryRowContext(ctx, `SELECT stop_requested_t, stop_reason FROM jobs WHERE vm_ref = ?`,
+ string(ref)).Scan(&r.requested, &r.reason)
+ })
+ }()
+ select {
+ case <-r.done:
+ return true
+ case <-time.After(2 * time.Second):
+ r.blocked = true
+ return false
+ }
}
func (p *stopProbe) Stop(ctx context.Context, ref isolatedjob.Ref, reason string) error {
- rctx, cancel := context.WithTimeout(ctx, 2*time.Second)
- defer cancel()
- var s probeStop
- s.err = p.store.Tx(rctx, func(tx *sql.Tx) error {
- return tx.QueryRowContext(rctx, `SELECT stop_requested_t, stop_reason FROM jobs WHERE vm_ref = ?`,
- string(ref)).Scan(&s.requested, &s.reason)
- })
- p.atStop = append(p.atStop, s)
- p.ops = append(p.ops, isolatedjob.OpStop)
+ if !p.read(isolatedjob.OpStop, ref) {
+ return errProbeBlocked
+ }
return p.Fake.Stop(ctx, ref, reason)
}
func (p *stopProbe) Get(ctx context.Context, ref isolatedjob.Ref) (isolatedjob.Job, error) {
- p.ops = append(p.ops, isolatedjob.OpGet)
+ if !p.read(isolatedjob.OpGet, ref) {
+ return isolatedjob.Job{}, errProbeBlocked
+ }
return p.Fake.Get(ctx, ref)
}
+func (p *stopProbe) List(ctx context.Context) ([]isolatedjob.Job, error) {
+ if !p.read(isolatedjob.OpList, "") {
+ return nil, errProbeBlocked
+ }
+ return p.Fake.List(ctx)
+}
+
+// join waits for every read the probe started and fails the test when one
+// was blocked or failed. Call it after the probed calls have returned.
+func (p *stopProbe) join(t *testing.T) []*probeRead {
+ t.Helper()
+ p.mu.Lock()
+ reads := append([]*probeRead(nil), p.reads...)
+ p.mu.Unlock()
+ for i, r := range reads {
+ select {
+ case <-r.done:
+ case <-time.After(5 * time.Second):
+ t.Fatalf("probe read %d (%s) is still blocked after the call returned", i, r.op)
+ }
+ if r.blocked {
+ t.Fatalf("provider %s (call %d): a store read waited 2 s; a transaction is held across the provider call", r.op, i)
+ }
+ if r.err != nil {
+ t.Fatalf("provider %s (call %d): reading the store = %v", r.op, i, r.err)
+ }
+ }
+ return reads
+}
+
func TestStopRecordsRequestBeforeProvider(t *testing.T) {
e := newLaunchEnv(t)
probe := &stopProbe{Fake: e.fake, store: e.store}
@@ -155,19 +217,18 @@ func TestStopRecordsRequestBeforeProvider(t *testing.T) {
asked := e.store.Clock().Now()
_, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-1", "task done")
+ reads := probe.join(t)
if !errors.Is(err, ErrStopPending) {
t.Fatalf("Stop of a running VM = %v, want ErrStopPending (it is only stopping)", err)
}
- if !slices.Equal(probe.ops, []isolatedjob.Op{isolatedjob.OpStop, isolatedjob.OpGet}) {
+ if len(reads) != 2 || reads[0].op != isolatedjob.OpStop || reads[1].op != isolatedjob.OpGet {
t.Fatalf("provider calls = %v, want stop then get", probe.ops)
}
- seen := probe.atStop[0]
- if seen.err != nil {
- t.Fatalf("reading the store during the provider stop = %v; a transaction is held across it", seen.err)
- }
- if !seen.requested.Valid || T(seen.requested.Int64) != asked || seen.reason.String != "task done" {
- t.Fatalf("at the provider stop: stop_requested_t %v, reason %v; want %d and \"task done\" already saved",
- seen.requested, seen.reason, asked)
+ for _, r := range reads {
+ if !r.requested.Valid || T(r.requested.Int64) != asked || r.reason.String != "task done" {
+ t.Fatalf("at the provider %s: stop_requested_t %v, reason %v; want %d and \"task done\" already saved",
+ r.op, r.requested, r.reason, asked)
+ }
}
if s := e.stopCols("att-1"); s.proof.Valid || s.state != JobStopping {
t.Fatalf("after Stop: state %q, proof %v; want stopping and no proof", s.state, s.proof)
@@ -175,6 +236,30 @@ func TestStopRecordsRequestBeforeProvider(t *testing.T) {
if !e.hasAudit("inst-1", "att-1", actionStopRequested, "task done") {
t.Fatal("no stop_requested audit row by inst-1")
}
+
+ // Refresh's Get and its List for a job with no Ref run outside any
+ // transaction too.
+ e.audit()
+ e.fake.Inject(isolatedjob.OpLaunch, isolatedjob.FaultThrottle)
+ if _, err := e.c.Launch(e.ctx, "inst-1", instKey, request("att-2")); err != nil {
+ t.Fatalf("throttled Launch = %v", err)
+ }
+ if _, err := e.c.Stop(e.ctx, "inst-1", instKey, "att-2", "task done"); !errors.Is(err, ErrStopPending) {
+ t.Fatalf("Stop of an intent with no Ref = %v, want ErrStopPending", err)
+ }
+ e.clk.AdvanceMono(3 * time.Minute)
+ err = e.c.Refresh(e.ctx)
+ reads = probe.join(t)
+ if err != nil {
+ t.Fatalf("Refresh = %v", err)
+ }
+ var ops []isolatedjob.Op
+ for _, r := range reads[2:] {
+ ops = append(ops, r.op)
+ }
+ if !slices.Contains(ops, isolatedjob.OpGet) || !slices.Contains(ops, isolatedjob.OpList) {
+ t.Fatalf("Refresh provider calls = %v, want a get and a list", ops)
+ }
}
func TestStopProofNeedsTerminalState(t *testing.T) {
@@ -570,6 +655,9 @@ func TestRestartFindsVMGone(t *testing.T) {
e.fake.Tick()
e.clk.SetWall(testWall.Add(2 * time.Hour))
e.up()
+ // A not-found at exactly OpenedAt cannot be told from one saved before
+ // the restart, so it never counts; real time always moves after Open.
+ e.clk.AdvanceMono(time.Second)
e.refresh()
// B is terminal: proof at once. A is only not found: it waits for a