oficina / equipo Public

Rework hosted runners slice 1 plan after Astra round 1

Revision 2 answers all twelve findings: certification now binds a
trusted matrix with positive controls, report provenance and replayed
guard mutations, plus the section 17 checkpoint, forged-hello and
direct-bypass tests. Adds a VM-key resume exchange with controller
lapse stops, a server-authenticated bootstrap listener, operator stop
of certification launches, immutable per-launch policy snapshots
enforced by proxy and resolver, unknown provider states that are never
stop proof, monotonic controller time, a Darwin-safe poll helper, a
full image inventory, reordered skeleton-first tasks, hosted CI
wiring, and production work deferred. Open questions take Astra's
views; question 3 proposes bounded continuation on a stale feed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev bb8e73b639f6c8639c249309c8bed466b4497da4 parent f201a02
2 files changed, +1,229 −515
  • docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md +1,227 −499
  • scripts/runner-reference-allowlist.json +2 −16

CI passed — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/design-hosted-runners: 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.5s
ci-box: codex: fetched and verified in 3.5s
ci-box: codex-code-mode-host: fetched and verified in 1.4s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.4s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.7s
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 4.2s
ci-box: file times set from content: 2679 files, 174 directories
ci-box: ready in 17.4s
=== 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.240s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
  1.0s
+ go list -export -test -tags testbuild -f  ./...
  0.5s
+ go list -export -test -tags browser,testbuild -f  ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
  0.2s
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 1m19.846s 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.281s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m18.28s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 32.41, cpu waiting 20.40%, memory waiting 0.00%, io waiting 1.49%
--- 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 1m19.877s 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.288s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m18.29s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 32.41, cpu waiting 20.40%, memory waiting 0.00%, io waiting 1.49%
--- 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 1m20.95s 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.914s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m8.77s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.61s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.54s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 31.81, cpu waiting 20.03%, memory waiting 0.00%, io waiting 1.44%
--- 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 1m16.81s 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 1m15.228s amadan.net/oficina/equipo/internal/headless
receipt: slow test 35.98s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 19.83s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.06s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.36s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 32.41, cpu waiting 20.69%, memory waiting 0.00%, io waiting 1.54%
--- 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 1m33.571s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m31.927s amadan.net/oficina/equipo/internal/headless
receipt: slow test 57.79s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 10.63s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 9.53s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 8.33s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 5.65s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 29.56, cpu waiting 16.76%, memory waiting 0.00%, io waiting 1.18%
--- 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 3m4.557s 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 3m2.59s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m42.46s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 23.37s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 11.13s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 7.91s amadan.net/oficina/equipo/internal/headless TestHeadlessClaudeSignIn
receipt: slow test 7.26s amadan.net/oficina/equipo/internal/headless TestHeadlessBatchAfterRefusedReply
machine: 32 CPUs, load 8.36, cpu waiting 3.63%, memory waiting 0.00%, io waiting 0.25%
--- 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 224ms 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 1m58.418s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 7.73s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.74s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 3.88s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.47s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 3.36s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
machine: 32 CPUs, load 1.48, cpu waiting 0.00%, memory waiting 0.00%, io waiting 5.50%
--- 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 368ms 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 1m6.756s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 6.77s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 3.72s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.34s amadan.net/oficina/equipo/internal/thintest TestContractPreview
receipt: slow test 2.01s amadan.net/oficina/equipo/internal/thintest TestContractHostedBindingRules
receipt: slow test 1.77s amadan.net/oficina/equipo/internal/thintest TestContractTokenConnection
machine: 32 CPUs, load 7.28, cpu waiting 0.65%, memory waiting 0.00%, io waiting 5.49%
--- 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 4m14.117s, over the 45s its record on line 44 allows; reported only, timing fails on CI

receipt: test step 4m26.648s 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 4m14.117s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.74s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.69s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.62s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.36s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 6.61s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.57, cpu waiting 0.92%, memory waiting 0.00%, io waiting 0.05%
--- 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.136s 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.04s amadan.net/oficina/equipo/internal/runner
receipt: slow test 26.01s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.02s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 33.52, cpu waiting 19.66%, memory waiting 0.00%, io waiting 2.55%
--- shard 10 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-plans: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

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

receipt: test step 34.203s 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 33.342s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.11s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 3.07s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 1.92s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 28.52, cpu waiting 13.42%, memory waiting 0.00%, io waiting 3.22%
--- shard 12 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-a started 30s late; cpu waiting 27.0%, load 22.90
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed

receipt: test step 1m2.545s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m0.799s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 25.45s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 25.41s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 23.52s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 21.18s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 20.94s amadan.net/oficina/equipo/internal/equipotest TestAuthorityProjectOwnershipIsLocal
machine: 32 CPUs, load 29.56, cpu waiting 17.30%, memory waiting 0.00%, io waiting 1.22%
--- shard 13 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-e started 30s late; cpu waiting 27.0%, load 22.90
test lane equipotest-e: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[E-P]' ./internal/equipotest

receipt: test step 430ms 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.593s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 19.02s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 19.01s amadan.net/oficina/equipo/internal/equipotest TestProjectRejectsUnsafeBinding
receipt: slow test 18.98s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 18.96s amadan.net/oficina/equipo/internal/equipotest TestProjectBindingUniqueness
receipt: slow test 18.87s amadan.net/oficina/equipo/internal/equipotest TestProjectRequestActorAndUpdate
machine: 32 CPUs, load 22.90, cpu waiting 10.85%, memory waiting 0.00%, io waiting 3.44%
--- shard 14 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-r started 30s late; cpu waiting 27.0%, load 22.90
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
cache miss: amadan.net/oficina/equipo/internal/equipotest: its inputs changed

receipt: test step 1m12.316s 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 1m1.292s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 13.65s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 12.66s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 9.61s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 9.5s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 6.56s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 25.64, cpu waiting 14.67%, memory waiting 0.00%, io waiting 1.03%
--- shard 15 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-rest started 30s late; cpu waiting 27.0%, load 22.90
test lane equipotest-rest: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test[A-D]|^TestQ|^Test[E-P]|^TestR' ./internal/equipotest

receipt: test step 421ms against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 1 cached, 0 without tests, 0 failed
receipt: slow package 1m4.891s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 24.23s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 23.15s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 23.13s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 21.36s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedOnce
receipt: slow test 21.32s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
machine: 32 CPUs, load 28.52, cpu waiting 11.87%, memory waiting 0.00%, io waiting 3.33%
--- shard 16 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: plan3test started 30s late; cpu waiting 27.0%, load 22.90
test lane plan3test: ./internal/plan3test
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/plan3test

receipt: test step 514ms 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 50.134s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.53s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 3.48s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 1.54s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.44s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.23s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorMessageSourcesUpgrade
machine: 32 CPUs, load 22.90, cpu waiting 10.85%, memory waiting 0.00%, io waiting 3.44%
--- shard 17 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: rest started 30s late; cpu waiting 27.0%, load 22.90
test lane rest: ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/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/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/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/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/opencode: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/codex: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/containment: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/pi: its inputs changed
budget note: internal/equipo took 20.611s, 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 10.188s, 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/setup took 10.085s, 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 41.767s, 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 38.656s, over the 15s its record on line 40 allows; reported only, timing fails on CI

receipt: test step 2m13.945s against a 60s target (the gate's other steps are not in this figure)
receipt: 11 packages ran, 49 cached, 18 without tests, 0 failed
receipt: slow package 51.874s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 51.622s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 41.767s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 38.656s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 36.093s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow test 21.05s amadan.net/oficina/equipo/internal/runner/provider/opencode TestOpenCodeAcceptanceHostileRepository
receipt: slow test 15.14s amadan.net/oficina/equipo/cmd/equipo-runner TestReleaseRunnerHasNoFakeWorker
receipt: slow test 14.8s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringOfflineGo
receipt: slow test 12.05s amadan.net/oficina/equipo/internal/idtest TestIDCallbackGuardAndPendingNonce
receipt: slow test 9.28s amadan.net/oficina/equipo/internal/runner/containment TestEngineeringMissingModuleCache
machine: 32 CPUs, load 10.99, cpu waiting 5.25%, memory waiting 0.00%, io waiting 0.36%
--- 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 1m21.22s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m19.836s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.19s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.93s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.39s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.53s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 5.54s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 31.81, cpu waiting 20.03%, memory waiting 0.00%, io waiting 1.44%
--- 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 1m28.983s 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 1m27.441s amadan.net/oficina/equipo/internal/headless
receipt: slow test 24.87s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 21.7s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 13.78s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 9.83s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 7.8s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 30.31, cpu waiting 17.82%, memory waiting 0.00%, io waiting 1.26%
--- 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 1m38.294s 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.677s amadan.net/oficina/equipo/internal/headless
receipt: slow test 13.17s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 12.81s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 12.59s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 10.22s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
receipt: slow test 10.19s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
machine: 32 CPUs, load 27.35, cpu waiting 15.17%, memory waiting 0.00%, io waiting 1.07%
--- 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-19T14:09:16.510Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-19T14:09:16.510Z level=INFO msg="startup phase done" phase=state_lock took=79µs
time=2026-11-19T14:09:16.510Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-19T14:09:16.510Z level=INFO msg="startup phase done" phase=claim_roots took=135µs
time=2026-11-19T14:09:16.510Z level=INFO msg="startup phase" phase=sweep
time=2026-11-19T14:09:16.537Z level=INFO msg="startup phase done" phase=sweep took=27.092ms
time=2026-11-19T14:09:16.537Z level=INFO msg="startup phase" phase=credentials
time=2026-11-19T14:09:16.538Z level=INFO msg="startup phase done" phase=credentials took=115µs
time=2026-11-19T14:09:16.538Z level=INFO msg="startup phase" phase=open_state
time=2026-11-19T14:09:16.577Z level=INFO msg="startup phase done" phase=open_state took=39.925ms
time=2026-11-19T14:09:16.578Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-19T14:09:16.579Z level=INFO msg=connecting host=127.0.0.1:44983 protocol=26
time=2026-11-19T14:09:16.580Z level=INFO msg=connected host=127.0.0.1:44983 took=969µs
time=2026-11-19T14:09:16.580Z level=INFO msg="capabilities gathering"
time=2026-11-19T14:09:16.581Z level=INFO msg="capabilities gathered" took=602µs tags=linux,claude,go
time=2026-11-19T14:09:16.582Z level=INFO msg="hello sent" protocol=26
time=2026-11-19T14:09:16.586Z level=INFO msg=welcome protocol=26 role=primary generation=1
time=2026-11-19T14:09:17.568Z 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: <nil>)
--- FAIL: TestBrowserEmptyExplore (5.75s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m25.213s
FAIL	amadan.net/oficina/equipo/internal/headless	85.504s


receipt: test step 1m26.515s 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 1m25.213s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.03s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 10.67s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.31s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 10.16s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 7.82s 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 bb8e73b639f6c8639c249309c8bed466b4497da4 5.75s 30.31
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 27.35, cpu waiting 15.68%, memory waiting 0.00%, io waiting 1.10%
--- 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/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor)$' ./internal/idtest

receipt: test step 320ms 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.647s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 1.65s 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 269ms 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.95s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 1.95s 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|TestBrowserCoordinatorQueue|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|TestBrowserThinkingWords|TestBrowserTokenRowEmail|TestBrowserTrackStarCentre)$' ./internal/thintest

receipt: test step 273ms 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 3m2.437s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 17.69s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.35s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 10.83s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.13s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 8.6s amadan.net/oficina/equipo/internal/thintest TestBrowserInnerScreens
machine: 32 CPUs, load 7.28, cpu waiting 0.65%, memory waiting 0.00%, io waiting 5.49%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless   (52s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 5.19s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.28s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.21s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.60s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 24.67s
+ 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   (59s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 12.51s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 21.29s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 10.93s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 12.77s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless   (21s)
ok ./internal/headless TestMixedVersions 19.82s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks   (1s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.77s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin   (0s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 32.12, cpu waiting 20.97%, memory waiting 0.00%, io waiting 2.08%
--- 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.289s 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.191s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 173ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 86ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 2ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 0s amadan.net/oficina/equipo/internal/runner/provider/gotoolchain
receipt: slow test 5.14s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.67s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 300ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 170ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 80ms amadan.net/oficina/equipo/internal/runner/provider/codex TestDirectJournalAdapterBarrier
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run '^TestNamespace' -count=1 ./internal/runner/containment
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run '^TestNamespace' -count=1 ./internal/runner/containment

receipt: test step 2.918s 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.614s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 280ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 180ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 14.15, cpu waiting 4.16%, memory waiting 0.00%, io waiting 4.64%
--- shard 25 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: runner-dead-references started 30s late; cpu waiting 27.0%, load 22.90
shard 25: make runner-dead-references lanes-check build vet fmt-check budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2393 text files, 2748 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: 87 directories within budget
CGO_ENABLED=0 go test ./internal/equipo -run '^TestMigrationModels$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipo	2.437s
machine: 32 CPUs, load 33.13, cpu waiting 18.14%, memory waiting 0.00%, io waiting 2.82%
--- 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 27.0%, load 22.90
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 28.52, cpu waiting 11.87%, memory waiting 0.00%, io waiting 3.33%
--- shard 27 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: govulncheck started 30s late; cpu waiting 27.0%, load 22.90
shard 27: make govulncheck
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
=== Symbol Results ===

No vulnerabilities found.

Your code is affected by 0 vulnerabilities.
This scan also found 0 vulnerabilities in packages you import and 5
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
machine: 32 CPUs, load 28.52, cpu waiting 14.64%, memory waiting 0.00%, io waiting 3.11%
--- shard 28 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: gitleaks started 30s late; cpu waiting 27.0%, load 22.90
shard 28: make gitleaks
2:08PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
2:08PM INF 1005 commits scanned.
2:08PM INF scanned ~59678034 bytes (59.68 MB) in 12.4s
2:08PM INF no leaks found
machine: 32 CPUs, load 33.13, cpu waiting 18.14%, memory waiting 0.00%, io waiting 2.82%
=== 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.062ms, worst 1.105ms, budget 150ms
perf: GET /api/runner/protocol: median 76µs, worst 97µs, budget 150ms
perf: GET /api/v1/account-setups/{id}: median 580µs, worst 689µs, budget 150ms
perf: GET /api/v1/accounts: median 438µs, worst 506µs, budget 150ms
perf: GET /api/v1/auth/devices: median 437µs, worst 448µs, budget 150ms
perf: GET /api/v1/budgets: median 489µs, worst 560µs, budget 150ms
perf: GET /api/v1/capabilities: median 242µs, worst 285µs, budget 150ms
perf: GET /api/v1/cards/{id}: median 1.197ms, worst 1.271ms, budget 150ms
perf: GET /api/v1/connections: median 577µs, worst 646µs, budget 150ms
perf: GET /api/v1/connections/{id}: median 531µs, worst 583µs, budget 150ms
perf: GET /api/v1/conversation: median 912µs, worst 957µs, budget 150ms
perf: GET /api/v1/conversation/cards: median 1.432ms, worst 1.596ms, budget 150ms
perf: GET /api/v1/coordinator: median 1.756ms, worst 1.804ms, budget 150ms
perf: GET /api/v1/invites/{id}: median 448µs, worst 510µs, budget 150ms
perf: GET /api/v1/journey: median 7.606ms, worst 8.082ms, budget 150ms
perf: GET /api/v1/me: median 410µs, worst 458µs, budget 150ms
perf: GET /api/v1/me/settings: median 491µs, worst 528µs, budget 150ms
perf: GET /api/v1/needs-you: median 7.064ms, worst 7.239ms, budget 150ms
perf: GET /api/v1/notifications: median 1.568ms, worst 1.707ms, budget 150ms
perf: GET /api/v1/onboarding: median 394µs, worst 427µs, budget 150ms
perf: GET /api/v1/people: median 429µs, worst 479µs, budget 150ms
perf: GET /api/v1/playbooks: median 586µs, worst 618µs, budget 150ms
perf: GET /api/v1/playbooks/{id}: median 518µs, worst 568µs, budget 150ms
perf: GET /api/v1/playbooks/{id}/template-diff: median 818µs, worst 834µs, budget 150ms
perf: GET /api/v1/preferences: median 740µs, worst 764µs, budget 150ms
perf: GET /api/v1/projects/{id}: median 449µs, worst 483µs, budget 150ms
perf: GET /api/v1/projects/{id}/settings: median 574µs, worst 603µs, budget 150ms
perf: GET /api/v1/roster: median 452µs, worst 510µs, budget 150ms
perf: GET /api/v1/runners/{id}: median 424µs, worst 437µs, budget 150ms
perf: GET /api/v1/specialists: median 7.994ms, worst 8.061ms, budget 150ms
perf: GET /api/v1/specialists/{id}: median 7.834ms, worst 7.913ms, budget 150ms
perf: GET /api/v1/specialists/{id}/template-diff: median 801µs, worst 874µs, budget 150ms
perf: GET /api/v1/tasks/{id}/plan: median 1.131ms, worst 1.168ms, budget 150ms
perf: GET /api/v1/tasks/{id}/thread: median 709µs, worst 752µs, budget 150ms
perf: GET /api/v1/teams: median 424µs, worst 446µs, budget 150ms
perf: GET /api/v1/templates: median 589µs, worst 619µs, budget 150ms
perf: GET /api/v1/templates/{id}: median 428µs, worst 489µs, budget 150ms
perf: GET /auth/callback: median 75µs, worst 96µs, budget 150ms
perf: GET /auth/devices/{id}: median 3.098ms, worst 3.178ms, budget 150ms
perf: GET /auth/verify: median 79µs, worst 113µs, budget 150ms
perf: GET /connections: median 3.385ms, worst 3.436ms, budget 150ms
perf: GET /conversation: median 7.183ms, worst 10.171ms, budget 150ms
perf: GET /conversation/connections: median 264µs, worst 281µs, budget 150ms
perf: GET /conversation/notebook: median 239µs, worst 262µs, budget 150ms
perf: GET /conversation/settings: median 3.872ms, worst 4.033ms, budget 150ms
perf: GET /conversation/settings/connections: median 5.798ms, worst 6.044ms, budget 150ms
perf: GET /conversation/settings/connections/add: median 5.921ms, worst 6.297ms, budget 150ms
perf: GET /conversation/settings/copy: median 3.309ms, worst 3.407ms, budget 150ms
perf: GET /conversation/settings/housekeeping: median 3.755ms, worst 3.821ms, budget 150ms
perf: GET /conversation/settings/machines: median 4.102ms, worst 4.312ms, budget 150ms
perf: GET /conversation/settings/machines/add: median 4.115ms, worst 4.275ms, budget 150ms
perf: GET /conversation/settings/notebook: median 3.14ms, worst 3.269ms, budget 150ms
perf: GET /conversation/settings/thinking: median 3.911ms, worst 5.549ms, budget 150ms
perf: GET /housekeeping: median 3.588ms, worst 3.67ms, budget 150ms
perf: GET /invites/new: median 586µs, worst 636µs, budget 150ms
perf: GET /invites/{id}: median 615µs, worst 720µs, budget 150ms
perf: GET /jobs: median 3.071ms, worst 3.137ms, budget 150ms
perf: GET /jobs/{id}: median 4.231ms, worst 4.298ms, budget 150ms
perf: GET /journey: median 9.835ms, worst 9.974ms, budget 150ms
perf: GET /nav/rail: median 2.69ms, worst 2.836ms, budget 150ms
perf: GET /needs-you: median 9.497ms, worst 9.69ms, budget 150ms
perf: GET /onboarding: median 3.919ms, worst 5.504ms, budget 150ms
perf: GET /people: median 3.189ms, worst 3.235ms, budget 150ms
perf: GET /playbook-suggestions/{suggestion}: median 4.194ms, worst 4.289ms, budget 150ms
perf: GET /playbooks: median 3.794ms, worst 3.89ms, budget 150ms
perf: GET /playbooks/new: median 3.896ms, worst 3.999ms, budget 150ms
perf: GET /playbooks/{id}: median 4.305ms, worst 4.391ms, budget 150ms
perf: GET /playbooks/{id}/edit: median 4.361ms, worst 4.455ms, budget 150ms
perf: GET /playbooks/{id}/template-diff: median 3.469ms, worst 3.538ms, budget 150ms
perf: GET /preferences: median 3.889ms, worst 4.021ms, budget 150ms
perf: GET /preferences/sources/{source}: median 3.705ms, worst 3.767ms, budget 150ms
perf: GET /projects: median 4.75ms, worst 4.946ms, budget 150ms
perf: GET /projects/accounts: median 3.366ms, worst 5.564ms, budget 150ms
perf: GET /projects/new: median 3.505ms, worst 3.579ms, budget 150ms
perf: GET /projects/{id}: median 10.062ms, worst 10.405ms, budget 150ms
perf: GET /projects/{id}/edit: median 3.438ms, worst 3.585ms, budget 150ms
perf: GET /runners/enrol: median 4.208ms, worst 4.316ms, budget 150ms
perf: GET /settings: median 3.205ms, worst 3.316ms, budget 150ms
perf: GET /settings/coordinator: median 5.114ms, worst 5.288ms, budget 150ms
perf: GET /settings/devices: median 2.966ms, worst 3.073ms, budget 150ms
perf: GET /settings/recovery: median 3.165ms, worst 3.199ms, budget 150ms
perf: GET /settings/recovery/release: median 3.19ms, worst 3.295ms, budget 150ms
perf: GET /settings/thinking: median 243µs, worst 260µs, budget 150ms
perf: GET /signin: median 303µs, worst 320µs, budget 150ms
perf: GET /specialists/new: median 3.12ms, worst 5.408ms, budget 150ms
perf: GET /specialists/{key}: median 10.231ms, worst 11.249ms, budget 150ms
perf: GET /specialists/{key}/edit: median 3.31ms, worst 3.348ms, budget 150ms
perf: GET /specialists/{key}/template-diff: median 3.449ms, worst 3.504ms, budget 150ms
perf: GET /tasks: median 4.733ms, worst 4.894ms, budget 150ms
perf: GET /tasks/new: median 2.958ms, worst 2.992ms, budget 150ms
perf: GET /tasks/{id}: median 5.078ms, worst 5.121ms, budget 150ms
perf: GET /tasks/{id}/merge: median 4.412ms, worst 4.514ms, budget 150ms
perf: GET /tasks/{id}/move: median 4.117ms, worst 4.188ms, budget 150ms
perf: GET /tasks/{id}/plan: median 5.511ms, worst 7.433ms, budget 150ms
perf: GET /tasks/{id}/questions/{question}: median 5.055ms, worst 5.139ms, budget 150ms
perf: GET /tasks/{id}/rendered-change: median 4.461ms, worst 4.504ms, budget 150ms
perf: GET /tasks/{id}/rendered-change/{hash}.png: median 4ms, worst 4.226ms, budget 150ms
perf: GET /tasks/{id}/thread: median 7.613ms, worst 7.716ms, budget 150ms
perf: GET /team/{specialist}: median 3.92ms, worst 4.011ms, budget 150ms
perf: GET /teams: median 9.495ms, worst 9.703ms, budget 150ms
perf: GET /templates: median 3.186ms, worst 3.201ms, budget 150ms
perf: GET /usage: median 3.911ms, worst 4.577ms, budget 150ms
perf: GET /work: median 2.874ms, worst 2.998ms, budget 150ms
perf: cold boot: median 252ms of [251.545493ms 252.211691ms 253.700061ms], budget 500ms

receipt: test step 28.229s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 83 without tests, 0 failed
receipt: slow package 8.524s 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 7.72s amadan.net/oficina/equipo/internal/equipotest TestPerfScreens
receipt: slow test 810ms amadan.net/oficina/equipo/internal/equipotest TestPerfBoot
=== cache ===
ci-box: build cache /home/ci/work/repos/oficina__equipo/cache/go-build: 2.95 GiB in 18821 files
ci-box: module cache /home/ci/work/repos/oficina__equipo/cache/go-mod: 0.84 GiB in 27329 files
diff --git a/docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md b/docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md
index 1d9a7675..be1901f1 100644
--- a/docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md
+++ b/docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md
@@ -1,210 +1,299 @@
-# Hosted runners, slice 1: foundation (plan, 2026-11-19)
+# Hosted runners, slice 1: foundation (plan, 2026-11-19, revision 2)
-> **For agentic workers:** REQUIRED SUB-SKILL: use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task by task. Steps use checkbox (`- [ ]`) syntax for tracking. Tasks marked **HUMAN** are not agent work: stop and ask Paul.
+> **For agentic workers:** REQUIRED SUB-SKILL: use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task by task. Steps use checkbox (`- [ ]`) syntax for tracking. Tasks and steps marked **HUMAN** are not agent work: stop and ask Paul.
-**Goal:** Build the hosted runner foundation in the dev AWS account, behind a flag and with nothing user-facing: the isolated job runner adapter, the controller, the egress stack, the image pipeline, the certification gate and the leaked-VM reaper, ending with a certified image that slice 2 (hosted checks) can launch.
+**Goal:** Build the hosted runner foundation in the dev AWS account, behind a flag and with nothing user-facing. That means the isolated job runner adapter, the controller, the egress stack, the image pipeline, the certification gate and the leaked-VM reaper. Slice 1 ends with a certified image that slice 2 (hosted checks) can launch.
-**Architecture:** A provider-neutral `isolatedjob.Runner` (interface, in-memory fake, AWS adapter) sits under `equipo-hosted-controller`, which owns the job table, launch intents, deadlines, pause generations, epochs, proxy credentials and the reaper, and answers a signed HTTPS API. An authenticated egress proxy and an exact-name resolver are the VM's only network. A root init inside the image fixes the managed mounts and runs the runner unprivileged. Certification runs the containment suite and the egress matrix inside a real VM and produces a signed certificate the controller requires before any ordinary launch.
+**Architecture:** A provider-neutral `isolatedjob.Runner` (interface, in-memory fake, AWS adapter) sits under `equipo-hosted-controller`. The controller owns the job table, launch intents with immutable per-launch policy snapshots, controller time, deadlines, pause generations, epochs, VM keys and proxy credentials, and the reaper, and answers a signed HTTPS API. An authenticated egress proxy and a per-launch resolver are the VM's only network. Inside the image, a root init fixes the managed mounts and starts an unprivileged foundation probe, which stands in for the runner until slice 2. Certification runs the containment suite and a trusted egress matrix inside a real VM. An operator then signs a certificate binding the image, policies, report provenance and guard mutation evidence, and the controller requires it before any ordinary launch.
-**Tech stack:** Go (module floor 1.26.0, gate `GOTOOLCHAIN=go1.26.11`, `CGO_ENABLED=0`), modernc SQLite through `database/sql` for the controller, `crypto/ed25519` and `crypto/x509` for signatures and proxy certificates, `golang.org/x/net/dns/dnsmessage` for the resolver, aws-sdk-go-v2 inside the AWS adapter only, OpenTofu for infrastructure (new to this repository, see Task 29 and open question 2).
+**Tech stack:** Go (module floor 1.26.0, gate `GOTOOLCHAIN=go1.26.11`, `CGO_ENABLED=0`), modernc SQLite through `database/sql` for the controller, `crypto/ed25519` and `crypto/x509`, `golang.org/x/net/dns/dnsmessage`, aws-sdk-go-v2 inside the AWS adapter only, and OpenTofu, which is new to this repository (Task 36, open question 2).
**Spec:** `docs/superpowers/specs/2026-11-18-hosted-runners-microvms.md` (approved 2026-11-19, rulings in §16, authority rules in §17). Executors read the spec and this plan together.
-**Baseline:** `design-hosted-runners` at `5ab8c160`. Implement Tasks 1 to 31 in order unless a task says it can run in parallel. H1 and H2 are Paul's and can start now.
+**Baseline:** `design-hosted-runners` at `f201a020`. Implement Tasks 1 to 38 in order. Each task builds and tests only with what earlier tasks created. H2 can start now. The production items wait until before slice 2 production.
+
+**Revision 2** answers Astra's round 1 review (`review1.md` in the planning workspace, verdict rework). Where each finding lands:
+
+| Finding | Where |
+| --- | --- |
+| 1 Certification evidence | Tasks 5, 11, 30, 31, 33 to 35 |
+| 2 Resume and renewal | Tasks 15 to 17, 26 to 29 |
+| 3 Bootstrap TLS and operator stop | Tasks 14, 19, 22, 24, 29 |
+| 4 Launch-bound policy | Tasks 10, 12, 13, 22, 25, 29 |
+| 5 Unknown provider state | Tasks 6 to 8, 14, 17, 18 |
+| 6 Clock | Tasks 6, 12, 17, 18 |
+| 7 Darwin | Task 1 |
+| 8 Image inputs and probe privileges | Tasks 27, 32, 34, 37 |
+| 9 Mutation strength | Tasks 16, 18, 32, 34 |
+| 10 Ordering | Phase order, Tasks 5, 9 to 12, 22, 27 to 29 |
+| 11 Hosted CI | Tasks 5, 37 |
+| 12 Production scope | "Before slice 2 production", Task 38 |
## Global constraints
-- Provider-neutral core: AWS SDK types and AWS names appear only under `internal/isolatedjob/awsjob/` and `cmd/equipo-hosted-controller/`. Task 6's guard test enforces this.
-- Every launch: `NO_INGRESS`, the VPC connector as only egress, no execution role, no idle policy, maximum duration at most 28,800 s, x86_64, and `additionalOsCapabilities: ["ALL"]` (without it bubblewrap cannot mount `/proc`). Sizes: Small 2 GB / 1 vCPU, Large 4 GB / 2 vCPU. Region `eu-west-1`.
-- The deadline is launch time plus the launch's MaxLifetime (8 h by default) and never moves. Suspended time counts.
-- Leaked VMs: reaper every 60 s; an incomplete `List` skips the pass; a live launch intent is replayed first; an unmatched VM is stopped after 10 minutes, once ownership is rechecked; a VM past its stop time is stopped.
-- Pause barrier: suspend only on a `quiescent` acknowledgement for the current generation; no acknowledgement within 2 minutes cancels that generation and late acknowledgements are ignored; resume carries an operation ID and raises the epoch once.
-- Bootstrap code: 2 minutes, single use, one attempt and VM. The run payload carries codes only, never tokens or keys.
-- Egress: exact fully qualified hostnames, port 443, no suffix match or wildcard. `proxy.golang.org`, `sum.golang.org`, `registry.npmjs.org`, `pypi.org`, `files.pythonhosted.org` and `amadan.net` are refused as service names. An unset service name blocks launch. Logs carry no credentials, request bodies or model text.
-- Slice 1 issues no forge token and no gateway token, runs no model work, and holds no provider key anywhere. The policy version built here refuses a gateway hostname (Task 9).
-- Flags: the controller refuses every launch unless `EQUIPO_HOSTED_ENABLED=1`. The instance-side client (Task 19) refuses construction unless `EQUIPO_HOSTED_RUNNERS=1`, and nothing in the instance calls it in this slice. No UI, no copy strings.
-- AWS: slice 1 runs in the dev account `640012953448` with profile `kass`, tag `purpose=equipo-hosted-dev`. The production account is organisation member `149757027610` (`equipo-hosted`); nothing is applied there in this slice and no agent sets up access to it.
-- Tests first. Each guard gets a mutation check: break the guard, watch the named test fail, restore it (spec §17, last paragraph). Record each command and result in `docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md`.
-- Local verification is targeted: `go test ./internal/<pkg> -run 'TestX' -count=1`. CI runs the full suite. No sudo. Scratch under `$TMPDIR`. Servers in tests bind `127.0.0.1`. Default Go caches. Each new package stays inside its 10 s test budget and 5,000 source lines.
-- Live AWS tests use the build tag `hostedlive` (the `e2elive` precedent) and never run in CI.
-- Commit subjects under 80 characters; never merge, never push the default branch, never deploy without Paul's GO.
+- **Provider-neutral core.** AWS SDK types and AWS names appear only under `internal/isolatedjob/awsjob/` and `cmd/equipo-hosted-controller/`. The guard in Task 8 enforces this.
+- **Every launch:** `NO_INGRESS`; the VPC connector as the only egress; no execution role; no idle policy; maximum duration at most 28,800 s; x86_64; `additionalOsCapabilities: ["ALL"]`. Sizes: Small 2 GB / 1 vCPU, Large 4 GB / 2 vCPU. Region `eu-west-1`.
+- **Time.** All controller deadlines, grace periods and expiries are measured in controller time (Task 12), which advances with the monotonic clock and never moves back. The deadline is launch plus MaxLifetime (8 h by default) and never moves. Suspended time counts.
+- **Provider state.** A state the adapter does not recognise is `unknown`. It is neither live nor terminal, and it is never stop proof.
+- **Leaked VMs.** The reaper runs every 60 s. An incomplete `List` skips the pass. A live launch intent is replayed first. An unmatched VM is stopped after 10 minutes of controller time, once ownership is rechecked. A VM past its stop time is stopped.
+- **Pause barrier.** Suspend only on a `quiescent` acknowledgement for the current generation. No acknowledgement within 2 minutes cancels that generation, and late or future acknowledgements are refused. Resume carries an operation ID and raises the epoch once.
+- **Authority in the VM.** The run payload carries a single-use, 2-minute bootstrap proxy code, never a token or key. A per-VM key generated at `/run` is the only authority for every later credential (renewal and post-resume exchange). A failed renewal stops the VM (spec §10), and the controller enforces this.
+- **Egress.** Each launch record holds an immutable snapshot of exact service names and the policy version. The proxy and resolver enforce the authenticated launch's own snapshot on every request. Names are exact fully qualified hostnames on port 443, with no suffix or wildcard. The six denied names (`proxy.golang.org`, `sum.golang.org`, `registry.npmjs.org`, `pypi.org`, `files.pythonhosted.org`, `amadan.net`) are refused. An unset name blocks launch. Logs carry no credentials, request bodies or model text.
+- **Scope.** Slice 1 issues no forge token and no gateway token, runs no model work and holds no provider key. The policy version built here refuses a gateway hostname.
+- **Flags.** The controller refuses every launch unless `EQUIPO_HOSTED_ENABLED=1`. Stop, get and reaping keep working with the flag off. The instance-side client (Task 21) refuses construction unless `EQUIPO_HOSTED_RUNNERS=1`, and nothing in the instance calls it in this slice. No UI, no copy strings.
+- **AWS.** Slice 1 runs in the dev account `640012953448` with profile `kass`, tag `purpose=equipo-hosted-dev`. Nothing is applied to the production account `149757027610` (`equipo-hosted`) in this slice, and no agent sets up access to it. Every AWS change, deployment, image registration, certificate signing and destructive drill needs Paul's GO.
+- **Tests and mutations.** Tests come first. Each guard gets a mutation check: break the guard, watch the named test fail, restore it (spec §17). Guards in tasks marked **(certified guards)** go further. Their mutations are committed as patches under `internal/hostedcert/mutations/` and registered in `internal/hostedcert/guards.json` (Task 5). Task 33 replays them for the certificate. Record every command and result in `docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md`.
+- **Verification.** Run targeted tests locally: `go test ./internal/<pkg> -run 'TestX' -count=1`. CI runs the full suite. No sudo. Scratch goes under `$TMPDIR`. Test servers bind `127.0.0.1`. Go caches stay at their defaults. Each new package stays inside its 10 s test budget and 5,000 source lines. Live AWS tests use build tag `hostedlive` and never run in CI.
+- **Git.** Commit subjects under 80 characters. Never merge, never push the default branch, never deploy without Paul's GO.
## Review focus
-1. **The VM is gone while the controller was down** (AWS maximum duration, a crash). On restart the job table still says running; the controller must find it gone, record stop proof and revoke its proxy access. Test: `TestRestartFindsVMGone` (Task 13).
-2. **The controller host's clock steps backwards.** Deadlines must not stretch and the 10-minute orphan wait must not restart. Test: `TestDeadlinesIgnoreClockRollback` (Task 15).
-3. **A long-lived tunnel survives revocation.** A runner stream opened before stop or an epoch change must be cut, not only new requests refused. Test: `TestRevocationClosesOpenTunnels` (Task 21).
-4. **Hostname spelling variants** (`Instance.Example.`, trailing dot, upper case, punycode, `host:443` versus `host`) must match the manifest name exactly once normalised, and nothing else. Tests: `TestServiceNameNormalisation` (Task 9), `TestProxyAuthorityNormalisation` (Task 22), `TestResolverNameNormalisation` (Task 23).
-5. **Two retries of one launch race each other.** Exactly one intent and one VM. Test: `TestConcurrentLaunchSameAttempt` (Task 12).
+1. **The VM is gone while the controller is down.** On restart the job table still says running. The controller must find the VM terminal, record stop proof and revoke its access, or find it in an unknown state and refuse proof. Tests: `TestRestartFindsVMGone`, `TestUnknownStateIsNeverProof` (Task 14).
+2. **The controller host's wall clock steps backwards, while running or across a restart.** Deadlines and the orphan wait must keep counting real elapsed time. Test: `TestRollbackThenElapsedTime` (Task 12), and the reaper's `TestReaperUnderRollback` (Task 17).
+3. **A long-lived tunnel survives revocation.** A stream opened before stop or an epoch change must be cut. Test: `TestRevocationClosesOpenTunnels` (Task 23).
+4. **Hostname spelling variants** (`Instance.Example.`, upper case, punycode, `host:443`) must match the launch's snapshot exactly once normalised, and nothing else. Tests: `TestSnapshotNameNormalisation` (Task 10), `TestProxyAuthorityNormalisation` (Task 24), `TestResolverNameNormalisation` (Task 25).
+5. **Two retries of one launch race each other.** The result must be exactly one intent and one VM. Test: `TestConcurrentLaunchSameAttempt` (Task 13).
---
-## Human tasks (run in parallel with Phase A)
-
-### H1: Set up access to the `equipo-hosted` account (HUMAN: Paul or operator)
+## HUMAN task now
-Not needed for any agent task in this slice; needed before slice 2 can run in production.
+### H2: Rulings and names before dev bring-up (Paul)
-- [ ] Create a CLI profile `equipo-hosted` for account `149757027610` (through the `titogo` organisation management account), with MFA, and confirm `aws sts get-caller-identity --profile equipo-hosted`.
-- [ ] Create the OpenTofu state bucket and lock table in that account (names recorded in `infra/hosted/envs/prod/backend.tf` by Task 29).
-- [ ] Read the applied MicroVM memory quota for `eu-west-1` in that account and record it in the progress file (spec §10: the dev account's is 2,048 GB).
-- [ ] Enable CloudTrail data events for the MicroVM APIs there (spec §11).
+- [ ] Answer the open questions at the end of this plan or accept the recommendations. Questions 3 and 6 qualify spec text and need an explicit yes.
+- [ ] Choose the exact hostnames: the dev staging instance, registered against its instance key (Task 20), and the controller endpoint. Gateway and mirror are `none` for slice 1.
+- [ ] Choose who holds the certification signing key (open question 4).
+- [ ] Say whether agents may run `tofu apply`, image registration and the destructive drills in `kass`, or whether Paul runs them. Task 38 assumes Paul does.
-### H2: Rulings and names before dev bring-up (HUMAN: Paul)
+## Before slice 2 production (HUMAN, deferred, not slice 1 work)
-- [ ] Answer the open questions at the end of this plan, or accept the recommendations.
-- [ ] Choose the exact hostnames: dev staging instance, controller endpoint. Gateway and mirror are `none` for slice 1 (open question 6).
-- [ ] Say whether agents may run `tofu apply` in `kass` for `purpose=equipo-hosted-dev` resources, or whether Paul applies (Task 31 assumes Paul applies).
+- [ ] Set up access to `equipo-hosted` (`149757027610`) through the `titogo` management account: a CLI profile `equipo-hosted` with MFA, confirmed with `aws sts get-caller-identity --profile equipo-hosted`.
+- [ ] Create the OpenTofu state bucket and lock table there. Write and apply `infra/hosted/envs/prod`.
+- [ ] Record the applied MicroVM memory quota for `eu-west-1` in that account (spec §10).
+- [ ] Enable CloudTrail data events for the MicroVM APIs (spec §11).
+- [ ] Deploy the controller and proxies there, register the image, and certify it in that account.
---
-## Phase A: containment suite fixes (spec §7, "test-suite fixes first")
+## Phase A: containment suite fixes (spec §7)
-### Task 1: Retry `poll` on `EINTR`
+### Task 1: Retry `poll` on `EINTR`, on Linux and Darwin
-**Files:** Create `internal/runner/containment/poll_linux.go`, `internal/runner/containment/poll_linux_test.go`. Modify `internal/runner/containment/linux_test.go` (`exited`, `alive`, the stop-before-exit check near line 489), `internal/runner/containment/recovery.go:78-79`.
+`recovery.go` has no build constraint and builds for the Mac runner, so the helper must too.
-**Interfaces:** Produces `pollRetry(fds []unix.PollFd, timeout time.Duration, poll func([]unix.PollFd, int) (int, error)) (int, error)`: retries on `unix.EINTR` with the remaining time, never extending the overall timeout; `pollFD(fds, timeout)` calls it with `unix.Poll`.
-
-- [ ] **Red:** `TestPollRetriesEINTR`: a poll stub returns `EINTR` twice, then `(1, nil)`; expect `(1, nil)` and three calls. `TestPollRetryKeepsDeadline`: a stub that sleeps 30 ms and returns `EINTR` forever, timeout 100 ms; expect a return within 200 ms with `n == 0`. Run `go test ./internal/runner/containment -run 'TestPollRetr' -count=1`; fails on the missing symbol.
-- [ ] **Implement** `pollRetry`; use it in `exited`, `alive`, the stop check, and in `recovery.go`'s zero-timeout exit check (today an `EINTR` there reports `errIdentity`, a spurious refusal).
-- [ ] **Green:** the same command, plus `go test ./internal/runner/containment -run 'TestNamespaceParentDeath|TestRecover' -count=1` on a runner host.
-- [ ] **Mutation:** return on the first `EINTR` in `pollRetry`; `TestPollRetriesEINTR` fails. Restore.
-- [ ] **Commit:** `containment: retry poll on EINTR in exit checks`.
-
-### Task 2: Source-reading tests run from the source tree only
+**Files:**
+- Create `internal/runner/containment/poll_unix.go` (`//go:build linux || darwin`) and `poll_unix_test.go`.
+- Modify `internal/runner/containment/linux_test.go` (`exited`, `alive`, and the stop check near line 489) and `recovery.go:78-79`.
-The two tests read files a compiled test binary does not carry (`TestNamespaceVersionTracksImplementation` reads `linux.go`; `TestBubblewrapPins` reads `../../../scripts/ci-box.json`), so they fail in a VM.
+**Interfaces:** Produces `pollRetry(fds []unix.PollFd, timeout time.Duration, poll func([]unix.PollFd, int) (int, error)) (int, error)` and `pollFD(fds []unix.PollFd, timeout time.Duration) (int, error)`. `pollRetry` retries on `unix.EINTR` with the remaining time and never extends the overall timeout.
-**Files:** Modify `internal/runner/containment/helper_version_test.go`, `bubblewrap_pin_test.go`, `scripts/ci-test.py` (lane names if either test is named there), `Makefile` (`runner-namespace-test` pattern only if needed).
+- [ ] **Red:** `TestPollRetriesEINTR`: a stub returns `EINTR` twice, then `(1, nil)`. Expect `(1, nil)` after three calls. `TestPollRetryKeepsDeadline`: a stub sleeps 30 ms and returns `EINTR` forever, with a 100 ms timeout. Expect `n == 0` within 200 ms. Run `go test ./internal/runner/containment -run 'TestPollRetr' -count=1`.
+- [ ] **Implement:** use `pollFD` in the three test helpers and in `recovery.go`'s zero-timeout exit check. Today an `EINTR` there reports `errIdentity`.
+- [ ] **Green:** run the same command, then `make build vet` (vet covers `GOOS=darwin GOARCH=arm64 ./internal/runner/...`). On a runner host, also run `go test ./internal/runner/containment -run 'TestNamespaceParentDeath|TestRecover' -count=1`.
+- [ ] **Mutation:** return on the first `EINTR`. `TestPollRetriesEINTR` fails. Restore.
+- [ ] **Commit:** `containment: retry poll on EINTR on Linux and Darwin`.
-**Interfaces:** Produces the test-name prefix `TestSource`, and the certification skip pattern `^TestSource` used by Task 27.
+### Task 2: Source-reading tests run from the source tree only
-- [ ] **Red:** rename to `TestSourceNamespaceVersionTracksImplementation`, and split the `ci-box.json` comparison out of `TestBubblewrapPins` into `TestSourceBubblewrapPinsMatchCIBox` (the manifest comparison stays in `TestBubblewrapPins`, which reads no file). Add `TestSourceTestsAreNamed` in the same package: it parses the package's `_test.go` files with `go/parser` and fails if a test function outside the `TestSource` prefix calls `os.ReadFile` or `os.Open` with a relative path literal. Run `go test ./internal/runner/containment -run 'TestSource' -count=1`.
-- [ ] **Implement** the rename and split; update lanes so `python3 scripts/ci-test.py check` passes.
-- [ ] **Green:** `go test ./internal/runner/containment -run 'TestSource|TestBubblewrapPins' -count=1` and `python3 scripts/ci-test.py check`. Then `go test -c -o $TMPDIR/containment.test ./internal/runner/containment && (cd $TMPDIR && ./containment.test -test.run 'TestBubblewrapPins' -test.skip '^TestSource')` passes outside the tree.
-- [ ] **Mutation:** move the `ci-box.json` read back into `TestBubblewrapPins`; `TestSourceTestsAreNamed` fails. Restore.
+**Files:**
+- Modify `internal/runner/containment/helper_version_test.go` and `bubblewrap_pin_test.go`.
+- Modify `scripts/ci-test.py`, only where a lane names either test.
+
+**Interfaces:** Produces the `TestSource` prefix and the certification skip pattern `^TestSource` (Task 34).
+
+- [ ] **Red:**
+ - Rename `TestNamespaceVersionTracksImplementation` to `TestSourceNamespaceVersionTracksImplementation`.
+ - Split the `ci-box.json` comparison out of `TestBubblewrapPins` into `TestSourceBubblewrapPinsMatchCIBox`.
+ - Add `TestSourceTestsAreNamed`. It parses the package's `_test.go` files with `go/parser` and fails when a test outside the prefix calls `os.ReadFile` or `os.Open` with a relative path literal.
+- [ ] **Green:**
+ - `go test ./internal/runner/containment -run 'TestSource|TestBubblewrapPins' -count=1`
+ - `python3 scripts/ci-test.py check`
+ - `go test -c -o $TMPDIR/containment.test ./internal/runner/containment && (cd $TMPDIR && ./containment.test -test.run TestBubblewrapPins -test.skip '^TestSource')`. This passes outside the tree. Remove the binary afterwards.
+- [ ] **Mutation:** move the `ci-box.json` read back into `TestBubblewrapPins`. `TestSourceTestsAreNamed` fails. Restore.
- [ ] **Commit:** `containment: name the source-reading tests TestSource`.
### Task 3: Skip the delegated-cgroup test where no user session exists
-**Files:** Modify `internal/runner/containment/linux_test.go` (`TestNamespaceCgroupMoveKeepsMembership`), `Makefile` (`runner-namespace-test`), `scripts/ci-test.py` only if the env must pass through.
+**Files:** Modify `internal/runner/containment/linux_test.go` and `Makefile` (`runner-namespace-test`).
-**Interfaces:** Produces env `EQUIPO_REQUIRE_USER_SESSION=1`: when set, the test fails instead of skipping. `runner-namespace-test` sets it, so the CI runner host still proves the cgroup move.
+**Interfaces:** Produces `cgroupSkip(base string, stat func(string) error, require bool) (skip bool, reason string, fail bool)` and env `EQUIPO_REQUIRE_USER_SESSION=1`. `runner-namespace-test` sets the env, so the CI runner host still has to prove the cgroup move.
-- [ ] **Red:** `TestCgroupSessionRule` (pure function `cgroupSkip(base string, stat func(string) error, require bool) (skip bool, reason string, fail bool)`): missing `user@UID.service` directory and `require=false` gives skip with reason `no systemd user session; production containment does not use cgroups`; `require=true` gives fail; present directory gives neither.
-- [ ] **Implement** `cgroupSkip` and call it first in the cgroup test; add `EQUIPO_REQUIRE_USER_SESSION=1` to the `runner-namespace-test` recipe.
-- [ ] **Green:** `go test ./internal/runner/containment -run 'TestCgroupSessionRule' -count=1`; on docs-t1 also `-run TestNamespaceCgroupMoveKeepsMembership` still passes.
-- [ ] **Mutation:** ignore `require`; `TestCgroupSessionRule` fails. Restore.
+- [ ] **Red:** `TestCgroupSessionRule`:
+ - With no `user@UID.service` directory and `require=false`, it skips with the reason `no systemd user session; production containment does not use cgroups`.
+ - With `require=true`, it fails.
+ - With the directory present, it neither skips nor fails.
+- [ ] **Implement and green:** `go test ./internal/runner/containment -run 'TestCgroupSessionRule' -count=1`. On docs-t1, `TestNamespaceCgroupMoveKeepsMembership` still passes.
+- [ ] **Mutation:** ignore `require`. The test fails. Restore.
- [ ] **Commit:** `containment: skip the cgroup test without a user session`.
---
-## Phase B: the isolated job runner adapter (spec §2)
+## Phase B: facts, contracts and skeletons
+
+### Task 4: Record the MicroVM API facts before any dependent code
+
+Astra's view on open question 1: settle the API, hooks and idempotency before building on them.
+
+**Files:** Create `internal/isolatedjob/awsjob/doc.go`, a package comment only.
+
+- [ ] Read AWS's MicroVM documentation and the SDK module list. Record these facts:
+ - whether aws-sdk-go-v2 publishes a MicroVM service package;
+ - the operation names;
+ - where `additionalOsCapabilities`, the connector and maximum duration are set;
+ - the client-token idempotency window, and the error for a reused token with changed parameters;
+ - the complete state vocabulary;
+ - the hook transport, and whether `/run` and `/resume` carry a payload;
+ - how a process inside the VM learns its VM ID;
+ - the maximum run-payload size;
+ - whether the AWS OpenTofu provider has resources for connectors and images.
+- [ ] Any fact that contradicts this plan stops the work, and the controller asks Paul. Examples: no client token, no `/resume` hook, no way to learn the VM ID.
+- [ ] **Commit:** `awsjob: record the MicroVM API facts the adapter relies on`.
+
+### Task 5: Guard registry (certified guard skeleton)
+
+**Files:**
+- Create `internal/hostedcert/guards.json` (empty list), `internal/hostedcert/mutations/` and `internal/hostedcert/guards_test.go`.
+- Modify `Makefile` (`hosted-guards-check`, added to `ci`) and `scripts/ci-test.py`. Add the target to the existing static-checks entry of `EXTRA_SHARDS`, so the `20-check@N` count is unchanged.
-### Task 4: `isolatedjob` types and validation
+**Interfaces:** Produces the registry format: `[{"id", "package", "test", "patch", "spec"}]`. `patch` is a path under `mutations/`. `spec` cites the spec section the guard protects.
-**Files:** Create `internal/isolatedjob/isolatedjob.go`, `validate.go`, `isolatedjob_test.go`.
+- [ ] **Red:** `TestGuardRegistry` checks:
+ - IDs are unique;
+ - every `test` exists by that name in `package` (via `go/parser`);
+ - every patch passes `git apply --check` at HEAD;
+ - no patch touches a `_test.go` file.
-**Interfaces (produces):** the spec §2 `Runner`, `LaunchSpec`, `Job`, `Limits` exactly, plus:
+ Use one throwaway sample entry to watch it fail, then remove it.
+- [ ] **Green:** `go test ./internal/hostedcert -run TestGuardRegistry -count=1`, then `python3 scripts/ci-test.py check`.
+- [ ] **Commit:** `hostedcert: registry for certified guard mutations`.
+
+### Task 6: `isolatedjob` types, validation and clock
+
+**Files:** Create `internal/isolatedjob/{isolatedjob.go,validate.go,clock.go,isolatedjob_test.go}`.
+
+**Interfaces (produces):** The spec §2 `Runner`, `LaunchSpec`, `Job` and `Limits`, exactly as written there, plus:
```go
type Ref string
type ImageDigest string // "sha256:" + 64 lower-case hex
-type Size string // SizeSmall = "small" (2 GB, 1 vCPU), SizeLarge = "large" (4 GB, 2 vCPU)
-type State string // starting running suspending suspended stopping stopped failed
+type Size string // SizeSmall "small" (2 GB, 1 vCPU), SizeLarge "large" (4 GB, 2 vCPU)
+type State string // starting running suspending suspended stopping stopped failed unknown
func (State) Live() bool // starting, running, suspending, suspended, stopping
-func (State) Terminal() bool // stopped, failed
+func (State) Terminal() bool // stopped, failed; unknown is neither
const HardMaxLifetime = 28800 * time.Second
var ErrNotFound, ErrInvalid, ErrConflict, ErrThrottled, ErrIncomplete, ErrBootstrapTooLarge error
func (s LaunchSpec) Validate(l Limits) error
+type Clock interface {
+ Wall() time.Time // may jump
+ Mono() time.Duration // monotonic since process start; never decreases
+}
type ImageRegistry interface {
Register(ctx context.Context, src ImageSource) (ImageDigest, error)
- Status(ctx context.Context, d ImageDigest) (ImageStatus, error) // Building, Ready, Failed
+ Status(ctx context.Context, d ImageDigest) (ImageStatus, error)
}
-type ImageSource struct{ Digest ImageDigest; OCILayout string } // path to an OCI image layout
type NetworkAuditor interface{ AuditNetwork(ctx context.Context) (NetworkAudit, error) }
type NetworkAudit struct {
- ResolverDisabled bool // provider DNS off for the VM network
- IngressClosed bool
- EgressOnly []netip.AddrPort // the proxy and resolver addresses, nothing else
- RouteOutAbsent bool // no default route on the VM subnet
- CheckedAt time.Time
+ ResolverDisabled, IngressClosed, RouteOutAbsent bool
+ EgressOnly []netip.AddrPort
}
func (a NetworkAudit) OK(want []netip.AddrPort) error
```
-- [ ] **Red:** `TestLaunchSpecValidate` table: AttemptID empty, over 64 bytes, or outside `[A-Za-z0-9-]`; image not `sha256:` + 64 hex; unknown size; MaxLifetime zero, negative, above `Limits.MaxLifetime`, above 28,800 s (28,801 s refused, as the spike found); Bootstrap empty or one byte over `MaxBootstrapBytes` (`ErrBootstrapTooLarge`); a valid spec at exactly each limit passes. `TestStateSets`: every state is exactly one of Live or Terminal. `TestNetworkAuditOK`: DNS on, ingress open, an extra egress address or a default route each fail.
-- [ ] **Implement.** Validate wraps `ErrInvalid` except the bootstrap case.
-- [ ] **Green:** `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate|TestStateSets|TestNetworkAuditOK' -count=1`.
-- [ ] **Mutations:** compare MaxLifetime with `>=` instead of `>`; the at-limit row fails. Drop the extra-address check; `TestNetworkAuditOK` fails. Restore.
-- [ ] **Commit:** `isolatedjob: runner interface, launch spec and validation`.
+- [ ] **Red:**
+ - `TestLaunchSpecValidate`, a table with these rows:
+ - AttemptID empty, over 64 bytes, or outside `[A-Za-z0-9-]`;
+ - a malformed image;
+ - an unknown size;
+ - MaxLifetime zero, above `Limits.MaxLifetime`, or above 28,800 s (28,801 s is refused);
+ - Bootstrap empty or one byte over the limit;
+ - and a passing row at exactly each limit.
+ - `TestStateSets`: `unknown` is neither Live nor Terminal, and every other state is exactly one of them.
+ - `TestNetworkAuditOK`.
+- [ ] **Green:** `go test ./internal/isolatedjob -count=1`.
+- [ ] **Mutations:** make `unknown` Terminal, and `TestStateSets` fails. Use `>=` for the lifetime limit, and the at-limit row fails. Restore.
+- [ ] **Commit:** `isolatedjob: runner interface, validation and two-part clock`.
-### Task 5: In-memory fake and the shared contract suite
+### Task 7: In-memory fake and the shared contract suite
-**Files:** Create `internal/isolatedjob/fake.go`, `fake_test.go`, `internal/isolatedjob/isolatedjobtest/contract.go`.
+**Files:** Create `internal/isolatedjob/{fake.go,fake_test.go}` and `internal/isolatedjob/isolatedjobtest/{contract.go,clock.go}`.
**Interfaces (produces):**
```go
-type Clock interface{ Now() time.Time }
-func NewFake(c Clock, l Limits) *Fake // implements Runner, ImageRegistry, NetworkAuditor
-func (*Fake) Inject(op Op, f Fault) // Op: OpLaunch OpGet OpSuspend OpResume OpStop OpList; Fault: FaultThrottle, FaultLostReply (apply, then error), FaultIncompleteList
-func (*Fake) Tick() // applies MaxLifetime expiry, counting suspended time, as AWS does
-func (*Fake) Plant(s LaunchSpec) Ref // a VM the controller never launched
-func (*Fake) LiveByAttempt() map[string]int // for simulation invariants
-func (*Fake) SetBackstop(on bool) // the simulation turns AWS's own expiry off
+func NewFake(c Clock, l Limits) *Fake // Runner, ImageRegistry, NetworkAuditor
+func (*Fake) Inject(op Op, f Fault) // FaultThrottle, FaultLostReply (apply, then error), FaultIncompleteList, FaultUnknownState
+func (*Fake) Tick() // AWS-style expiry at MaxLifetime, counting suspended time
+func (*Fake) SetBackstop(on bool)
+func (*Fake) Plant(s LaunchSpec) Ref
+func (*Fake) LiveByAttempt() map[string]int
+func (*Fake) StopsIssued() []Ref
// isolatedjobtest:
-type Harness struct {
- Runner isolatedjob.Runner
- Image isolatedjob.ImageDigest
- Settle func(ctx context.Context, ref isolatedjob.Ref, want func(isolatedjob.State) bool) (isolatedjob.Job, error)
-}
+type FakeClock struct{ /* SetWall, AdvanceMono, Advance (both) */ }
+type Harness struct{ Runner isolatedjob.Runner; Image isolatedjob.ImageDigest; Settle func(ctx context.Context, ref isolatedjob.Ref, want func(isolatedjob.State) bool) (isolatedjob.Job, error) }
func Contract(t *testing.T, h Harness)
```
-Fake limits match the spike: `MaxLifetime` 8 h, `SuspendUsesLifetime` true, `ConnectionsSurvive` false.
-
-- [ ] **Red:** `Contract` subtests: `LaunchIdempotentOnAttempt` (same spec twice gives one Ref and one VM in `List`); `ChangedSpecConflicts` (same AttemptID, other size gives `ErrConflict`); `StopTwice` and `StopUnknownRef` both nil; `GetAfterStop` gives a terminal state or `ErrNotFound`; `SuspendResumeRoundTrip`; `OversizeBootstrapRefusedBeforeProvider`; `LimitsAreSane`. `TestFakeContract` runs `Contract` on the fake. `TestFakeFaults`: `FaultLostReply` on Launch leaves a VM and returns an error; `FaultIncompleteList` returns `ErrIncomplete` with no jobs; `Tick` stops a VM at launch plus MaxLifetime whether it was suspended or not.
-- [ ] **Implement** the fake (mutex-guarded maps, deterministic Refs `fake-1`, `fake-2`).
-- [ ] **Green:** `go test ./internal/isolatedjob/... -run 'TestFake' -count=1`.
-- [ ] **Mutations:** key idempotency on Ref instead of AttemptID; `LaunchIdempotentOnAttempt` fails. Exclude suspended time in `Tick`; `TestFakeFaults` fails. Restore.
+The fake's limits match the spike: MaxLifetime 8 h, `SuspendUsesLifetime` true, `ConnectionsSurvive` false.
+
+- [ ] **Red:** `Contract` has these subtests:
+ - `LaunchIdempotentOnAttempt`;
+ - `ChangedSpecConflicts`;
+ - `StopTwice`;
+ - `StopUnknownRef`;
+ - `GetAfterStop`, which gives a terminal state or `ErrNotFound`, never `unknown`;
+ - `SuspendResumeRoundTrip`;
+ - `OversizeBootstrapRefusedBeforeProvider`;
+ - `LimitsAreSane`.
+
+ `TestFakeContract` runs `Contract` on the fake. `TestFakeFaults` covers each fault. With `FaultUnknownState`, Get reports `unknown` while the VM stays live.
+- [ ] **Green:** `go test ./internal/isolatedjob/... -count=1`.
+- [ ] **Mutations:** key idempotency on Ref instead of AttemptID, and `LaunchIdempotentOnAttempt` fails. Exclude suspended time from `Tick`, and `TestFakeFaults` fails. Restore.
- [ ] **Commit:** `isolatedjob: in-memory fake and adapter contract suite`.
-### Task 6: AWS adapter
-
-**Files:** Create `internal/isolatedjob/awsjob/{runner.go,images.go,network.go,errors.go,runner_test.go,network_test.go,live_test.go}`, `internal/isolatedjob/providerguard_test.go`. Modify `go.mod`, `go.sum`.
-
-**Interfaces:** Consumes Task 4. Produces:
-
-```go
-type Config struct {
- Region string // "eu-west-1"
- ConnectorID string // the VPC connector, the only egress
- ImageVersions map[isolatedjob.ImageDigest]string // filled by Registry
- ProxyAndResolver []netip.AddrPort
- VPCID, VMSubnetID, VMSecurityGroupID string
-}
-type API interface { /* the six MicroVM operations, image build and status, and the four EC2 Describe calls the audit needs, in SDK input/output types */ }
-func New(cfg Config, api API) (*Runner, error) // refuses an empty field
-func NewRegistry(cfg Config, api API) (*Registry, error)
-```
-
-- [ ] **Step 1, decide the client:** check whether aws-sdk-go-v2 publishes a MicroVM service package (`go list -m -versions github.com/aws/aws-sdk-go-v2/service/...` for the service the spike's `run-microvm` CLI command belongs to). If it does, use it. If not, write the six calls against the documented HTTP API with `github.com/aws/aws-sdk-go-v2/aws/signer/v4`, inside this package only. Record the choice, the hook transport and the client-token idempotency window from AWS's documentation in the package comment (open question 1).
-- [ ] **Red:** `TestRunRequestShape` against a recording `API` stub: ingress `NO_INGRESS`; egress only `ConnectorID`; no execution role field set; no idle policy; maximum duration equals `MaxLifetime` seconds; architecture x86_64; `additionalOsCapabilities` exactly `["ALL"]` (on the launch or the image version, wherever the API takes it); memory 2048 or 4096 by size; client token equals AttemptID; payload equals Bootstrap byte for byte; image is the registered version for the digest (unregistered digest gives `ErrInvalid`, so a suspended VM's snapshot can never be a launch source). `TestStateMapping` table from every provider state to `isolatedjob.State` (an unknown provider state maps to `failed`, never to a live state). `TestErrorMapping`: throttling to `ErrThrottled`, idempotency mismatch to `ErrConflict`, not found to `ErrNotFound`. `TestListAllPages`: three pages concatenate; an error on page two returns `ErrIncomplete` and no jobs. `TestAuditNetwork`: VPC `enableDnsSupport` true, a security-group egress rule beyond proxy and resolver, any ingress rule, or a `0.0.0.0/0` or `::/0` route on the VM subnet each fail `NetworkAudit.OK`. `TestProviderTypesStayInAdapter` (in `internal/isolatedjob`): `go list -deps` of `./cmd/equipo`, `./cmd/equipo-runner`, `./internal/hostedctl/...`, `./internal/egressproxy/...` contains no `github.com/aws/` path and no `internal/isolatedjob/awsjob`.
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/isolatedjob/... -run 'TestRunRequestShape|TestStateMapping|TestErrorMapping|TestListAllPages|TestAuditNetwork|TestProviderTypesStayInAdapter' -count=1`; `make build vet govulncheck`.
-- [ ] **Mutations:** set an execution role; `TestRunRequestShape` fails. Set an idle policy; it fails. Drop the capabilities field; it fails. Map an unknown state to `running`; `TestStateMapping` fails. Return partial pages; `TestListAllPages` fails. Import `awsjob` from `internal/hostedctl`; the guard fails. Restore each.
-- [ ] **Live (agent, `kass`, under $1):** `live_test.go` (`//go:build hostedlive`) runs `Contract` against a throwaway image and a pre-existing dev connector, then lists and confirms no VM it launched remains. Run once with `AWS_PROFILE=kass go test -tags hostedlive ./internal/isolatedjob/awsjob -run TestLiveContract -count=1` after Task 31's network exists, not before. Record output and teardown proof.
+### Task 8: AWS adapter (certified guards)
+
+**Files:**
+- Create `internal/isolatedjob/awsjob/{runner.go,images.go,network.go,errors.go,runner_test.go,network_test.go,live_test.go}` and `internal/isolatedjob/providerguard_test.go`.
+- Modify `go.mod` and `go.sum`.
+
+**Interfaces:**
+- Consumes Tasks 4, 6 and 7.
+- Produces `New(cfg Config, api API) (*Runner, error)`, `NewRegistry(cfg Config, api API) (*Registry, error)` and `Config{Region, ConnectorID, VPCID, VMSubnetID, VMSecurityGroupID string; ProxyAndResolver []netip.AddrPort}`. `API` is a narrow interface in the SDK's own types, or SigV4 calls if Task 4 found no SDK package.
+
+- [ ] **Red:**
+ - `TestRunRequestShape`, against a recording `API` stub, asserts:
+ - `NO_INGRESS`;
+ - egress only through the connector;
+ - no execution role;
+ - no idle policy;
+ - maximum duration equal to MaxLifetime;
+ - x86_64;
+ - `additionalOsCapabilities` exactly `["ALL"]`;
+ - memory 2048 or 4096;
+ - client token equal to AttemptID;
+ - payload byte for byte;
+ - the registered version for the digest. An unregistered digest gives `ErrInvalid`, so a suspended VM's snapshot can never be a launch source.
+ - `TestStateMapping`: every documented state maps, and an unfamiliar state gives `unknown` with the raw value in `Reason`.
+ - `TestErrorMapping`.
+ - `TestListAllPages`: an error on page two gives `ErrIncomplete` and no jobs.
+ - `TestAuditNetwork`.
+ - `TestProviderTypesStayInAdapter`: `go list -deps -f` over `./...`. Any package other than `awsjob` (and its subpackages) and `cmd/equipo-hosted-controller` that depends on `github.com/aws/` or on `awsjob` fails. This holds at every later task.
+- [ ] **Green:**
+ - `go test ./internal/isolatedjob/... -run 'TestRunRequestShape|TestStateMapping|TestErrorMapping|TestListAllPages|TestAuditNetwork|TestProviderTypesStayInAdapter' -count=1`
+ - `make build vet govulncheck`
+- [ ] **Mutations (register each):**
+ - Set a role, an idle policy, or drop the capabilities field: `TestRunRequestShape` fails.
+ - Map an unfamiliar state to `failed`: `TestStateMapping` fails.
+ - Return partial pages: `TestListAllPages` fails.
+ - Import `awsjob` from `internal/isolatedjob`: the guard fails.
+- [ ] **Live (after Task 38's network exists, with Paul's GO):** `live_test.go` (`//go:build hostedlive`) runs `Contract` in `kass` and lists afterwards to confirm teardown.
- [ ] **Commit:** `isolatedjob: AWS MicroVM adapter behind the runner interface`.
----
-
-## Phase C: the controller (spec §2 controller, §3, §10 leaked VMs)
+### Task 9: Shared wire types and signatures (`hostedwire`, certified guards)
-### Task 7: Signed requests and responses (`hostedwire`)
+This is the shared skeleton. The controller, proxy, probe and instance client all build on these types.
-**Files:** Create `internal/hostedwire/{sign.go,verify.go,types.go,sign_test.go}`.
+**Files:** Create `internal/hostedwire/{sign.go,verify.go,identity.go,vmkey.go,api.go,sign_test.go,vmkey_test.go}`.
**Interfaces (produces):**
@@ -213,62 +302,73 @@ type KeyID string
type Role string // RoleInstance, RoleOperator, RoleProxy
func SignRequest(r *http.Request, body []byte, id KeyID, key ed25519.PrivateKey, now time.Time, nonce string) error
type NonceStore interface{ Remember(ctx context.Context, id KeyID, nonce string, until time.Time) (fresh bool, err error) }
-type Verifier struct {
- Keys map[KeyID]VerifyKey // VerifyKey{Public ed25519.PublicKey; Role Role}
- Nonces NonceStore
- Now func() time.Time
-}
-func (v *Verifier) Verify(r *http.Request, body []byte) (KeyID, Role, error)
+type Verifier struct{ Keys map[KeyID]VerifyKey; Nonces NonceStore; Now func() time.Time } // VerifyKey{Public; Role; InstanceHost string}
+func (*Verifier) Verify(r *http.Request, body []byte) (KeyID, VerifyKey, error)
func SignResponse(h http.Header, status int, requestNonce string, body []byte, key ed25519.PrivateKey)
func VerifyResponse(resp *http.Response, body []byte, requestNonce string, pub ed25519.PublicKey) error
const MaxBody = 1 << 20
+// identity.go: proxy credential identity, URI SAN
+// equipo-hosted://launch/<launch>/attempt/<attempt>/vm/<vm>/epoch/<n>
+type Identity struct{ LaunchID, AttemptID, VMRef string; Epoch int64 }
+func ParseIdentity(c *x509.Certificate) (Identity, error)
+// vmkey.go: VM-key proofs, signed by the per-VM key made at /run
+func RedeemMessage(launch, vm string, codeSHA256 [32]byte, vmKey, credKey ed25519.PublicKey) []byte
+func ExchangeMessage(launch, vm string, epoch int64, challenge string, credKey ed25519.PublicKey) []byte
+// api.go: request and response structs for every Task 20 route, strict JSON
+type Bootstrap struct{ Version int; LaunchID string; Purpose string; ProxyCode string; InstanceCode string }
+// FeedLaunch and FeedPage are added by Task 10, which owns the snapshot type they carry.
```
-Headers `Equipo-Key-Id`, `Equipo-Timestamp` (Unix seconds), `Equipo-Nonce` (32 hex), `Equipo-Signature` (base64). The request message is `"equipo-hosted-request-v1\n" + method + "\n" + escaped path and raw query + "\n" + timestamp + "\n" + nonce + "\n" + hex(sha256(body))`; the response message is `"equipo-hosted-response-v1\n" + status + "\n" + request nonce + "\n" + hex(sha256(body))`. Skew limit 60 s; nonces kept 10 minutes.
-
-- [ ] **Red:** `TestSignedRequestRoundTrip`; `TestSignatureCoversEveryField` (changed method, path, query, timestamp, nonce or body each fail); `TestSkewRefused` (61 s either way); `TestNonceReplayRefused`; `TestUnknownKeyRefused`; `TestNonceStoreErrorDenies`; `TestResponseBoundToRequestNonce` (a valid response replayed for another request fails); `TestOversizeBodyRefused`.
-- [ ] **Implement.**
+Request message: `"equipo-hosted-request-v1\n" + method + "\n" + escaped path and raw query + "\n" + timestamp + "\n" + nonce + "\n" + hex(sha256(body))`. Response message: `"equipo-hosted-response-v1\n" + status + "\n" + request nonce + "\n" + hex(sha256(body))`. The skew limit is 60 s, and nonces are kept 10 minutes. Each VM-key message starts with its own domain string (`equipo-hosted-redeem-v1`, `equipo-hosted-exchange-v1`), so neither can stand in for the other.
+
+- [ ] **Red:**
+ - `TestSignedRequestRoundTrip`
+ - `TestSignatureCoversEveryField`
+ - `TestSkewRefused`
+ - `TestNonceReplayRefused`
+ - `TestNonceStoreErrorDenies`
+ - `TestResponseBoundToRequestNonce`
+ - `TestOversizeBodyRefused`
+ - `TestIdentityRoundTrip`
+ - `TestVMKeyMessagesAreDomainSeparated`: a redeem signature never verifies as an exchange signature.
- [ ] **Green:** `go test ./internal/hostedwire -count=1`.
-- [ ] **Mutations:** drop the body hash from the message; `TestSignatureCoversEveryField` fails. Skip `Remember`; `TestNonceReplayRefused` fails. Treat a store error as fresh; `TestNonceStoreErrorDenies` fails. Restore.
-- [ ] **Commit:** `hostedwire: signed requests and responses for the controller`.
-
-### Task 8: Controller store
-
-**Files:** Create `internal/hostedctl/{store.go,schema/0001_jobs.sql,store_test.go}`.
+- [ ] **Mutations (register each):**
+ - Drop the body hash: `TestSignatureCoversEveryField` fails.
+ - Skip `Remember`: `TestNonceReplayRefused` fails.
+ - Treat a store error as fresh: `TestNonceStoreErrorDenies` fails.
+ - Drop the domain strings: `TestVMKeyMessagesAreDomainSeparated` fails.
+- [ ] **Commit:** `hostedwire: signatures, identities and controller wire types`.
-**Interfaces (produces):** `Open(ctx, path string, clock isolatedjob.Clock) (*Store, error)` (one writer connection, WAL, schema version table, refuses a newer schema); `(*Store) Tx(ctx, fn func(*sql.Tx) error) error`; `(*Store) Close() error`; `(*Store).Remember` implements `hostedwire.NonceStore`; `appendAudit(tx *sql.Tx, a Audit) error` with `Audit{Actor hostedwire.KeyID; Account, Task, Attempt, Action, Reason string}`; `(*Store) Now() time.Time` returns the larger of the clock and a persisted high-water mark.
+### Task 10: Egress policy with per-launch snapshots (certified guards)
-Tables: `jobs` (attempt_id primary key; launch_id unique; task_id, account_id, purpose `job` or `certification`, replaces_attempt; request_json and request_sha256, the exact `LaunchSpec`; proxy_code_sha256, proxy_code_expires_at, proxy_code_used_at; vm_ref unique nullable; state; image_digest, certificate_digest; launched_at, deadline, drain_at, stop_at; epoch, resume_operation_id; pause_generation, pause_started_at, pause_quiescent, pause_cancelled; stop_requested_at, stop_reason, stop_proof_json; revision), `unmatched_vms` (vm_ref, first_seen_at), `certificates` (image_digest, digest, payload, signature, stored_at), `nonces`, `audit`, `clock` (high-water), `feed` (revision counter).
-
-- [ ] **Red:** `TestStoreMigratesTwice` (second open applies nothing); `TestStoreRefusesNewerSchema`; `TestAuditRollsBackWithTx`; `TestHighWaterNeverMovesBack` (clock set back one hour, `Now` stays at the high-water mark); `TestOneWriterConnection`.
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/hostedctl -run 'TestStore|TestAudit|TestHighWater|TestOneWriter' -count=1`.
-- [ ] **Mutations:** write audit outside the transaction; `TestAuditRollsBackWithTx` fails. Return the raw clock from `Now`; `TestHighWaterNeverMovesBack` fails. Restore.
-- [ ] **Commit:** `hostedctl: job table, audit and clock high-water store`.
-
-### Task 9: Egress policy model
-
-**Files:** Create `internal/egresspolicy/{names.go,policy.go,policy_test.go}`.
+**Files:**
+- Create `internal/egresspolicy/{names.go,snapshot.go,rules.go,policy_test.go}`.
+- Create `internal/hostedwire/feed.go`: `FeedLaunch{LaunchID, AttemptID, VMRef, State, Purpose string; Epoch int64; Snapshot egresspolicy.Snapshot}` and `FeedPage{Revision int64; Launches []FeedLaunch}`.
**Interfaces (produces):**
```go
-type ServiceNames struct{ Instance, Gateway, Mirror string } // exact FQDN, or None; "" is unset
const None = "none"
var ErrUnset, ErrDeniedName, ErrBadName error
-func ParseServiceNames(in ServiceNames) (ServiceNames, error) // lower-cases, strips one trailing dot, IDNA to ASCII
+func ParseName(s string, allowNone bool) (string, error) // lower-case, one trailing dot stripped, IDNA to ASCII
type Purpose string // PurposeJob, PurposeCertification
-type Policy struct {
- Version string // "hosted-egress-1"
- Services ServiceNames
- ReportHost string // controller host for certification reports
+type Snapshot struct { // immutable, stored in the launch record
+ Version string // "hosted-egress-1"
+ Instance string // exact host of the requesting instance key
+ Gateway string // None in this version
+ Mirror string // exact host or None
+ Purpose Purpose
+ Report string // controller report host; set only for certification
}
-type Request struct{ Host, Method, Path string; WebSocket bool; Purpose Purpose }
+func NewSnapshot(version, instance, gateway, mirror, report string, p Purpose) (Snapshot, error)
+func (Snapshot) Digest() string // sha256 of canonical JSON
+type Rules struct{ /* compiled from one snapshot */ }
+func Compile(s Snapshot) (*Rules, error)
+type Request struct{ Host, Method, RawPath string; WebSocket bool }
type Decision struct{ Allowed bool; Service, PathClass, Reason string }
-func Compile(p Policy) (*Rules, error)
-func (r *Rules) Decide(q Request) Decision
-func (r *Rules) Hosts(p Purpose) []string // exact names the resolver answers
-func Digest(p Policy) string // sha256 of canonical JSON
+func (*Rules) Decide(q Request) Decision
+func (*Rules) Hosts() []string
+func RulesDigest(version string) string // path classes and methods only; the certificate binds this
```
Path classes for `hosted-egress-1`:
@@ -282,479 +382,1107 @@ Path classes for `hosted-egress-1`:
| mirror | GET, HEAD | `/v1/objects/sha256/{64 hex}` | no |
| report (certification purpose only) | POST | `/v1/certification/report` | no |
-A gateway name other than `none` is a `Compile` error in this version (no model work). Paths are matched raw: percent-encoded `/`, `.` or `%`, dot segments, `//`, a query on the mirror class, or a fragment are refused before matching.
-
-- [ ] **Red:** `TestServiceNamesRefuse` table: `*.example.com`, `.example.com`, an IPv4 or IPv6 literal, `host:443`, userinfo, every denied registry name and `amadan.net`, an empty label. `TestServiceNameNormalisation`: `Instance.Example.` equals `instance.example`; a punycode name equals its Unicode form; `instance.example.evil` never equals `instance.example`. `TestUnsetBlocks` (any "" gives `ErrUnset`). `TestNoneDeniesService`. `TestPathClasses` table covering every row above and its near misses (`/api/runner/stream` without upgrade, `/api/runner/v2/../x`, `%2e%2e`, `%2F`, `PUT` on the mirror, a mirror query string). `TestGatewayRefusedInThisVersion`. `TestReportRouteOnlyForCertification`. `TestDigestCoversEveryField`.
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/egresspolicy -count=1`.
-- [ ] **Mutations:** allow a suffix match; the `.evil` row fails. Decode the path before matching; the `%2F` row fails. Allow the report route for jobs; its test fails. Restore.
-- [ ] **Commit:** `egresspolicy: exact service names and path classes`.
+The following are refused before matching:
+- percent-encoded `/`, `.` or `%`;
+- dot segments;
+- `//`;
+- a fragment;
+- a query on the mirror class.
+
+A gateway other than `none` is a `NewSnapshot` error in this version.
+
+- [ ] **Red:**
+ - `TestNamesRefuse`: a wildcard, a leading dot, IP literals, a port, userinfo, each of the six denied names, and an empty label.
+ - `TestSnapshotNameNormalisation`.
+ - `TestUnsetBlocks`.
+ - `TestNoneDeniesService`.
+ - `TestPathClasses`: every row in the table above, plus near misses.
+ - `TestGatewayRefusedInThisVersion`.
+ - `TestReportOnlyForCertification`.
+ - `TestRulesAreSnapshotBound`: two snapshots with different instance hosts each allow only their own host.
+ - `TestDigestCoversEveryField`.
+- [ ] **Green:** `go test ./internal/egresspolicy ./internal/hostedwire -count=1`.
+- [ ] **Mutations (register each):**
+ - Suffix-match names: normalisation fails.
+ - Decode the path before matching: the `%2F` row fails.
+ - Allow the report class for jobs: its test fails.
+ - Use one global host list: `TestRulesAreSnapshotBound` fails.
+- [ ] **Commit:** `egresspolicy: per-launch snapshots, exact names and path classes`.
+
+### Task 11: Certificate format and the trusted matrix definition (certified guards)
+
+The expected outcomes live here, in the repository, and are embedded in the verifier. A report supplies observations only.
+
+**Files:** Create `internal/hostedcert/{certificate.go,matrix.json,definition.go,certificate_test.go}`.
-### Task 10: Image certificate format and verification
-
-**Files:** Create `internal/hostedcert/{certificate.go,certificate_test.go}`.
-
-**Interfaces:** Consumes `egresspolicy.ServiceNames`, `egresspolicy.Digest`, `isolatedjob.ImageDigest`. Produces:
+**Interfaces (produces):**
```go
+type MatrixRow struct { // from matrix.json, embedded
+ Name, Actor string // actor: root, runner, sandbox
+ Expect string // allowed, proxy_refused:<reason>, nxdomain, unreachable, denied_locally
+ Control string // name of the positive-control row that must pass for this refusal to count; "" for allowed rows
+}
+func Matrix() []MatrixRow
+type Observation struct{ Name, Outcome, Evidence string } // the only thing a report says about a row
+type Report struct {
+ Containment SuiteResult // Total, Passed int; Failed, Skipped []string
+ Rows []Observation
+}
+type Provenance struct{ LaunchID, VMRef string; Epoch int64; SnapshotDigest string; ReceivedAt time.Time; ReportSHA256 string } // recorded by the controller from the authenticated identity and the launch record, not the VM
+type GuardEvidence struct{ Commit string; Guards []GuardResult; SHA256 string } // GuardResult{ID, Test string; FailedUnderMutation, PassedAfterRestore bool}
type Certificate struct {
- Version int // 1
+ Version int
Image isolatedjob.ImageDigest
- RunnerDigest string // sha256 of the runner binary in the image
- SandboxPolicyDigest string // containment LauncherVersion and launch policy hash
- ProxyPolicyVersion string
- ProxyPolicyDigest string // egresspolicy.Digest without ReportHost
- Services egresspolicy.ServiceNames
- MirrorConfigDigest string // "none" while Mirror is none
- Containment SuiteResult // Total, Passed int; Failed, Skipped []string
- Matrix []MatrixRow // Name, Actor, Expected, Observed string
+ BuildCommit string // from release provenance
+ RunnerSHA256, ToolProxySHA256, ProbeSHA256 string
+ SandboxPolicyDigest string
+ PolicyVersion string
+ RulesDigest string // egresspolicy.RulesDigest
+ Gateway, Mirror string // as in snapshots; "none" in slice 1
+ MirrorConfigDigest string
+ ReportPolicyDigest string // the certification launch's own snapshot digest, bound separately
+ ProxyRootSHA256, InterceptRootSHA256 string // roots pinned in the image
+ Report Report
+ Provenance Provenance
Network isolatedjob.NetworkAudit
- ReportDigest string
+ Guards GuardEvidence
IssuedAt time.Time
KeyID string
}
type Signed struct{ Payload, Signature []byte }
-type Expectation struct {
+type Expectation struct { // built from repository data and the controller's configuration, never from a report
Image isolatedjob.ImageDigest
- RunnerDigest, SandboxPolicyDigest, ProxyPolicyDigest, MirrorConfigDigest string
- Services egresspolicy.ServiceNames
- ContainmentTotal int // from the image manifest (Task 26)
+ BuildCommit, RunnerSHA256, ToolProxySHA256, ProbeSHA256, SandboxPolicyDigest string
+ PolicyVersion, Gateway, Mirror, MirrorConfigDigest string
+ ProxyRootSHA256, InterceptRootSHA256 string
+ ContainmentTotal int // from the image manifest (Task 32)
AllowedSkips []string // exactly {"TestNamespaceCgroupMoveKeepsMembership"}
- MatrixRows []string // every row name of Task 27
+ Guards []string // every id in guards.json
}
func Sign(c Certificate, id string, key ed25519.PrivateKey) (Signed, error)
-func Verify(s Signed, keys map[string]ed25519.PublicKey, want Expectation) (Certificate, string /*digest*/, error)
+func Verify(s Signed, keys map[string]ed25519.PublicKey, want Expectation) (Certificate, string, error)
```
-- [ ] **Red:** `TestCertificateVerifies`; `TestCertificateRefusesEachMismatch` (one row per Expectation field); `TestCertificateRefusesFailures` (one failed test, an extra skip, a missing matrix row, a row whose Observed differs from Expected, a failing NetworkAudit, Total below the manifest count); `TestCertificateRefusesBadSignatureAndUnknownKey`; `TestCertificateRefusesUnknownFields` (strict decoding).
-- [ ] **Implement.** The digest is sha256 of `Payload`.
+`Verify` checks each of these:
+- every `Matrix()` row has exactly one observation, and its outcome equals the row's `Expect`;
+- every refusal's control row passed;
+- no observation names a row the definition lacks;
+- `Containment` matches the expected total and skips;
+- `Provenance.ReportSHA256` equals the hash of the report;
+- `ReportPolicyDigest` equals `Provenance.SnapshotDigest`, and that snapshot has the certification purpose and the certified policy version;
+- every registered guard appears with both flags true, at `BuildCommit`;
+- the network audit passes;
+- every Expectation field matches.
+
+- [ ] **Red:**
+ - `TestCertificateVerifies`.
+ - `TestCertificateRefusesEachMismatch`: one row per Expectation field.
+ - `TestReportCannotChooseExpectations`: an observation that mirrors a wrong expectation still fails.
+ - `TestRefusalNeedsPassingControl`.
+ - `TestUnknownRowRefused`.
+ - `TestGuardEvidenceRequired`: a missing guard, a guard that did not fail under mutation, and evidence from another commit each fail.
+ - `TestProvenanceBindsReport`.
+ - `TestStrictDecoding`.
- [ ] **Green:** `go test ./internal/hostedcert -count=1`.
-- [ ] **Mutations:** skip the Skipped comparison; the extra-skip row fails. Skip the Services comparison; its row fails. Restore.
-- [ ] **Commit:** `hostedcert: signed image certificate and verification`.
+- [ ] **Mutations (register each):**
+ - Compare against the report's outcome instead of `Expect`: `TestReportCannotChooseExpectations` fails.
+ - Skip the control check: `TestRefusalNeedsPassingControl` fails.
+ - Skip the commit comparison: `TestGuardEvidenceRequired` fails.
+- [ ] **Commit:** `hostedcert: certificate, trusted matrix and guard evidence`.
+
+---
-### Task 11: Bootstrap payload and proxy credentials
+## Phase C: the controller (spec §2, §3, §10)
-**Files:** Create `internal/hostedctl/{bootstrap.go,credential.go,credential_test.go}`, `internal/hostedwire/identity.go`.
+### Task 12: Controller store, controller time and the controller skeleton (certified guards)
+
+**Files:** Create `internal/hostedctl/{store.go,clock.go,controller.go,schema/0001_jobs.sql,store_test.go,clock_test.go}`.
**Interfaces (produces):**
```go
-type Bootstrap struct { // JSON, the LaunchSpec.Bootstrap bytes
- Version int
- LaunchID string
- Purpose egresspolicy.Purpose
- ProxyCode string // controller-minted, single use, 2 minutes
- InstanceCode string // opaque, from the instance; empty for certification
+type T time.Duration // controller time; persists across restarts, never decreases
+type CtlClock struct{ /* base T restored from store + Clock.Mono() */ }
+func (*CtlClock) Now() T
+func Open(ctx context.Context, path string, c isolatedjob.Clock, alert func(Alert)) (*Store, error)
+func (*Store) Tx(ctx context.Context, fn func(*sql.Tx) error) error
+func (*Store) Clock() *CtlClock
+func (*Store) Remember(...) // hostedwire.NonceStore
+func appendAudit(tx *sql.Tx, a Audit) error // Audit{Actor hostedwire.KeyID; Account, Task, Attempt, Action, Reason string; At T}
+type Alert struct{ Kind, Detail string; At T }
+type Alerter interface{ Alert(ctx context.Context, a Alert) error } // implemented in Task 20; tests record
+type Issuer interface { // implemented by Task 15's CA
+ Issue(id hostedwire.Identity, credKey ed25519.PublicKey, lifetime time.Duration) ([]byte, error)
}
-type CA struct{ /* Ed25519 x509 CA, key loaded from a 0600 file */ }
-func LoadCA(path string) (*CA, error)
-func (*Controller) Redeem(ctx context.Context, r RedeemRequest) (certDER []byte, err error)
-// RedeemRequest{LaunchID, VMRef, ProxyCode string; PublicKey ed25519.PublicKey}
-func (*Controller) Renew(ctx context.Context, presented *x509.Certificate, pub ed25519.PublicKey) ([]byte, error)
-// in hostedwire, so the proxy never imports the controller:
-func hostedwire.ParseIdentity(c *x509.Certificate) (hostedwire.Identity, error)
-// Identity{LaunchID, AttemptID, VMRef string; Epoch int64}; URI SAN
-// equipo-hosted://launch/<launch>/attempt/<attempt>/vm/<vm>/epoch/<n>
-const CredentialLifetime = 15 * time.Minute
+type Config struct{ Enabled bool } // later tasks add fields
+type Deps struct {
+ Store *Store
+ Runner isolatedjob.Runner
+ Auditor isolatedjob.NetworkAuditor
+ Issuer Issuer
+ Alerter Alerter
+}
+type Controller struct{ /* fields wired by New; methods added by later tasks */ }
+func New(cfg Config, d Deps) (*Controller, error) // refuses a nil dependency
```
-- [ ] **Red:** `TestRedeemSingleUse`; `TestRedeemWrongVMRefused` (VMRef differs from the job's saved ref); `TestRedeemExpiredCode` (2 minutes and 1 second after the provider call returned); `TestRedeemAfterStopRequested`; `TestRedeemStoresOnlyCodeHash`; `TestRenewKeepsIdentityAndEpoch`; `TestRenewRefusedAfterEpochChange`; `TestIdentityRoundTrip`; `TestBootstrapFitsLimit` (a maximal payload is under the fake's `MaxBootstrapBytes`).
-- [ ] **Implement.** Redeem and Renew run in one store transaction each and append audit.
-- [ ] **Green:** `go test ./internal/hostedctl -run 'TestRedeem|TestRenew|TestIdentity|TestBootstrap' -count=1`.
-- [ ] **Mutations:** skip the used-at check; `TestRedeemSingleUse` fails. Skip the VM comparison; `TestRedeemWrongVMRefused` fails. Restore.
-- [ ] **Commit:** `hostedctl: bootstrap codes and short-lived proxy credentials`.
-
-### Task 12: Launch with intent replay and admission gates
-
-**Files:** Create `internal/hostedctl/{controller.go,launch.go,launch_test.go}`.
-
-**Interfaces:** Consumes Tasks 4, 8 to 11. Produces:
+Controller time works like this:
+- Every reaper pass checkpoints `(T, wall)`.
+- On open, `T0 = persisted T + max(0, wall now - persisted wall)`. Wall time that moved forward counts as downtime, which is conservative because deadlines arrive earlier.
+- If the wall clock is behind the persisted wall by more than 2 s, no downtime is credited and the store raises a `clock_rollback` alert.
+- While running, `T` advances only with `Mono()`, so a wall-clock jump has no effect.
+
+For live jobs after a restart, Task 14 also takes elapsed time as the larger of controller-time elapsed and the provider-reported age. AWS's own maximum duration remains the backstop.
+
+Tables:
+- `jobs`:
+ - keys: attempt_id (primary), launch_id (unique), vm_ref (unique, nullable);
+ - who and what: task_id, account_id, actor_key, purpose, replaces_attempt;
+ - the exact `LaunchSpec`: spec_json and spec_sha256;
+ - policy: snapshot_json and snapshot_digest (immutable after insert), certificate_digest;
+ - proxy code: proxy_code_sha256, proxy_code_expires_t, proxy_code_used_t;
+ - VM key: vm_public_key;
+ - state, launched_t, deadline_t, drain_t, stop_t;
+ - epoch, resume_operation_id, exchange_open_until_t, last_credential_t;
+ - pause: pause_generation, pause_started_t, pause_quiescent, pause_cancelled;
+ - stop: stop_requested_t, stop_reason, stop_proof_json;
+ - revision.
+- `challenges`
+- `unmatched_vms` (vm_ref, first_seen_t)
+- `certificates`
+- `reports` (launch_id, sha256, payload, provenance_json)
+- `nonces`
+- `audit`
+- `clock` (t, wall)
+- `feed` (revision)
+
+A trigger refuses any update to `snapshot_json`, `snapshot_digest` or `spec_json`.
+
+- [ ] **Red:**
+ - `TestStoreMigratesTwice`
+ - `TestStoreRefusesNewerSchema`
+ - `TestAuditRollsBackWithTx`
+ - `TestSnapshotImmutable`
+ - `TestRollbackThenElapsedTime` (review focus 2):
+ - set the wall clock back one hour while running, advance Mono 10 minutes, and `Now` has advanced exactly 10 minutes;
+ - close, set the wall clock back again, and reopen: `T` does not go back and one `clock_rollback` alert is raised;
+ - advance Mono 5 minutes, and `T` has advanced exactly 5 minutes.
+ - `TestForwardJumpAcrossRestartCountsAsDowntime`
+- [ ] **Green:** `go test ./internal/hostedctl -run 'TestStore|TestAudit|TestSnapshotImmutable|TestRollback|TestForwardJump' -count=1`.
+- [ ] **Mutations (register each):**
+ - Derive `T` from the wall clock: `TestRollbackThenElapsedTime` fails.
+ - Credit negative downtime: it fails.
+ - Drop the trigger: `TestSnapshotImmutable` fails.
+- [ ] **Commit:** `hostedctl: store, controller time and controller skeleton`.
+
+### Task 13: Launch with intent replay, snapshots and certified admission (certified guards)
+
+**Files:** Create `internal/hostedctl/{launch.go,launch_test.go}` and `internal/hostedctl/testcert_test.go`. The latter signs test certificates with a throwaway key and a test Expectation.
+
+**Interfaces:** Consumes Tasks 6 to 12. Produces:
```go
-type Config struct {
- Enabled bool // EQUIPO_HOSTED_ENABLED=1
- Policy egresspolicy.Policy
- Expect func(isolatedjob.ImageDigest) (hostedcert.Expectation, error)
- CertificateKeys map[string]ed25519.PublicKey
- AuditMaxAge time.Duration // 5 minutes
+type Config struct { // extends Task 12's Config
+ Enabled bool // EQUIPO_HOSTED_ENABLED=1
+ PolicyVersion, Gateway, Mirror, ReportHost string
+ Expect func(isolatedjob.ImageDigest) (hostedcert.Expectation, error)
+ CertificateKeys map[string]ed25519.PublicKey
+ AuditMaxAge time.Duration // 5 min, controller time
}
-func New(cfg Config, s *Store, r isolatedjob.Runner, a isolatedjob.NetworkAuditor, ca *CA) (*Controller, error)
type LaunchRequest struct {
AttemptID, TaskID, Account, Replaces string
- Image isolatedjob.ImageDigest
- Size isolatedjob.Size
- MaxLifetime time.Duration // default 8 h
+ Image isolatedjob.ImageDigest; Size isolatedjob.Size
+ MaxLifetime time.Duration // default 8 h
InstanceCode []byte
- Purpose egresspolicy.Purpose
+ Purpose egresspolicy.Purpose
}
-type JobView struct{ AttemptID, LaunchID, State string; VMRef isolatedjob.Ref; Deadline, DrainAt, StopAt time.Time; Epoch int64; CertificateDigest string }
-func (*Controller) Launch(ctx context.Context, actor hostedwire.KeyID, role hostedwire.Role, q LaunchRequest) (JobView, error)
+type JobView struct{ AttemptID, LaunchID, State string; VMRef isolatedjob.Ref; Epoch int64; DeadlineIn, DrainIn, StopIn time.Duration; CertificateDigest, SnapshotDigest string }
+func (*Controller) Launch(ctx context.Context, by hostedwire.KeyID, key hostedwire.VerifyKey, q LaunchRequest) (JobView, error)
func (*Controller) Replay(ctx context.Context) error
-func Deadlines(launched time.Time, max time.Duration) (deadline, drainAt, stopAt time.Time)
-// deadline = launched+max; drainAt = deadline-45m; stopAt = deadline-10m; both clamped to launched
+func Deadlines(launched T, max time.Duration) (deadline, drain, stop T) // drain = deadline-45m, stop = deadline-10m, clamped to launched
var ErrDisabled, ErrUncertified, ErrNetworkAudit, ErrReplacementLive error
```
-Order inside `Launch`: refuse unless enabled; parse service names (unset refuses); certification purpose requires `RoleOperator` and a registered image, a job requires `RoleInstance` and a stored certificate that verifies against the current Expectation; require a passing network audit no older than `AuditMaxAge`; a `Replaces` attempt must have stop proof; then transaction 1 saves the intent (exact `LaunchSpec` bytes, hash, deadlines, certificate digest, proxy code hash) or returns the existing job when the request hash matches (`ErrConflict` when it differs); then `Runner.Launch`; then transaction 2 saves the Ref and state `starting`. `ErrThrottled` leaves the intent in state `waiting` for `Replay`.
-
-- [ ] **Red:** `TestLaunchSavesIntentBeforeProvider` (the Runner stub reads the store during its call and finds the intent); `TestLaunchIdempotentOnAttempt`; `TestLaunchConflictOnChangedRequest`; `TestConcurrentLaunchSameAttempt` (20 goroutines, one VM, one intent); `TestCrashBetweenLaunchAndSave` (`FaultLostReply`, reopen the store, `Replay`, exactly one VM and the Ref saved); `TestLaunchRefusals` table (disabled, unset name, uncertified image, certificate for other services, stale or failing audit, job purpose from operator, certification from instance, live replaced attempt); `TestLaunchRecordsCertificateDigest`; `TestThrottleWaitsThenReplays`; `TestDeadlines` (8 h gives 7 h 15 and 7 h 50; 15 min gives 0 and 5 min).
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/hostedctl -run 'TestLaunch|TestConcurrentLaunch|TestCrashBetween|TestThrottle|TestDeadlines' -count=1`.
-- [ ] **Mutations:** save the intent after the provider call; `TestCrashBetweenLaunchAndSave` fails. Skip certificate verification; `TestLaunchRefusals` fails. Skip the Replaces check; it fails. Restore.
-- [ ] **Commit:** `hostedctl: launch intents, replay and certified admission`.
-
-### Task 13: Get, stop and stop proof
+`Launch` runs in this order:
+1. Refuse unless enabled.
+2. Build the snapshot. The instance host comes from the calling key's `InstanceHost`, never from the request. Gateway and mirror come from configuration. An unset name refuses.
+3. A job purpose needs `RoleInstance` and a stored certificate that verifies against `Expect`, whose Gateway and Mirror equal the snapshot's. A certification purpose needs `RoleOperator` and a registered image.
+4. Require a passing audit no older than `AuditMaxAge`.
+5. `Replaces` needs stop proof.
+6. Transaction 1 saves the intent: spec, snapshot, deadlines, proxy-code hash, certificate digest. If the request hash already matches an existing intent, return it. If it differs, return `ErrConflict`.
+7. Call `Runner.Launch`.
+8. Transaction 2 saves the Ref and the `starting` state.
+
+`ErrThrottled` leaves state `waiting`.
+
+- [ ] **Red:**
+ - `TestLaunchSavesIntentBeforeProvider`
+ - `TestLaunchIdempotentOnAttempt`
+ - `TestLaunchConflictOnChangedRequest`
+ - `TestConcurrentLaunchSameAttempt` (review focus 5)
+ - `TestCrashBetweenLaunchAndSave`
+ - `TestSnapshotUsesKeyHost`: a request cannot name another instance.
+ - `TestConfigChangeLeavesOldSnapshots`
+ - `TestLaunchRefusals`, a table:
+ - flag off;
+ - an unset name;
+ - no certificate;
+ - a certificate for another mirror;
+ - a stale audit;
+ - a failing audit;
+ - the wrong role for the purpose;
+ - a live replaced attempt.
+ - `TestThrottleWaitsThenReplays`
+ - `TestDeadlines`
+- [ ] **Green:** `go test ./internal/hostedctl -run 'TestLaunch|TestConcurrentLaunch|TestCrashBetween|TestSnapshotUses|TestConfigChange|TestThrottle|TestDeadlines' -count=1`.
+- [ ] **Mutations (register each):**
+ - Take the instance host from the request: `TestSnapshotUsesKeyHost` fails.
+ - Skip certificate verification: `TestLaunchRefusals` fails.
+ - Skip the Replaces check: it fails.
+- [ ] **Commit:** `hostedctl: launch intents, replay, snapshots and certified admission`.
+
+### Task 14: Get, stop, stop proof and unknown states (certified guards)
**Files:** Create `internal/hostedctl/{stop.go,stop_test.go}`.
-**Interfaces (produces):** `(*Controller) Get(ctx, attemptID) (JobView, error)`; `(*Controller) Stop(ctx, actor, attemptID, reason string) (StopProof, error)` with `StopProof{AttemptID string; VMRef isolatedjob.Ref; State isolatedjob.State; ObservedAt time.Time}`; `ErrStopPending`. Stop first records `stop_requested_at` and bumps the feed revision (proxy access ends, Task 21), then calls `Runner.Stop`, then `Runner.Get`; proof exists only for a terminal state or `ErrNotFound` after the stop request. `(*Controller) Refresh(ctx) error` reconciles live jobs with `Get`.
+**Interfaces (produces):**
+- `Get(ctx, by, attemptID) (JobView, error)`.
+- `Stop(ctx, by hostedwire.KeyID, key hostedwire.VerifyKey, attemptID, reason string) (StopProof, error)`. An instance key may stop only its own jobs. An operator key may stop only the certification launches it created.
+- `StopProof{AttemptID string; VMRef isolatedjob.Ref; State isolatedjob.State; ObservedAt T}`.
+- `Refresh(ctx) error`.
+- `ErrStopPending`, `ErrStateUnknown`.
+
+Stop runs in this order:
+1. Record `stop_requested_t` and bump the feed revision.
+2. Call `Runner.Stop`.
+3. Call `Runner.Get`.
+
+Proof needs a terminal state, or `ErrNotFound` after the stop request. An `unknown` state gives `ErrStateUnknown`, with no proof and no replacement. `Refresh` after a restart uses the larger of controller-time elapsed and the provider-reported age (Task 12).
+
+- [ ] **Red:**
+ - `TestStopRevokesBeforeProvider`
+ - `TestStopProofNeedsTerminalState`
+ - `TestUnknownStateIsNeverProof` (review focus 1): `FaultUnknownState`, so no proof and a replacement launch is refused.
+ - `TestLostStopReplyRetries`
+ - `TestStopOfGoneVMSucceeds`
+ - `TestRestartFindsVMGone`
+ - `TestStopRoles`: an instance key cannot stop another instance's job; an operator stops its own certification launch but cannot stop a job; a proxy key stops nothing.
+- [ ] **Green:** `go test ./internal/hostedctl -run 'TestStop|TestUnknownState|TestLostStop|TestRestartFinds' -count=1`.
+- [ ] **Mutations (register each):**
+ - Accept `stopping`, or accept `unknown`, as proof: its test fails.
+ - Call the provider before recording the stop: `TestStopRevokesBeforeProvider` fails.
+- [ ] **Commit:** `hostedctl: stop proof, unknown states and stop roles`.
+
+### Task 15: VM keys, credentials, the resume exchange and the feed (certified guards)
+
+**Files:** Create `internal/hostedctl/{ca.go,credential.go,feed.go,credential_test.go,feed_test.go}`.
-- [ ] **Red:** `TestStopRevokesBeforeProvider` (the feed shows the launch revoked when the Runner stub's Stop runs); `TestStopProofNeedsTerminalState` (a `stopping` VM gives `ErrStopPending`); `TestLostStopReplyRetries` (`FaultLostReply` on Stop, a second Stop gives proof, one provider stop applied); `TestStopOfGoneVMSucceeds`; `TestRestartFindsVMGone` (review focus 1: the fake expires the VM while the controller is closed; after reopen, `Refresh` records proof and revokes).
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/hostedctl -run 'TestStop|TestLostStop|TestRestartFindsVMGone' -count=1`.
-- [ ] **Mutations:** call the provider before recording the stop request; `TestStopRevokesBeforeProvider` fails. Accept `stopping` as proof; `TestStopProofNeedsTerminalState` fails. Restore.
-- [ ] **Commit:** `hostedctl: stop with revocation first and terminal proof`.
+**Interfaces (produces):**
-### Task 14: Pause barrier and resume epochs (controller half)
+```go
+func LoadCA(path string) (*CA, error) // Ed25519 x509 CA; key file 0600; implements Task 12's Issuer
+const CredentialLifetime = 15 * time.Minute
+const ExchangeWindow = 2 * time.Minute
+// Redeem: once per launch. Registers the VM key and returns the first credential.
+func (*Controller) Redeem(ctx context.Context, r hostedwire.RedeemRequest) (certDER []byte, err error)
+// RedeemRequest{LaunchID, VMRef, ProxyCode string; VMKey, CredKey ed25519.PublicKey; Proof []byte /* VM key over RedeemMessage */}
+// Challenge: a nonce bound to (launch, current epoch), single use, ExchangeWindow.
+func (*Controller) Challenge(ctx context.Context, launchID string) (challenge string, epoch int64, err error)
+// Exchange: renewal and post-resume rotation. Authority is the registered VM key only.
+func (*Controller) Exchange(ctx context.Context, r hostedwire.ExchangeRequest) (certDER []byte, err error)
+// ExchangeRequest{LaunchID, VMRef string; Epoch int64; Challenge string; CredKey ed25519.PublicKey; Proof []byte /* VM key over ExchangeMessage */}
+func (*Controller) Feed(ctx context.Context, after int64) (hostedwire.FeedPage, error) // signed by the controller key; long poll
+```
-**Files:** Create `internal/hostedctl/{pause.go,pause_test.go}`.
+The rules:
+- **Redeem** requires all of these: the code is unused; its expiry has not passed (2 min after the provider call returned, in controller time); `VMRef` equals the saved Ref; the job is live with no stop requested; the proof verifies under `VMKey`.
+- **Exchange** requires the registered VM key, the current epoch, an unused challenge for that epoch, and a live state that is neither suspended nor stop-requested.
+- **Credentials** are bound to `(launch, attempt, VM, epoch)` in `Identity`. `last_credential_t` is updated on every issue.
+- **The feed** carries each launch's state, epoch and immutable snapshot, and bumps its revision on every change.
+
+- [ ] **Red:**
+ - `TestRedeemSingleUse`
+ - `TestRedeemWrongVMRefused`
+ - `TestRedeemExpiredCode`
+ - `TestRedeemNeedsProofOfKey`
+ - `TestRedeemStoresOnlyCodeHash`
+ - `TestExchangeNeedsRegisteredKey`: a fresh key with a valid challenge fails.
+ - `TestExchangeChallengeSingleUse`
+ - `TestExchangeOldEpochRefused`
+ - `TestExchangeRefusedWhileSuspendedOrStopping`
+ - `TestFeedCarriesSnapshotAndEpoch`
+ - `TestFeedSigned`
+- [ ] **Green:** `go test ./internal/hostedctl -run 'TestRedeem|TestExchange|TestFeed' -count=1`.
+- [ ] **Mutations (register each):**
+ - Skip the used check: `TestRedeemSingleUse` fails.
+ - Skip the VM comparison: `TestRedeemWrongVMRefused` fails.
+ - Accept any key in Exchange: `TestExchangeNeedsRegisteredKey` fails.
+ - Skip the epoch check: `TestExchangeOldEpochRefused` fails.
+- [ ] **Commit:** `hostedctl: VM keys, credential exchange and launch feed`.
+
+### Task 16: Pause generations and resume epochs (certified guards)
-**Interfaces (produces):** `Drain(ctx, attemptID) (generation int64, error)`; `Quiescent(ctx, attemptID string, generation int64) error`; `Suspend(ctx, attemptID string, generation int64) error`; `Reopen(ctx, attemptID string, generation int64) error`; `Resume(ctx, attemptID, operationID string) (epoch int64, error)`; `ErrGenerationCancelled`, `ErrNotQuiescent`, `ErrPastDeadline`. `PauseAckTimeout = 2 * time.Minute`. The instance owns admission (slice 2); the controller owns the generation, the acknowledgement and the epoch.
+**Files:** Create `internal/hostedctl/{pause.go,pause_test.go}`.
-- [ ] **Red:** `TestSuspendNeedsCurrentAck` (no ack, ack for an older generation, ack for a cancelled generation each refuse); `TestLateAckIgnored` (ack at 2 min 1 s gives `ErrGenerationCancelled` and Suspend refuses); `TestResumeRaisesEpochOnce` (same operation ID twice gives the same epoch; a new ID raises it again); `TestResumeRevokesOldEpoch` (a credential minted before resume is refused by `Renew` and by the feed); `TestResumePastDeadlineRefused`; `TestSuspendedTimeCountsToDeadline`.
-- [ ] **Implement.**
+**Interfaces (produces):**
+- `Drain(ctx, by, attemptID) (generation int64, error)`
+- `Quiescent(ctx, by, attemptID string, generation int64) error`
+- `Suspend(ctx, by, attemptID string, generation int64) error`
+- `Reopen(ctx, by, attemptID string, generation int64) error`
+- `Resume(ctx, by, attemptID, operationID string) (epoch int64, error)`
+- `ErrGenerationCancelled`, `ErrNotQuiescent`, `ErrPastDeadline`
+- `PauseAckTimeout = 2 * time.Minute` (controller time)
+
+`Resume` calls `Runner.Resume`, raises the epoch once per operation ID, bumps the feed (which revokes old-epoch credentials), and opens the exchange window (`exchange_open_until_t = now + ExchangeWindow`). The instance owns admission, which comes in slice 2.
+
+- [ ] **Red:**
+ - `TestSuspendNeedsCurrentAck`: no acknowledgement, an older generation, a future generation (current + 1) and a cancelled generation are each refused.
+ - `TestLateAckIgnored`: an acknowledgement at 2 min 1 s.
+ - `TestResumeRaisesEpochOnce`
+ - `TestResumeRevokesOldEpoch`
+ - `TestResumeOpensExchangeWindow`
+ - `TestResumePastDeadlineRefused`
+ - `TestSuspendedTimeCountsToDeadline`
- [ ] **Green:** `go test ./internal/hostedctl -run 'TestSuspend|TestLateAck|TestResume' -count=1`.
-- [ ] **Mutations:** compare generations with `>=`; `TestSuspendNeedsCurrentAck` fails. Raise the epoch on every Resume call; `TestResumeRaisesEpochOnce` fails. Restore.
+- [ ] **Mutations (register each):**
+ - Compare generations with `>=`: the future-generation row fails.
+ - Raise the epoch on every call: `TestResumeRaisesEpochOnce` fails.
- [ ] **Commit:** `hostedctl: pause generations and resume epochs`.
-### Task 15: Reaper, deadlines and the network audit loop
+### Task 17: Reaper, deadlines, credential lapse and network audit (certified guards)
**Files:** Create `internal/hostedctl/{reaper.go,reaper_test.go}`.
-**Interfaces (produces):** `(*Controller) Reap(ctx) (ReapReport, error)` with `ReapReport{Skipped bool; Replayed, Drained, Stopped, OrphansSeen, OrphansStopped int}`; `(*Controller) Loop(ctx, every time.Duration)` running `Replay`, `Refresh`, `Reap` and the network audit; `ReapInterval = 60 * time.Second`; `OrphanGrace = 10 * time.Minute`.
-
-Pass order: replay live intents; `List`, and skip on `ErrIncomplete`; for each listed VM without a job row, record `first_seen_at` (store time, Task 8) and, once `OrphanGrace` has passed, recheck ownership (replay again, re-read the table, `List` again) before `Stop`; mark jobs past `drain_at` as draining (visible in `JobView`); stop jobs past `stop_at`. A failing audit refuses launches until it passes and raises an alert (Task 18).
-
-- [ ] **Red:** `TestReapSkipsIncompleteList`; `TestReapReplaysIntentFirst` (a VM whose Ref is not yet saved is claimed by replay, not stopped); `TestReapStopsOrphanAfterTenMinutes` (9 min 59 s no, 10 min yes); `TestReapRechecksOwnership` (a job row appears between the two Lists; no stop); `TestReapDrainsThenStops` (7 h 15 and 7 h 50); `TestDeadlinesIgnoreClockRollback` (review focus 2); `TestFailingAuditBlocksLaunch`.
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/hostedctl -run 'TestReap|TestDeadlinesIgnore|TestFailingAudit' -count=1`.
-- [ ] **Mutations:** reap on an incomplete List; `TestReapSkipsIncompleteList` fails. Drop the recheck; `TestReapRechecksOwnership` fails. Use the raw clock; `TestDeadlinesIgnoreClockRollback` fails. Restore.
-- [ ] **Commit:** `hostedctl: leaked-VM reaper, deadlines and network audit loop`.
-
-### Task 16: Lifecycle simulation with invariants (spec §14)
+**Interfaces (produces):**
+- `Reap(ctx) (ReapReport, error)`, where `ReapReport{Skipped bool; Replayed, Drained, Stopped, OrphansSeen, OrphansStopped, Lapsed, Unknown int}`.
+- `Loop(ctx, every time.Duration)`.
+- `ReapInterval = 60 * time.Second`, `OrphanGrace = 10 * time.Minute`, `LapseGrace = 2 * time.Minute`.
+
+Each pass runs these steps in order:
+1. Checkpoint the clock.
+2. Replay live intents.
+3. Refresh live jobs.
+4. `List`. Skip the rest on `ErrIncomplete`.
+5. Handle orphans. Record `first_seen_t` for each. After `OrphanGrace`, recheck ownership: replay again, re-read the table and `List` again. Only then call `Stop`.
+6. Mark jobs past `drain_t` as draining.
+7. Stop jobs past `stop_t`.
+8. Stop each running, unsuspended job whose credential has lapsed, with reason `credential_lapsed`. Lapsed means more than `CredentialLifetime + LapseGrace` past `last_credential_t`, or past `exchange_open_until_t + LapseGrace` after a resume without an exchange (spec §10: a failed renewal stops the VM).
+9. Re-issue Stop for `unknown` states and alert after three passes.
+10. Run the network audit. A failure refuses launches until it passes and alerts.
+
+On controller start, each live job's lapse clock restarts at the start time. This is restore reconciliation, so VMs whose credentials expired during an outage get one exchange window before they are stopped (open question 3).
+
+- [ ] **Red:**
+ - `TestReapSkipsIncompleteList`
+ - `TestReapReplaysIntentFirst`
+ - `TestReapStopsOrphanAfterTenMinutes`: 9 min 59 s gives no stop; 10 min gives a stop.
+ - `TestReapRechecksOwnership`
+ - `TestReapDrainsThenStops`
+ - `TestReaperUnderRollback`: the wall clock goes back two hours mid-run, and the orphan is still stopped after 10 minutes of Mono time.
+ - `TestLapsedCredentialStopsVM`
+ - `TestNoExchangeAfterResumeStopsVM`
+ - `TestRestartGivesOneExchangeWindow`
+ - `TestUnknownStateRetriedAndAlerted`
+ - `TestFailingAuditBlocksLaunch`
+- [ ] **Green:** `go test ./internal/hostedctl -run 'TestReap|TestLapsed|TestNoExchange|TestRestartGives|TestUnknownStateRetried|TestFailingAudit' -count=1`.
+- [ ] **Mutations (register each):**
+ - Reap on an incomplete List: its test fails.
+ - Drop the recheck: `TestReapRechecksOwnership` fails.
+ - Skip the lapse stop: `TestLapsedCredentialStopsVM` fails.
+- [ ] **Commit:** `hostedctl: reaper, deadlines and credential lapse stops`.
+
+### Task 18: Lifecycle simulation with invariants (spec §14, certified guards)
**Files:** Create `internal/hostedctl/{sim_test.go,sim_model_test.go}`.
-**Interfaces:** Consumes Tasks 5, 11 to 15. Produces `TestLifecycleSimulation`, 200 seeds by default inside the 10 s budget, `EQUIPO_SIM_SEEDS=n` for longer runs; a failing seed prints its seed and step log.
-
-Operations, chosen at random per step: launch (fresh or replacement), concurrent duplicate launch, crash and reopen the controller, lost reply on Launch or Stop, throttle, incomplete List, drain, acknowledge (current, stale or late), suspend, resume (new or repeated operation ID), stop, redeem and renew a credential, a proxy authorisation check with a random held credential, plant an orphan, advance the clock by up to 9 h, reaper tick. The fake's own lifetime backstop is off, so the controller alone must hold the deadline.
-
-Invariants, checked after every step:
-
-| ID | Invariant | Mutation that must break it |
+**Interfaces:** Consumes Tasks 7 and 12 to 17. Produces `TestLifecycleSimulation`. It runs 200 seeds by default, inside the 10 s budget; `EQUIPO_SIM_SEEDS=n` runs longer. A failure prints its seed and step log.
+
+Each step picks one of these operations at random:
+- launch (fresh, replacement, or a concurrent duplicate);
+- crash and reopen, at any point, including between the provider call and transaction 2;
+- lost reply on Launch or Stop;
+- throttle;
+- incomplete List;
+- unknown state;
+- drain;
+- an acknowledgement (current, stale, future or late);
+- suspend;
+- resume (new or repeated operation ID);
+- redeem, challenge or exchange, with valid, replayed, wrong-VM or old-epoch inputs;
+- a feed authorisation check;
+- plant an orphan;
+- a wall-clock jump of up to 3 h either way;
+- advance Mono by up to 9 h;
+- a reaper tick;
+- stop.
+
+The fake's own lifetime backstop is off.
+
+| ID | Invariant (checked after every step) | Mutation that must break it |
| --- | --- | --- |
-| I1 | At most one live VM per attempt ID | Save the intent after the provider call |
-| I2 | No proxy authorisation succeeds for an epoch other than the current one, or for a stopped, stop-requested or suspended launch | Skip the epoch comparison in the feed |
-| I3 | No VM is live after its job's `stop_at` plus one reaper interval | Reap only at `deadline` |
-| I4 | A provider Suspend happens only with an acknowledgement for the current, uncancelled generation | Accept late acknowledgements |
-| I5 | Every listed VM is a job's Ref, a live intent's, or an orphan stopped within 10 min plus one interval | Stop orphans on first sight (breaks I1 via replay) or never (breaks I5) |
-| I6 | A replacement launches only after its predecessor's stop proof | Skip the Replaces check |
-| I7 | A proxy code is redeemed at most once, and only for its own VM | Skip the used-at check |
-
-- [ ] **Red:** write the model and invariants; run with the Task 12 to 15 code present. Each mutation in the table, applied alone, must fail within the default seeds.
+| I1 | At most one live VM per attempt ID | Drop the client token (launch with a fresh token each replay) |
+| I2 | Recoverable ownership: every VM the fake holds is a saved Ref, matches a stored intent's attempt, or is a planted orphan | Save the intent after the provider call |
+| I3 | No premature stop: no stop is ever issued for a VM with a job or intent, and no orphan is stopped before 10 min of controller time | Stop orphans on first sight; drop the ownership recheck |
+| I4 | No VM is live past its job's `stop_t` plus one reaper interval of Mono time | Reap only at `deadline_t`; use wall time |
+| I5 | A provider Suspend happens only with an acknowledgement for the current, uncancelled generation | Accept `>=` generations |
+| I6 | A replacement launches only after stop proof, and proof never comes from `unknown` | Treat `unknown` as terminal |
+| I7 | A feed authorisation succeeds only for the current epoch, a live state and the credential's own snapshot | Skip the epoch comparison |
+| I8 | A proxy code is redeemed at most once, only for its own VM; an exchange succeeds only with the registered VM key | Skip the used check; accept any key |
+| I9 | A running, unsuspended job with no credential issued for `CredentialLifetime + LapseGrace` is stopped within one interval | Skip the lapse stop |
+
+- [ ] **Red:** write the model and invariants. Apply each mutation in the table alone. Each must fail within the default seeds. Record which seed caught it.
- [ ] **Green:** `go test ./internal/hostedctl -run TestLifecycleSimulation -count=1`, then once with `EQUIPO_SIM_SEEDS=5000`.
-- [ ] **Commit:** `hostedctl: randomised lifecycle simulation with invariants`.
+- [ ] **Commit:** `hostedctl: randomised lifecycle simulation with nine invariants`.
-Slice 2 extends this model with the instance's two invariants: nothing starts while draining, and only one attempt publishes.
+Slice 2 adds the instance's two invariants: nothing starts while draining, and only one attempt publishes.
-### Task 17: Controller HTTP API and command
+### Task 19: Controller HTTP API and command
-**Files:** Create `internal/hostedctl/{http.go,http_test.go}`, `cmd/equipo-hosted-controller/{main.go,config.go,config_test.go}`.
+**Files:** Create `internal/hostedctl/{http.go,http_test.go}` and `cmd/equipo-hosted-controller/{main.go,config.go,config_test.go}`.
-**Interfaces:** Consumes Tasks 7 to 15 and `awsjob`. Produces routes (JSON, strict decoding, `hostedwire.MaxBody`, every response signed):
+**Interfaces:** Consumes Tasks 9 and 12 to 17, plus `awsjob` in `main` only. Routes take strict JSON, enforce `MaxBody` and sign every response:
-| Route | Role |
+| Route | Callers |
| --- | --- |
| `POST /v1/jobs` | instance (job), operator (certification) |
-| `GET /v1/jobs/{attempt}` | instance, operator |
-| `POST /v1/jobs/{attempt}/stop`, `/drain`, `/quiescent`, `/suspend`, `/reopen`, `/resume` | instance |
-| `GET /v1/vms` | operator |
-| `PUT /v1/certificates/{image}`, `GET /v1/certifications/{attempt}/report` | operator |
-| `GET /v1/feed?after=n` (long poll, 25 s) | proxy |
-| `POST /v1/credentials/redeem`, `/renew`, `POST /v1/certification/report` | proxy, forwarding for a VM |
-
-An instance key may act only on jobs it created. Configuration comes from a file named by `-config`: listen address (required, no default), TLS certificate and key, database path, CA key path, signing key path, verify keys with roles, certificate keys, service names, policy version, region and network IDs. `Enabled` comes only from `EQUIPO_HOSTED_ENABLED=1`.
-
-- [ ] **Red:** `TestRoutesEnforceRoles` (each route with each wrong role is 403 and audited); `TestInstanceKeySeesOnlyItsJobs`; `TestUnknownFieldsRefused`; `TestResponsesSigned`; `TestConfigRefusesMissingListenOrKeys`; `TestDisabledRefusesLaunchButServesStop` (stop and get keep working with the flag off, so a switched-off controller can still clean up).
-- [ ] **Implement.** `main` wires `awsjob` only here.
-- [ ] **Green:** `go test ./internal/hostedctl ./cmd/equipo-hosted-controller -run 'TestRoutes|TestInstanceKey|TestUnknownFields|TestResponsesSigned|TestConfig|TestDisabled' -count=1`; `make build vet`.
-- [ ] **Mutations:** drop the role check on `/stop`; `TestRoutesEnforceRoles` fails. Drop the creator check; `TestInstanceKeySeesOnlyItsJobs` fails. Restore.
+| `GET /v1/jobs/{attempt}`, `POST /v1/jobs/{attempt}/stop` | the creating instance; the creating operator for certification launches |
+| `POST /v1/jobs/{attempt}/drain`, `/quiescent`, `/suspend`, `/reopen`, `/resume` | the creating instance |
+| `GET /v1/vms`, `PUT /v1/certificates/{image}`, `GET /v1/reports/{launch}` | operator |
+| `GET /v1/feed?after=n` | proxy |
+| `POST /v1/vm/redeem`, `/v1/vm/challenge`, `/v1/vm/exchange` | proxy, forwarding unchanged bodies from its bootstrap listener; the controller does all verification |
+| `POST /v1/vm/report` | proxy, forwarding with the authenticated Identity from the egress listener; accepted only for a live certification launch; the controller records Provenance |
+
+Configuration comes from the file named by `-config`:
+- the listen address (required, no default);
+- TLS files;
+- the database, CA and signing key paths;
+- verify keys with roles and, for instance keys, `InstanceHost`;
+- certification public keys;
+- gateway, mirror and report host;
+- the policy version;
+- region and network IDs.
+
+`Enabled` comes only from `EQUIPO_HOSTED_ENABLED=1`.
+
+- [ ] **Red:**
+ - `TestRoutesEnforceRoles`: each route with each wrong role returns 403 and is audited.
+ - `TestInstanceKeySeesOnlyItsJobs`
+ - `TestOperatorStopsOwnCertificationLaunch`
+ - `TestReportOnlyFromCertificationLaunch`
+ - `TestReportProvenanceFromIdentity`: VM-supplied provenance fields are ignored.
+ - `TestUnknownFieldsRefused`
+ - `TestResponsesSigned`
+ - `TestConfigRefusesMissingListenOrKeys`
+ - `TestDisabledRefusesLaunchButServesStop`
+- [ ] **Green:**
+ - `go test ./internal/hostedctl ./cmd/equipo-hosted-controller -run 'TestRoutes|TestInstanceKey|TestOperatorStops|TestReport|TestUnknownFields|TestResponsesSigned|TestConfig|TestDisabled' -count=1`
+ - `make build vet`
+- [ ] **Mutations:**
+ - Drop the creator check: `TestInstanceKeySeesOnlyItsJobs` fails.
+ - Take provenance from the body: `TestReportProvenanceFromIdentity` fails.
- [ ] **Commit:** `hosted controller: signed HTTPS API and command`.
-### Task 18: Metrics and alerts
-
-**Files:** Create `internal/hostedctl/{metrics.go,alerts.go,metrics_test.go}`, `internal/isolatedjob/awsjob/alerts.go`.
+### Task 20: Metrics and alerts
-**Interfaces (produces):** `Alerter interface{ Alert(ctx context.Context, a Alert) error }`, `Alert{Kind, Detail string; At time.Time}`, kinds `leaked_vm`, `network_audit_failed` (covers VPC DNS switched on), `no_healthy_proxy` (no proxy has polled the feed for 2 minutes); `MetricsHandler()` serving text counters on a separate listener (loopback in tests): jobs by state, launches, launch errors by kind, orphans stopped, credential renewals and failures, audit status. `awsjob.SNSAlerter` publishes to one topic. Daily-spend alerts and VM-hour cost wait for slice 3.
+**Files:** Create `internal/hostedctl/{metrics.go,alerts.go,metrics_test.go}` and `internal/isolatedjob/awsjob/alerts.go`.
-- [ ] **Red:** `TestOrphanStopRaisesLeakAlert`; `TestAuditFailureAlertsOnce` (not every tick); `TestNoHealthyProxyAlert`; `TestMetricsCountJobsByState`; `TestAlertCarriesNoSecrets` (no code, credential or bootstrap bytes in Detail).
-- [ ] **Implement.**
+**Interfaces (produces):**
+- Implementations of Task 12's `Alerter`: a deduplicating wrapper and `awsjob.SNSAlerter`.
+- Alert kinds:
+ - `leaked_vm`
+ - `network_audit_failed` (covers VPC DNS switched on)
+ - `no_healthy_proxy` (no proxy has polled the feed for 2 minutes)
+ - `clock_rollback`
+ - `unknown_state`
+ - `credential_lapsed`
+- `MetricsHandler()` serves on a separate listener. It counts jobs by state, launches, launch errors by kind, orphans stopped, credential issues and lapses, and audit status.
+- `awsjob.SNSAlerter`.
+
+Daily-spend alerts wait for slice 3.
+
+- [ ] **Red:**
+ - `TestOrphanStopRaisesLeakAlert`
+ - `TestAuditFailureAlertsOnce`
+ - `TestNoHealthyProxyAlert`
+ - `TestMetricsCountJobsByState`
+ - `TestAlertCarriesNoSecrets`
- [ ] **Green:** `go test ./internal/hostedctl -run 'TestOrphanStopRaises|TestAuditFailureAlerts|TestNoHealthyProxy|TestMetrics|TestAlertCarries' -count=1`.
-- [ ] **Mutation:** alert on every failing tick; `TestAuditFailureAlertsOnce` fails. Restore.
-- [ ] **Commit:** `hostedctl: lifecycle metrics and leak, audit and proxy alerts`.
+- [ ] **Mutation:** alert on every failing tick. `TestAuditFailureAlertsOnce` fails. Restore.
+- [ ] **Commit:** `hostedctl: lifecycle metrics and alerts`.
-### Task 19: Instance-side controller client (flag off, no callers)
+### Task 21: Instance-side controller client (flag off, no callers)
**Files:** Create `internal/hostedclient/{client.go,client_test.go}`.
-**Interfaces (produces):** `New(cfg Config) (*Client, error)` where `Config{BaseURL string; KeyID hostedwire.KeyID; Key ed25519.PrivateKey; ControllerKey ed25519.PublicKey; HTTP *http.Client}`; refuses unless `EQUIPO_HOSTED_RUNNERS=1`; methods `Launch`, `Get`, `Stop`, `Drain`, `Quiescent`, `Suspend`, `Reopen`, `Resume` with the Task 17 request and response types, each verifying the response signature against its own request nonce.
+**Interfaces (produces):** `New(cfg Config) (*Client, error)`, where `Config{BaseURL string; KeyID hostedwire.KeyID; Key ed25519.PrivateKey; ControllerKey ed25519.PublicKey; HTTP *http.Client}`. `New` refuses unless `EQUIPO_HOSTED_RUNNERS=1`. Methods mirror the instance routes and verify every response against their own request nonce.
-- [ ] **Red:** `TestClientAgainstController` (an `httptest` TLS server with the real handler, fake runner and test certificate: launch, get, stop with proof); `TestClientRefusesUnsignedResponse`; `TestClientRefusesWithoutFlag`; `TestInstanceDoesNotCallHostedClient` (`go list -deps ./cmd/equipo` has no `internal/hostedclient` in this slice; slice 2 deletes this test when it wires the client).
-- [ ] **Implement.**
+- [ ] **Red:**
+ - `TestClientAgainstController`: real handler over `httptest` TLS, with the fake runner.
+ - `TestClientRefusesUnsignedResponse`
+ - `TestClientRefusesWithoutFlag`
+ - `TestInstanceDoesNotCallHostedClient`: `go list -deps ./cmd/equipo` has no `internal/hostedclient`. Slice 2 deletes this test.
- [ ] **Green:** `go test ./internal/hostedclient -count=1`.
-- [ ] **Mutation:** skip response verification; `TestClientRefusesUnsignedResponse` fails. Restore.
+- [ ] **Mutation:** skip response verification. Its test fails. Restore.
- [ ] **Commit:** `hostedclient: signed controller client behind a flag`.
---
## Phase D: the egress stack (spec §6)
-### Task 20: Proxy listener, client authentication and the launch-state feed
+### Task 22: Proxy core: two listeners, feed and per-launch rules (certified guards)
-**Files:** Create `internal/egressproxy/{server.go,auth.go,feed.go,auth_test.go,feed_test.go}`.
+**Files:** Create `internal/egressproxy/{server.go,bootstrap.go,feed.go,tunnel.go,server_test.go,bootstrap_test.go,feed_test.go}`.
-**Interfaces:** Consumes `egresspolicy` and `hostedwire` (including `ParseIdentity`), never `hostedctl`. Produces:
+**Interfaces:** Consumes Tasks 9, 10 and 15. Never imports `hostedctl`. Produces:
```go
type Server struct {
- Rules *egresspolicy.Rules
- ClientCA *x509.CertPool // the controller CA
- InterceptCA *ecdsa.PrivateKey // signs per-host leaves; trusted only by the runner's dialer
Feed *Feed
- Upstream Upstream // Task 22
+ ClientRoots *x509.CertPool // controller CA
+ ServerCert tls.Certificate // from the proxy root pinned in the image
+ InterceptCA crypto.Signer // per-host leaves; root pinned in the image
+ Upstream Upstream // Task 24; a direct test dialer until then
Log DecisionLog
Now func() time.Time
}
-func (*Server) Serve(ctx context.Context, l net.Listener) error // TLS 1.3, client certificate required
-type Feed struct{ /* polls GET /v1/feed with a proxy key; holds launch state */ }
-func (*Feed) Allow(id hostedwire.Identity) (Launch, error) // denies everything when the last good poll is older than 30 s
+func (*Server) ServeEgress(ctx context.Context, l net.Listener) error // TLS 1.3, client certificate required
+func (*Server) ServeBootstrap(ctx context.Context, l net.Listener) error // TLS 1.3, server-authenticated only
+type Feed struct{ /* polls GET /v1/feed with a proxy key; verifies the controller signature; compiles Rules per snapshot digest */ }
+func (*Feed) Authorise(id hostedwire.Identity) (*egresspolicy.Rules, error)
+const FeedGrace = 15 * time.Minute // open question 3
```
-The proxy also serves two local, unauthenticated-by-certificate routes that forward to the controller: `POST /v1/credentials/redeem` (body carries the bootstrap proxy code) and, with a valid certificate, `POST /v1/credentials/renew`.
+The two listeners divide the work:
+- **The bootstrap listener** accepts exactly three routes: `POST /v1/vm/redeem`, `/v1/vm/challenge` and `/v1/vm/exchange`. Each body is size-checked and its shape validated, then forwarded unchanged to the controller with the proxy's signature. Authority for each route comes from the controller's checks in Task 15: the code, or the VM-key proof. Each launch ID is rate-limited.
+- **The egress listener** authorises every connection, and every request, against the authenticated identity's own snapshot rules. In this task it supports a minimal CONNECT-and-tunnel path, so Tasks 23 and 24 have something to extend.
+
+`Authorise` refuses in each of these cases: the epoch differs from the feed's; the VM differs; the state is not live; stop is requested; or the last good poll is older than `FeedGrace`.
-- [ ] **Red:** `TestProxyRefusesClientCerts` table: none, expired, other CA, unparseable identity, an epoch below the feed's, a stopped or stop-requested launch, a VM ref that differs from the feed's (a certificate replayed from another VM); `TestStaleFeedDeniesAll`; `TestFeedVerifiesControllerSignature`; `TestRedeemForwardsOnlyTheRedeemShape`.
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/egressproxy -run 'TestProxyRefusesClientCerts|TestStaleFeed|TestFeedVerifies|TestRedeemForwards' -count=1`.
-- [ ] **Mutations:** skip the epoch comparison; its row fails. Ignore feed age; `TestStaleFeedDeniesAll` fails. Restore.
-- [ ] **Commit:** `egressproxy: certificate-bound clients and launch-state feed`.
+- [ ] **Red:**
+ - `TestEgressRefusesClientCerts`, a table: no certificate; expired; another CA; an unparseable identity; an old epoch; a stopped or stop-requested launch; another VM's certificate.
+ - `TestBootstrapListenerNeedsNoClientCert`
+ - `TestBootstrapForwardsOnlyThreeShapes`
+ - `TestRequestsUseOwnSnapshot`: launches A and B with different instance hosts; A cannot reach B's host even though B is live.
+ - `TestFeedGraceThenDeny`: the controller goes away, a live launch keeps working until 15 minutes, then is denied.
+ - `TestFeedVerifiesControllerSignature`
+- [ ] **Green:** `go test ./internal/egressproxy -run 'TestEgressRefuses|TestBootstrap|TestRequestsUseOwnSnapshot|TestFeedGrace|TestFeedVerifies' -count=1`.
+- [ ] **Mutations (register each):**
+ - Skip the epoch check: its row fails.
+ - Use one rule set for all launches: `TestRequestsUseOwnSnapshot` fails.
+ - Ignore feed age: `TestFeedGraceThenDeny` fails.
+- [ ] **Commit:** `egressproxy: bootstrap and egress listeners with per-launch rules`.
-### Task 21: Revocation of open tunnels
+### Task 23: Revocation of open tunnels (certified guards)
-**Files:** Modify `internal/egressproxy/server.go`; create `internal/egressproxy/revoke_test.go`.
+**Files:** Modify `internal/egressproxy/tunnel.go`. Create `internal/egressproxy/revoke_test.go`.
-**Interfaces:** Produces `(*Server) revoke(launchID string)` driven by feed changes; every open tunnel is registered by launch and epoch.
+**Interfaces:** Produces a tunnel registry keyed by launch and epoch. Feed changes close affected tunnels.
-- [ ] **Red:** `TestRevocationClosesOpenTunnels` (review focus 3: an open WebSocket through the proxy is closed within one feed poll of stop, and of an epoch change); `TestUnrelatedTunnelsSurvive`.
-- [ ] **Implement.**
+- [ ] **Red:** `TestRevocationClosesOpenTunnels` (review focus 3): stop, and separately an epoch change, each close an open tunnel within one feed poll. `TestUnrelatedTunnelsSurvive`.
- [ ] **Green:** `go test ./internal/egressproxy -run 'TestRevocation|TestUnrelated' -count=1`.
-- [ ] **Mutation:** check revocation only on new requests; `TestRevocationClosesOpenTunnels` fails. Restore.
+- [ ] **Mutation (register):** check only new connections. `TestRevocationClosesOpenTunnels` fails. Restore.
- [ ] **Commit:** `egressproxy: close open tunnels on stop and epoch change`.
-### Task 22: CONNECT inspection, origin TLS and decision logs
+### Task 24: CONNECT inspection, origin TLS and decision logs (certified guards)
-**Files:** Create `internal/egressproxy/{connect.go,inspect.go,upstream.go,log.go,inspect_test.go,log_test.go}`.
+**Files:** Create `internal/egressproxy/{inspect.go,upstream.go,log.go,inspect_test.go,log_test.go}`. Modify `tunnel.go`.
-**Interfaces (produces):** `Upstream interface{ Dial(ctx context.Context, host string) (net.Conn, error) }` with `NewUpstream(resolver string /*DNS-over-TLS address*/, roots *x509.CertPool)`: resolves upstream names itself (VPC DNS is off) and refuses an answer in private, loopback, link-local (including 169.254.169.254) or IPv6 unique-local ranges; `DecisionLog` writes JSON lines `{at, vm, task, attempt, launch, host, method, path_class, decision, reason, bytes_up, bytes_down}`, never headers, query strings, bodies or credentials.
-
-Per connection: the CONNECT target must be an exact compiled host on port 443 (no IP literal, no other port); the proxy terminates the inner TLS with a leaf for that host from `InterceptCA`; SNI must be present and equal the CONNECT host; a ClientHello with the encrypted ClientHello extension (`0xfe0d`) is refused. Per request (HTTP/1.1 or HTTP/2): Host or `:authority` must equal the CONNECT host after normalisation (an explicit `:443` is allowed, nothing else); an absolute-form target with another authority, userinfo, a `CONNECT` method, an `Upgrade: h2c`, or a WebSocket upgrade outside the stream class is refused; `Rules.Decide` must allow method and path. The proxy then opens TLS to the exact host and validates its certificate against system roots. A 3xx response whose `Location` names another host is replaced with 502 and logged `redirect_refused`.
-
-- [ ] **Red:** `TestProxyInspection` table with an in-process origin: allowed `GET /healthz`; allowed runner stream WebSocket; SNI differs; SNI missing; ECH extension present; Host differs; HTTP/2 `:authority` differs; IP literal CONNECT (IPv4 and IPv6); port 8443; CONNECT to each denied registry; userinfo authority; `%2e%2e` path; `%2F` path; nested CONNECT; `h2c` upgrade; WebSocket on `/healthz`; `PUT` to mirror while mirror is `none`; redirect to another host; origin resolving to 169.254.169.254; report route from a job launch. `TestProxyAuthorityNormalisation` (review focus 4). `TestDecisionLogCarriesNoSecrets` (a request with `Authorization`, a query token and a body: none appears in the log; byte counts do).
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/egressproxy -run 'TestProxyInspection|TestProxyAuthority|TestDecisionLog' -count=1`.
-- [ ] **Mutations, one at a time:** drop the SNI comparison; drop the Host comparison; allow the ECH extension; follow cross-host redirects; allow private upstream answers. Each makes its row fail. Restore.
+**Interfaces (produces):**
+- `NewUpstream(resolvers []netip.AddrPort, resolverName string, roots *x509.CertPool) Upstream` resolves over DNS over TLS to the pinned addresses and TLS name only, with no fallback (Astra's view on open question 8). It refuses answers in private, loopback, link-local (including 169.254.169.254) and unique-local ranges.
+- `DecisionLog` writes JSON lines: `{at, vm, task, attempt, launch, host, method, path_class, decision, reason, bytes_up, bytes_down}`. It never writes headers, query strings, bodies or credentials.
+- Refusals return status 403 with the header `Equipo-Egress-Refusal: <reason>`, so a probe can tell a policy refusal from a network failure.
+
+Per connection:
+- The CONNECT target must be an exact host from the launch's rules, on port 443.
+- The proxy terminates the inner TLS with a leaf signed by `InterceptCA`.
+- SNI must be present and equal the CONNECT host.
+- A ClientHello carrying the encrypted ClientHello extension (`0xfe0d`) is refused.
+
+Per request:
+- Host or `:authority` must equal the CONNECT host, allowing an explicit `:443`.
+- These are refused: an absolute-form target naming another authority; userinfo; `CONNECT`; `Upgrade: h2c`; a WebSocket outside the stream class.
+- The launch's `Rules.Decide` must allow the request.
+- The report class is never tunnelled to an origin. The proxy terminates it and forwards the body to the controller's `POST /v1/vm/report`, with its proxy signature and the authenticated `Identity`.
+
+Origin TLS goes to the exact host and validates against system roots. A 3xx response whose `Location` names another host becomes 502, logged as `redirect_refused`.
+
+- [ ] **Red:**
+ - `TestProxyInspection`, a table:
+ - allowed `/healthz`;
+ - allowed stream WebSocket;
+ - SNI differs;
+ - SNI missing;
+ - ECH;
+ - Host differs;
+ - HTTP/2 `:authority` differs;
+ - IPv4 and IPv6 literal CONNECT;
+ - port 8443;
+ - each of the six denied names;
+ - userinfo;
+ - `%2e%2e`;
+ - `%2F`;
+ - nested CONNECT;
+ - h2c;
+ - WebSocket on `/healthz`;
+ - mirror `PUT` and `GET` while the mirror is `none`;
+ - cross-host redirect;
+ - an origin resolving to 169.254.169.254;
+ - the report route from a job launch.
+ - `TestProxyAuthorityNormalisation` (review focus 4).
+ - `TestUpstreamResolverPinned`: a wrong TLS name, or an unreachable pinned resolver, fails with no fallback.
+ - `TestDecisionLogCarriesNoSecrets`.
+- [ ] **Green:** `go test ./internal/egressproxy -run 'TestProxyInspection|TestProxyAuthority|TestUpstreamResolver|TestDecisionLog' -count=1`.
+- [ ] **Mutations (register each):** dropping the SNI comparison, the Host comparison, the ECH refusal, the cross-host redirect refusal or the private-answer refusal each make its row fail. Restore each.
- [ ] **Commit:** `egressproxy: CONNECT inspection, origin TLS and decision log`.
-### Task 23: Exact-name resolver
+### Task 25: Per-launch resolver (certified guards)
+
+The VMs share one source address, so a plain DNS query cannot say which launch it came from.
**Files:** Create `internal/egressdns/{server.go,server_test.go}`. Modify `go.mod` (`golang.org/x/net`).
-**Interfaces (produces):** `Server{Names func() []string; Answer []netip.Addr; Log DecisionLog}`; `(*Server) ServeUDP(ctx, net.PacketConn) error`, `ServeTCP(ctx, net.Listener) error`. `Names` is `Rules.Hosts` for every live launch purpose in the feed. Known name and type A: the proxies' IPv4 addresses. Known name, other type: no data. Unknown name: NXDOMAIN. Recursion-available is always off; ANY, AXFR and more than one question are refused.
+**Interfaces (produces):** `Server{Feed *egressproxy.Feed; Answer []netip.Addr; Log DecisionLog}` with:
+- `ServePlain(ctx, net.PacketConn, net.Listener) error`: answers every name NXDOMAIN, with recursion-available off.
+- `ServeTLS(ctx, net.Listener) error`: DNS over TLS on 853, client certificate required. Answers the authenticated launch's snapshot hosts with the proxy addresses for type A; other types for known names get no data; unknown names get NXDOMAIN. ANY, AXFR and multiple questions are refused.
-- [ ] **Red:** `TestResolverAnswers` table; `TestResolverNameNormalisation` (review focus 4: case and trailing dot match, `instance.example.evil` and `xinstance.example` do not); `TestResolverNeverRecurses`; `TestResolverRefusesMultipleQuestions`.
-- [ ] **Implement** with `golang.org/x/net/dns/dnsmessage`.
-- [ ] **Green:** `go test ./internal/egressdns -count=1`; `make govulncheck`.
-- [ ] **Mutation:** suffix-match names; `TestResolverNameNormalisation` fails. Restore.
-- [ ] **Commit:** `egressdns: resolver that answers only launch service names`.
+Spec §6 says "answers only the launch record's exact service names". Answering by authenticated launch is the only way to keep that exact while VMs share a source address.
-### Task 24: Proxy command and the trusted-side dialer
+- [ ] **Red:**
+ - `TestPlainResolverAnswersNothing`
+ - `TestTLSResolverAnswersOwnSnapshot`: A cannot resolve B's instance host.
+ - `TestResolverNameNormalisation`
+ - `TestResolverNeverRecurses`
+ - `TestResolverRefusesStaleOrRevoked`
+- [ ] **Green:** `go test ./internal/egressdns -count=1`, then `make govulncheck`.
+- [ ] **Mutations (register each):**
+ - Answer the union of all launches: `TestTLSResolverAnswersOwnSnapshot` fails.
+ - Answer plain queries: `TestPlainResolverAnswersNothing` fails.
+- [ ] **Commit:** `egressdns: resolver answering only the caller's launch names`.
-**Files:** Create `cmd/equipo-egress-proxy/{main.go,config_test.go}`, `internal/egressproxy/client/{dialer.go,credential.go,dialer_test.go}`.
+### Task 26: Proxy command, dialer and VM credential manager
-**Interfaces (produces):** the command serves the proxy, the resolver (UDP and TCP 53) and metrics, each on an explicit configured address. `client.Dialer{Proxies []string; Credential *Credential; ProxyRoots, InterceptRoots *x509.CertPool}` with `DialContext(ctx, network, addr string) (net.Conn, error)` (tries each proxy in order) and `HTTPClient() *http.Client`. `client.Credential` generates an Ed25519 key in memory, redeems the bootstrap code, renews at half the lifetime, and swaps atomically. This package must build for darwin and linux, since slice 2 wires it into the runner.
+**Files:** Create `cmd/equipo-egress-proxy/{main.go,config_test.go}` and `internal/egressproxy/client/{dialer.go,credential.go,dialer_test.go,credential_test.go}`. The client package builds for darwin and linux, because slice 2 wires it into the runner.
-- [ ] **Red:** `TestDialerFailsOverToSecondProxy`; `TestDialerTrustsInterceptRootsOnlyThroughProxy`; `TestCredentialRenewsAtHalfLife`; `TestRenewFailureStopsUse` (a failed renewal past expiry returns an error, never a stale credential, as spec §10 requires); `TestProxyConfigRefusesWildcardListen` (`0.0.0.0`, `::`, `:port`).
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/egressproxy/... ./cmd/equipo-egress-proxy -count=1`; `make build vet` (darwin vet includes `internal/egressproxy/client` once slice 2 imports it from the runner).
-- [ ] **Mutation:** use a credential past expiry; `TestRenewFailureStopsUse` fails. Restore.
-- [ ] **Commit:** `egress proxy command and trusted-side dialer`.
+**Interfaces (produces):**
+- `client.Dialer{Proxies []string; Credential *Credential; ProxyRoots, InterceptRoots *x509.CertPool}`, with `DialContext` (tries each proxy in turn) and `HTTPClient()`.
+- `client.Credential`:
+ - `NewCredential(bootstrap hostedwire.Bootstrap, vmRef string, bootstrapURLs []string, roots *x509.CertPool) (*Credential, error)` generates the VM key in memory.
+ - `Start(ctx) error` redeems, then renews through challenge and exchange at half the lifetime.
+ - `Rotate(ctx) error` runs the exchange after a resume.
+ - `Current() (*tls.Certificate, error)` returns an error once the credential has expired. It never returns a stale credential.
+
+The command serves the egress listener, the bootstrap listener, plain and TLS DNS, and metrics, each on an explicit configured address.
+
+- [ ] **Red:**
+ - `TestDialerFailsOverToSecondProxy`
+ - `TestCredentialRenewsAtHalfLife`
+ - `TestRotateUsesVMKey`
+ - `TestExpiredCredentialNeverUsed`
+ - `TestProxyConfigRefusesWildcardListen`: `0.0.0.0`, `::` and a bare `:port`.
+- [ ] **Green:** `go test ./internal/egressproxy/... ./cmd/equipo-egress-proxy -count=1`, then `GOOS=darwin GOARCH=arm64 go vet ./internal/egressproxy/client`.
+- [ ] **Mutation:** return the last credential after expiry. `TestExpiredCredentialNeverUsed` fails. Restore.
+- [ ] **Commit:** `egress proxy command, dialer and VM credential manager`.
---
-## Phase E: the image (spec §4, §7)
+## Phase E: the VM side and the end-to-end foundation test
-### Task 25: Root init and lifecycle hooks
+### Task 27: Root init and lifecycle hooks (certified guards)
-**Files:** Create `cmd/equipo-vm-init/main.go`, `internal/vminit/{init_linux.go,hooks.go,drop_linux.go,init_test.go}`, `internal/isolatedjob/awsjob/vmhooks/{hooks.go,hooks_test.go}`.
+**Files:** Create `cmd/equipo-vm-init/main.go`, `internal/vminit/{init_linux.go,hooks.go,drop_linux.go,control.go,init_test.go}` and `internal/isolatedjob/awsjob/vmhooks/{hooks.go,hooks_test.go}`.
-**Interfaces (produces):** `vminit.Hooks interface{ Ready(ctx) error; Run(ctx, payload []byte) error; Resume(ctx) error }`; `vminit.New(sys Sys, cfg Config) (*Init, error)` where `Sys` wraps mount, chown, prctl and exec so tests inject it; `Config{ResolverAddr netip.Addr; RunnerUser string /*"equipo"*/; StateDir string /*"/var/lib/equipo-runner"*/; RunnerPath string}`. `vmhooks.Serve(ctx, h vminit.Hooks)` maps the provider's hook transport (recorded in Task 6) to `Hooks`; it is the only provider-specific code in the image.
+**Interfaces (produces):**
+- `vminit.Hooks interface{ Ready(ctx) error; Run(ctx, payload []byte) error; Resume(ctx) error }`.
+- `vminit.New(sys Sys, cfg Config) (*Init, error)`. `Sys` wraps mount, chown, prctl and exec.
+- `Config{Resolver netip.Addr; User string /*"equipo"*/; StateDir string; ProbePath string}`.
+- `vmhooks.Serve(ctx, h vminit.Hooks)` uses the transport recorded in Task 4. It is the only provider-specific code in the image.
+
+As root, init does the following:
+1. Bind-mounts generated `/etc/resolv.conf` (the plain resolver, which answers nothing) and `/etc/hosts` over the managed mounts, then remounts them read-only.
+2. Becomes the child subreaper.
+3. Creates the empty state directory, owned by the runner user.
+
+The hooks:
+- **`Ready`** fails if anything exists in the state directory, or if any machine key, token, SSH host key or `.aws` directory exists.
+- **`Run`**:
+ 1. Validates the `hostedwire.Bootstrap` payload and its size.
+ 2. Generates the machine ID and random seed.
+ 3. Writes the payload to `/run/equipo/bootstrap.json` (mode 0400, runner user).
+ 4. Learns the VM ID by the method recorded in Task 4.
+ 5. For a job launch, starts `equipo-vm-probe serve` through `equipo-vm-init drop`, which sets no-new-privileges, clears the bounding and ambient capability sets, sets the user's IDs and execs.
+ 6. For a certification launch, starts `equipo-vm-probe certify` as root. The harness drops its own privileges after the root rows (Task 34).
+- **`Resume`** writes `rotate` to the probe's control socket (`/run/equipo/control`, mode 0600, probe user) and waits up to 30 s for the probe's acknowledgement. Slice 2 points the same socket at the runner.
+
+- [ ] **Red:**
+ - `TestInitReplacesResolverMounts`
+ - `TestReadyRefusesState`: one row per forbidden item.
+ - `TestRunWritesBootstrapForProbeOnly`
+ - `TestRunRefusesOversizePayload`
+ - `TestDropClearsCapabilities`: the recorded calls must appear in order.
+ - `TestCertificationStartsAsRoot`
+ - `TestResumeSignalsRotation`
+ - `TestHooksTransport`
+- [ ] **Green:** `go test ./internal/vminit ./internal/isolatedjob/awsjob/vmhooks -count=1`, then `make build`.
+- [ ] **Mutations (register each):**
+ - Skip the read-only remount: `TestInitReplacesResolverMounts` fails.
+ - Skip the bounding-set clear: `TestDropClearsCapabilities` fails.
+- [ ] **Commit:** `vm init: resolver mounts, reaping, privilege drop and hooks`.
+
+### Task 28: Foundation probe, the runner's stand-in for slice 1
+
+The runner has no hosted bootstrap reader or rotation handler yet. Slice 2 adds both. Until then, this probe is the trusted in-VM process.
+
+**Files:** Create `cmd/equipo-vm-probe/main.go` and `internal/vmprobe/{serve.go,serve_test.go}`.
+
+**Interfaces:** Consumes Tasks 26 and 27. `vmprobe.Serve(ctx, cfg Config) error`:
+1. Reads the bootstrap.
+2. Starts the `Credential`.
+3. Calls `GET /healthz` on the snapshot's instance host through the dialer every 30 s.
+4. Handles `rotate` from the control socket by calling `Credential.Rotate` and acknowledging.
+5. Exits non-zero when `Current()` errors.
+
+- [ ] **Red:** `TestProbeRotatesOnSignal`, `TestProbeExitsOnLapse`, `TestProbeNeverReadsOtherFiles`. The last runs the probe under an `os.DirFS` jail with only the bootstrap file.
+- [ ] **Green:** `go test ./internal/vmprobe -count=1`.
+- [ ] **Commit:** `vm probe: trusted stand-in for the runner in slice 1`.
+
+### Task 29: End-to-end foundation test through real handlers and TLS (certified guards)
+
+**Files:** Create `internal/hostedtest/{rig_test.go,foundation_test.go}`.
+
+**Interfaces:** Consumes every earlier task. The rig runs these in one process on `127.0.0.1`, with real TLS listeners and test CAs:
+- the controller HTTP handler, with the fake runner and its own store;
+- the proxy's egress and bootstrap listeners;
+- the TLS resolver;
+- an instance stub (`/healthz`) for each of two instance hosts;
+- `vminit` with a recording `Sys`, whose `Run` and `Resume` hooks drive an in-process probe.
+
+- [ ] **Red:** `TestFoundationEndToEnd` subtests:
+ - `BootstrapThenEgress`: launch, Run hook, the probe redeems over the bootstrap listener without a client certificate, then reaches its instance over mTLS through CONNECT.
+ - `ReplayedCodeAndWrongVM`: both refused.
+ - `SuspendResumeExchange`: drain, quiescent, suspend, resume. The Resume hook leads to a VM-key exchange. The new epoch works, the old certificate is refused, and the open tunnel is cut.
+ - `RenewalFailureStopsVM`: the challenge route is blocked at the proxy. The probe's credential lapses, the probe exits, and the reaper stops the VM with `credential_lapsed` and proof.
+ - `OperatorCertificationLaunch`: an operator launches a certification VM, the report is accepted with provenance, and the operator stops it with proof. An instance key cannot stop it.
+ - `ControllerOutage`: with the controller stopped, the tunnel keeps working inside `FeedGrace` and is refused after it. Restart grants one exchange window.
+ - `TwoInstancesIsolated`: launches for two instance keys each reach and resolve only their own host.
+- [ ] **Green:** `go test ./internal/hostedtest -count=1`, inside the 10 s budget.
+- [ ] **Mutations (register each):** forward client-certificate-only routes on the bootstrap listener, or skip the exchange on resume. The matching subtest fails.
+- [ ] **Commit:** `hostedtest: end-to-end foundation flows over real TLS`.
-Init, as root: bind-mounts generated `/etc/resolv.conf` (one nameserver, the resolver) and `/etc/hosts` over the managed mounts and remounts them read-only; becomes child subreaper and reaps; creates the empty state directory owned by the runner user. `Ready` fails if the state directory holds anything, or if any machine key, token, SSH host key or `.aws` directory exists. `Run` validates the payload (Task 11 `Bootstrap`, size limit), generates per-VM machine ID and random seed, writes the payload to `/run/equipo/bootstrap.json` (0400, runner user), and starts the runner (or, for the certification purpose, the Task 27 harness) through `equipo-vm-init drop`, which sets no-new-privileges, clears the bounding and ambient capability sets, sets the runner user's IDs and execs. `Resume` signals the runner to rotate its credential.
+---
-- [ ] **Red:** `TestInitReplacesResolverMounts`; `TestReadyRefusesState` table (one row per forbidden item); `TestRunWritesBootstrapForRunnerOnly`; `TestRunRefusesOversizePayload`; `TestDropClearsCapabilities` (the recorded `Sys` calls show no-new-privileges, empty sets, the runner IDs, in that order before exec); `TestHooksTransport`.
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/vminit ./internal/isolatedjob/awsjob/vmhooks -count=1`; `make build`.
-- [ ] **Mutations:** skip the read-only remount; `TestInitReplacesResolverMounts` fails. Skip the bounding-set clear; `TestDropClearsCapabilities` fails. Restore.
-- [ ] **Commit:** `vm init: resolver mounts, reaping and an unprivileged runner`.
+## Phase F: §17 guards, the image and certification
-### Task 26: Image manifest and deterministic build
+### Task 30: Checkpoint binding and quoting (spec §3, §17; certified guards)
-**Files:** Create `internal/hostedimage/{manifest.go,manifest.json,build.go,build_test.go}`, `cmd/equipo-hosted-image/main.go`, `scripts/hosted-image-inputs-check.sh`. Modify `Makefile` (`hosted-image-check`, added to `ci`).
+Slice 4 builds checkpointing. These guards land now so that certification covers them from the first image.
-**Interfaces:** Consumes `containment.BubblewrapSHA256`, `release.BuildManifest()`. Produces:
+**Files:** Create `internal/hostedcheckpoint/{bind.go,quote.go,bind_test.go,quote_test.go}`. If the injection-defences work has landed a shared quoting helper by then, build on it rather than duplicating it.
-```go
-type Manifest struct {
- Version int
- Base string // OCI base image by digest
- Files []File // Path, SHA256, Mode, Owner; Source names a release artifact
- RunnerDigest string
- BwrapSHA256 string
- Toolchains []File // what the containment suite needs: python3, git; slice 2 adds check toolchains
- ContainmentTests int // `containment.test -test.list` count minus ^TestSource
- CertTools []File // containment.test, equipo-vm-certcheck
-}
-func Load() (Manifest, error) // embedded manifest.json
-func Build(ctx context.Context, m Manifest, inputs fs.FS, out string) (isolatedjob.ImageDigest, error)
-```
+**Interfaces (produces):**
+- `Record{Task, Repository, Base, Candidate, Attempt, LaunchID string}`.
+- `Claim{Record; PackSHA256, NoteSHA256 string}`.
+- `Bind(rec Record, c Claim, pack, note []byte) (Ack, error)` refuses any field mismatch and any digest mismatch.
+- `Resumable(ack *Ack) error` refuses a nil (unacknowledged) checkpoint.
+- `ResumePrompt(rec Record, ack Ack, notes []string, personWords []string) string` labels the task, attempt and checkpoint digest. It carries each note as a JSON-quoted string under a `checkpoint note (runner output, untrusted)` label, and keeps composer-origin person words in a separate block.
+
+- [ ] **Red:**
+ - `TestBindRefusesEachMismatch`: one row each for task, repository, base, candidate, attempt, launch ID, pack hash and note hash.
+ - `TestUnacknowledgedCannotResume`.
+ - `TestNoteCannotEscapeQuoting`: notes containing closing quotes, backslashes, newlines, the label text, a fake `person words` block header, and the prompt's own delimiters all stay inside one JSON string, and the parsed prompt shows exactly one person block.
+ - `TestNotesNeverInPersonBlock`.
+- [ ] **Green:** `go test ./internal/hostedcheckpoint -count=1`.
+- [ ] **Mutations (register each):**
+ - Skip the task comparison: its row fails.
+ - Concatenate notes unquoted: `TestNoteCannotEscapeQuoting` fails.
+- [ ] **Commit:** `hostedcheckpoint: bound acknowledgements and quoted notes`.
+
+### Task 31: Hosted admission check (spec §7 and §17 M8; certified guards)
+
+**Files:** Create `internal/hostedadmit/{admit.go,admit_test.go}`.
-`cmd/equipo-hosted-image build` writes an OCI image layout; `register` calls `awsjob.Registry.Register` and waits for `Ready`. Build refuses a file whose digest differs from the manifest and any path in a forbidden set (`.ssh`, `.aws`, `*.pem`, `*.key`, runner state, OAuth homes). `hosted-image-check` runs gitleaks over the inputs directory and `go test ./internal/hostedimage`.
+**Interfaces (produces):**
+- `LaunchRecord{AttemptID, LaunchID, VMRef string; Epoch int64; Image isolatedjob.ImageDigest; CertificateDigest string}` comes from the controller via `hostedclient.Get`.
+- `Hello{VMRef, Image, Profile string; Epoch int64}` is what the runner claims.
+- `Admit(rec LaunchRecord, current map[isolatedjob.ImageDigest]string /*image to current certificate digest*/, h Hello) (Admission, error)`.
-- [ ] **Red:** `TestBuildIsDeterministic` (two builds, one digest: fixed mtimes, sorted entries, fixed owners); `TestBuildRefusesDigestMismatch`; `TestBuildRefusesForbiddenPaths`; `TestManifestPinsBubblewrap` (equals `containment.BubblewrapSHA256`); `TestManifestRunnerMatchesRelease`; `TestContainmentCountMatchesSuite` (compares with `go test -list` on the package, minus `TestSource`).
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/hostedimage -count=1`; `make hosted-image-check`.
-- [ ] **Mutations:** drop the fixed mtime; `TestBuildIsDeterministic` fails. Change one pin byte; `TestManifestPinsBubblewrap` fails. Restore.
-- [ ] **Commit:** `hosted image: pinned manifest and reproducible build`.
+`Admission` is built only from `rec`. The hello can cause a refusal but never grants anything. Slice 2 calls `Admit` on every hosted admission path.
----
+- [ ] **Red:**
+ - `TestForgedImageHelloRefused`: the hello claims a certified image that differs from the record.
+ - `TestReplayedHelloRefused`: another VM's ref.
+ - `TestEpochMismatchRefused`.
+ - `TestRecordWithoutCurrentCertificateRefused`.
+ - `TestAdmissionIgnoresHelloProfile`: a hello saying `bubblewrap` on an uncertified record is refused.
+- [ ] **Green:** `go test ./internal/hostedadmit -count=1`.
+- [ ] **Mutation (register):** take the image from the hello. `TestForgedImageHelloRefused` fails. Restore.
+- [ ] **Commit:** `hostedadmit: admission from the launch record, not the hello`.
-## Phase F: the certification gate (spec §7, §14 egress matrix, §17)
+### Task 32: Image inventory, manifest and deterministic build
-### Task 27: In-VM certification harness and the egress matrix
+**Files:**
+- Create `internal/hostedimage/{manifest.go,manifest.json,inventory.go,build.go,build_test.go,inventory_test.go}` and `cmd/equipo-hosted-image/main.go`.
+- Modify `Makefile` (`hosted-image-check`, in `ci`) and `scripts/ci-test.py` (the same target in the static-checks `EXTRA_SHARDS` entry).
-**Files:** Create `cmd/equipo-vm-certcheck/main.go`, `internal/hostedcert/matrix/{rows.go,run_linux.go,report.go,matrix_test.go}`.
+**Interfaces (produces):**
-**Interfaces:** Consumes Tasks 2, 3, 10, 24, 25. Produces `matrix.Rows() []Row` (`Row{Name, Actor /*root, runner, sandbox*/, Expected /*allowed, refused*/}`), `matrix.Run(ctx, env Env) (hostedcert.Certificate fields: Containment, Matrix)`, and the report JSON posted to the report route through the proxy with the VM's credential.
+```go
+type Manifest struct {
+ Version int
+ Base string // OCI base image by digest
+ Provenance string // the release provenance manifest's commit and digests (Task 37)
+ Files []File // Path, SHA256, Mode, Owner, Source
+ Executables []string // every program the suite or probe executes, each present in Files
+ ProxyRootSHA256, InterceptRootSHA256 string
+ ContainmentTests int // containment.test -test.list, minus ^TestSource
+}
+func Load() (Manifest, error)
+func Inventory(testSources fs.FS) ([]string, error) // absolute program paths and bare names exec'd by the containment tests
+func Build(ctx context.Context, m Manifest, inputs fs.FS, out string) (isolatedjob.ImageDigest, error)
+```
-The harness runs the containment suite as the runner user: `containment.test -test.v -test.count=1 -test.skip '^TestSource'`, and records each test's result; only `TestNamespaceCgroupMoveKeepsMembership` may skip. Then the matrix. The sandbox actor runs inside the containment manager with the hosted launch policy, exactly as checks will.
+The image contains:
+- `equipo-vm-init`, `equipo-vm-probe` and `containment.test`;
+- the runner and the tool proxy (`equipo-tool-proxy`), with digests taken from release provenance, not `release.BuildManifest()`;
+- the pinned bubblewrap;
+- the release-pinned codex (open question 5);
+- the Go toolchain at `go1.26.11`, because the tests run `go env GOROOT` and Go builds;
+- `make`, `bash`, `python3`, `git`, and the coreutils the tests name (`true`, `false`, `cat`, `sleep`, `touch`);
+- the two pinned roots.
+
+- [ ] **Red:**
+ - `TestInventoryCoversSuite`: every program the inventory finds in the containment tests' sources is in `Executables` and `Files`.
+ - `TestBuildIsDeterministic`: inputs with deliberately different mtimes, set with `os.Chtimes` to two dates a year apart, give one digest.
+ - `TestBuildRefusesDigestMismatch`.
+ - `TestBuildRefusesForbiddenPaths`: `.ssh`, `.aws`, `*.pem`, `*.key`, runner state and OAuth homes.
+ - `TestManifestPinsBubblewrap`: equals `containment.BubblewrapSHA256`.
+ - `TestContainmentCountMatchesSuite`.
+- [ ] **Green:** `go test ./internal/hostedimage -count=1`, `make hosted-image-check`, and `python3 scripts/ci-test.py check`.
+- [ ] **Mutations:**
+ - Remove `make` from the manifest: `TestInventoryCoversSuite` fails.
+ - Drop the fixed mtime: `TestBuildIsDeterministic` fails.
+ - Change one pin byte: `TestManifestPinsBubblewrap` fails.
+- [ ] **Commit:** `hosted image: inventory, pinned manifest and reproducible build`.
+
+### Task 33: Guard mutation evidence
+
+**Files:** Create `scripts/hosted-guard-evidence.py`, plus a `--self-test` with two fixture guards under `scripts/testdata/`.
+
+**Interfaces (produces):** `python3 scripts/hosted-guard-evidence.py run --commit <sha> --out <file>` works like this:
+1. Clones the commit into a fresh `mktemp -d` under `$TMPDIR`.
+2. For each guard in `guards.json`:
+ 1. Applies the patch.
+ 2. Runs `go test ./<package> -run '^<test>$' -count=1` and expects failure.
+ 3. Reverts the patch.
+ 4. Reruns the test and expects a pass.
+3. Writes `hostedcert.GuardEvidence` as JSON with its sha256.
+4. Removes the clone.
+
+This replays the guards registered so far. It runs once per certification, not in a loop. It refuses a dirty clone.
+
+- [ ] **Red:** `--self-test`. A fixture guard whose test still passes under its mutation must be reported as `FailedUnderMutation: false`, and the run must exit non-zero.
+- [ ] **Green:** `python3 scripts/hosted-guard-evidence.py --self-test`. Then run it once at HEAD and record the guard count and the time taken.
+- [ ] **Commit:** `scripts: replay certified guard mutations as evidence`.
+
+### Task 34: In-VM certification harness and the egress matrix
+
+**Files:** Create `internal/vmprobe/{certify_linux.go,probes_linux.go,certify_test.go}`. Modify `internal/hostedcert/matrix.json` to add every row below.
+
+**Interfaces:**
+- Consumes Tasks 2, 3, 11 and 26 to 28.
+- Produces `vmprobe.Certify(ctx, cfg Config) error`, which starts as root and runs four phases in order.
+- The report carries observations only (`hostedcert.Report`). It is posted to the report route through the proxy with the VM's credential.
+
+The four phases:
+1. **Root rows.**
+2. **Drop.** Re-exec through `equipo-vm-init drop`.
+3. **Runner rows.** Run the containment suite as the runner user: `containment.test -test.v -test.count=1 -test.skip '^TestSource'`.
+4. **Sandbox rows.** Run inside the containment manager with the hosted launch policy, exactly as checks will run.
+
+Each refusal row names a positive control that proves the probe itself works:
+
+| Rows | Actor | Expect | Control |
+| --- | --- | --- | --- |
+| `root_metadata_no_credentials`, `root_no_aws_files` | root | denied_locally | `root_metadata_reachable` (allowed: region only) |
+| `root_managed_resolver_<n>`, `root_direct_v4`, `root_direct_v6` | root | unreachable | `root_proxy_port_reachable` |
+| `runner_instance_healthz` | runner | allowed | — |
+| `runner_proxy_port_reachable`, `runner_bootstrap_listener_reachable` | runner | allowed | — |
+| `runner_direct_instance_v4`, `runner_direct_instance_v6` (connect to the instance's real addresses, bypassing the proxy) | runner | unreachable | `runner_proxy_port_reachable` |
+| `runner_managed_resolver_<n>`, `runner_metadata` | runner | unreachable or denied_locally | `runner_proxy_port_reachable` |
+| `runner_no_credential`, `runner_expired_credential`, `runner_other_vm_credential`, `runner_old_epoch` | runner | proxy_refused:credential | `runner_instance_healthz` |
+| `sni_mismatch`, `missing_sni`, `ech`, `host_mismatch`, `h2_authority_mismatch`, `redirect_cross_host`, `encoded_authority`, `nested_connect`, `ip_literal_v4`, `ip_literal_v6`, `other_proxy_port` | runner | proxy_refused:<reason> | `runner_instance_healthz` |
+| `denied_<name>` (six), `mirror_get_none`, `mirror_upload`, `mirror_cache_miss_url`, `gateway_route`, `report_route_as_job` | runner | proxy_refused:<reason> | `runner_instance_healthz` |
+| `plain_dns_any_name` | runner | nxdomain | `tls_dns_own_instance` (allowed) |
+| `resolver_files_read_only`, `no_capabilities`, `no_new_privileges`, `no_setuid_binaries` | runner | denied_locally | `runner_can_write_state_dir` (allowed) |
+| `sandbox_any_host`, `sandbox_resolver`, `sandbox_proxy`, `sandbox_bootstrap_listener`, `sandbox_metadata`, `sandbox_ipv6`, `sandbox_shell_dns`, `sandbox_build_script_network` | sandbox | unreachable | `sandbox_loopback_listener` (allowed: a listener inside the sandbox) |
+
+`mirror_get_none` is a refusal row. There is no allowed mirror case while the mirror is `none`. Its control is the instance row, and the expected reason is `service_none`, which tells a policy refusal from a broken probe.
+
+- [ ] **Red:**
+ - `TestMatrixDefinitionCoversSpec`: every network item in spec §14 and §17 names a row.
+ - `TestEveryRefusalHasControl`.
+ - `TestRootRowsRunBeforeDrop`.
+ - `TestReportHasNoExpectations`: the report type has no field for them.
+ - `TestReportCarriesNoSecrets`.
+ - `TestOutcomeClassification`, with injected dialers: a timeout or `ENETUNREACH` is `unreachable`; a 403 carrying `Equipo-Egress-Refusal` is `proxy_refused:<reason>`; a 403 without that header, or any other status, is an error outcome that matches no expectation.
+- [ ] **Green:** `go test ./internal/vmprobe ./internal/hostedcert -count=1`.
+- [ ] **Mutation (register):** classify a timeout as `proxy_refused`. `TestOutcomeClassification` fails. Restore.
+- [ ] **Commit:** `certification: in-VM harness, trusted matrix rows and controls`.
+
+### Task 35: Certification flow: online collection, offline signing
+
+Astra's view on open question 4: keep report collection online and signing under the operator's control, as separate steps.
+
+**Files:** Create `cmd/equipo-hosted-controller/certify.go`, `internal/hostedctl/{certify.go,certify_test.go}` and `internal/hostedcert/bundle.go`.
-| Row | Actor | Expected |
-| --- | --- | --- |
-| `instance_healthz_via_proxy` | runner | allowed |
-| `no_credential_refused`, `expired_credential_refused`, `other_vm_credential_refused`, `old_epoch_refused` | runner | refused |
-| `sni_mismatch`, `missing_sni`, `ech`, `host_mismatch`, `h2_authority_mismatch`, `redirect_cross_host`, `encoded_authority`, `nested_connect`, `ip_literal_v4`, `ip_literal_v6`, `other_proxy_port` | runner | refused |
-| `denied_registry_<name>` (one per denied name), `mirror_upload`, `mirror_cache_miss_url`, `gateway_route` | runner | refused |
-| `unknown_name_nxdomain` | runner | refused |
-| `managed_resolver_<n>` (each managed resolver address) | root and runner | refused |
-| `metadata_credentials` (role path empty, no AWS keys in env or files) | root and runner | refused |
-| `resolver_files_read_only`, `no_capabilities`, `no_new_privileges`, `no_setuid_binaries` | runner | refused |
-| `sandbox_any_host`, `sandbox_resolver`, `sandbox_proxy_socket`, `sandbox_metadata`, `sandbox_ipv6` | sandbox | refused |
-| `sandbox_build_script_network` (a lifecycle script that resolves and connects), `sandbox_shell_dns` | sandbox | refused |
-
-- [ ] **Red:** `TestRowsCoverSpec` (every spec §14 and §17 network item named above exists exactly once); `TestUnexpectedSuccessFailsReport`; `TestOnlyCgroupSkipAllowed`; `TestReportCarriesNoSecrets`.
-- [ ] **Implement.** Rows that need a real VM are built and run there in Task 31; local tests cover report logic with injected probes.
-- [ ] **Green:** `go test ./internal/hostedcert/matrix -count=1`.
-- [ ] **Mutation:** treat a probe error as refused when the row expected allowed; `TestUnexpectedSuccessFailsReport`'s mirror case fails. Restore.
-- [ ] **Commit:** `certification: in-VM containment run and egress matrix`.
-
-### Task 28: Operator certification flow
-
-**Files:** Create `cmd/equipo-hosted-controller/certify.go`, `internal/hostedctl/{certify.go,certify_test.go}`.
-
-**Interfaces:** Consumes Tasks 10, 12, 13, 17, 27. Produces `equipo-hosted-controller certify -image sha256:... -key <operator certification key> -config <client config>`: launch a Large certification VM as operator, wait up to 20 minutes for the report, stop it with proof, verify the report against `Expectation` plus the controller's own network audit taken during the run, sign the certificate with the operator's key, upload with `PUT /v1/certificates/{image}`; the controller verifies before storing (Task 10) and records it with the audit. `(*Controller) StoreCertificate(ctx, actor, hostedcert.Signed) error`.
-
-- [ ] **Red:** `TestCertifyRefusesFailedReport` (each Task 10 failure kind); `TestReportFromJobLaunchRefused`; `TestCertificationLaunchCannotEnrol` (its Bootstrap has an empty InstanceCode); `TestStoreCertificateVerifiesFirst`; `TestCertifiedImageThenLaunches` (end to end on the fake: uncertified launch refused, certify, launch accepted with the digest recorded).
-- [ ] **Implement.**
-- [ ] **Green:** `go test ./internal/hostedctl -run 'TestCertif|TestReportFromJob|TestStoreCertificate' -count=1`.
-- [ ] **Mutation:** store without verifying; `TestStoreCertificateVerifiesFirst` fails. Restore.
-- [ ] **Commit:** `certification: operator flow from report to signed certificate`.
+**Interfaces (produces):**
+- `equipo-hosted-controller certify collect -image <digest> -client <operator config> -out <bundle>`, with the operator API key:
+ 1. Launches a Large certification VM.
+ 2. Waits up to 20 minutes for the report.
+ 3. Fetches the report with its controller-recorded Provenance and the audit taken during the run.
+ 4. Stops the VM with proof.
+ 5. Writes a bundle.
+- `equipo-hosted-controller certify sign -bundle <file> -evidence <guard evidence> -provenance <release provenance> -key <certification key> -out <signed>`, offline, with no network:
+ 1. Builds the Expectation from repository data (`guards.json`, `matrix.json`, the image manifest and release provenance).
+ 2. Verifies everything.
+ 3. Signs.
+- `equipo-hosted-controller certify upload -signed <file>` sends `PUT /v1/certificates/{image}`.
+- `(*Controller) StoreCertificate(ctx, by, hostedcert.Signed) error` verifies before storing and records the audit.
+
+- [ ] **Red:**
+ - `TestSignRefusesFailedBundle`: each `Verify` failure class.
+ - `TestSignNeedsNoNetwork`: runs with a `Dialer` that panics.
+ - `TestStoreCertificateVerifiesFirst`.
+ - `TestCertifiedImageThenLaunches`: on the fake, launch is refused, then certify, then launch is accepted with the digest recorded.
+ - `TestCertificationLaunchCannotEnrol`: an empty `InstanceCode`.
+- [ ] **Green:** `go test ./internal/hostedctl ./internal/hostedcert -run 'TestSign|TestStoreCertificate|TestCertified|TestCertificationLaunch' -count=1`.
+- [ ] **Mutation:** store without verifying. `TestStoreCertificateVerifiesFirst` fails. Restore.
+- [ ] **Commit:** `certification: online collection, offline signing and upload`.
---
## Phase G: infrastructure, release and dev bring-up
-### Task 29: OpenTofu for the hosted network, controller and proxies
-
-This repository has no infrastructure code. This task proposes `infra/hosted/` in OpenTofu, following carlos/platform's `infra/modules` style (open question 2).
-
-**Files:** Create `infra/hosted/modules/{network,controller,proxies}/{main.tf,variables.tf,outputs.tf}`, `infra/hosted/envs/dev/{main.tf,backend.tf}` (account `640012953448`, profile `kass`, `eu-west-1`, tag `purpose=equipo-hosted-dev`), `infra/hosted/envs/prod/{main.tf,backend.tf}` (account `149757027610`, profile `equipo-hosted`, not applied), `infra/hosted/README.md`, `scripts/hosted-infra-check.py`.
-
-Network: VPC with `enable_dns_support = false` and `enable_dns_hostnames = false`; VM subnets in two zones whose route table has no default route; an egress subnet per zone for the proxies with internet access; VM security group with no ingress and egress only to the two proxies' port and the resolver's UDP and TCP 53; proxy security group allowing those from the VM group, and egress 443 and 853 (DNS over TLS) only. Controller: one arm64 instance with an instance profile allowed only the MicroVM operations, image registry writes for its own repository, the EC2 `Describe*` calls the audit needs, and `sns:Publish` to its topic; its database on an encrypted volume. Proxies: two instances in two zones with fixed private addresses. No role is attached to any VM. The VPC connector and MicroVM image resources go in OpenTofu if the AWS provider supports them; otherwise `equipo-hosted-controller ops ensure-connector` creates them idempotently (open question 1).
-
-- [ ] **Red:** `scripts/hosted-infra-check.py` reads `tofu show -json` of a plan and fails on: DNS support on, any VM-subnet default route, any VM ingress rule, VM egress beyond proxy and resolver, a role or instance profile attached outside the controller, a controller policy action outside its list. A fixture plan under `scripts/testdata/` drives `python3 scripts/hosted-infra-check.py --self-test`.
-- [ ] **Implement** the modules; `tofu fmt -check` and `tofu validate` in each env.
-- [ ] **Green:** `python3 scripts/hosted-infra-check.py --self-test`; with `kass`, `tofu plan -out` in `envs/dev` and the check over its JSON (agent may run plan; plan only).
-- [ ] **Mutation:** flip DNS support in the fixture; the self-test fails. Restore.
-- [ ] **Commit:** `infra: OpenTofu for the hosted network, controller and proxies`.
-
-### Task 30: Hosted release artifacts
-
-**Files:** Modify `Makefile` (`release-hosted`), `scripts/release-isolated.sh` (a hosted mode), create `scripts/hosted-release-check.py`.
-
-**Interfaces (produces):** `make release-hosted` builds in an isolated clean tree at one commit: `equipo-hosted-controller` and `equipo-egress-proxy` for linux/arm64; `equipo-vm-init`, `equipo-vm-certcheck`, `containment.test` (`go test -c -trimpath`) and the runner for linux/amd64; a provenance manifest of digests and commit. `hosted-image` consumes these as its inputs.
-
-- [ ] **Red:** `python3 scripts/hosted-release-check.py --self-test`: a binary whose build information names another commit, a dirty tree flag, or a missing artifact each fail.
-- [ ] **Implement.**
-- [ ] **Green:** the self-test; `make release-hosted` once, then the check over its output.
-- [ ] **Commit:** `release: hosted controller, proxy and image artifacts`.
-
-### Task 31: Dev bring-up, certification and drills (HUMAN-gated)
-
-Every step that changes AWS needs Paul's GO first (H2). Agents run the checks and drills with `kass` once the resources exist.
-
-- [ ] **HUMAN:** Paul applies `infra/hosted/envs/dev` (or authorises the agent to). Agent then runs `hosted-infra-check.py` against the applied state.
-- [ ] **HUMAN:** Paul deploys the controller and both proxies from a `release-hosted` build, with the H2 hostnames, gateway `none`, mirror `none`, and `EQUIPO_HOSTED_ENABLED=1`.
-- [ ] Agent: run Task 6's live contract test; record teardown.
-- [ ] Agent: `equipo-hosted-image build` and `register`; record the digest.
-- [ ] **HUMAN for the key:** Paul (or the operator holding the certification key, open question 4) runs `equipo-hosted-controller certify`. Record the certificate digest, the full containment result (expect every test but the cgroup test to pass, against the spike's 71 of 79) and every matrix row.
-- [ ] Agent drills, each recorded in the progress file: launch a Small job with an operator-supplied dummy instance code and stop it with proof; plant an orphan with the AWS CLI and watch the reaper stop it after 10 minutes; kill the controller between launch and save, restart, see one VM; stop one proxy and see the dialer fail over, then both and see the trusted route refuse rather than fall back; switch VPC DNS support on in a scratch copy of the network module, see the audit fail, launches refuse and the alert fire, then restore; a launch with a 15-minute lifetime is drained at once and stopped at 5 minutes by the controller.
-- [ ] Agent: list every VM and confirm none remain; record the dev spend so far.
+### Task 36: OpenTofu for the dev hosted network, controller and proxies
+
+The repository has no infrastructure code. This task proposes `infra/hosted/` in OpenTofu, following carlos/platform's `infra/modules` style (open question 2). Only the dev environment is written in this slice.
+
+**Files:** Create `infra/hosted/modules/{network,controller,proxies}/{main.tf,variables.tf,outputs.tf}`, `infra/hosted/envs/dev/{main.tf,backend.tf}` (account `640012953448`, profile `kass`, `eu-west-1`, tag `purpose=equipo-hosted-dev`), `infra/hosted/README.md`, `scripts/hosted-infra-check.py` and a fixture under `scripts/testdata/`.
+
+**Network:**
+- A VPC with `enable_dns_support = false` and `enable_dns_hostnames = false`.
+- VM subnets in two zones, with no default route.
+- An egress subnet per zone for the proxies.
+- The VM security group has no ingress. Its egress goes only to the two proxies' egress and bootstrap ports and the resolver's ports 53 and 853.
+- The proxy security group allows only those ports, from the VM group. Its egress is 443 to anywhere, plus 853 to the pinned upstream resolver addresses only.
+
+**Controller:**
+- One arm64 instance, with its database on an encrypted volume.
+- An instance profile allowed only:
+ - the MicroVM operations;
+ - writes to its own image repository;
+ - the EC2 `Describe*` calls the audit needs;
+ - `sns:Publish` to its topic.
+
+**Proxies:** two instances in two zones, with fixed private addresses. No role is attached to any VM. Resources the OpenTofu AWS provider lacks (Task 4) come from an idempotent `equipo-hosted-controller ops ensure` command instead.
+
+- [ ] **Red:** `python3 scripts/hosted-infra-check.py --self-test` reads `tofu show -json`. It fails on any of these:
+ - DNS support on;
+ - a default route on a VM subnet;
+ - a VM ingress rule;
+ - VM egress beyond the proxy and resolver;
+ - a role outside the controller;
+ - a controller action outside its list.
+- [ ] **Implement:** run `tofu fmt -check` and `tofu validate`.
+- [ ] **Green:** the self-test. With `kass`, `tofu plan -out` in `envs/dev`, then the check over its JSON. The agent may run plan only.
+- [ ] **Mutation:** flip DNS support in the fixture. The self-test fails. Restore.
+- [ ] **Commit:** `infra: OpenTofu for the dev hosted network, controller and proxies`.
+
+### Task 37: Hosted release artifacts and CI wiring
+
+**Files:** Modify `Makefile` (`release-hosted`) and `scripts/release-isolated.sh` (a hosted mode). Create `scripts/hosted-release-check.py`.
+
+**Interfaces (produces):** `make release-hosted` builds in an isolated clean tree at one commit. Its output feeds the image manifest's `Provenance`:
+- `equipo-hosted-controller` and `equipo-egress-proxy`, for linux/arm64;
+- for linux/amd64: `equipo-vm-init`, `equipo-vm-probe`, `containment.test` (built with `go test -c -trimpath`), the runner and `equipo-tool-proxy`;
+- a provenance manifest of commit and sha256 in the format of `scripts/staged-artifacts.py`.
+
+- [ ] **Red:** `python3 scripts/hosted-release-check.py --self-test`. A binary whose build information names another commit, a dirty-tree flag, or a missing artifact (including the tool proxy) each fail.
+- [ ] **Green:**
+ - the self-test;
+ - `make release-hosted` once, then the check over its output;
+ - `python3 scripts/ci-test.py check`, which confirms `hosted-guards-check` and `hosted-image-check` are in both `make ci` and the hosted static-checks shard.
+- [ ] **Commit:** `release: hosted artifacts with provenance, wired into CI`.
+
+### Task 38: Dev bring-up, certification and drills (HUMAN-gated)
+
+Each step marked **HUMAN** needs Paul's GO. Agents run the read-only checks and the non-destructive drills with `kass`.
+
+- [ ] **HUMAN:** apply `infra/hosted/envs/dev`. The agent then runs `hosted-infra-check.py` against the applied state.
+- [ ] **HUMAN:** deploy the controller and both proxies from a `release-hosted` build, with the H2 hostnames, gateway `none`, mirror `none`, and `EQUIPO_HOSTED_ENABLED=1`.
+- [ ] Agent, with GO: run Task 8's live contract test, and record the teardown proof.
+- [ ] **HUMAN:** register the image (`equipo-hosted-image build`, then `register`). The agent records the digest.
+- [ ] Agent: run `certify collect` and `hosted-guard-evidence.py run`. Record the full containment result (every test passes except the cgroup skip, against the spike's 71 of 79), every matrix row and the guard count.
+- [ ] **HUMAN:** the certification key holder runs `certify sign` offline, then `certify upload`.
+- [ ] Agent, non-destructive drills:
+ - launch a Small job with an operator-supplied dummy instance code, then stop it with proof;
+ - kill the controller between launch and save, restart it, and see exactly one VM;
+ - suspend and resume a job, and see the probe exchange and the old credential refused;
+ - give a 15-minute lifetime, and see it drained at once and stopped at 5 minutes.
+- [ ] **HUMAN GO, then agent, destructive drills:**
+ - plant an orphan with the AWS CLI and see it stopped after 10 minutes;
+ - stop one proxy and see failover, then both and see the trusted route refused with no fallback;
+ - stop the controller past `FeedGrace` and see egress refused, then restart and see the exchange;
+ - switch VPC DNS support on, and see the audit fail, launches refuse and the alert fire, then switch it off.
+- [ ] Agent: list every VM, confirm none remain, and record the dev spend.
- [ ] One whole-branch review (Astra or Fable, as Paul directs), at most three rounds. Paul lands it.
-**Slice 1 is done when:** a certified image digest exists in dev; the controller launches it only with that certificate; the drills pass; no VM is left running; and everything is off unless `EQUIPO_HOSTED_ENABLED=1`.
+**Slice 1 is done when** all of these hold:
+- a certified image digest exists in dev;
+- the controller launches it only with that certificate;
+- the end-to-end test and the drills pass;
+- no VM is left running;
+- everything is off unless `EQUIPO_HOSTED_ENABLED=1`.
---
## What slice 2 then needs
-Slice 2 (hosted checks) builds on the above and needs, in roughly this order:
-
-1. **Dependency mirror and importer** (spec §6, Paul's ruling 4): required before any hosted code runs. Its exact hostname goes in the manifest, the mirror path class is already in policy, and the image is recertified with the mirror set.
-2. **Enrolment on the instance:** `POST /api/hosted/enrol` (bootstrap code, VM ID, machine public key), minted bootstrap codes passed as `InstanceCode`, runner bearer of 1 hour renewable to the deadline, epochs, and the 2-minute enrolment timeout (stop, retry once, fail with a reason).
-3. **Runner changes:** `Link` reads the current bearer on each dial; the runner uses `egressproxy/client` and its `Credential`; a Linux checks worker on the containment manager with namespace proof, since `thin.Run` starts the worker loop only on a Mac or the test fake.
-4. **Instance admission:** a hosted VM enrols as a worker bound to one job (`fits`, authorisation and dispatch refuse anything else); the instance accepts `bubblewrap` from a worker only when the controller's launch record carries a current certificate; a hello's claimed image or profile is diagnostic only, with the M8 test that a hello claiming another certified image fails.
-5. **Placement and limits:** the project setting (off by default) read by `place` before its early return; the `waiting_hosted` placement; offline-withdrawal exemption for starting, draining and suspended VMs; per-person limits of 2 running VMs, 8 VM-hours a day and $50 a month.
-6. **The instance half of the pause barrier**, if slice 2 pauses at all: `draining` with the generation in the admission transaction.
-7. **Wiring `hostedclient`** into the instance (deleting `TestInstanceDoesNotCallHostedClient`), the launch-to-enrolled metric, and the slice 2 end-to-end test: pack transfer, checks in the sandbox, certified report.
-8. **Simulation:** add the instance invariants (nothing starts while draining, one attempt publishes) to Task 16's model.
-9. **Production:** H1 done, `infra/hosted/envs/prod` applied, the controller and proxies deployed there, the quota confirmed, and the image certified in that account.
+1. **Dependency mirror and importer.** Spec §6 and Paul's ruling 4 require it before any hosted code runs. Set its exact host in configuration and recertify; the matrix gains an allowed mirror row with its control.
+2. **Enrolment on the instance.** Covers:
+ - `POST /api/hosted/enrol` (bootstrap code, VM ID, machine key);
+ - instance-minted codes passed as `InstanceCode`;
+ - the 1-hour runner bearer, renewable to the deadline;
+ - epochs;
+ - the 2-minute enrolment timeout: stop, retry once, then fail with a reason.
+3. **Runner changes.** Covers:
+ - the runner replaces the probe;
+ - it reads the bootstrap, uses `egressproxy/client` and its `Credential`, and handles `rotate` on the control socket;
+ - `Link` reads the current bearer on each dial;
+ - a Linux checks worker on the containment manager with namespace proof (`thin.Run` starts the worker loop only on a Mac or the fake).
+
+ Changing `vminit` to start the runner changes the image, so recertify.
+4. **Instance admission.** Every hosted admission path calls `hostedadmit.Admit` with the controller's record. The instance accepts `bubblewrap` from a worker only through it. A hosted VM is a worker bound to one job (`fits`, authorisation and dispatch).
+5. **Placement and limits:**
+ - the project setting (off by default) read by `place` before its early return;
+ - `waiting_hosted`;
+ - the offline-withdrawal exemption;
+ - per person: 2 running VMs, 8 VM-hours a day and $50 a month.
+6. **The instance half of the pause barrier**, if checks pause at all: `draining` with the generation in the admission transaction.
+7. **Wiring and testing:**
+ - wire `hostedclient`, and delete `TestInstanceDoesNotCallHostedClient`;
+ - add the launch-to-enrolled metric;
+ - run the slice 2 end-to-end test (pack transfer, checks in the sandbox, certified report);
+ - add the instance invariants to Task 18's model.
+8. **Production.** The deferred section above.
## Open questions
-1. **MicroVM client in Go.** If aws-sdk-go-v2 has no package for the MicroVM API yet, what do we call it with? *Recommendation:* use the SDK package if it exists; otherwise a SigV4-signed client for the six calls, kept inside `awsjob` and replaced when the SDK ships. The same applies to OpenTofu: resources the AWS provider lacks are created by an idempotent controller `ops` command.
-2. **Where infrastructure code lives.** This repository has none. *Recommendation:* `infra/hosted/` in oficina/equipo, OpenTofu, in the style of carlos/platform's `infra/modules`, with state in each account. The alternative is a private infrastructure repository like platform-infrastructure; that only pays off once a second deployment exists.
-3. **Controller compute and job table durability.** *Recommendation:* one small arm64 EC2 instance with SQLite on an encrypted volume and daily snapshots in dev; add continuous replication to S3 in the same account before production. No high availability: running VMs continue while it is down (spec §10).
-4. **Who holds the certification key.** *Recommendation:* an Ed25519 key held by Paul (or a named operator) offline for dev; for production, a key that only a certification role can use, created in `equipo-hosted`. The controller pins the public key either way.
-5. **Codex in the image.** Five containment tests need the codex binary, but hosted VMs run no Codex. *Recommendation:* include the release-pinned codex binary, with no credentials, so the full suite passes as §7 requires; drop it only with a spec change that names those five tests as not applicable.
-6. **Gateway and mirror names before they exist.** The spec says an unset name blocks launch. *Recommendation:* a third value, `none`, recorded in the certificate, which denies the route; unset still blocks. Slice 1 certifies with both `none`. Slice 2 sets the mirror and recertifies.
-7. **How certification results leave the VM.** *Recommendation:* one controller report route through the proxy, allowed only for certification launches and left out of the policy digest that production launches compare against, so production policy is unchanged.
-8. **Upstream DNS for the proxies while VPC DNS is off.** *Recommendation:* the proxies resolve upstream names over DNS over TLS to a pinned public resolver, keeping the spike's single VPC; a separate egress VPC is the alternative if that is not acceptable.
+1. **MicroVM API and SDK.** *Recommendation:* use the SDK package if one exists. Otherwise, a SigV4 client inside `awsjob`. *Astra:* agrees, provided the API, hook and idempotency facts are settled first. Task 4 now does that, and stops the work on any contradiction.
+2. **Where infrastructure code lives.** *Recommendation:* `infra/hosted/` in this repository, OpenTofu, in carlos/platform's module style. *Astra:* agrees.
+3. **Controller outage versus a stale feed.** Spec §10 says running VMs continue while the controller is down, and that nothing falls back to open egress. A proxy that denies on a stale feed breaks the first; one that never denies would keep honouring stops and epochs it has not heard about. *Recommendation:* bounded continuation. The proxy serves from the last signed feed for up to 15 minutes, the credential lifetime, then refuses. Outages longer than that make steps wait, as "Proxy down" does. On restart, the controller reconciles with the provider and grants each live VM one exchange window before lapse stops apply (Task 17). This qualifies §10's "Running VMs continue" to "for up to 15 minutes", so Paul should approve it as a spec interpretation. *Astra:* SQLite and a single instance suit dev, with restore reconciliation defined, which this now does. For production durability, add continuous replication to S3 in the same account before slice 2 production.
+4. **Who holds the certification key.** *Recommendation:* an Ed25519 key held by Paul or a named operator, offline, for dev. For production, a key only a certification role can use in `equipo-hosted`. The controller pins the public key. *Astra:* agrees, with collection and signing separated, which Task 35 now does.
+5. **Codex in the image.** *Recommendation:* include the release-pinned codex binary with no credentials, plus every executable the suite runs (Task 32's inventory), so the full suite passes as §7 requires. *Astra:* agrees.
+6. **Gateway and mirror before they exist.** *Recommendation:* an explicit `none` value, recorded in every snapshot and the certificate, which denies the route. Unset still blocks. Setting either name requires recertification, enforced because the certificate binds both. *Astra:* reasonable, but this interpretation of §6 needs Paul's explicit approval.
+7. **Getting certification results out of the VM.** *Recommendation:* one report route through the proxy, allowed only for certification launches. Per Astra, its policy and provenance are bound separately in the certificate (`ReportPolicyDigest`, `Provenance`) rather than left outside it.
+8. **Upstream DNS for the proxies with VPC DNS off.** *Recommendation:* DNS over TLS to pinned resolver addresses with a pinned TLS name and no fallback, keeping one VPC. *Astra:* agrees with that pinning.
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 638bffe0..ae6a4ee3 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -15856,23 +15856,9 @@
},
{
"path": "docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md",
- "line_sha256": "713e8f48d4ba60502e11ad13b0ac88ef87d2c498df6acd76683d0921b78daa54",
- "match": "equipo-runner",
- "count": 1,
- "reason": "Hosted runners slice 1 plan (design-hosted-runners): names the runner executable, its state path and the denied package registries; this line grants no runtime authority."
- },
- {
- "path": "docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md",
- "line_sha256": "95b04b29a0dff68ffdc483a4491dde9fe9c7850764c3a1f329957a294615d499",
+ "line_sha256": "666ae9f23ef549f2af4049e0af743e92bee864633639566af9a18a8503333af8",
"match": "npm",
"count": 1,
- "reason": "Hosted runners slice 1 plan (design-hosted-runners): names the runner executable, its state path and the denied package registries; this line grants no runtime authority."
- },
- {
- "path": "docs/superpowers/plans/2026-11-19-hosted-runners-slice-1.md",
- "line_sha256": "e2458cbf4f611f48ea8a1bf5ca2bd84a2bd0356ebfb55ff5192b36531f7f1aa7",
- "match": "equipo-runner",
- "count": 1,
- "reason": "Hosted runners slice 1 plan (design-hosted-runners): names the runner executable, its state path and the denied package registries; this line grants no runtime authority."
+ "reason": "Hosted runners slice 1 plan (design-hosted-runners): names the denied package registries; this line grants no runtime authority."
}
]