oficina / equipo Public

hostedctl: store, controller time and controller skeleton

The SQLite store for equipo-hosted-controller: jobs (spec immutable by
trigger), resume_ops, unmatched_vms, nonces, audit and the clock
checkpoint, migrated by user_version and refusing a newer schema. Tx is
BEGIN IMMEDIATE and checkpoints controller time on every commit.

Controller time advances only with the monotonic clock. A restart adds
the wall time since the checkpoint, never less than zero, marks elapsed
time untrusted, and turns a wall clock behind the checkpoint into an
audited clock_rollback alert that New must deliver before it returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 3e074674e5a7890775d21c5208e473a6a207e6dc parent e78d64e
7 files changed, +1,065 −0
  • docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md +17 −0
  • internal/hostedctl/clock.go +66 −0
  • internal/hostedctl/clock_test.go +169 −0
  • internal/hostedctl/controller.go +66 −0
  • internal/hostedctl/schema/0001_jobs.sql +94 −0
  • internal/hostedctl/store.go +322 −0
  • internal/hostedctl/store_test.go +331 −0

CI passed — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/hosted-runners-1a: Type  Size Avail | ext4   96G   86G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   86G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.3s
ci-box: codex: fetched and verified in 3.5s
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.3s
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 9.3s
ci-box: clone deepened in 3.8s
ci-box: file times set from content: 2868 files, 192 directories
ci-box: ready in 16.8s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipotest	0.248s
=== compile ===
go build ./...
go: downloading github.com/aws/aws-sdk-go-v2/service/lambdacore v1.14.0
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
  1.1s
+ go list -export -test -tags testbuild -f  ./...
  0.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.666s 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.082s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m20.08s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 41.39, cpu waiting 22.95%, memory waiting 0.00%, io waiting 0.46%
--- 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.315s 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.742s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m21.74s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 41.39, cpu waiting 22.82%, memory waiting 0.00%, io waiting 0.44%
--- 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 1m25.289s 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 1m23.191s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m12.38s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.98s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.83s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 41.39, cpu waiting 22.43%, memory waiting 0.00%, io waiting 0.43%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

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

receipt: test step 1m38.211s 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.489s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m0.47s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.39s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 9.85s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 8.82s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.96s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 35.89, cpu waiting 19.11%, memory waiting 0.00%, io waiting 0.35%
--- shard 5 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-rest: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$|^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$|^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$|^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$|^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 3m10.404s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3m8.33s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m46.51s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 24.13s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.53s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 8.13s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.36s amadan.net/oficina/equipo/internal/headless TestHeadlessBatchAfterRefusedReply
machine: 32 CPUs, load 10.81, cpu waiting 4.01%, memory waiting 0.00%, io waiting 0.06%
--- 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.109s 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 5.73, cpu waiting 0.46%, memory waiting 0.00%, io waiting 1.77%
--- 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.155s 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 5.73, cpu waiting 0.46%, memory waiting 0.00%, io waiting 1.77%
--- shard 8 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-thin: ./internal/runner/thin
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/runner/thin
cache miss: amadan.net/oficina/equipo/internal/runner/thin: its inputs changed
budget note: internal/runner/thin took 4m28.707s, over the 45s its record on line 44 allows; reported only, timing fails on CI

receipt: test step 4m41.729s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 4m28.707s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.96s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.88s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.77s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.45s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 6.83s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.89, cpu waiting 0.89%, memory waiting 0.00%, io waiting 0.01%
--- shard 9 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-bug: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 47.412s 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.274s amadan.net/oficina/equipo/internal/runner
receipt: slow test 26.24s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 45.73, cpu waiting 21.42%, memory waiting 0.00%, io waiting 0.82%
--- shard 10 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-plans: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 47.465s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 45.528s amadan.net/oficina/equipo/internal/runner
receipt: slow test 35.62s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 31.24s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.38s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.52s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 45.73, cpu waiting 21.42%, memory waiting 0.00%, io waiting 0.82%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 35.042s 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.173s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.45s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.11s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.2s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestCoordinatorTransientRefusalKeepsServing
machine: 32 CPUs, load 34.79, cpu waiting 14.90%, memory waiting 0.00%, io waiting 1.00%
--- 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.8%, load 27.29
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.722s 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.945s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.83s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 26.82s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 24.87s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 22.43s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 22.18s amadan.net/oficina/equipo/internal/equipotest TestAuthorityProjectKinds
machine: 32 CPUs, load 38.23, cpu waiting 19.72%, memory waiting 0.00%, io waiting 0.36%
--- 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.9%, load 27.29
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.228s 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 34.79, cpu waiting 11.68%, memory waiting 0.00%, io waiting 1.07%
--- 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.8%, load 27.29
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed

receipt: test step 1m16.268s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m4.308s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 15.19s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 12.59s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 9.57s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 9.51s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 6.47s amadan.net/oficina/equipo/internal/equipotest TestRosterAuditFailureRollsBack
machine: 32 CPUs, load 30.76, cpu waiting 16.72%, memory waiting 0.00%, io waiting 0.30%
--- 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.8%, load 27.29
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
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed

receipt: test step 1m5.794s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m4.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 35.89, cpu waiting 19.72%, memory waiting 0.00%, io waiting 0.36%
--- shard 16 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: plan3test started 30s late; cpu waiting 26.8%, load 27.29
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 537ms 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 27.29, cpu waiting 11.68%, memory waiting 0.00%, io waiting 1.07%
--- 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 28.9%, load 27.29
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/copydesk: its inputs changed
cache miss: amadan.net/oficina/equipo/cmd/equipo-runner: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/opencode: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runnerproto: 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:301 Reason: File:s001.txt}
--- FAIL: TestTimeouts (0.61s)

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

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.912s, over the 15s its record on line 40 allows; reported only, timing fails on CI

receipt: test step 2m16.756s against a 60s target (the gate's other steps are not in this figure)
receipt: 16 packages ran, 48 cached, 20 without tests, 1 failed
receipt: slow package 53.567s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 51.397s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 45.275s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 39.912s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 39.84s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 21.81s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 15.44s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringOfflineGo
receipt: slow test 10.89s amadan.net/oficina/equipo/internal/idtest TestIDCallbackGuardAndPendingNonce
receipt: slow test 10.82s amadan.net/oficina/equipo/internal/equipo TestAgentReadRechecksIdentity
receipt: slow test 9.63s 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 3e074674e5a7890775d21c5208e473a6a207e6dc 0.61s 14.70
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 14.70, cpu waiting 5.78%, memory waiting 0.00%, io waiting 0.10%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
cache miss: amadan.net/oficina/equipo/internal/headless: its inputs changed

receipt: test step 1m23.181s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m21.642s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.33s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 15.2s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.6s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.83s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.03s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 41.39, cpu waiting 22.43%, memory waiting 0.00%, io waiting 0.43%
--- 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 1m33.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 1m32.186s amadan.net/oficina/equipo/internal/headless
receipt: slow test 26.47s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 22.98s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 14.25s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 10.47s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 8.12s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 38.23, cpu waiting 19.72%, memory waiting 0.00%, io waiting 0.36%
--- 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.405s 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.966s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.22s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.11s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 13.03s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 10.26s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.2s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 33.17, cpu waiting 17.88%, memory waiting 0.00%, io waiting 0.32%
--- shard 21 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-rest: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserEmptyExplore
=== RUN   TestBrowserEmptyExplore
time=2026-11-22T16:45:17.363Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-22T16:45:17.363Z level=INFO msg="startup phase done" phase=state_lock took=61µs
time=2026-11-22T16:45:17.363Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-22T16:45:17.363Z level=INFO msg="startup phase done" phase=claim_roots took=89µs
time=2026-11-22T16:45:17.363Z level=INFO msg="startup phase" phase=sweep
time=2026-11-22T16:45:17.391Z level=INFO msg="startup phase done" phase=sweep took=27.985ms
time=2026-11-22T16:45:17.391Z level=INFO msg="startup phase" phase=credentials
time=2026-11-22T16:45:17.392Z level=INFO msg="startup phase done" phase=credentials took=137µs
time=2026-11-22T16:45:17.392Z level=INFO msg="startup phase" phase=open_state
time=2026-11-22T16:45:17.434Z level=INFO msg="startup phase done" phase=open_state took=42.794ms
time=2026-11-22T16:45:17.435Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-22T16:45:17.436Z level=INFO msg=connecting host=127.0.0.1:45929 protocol=28
time=2026-11-22T16:45:17.438Z level=INFO msg=connected host=127.0.0.1:45929 took=2.089ms
time=2026-11-22T16:45:17.438Z level=INFO msg="capabilities gathering"
time=2026-11-22T16:45:17.438Z level=INFO msg="capabilities gathered" took=484µs tags=linux,claude,go
time=2026-11-22T16:45:17.441Z level=INFO msg="hello sent" protocol=28
time=2026-11-22T16:45:17.443Z level=INFO msg=welcome protocol=28 role=primary generation=1
time=2026-11-22T16:45:18.526Z 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.83s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m28.044s
FAIL	amadan.net/oficina/equipo/internal/headless	88.341s


receipt: test step 1m29.416s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m28.044s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.28s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.83s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.58s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 10.38s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 8.04s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserEmptyExplore$' -count=1 ./internal/headless   (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserEmptyExplore browser-headless-rest 3e074674e5a7890775d21c5208e473a6a207e6dc 5.83s 39.12
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 35.89, cpu waiting 17.88%, memory waiting 0.00%, io waiting 0.32%
--- 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 955ms 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 851ms 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 214ms 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.073s 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 5.73, cpu waiting 1.97%, memory waiting 0.00%, io waiting 1.66%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless   (53s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.30s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.42s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.49s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.92s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.74s
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^C5_review_auth$|^TestHeadlessConnections$/^C5_review_failover$|^TestHeadlessConnections$/^C5_review_on_codex$|^TestHeadlessConnections$/^C5_review_other_family_first$' ./internal/headless   (63s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 12.89s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 14.33s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 20.70s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 13.21s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless   (22s)
ok ./internal/headless TestMixedVersions 20.12s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks   (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.78s
+ 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 44.80, cpu waiting 22.50%, memory waiting 0.00%, io waiting 0.62%
--- 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.294s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 3 without tests, 0 failed
receipt: slow package 7.248s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 156ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 75ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 5.19s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.65s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 320ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 160ms 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.171s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.871s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 270ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 200ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryReusedPID
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryMalformedRecord
machine: 32 CPUs, load 12.35, cpu waiting 5.04%, memory waiting 0.00%, io waiting 1.45%
--- shard 25 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: runner-dead-references started 30s late; cpu waiting 26.8%, load 27.29
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2581 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.571s
machine: 32 CPUs, load 41.70, cpu waiting 20.79%, memory waiting 0.00%, io waiting 0.85%
--- shard 26 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: staticcheck started 30s late; cpu waiting 26.8%, load 27.29
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 34.79, cpu waiting 13.00%, memory waiting 0.00%, io waiting 1.04%
--- 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.9%, load 27.29
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 37.93, cpu waiting 16.21%, memory waiting 0.00%, io waiting 0.97%
--- 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 28.9%, load 27.29
shard 28: make gitleaks
4:44PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
4:44PM INF 1113 commits scanned.
4:44PM INF scanned ~61507289 bytes (61.51 MB) in 14.1s
4:44PM INF no leaks found
machine: 32 CPUs, load 41.70, cpu waiting 20.79%, memory waiting 0.00%, io waiting 0.85%
=== perf ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -require TestPerfScreens,TestPerfBoot -tags perf -count=1 -p 1 -parallel 1 -run '^TestPerf' ./...
perf: GET /: median 1.054ms, worst 1.156ms, budget 150ms
perf: GET /api/runner/protocol: median 86µs, worst 111µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 588µs, worst 657µs, budget 150ms
perf: GET /api/v1/accounts: median 420µs, worst 441µs, budget 150ms
perf: GET /api/v1/auth/devices: median 446µs, worst 487µs, budget 150ms
perf: GET /api/v1/budgets: median 472µs, worst 504µs, budget 150ms
perf: GET /api/v1/capabilities: median 263µs, worst 317µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.197ms, worst 1.303ms, budget 150ms
perf: GET /api/v1/connections: median 567µs, worst 597µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 526µs, worst 570µs, budget 150ms
perf: GET /api/v1/conversation: median 885µs, worst 962µs, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.412ms, worst 1.508ms, budget 150ms
perf: GET /api/v1/coordinator: median 2.029ms, worst 2.069ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 483µs, worst 495µs, budget 150ms
perf: GET /api/v1/journey: median 7.64ms, worst 7.94ms, budget 150ms
perf: GET /api/v1/me: median 430µs, worst 479µs, budget 150ms
perf: GET /api/v1/me/settings: median 508µs, worst 548µs, budget 150ms
perf: GET /api/v1/needs-you: median 7.344ms, worst 7.447ms, budget 150ms
perf: GET /api/v1/notifications: median 1.64ms, worst 1.724ms, budget 150ms
perf: GET /api/v1/onboarding: median 387µs, worst 469µs, budget 150ms
perf: GET /api/v1/people: median 453µs, worst 490µs, budget 150ms
perf: GET /api/v1/playbooks: median 600µs, worst 659µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 544µs, worst 575µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 861µs, worst 887µs, budget 150ms
perf: GET /api/v1/preferences: median 756µs, worst 783µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 463µs, worst 531µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 577µs, worst 647µs, budget 150ms
perf: GET /api/v1/roster: median 469µs, worst 503µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 432µs, worst 474µs, budget 150ms
perf: GET /api/v1/specialists: median 8.097ms, worst 8.213ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 7.925ms, worst 8.046ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 886µs, worst 917µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.175ms, worst 1.247ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 769µs, worst 780µs, budget 150ms
perf: GET /api/v1/teams: median 436µs, worst 460µs, budget 150ms
perf: GET /api/v1/templates: median 615µs, worst 654µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 462µs, worst 519µs, budget 150ms
perf: GET /auth/callback: median 94µs, worst 115µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.448ms, worst 5.979ms, budget 150ms
perf: GET /auth/verify: median 69µs, worst 107µs, budget 150ms
perf: GET /connections: median 3.669ms, worst 3.764ms, budget 150ms
perf: GET /conversation: median 7.257ms, worst 7.808ms, budget 150ms
perf: GET /conversation/connections: median 259µs, worst 267µs, budget 150ms
perf: GET /conversation/notebook: median 237µs, worst 269µs, budget 150ms
perf: GET /conversation/settings: median 3.88ms, worst 4.059ms, budget 150ms
perf: GET /conversation/settings/autonomy: median 3.48ms, worst 3.538ms, budget 150ms
perf: GET /conversation/settings/connections: median 6.114ms, worst 6.273ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 6.356ms, worst 6.51ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.672ms, worst 6.011ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 4.178ms, worst 4.332ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.374ms, worst 4.485ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.261ms, worst 4.391ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.267ms, worst 3.301ms, budget 150ms
perf: GET /conversation/settings/thinking: median 3.801ms, worst 3.914ms, budget 150ms
perf: GET /housekeeping: median 3.645ms, worst 3.683ms, budget 150ms
perf: GET /invites/new: median 574µs, worst 611µs, budget 150ms
perf: GET /invites/{id}: median 607µs, worst 618µs, budget 150ms
perf: GET /jobs: median 3.196ms, worst 3.244ms, budget 150ms
perf: GET /jobs/{id}: median 4.369ms, worst 4.598ms, budget 150ms
perf: GET /journey: median 12.443ms, worst 15.999ms, budget 150ms
perf: GET /nav/rail: median 3.19ms, worst 3.421ms, budget 150ms
perf: GET /needs-you: median 11.773ms, worst 12.309ms, budget 150ms
perf: GET /onboarding: median 4.281ms, worst 4.343ms, budget 150ms
perf: GET /people: median 3.517ms, worst 3.721ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 5.063ms, worst 5.192ms, budget 150ms
perf: GET /playbooks: median 4.604ms, worst 4.73ms, budget 150ms
perf: GET /playbooks/new: median 5.011ms, worst 5.145ms, budget 150ms
perf: GET /playbooks/{id}: median 4.395ms, worst 4.61ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.636ms, worst 4.786ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 3.94ms, worst 6.164ms, budget 150ms
perf: GET /preferences: median 4.186ms, worst 4.25ms, budget 150ms
perf: GET /preferences/sources/{source}: median 3.863ms, worst 3.954ms, budget 150ms
perf: GET /projects: median 5.122ms, worst 5.214ms, budget 150ms
perf: GET /projects/accounts: median 3.518ms, worst 3.605ms, budget 150ms
perf: GET /projects/new: median 3.43ms, worst 3.583ms, budget 150ms
perf: GET /projects/{id}: median 10.207ms, worst 10.299ms, budget 150ms
perf: GET /projects/{id}/edit: median 3.598ms, worst 3.729ms, budget 150ms
perf: GET /runners/enrol: median 4.303ms, worst 4.396ms, budget 150ms
perf: GET /settings: median 3.32ms, worst 3.484ms, budget 150ms
perf: GET /settings/coordinator: median 5.536ms, worst 5.776ms, budget 150ms
perf: GET /settings/devices: median 3.238ms, worst 3.4ms, budget 150ms
perf: GET /settings/recovery: median 3.372ms, worst 3.435ms, budget 150ms
perf: GET /settings/recovery/release: median 3.371ms, worst 3.4ms, budget 150ms
perf: GET /settings/thinking: median 245µs, worst 259µs, budget 150ms
perf: GET /signin: median 314µs, worst 349µs, budget 150ms
perf: GET /specialists/new: median 3.289ms, worst 3.339ms, budget 150ms
perf: GET /specialists/{key}: median 10.628ms, worst 10.723ms, budget 150ms
perf: GET /specialists/{key}/edit: median 3.564ms, worst 3.604ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 3.601ms, worst 3.685ms, budget 150ms
perf: GET /tasks: median 5.078ms, worst 5.162ms, budget 150ms
perf: GET /tasks/new: median 3.267ms, worst 5.68ms, budget 150ms
perf: GET /tasks/{id}: median 5.639ms, worst 5.7ms, budget 150ms
perf: GET /tasks/{id}/merge: median 4.757ms, worst 4.795ms, budget 150ms
perf: GET /tasks/{id}/move: median 4.564ms, worst 4.669ms, budget 150ms
perf: GET /tasks/{id}/plan: median 5.591ms, worst 5.629ms, budget 150ms
perf: GET /tasks/{id}/preview: median 1.53ms, worst 1.593ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 5.061ms, worst 5.147ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 4.584ms, worst 4.626ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4.147ms, worst 4.304ms, budget 150ms
perf: GET /tasks/{id}/thread: median 7.798ms, worst 8.208ms, budget 150ms
perf: GET /team/{specialist}: median 4.312ms, worst 6.006ms, budget 150ms
perf: GET /teams: median 9.911ms, worst 10.111ms, budget 150ms
perf: GET /templates: median 3.336ms, worst 3.396ms, budget 150ms
perf: GET /usage: median 4.098ms, worst 4.127ms, budget 150ms
perf: GET /work: median 2.973ms, worst 2.989ms, budget 150ms
perf: cold boot: median 261ms of [260.107045ms 260.726828ms 264.755811ms], budget 500ms

receipt: test step 30.747s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 90 without tests, 0 failed
receipt: slow package 8.86s amadan.net/oficina/equipo/internal/equipotest
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-runner
receipt: slow package 0s amadan.net/oficina/equipo/cmd/equipo-tool-proxy
receipt: slow package 0s amadan.net/oficina/equipo/internal/advice
receipt: slow package 0s amadan.net/oficina/equipo/internal/attach
receipt: slow test 8.02s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 840ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 3.22 GiB in 23313 files
ci-box: module cache /home/ci/work/repos/oficina__equipo/cache/go-mod: 0.90 GiB in 32632 files
diff --git a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
index 4b5c6118..bfc46eac 100644
--- a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
+++ b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
@@ -218,3 +218,20 @@ Fix round 1 (review r1). `StopProof.ObservedAt` is controller time, a `time.Dura
| lifetime unchecked (`if false && ms < 0 \|\| false && ms > ...`) | `go test ./internal/hostedwire -run 'TestLaunchLifetimeBounds' -count=1` | `api_test.go:157: MaxLifetime(9223372036855 ms) = (-2562047h47m16.854551616s, <nil>), want (0, ErrDuration)` | yes, passes |
| negative lifetime allowed (`if ms > math...`) | same | `api_test.go:157: MaxLifetime(-288230376148111744 ms) = (1h0m0s, <nil>), want (0, ErrDuration)` | yes, passes |
| empty query unsigned (`if r.URL.RawQuery != "" {`) | `go test ./internal/hostedwire -run 'TestSignatureCoversEveryField' -count=1` | `sign_test.go:256: Verify after the empty query added = <nil>, want ErrBadSignature` and `... empty query removed = <nil>, want ErrBadSignature` | yes, passes |
+
+## Task 9
+
+`internal/hostedctl` foundation: the SQLite store (schema `schema/0001_jobs.sql`, `PRAGMA user_version`, WAL, busy timeout, foreign keys, one connection, `BEGIN IMMEDIATE` transactions), controller time and the controller skeleton. Controller time: `Now() = base + (Mono() - monoAtOpen)`. Every `Tx` commit and every `Checkpoint` writes `(Now(), Wall())`; on `Open` with a checkpoint, `base = cpT + max(0, wallNow - cpWall)`, `Restarted()` is true, a wall clock behind the checkpoint adds a `clock_rollback` audit row and a startup alert that `New` must deliver, and Open writes a fresh checkpoint. A fresh database starts at T = 0 with `Restarted()` false. RED was taken against stubs (API only, T from the wall clock, no schema, no checks): all ten tests failed by assertion (for example `clock_test.go:20: Now on a fresh database = 498708h0m0s, want 0`, `store_test.go:120: Open of a database at schema 99 = nil error, want ErrSchemaNewer`, `store_test.go:184: Tx = database is locked (5) (SQLITE_BUSY)` after a panicking Tx). GREEN: `go test ./internal/hostedctl -run 'TestStore|TestAudit|TestSpecImmutable|TestRollback|TestRestart' -count=1` ok; whole package 0.6 s.
+
+| Mutation | Command | Observed failure | Restored |
+| --- | --- | --- | --- |
+| T from the wall clock (`elapsed := k.c.Wall().Sub(k.wallAtOpen)`) | `go test ./internal/hostedctl -run 'TestRollbackThenElapsedTime' -count=1` | `clock_test.go:31: Now advanced 0s after the wall clock went back 1h and Mono advanced 10m, want exactly 10m` | yes, passes |
+| `Restarted()` false when the wall clock moved forward (`s.restarted = restarted && rollback > 0`) | `go test ./internal/hostedctl -run 'TestRestartMarksElapsedUntrusted' -count=1` | `clock_test.go:60: Restarted() after a restart with the wall clock ahead = false, want true` | yes, passes |
+| drop the `jobs_spec_immutable` trigger | `go test ./internal/hostedctl -run 'TestSpecImmutable' -count=1` | `store_test.go:218: UPDATE jobs SET spec_json = '{"image":"b"}' ... = <nil>, want 'spec is immutable'` and `store_test.go:228: spec after refused updates = "{\"image\":\"b\"}" "bbbb", want the original` | yes, passes |
+| extra: newer schema accepted (`if false && version > schemaVersion()`) | `go test ./internal/hostedctl -run 'TestStoreRefusesNewerSchema' -count=1` | `store_test.go:121: Open of a database at schema 99 = nil error, want ErrSchemaNewer` | yes, passes |
+| extra: nonce replay accepted (`ON CONFLICT ... DO UPDATE SET until_unix_ns = ...`) | `go test ./internal/hostedctl -run 'TestStoreRemembersNonces' -count=1` | `store_test.go:247: Remember(inst-1, n1) = (true, <nil>), want (false, nil)` | yes, passes |
+| extra: nil runner accepted (`case false && d.Runner == nil:`) | `go test ./internal/hostedctl -run 'TestNewRefusesNilDependency' -count=1` | `store_test.go:326: New without the runner = (&{...}, <nil>), want (nil, an error)` | yes, passes |
+| extra: no rollback alert (`if false && rollback > 0 {`) | `go test ./internal/hostedctl -run 'TestRestartWithRollback' -count=1` | `clock_test.go:125: StartupAlerts = [], want one clock_rollback alert naming 1h0m0s at 20m` | yes, passes |
+| extra: rollback alert sent again by a second `New` (`s.delivered = 0` after delivery) | same | `clock_test.go:146: alerts delivered after Open and two News = [{Kind:clock_rollback ...} {Kind:clock_rollback ...}], want exactly [...]` | yes, passes |
+| extra: no checkpoint in `Tx` commits | `go test ./internal/hostedctl -run 'TestRestartKeepsCommittedTime' -count=1` | `clock_test.go:98: Now after a restart = 0s, below the 7m0s a committed row already holds` | yes, passes |
+| extra: Open keeps the old checkpoint (`ON CONFLICT (id) DO NOTHING`) | `go test ./internal/hostedctl -run 'TestRestartMarksElapsedUntrusted' -count=1` | `clock_test.go:72: Now after a second restart with the wall clock 20m back = 15m0s, want 35m` | yes, passes |
diff --git a/internal/hostedctl/clock.go b/internal/hostedctl/clock.go
new file mode 100644
index 00000000..c344075b
--- /dev/null
+++ b/internal/hostedctl/clock.go
@@ -0,0 +1,66 @@
+package hostedctl
+
+import (
+ "fmt"
+ "math"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/isolatedjob"
+)
+
+// T is controller time: nanoseconds since the controller's first start. It
+// advances only with the host's monotonic clock while the controller runs,
+// never decreases, and is stored as an integer. Deadlines, grace periods and
+// timeouts use T, never the wall clock.
+type T time.Duration
+
+// CtlClock reads controller time: the base restored at Open plus the
+// monotonic time elapsed since Open. The wall clock plays no part while the
+// controller runs, so setting it back or forward does not move T.
+type CtlClock struct {
+ base T // T at Open
+ monoAtOpen time.Duration // Clock.Mono() at Open
+ c isolatedjob.Clock
+}
+
+// Now returns the current controller time.
+func (k *CtlClock) Now() T {
+ elapsed := k.c.Mono() - k.monoAtOpen
+ if elapsed < 0 { // Mono never decreases; a broken clock must not move T back
+ elapsed = 0
+ }
+ return k.base + T(elapsed)
+}
+
+// restoreBase works out controller time at Open from the last checkpoint
+// (cpT, cpWall) and the wall clock now, both walls in Unix nanoseconds.
+//
+// The base is cpT plus the wall time since the checkpoint, or cpT alone when
+// the wall clock is behind the checkpoint, so T never decreases. That wall
+// delta is not the real downtime: the clock may have moved during the
+// downtime, back and forth, and still read ahead of the checkpoint. Callers
+// mark elapsed time across the restart untrusted whatever the delta says.
+// rollback is how far the wall clock is behind the checkpoint, zero when it
+// is not.
+func restoreBase(cpT T, cpWall, wallNow int64) (base T, rollback time.Duration, err error) {
+ if cpT < 0 {
+ return 0, 0, fmt.Errorf("hostedctl: clock checkpoint holds negative controller time %d", cpT)
+ }
+ if wallNow < cpWall {
+ return cpT, wallDelta(cpWall, wallNow), nil
+ }
+ ahead := wallDelta(wallNow, cpWall)
+ if ahead > time.Duration(math.MaxInt64-int64(cpT)) {
+ return 0, 0, fmt.Errorf("hostedctl: wall clock %v ahead of the checkpoint; controller time would overflow", ahead)
+ }
+ return cpT + T(ahead), 0, nil
+}
+
+// wallDelta returns later minus earlier, saturating at the largest Duration.
+func wallDelta(later, earlier int64) time.Duration {
+ d := later - earlier
+ if d < 0 { // the subtraction overflowed
+ return time.Duration(math.MaxInt64)
+ }
+ return time.Duration(d)
+}
diff --git a/internal/hostedctl/clock_test.go b/internal/hostedctl/clock_test.go
new file mode 100644
index 00000000..f8f7724a
--- /dev/null
+++ b/internal/hostedctl/clock_test.go
@@ -0,0 +1,169 @@
+package hostedctl
+
+import (
+ "context"
+ "database/sql"
+ "errors"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/isolatedjob/isolatedjobtest"
+)
+
+func TestRollbackThenElapsedTime(t *testing.T) {
+ ctx := context.Background()
+ clk := isolatedjobtest.NewFakeClock(testWall)
+ s := openStore(t, filepath.Join(t.TempDir(), "hosted.db"), clk)
+ if got := s.Clock().Now(); got != 0 {
+ t.Fatalf("Now on a fresh database = %v, want 0", time.Duration(got))
+ }
+ clk.AdvanceMono(3 * time.Minute)
+ start := s.Clock().Now()
+
+ clk.SetWall(testWall.Add(-time.Hour))
+ clk.AdvanceMono(10 * time.Minute)
+ if err := s.Checkpoint(ctx); err != nil {
+ t.Fatalf("Checkpoint = %v", err)
+ }
+ if got := time.Duration(s.Clock().Now() - start); got != 10*time.Minute {
+ t.Fatalf("Now advanced %v after the wall clock went back 1h and Mono advanced 10m, want exactly 10m", got)
+ }
+
+ clk.SetWall(testWall.Add(5 * time.Hour))
+ if got := time.Duration(s.Clock().Now() - start); got != 10*time.Minute {
+ t.Fatalf("Now advanced %v after the wall clock jumped forward with no Mono time, want 10m still", got)
+ }
+}
+
+func TestRestartMarksElapsedUntrusted(t *testing.T) {
+ ctx := context.Background()
+ path := filepath.Join(t.TempDir(), "hosted.db")
+ clk := isolatedjobtest.NewFakeClock(testWall)
+ s, err := Open(ctx, path, clk)
+ if err != nil {
+ t.Fatal(err)
+ }
+ clk.AdvanceMono(5 * time.Minute)
+ if err := s.Checkpoint(ctx); err != nil {
+ t.Fatal(err)
+ }
+ _ = s.Close()
+
+ // A new process: Mono starts again from zero, the wall clock is 30 min on.
+ s = openStore(t, path, isolatedjobtest.NewFakeClock(testWall.Add(30*time.Minute)))
+ if got := time.Duration(s.Clock().Now()); got != 35*time.Minute {
+ t.Fatalf("Now after a restart with the wall clock 30m ahead = %v, want 35m", got)
+ }
+ if !s.Restarted() {
+ t.Fatal("Restarted() after a restart with the wall clock ahead = false, want true")
+ }
+ if alerts := s.StartupAlerts(); len(alerts) != 0 {
+ t.Fatalf("StartupAlerts with the wall clock ahead = %v, want none", alerts)
+ }
+ _ = s.Close()
+
+ // Open again with no write in between and the wall clock 20 min back
+ // (still 10 min ahead of the first checkpoint). T handed out at 35m must
+ // not drop to 15m, so Open's own checkpoint is the one that counts.
+ s = openStore(t, path, isolatedjobtest.NewFakeClock(testWall.Add(10*time.Minute)))
+ if got := time.Duration(s.Clock().Now()); got != 35*time.Minute {
+ t.Fatalf("Now after a second restart with the wall clock 20m back = %v, want 35m", got)
+ }
+ if !s.Restarted() {
+ t.Fatal("Restarted() after the second restart = false, want true")
+ }
+}
+
+func TestRestartKeepsCommittedTime(t *testing.T) {
+ ctx := context.Background()
+ path := filepath.Join(t.TempDir(), "hosted.db")
+ clk := isolatedjobtest.NewFakeClock(testWall)
+ s, err := Open(ctx, path, clk)
+ if err != nil {
+ t.Fatal(err)
+ }
+ clk.AdvanceMono(7 * time.Minute)
+ stored := s.Clock().Now()
+ if err := s.Tx(ctx, func(tx *sql.Tx) error {
+ return appendAudit(tx, Audit{Action: "launch", At: stored})
+ }); err != nil {
+ t.Fatal(err)
+ }
+ _ = s.Close() // no reaper checkpoint since the write
+
+ s = openStore(t, path, isolatedjobtest.NewFakeClock(testWall))
+ if got := s.Clock().Now(); got < stored {
+ t.Fatalf("Now after a restart = %v, below the %v a committed row already holds", time.Duration(got), time.Duration(stored))
+ }
+}
+
+func TestRestartWithRollback(t *testing.T) {
+ ctx := context.Background()
+ path := filepath.Join(t.TempDir(), "hosted.db")
+ clk := isolatedjobtest.NewFakeClock(testWall)
+ s, err := Open(ctx, path, clk)
+ if err != nil {
+ t.Fatal(err)
+ }
+ clk.AdvanceMono(20 * time.Minute)
+ if err := s.Checkpoint(ctx); err != nil {
+ t.Fatal(err)
+ }
+ _ = s.Close()
+
+ s = openStore(t, path, isolatedjobtest.NewFakeClock(testWall.Add(-time.Hour)))
+ if got := time.Duration(s.Clock().Now()); got != 20*time.Minute {
+ t.Fatalf("Now after a restart with the wall clock 1h behind = %v, want 20m (unchanged)", got)
+ }
+ if !s.Restarted() {
+ t.Fatal("Restarted() after a restart with the wall clock behind = false, want true")
+ }
+ alerts := s.StartupAlerts()
+ if len(alerts) != 1 || alerts[0].Kind != AlertClockRollback || !strings.Contains(alerts[0].Detail, "1h0m0s") || alerts[0].At != T(20*time.Minute) {
+ t.Fatalf("StartupAlerts = %+v, want one %s alert naming 1h0m0s at 20m", alerts, AlertClockRollback)
+ }
+ var rolled []Audit
+ for _, a := range auditRows(t, s) {
+ if a.Action == AlertClockRollback {
+ rolled = append(rolled, a)
+ }
+ }
+ if len(rolled) != 1 || rolled[0].Actor != "" || !strings.Contains(rolled[0].Reason, "1h0m0s") {
+ t.Fatalf("clock_rollback audit rows = %+v, want one from the controller naming 1h0m0s", rolled)
+ }
+
+ rec := &recordingAlerter{}
+ deps := Deps{Store: s, Runner: nopRunner{}, Auditor: nopAuditor{}, Alerter: rec}
+ if _, err := New(Config{}, deps); err != nil {
+ t.Fatalf("New = %v", err)
+ }
+ if _, err := New(Config{}, deps); err != nil {
+ t.Fatalf("second New = %v", err)
+ }
+ if len(rec.got) != 1 || rec.got[0] != alerts[0] {
+ t.Fatalf("alerts delivered after Open and two News = %+v, want exactly [%+v]", rec.got, alerts[0])
+ }
+ _ = s.Close()
+
+ // The wall clock is still behind the first checkpoint, but Open wrote a
+ // new one, so this restart sees no rollback.
+ s = openStore(t, path, isolatedjobtest.NewFakeClock(testWall.Add(-time.Hour)))
+ if alerts := s.StartupAlerts(); len(alerts) != 0 {
+ t.Fatalf("StartupAlerts on the next restart = %+v, want none", alerts)
+ }
+ _ = s.Close()
+
+ // An alert that cannot be delivered stops the controller starting.
+ s = openStore(t, path, isolatedjobtest.NewFakeClock(testWall.Add(-2*time.Hour)))
+ down := errors.New("alert channel down")
+ c, err := New(Config{}, Deps{Store: s, Runner: nopRunner{}, Auditor: nopAuditor{}, Alerter: &recordingAlerter{fail: down}})
+ if c != nil || !errors.Is(err, down) {
+ t.Fatalf("New with an undeliverable rollback alert = (%v, %v), want (nil, the alert error)", c, err)
+ }
+ rec = &recordingAlerter{}
+ if _, err := New(Config{}, Deps{Store: s, Runner: nopRunner{}, Auditor: nopAuditor{}, Alerter: rec}); err != nil || len(rec.got) != 1 {
+ t.Fatalf("New after the channel recovers = %v with %d alerts, want nil and 1", err, len(rec.got))
+ }
+}
diff --git a/internal/hostedctl/controller.go b/internal/hostedctl/controller.go
new file mode 100644
index 00000000..6920297d
--- /dev/null
+++ b/internal/hostedctl/controller.go
@@ -0,0 +1,66 @@
+package hostedctl
+
+import (
+ "context"
+ "errors"
+ "maps"
+
+ "amadan.net/oficina/equipo/internal/isolatedjob"
+)
+
+// Alert is one operator alert. At is controller time.
+type Alert struct {
+ Kind, Detail string
+ At T
+}
+
+// Alerter delivers operator alerts.
+type Alerter interface {
+ Alert(ctx context.Context, a Alert) error
+}
+
+// Config is the controller's settings. Later tasks add fields.
+type Config struct {
+ Enabled bool // launches allowed; only EQUIPO_HOSTED_ENABLED=1 sets it
+ Images map[isolatedjob.ImageDigest]bool // image digests launches may use
+}
+
+// Deps are the controller's collaborators. Every one is required.
+type Deps struct {
+ Store *Store
+ Runner isolatedjob.Runner
+ Auditor isolatedjob.NetworkAuditor
+ Alerter Alerter
+}
+
+// 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
+}
+
+// New builds a controller. It refuses a nil dependency. It then delivers the
+// store's startup alerts (a clock rollback found by Open) through
+// d.Alerter, once each; if one cannot be delivered New returns that error
+// and no controller, so a controller never runs with an undelivered rollback
+// alert. A later New on the same store retries only the undelivered alerts.
+func New(cfg Config, d Deps) (*Controller, error) {
+ switch {
+ case d.Store == nil:
+ return nil, errors.New("hostedctl: controller needs a store")
+ case d.Runner == nil:
+ return nil, errors.New("hostedctl: controller needs a runner")
+ case d.Auditor == nil:
+ return nil, errors.New("hostedctl: controller needs a network auditor")
+ case d.Alerter == nil:
+ return nil, errors.New("hostedctl: controller needs an alerter")
+ }
+ if err := d.Store.deliverStartupAlerts(context.Background(), d.Alerter); err != nil {
+ return nil, err
+ }
+ cfg.Images = maps.Clone(cfg.Images)
+ return &Controller{cfg: cfg, store: d.Store, runner: d.Runner, auditor: d.Auditor, alerter: d.Alerter}, nil
+}
diff --git a/internal/hostedctl/schema/0001_jobs.sql b/internal/hostedctl/schema/0001_jobs.sql
new file mode 100644
index 00000000..35326f45
--- /dev/null
+++ b/internal/hostedctl/schema/0001_jobs.sql
@@ -0,0 +1,94 @@
+-- Schema version 1 of the hosted controller store. Controller times (columns
+-- ending _t) are integer nanoseconds of controller time. Wall times (columns
+-- ending _unix_ns) are Unix nanoseconds. Migrations are additive: a later
+-- version adds a new file and never edits this one.
+
+-- One row per attempt, created as the launch intent before any provider call.
+CREATE TABLE jobs (
+ attempt_id TEXT PRIMARY KEY,
+ launch_id TEXT NOT NULL UNIQUE,
+ vm_ref TEXT UNIQUE, -- absent until the provider answers
+ task_id TEXT NOT NULL,
+ account_id TEXT NOT NULL,
+ actor_key TEXT NOT NULL, -- the verified key that asked for the launch
+ purpose TEXT NOT NULL,
+ replaces_attempt TEXT, -- absent unless this attempt replaces another
+ spec_json TEXT NOT NULL,
+ spec_sha256 TEXT NOT NULL,
+ state TEXT NOT NULL,
+ launched_t INTEGER NOT NULL,
+ deadline_t INTEGER NOT NULL,
+ drain_t INTEGER NOT NULL,
+ stop_t INTEGER NOT NULL,
+ epoch INTEGER NOT NULL DEFAULT 0,
+ pause_generation INTEGER NOT NULL DEFAULT 0,
+ pause_started_t INTEGER, -- absent unless a pause is open
+ pause_quiescent INTEGER NOT NULL DEFAULT 0 CHECK (pause_quiescent IN (0, 1)),
+ pause_cancelled INTEGER NOT NULL DEFAULT 0 CHECK (pause_cancelled IN (0, 1)),
+ stop_requested_t INTEGER, -- absent until a stop is asked for
+ stop_reason TEXT,
+ stop_proof_json TEXT, -- absent until a stop is proven
+ revision INTEGER NOT NULL DEFAULT 0
+);
+
+CREATE INDEX jobs_state ON jobs(state);
+
+-- The launch spec is what the provider was asked for; it never changes.
+CREATE TRIGGER jobs_spec_immutable
+BEFORE UPDATE OF spec_json, spec_sha256 ON jobs
+WHEN NEW.spec_json IS NOT OLD.spec_json OR NEW.spec_sha256 IS NOT OLD.spec_sha256
+BEGIN
+ SELECT RAISE(ABORT, 'spec is immutable');
+END;
+
+-- Resume operations, kept for the attempt's lifetime so a retried operation
+-- ID returns its original epoch.
+CREATE TABLE resume_ops (
+ attempt_id TEXT NOT NULL REFERENCES jobs(attempt_id) ON DELETE CASCADE,
+ operation_id TEXT NOT NULL,
+ status TEXT NOT NULL CHECK (status IN ('pending', 'done', 'failed')),
+ prepared_epoch INTEGER NOT NULL,
+ result_epoch INTEGER, -- absent until done
+ prepared_t INTEGER NOT NULL,
+ completed_t INTEGER, -- absent until done or failed
+ PRIMARY KEY (attempt_id, operation_id)
+);
+
+-- At most one pending resume per attempt.
+CREATE UNIQUE INDEX resume_ops_one_pending ON resume_ops(attempt_id) WHERE status = 'pending';
+
+-- VMs the provider lists that match no job, with when the controller first
+-- saw each.
+CREATE TABLE unmatched_vms (
+ vm_ref TEXT PRIMARY KEY,
+ first_seen_t INTEGER NOT NULL
+);
+
+-- Request nonces held until they expire, so a replay is refused.
+CREATE TABLE nonces (
+ key_id TEXT NOT NULL,
+ nonce TEXT NOT NULL,
+ until_unix_ns INTEGER NOT NULL,
+ PRIMARY KEY (key_id, nonce)
+);
+
+CREATE INDEX nonces_until ON nonces(until_unix_ns);
+
+-- Every decision the controller takes. Never holds credentials.
+CREATE TABLE audit (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ actor_key TEXT NOT NULL, -- empty for the controller itself
+ account_id TEXT NOT NULL,
+ task_id TEXT NOT NULL,
+ attempt_id TEXT NOT NULL,
+ action TEXT NOT NULL CHECK (action <> ''),
+ reason TEXT NOT NULL,
+ at_t INTEGER NOT NULL
+);
+
+-- The last controller-time checkpoint: one row.
+CREATE TABLE clock (
+ id INTEGER PRIMARY KEY CHECK (id = 1),
+ t_ns INTEGER NOT NULL CHECK (t_ns >= 0),
+ wall_unix_ns INTEGER NOT NULL
+);
diff --git a/internal/hostedctl/store.go b/internal/hostedctl/store.go
new file mode 100644
index 00000000..bae61f9a
--- /dev/null
+++ b/internal/hostedctl/store.go
@@ -0,0 +1,322 @@
+// Package hostedctl is the core of equipo-hosted-controller: the job table,
+// controller time, launch intents, stop proof, pause generations, resume
+// epochs and the reaper. It talks to VMs only through isolatedjob.Runner.
+package hostedctl
+
+import (
+ "context"
+ "database/sql"
+ "embed"
+ "errors"
+ "fmt"
+ "net/url"
+ "sync"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/hostedwire"
+ "amadan.net/oficina/equipo/internal/isolatedjob"
+
+ _ "modernc.org/sqlite"
+)
+
+// ErrSchemaNewer: the database was written by a newer controller. Open
+// refuses it rather than guess what the newer columns mean.
+var ErrSchemaNewer = errors.New("hostedctl: database schema is newer than this controller")
+
+// AlertClockRollback is the alert kind, and the audit action, raised when
+// Open finds the wall clock behind the last checkpoint.
+const AlertClockRollback = "clock_rollback"
+
+//go:embed schema/*.sql
+var schemaFS embed.FS
+
+// migrations are applied in order; version n is migrations[n-1]. Add a file,
+// never edit one.
+var migrations = []string{"schema/0001_jobs.sql"}
+
+// schemaVersion is the newest schema this code knows.
+func schemaVersion() int { return len(migrations) }
+
+// Store is the controller's SQLite database and its controller time.
+type Store struct {
+ db *sql.DB
+ host isolatedjob.Clock
+ clock *CtlClock
+ restarted bool
+
+ mu sync.Mutex
+ alerts []Alert // raised by Open, before any Alerter exists
+ delivered int // how many of alerts have reached an Alerter
+}
+
+// Audit is one audit row. Actor is the verified key that asked, or empty for
+// the controller itself. Reason never holds credentials.
+type Audit struct {
+ Actor hostedwire.KeyID
+ Account, Task, Attempt, Action, Reason string
+ At T
+}
+
+// Open opens or creates the store at path, applies any missing schema
+// migrations, and restores controller time from the last checkpoint.
+//
+// On a fresh database controller time starts at 0 and Restarted is false.
+// Otherwise T starts at the checkpoint's T plus the wall time since the
+// checkpoint, or the checkpoint's T alone when the wall clock is behind it;
+// Restarted is true; and a wall clock behind the checkpoint is audited and
+// kept as a clock_rollback startup alert for New to deliver. Either way Open
+// writes a fresh checkpoint, so the next restart does not count the same
+// wall time twice.
+func Open(ctx context.Context, path string, c isolatedjob.Clock) (*Store, error) {
+ if path == "" {
+ return nil, errors.New("hostedctl: store path is empty")
+ }
+ if c == nil {
+ return nil, errors.New("hostedctl: store needs a clock")
+ }
+ // _txlock=immediate makes every transaction BEGIN IMMEDIATE: it takes the
+ // write lock up front, so a read-check-write sequence is never
+ // interleaved with another writer.
+ dsn := (&url.URL{Scheme: "file", Path: path}).String() +
+ "?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)&_pragma=synchronous(FULL)&_pragma=foreign_keys(1)&_txlock=immediate"
+ db, err := sql.Open("sqlite", dsn)
+ if err != nil {
+ return nil, fmt.Errorf("hostedctl: open store: %w", err)
+ }
+ // One connection: transactions in this process queue for it instead of
+ // meeting SQLITE_BUSY.
+ db.SetMaxOpenConns(1)
+ s := &Store{db: db, host: c}
+ if err := s.migrate(ctx); err != nil {
+ _ = db.Close()
+ return nil, err
+ }
+ if err := s.restoreClock(ctx); err != nil {
+ _ = db.Close()
+ return nil, err
+ }
+ return s, nil
+}
+
+// migrate applies the missing migrations in one transaction. The version is
+// read inside the transaction, so two Opens racing apply each one once.
+func (s *Store) migrate(ctx context.Context) error {
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return fmt.Errorf("hostedctl: migrate: %w", err)
+ }
+ defer func() { _ = tx.Rollback() }()
+ var version int
+ if err := tx.QueryRowContext(ctx, `PRAGMA user_version`).Scan(&version); err != nil {
+ return fmt.Errorf("hostedctl: read schema version: %w", err)
+ }
+ if version > schemaVersion() {
+ return fmt.Errorf("%w: database at version %d, this controller knows %d", ErrSchemaNewer, version, schemaVersion())
+ }
+ if version == schemaVersion() {
+ return nil
+ }
+ for v := version; v < schemaVersion(); v++ {
+ body, err := schemaFS.ReadFile(migrations[v])
+ if err != nil {
+ return fmt.Errorf("hostedctl: read migration %s: %w", migrations[v], err)
+ }
+ if _, err := tx.ExecContext(ctx, string(body)); err != nil {
+ return fmt.Errorf("hostedctl: apply migration %s: %w", migrations[v], err)
+ }
+ if _, err := tx.ExecContext(ctx, fmt.Sprintf(`PRAGMA user_version = %d`, v+1)); err != nil {
+ return fmt.Errorf("hostedctl: record schema version %d: %w", v+1, err)
+ }
+ }
+ if err := tx.Commit(); err != nil {
+ return fmt.Errorf("hostedctl: migrate: %w", err)
+ }
+ return nil
+}
+
+// restoreClock sets controller time from the last checkpoint and writes a
+// new one, in one transaction with any clock_rollback audit row.
+func (s *Store) restoreClock(ctx context.Context) error {
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return fmt.Errorf("hostedctl: restore clock: %w", err)
+ }
+ defer func() { _ = tx.Rollback() }()
+
+ wallNow := s.host.Wall().UnixNano()
+ monoNow := s.host.Mono()
+ var cpT, cpWall int64
+ var base T
+ var rollback time.Duration
+ restarted := false
+ err = tx.QueryRowContext(ctx, `SELECT t_ns, wall_unix_ns FROM clock WHERE id = 1`).Scan(&cpT, &cpWall)
+ switch {
+ case errors.Is(err, sql.ErrNoRows): // a fresh database: T starts at 0
+ case err != nil:
+ return fmt.Errorf("hostedctl: read clock checkpoint: %w", err)
+ default:
+ restarted = true
+ if base, rollback, err = restoreBase(T(cpT), cpWall, wallNow); err != nil {
+ return err
+ }
+ }
+
+ var alert *Alert
+ if rollback > 0 {
+ alert = &Alert{
+ Kind: AlertClockRollback,
+ Detail: fmt.Sprintf("wall clock %v behind the last checkpoint at start; controller time kept at %v", rollback, time.Duration(base)),
+ At: base,
+ }
+ if err := appendAudit(tx, Audit{Action: AlertClockRollback, Reason: alert.Detail, At: base}); err != nil {
+ return err
+ }
+ }
+ if _, err := tx.ExecContext(ctx, `INSERT INTO clock (id, t_ns, wall_unix_ns) VALUES (1, ?, ?)
+ ON CONFLICT (id) DO UPDATE SET t_ns = excluded.t_ns, wall_unix_ns = excluded.wall_unix_ns`,
+ int64(base), wallNow); err != nil {
+ return fmt.Errorf("hostedctl: write clock checkpoint: %w", err)
+ }
+ if err := tx.Commit(); err != nil {
+ return fmt.Errorf("hostedctl: restore clock: %w", err)
+ }
+ s.clock = &CtlClock{base: base, monoAtOpen: monoNow, c: s.host}
+ s.restarted = restarted
+ if alert != nil {
+ s.alerts = append(s.alerts, *alert)
+ }
+ return nil
+}
+
+// Close closes the database.
+func (s *Store) Close() error { return s.db.Close() }
+
+// Clock returns the store's controller clock.
+func (s *Store) Clock() *CtlClock { return s.clock }
+
+// Restarted reports whether Open found state from an earlier run. When it
+// is true, the time that passed while the controller was down is unknown:
+// the wall delta Open added to T is a lower bound at best, never proof of
+// how long a job has lived.
+func (s *Store) Restarted() bool { return s.restarted }
+
+// StartupAlerts returns the alerts Open raised, delivered or not.
+func (s *Store) StartupAlerts() []Alert {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return append([]Alert(nil), s.alerts...)
+}
+
+// deliverStartupAlerts sends each startup alert not yet delivered, in order,
+// and stops at the first that fails; that one is tried again next time.
+func (s *Store) deliverStartupAlerts(ctx context.Context, a Alerter) error {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ for s.delivered < len(s.alerts) {
+ if err := a.Alert(ctx, s.alerts[s.delivered]); err != nil {
+ return fmt.Errorf("hostedctl: deliver %s alert: %w", s.alerts[s.delivered].Kind, err)
+ }
+ s.delivered++
+ }
+ return nil
+}
+
+// Tx runs fn in one write transaction, which holds SQLite's write lock from
+// the start. It rolls back when fn returns an error (returned as is) or
+// panics, and otherwise checkpoints controller time and commits. Use the tx
+// handle for every statement inside fn, audit rows included. Never call Tx,
+// Checkpoint or Remember from inside fn: the store has one connection, so
+// the inner call would wait for it forever. Do provider calls outside fn.
+//
+// The checkpoint in every commit means no committed row holds a T later than
+// the checkpoint, so T after a restart is at least every stored T even when
+// the wall clock went back.
+func (s *Store) Tx(ctx context.Context, fn func(*sql.Tx) error) error {
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return fmt.Errorf("hostedctl: begin: %w", err)
+ }
+ done := false
+ defer func() {
+ if !done {
+ _ = tx.Rollback()
+ }
+ }()
+ if err := fn(tx); err != nil {
+ return err
+ }
+ if err := s.checkpoint(ctx, tx); err != nil {
+ return err
+ }
+ if err := tx.Commit(); err != nil {
+ return fmt.Errorf("hostedctl: commit: %w", err)
+ }
+ done = true
+ return nil
+}
+
+// Checkpoint records (controller time, wall time) so a restart can carry T
+// on. The reaper calls it every pass; every Tx commit does it too.
+func (s *Store) Checkpoint(ctx context.Context) error {
+ return s.Tx(ctx, func(*sql.Tx) error { return nil })
+}
+
+func (s *Store) checkpoint(ctx context.Context, tx *sql.Tx) error {
+ res, err := tx.ExecContext(ctx, `UPDATE clock SET t_ns = ?, wall_unix_ns = ? WHERE id = 1`,
+ int64(s.clock.Now()), s.host.Wall().UnixNano())
+ if err != nil {
+ return fmt.Errorf("hostedctl: clock checkpoint: %w", err)
+ }
+ if n, err := res.RowsAffected(); err != nil || n != 1 {
+ return fmt.Errorf("hostedctl: clock checkpoint row missing (%d rows, %v)", n, err)
+ }
+ return nil
+}
+
+// Remember implements hostedwire.NonceStore. It records (id, nonce) until the
+// given wall time and reports false when the pair is already held and has not
+// expired. Expired nonces, by this host's wall clock, are pruned in the same
+// transaction. Any database error returns false with the error, so the
+// request is denied.
+func (s *Store) Remember(ctx context.Context, id hostedwire.KeyID, nonce string, until time.Time) (bool, error) {
+ if id == "" || nonce == "" {
+ return false, errors.New("hostedctl: nonce needs a key ID and a value")
+ }
+ fresh := false
+ err := s.Tx(ctx, func(tx *sql.Tx) error {
+ if _, err := tx.ExecContext(ctx, `DELETE FROM nonces WHERE until_unix_ns < ?`, s.host.Wall().UnixNano()); err != nil {
+ return fmt.Errorf("hostedctl: prune nonces: %w", err)
+ }
+ res, err := tx.ExecContext(ctx, `INSERT INTO nonces (key_id, nonce, until_unix_ns) VALUES (?, ?, ?)
+ ON CONFLICT (key_id, nonce) DO NOTHING`, string(id), nonce, until.UnixNano())
+ if err != nil {
+ return fmt.Errorf("hostedctl: remember nonce: %w", err)
+ }
+ n, err := res.RowsAffected()
+ if err != nil {
+ return fmt.Errorf("hostedctl: remember nonce: %w", err)
+ }
+ fresh = n == 1
+ return nil
+ })
+ if err != nil {
+ return false, err
+ }
+ return fresh, nil
+}
+
+// appendAudit adds one audit row inside tx, so it commits or rolls back with
+// the change it records. a must name an action and must not hold
+// credentials.
+func appendAudit(tx *sql.Tx, a Audit) error {
+ if a.Action == "" {
+ return errors.New("hostedctl: audit row needs an action")
+ }
+ _, err := tx.Exec(`INSERT INTO audit (actor_key, account_id, task_id, attempt_id, action, reason, at_t)
+ VALUES (?, ?, ?, ?, ?, ?, ?)`,
+ string(a.Actor), a.Account, a.Task, a.Attempt, a.Action, a.Reason, int64(a.At))
+ if err != nil {
+ return fmt.Errorf("hostedctl: append audit: %w", err)
+ }
+ return nil
+}
diff --git a/internal/hostedctl/store_test.go b/internal/hostedctl/store_test.go
new file mode 100644
index 00000000..b4bd875e
--- /dev/null
+++ b/internal/hostedctl/store_test.go
@@ -0,0 +1,331 @@
+package hostedctl
+
+import (
+ "context"
+ "database/sql"
+ "errors"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/hostedwire"
+ "amadan.net/oficina/equipo/internal/isolatedjob"
+ "amadan.net/oficina/equipo/internal/isolatedjob/isolatedjobtest"
+ "amadan.net/rastrillo/rastrillo/budget"
+)
+
+func TestMain(m *testing.M) { os.Exit(budget.Main(m)) }
+
+var testWall = time.Date(2026, 11, 22, 12, 0, 0, 0, time.UTC)
+
+// openStore opens the store at path and closes it when the test ends.
+func openStore(t *testing.T, path string, c isolatedjob.Clock) *Store {
+ t.Helper()
+ s, err := Open(context.Background(), path, c)
+ if err != nil {
+ t.Fatalf("Open(%s) = %v", path, err)
+ }
+ t.Cleanup(func() { _ = s.Close() })
+ return s
+}
+
+// rawDB opens path directly, past the store, to look at or tamper with it.
+func rawDB(t *testing.T, path string) *sql.DB {
+ t.Helper()
+ db, err := sql.Open("sqlite", (&url.URL{Scheme: "file", Path: path}).String()+"?_pragma=busy_timeout(5000)")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { _ = db.Close() })
+ return db
+}
+
+func insertJob(ctx context.Context, tx *sql.Tx, attempt string) error {
+ _, err := tx.ExecContext(ctx, `INSERT INTO jobs (attempt_id, launch_id, task_id, account_id, actor_key, purpose,
+ spec_json, spec_sha256, state, launched_t, deadline_t, drain_t, stop_t)
+ VALUES (?, ?, 'task-1', 'acct-1', 'inst-1', 'task', '{"image":"a"}', 'aaaa', 'waiting', 0, 100, 50, 90)`,
+ attempt, "launch-"+attempt)
+ return err
+}
+
+func TestStoreMigratesTwice(t *testing.T) {
+ ctx := context.Background()
+ path := filepath.Join(t.TempDir(), "hosted.db")
+
+ s, err := Open(ctx, path, isolatedjobtest.NewFakeClock(testWall))
+ if err != nil {
+ t.Fatalf("first Open = %v", err)
+ }
+ if s.Restarted() {
+ t.Fatal("first Open of a fresh database: Restarted() = true, want false")
+ }
+ if err := s.Tx(ctx, func(tx *sql.Tx) error { return insertJob(ctx, tx, "att-1") }); err != nil {
+ t.Fatalf("insert job = %v", err)
+ }
+ if err := s.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ s2 := openStore(t, path, isolatedjobtest.NewFakeClock(testWall))
+ if !s2.Restarted() {
+ t.Fatal("second Open: Restarted() = false, want true")
+ }
+ var n int
+ if err := s2.Tx(ctx, func(tx *sql.Tx) error {
+ return tx.QueryRowContext(ctx, `SELECT count(*) FROM jobs WHERE attempt_id = 'att-1'`).Scan(&n)
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if n != 1 {
+ t.Fatalf("jobs after a second Open = %d rows, want 1: the second Open must not reapply the schema", n)
+ }
+ _ = s2.Close()
+
+ var version int
+ if err := rawDB(t, path).QueryRow(`PRAGMA user_version`).Scan(&version); err != nil {
+ t.Fatal(err)
+ }
+ if version != schemaVersion() {
+ t.Fatalf("user_version = %d, want %d", version, schemaVersion())
+ }
+ for _, table := range []string{"jobs", "resume_ops", "unmatched_vms", "nonces", "audit", "clock"} {
+ var name string
+ err := rawDB(t, path).QueryRow(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?`, table).Scan(&name)
+ if err != nil {
+ t.Fatalf("table %s missing: %v", table, err)
+ }
+ }
+}
+
+func TestStoreRefusesNewerSchema(t *testing.T) {
+ ctx := context.Background()
+ path := filepath.Join(t.TempDir(), "hosted.db")
+ s, err := Open(ctx, path, isolatedjobtest.NewFakeClock(testWall))
+ if err != nil {
+ t.Fatal(err)
+ }
+ _ = s.Close()
+ db := rawDB(t, path)
+ if _, err := db.Exec(`PRAGMA user_version = 99`); err != nil {
+ t.Fatal(err)
+ }
+ _ = db.Close()
+
+ s, err = Open(ctx, path, isolatedjobtest.NewFakeClock(testWall))
+ if err == nil {
+ _ = s.Close()
+ t.Fatal("Open of a database at schema 99 = nil error, want ErrSchemaNewer")
+ }
+ if !errors.Is(err, ErrSchemaNewer) {
+ t.Fatalf("Open of a database at schema 99 = %v, want ErrSchemaNewer", err)
+ }
+}
+
+func auditRows(t *testing.T, s *Store) []Audit {
+ t.Helper()
+ ctx := context.Background()
+ var out []Audit
+ err := s.Tx(ctx, func(tx *sql.Tx) error {
+ rows, err := tx.QueryContext(ctx, `SELECT actor_key, account_id, task_id, attempt_id, action, reason, at_t FROM audit ORDER BY id`)
+ if err != nil {
+ return err
+ }
+ defer rows.Close()
+ for rows.Next() {
+ var a Audit
+ var actor string
+ var at int64
+ if err := rows.Scan(&actor, &a.Account, &a.Task, &a.Attempt, &a.Action, &a.Reason, &at); err != nil {
+ return err
+ }
+ a.Actor, a.At = hostedwire.KeyID(actor), T(at)
+ out = append(out, a)
+ }
+ return rows.Err()
+ })
+ if err != nil {
+ t.Fatalf("read audit = %v", err)
+ }
+ return out
+}
+
+func TestAuditRollsBackWithTx(t *testing.T) {
+ ctx := context.Background()
+ s := openStore(t, filepath.Join(t.TempDir(), "hosted.db"), isolatedjobtest.NewFakeClock(testWall))
+ a := Audit{Actor: "inst-1", Account: "acct-1", Task: "task-1", Attempt: "att-1", Action: "launch", Reason: "asked", At: 5}
+
+ failed := errors.New("later step failed")
+ err := s.Tx(ctx, func(tx *sql.Tx) error {
+ if err := appendAudit(tx, a); err != nil {
+ return err
+ }
+ return failed
+ })
+ if !errors.Is(err, failed) {
+ t.Fatalf("Tx = %v, want the function's own error", err)
+ }
+ func() {
+ defer func() { _ = recover() }()
+ _ = s.Tx(ctx, func(tx *sql.Tx) error {
+ if err := appendAudit(tx, a); err != nil {
+ return err
+ }
+ panic("boom")
+ })
+ }()
+ if got := auditRows(t, s); len(got) != 0 {
+ t.Fatalf("audit after a failed and a panicking Tx = %v, want no rows", got)
+ }
+
+ if err := s.Tx(ctx, func(tx *sql.Tx) error { return appendAudit(tx, a) }); err != nil {
+ t.Fatalf("Tx = %v", err)
+ }
+ if got := auditRows(t, s); len(got) != 1 || got[0] != a {
+ t.Fatalf("audit after a committed Tx = %v, want [%v]", got, a)
+ }
+
+ if err := s.Tx(ctx, func(tx *sql.Tx) error { return appendAudit(tx, Audit{Actor: "inst-1"}) }); err == nil {
+ t.Fatal("appendAudit with no action = nil, want an error")
+ }
+}
+
+func TestSpecImmutable(t *testing.T) {
+ ctx := context.Background()
+ s := openStore(t, filepath.Join(t.TempDir(), "hosted.db"), isolatedjobtest.NewFakeClock(testWall))
+ if err := s.Tx(ctx, func(tx *sql.Tx) error { return insertJob(ctx, tx, "att-1") }); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.Tx(ctx, func(tx *sql.Tx) error {
+ _, err := tx.ExecContext(ctx, `UPDATE jobs SET state = 'starting', vm_ref = 'vm-1', revision = revision + 1 WHERE attempt_id = 'att-1'`)
+ return err
+ }); err != nil {
+ t.Fatalf("update of state and vm_ref = %v, want nil", err)
+ }
+ for _, change := range []string{
+ `UPDATE jobs SET spec_json = '{"image":"b"}' WHERE attempt_id = 'att-1'`,
+ `UPDATE jobs SET spec_sha256 = 'bbbb' WHERE attempt_id = 'att-1'`,
+ `UPDATE jobs SET spec_json = NULL WHERE attempt_id = 'att-1'`,
+ } {
+ err := s.Tx(ctx, func(tx *sql.Tx) error {
+ _, err := tx.ExecContext(ctx, change)
+ return err
+ })
+ if err == nil || !strings.Contains(err.Error(), "spec is immutable") {
+ t.Errorf("%s = %v, want 'spec is immutable'", change, err)
+ }
+ }
+ var spec, sum string
+ if err := s.Tx(ctx, func(tx *sql.Tx) error {
+ return tx.QueryRowContext(ctx, `SELECT spec_json, spec_sha256 FROM jobs WHERE attempt_id = 'att-1'`).Scan(&spec, &sum)
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if spec != `{"image":"a"}` || sum != "aaaa" {
+ t.Fatalf("spec after refused updates = %q %q, want the original", spec, sum)
+ }
+}
+
+func TestStoreRemembersNonces(t *testing.T) {
+ ctx := context.Background()
+ clk := isolatedjobtest.NewFakeClock(testWall)
+ s := openStore(t, filepath.Join(t.TempDir(), "hosted.db"), clk)
+ var _ hostedwire.NonceStore = s
+
+ until := testWall.Add(hostedwire.NonceTTL)
+ check := func(id hostedwire.KeyID, nonce string, want bool) {
+ t.Helper()
+ got, err := s.Remember(ctx, id, nonce, until)
+ if err != nil || got != want {
+ t.Fatalf("Remember(%s, %s) = (%v, %v), want (%v, nil)", id, nonce, got, err, want)
+ }
+ }
+ check("inst-1", "n1", true)
+ check("inst-1", "n1", false) // a replay
+ check("inst-2", "n1", true) // nonces are per key
+ check("inst-1", "n2", true)
+
+ clk.SetWall(until.Add(time.Second))
+ until = until.Add(time.Hour)
+ check("inst-1", "n1", true) // expired, so remembered afresh
+ check("inst-1", "n1", false)
+
+ var left int
+ if err := s.Tx(ctx, func(tx *sql.Tx) error {
+ return tx.QueryRowContext(ctx, `SELECT count(*) FROM nonces`).Scan(&left)
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if left != 1 {
+ t.Fatalf("nonces held after expiry = %d, want 1: expired rows are pruned", left)
+ }
+
+ // Of concurrent calls with one pair, exactly one gets true.
+ var wg sync.WaitGroup
+ results := make(chan bool, 20)
+ for range 20 {
+ wg.Go(func() {
+ ok, err := s.Remember(ctx, "inst-3", "race", until)
+ if err != nil {
+ t.Errorf("concurrent Remember = %v", err)
+ }
+ results <- ok
+ })
+ }
+ wg.Wait()
+ close(results)
+ fresh := 0
+ for ok := range results {
+ if ok {
+ fresh++
+ }
+ }
+ if fresh != 1 {
+ t.Fatalf("20 concurrent Remember calls with one nonce: %d got true, want 1", fresh)
+ }
+
+ _ = s.Close()
+ if ok, err := s.Remember(ctx, "inst-1", "n3", until); err == nil || ok {
+ t.Fatalf("Remember on a closed store = (%v, %v), want (false, an error)", ok, err)
+ }
+}
+
+type recordingAlerter struct {
+ got []Alert
+ fail error
+}
+
+func (r *recordingAlerter) Alert(_ context.Context, a Alert) error {
+ if r.fail != nil {
+ return r.fail
+ }
+ r.got = append(r.got, a)
+ return nil
+}
+
+type nopRunner struct{ isolatedjob.Runner }
+type nopAuditor struct{ isolatedjob.NetworkAuditor }
+
+func TestNewRefusesNilDependency(t *testing.T) {
+ s := openStore(t, filepath.Join(t.TempDir(), "hosted.db"), isolatedjobtest.NewFakeClock(testWall))
+ full := Deps{Store: s, Runner: nopRunner{}, Auditor: nopAuditor{}, Alerter: &recordingAlerter{}}
+ if _, err := New(Config{}, full); err != nil {
+ t.Fatalf("New with every dependency = %v, want nil", err)
+ }
+ for name, d := range map[string]Deps{
+ "store": {Runner: full.Runner, Auditor: full.Auditor, Alerter: full.Alerter},
+ "runner": {Store: s, Auditor: full.Auditor, Alerter: full.Alerter},
+ "auditor": {Store: s, Runner: full.Runner, Alerter: full.Alerter},
+ "alerter": {Store: s, Runner: full.Runner, Auditor: full.Auditor},
+ } {
+ c, err := New(Config{}, d)
+ if err == nil || c != nil {
+ t.Errorf("New without the %s = (%v, %v), want (nil, an error)", name, c, err)
+ } else if !strings.Contains(err.Error(), name) {
+ t.Errorf("New without the %s = %v, want the error to name it", name, err)
+ }
+ }
+}