runner: pause the step to snapshot its workspace (tree: work)
Plan task 9. New package internal/runner/pause (Linux; ErrUnsupported
elsewhere): Hold stops every descendant of the step sandbox's first
process with SIGSTOP via pidfds (identity by start time and pid
namespace, children by PPid with start-time and NSpid-depth checks
against pid reuse), rescans /proc until every thread reads stopped and
no new process appears, runs the work, and sends SIGCONT on every exit
path: return, panic (deferred), and a watchdog at the 10 s bound that
resumes even while the work runs (then ErrBusy). No cgroup is frozen.
thin: copyWorkSite reads release/preview.json and copies its output
into a 0700 stage with openat2 from the workspace root
(RESOLVE_BENEATH|NO_SYMLINKS|NO_MAGICLINKS|NO_XDEV, O_NOFOLLOW), types
read through O_PATH, regular files only, by exportStatic's rules; the
rules are factored out of preview.go (parsePreviewConfig, siteEntry,
siteBudget, siteStage), behaviour unchanged, and the digest equals
exportStatic's for the same tree. Walk caps: depth 32, 2000 dirs.
snapshotWork runs the copy inside pause.Hold; any pause failure is
errWorkBusy, and a failed snapshot removes its stage. The Claude step
run keeps the sandbox's first process on specialistRun.sandbox from
containment's post-start record (recordedStartKept). No git index,
nothing written to the workspace or branch.
Tests: CGO_ENABLED=0 go test ./internal/runner/pause/ -count=20;
go test ./internal/runner/thin/ -run 'TestWorkSite|TestRecordedStartKeepsTheSandbox|TestSnapshotWork';
full thin lane (-tags testbuild -timeout 15m) ok 667.6 s. Darwin
build and vet gates ok; staticcheck clean.
RED: a stub Hold let all three writers (direct, unshare --user --pid,
nested bwrap) run while "paused" ("writers ran while paused: [direct
4->724 unshare 2->716 bwrap 2->720]"), no busy past the bound, no
refusal of a wrong identity; a stub copy staged nothing and refused
no link, entry, config or cap.
GREEN: all pass; writers make no progress for 300 ms in the pause and
resume after; SIGCONT after an injected panic and at the bound.
Mutations (each restored):
- skip one descendant (the direct writer): StopsEveryWriter fails
- skip nested-namespace processes: StopsEveryWriter fails
- children only: StopsEveryWriter fails
- no settle check / S counted stopped: PassWaitsForStopped fails
- no watchdog / busy ignored: ResumesAtTheBound fails
- no deferred resume: ResumesAfterPanic fails
- no namespace check: RefusesAnotherProcess fails
- start check in stopRoot and descendants both: RefusesAnotherProcess
- stop deadline and watchdog both: BusyWhenStoppingRunsOut fails
- no RESOLVE_NO_SYMLINKS / no RESOLVE_BENEATH: FollowsNoLink fails
- entry rule removed / files only: RefusesOtherEntries fails
- depth cap removed or off by one, dirs cap removed: Caps fails
- budget removed: CopiesOnlyTheOutput and Caps fail
- empty output, config parse removed: Config fails
- reverse order: CopiesOnlyTheOutput fails (digest differs from git)
- _headers skip removed: CopiesOnlyTheOutput fails
- ErrGone unmapped, stage kept on error: SnapshotWorkPausesTheStep
- keep pre-launch record, keep before record, no drop:
RecordedStartKeepsTheSandbox fails
- layered (fail only together): O_NOFOLLOW with NO_SYMLINKS; links
in walk with readFile's NOFOLLOW and dev/ino; FIFO in walk with
readFile's regular check; the three copy deadline checks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 files changed,
+1,973
−39
internal/runner/pause/pause.go+39 −0internal/runner/pause/pause_linux.go+348 −0internal/runner/pause/pause_linux_test.go+418 −0internal/runner/pause/pause_other.go+10 −0internal/runner/thin/engineer.go+6 −1internal/runner/thin/preview.go+105 −35internal/runner/thin/step.go+1 −3internal/runner/thin/worksnap.go+102 −0internal/runner/thin/worksnap_linux.go+282 −0internal/runner/thin/worksnap_linux_test.go+651 −0internal/runner/thin/worksnap_other.go+11 −0
CI failed — 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/specialists-slice-1: Type Size Avail | ext4 96G 84G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 84G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.3s
ci-box: codex: fetched and verified in 3.6s
ci-box: codex-code-mode-host: fetched and verified in 1.6s
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 10.1s
ci-box: pi: installed and verified in 7.2s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.3s
ci-box: clone deepened in 4.8s
ci-box: file times set from content: 3352 files, 219 directories
ci-box: ready in 18.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.148s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
5.5s
+ go list -export -test -tags testbuild -f ./...
5.3s
+ go list -export -test -tags browser,testbuild -f ./internal/equipo ./internal/equipotest ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
3.6s
rastrillo: budget size: 2 problem(s)
exit status 1
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-24 15:56:00 +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
receipt: test step 1m20.155s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m18.182s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m18.18s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 66.72, cpu waiting 40.14%, memory waiting 0.00%, io waiting 0.44%
--- 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
receipt: test step 1m20.461s 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.022s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m18.02s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 68.52, cpu waiting 40.14%, memory waiting 0.00%, io waiting 0.44%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless
receipt: test step 1m21.551s 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.874s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m9.1s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.06s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.71s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 66.72, cpu waiting 39.97%, memory waiting 0.00%, io waiting 0.42%
--- 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
receipt: test step 1m17.114s 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 1m14.784s amadan.net/oficina/equipo/internal/headless
receipt: slow test 37.33s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 19.33s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.1s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
receipt: slow test 9.03s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
machine: 32 CPUs, load 68.52, cpu waiting 40.34%, memory waiting 0.00%, io waiting 0.45%
--- 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_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
receipt: test step 1m35.776s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m33.774s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m3.33s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.69s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 8.55s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 7.31s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 4.9s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 61.49, cpu waiting 38.41%, memory waiting 0.00%, io waiting 0.33%
--- 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_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
receipt: test step 3m8.093s 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 3m5.662s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m40.32s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 20s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 18.14s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 7.23s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistantAttachments
receipt: slow test 6.78s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 21.63, cpu waiting 8.98%, memory waiting 0.00%, io waiting 0.06%
--- shard 6 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest
receipt: test step 2m17.413s 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 2m15.312s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 10.21s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.75s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 3.94s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 3.88s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 2.67s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
machine: 32 CPUs, load 39.15, cpu waiting 20.60%, memory waiting 0.00%, io waiting 0.16%
--- 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 1m59.226s 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 1m56.672s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.57s amadan.net/oficina/equipo/internal/thintest TestContractRetryPreviewUnverifiedMerge
receipt: slow test 9.09s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 4.97s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.56s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 3.06s amadan.net/oficina/equipo/internal/thintest TestContractPausedJob
machine: 32 CPUs, load 48.16, cpu waiting 27.61%, memory waiting 0.00%, io waiting 0.22%
--- 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
budget note: internal/runner/thin took 5m13.712s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 5m19.501s 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 5m13.712s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.99s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.87s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.81s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.48s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 9.91s amadan.net/oficina/equipo/internal/runner/thin TestTimeoutKeepsNothingForAnOlderInstance
machine: 32 CPUs, load 4.07, cpu waiting 0.99%, memory waiting 0.00%, io waiting 0.00%
--- 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
receipt: test step 51.8s 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 50.832s amadan.net/oficina/equipo/internal/runner
receipt: slow test 30.8s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.02s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 59.54, cpu waiting 35.72%, memory waiting 0.00%, io waiting 0.68%
--- 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
receipt: test step 1m1.196s 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 59.886s amadan.net/oficina/equipo/internal/runner
receipt: slow test 49.89s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 45.32s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.4s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.57s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 66.90, cpu waiting 39.46%, memory waiting 0.00%, io waiting 0.59%
--- 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
receipt: test step 36.054s 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 35.206s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.48s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.12s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.95s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestCoordinatorTransientRefusalKeepsServing
machine: 32 CPUs, load 40.94, cpu waiting 23.43%, memory waiting 0.00%, io waiting 0.89%
--- 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 40.1%, load 31.02
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
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/equipotest TestDirectDeadReferencesRepository
=== RUN TestDirectDeadReferencesRepository
direct_cutover_test.go:221: repository reference inventory: exit status 1
docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1.md:109:5: unclassified equipo-runner
docs/superpowers/plans/CONTROLLER-BRIEF-specialists-slice-1.md:84:25: unclassified Paseo
docs/superpowers/specs/2026-11-28-dynamic-specialists.md:224:15: unclassified equipo-runner
internal/runner/render/driver.go:302:3: unclassified Node
internal/runner/render/driver.go:302:13: unclassified Node
internal/runner/render/driver.go:302:25: unclassified node
internal/runner/render/driver.go:307:39: unclassified Node
internal/runner/render/driver_test.go:89:30: unclassified node
internal/runner/render/driver_test.go:90:20: unclassified node
internal/runner/render/driver_test.go:91:20: unclassified node
internal/runner/render/health_test.go:38:37: unclassified equipo-runner
internal/runner/render/page.go:351:6: unclassified Node
internal/runner/render/page.go:351:18: unclassified node
internal/runner/render/page.go:352:8: unclassified Node
internal/runner/render/page.go:353:2: unclassified Node
internal/runner/render/page.go:353:27: unclassified node
internal/runner/render/page.go:376:9: unclassified Node
internal/runner/render/page.go:376:26: unclassified node
internal/runner/render/page.go:379:7: unclassified Node
internal/runner/render/page.go:383:62: unclassified node
internal/runner/render/page.go:384:66: unclassified node
internal/runner/render/page.go:388:24: unclassified node
internal/runner/render/page.go:390:14: unclassified node
internal/runner/render/page.go:390:24: unclassified Node
internal/runner/render/page.go:391:9: unclassified node
internal/runner/render/page.go:391:23: unclassified Node
internal/runner/render/page.go:392:3: unclassified node
internal/runner/render/page.go:392:16: unclassified node
internal/runner/render/page.go:392:28: unclassified Node
internal/runner/render/page.go:394:36: unclassified node
internal/runner/render/page.go:395:20: unclassified node
internal/runner/render/page.go:396:24: unclassified Node
internal/runner/render/page.go:396:43: unclassified Node
internal/runner/render/page.go:397:12: unclassified Node
internal/runner/render/page.go:401:20: unclassified node
internal/runner/render/page.go:414:27: unclassified node
internal/runner/render/page.go:424:8: unclassified node
internal/runner/render/page.go:448:24: unclassified Node
internal/runner/render/page_test.go:197:77: unclassified Node
internal/runner/render/page_test.go:198:9: unclassified Node
internal/runner/render/page_test.go:198:14: unclassified Node
internal/runner/render/page_test.go:208:41: unclassified node
internal/runner/render/page_test.go:211:2: unclassified node
internal/runner/render/page_test.go:211:15: unclassified Node
internal/runner/render/page_test.go:221:23: unclassified node
internal/runner/render/page_test.go:227:13: unclassified Node
internal/runner/render/page_test.go:245:11: unclassified node
internal/runner/render/page_test.go:246:14: unclassified Node
internal/runner/render/report.go:151:44: unclassified node
internal/runner/thin/worksnap_linux.go:98:5: unclassified node
reference scan: 3064 text files, 3318 matches, 50 failures
--- FAIL: TestDirectDeadReferencesRepository (2.43s)
--- FAIL amadan.net/oficina/equipo/internal/equipotest (package output)
FAIL
rastrillo-budget/v1 ran 1m7.64s
FAIL amadan.net/oficina/equipo/internal/equipotest 67.934s
receipt: test step 1m9.703s 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 1m7.64s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 28.62s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 28.49s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 26.33s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 23.32s amadan.net/oficina/equipo/internal/equipotest TestAuthorityFailureIsNotRevocation
receipt: slow test 23.28s amadan.net/oficina/equipo/internal/equipotest TestAccountConcurrentDuplicate
exit status 1
+ go test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' -v -run '^TestDirectDeadReferencesRepository$' -count=1 ./internal/equipotest (retry, once)
FAILED TWICE ./internal/equipotest:TestDirectDeadReferencesRepository equipotest-a
=== RUN TestDirectDeadReferencesRepository
direct_cutover_test.go:221: repository reference inventory: exit status 1
docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1.md:109:5: unclassified equipo-runner
docs/superpowers/plans/CONTROLLER-BRIEF-specialists-slice-1.md:84:25: unclassified Paseo
docs/superpowers/specs/2026-11-28-dynamic-specialists.md:224:15: unclassified equipo-runner
internal/runner/render/driver.go:302:3: unclassified Node
internal/runner/render/driver.go:302:13: unclassified Node
internal/runner/render/driver.go:302:25: unclassified node
internal/runner/render/driver.go:307:39: unclassified Node
internal/runner/render/driver_test.go:89:30: unclassified node
internal/runner/render/driver_test.go:90:20: unclassified node
internal/runner/render/driver_test.go:91:20: unclassified node
internal/runner/render/health_test.go:38:37: unclassified equipo-runner
internal/runner/render/page.go:351:6: unclassified Node
internal/runner/render/page.go:351:18: unclassified node
internal/runner/render/page.go:352:8: unclassified Node
internal/runner/render/page.go:353:2: unclassified Node
internal/runner/render/page.go:353:27: unclassified node
internal/runner/render/page.go:376:9: unclassified Node
internal/runner/render/page.go:376:26: unclassified node
internal/runner/render/page.go:379:7: unclassified Node
internal/runner/render/page.go:383:62: unclassified node
internal/runner/render/page.go:384:66: unclassified node
internal/runner/render/page.go:388:24: unclassified node
internal/runner/render/page.go:390:14: unclassified node
internal/runner/render/page.go:390:24: unclassified Node
internal/runner/render/page.go:391:9: unclassified node
internal/runner/render/page.go:391:23: unclassified Node
internal/runner/render/page.go:392:3: unclassified node
internal/runner/render/page.go:392:16: unclassified node
internal/runner/render/page.go:392:28: unclassified Node
internal/runner/render/page.go:394:36: unclassified node
internal/runner/render/page.go:395:20: unclassified node
internal/runner/render/page.go:396:24: unclassified Node
internal/runner/render/page.go:396:43: unclassified Node
internal/runner/render/page.go:397:12: unclassified Node
internal/runner/render/page.go:401:20: unclassified node
internal/runner/render/page.go:414:27: unclassified node
internal/runner/render/page.go:424:8: unclassified node
internal/runner/render/page.go:448:24: unclassified Node
internal/runner/render/page_test.go:197:77: unclassified Node
internal/runner/render/page_test.go:198:9: unclassified Node
internal/runner/render/page_test.go:198:14: unclassified Node
internal/runner/render/page_test.go:208:41: unclassified node
internal/runner/render/page_test.go:211:2: unclassified node
internal/runner/render/page_test.go:211:15: unclassified Node
internal/runner/render/page_test.go:221:23: unclassified node
internal/runner/render/page_test.go:227:13: unclassified Node
internal/runner/render/page_test.go:245:11: unclassified node
internal/runner/render/page_test.go:246:14: unclassified Node
internal/runner/render/report.go:151:44: unclassified node
internal/runner/thin/worksnap_linux.go:98:5: unclassified node
reference scan: 3064 text files, 3318 matches, 50 failures
--- FAIL: TestDirectDeadReferencesRepository (2.28s)
FAIL
rastrillo-budget/v1 ran 2.278s
FAIL amadan.net/oficina/equipo/internal/equipotest 2.442s
FAIL
machine: 32 CPUs, load 58.25, cpu waiting 34.94%, memory waiting 0.00%, io waiting 0.29%
make: *** [Makefile:113: ci-shard] Error 1
amadan: step check shard 12 of 29 failed: exit status 2
--- 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 40.1%, load 34.06
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 2m14.731s 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 2m12.51s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 21.18s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 21.17s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 21.16s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 21.12s amadan.net/oficina/equipo/internal/equipotest TestProjectRetryAndRevision
receipt: slow test 21.11s amadan.net/oficina/equipo/internal/equipotest TestProjectConcurrentRetry
machine: 32 CPUs, load 28.31, cpu waiting 12.95%, memory waiting 0.00%, io waiting 0.10%
--- 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 40.1%, load 34.06
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
budget note: internal/equipotest took 5m39.825s, over the 5m0s its record on line 15 allows; reported only, timing fails on CI
receipt: test step 5m45.592s 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 5m39.825s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 4m47.62s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.32s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.27s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.18s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.17s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 2.31, cpu waiting 0.38%, memory waiting 0.00%, io waiting 0.00%
--- 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 41.9%, load 34.06
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 1m10.32s 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 1m7.946s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.82s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 25.99s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 25.99s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 24.11s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsCurrentOwner
receipt: slow test 24.01s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
machine: 32 CPUs, load 58.25, cpu waiting 35.95%, memory waiting 0.00%, io waiting 0.30%
--- 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 40.1%, load 34.06
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 56.26s 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 53.859s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.85s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.48s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.85s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.63s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.32s amadan.net/oficina/equipo/internal/plan3test TestSpecialistLibraryMigration
machine: 32 CPUs, load 64.34, cpu waiting 39.52%, memory waiting 0.00%, io waiting 0.38%
--- 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 40.1%, load 31.02
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/diffscan ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/door ./internal/equipo/github ./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/pause ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/release/renderertest ./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/pause ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/claude/realcli ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/render ./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/forgekey ./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/diffscan ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/door ./internal/equipo/github ./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/pause ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/release/renderertest ./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/pause ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/claude/realcli ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/render ./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/forgekey ./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/provider/claude/realcli: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runnerproto: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/testci: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
--- FAIL amadan.net/oficina/equipo/internal/runner/pause TestHoldStopsEveryWriter
=== RUN TestHoldStopsEveryWriter
pause_linux_test.go:198: Hold: sandbox could not be paused in time (called false)
pause_linux_test.go:68: sandbox stderr:
--- FAIL: TestHoldStopsEveryWriter (10.06s)
--- FAIL amadan.net/oficina/equipo/internal/runner/pause (package output)
FAIL
FAIL amadan.net/oficina/equipo/internal/runner/pause 12.310s
--- FAIL amadan.net/oficina/equipo/internal/testci TestBudgetRecordsAreShort
=== RUN TestBudgetRecordsAreShort
budgets_file_test.go:37: .rastrillo/budgets.txt:41: reason is 214 bytes, over 200
budgets_file_test.go:37: .rastrillo/budgets.txt:74: reason is 232 bytes, over 200
--- FAIL: TestBudgetRecordsAreShort (0.00s)
--- FAIL amadan.net/oficina/equipo/internal/testci (package output)
FAIL
rastrillo-budget/v1 ran 2.391s
FAIL amadan.net/oficina/equipo/internal/testci 2.411s
budget note: internal/equipo took 2m25.149s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/chat took 27.555s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/github took 40.581s, 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 11.729s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/idtest took 1m53.974s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/release took 41.923s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/runner/containment took 1m1.006s, over the 15s its record on line 40 allows; reported only, timing fails on CI
budget note: internal/runner/forge took 25.221s, over the 20s its record on line 35 allows; reported only, timing fails on CI
budget note: internal/runner/provider/claude/realcli took 13.547s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/runner/provider/pi took 1m22.301s, over the 1m0s its record on line 27 allows; reported only, timing fails on CI
budget note: internal/runner/render took 1m29.554s, over the 10s the default allows; reported only, timing fails on CI
receipt: test step 2m30.189s against a 60s target (the gate's other steps are not in this figure)
receipt: 30 packages ran, 39 cached, 17 without tests, 2 failed
receipt: slow package 2m25.149s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 1m53.974s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 1m29.554s amadan.net/oficina/equipo/internal/runner/render
receipt: slow package 1m22.301s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 1m12.041s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow test 55.27s amadan.net/oficina/equipo/internal/idtest TestDoorRemembersOficinaID
receipt: slow test 50.29s amadan.net/oficina/equipo/internal/runner/render TestLaunchNeverClaimsAnUnprovenEnd
receipt: slow test 46.85s amadan.net/oficina/equipo/internal/idtest TestDoorOficinaSettingsUnreadableIsNoLoop
receipt: slow test 46.45s amadan.net/oficina/equipo/internal/idtest TestDoorStepUpIsLocal
receipt: slow test 45.76s amadan.net/oficina/equipo/internal/idtest TestDoorNeverJudgesANativeSession
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -v -run '^TestHoldStopsEveryWriter$' -count=1 ./internal/runner/pause (retry, once)
##############################################################################
FLAKE ./internal/runner/pause:TestHoldStopsEveryWriter rest 2c7782e69454566aa3700c4c9a1d1aeeef07fa86 10.06s 23.08
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
+ go test -tags testbuild -timeout 15m -v -run '^TestBudgetRecordsAreShort$' -count=1 ./internal/testci (retry, once)
FAILED TWICE ./internal/testci:TestBudgetRecordsAreShort rest
=== RUN TestBudgetRecordsAreShort
budgets_file_test.go:37: .rastrillo/budgets.txt:41: reason is 214 bytes, over 200
budgets_file_test.go:37: .rastrillo/budgets.txt:74: reason is 232 bytes, over 200
--- FAIL: TestBudgetRecordsAreShort (0.00s)
FAIL
rastrillo-budget/v1 ran 0s
FAIL amadan.net/oficina/equipo/internal/testci 0.004s
FAIL
machine: 32 CPUs, load 23.08, cpu waiting 9.92%, memory waiting 0.00%, io waiting 0.07%
make: *** [Makefile:113: ci-shard] Error 1
amadan: step check shard 17 of 29 failed: exit status 2
--- 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
receipt: test step 1m27.212s 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 1m25.296s amadan.net/oficina/equipo/internal/headless
receipt: slow test 39.19s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.93s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.83s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.49s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.74s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 64.34, cpu waiting 39.52%, memory waiting 0.00%, io waiting 0.38%
--- 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
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
rastrillo: budget test: go test failed
=== RUN TestBrowserRailFollowsWork
time=2026-11-28T21:25:12.630Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-28T21:25:12.630Z level=INFO msg="startup phase done" phase=state_lock took=191µs
time=2026-11-28T21:25:12.630Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-28T21:25:12.630Z level=INFO msg="startup phase done" phase=claim_roots took=351µs
time=2026-11-28T21:25:12.630Z level=INFO msg="startup phase" phase=sweep
time=2026-11-28T21:25:12.667Z level=INFO msg="startup phase done" phase=sweep took=36.442ms
time=2026-11-28T21:25:12.667Z level=INFO msg="startup phase" phase=credentials
time=2026-11-28T21:25:12.667Z level=INFO msg="startup phase done" phase=credentials took=219µs
time=2026-11-28T21:25:12.667Z level=INFO msg="startup phase" phase=open_state
time=2026-11-28T21:25:12.710Z level=INFO msg="startup phase done" phase=open_state took=42.536ms
time=2026-11-28T21:25:12.710Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-28T21:25:12.711Z level=INFO msg=connecting host=127.0.0.1:35817 protocol=35
time=2026-11-28T21:25:12.712Z level=INFO msg=connected host=127.0.0.1:35817 took=854µs
time=2026-11-28T21:25:12.712Z level=INFO msg="capabilities gathering"
time=2026-11-28T21:25:12.713Z level=INFO msg="capabilities gathered" took=422µs tags=linux,claude,go
time=2026-11-28T21:25:12.713Z level=INFO msg="hello sent" protocol=35
time=2026-11-28T21:25:12.719Z level=INFO msg=welcome protocol=35 role=primary generation=1
time=2026-11-28T21:25:13.708Z level=INFO msg="connection checked" connection=claude-1 state=healthy
time=2026-11-28T21:25:20.435Z level=INFO msg="kept sessions" kept=1 bytes=2885 expired=0
time=2026-11-28T21:25:24.869Z level=INFO msg="kept sessions" kept=2 bytes=5037 expired=0
time=2026-11-28T21:25:25.649Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-28T21:25:25.649Z level=INFO msg="startup phase done" phase=state_lock took=276µs
time=2026-11-28T21:25:25.649Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-28T21:25:25.649Z level=INFO msg="startup phase done" phase=claim_roots took=185µs
time=2026-11-28T21:25:25.649Z level=INFO msg="startup phase" phase=sweep
time=2026-11-28T21:25:25.696Z level=INFO msg="startup phase done" phase=sweep took=46.675ms
time=2026-11-28T21:25:25.696Z level=INFO msg="startup phase" phase=credentials
time=2026-11-28T21:25:25.696Z level=INFO msg="startup phase done" phase=credentials took=192µs
time=2026-11-28T21:25:25.696Z level=INFO msg="startup phase" phase=open_state
time=2026-11-28T21:25:25.746Z level=INFO msg="startup phase done" phase=open_state took=50.173ms
time=2026-11-28T21:25:25.747Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-28T21:25:25.748Z level=INFO msg=connecting host=127.0.0.1:34919 protocol=35
time=2026-11-28T21:25:25.751Z level=INFO msg=connected host=127.0.0.1:34919 took=3.69ms
time=2026-11-28T21:25:25.752Z level=INFO msg="capabilities gathering"
time=2026-11-28T21:25:25.752Z level=INFO msg="capabilities gathered" took=427µs tags=linux,claude,go
time=2026-11-28T21:25:25.752Z level=INFO msg="hello sent" protocol=35
time=2026-11-28T21:25:25.761Z level=INFO msg=welcome protocol=35 role=primary generation=1
time=2026-11-28T21:25:27.670Z level=INFO msg="connection checked" connection=claude-1 state=healthy
browser_review_test.go:57: waiting for document.querySelector('#rail [data-specialist="engineering"]')?.dataset.state==='working' && document.querySelector('#rail [data-specialist="engineering"]').querySelector('[equipo-nav-task]')?.textContent==='Slow sidebar change' && document.querySelector('#nav-tasks [data-count]')?.textContent==='1': context deadline exceeded (last evaluation: context deadline exceeded)
time=2026-11-28T21:25:31.929Z level=WARN msg="step account" err=cancelled
--- FAIL: TestBrowserRailFollowsWork (19.95s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m25.89s
FAIL amadan.net/oficina/equipo/internal/headless 86.085s
receipt: test step 1m27.513s 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.89s amadan.net/oficina/equipo/internal/headless
receipt: slow test 22.73s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 19.95s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 13.57s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 11.21s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
receipt: slow test 9.61s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' -v -run '^TestBrowserRailFollowsWork$' -count=1 ./internal/headless (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserRailFollowsWork browser-headless-work 2c7782e69454566aa3700c4c9a1d1aeeef07fa86 19.95s 64.34
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 51.65, cpu waiting 31.04%, memory waiting 0.00%, io waiting 0.25%
--- 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
receipt: test step 1m54.528s 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 1m52.662s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.75s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.42s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 12.9s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 11.33s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 11.27s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsSignInEmail
machine: 32 CPUs, load 48.16, cpu waiting 29.37%, memory waiting 0.00%, io waiting 0.23%
--- 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|TestBrowserCardAnswerSettlesAtBottom|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInEmail|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserCopyContinue
=== RUN TestBrowserCopyContinue
time=2026-11-28T21:25:35.713Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-28T21:25:35.713Z level=INFO msg="startup phase done" phase=state_lock took=91µs
time=2026-11-28T21:25:35.713Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-28T21:25:35.713Z level=INFO msg="startup phase done" phase=claim_roots took=76µs
time=2026-11-28T21:25:35.713Z level=INFO msg="startup phase" phase=sweep
time=2026-11-28T21:25:35.775Z level=INFO msg="startup phase done" phase=sweep took=61.666ms
time=2026-11-28T21:25:35.775Z level=INFO msg="startup phase" phase=credentials
time=2026-11-28T21:25:35.775Z level=INFO msg="startup phase done" phase=credentials took=171µs
time=2026-11-28T21:25:35.776Z level=INFO msg="startup phase" phase=open_state
time=2026-11-28T21:25:35.820Z level=INFO msg="startup phase done" phase=open_state took=44.362ms
time=2026-11-28T21:25:35.821Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-28T21:25:35.822Z level=INFO msg=connecting host=127.0.0.1:36985 protocol=35
time=2026-11-28T21:25:35.824Z level=INFO msg=connected host=127.0.0.1:36985 took=2.242ms
time=2026-11-28T21:25:35.824Z level=INFO msg="capabilities gathering"
time=2026-11-28T21:25:35.826Z level=INFO msg="capabilities gathered" took=2.049ms tags=linux,claude,go
time=2026-11-28T21:25:35.833Z level=INFO msg="hello sent" protocol=35
time=2026-11-28T21:25:35.835Z level=INFO msg=welcome protocol=35 role=primary generation=1
browser_copy_test.go:90: waiting for !document.querySelector('[data-copy-continue]'): context deadline exceeded (last evaluation: <nil>)
--- FAIL: TestBrowserCopyContinue (6.38s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m39.873s
FAIL amadan.net/oficina/equipo/internal/headless 100.089s
receipt: test step 1m41.725s 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 1m39.873s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.08s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 13.13s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.28s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 9.32s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.36s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserCardAnswerSettlesAtBottom|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInEmail|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserCopyContinue$' -count=1 ./internal/headless (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserCopyContinue browser-headless-rest 2c7782e69454566aa3700c4c9a1d1aeeef07fa86 6.38s 58.25
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 55.10, cpu waiting 32.97%, memory waiting 0.00%, io waiting 0.27%
--- shard 22 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-rest: ./internal/equipo
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserPreviewBlocksNavigation|TestBrowserPreviewPassExchange)$' ./internal/equipo
receipt: test step 4.282s 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.454s amadan.net/oficina/equipo/internal/equipo
receipt: slow test 1.84s amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewPassExchange
receipt: slow test 610ms amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewBlocksNavigation
browser lane browser-rest: ./internal/equipotest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserGitHubManifestCSP)$' ./internal/equipotest
receipt: test step 8.034s 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 6.305s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 6.3s amadan.net/oficina/equipo/internal/equipotest TestBrowserGitHubManifestCSP
browser lane browser-rest: ./internal/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor|TestBrowserSmartDoor)$' ./internal/idtest
budget note: internal/idtest took 11.659s, over the 10s the default allows; reported only, timing fails on CI
receipt: test step 13.214s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 11.659s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 9.39s amadan.net/oficina/equipo/internal/idtest TestBrowserSmartDoor
receipt: slow test 2.27s 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 3.934s 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.301s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 2.3s amadan.net/oficina/equipo/internal/plan3test TestTeamsHierarchyBrowser
browser lane browser-rest: ./internal/thintest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAccessEmojiByline|TestBrowserAccessFinalOutcomes|TestBrowserAccessRequest|TestBrowserAccessReview|TestBrowserActivitySubjects|TestBrowserAutonomySettings|TestBrowserCoordinatorQueue|TestBrowserEmptyConversation|TestBrowserEndedNoteStaysGone|TestBrowserHousekeeping|TestBrowserInnerGallery|TestBrowserInnerScreens|TestBrowserInstantThinking|TestBrowserInstantThinkingQueued|TestBrowserMachines|TestBrowserPausedWork|TestBrowserPhoneIndex|TestBrowserPlacementQuestionAndPending|TestBrowserProjectPlacement|TestBrowserProjectsList|TestBrowserReportActionFeedback|TestBrowserReportNextSteps|TestBrowserReportThread|TestBrowserRhythm|TestBrowserRollup|TestBrowserRosterAlignment|TestBrowserRosterDecisionStates|TestBrowserRosterQuietDay|TestBrowserRosterReports|TestBrowserRosterSetAside|TestBrowserRosterSubchat|TestBrowserRosterThinking|TestBrowserRosterVisual|TestBrowserSettingsHousekeepingGroups|TestBrowserSettingsMenu|TestBrowserSettingsRail|TestBrowserSettingsSaveBar|TestBrowserSettingsShots|TestBrowserSettingsStayOnPage|TestBrowserSettingsTeams|TestBrowserShipsButtons|TestBrowserSpecialistRows|TestBrowserSpendFollowsAnswers|TestBrowserTaskRows|TestBrowserTeamPanel|TestBrowserThinkingCycles|TestBrowserThinkingLinesClear|TestBrowserThinkingSteady|TestBrowserThinkingWords|TestBrowserTokenRowEmail|TestBrowserTrackPulse|TestBrowserTrackStarCentre|TestBrowserTryAgain)$' ./internal/thintest
receipt: test step 3m35.403s 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 3m32.246s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 25.9s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.41s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.08s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.62s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.08s amadan.net/oficina/equipo/internal/thintest TestBrowserRhythm
machine: 32 CPUs, load 9.37, cpu waiting 3.42%, memory waiting 0.00%, io waiting 0.02%
--- 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 (54s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 4.75s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.23s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 9.09s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.11s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 27.46s
+ 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 (58s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 13.75s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 12.28s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 10.80s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 18.98s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (22s)
ok ./internal/headless TestMixedVersions 19.48s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.81s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin (2s)
first attempt failed: TestRunnerCancelAndSupersede; output tail:
=== RUN TestRunnerCancelAndSupersede
time=2026-11-28T21:24:49.090Z level=INFO msg=connecting host=127.0.0.1:37529 protocol=35
time=2026-11-28T21:24:49.091Z level=INFO msg=connected host=127.0.0.1:37529 took=688µs
time=2026-11-28T21:24:49.092Z level=INFO msg="hello sent" protocol=35
time=2026-11-28T21:24:49.092Z level=INFO msg=welcome protocol=1 role=primary generation=3
contract_test.go:289: waiting for ack, got {"id":"rkxgzddt5ab-1","type":"turn","data":{"turn_id":"t_wait","attempt":1,"state":"cancelled","reason":"cancelled"}}
--- FAIL: TestRunnerCancelAndSupersede (0.07s)
FAIL
rastrillo-budget/v1 ran 72ms
FAIL amadan.net/oficina/equipo/internal/runner/thin 0.094s
FAIL
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' -count=1 ./internal/runner/thin (retry, once)
##############################################################################
FLAKE ./internal/runner/thin:TestRunnerCancelAndSupersede quarantine 2c7782e69454566aa3700c4c9a1d1aeeef07fa86 0.07s 12.61
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
quarantine: 1 flaked (passed on the retry), 0 failed
quarantine flake: TestRunnerCancelAndSupersede
machine: 32 CPUs, load 66.54, cpu waiting 38.91%, memory waiting 0.00%, io waiting 0.61%
--- 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 12.871s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 4 without tests, 0 failed
receipt: slow package 7.469s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 196ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 85ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 2ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 2ms amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 5.22s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.73s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 400ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 200ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 100ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxToolchain
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 4.192s 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 3.134s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 290ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 220ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryMalformedRecord
machine: 32 CPUs, load 25.45, cpu waiting 11.02%, memory waiting 0.00%, io waiting 1.25%
--- 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 40.1%, load 31.02
shard 25: make runner-dead-references lanes-check build vet fmt-check spacing budget migration-check
python3 scripts/runner-dead-references.py
docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1.md:109:5: unclassified equipo-runner
docs/superpowers/plans/CONTROLLER-BRIEF-specialists-slice-1.md:84:25: unclassified Paseo
docs/superpowers/specs/2026-11-28-dynamic-specialists.md:224:15: unclassified equipo-runner
internal/runner/render/driver.go:302:3: unclassified Node
internal/runner/render/driver.go:302:13: unclassified Node
internal/runner/render/driver.go:302:25: unclassified node
internal/runner/render/driver.go:307:39: unclassified Node
internal/runner/render/driver_test.go:89:30: unclassified node
internal/runner/render/driver_test.go:90:20: unclassified node
internal/runner/render/driver_test.go:91:20: unclassified node
internal/runner/render/health_test.go:38:37: unclassified equipo-runner
internal/runner/render/page.go:351:6: unclassified Node
internal/runner/render/page.go:351:18: unclassified node
internal/runner/render/page.go:352:8: unclassified Node
internal/runner/render/page.go:353:2: unclassified Node
internal/runner/render/page.go:353:27: unclassified node
internal/runner/render/page.go:376:9: unclassified Node
internal/runner/render/page.go:376:26: unclassified node
internal/runner/render/page.go:379:7: unclassified Node
internal/runner/render/page.go:383:62: unclassified node
internal/runner/render/page.go:384:66: unclassified node
internal/runner/render/page.go:388:24: unclassified node
internal/runner/render/page.go:390:14: unclassified node
internal/runner/render/page.go:390:24: unclassified Node
internal/runner/render/page.go:391:9: unclassified node
internal/runner/render/page.go:391:23: unclassified Node
internal/runner/render/page.go:392:3: unclassified node
internal/runner/render/page.go:392:16: unclassified node
internal/runner/render/page.go:392:28: unclassified Node
internal/runner/render/page.go:394:36: unclassified node
internal/runner/render/page.go:395:20: unclassified node
internal/runner/render/page.go:396:24: unclassified Node
internal/runner/render/page.go:396:43: unclassified Node
internal/runner/render/page.go:397:12: unclassified Node
internal/runner/render/page.go:401:20: unclassified node
internal/runner/render/page.go:414:27: unclassified node
internal/runner/render/page.go:424:8: unclassified node
internal/runner/render/page.go:448:24: unclassified Node
internal/runner/render/page_test.go:197:77: unclassified Node
internal/runner/render/page_test.go:198:9: unclassified Node
internal/runner/render/page_test.go:198:14: unclassified Node
internal/runner/render/page_test.go:208:41: unclassified node
internal/runner/render/page_test.go:211:2: unclassified node
internal/runner/render/page_test.go:211:15: unclassified Node
internal/runner/render/page_test.go:221:23: unclassified node
internal/runner/render/page_test.go:227:13: unclassified Node
internal/runner/render/page_test.go:245:11: unclassified node
internal/runner/render/page_test.go:246:14: unclassified Node
internal/runner/render/report.go:151:44: unclassified node
internal/runner/thin/worksnap_linux.go:98:5: unclassified node
reference scan: 3064 text files, 3318 matches, 50 failures
make[1]: *** [Makefile:238: runner-dead-references] Error 1
machine: 32 CPUs, load 34.06, cpu waiting 17.83%, memory waiting 0.00%, io waiting 0.99%
make: *** [Makefile:113: ci-shard] Error 2
amadan: step check shard 25 of 29 failed: exit status 2
--- 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 41.9%, load 34.06
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 66.54, cpu waiting 38.06%, memory waiting 0.00%, io waiting 0.64%
--- 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 40.1%, load 34.06
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 1 vulnerability in packages you import and 10
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 59.54, cpu waiting 35.72%, memory waiting 0.00%, io waiting 0.68%
--- 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 40.1%, load 31.02
shard 28: make gitleaks
[90m9:25PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m9:25PM[0m [32mINF[0m [1m1279 commits scanned.[0m
[90m9:25PM[0m [32mINF[0m [1mscanned ~69356458 bytes (69.36 MB) in 27.4s[0m
[90m9:25PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 66.54, cpu waiting 38.06%, memory waiting 0.00%, io waiting 0.64%
amadan: job failed at step check shards 12, 17, 25 of 29 — its output is above, not at the tail of this log
diff --git a/internal/runner/pause/pause.go b/internal/runner/pause/pause.go| new file mode 100644 |
| index 00000000..beca1b45 |
| --- /dev/null |
| +++ b/internal/runner/pause/pause.go |
| @@ -0,0 +1,39 @@ |
| +// Package pause holds every process of a step's sandbox stopped while the |
| +// runner reads the sandbox's workspace (spec §3, "What it renders"; plan |
| +// task 9). |
| +// |
| +// The pause is signals only: SIGSTOP to every descendant of the sandbox's |
| +// first process, rescanning /proc until each one reads stopped, and |
| +// SIGCONT to all of them on every way out. No cgroup is frozen: freezing a |
| +// slice systemd spawns into once stalled PID 1. |
| +package pause |
| + |
| +import ( |
| + "errors" |
| + "time" |
| +) |
| + |
| +// Bound is the longest a sandbox stays paused: stopping it and the work |
| +// done inside the pause together (spec §3: "at most 10 seconds"). |
| +const Bound = 10 * time.Second |
| + |
| +// Process is a sandbox's first process as containment recorded it when it |
| +// started: its host pid, its start time in clock ticks (field 22 of |
| +// /proc/<pid>/stat) and its pid namespace link ("pid:[...]"; "" skips |
| +// that check). |
| +type Process struct { |
| + PID int |
| + StartTicks uint64 |
| + Namespace string |
| +} |
| + |
| +var ( |
| + // ErrBusy: the sandbox could not be held stopped within the bound, or |
| + // the work inside the pause ran past it. Everything is resumed. |
| + ErrBusy = errors.New("sandbox could not be paused in time") |
| + // ErrGone: the recorded first process is no longer the one running |
| + // at that pid (it exited, or the pid was reused). Nothing is signalled. |
| + ErrGone = errors.New("sandbox process is gone") |
| + // ErrUnsupported: this system has no pause (only Linux does). |
| + ErrUnsupported = errors.New("pausing a sandbox is not supported on this system") |
| +) |
diff --git a/internal/runner/pause/pause_linux.go b/internal/runner/pause/pause_linux.go| new file mode 100644 |
| index 00000000..faa45cd0 |
| --- /dev/null |
| +++ b/internal/runner/pause/pause_linux.go |
| @@ -0,0 +1,348 @@ |
| +//go:build linux |
| + |
| +package pause |
| + |
| +import ( |
| + "bytes" |
| + "errors" |
| + "fmt" |
| + "os" |
| + "strconv" |
| + "strings" |
| + "sync" |
| + "time" |
| + |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// maxMembers bounds the processes one pause holds (each holds a pidfd); |
| +// a sandbox with more is refused with ErrBusy. |
| +const maxMembers = 4096 |
| + |
| +// rescanEvery paces the passes over /proc while the sandbox stops. |
| +const rescanEvery = time.Millisecond |
| + |
| +// Hold stops every process of the sandbox whose first process is p, calls |
| +// fn while all of them are stopped, and resumes them on every way out: |
| +// fn's return, its panic, or the bound passing. bound covers both the |
| +// stopping and fn. When the bound passes first, the sandbox is resumed at |
| +// once (fn may still be running) and Hold returns ErrBusy after fn |
| +// returns: whatever fn read is not a paused read. fn gets the deadline so |
| +// it can give up early. |
| +// |
| +// The descendants are found from /proc: every process whose parent chain |
| +// reaches p, each child started no earlier than its parent and in p's pid |
| +// namespace or one nested in it, so a reused pid is not taken for one. |
| +// Each is opened as a pidfd, checked against the start time the scan saw, |
| +// and signalled through that pidfd only, so SIGSTOP and SIGCONT reach that |
| +// exact process or none. The passes repeat until one full pass finds no |
| +// new process and every thread of every one reads stopped (T or t) or |
| +// dead (Z or X) in /proc/<pid>/task/<tid>/stat. |
| +func Hold(p Process, bound time.Duration, fn func(deadline time.Time) error) error { |
| + deadline := time.Now().Add(bound) |
| + h := &held{members: map[member]int{}} |
| + // Every way out resumes, a panic in fn included: deferred calls run |
| + // while a panic unwinds, before it goes on up. |
| + defer h.resume() |
| + watchdog := time.AfterFunc(bound, func() { h.resume() }) |
| + defer watchdog.Stop() |
| + if err := h.stop(p, deadline); err != nil { |
| + return err |
| + } |
| + err := fn(deadline) |
| + if !h.resume() { |
| + // The watchdog resumed the sandbox while fn ran. |
| + return ErrBusy |
| + } |
| + return err |
| +} |
| + |
| +// member is one process as the scan saw it: its pid and start time. |
| +type member struct { |
| + pid int |
| + start uint64 |
| +} |
| + |
| +type held struct { |
| + mu sync.Mutex |
| + // members maps every process signalled SIGSTOP to its pidfd. |
| + members map[member]int |
| + resumed bool |
| +} |
| + |
| +// resume sends SIGCONT to every process stopped, through its pidfd, and |
| +// closes them. Only the first call does anything; it reports whether this |
| +// call was that one. |
| +func (h *held) resume() bool { |
| + h.mu.Lock() |
| + defer h.mu.Unlock() |
| + if h.resumed { |
| + return false |
| + } |
| + h.resumed = true |
| + for _, fd := range h.members { |
| + // ESRCH: it exited. Nothing else can fail for a process this |
| + // pidfd already stopped. |
| + unix.PidfdSendSignal(fd, unix.SIGCONT, nil, 0) |
| + unix.Close(fd) |
| + } |
| + h.members = nil |
| + return true |
| +} |
| + |
| +// stop signals SIGSTOP until the whole sandbox reads stopped. |
| +func (h *held) stop(p Process, deadline time.Time) error { |
| + if err := h.stopRoot(p); err != nil { |
| + return err |
| + } |
| + for { |
| + if !time.Now().Before(deadline) { |
| + return ErrBusy |
| + } |
| + tree, err := descendants(p) |
| + if err != nil { |
| + return err |
| + } |
| + settled, err := h.pass(tree) |
| + if err != nil || settled { |
| + return err |
| + } |
| + time.Sleep(rescanEvery) |
| + } |
| +} |
| + |
| +// stopRoot checks that p is still the recorded process (its start time |
| +// and namespace, read after its pidfd is open so the pid cannot be reused |
| +// in between) and stops it first. |
| +func (h *held) stopRoot(p Process) error { |
| + if p.PID <= 0 || p.StartTicks == 0 { |
| + return ErrGone |
| + } |
| + fd, err := unix.PidfdOpen(p.PID, 0) |
| + if err != nil { |
| + return ErrGone |
| + } |
| + _, _, start, err := readStat(fmt.Sprintf("/proc/%d/stat", p.PID)) |
| + if err == nil && p.Namespace != "" { |
| + var ns string |
| + if ns, err = os.Readlink(fmt.Sprintf("/proc/%d/ns/pid", p.PID)); err == nil && ns != p.Namespace { |
| + err = ErrGone |
| + } |
| + } |
| + if err != nil || start != p.StartTicks { |
| + unix.Close(fd) |
| + return ErrGone |
| + } |
| + return h.signal(member{p.PID, start}, fd) |
| +} |
| + |
| +// signal keeps fd as m's pidfd and sends it SIGSTOP; it refuses once the |
| +// sandbox has been resumed, so the watchdog's resume is never undone. |
| +func (h *held) signal(m member, fd int) error { |
| + h.mu.Lock() |
| + defer h.mu.Unlock() |
| + if h.resumed { |
| + unix.Close(fd) |
| + return ErrBusy |
| + } |
| + if len(h.members) >= maxMembers { |
| + unix.Close(fd) |
| + return ErrBusy |
| + } |
| + // Kept before the signal, so resume covers it whatever happens next. |
| + h.members[m] = fd |
| + if err := unix.PidfdSendSignal(fd, unix.SIGSTOP, nil, 0); err != nil && err != unix.ESRCH { |
| + return ErrBusy |
| + } |
| + return nil |
| +} |
| + |
| +// pass stops each process of tree not yet stopped and reports whether |
| +// the sandbox is settled: no new process, and every thread stopped. |
| +func (h *held) pass(tree []proc) (bool, error) { |
| + settled := true |
| + for _, d := range tree { |
| + m := member{d.pid, d.start} |
| + h.mu.Lock() |
| + fd, known := h.members[m] |
| + resumed := h.resumed |
| + h.mu.Unlock() |
| + if resumed { |
| + return false, ErrBusy |
| + } |
| + if !known { |
| + settled = false |
| + fd, err := unix.PidfdOpen(d.pid, 0) |
| + if err == unix.ESRCH { |
| + continue // exited since the scan |
| + } |
| + if err != nil { |
| + return false, ErrBusy |
| + } |
| + // The pid may have been reused between the scan and the open: |
| + // the pidfd names whatever holds it now. |
| + if _, _, start, err := readStat(fmt.Sprintf("/proc/%d/stat", d.pid)); err != nil || start != d.start { |
| + unix.Close(fd) |
| + continue |
| + } |
| + if err := h.signal(m, fd); err != nil { |
| + return false, err |
| + } |
| + continue |
| + } |
| + if !allStopped(d, fd) { |
| + settled = false |
| + // Again: a thread may have been mid-call; SIGSTOP is idempotent. |
| + if err := unix.PidfdSendSignal(fd, unix.SIGSTOP, nil, 0); err != nil && err != unix.ESRCH { |
| + return false, ErrBusy |
| + } |
| + } |
| + } |
| + return settled, nil |
| +} |
| + |
| +// allStopped: every thread of d reads stopped or dead, or d (its pidfd |
| +// fd) has exited. Anything unreadable for another reason counts as running. |
| +func allStopped(d proc, fd int) bool { |
| + dir := fmt.Sprintf("/proc/%d/task", d.pid) |
| + tasks, err := os.ReadDir(dir) |
| + if err != nil { |
| + return exited(fd) |
| + } |
| + for _, task := range tasks { |
| + state, _, start, err := readStat(dir + "/" + task.Name() + "/stat") |
| + if errors.Is(err, os.ErrNotExist) { |
| + continue // that thread exited |
| + } |
| + if err != nil { |
| + return false |
| + } |
| + if task.Name() == strconv.Itoa(d.pid) && start != d.start { |
| + return exited(fd) |
| + } |
| + switch state { |
| + case 'T', 't', 'Z', 'X': |
| + default: |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +// exited reports whether the process behind pidfd fd has exited (a pidfd |
| +// polls readable then). |
| +func exited(fd int) bool { |
| + polls := []unix.PollFd{{Fd: int32(fd), Events: unix.POLLIN}} |
| + n, err := unix.Poll(polls, 0) |
| + return err == nil && n > 0 && polls[0].Revents&unix.POLLIN != 0 |
| +} |
| + |
| +// proc is one process of the sandbox as one scan of /proc saw it. |
| +type proc struct { |
| + pid, depth int |
| + start uint64 |
| +} |
| + |
| +// descendants scans /proc once and returns p and every process whose |
| +// parent chain reaches it. A child counts only when it started no earlier |
| +// than its parent and its pid namespace is p's or one nested in it (as |
| +// deep as p's or deeper, by NSpid), so a pid reused while the scan reads |
| +// is not taken for a member. |
| +func descendants(p Process) ([]proc, error) { |
| + d, err := os.Open("/proc") |
| + if err != nil { |
| + return nil, ErrBusy |
| + } |
| + names, err := d.Readdirnames(-1) |
| + d.Close() |
| + if err != nil { |
| + return nil, ErrBusy |
| + } |
| + type entry struct { |
| + ppid int |
| + start uint64 |
| + } |
| + all := map[int]entry{} |
| + children := map[int][]int{} |
| + for _, name := range names { |
| + pid, err := strconv.Atoi(name) |
| + if err != nil || pid <= 0 { |
| + continue |
| + } |
| + _, ppid, start, err := readStat("/proc/" + name + "/stat") |
| + if err != nil { |
| + continue // exited while the scan read |
| + } |
| + all[pid] = entry{ppid, start} |
| + children[ppid] = append(children[ppid], pid) |
| + } |
| + root, ok := all[p.PID] |
| + if !ok || root.start != p.StartTicks { |
| + return nil, ErrGone |
| + } |
| + rootDepth := nsDepth(p.PID) |
| + if rootDepth == 0 { |
| + return nil, ErrGone |
| + } |
| + tree := []proc{{pid: p.PID, start: root.start, depth: rootDepth}} |
| + for i := 0; i < len(tree); i++ { |
| + parent := tree[i] |
| + for _, c := range children[parent.pid] { |
| + e := all[c] |
| + if e.start < parent.start { |
| + continue |
| + } |
| + depth := nsDepth(c) |
| + if depth < rootDepth { |
| + continue |
| + } |
| + tree = append(tree, proc{pid: c, start: e.start, depth: depth}) |
| + if len(tree) > maxMembers { |
| + return nil, ErrBusy |
| + } |
| + } |
| + } |
| + return tree, nil |
| +} |
| + |
| +// nsDepth is how many pid namespaces pid sits in, from ours down (the |
| +// fields of NSpid in /proc/<pid>/status); 0 when it cannot be read. |
| +func nsDepth(pid int) int { |
| + raw, err := os.ReadFile(fmt.Sprintf("/proc/%d/status", pid)) |
| + if err != nil { |
| + return 0 |
| + } |
| + for _, line := range strings.Split(string(raw), "\n") { |
| + if rest, ok := strings.CutPrefix(line, "NSpid:"); ok { |
| + return len(strings.Fields(rest)) |
| + } |
| + } |
| + return 0 |
| +} |
| + |
| +var errStat = errors.New("unreadable stat") |
| + |
| +// readStat reads a /proc stat file: the state (field 3), the parent pid |
| +// (field 4) and the start time in clock ticks (field 22). The command name |
| +// (field 2) may hold anything, so fields are counted after its last ')'. |
| +func readStat(path string) (state byte, ppid int, start uint64, err error) { |
| + raw, err := os.ReadFile(path) |
| + if err != nil { |
| + return 0, 0, 0, err |
| + } |
| + end := bytes.LastIndexByte(raw, ')') |
| + if end < 0 { |
| + return 0, 0, 0, errStat |
| + } |
| + f := strings.Fields(string(raw[end+1:])) |
| + if len(f) < 20 || len(f[0]) != 1 { |
| + return 0, 0, 0, errStat |
| + } |
| + if ppid, err = strconv.Atoi(f[1]); err != nil { |
| + return 0, 0, 0, errStat |
| + } |
| + if start, err = strconv.ParseUint(f[19], 10, 64); err != nil { |
| + return 0, 0, 0, errStat |
| + } |
| + return f[0][0], ppid, start, nil |
| +} |
diff --git a/internal/runner/pause/pause_linux_test.go b/internal/runner/pause/pause_linux_test.go| new file mode 100644 |
| index 00000000..550ec124 |
| --- /dev/null |
| +++ b/internal/runner/pause/pause_linux_test.go |
| @@ -0,0 +1,418 @@ |
| +//go:build linux |
| + |
| +package pause |
| + |
| +import ( |
| + "bytes" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strconv" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// writerBody appends a counter to $DIR/$0 about every millisecond, each |
| +// pass forking a sleep: a writer that also keeps making new processes. |
| +const writerBody = `i=0; while :; do i=$((i+1)); echo $i >> "$DIR/$0"; sleep 0.001; done` |
| + |
| +// writers are the files the sandbox's writers append to: one a child of |
| +// the sandbox's first process, one inside a nested user and pid namespace |
| +// made by unshare, one inside a nested bubblewrap sandbox. |
| +var writers = []string{"direct", "unshare", "bwrap"} |
| + |
| +// A nested start that fails (a busy shared host) is tried again. |
| +const writersScript = `sh -c "$W" direct & |
| +until unshare --user --pid --fork sh -c "$W" unshare; do sleep 0.1; done & |
| +until bwrap --dev-bind / / --unshare-user --unshare-pid --die-with-parent sh -c "$W" bwrap; do sleep 0.1; done & |
| +wait` |
| + |
| +// sandbox starts script as the first process of a bubblewrap sandbox made |
| +// with the step sandbox's namespace arguments (provider.NamespaceArguments: |
| +// --unshare-pid, --new-session, --as-pid-1, --json-status-fd 3), and |
| +// returns that process as containment records it. The sandbox is killed |
| +// when the test ends. |
| +func sandbox(t *testing.T, dir, script string) Process { |
| + t.Helper() |
| + bwrap, err := exec.LookPath("bwrap") |
| + if err != nil { |
| + t.Skip("no bwrap") |
| + } |
| + for _, tool := range []string{"sh", "unshare", "sleep"} { |
| + if _, err := exec.LookPath(tool); err != nil { |
| + t.Skipf("no %s", tool) |
| + } |
| + } |
| + status, statusW, err := os.Pipe() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer status.Close() |
| + // A /proc of the sandbox's own pid namespace, as the step sandbox has: |
| + // the nested bwrap reads its own pid there. |
| + args := append([]string{"--dev-bind", "/", "/", "--proc", "/proc"}, provider.NamespaceArguments()...) |
| + cmd := exec.Command(bwrap, append(args, "sh", "-c", script)...) |
| + cmd.Env = []string{"PATH=/usr/bin:/bin", "DIR=" + dir, "W=" + writerBody} |
| + cmd.ExtraFiles = []*os.File{statusW} |
| + stderr := &lockedBuffer{} |
| + cmd.Stderr = stderr |
| + t.Cleanup(func() { |
| + if t.Failed() { |
| + t.Logf("sandbox stderr: %s", stderr.String()) |
| + } |
| + }) |
| + if err := cmd.Start(); err != nil { |
| + t.Fatal(err) |
| + } |
| + statusW.Close() |
| + var msg struct { |
| + PID int `json:"child-pid"` |
| + } |
| + status.SetReadDeadline(time.Now().Add(10 * time.Second)) |
| + if err := json.NewDecoder(status).Decode(&msg); err != nil || msg.PID <= 1 { |
| + cmd.Process.Kill() |
| + cmd.Wait() |
| + t.Skipf("bwrap did not start a sandbox here: %v", err) |
| + } |
| + fd, err := unix.PidfdOpen(msg.PID, 0) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { |
| + // SIGKILL to the namespace's init ends every process in it and in |
| + // the namespaces nested inside, stopped or not. |
| + unix.PidfdSendSignal(fd, unix.SIGKILL, nil, 0) |
| + unix.Close(fd) |
| + cmd.Process.Kill() |
| + cmd.Wait() |
| + }) |
| + _, _, start, err := readStat(fmt.Sprintf("/proc/%d/stat", msg.PID)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ns, err := os.Readlink(fmt.Sprintf("/proc/%d/ns/pid", msg.PID)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return Process{PID: msg.PID, StartTicks: start, Namespace: ns} |
| +} |
| + |
| +type lockedBuffer struct { |
| + mu sync.Mutex |
| + b bytes.Buffer |
| +} |
| + |
| +func (l *lockedBuffer) Write(p []byte) (int, error) { |
| + l.mu.Lock() |
| + defer l.mu.Unlock() |
| + if l.b.Len() > 64<<10 { |
| + return len(p), nil |
| + } |
| + return l.b.Write(p) |
| +} |
| + |
| +func (l *lockedBuffer) String() string { |
| + l.mu.Lock() |
| + defer l.mu.Unlock() |
| + return l.b.String() |
| +} |
| + |
| +func sizes(dir string) map[string]int64 { |
| + out := map[string]int64{} |
| + for _, w := range writers { |
| + if info, err := os.Stat(filepath.Join(dir, w)); err == nil { |
| + out[w] = info.Size() |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// allGrowing waits until every writer's file grows, and fails the test |
| +// with the ones that did not. |
| +func allGrowing(t *testing.T, dir string, within time.Duration) { |
| + t.Helper() |
| + before := sizes(dir) |
| + deadline := time.Now().Add(within) |
| + for { |
| + now := sizes(dir) |
| + var still []string |
| + for _, w := range writers { |
| + if now[w] == 0 || now[w] == before[w] { |
| + still = append(still, w) |
| + } |
| + } |
| + if len(still) == 0 { |
| + return |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("writers made no progress in %s: %v (sizes %v)", within, still, now) |
| + } |
| + time.Sleep(5 * time.Millisecond) |
| + } |
| +} |
| + |
| +// movedOver reports the writers whose files changed over d. |
| +func movedOver(dir string, d time.Duration) []string { |
| + before := sizes(dir) |
| + time.Sleep(d) |
| + after := sizes(dir) |
| + var moved []string |
| + for _, w := range writers { |
| + if after[w] != before[w] { |
| + moved = append(moved, fmt.Sprintf("%s %d->%d", w, before[w], after[w])) |
| + } |
| + } |
| + return moved |
| +} |
| + |
| +func writerSandbox(t *testing.T) (Process, string) { |
| + dir := t.TempDir() |
| + p := sandbox(t, dir, writersScript) |
| + allGrowing(t, dir, 10*time.Second) |
| + return p, dir |
| +} |
| + |
| +// Plan task 9: a writer that appends a counter every millisecond, from a |
| +// nested namespace too, makes no progress between pause and resume, and |
| +// all of them go on after. |
| +func TestHoldStopsEveryWriter(t *testing.T) { |
| + p, dir := writerSandbox(t) |
| + var moved []string |
| + called := false |
| + err := Hold(p, Bound, func(deadline time.Time) error { |
| + called = true |
| + if time.Until(deadline) <= 0 || time.Until(deadline) > Bound { |
| + t.Errorf("deadline %s away", time.Until(deadline)) |
| + } |
| + moved = movedOver(dir, 300*time.Millisecond) |
| + return nil |
| + }) |
| + if err != nil || !called { |
| + t.Fatalf("Hold: %v (called %v)", err, called) |
| + } |
| + if len(moved) > 0 { |
| + t.Fatalf("writers ran while paused: %v", moved) |
| + } |
| + allGrowing(t, dir, 2*time.Second) |
| +} |
| + |
| +// fn's error comes back as Hold's, after everything is resumed. |
| +func TestHoldReturnsWorkError(t *testing.T) { |
| + p, dir := writerSandbox(t) |
| + want := errors.New("work failed") |
| + if err := Hold(p, Bound, func(time.Time) error { return want }); err != want { |
| + t.Fatalf("Hold: %v", err) |
| + } |
| + allGrowing(t, dir, 2*time.Second) |
| +} |
| + |
| +// A panic inside the pause resumes every process before it goes on up. |
| +func TestHoldResumesAfterPanic(t *testing.T) { |
| + p, dir := writerSandbox(t) |
| + var moved []string |
| + func() { |
| + defer func() { |
| + if r := recover(); r != "injected" { |
| + t.Fatalf("recovered %v", r) |
| + } |
| + }() |
| + Hold(p, Bound, func(time.Time) error { |
| + moved = movedOver(dir, 100*time.Millisecond) |
| + panic("injected") |
| + }) |
| + t.Fatal("Hold returned past the panic") |
| + }() |
| + if len(moved) > 0 { |
| + t.Fatalf("writers ran while paused: %v", moved) |
| + } |
| + allGrowing(t, dir, 2*time.Second) |
| +} |
| + |
| +// Past the bound the sandbox is resumed even while the work still runs, |
| +// and Hold refuses with ErrBusy once the work returns. |
| +func TestHoldResumesAtTheBound(t *testing.T) { |
| + p, dir := writerSandbox(t) |
| + var early, late []string |
| + start := time.Now() |
| + err := Hold(p, 800*time.Millisecond, func(time.Time) error { |
| + early = movedOver(dir, 200*time.Millisecond) |
| + time.Sleep(time.Until(start.Add(900 * time.Millisecond))) |
| + // The work is still running here, past the bound. |
| + late = movedOver(dir, 300*time.Millisecond) |
| + return nil |
| + }) |
| + if !errors.Is(err, ErrBusy) { |
| + t.Fatalf("Hold past its bound: %v", err) |
| + } |
| + if len(early) > 0 { |
| + t.Fatalf("writers ran while paused: %v", early) |
| + } |
| + if len(late) != len(writers) { |
| + t.Fatalf("writers not resumed at the bound while the work ran on: moved %v", late) |
| + } |
| + allGrowing(t, dir, 2*time.Second) |
| +} |
| + |
| +// A bound too short to stop the sandbox refuses with ErrBusy without |
| +// calling the work, and leaves nothing stopped. |
| +func TestHoldBusyWhenStoppingRunsOut(t *testing.T) { |
| + p, dir := writerSandbox(t) |
| + called := false |
| + err := Hold(p, time.Nanosecond, func(time.Time) error { called = true; return nil }) |
| + if !errors.Is(err, ErrBusy) || called { |
| + t.Fatalf("Hold: %v (called %v)", err, called) |
| + } |
| + allGrowing(t, dir, 2*time.Second) |
| + if s := stoppedIn(t, p); len(s) > 0 { |
| + t.Fatalf("left stopped: %v", s) |
| + } |
| +} |
| + |
| +// A recorded process that is not the one at that pid (another start |
| +// time, another namespace, or none) is refused with ErrGone, and nothing |
| +// is stopped. |
| +func TestHoldRefusesAnotherProcess(t *testing.T) { |
| + p, dir := writerSandbox(t) |
| + for name, q := range map[string]Process{ |
| + "start time": {PID: p.PID, StartTicks: p.StartTicks + 1, Namespace: p.Namespace}, |
| + "namespace": {PID: p.PID, StartTicks: p.StartTicks, Namespace: "pid:[1]"}, |
| + "no process": {PID: 1 << 30, StartTicks: p.StartTicks}, |
| + "zero": {}, |
| + } { |
| + called := false |
| + err := Hold(q, Bound, func(time.Time) error { called = true; return nil }) |
| + if !errors.Is(err, ErrGone) || called { |
| + t.Errorf("%s: Hold %v (called %v)", name, err, called) |
| + } |
| + } |
| + allGrowing(t, dir, 2*time.Second) |
| +} |
| + |
| +// After Hold, no process of the sandbox is left stopped. |
| +func TestHoldLeavesNothingStopped(t *testing.T) { |
| + p, _ := writerSandbox(t) |
| + if err := Hold(p, Bound, func(time.Time) error { return nil }); err != nil { |
| + t.Fatal(err) |
| + } |
| + // SIGCONT is delivered at once; give the scheduler a moment. |
| + deadline := time.Now().Add(2 * time.Second) |
| + for { |
| + s := stoppedIn(t, p) |
| + if len(s) == 0 { |
| + return |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("left stopped: %v", s) |
| + } |
| + time.Sleep(10 * time.Millisecond) |
| + } |
| +} |
| + |
| +// stoppedIn lists the sandbox's tasks that read stopped. |
| +func stoppedIn(t *testing.T, p Process) []string { |
| + t.Helper() |
| + tree, err := descendants(p) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var out []string |
| + for _, d := range tree { |
| + tasks, _ := os.ReadDir(fmt.Sprintf("/proc/%d/task", d.pid)) |
| + for _, task := range tasks { |
| + state, _, _, err := readStat(fmt.Sprintf("/proc/%d/task/%s/stat", d.pid, task.Name())) |
| + if err == nil && (state == 'T' || state == 't') { |
| + out = append(out, strconv.Itoa(d.pid)+"/"+task.Name()) |
| + } |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// readStat parses the fields Hold reads from a stat file. |
| +func TestReadStat(t *testing.T) { |
| + dir := t.TempDir() |
| + // A command name may hold spaces and parentheses. |
| + line := "4242 (a) b (c) S 17 4242 4242 0 -1 4194560 1 0 0 0 0 0 0 0 20 0 1 0 987654 1 1" |
| + path := filepath.Join(dir, "stat") |
| + if err := os.WriteFile(path, []byte(line+"\n"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + state, ppid, start, err := readStat(path) |
| + if err != nil || state != 'S' || ppid != 17 || start != 987654 { |
| + t.Fatalf("readStat: %c %d %d %v", state, ppid, start, err) |
| + } |
| + for _, bad := range []string{"", "1 (x", "1 (x) S", "1 (x) S 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 notanumber"} { |
| + os.WriteFile(path, []byte(bad), 0o600) |
| + if _, _, _, err := readStat(path); err == nil { |
| + t.Errorf("readStat accepted %q", bad) |
| + } |
| + } |
| +} |
| + |
| +// A pass is settled only once every member reads stopped: a member still |
| +// running (here one held but never signalled) keeps it unsettled and is |
| +// sent SIGSTOP again, and a sleeping process does not count as stopped. |
| +func TestPassWaitsForStopped(t *testing.T) { |
| + cmd := exec.Command("sleep", "30") |
| + if err := cmd.Start(); err != nil { |
| + t.Skip("no sleep") |
| + } |
| + defer func() { cmd.Process.Kill(); cmd.Wait() }() |
| + pid := cmd.Process.Pid |
| + var start uint64 |
| + for deadline := time.Now().Add(2 * time.Second); ; { |
| + state, _, s, err := readStat(fmt.Sprintf("/proc/%d/stat", pid)) |
| + if err == nil && state == 'S' { |
| + start = s |
| + break |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("sleep never slept: %c %v", state, err) |
| + } |
| + time.Sleep(time.Millisecond) |
| + } |
| + fd, err := unix.PidfdOpen(pid, 0) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + m := member{pid, start} |
| + h := &held{members: map[member]int{m: fd}} |
| + defer h.resume() |
| + tree := []proc{{pid: pid, start: start, depth: 1}} |
| + if settled, err := h.pass(tree); err != nil || settled { |
| + t.Fatalf("a sleeping member settled the pass: %v %v", settled, err) |
| + } |
| + for deadline := time.Now().Add(2 * time.Second); ; { |
| + settled, err := h.pass(tree) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if settled { |
| + break |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatal("the member never read stopped") |
| + } |
| + time.Sleep(time.Millisecond) |
| + } |
| + if state, _, _, _ := readStat(fmt.Sprintf("/proc/%d/stat", pid)); state != 'T' { |
| + t.Fatalf("settled with the member in state %c", state) |
| + } |
| + h.resume() |
| + for deadline := time.Now().Add(2 * time.Second); ; { |
| + if state, _, _, _ := readStat(fmt.Sprintf("/proc/%d/stat", pid)); state == 'S' { |
| + return |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatal("not resumed") |
| + } |
| + time.Sleep(time.Millisecond) |
| + } |
| +} |
diff --git a/internal/runner/pause/pause_other.go b/internal/runner/pause/pause_other.go| new file mode 100644 |
| index 00000000..07acd340 |
| --- /dev/null |
| +++ b/internal/runner/pause/pause_other.go |
| @@ -0,0 +1,10 @@ |
| +//go:build !linux |
| + |
| +package pause |
| + |
| +import "time" |
| + |
| +// Hold refuses: only Linux runners pause a sandbox. |
| +func Hold(Process, time.Duration, func(deadline time.Time) error) error { |
| + return ErrUnsupported |
| +} |
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go| index 77a708e0..fdecaf72 100644 |
| --- a/internal/runner/thin/engineer.go |
| +++ b/internal/runner/thin/engineer.go |
| @@ -814,6 +814,10 @@ type specialistRun struct { |
| // admit is the scheduler's admission of a metered attempt, written in |
| // the metered guard's transaction (nil: admitted already, or none). |
| admit admitFunc |
| + // sandbox receives the step sandbox's first process once it runs, for |
| + // the workspace snapshot (render_page's `tree: work`), and is cleared |
| + // when the run ends (nil: not kept). Claude runs only. |
| + sandbox *sandboxHandle |
| } |
| // stepResult is how the specialist's process ended. session is the |
| @@ -1073,7 +1077,8 @@ func (e *Engineer) run(ctx context.Context, r stepRow, tree workspace.TaskTree, |
| // The namespace is recorded before it launches: a record that cannot |
| // be written launches nothing, so an unverified exit always has a |
| // namespace to verify. |
| - proc, err := recordedStart(pctx, o.Manager, launch, in.Argv, record) |
| + defer spec.sandbox.drop() |
| + proc, err := recordedStartKept(pctx, o.Manager, launch, in.Argv, record, spec.sandbox) |
| if err != nil { |
| e.log("step start", err) |
| return stepResult{reason: "policy_rejected", terminated: true} |
diff --git a/internal/runner/thin/preview.go b/internal/runner/thin/preview.go| index 79ce2f69..edd19252 100644 |
| --- a/internal/runner/thin/preview.go |
| +++ b/internal/runner/thin/preview.go |
| @@ -9,6 +9,7 @@ import ( |
| "encoding/json" |
| "errors" |
| "fmt" |
| + "hash" |
| "io" |
| "log/slog" |
| "net/http" |
| @@ -198,6 +199,15 @@ func readPreviewConfig(ctx context.Context, git, gitDir, sha string) (previewCon |
| if err != nil { |
| return previewConfig{}, errPreviewConfig |
| } |
| + return parsePreviewConfig(raw) |
| +} |
| + |
| +// parsePreviewConfig is release/preview.json's content rule, wherever it |
| +// was read from: at most 4 KiB, strictly {"output": <clean path>}. |
| +func parsePreviewConfig(raw []byte) (previewConfig, error) { |
| + if len(raw) > previewMaxConfig { |
| + return previewConfig{}, errPreviewConfig |
| + } |
| var c previewConfig |
| d := json.NewDecoder(bytes.NewReader(raw)) |
| d.DisallowUnknownFields() |
| @@ -252,11 +262,7 @@ func exportStatic(ctx context.Context, git, gitDir, sha, output, stage, headers |
| size int64 |
| } |
| var entries []entry |
| - total := int64(len(headers)) |
| - headerFiles := 0 |
| - if headers != "" { |
| - headerFiles = 1 |
| - } |
| + budget := newSiteBudget(headers) |
| for _, rec := range bytes.Split(bytes.TrimRight(ls, "\x00"), []byte{0}) { |
| if len(rec) == 0 { |
| continue |
| @@ -271,41 +277,34 @@ func exportStatic(ctx context.Context, git, gitDir, sha, output, stage, headers |
| return previewExport{}, errPreviewConfig |
| } |
| rel := strings.TrimPrefix(name, output+"/") |
| - if !cleanPreviewPath(rel) || rel == previewMarker || rel == siteMarker { |
| - return previewExport{}, errPreviewConfig |
| + skip, err := siteEntry(rel, headers) |
| + if err != nil { |
| + return previewExport{}, err |
| } |
| - if headers != "" && rel == "_headers" { |
| + if skip { |
| continue |
| } |
| size, err := strconv.ParseInt(f[3], 10, 64) |
| - if err != nil || size < 0 || size > previewMaxFile { |
| + if err != nil { |
| return previewExport{}, errPreviewTooLarge |
| } |
| - total += size |
| - entries = append(entries, entry{rel, f[2], size}) |
| - if len(entries)+headerFiles > previewMaxFiles || total > previewMaxBytes { |
| - return previewExport{}, errPreviewTooLarge |
| + if err := budget.add(size); err != nil { |
| + return previewExport{}, err |
| } |
| + entries = append(entries, entry{rel, f[2], size}) |
| } |
| if len(entries) == 0 { |
| return previewExport{}, errPreviewConfig |
| } |
| - if err := os.RemoveAll(stage); err != nil { |
| - return previewExport{}, err |
| - } |
| - if err := os.MkdirAll(stage, 0o700); err != nil { |
| - return previewExport{}, err |
| - } |
| - root, err := os.OpenRoot(stage) |
| + st, err := openSiteStage(stage) |
| if err != nil { |
| return previewExport{}, err |
| } |
| - defer root.Close() |
| + defer st.close() |
| if headers != "" { |
| entries = append(entries, entry{rel: "_headers", size: int64(len(headers))}) |
| } |
| sort.Slice(entries, func(i, j int) bool { return entries[i].rel < entries[j].rel }) |
| - sum := sha256.New() |
| for _, e := range entries { |
| var blob []byte |
| if headers != "" && e.rel == "_headers" { |
| @@ -316,25 +315,96 @@ func exportStatic(ctx context.Context, git, gitDir, sha, output, stage, headers |
| return previewExport{}, errPreviewTooLarge |
| } |
| } |
| - if dir := path.Dir(e.rel); dir != "." { |
| - if err := root.MkdirAll(dir, 0o700); err != nil { |
| - return previewExport{}, err |
| - } |
| - } |
| - fh, err := root.OpenFile(e.rel, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600) |
| - if err != nil { |
| + if err := st.put(e.rel, blob); err != nil { |
| return previewExport{}, err |
| } |
| - _, werr := fh.Write(blob) |
| - if cerr := fh.Close(); werr != nil || cerr != nil { |
| - return previewExport{}, errors.Join(werr, cerr) |
| + } |
| + return previewExport{Digest: st.digest(), Files: len(entries), Bytes: budget.bytes}, nil |
| +} |
| + |
| +// siteEntry is the rule for one path inside the output directory, |
| +// relative to it: clean, no part starting with a dot, not a marker's |
| +// name. skip: the tree's own _headers, replaced by the runner's. |
| +func siteEntry(rel, headers string) (skip bool, err error) { |
| + if !cleanPreviewPath(rel) || rel == previewMarker || rel == siteMarker { |
| + return false, errPreviewConfig |
| + } |
| + return headers != "" && rel == "_headers", nil |
| +} |
| + |
| +// siteBudget counts an export against the caps: files, bytes, and each |
| +// file's size. The runner's _headers counts from the start. |
| +type siteBudget struct { |
| + files int |
| + bytes int64 |
| +} |
| + |
| +func newSiteBudget(headers string) siteBudget { |
| + b := siteBudget{bytes: int64(len(headers))} |
| + if headers != "" { |
| + b.files = 1 |
| + } |
| + return b |
| +} |
| + |
| +func (b *siteBudget) add(size int64) error { |
| + if size < 0 || size > previewMaxFile { |
| + return errPreviewTooLarge |
| + } |
| + b.bytes += size |
| + b.files++ |
| + if b.files > previewMaxFiles || b.bytes > previewMaxBytes { |
| + return errPreviewTooLarge |
| + } |
| + return nil |
| +} |
| + |
| +// siteStage is an export's stage: fresh and private, each file created |
| +// once (never over another), the digest SHA-256 over the "<path> |
| +// <sha256>" lines in the order put (sorted by the caller). |
| +type siteStage struct { |
| + root *os.Root |
| + sum hash.Hash |
| +} |
| + |
| +// openSiteStage empties stage and makes it again, 0700. |
| +func openSiteStage(stage string) (*siteStage, error) { |
| + if err := os.RemoveAll(stage); err != nil { |
| + return nil, err |
| + } |
| + if err := os.MkdirAll(stage, 0o700); err != nil { |
| + return nil, err |
| + } |
| + root, err := os.OpenRoot(stage) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return &siteStage{root: root, sum: sha256.New()}, nil |
| +} |
| + |
| +func (s *siteStage) put(rel string, blob []byte) error { |
| + if dir := path.Dir(rel); dir != "." { |
| + if err := s.root.MkdirAll(dir, 0o700); err != nil { |
| + return err |
| } |
| - h := sha256.Sum256(blob) |
| - fmt.Fprintf(sum, "%s %s\n", e.rel, hex.EncodeToString(h[:])) |
| } |
| - return previewExport{Digest: hex.EncodeToString(sum.Sum(nil)), Files: len(entries), Bytes: total}, nil |
| + fh, err := s.root.OpenFile(rel, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600) |
| + if err != nil { |
| + return err |
| + } |
| + _, werr := fh.Write(blob) |
| + if cerr := fh.Close(); werr != nil || cerr != nil { |
| + return errors.Join(werr, cerr) |
| + } |
| + h := sha256.Sum256(blob) |
| + fmt.Fprintf(s.sum, "%s %s\n", rel, hex.EncodeToString(h[:])) |
| + return nil |
| } |
| +func (s *siteStage) digest() string { return hex.EncodeToString(s.sum.Sum(nil)) } |
| + |
| +func (s *siteStage) close() { s.root.Close() } |
| + |
| // previewMark is the marker the runner adds beside the export (outside |
| // its digest) and fetches back to confirm what is served. |
| type previewMark struct { |
diff --git a/internal/runner/thin/step.go b/internal/runner/thin/step.go| index 99ceff3a..ed698829 100644 |
| --- a/internal/runner/thin/step.go |
| +++ b/internal/runner/thin/step.go |
| @@ -883,7 +883,5 @@ type starter interface { |
| // recordedStart starts a step's or question's process with its namespace |
| // written durably before it launches. |
| func recordedStart(ctx context.Context, m starter, l provider.Launch, argv []string, record func(context.Context, string) error) (provider.Process, error) { |
| - return m.StartRecorded(ctx, l, argv, func(_ context.Context, r containment.Record) error { |
| - return record(context.WithoutCancel(ctx), r.ID) |
| - }) |
| + return recordedStartKept(ctx, m, l, argv, record, nil) |
| } |
diff --git a/internal/runner/thin/worksnap.go b/internal/runner/thin/worksnap.go| new file mode 100644 |
| index 00000000..6a7bb537 |
| --- /dev/null |
| +++ b/internal/runner/thin/worksnap.go |
| @@ -0,0 +1,102 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "sync" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/containment" |
| + "amadan.net/oficina/equipo/internal/runner/pause" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +// The workspace snapshot (`tree: work`, spec §3 "What it renders", plan |
| +// task 9): the runner pauses every process of the step's sandbox and, |
| +// inside the pause, reads the workspace's release/preview.json and copies |
| +// its output directory into a runner-private stage, by exportStatic's |
| +// rules. No git index is used and nothing is written to the workspace or |
| +// the branch. |
| + |
| +// errWorkBusy: the step's sandbox could not be paused for the copy within |
| +// the bound (or is gone, or this system cannot pause one). render_page |
| +// answers `busy`. |
| +var errWorkBusy = errors.New("workspace snapshot refused: busy") |
| + |
| +// snapshotBound bounds the pause, stopping and copying together (a seam |
| +// for the tests). |
| +var snapshotBound = pause.Bound |
| + |
| +// Bounds of a workspace walk beyond exportStatic's (a git listing has no |
| +// directories of its own): how deep below the output a path may go, and |
| +// how many directories it may hold. |
| +const ( |
| + previewMaxDepth = 32 |
| + previewMaxDirs = 2000 |
| +) |
| + |
| +// sandboxHandle carries the step sandbox's first process, as containment |
| +// recorded it once it ran, from the step's start to its tool calls. |
| +type sandboxHandle struct { |
| + mu sync.Mutex |
| + p pause.Process |
| + ok bool |
| + // snap runs one snapshot at a time: two pauses of one sandbox would |
| + // resume each other's. |
| + snap sync.Mutex |
| +} |
| + |
| +// keep holds r's first process; a record without one (the record written |
| +// before the launch) is ignored. |
| +func (h *sandboxHandle) keep(r containment.Record) { |
| + if h == nil || r.HostPID <= 0 || r.StartTicks == 0 { |
| + return |
| + } |
| + h.mu.Lock() |
| + defer h.mu.Unlock() |
| + h.p, h.ok = pause.Process{PID: r.HostPID, StartTicks: r.StartTicks, Namespace: r.NamespaceID}, true |
| +} |
| + |
| +// drop forgets the process once the step's run is over. |
| +func (h *sandboxHandle) drop() { |
| + if h == nil { |
| + return |
| + } |
| + h.mu.Lock() |
| + defer h.mu.Unlock() |
| + h.p, h.ok = pause.Process{}, false |
| +} |
| + |
| +func (h *sandboxHandle) current() (pause.Process, bool) { |
| + if h == nil { |
| + return pause.Process{}, false |
| + } |
| + h.mu.Lock() |
| + defer h.mu.Unlock() |
| + return h.p, h.ok |
| +} |
| + |
| +// snapshot copies the running step's workspace site into stage (fresh, |
| +// 0700) while its sandbox is paused. On any error the stage's content is |
| +// not a snapshot and must not be used. |
| +func (h *sandboxHandle) snapshot(workspace, stage, headers string) (previewExport, error) { |
| + p, ok := h.current() |
| + if !ok { |
| + return previewExport{}, errWorkBusy |
| + } |
| + h.snap.Lock() |
| + defer h.snap.Unlock() |
| + return snapshotWork(p, workspace, stage, headers) |
| +} |
| + |
| +// recordedStartKept is recordedStart that also keeps the sandbox's first |
| +// process on h, from the record containment writes once it runs (before |
| +// the harness is released, so before any tool call). |
| +func recordedStartKept(ctx context.Context, m starter, l provider.Launch, argv []string, record func(context.Context, string) error, h *sandboxHandle) (provider.Process, error) { |
| + return m.StartRecorded(ctx, l, argv, func(_ context.Context, r containment.Record) error { |
| + if err := record(context.WithoutCancel(ctx), r.ID); err != nil { |
| + return err |
| + } |
| + h.keep(r) |
| + return nil |
| + }) |
| +} |
diff --git a/internal/runner/thin/worksnap_linux.go b/internal/runner/thin/worksnap_linux.go| new file mode 100644 |
| index 00000000..5ecf59e9 |
| --- /dev/null |
| +++ b/internal/runner/thin/worksnap_linux.go |
| @@ -0,0 +1,282 @@ |
| +//go:build linux |
| + |
| +package thin |
| + |
| +import ( |
| + "errors" |
| + "io" |
| + "os" |
| + "path" |
| + "sort" |
| + "strings" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/pause" |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// snapshotWork pauses the sandbox whose first process is p and, inside |
| +// the pause, copies workspace's site into stage (emptied and made 0700 |
| +// first, outside the pause). Any failure to pause in time, or a copy that |
| +// runs past the bound, is errWorkBusy; the site's own refusals are |
| +// exportStatic's (errPreviewConfig, errPreviewTooLarge). On any error the |
| +// stage is removed, so a partial or unpaused copy is never left to use. |
| +func snapshotWork(p pause.Process, workspace, stage, headers string) (_ previewExport, err error) { |
| + st, err := openSiteStage(stage) |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + defer func() { |
| + st.close() |
| + if err != nil { |
| + os.RemoveAll(stage) |
| + } |
| + }() |
| + var ex previewExport |
| + err = pause.Hold(p, snapshotBound, func(deadline time.Time) error { |
| + var err error |
| + ex, err = copyWorkSite(workspace, st, headers, deadline) |
| + return err |
| + }) |
| + if errors.Is(err, pause.ErrBusy) || errors.Is(err, pause.ErrGone) || errors.Is(err, pause.ErrUnsupported) { |
| + return previewExport{}, errWorkBusy |
| + } |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + return ex, nil |
| +} |
| + |
| +// workResolve is how every path below the workspace root is resolved: never |
| +// above the root, through no symlink (and so no magic link), and on the |
| +// root's own mount. |
| +const workResolve = unix.RESOLVE_BENEATH | unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS | unix.RESOLVE_NO_XDEV |
| + |
| +// workRoot is the workspace opened once; every path is opened from it. |
| +type workRoot struct{ fd int } |
| + |
| +func openWorkRoot(workspace string) (workRoot, error) { |
| + fd, err := unix.Open(workspace, unix.O_PATH|unix.O_DIRECTORY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) |
| + if err != nil { |
| + return workRoot{}, errPreviewConfig |
| + } |
| + return workRoot{fd}, nil |
| +} |
| + |
| +func (w workRoot) close() { unix.Close(w.fd) } |
| + |
| +// open opens rel from the root by workResolve. A link as rel's last part |
| +// is refused too (O_NOFOLLOW), so no link is followed at any depth. |
| +func (w workRoot) open(rel string, flags uint64) (int, error) { |
| + for try := 0; ; try++ { |
| + fd, err := unix.Openat2(w.fd, rel, &unix.OpenHow{Flags: flags | unix.O_NOFOLLOW | unix.O_CLOEXEC, Resolve: workResolve}) |
| + if (err == unix.EINTR || err == unix.EAGAIN) && try < 16 { |
| + // EAGAIN: a rename raced the resolution (RESOLVE_BENEATH). |
| + continue |
| + } |
| + return fd, err |
| + } |
| +} |
| + |
| +// stat is rel's own type and identity, read through an O_PATH descriptor: |
| +// nothing of a device or FIFO is opened to learn what it is. A link as the |
| +// last part comes back as the link itself. |
| +func (w workRoot) stat(rel string) (unix.Stat_t, error) { |
| + var st unix.Stat_t |
| + fd, err := w.open(rel, unix.O_PATH) |
| + if err != nil { |
| + return st, errPreviewConfig |
| + } |
| + defer unix.Close(fd) |
| + if err := unix.Fstat(fd, &st); err != nil { |
| + return st, errPreviewConfig |
| + } |
| + return st, nil |
| +} |
| + |
| +// readFile reads rel, a regular file the walk saw as want (same device and |
| +// inode), whole: at most limit bytes, exactly its size. |
| +func (w workRoot) readFile(rel string, want unix.Stat_t, limit int64) ([]byte, error) { |
| + fd, err := w.open(rel, unix.O_RDONLY|unix.O_NONBLOCK|unix.O_NOCTTY) |
| + if err != nil { |
| + return nil, errPreviewConfig |
| + } |
| + defer unix.Close(fd) |
| + var st unix.Stat_t |
| + if err := unix.Fstat(fd, &st); err != nil || st.Mode&unix.S_IFMT != unix.S_IFREG || st.Dev != want.Dev || st.Ino != want.Ino { |
| + return nil, errPreviewConfig |
| + } |
| + if st.Size < 0 || st.Size > limit || st.Size != want.Size { |
| + return nil, errPreviewTooLarge |
| + } |
| + buf := make([]byte, st.Size+1) |
| + n, err := io.ReadFull(fdReader(fd), buf) |
| + if err != io.ErrUnexpectedEOF && err != io.EOF || int64(n) != st.Size { |
| + // A file that is not the size it said, while the step is paused. |
| + return nil, errPreviewTooLarge |
| + } |
| + return buf[:n], nil |
| +} |
| + |
| +type fdReader int |
| + |
| +func (f fdReader) Read(p []byte) (int, error) { |
| + for { |
| + n, err := unix.Read(int(f), p) |
| + if err == unix.EINTR { |
| + continue |
| + } |
| + if err != nil { |
| + return 0, err |
| + } |
| + if n == 0 { |
| + return 0, io.EOF |
| + } |
| + return n, nil |
| + } |
| +} |
| + |
| +// names lists the directory rel (opened by workResolve, O_DIRECTORY), at |
| +// most budget names in all. |
| +func (w workRoot) names(rel string, budget *int) ([]string, error) { |
| + fd, err := w.open(rel, unix.O_RDONLY|unix.O_DIRECTORY) |
| + if err != nil { |
| + return nil, errPreviewConfig |
| + } |
| + defer unix.Close(fd) |
| + var out []string |
| + buf := make([]byte, 32<<10) |
| + for { |
| + n, err := unix.Getdents(fd, buf) |
| + if err == unix.EINTR { |
| + continue |
| + } |
| + if err != nil { |
| + return nil, errPreviewConfig |
| + } |
| + if n <= 0 { |
| + return out, nil |
| + } |
| + before := len(out) |
| + _, _, out = unix.ParseDirent(buf[:n], -1, out) |
| + if *budget -= len(out) - before; *budget < 0 { |
| + return nil, errPreviewTooLarge |
| + } |
| + } |
| +} |
| + |
| +// copyWorkSite reads the workspace's release/preview.json by |
| +// readPreviewConfig's rules and copies its output directory into st by |
| +// exportStatic's: every path clean (no part starting with a dot, no |
| +// marker's name), regular files and directories only, never a link, the |
| +// caps checked against the whole listing before any file is read and |
| +// again while copying, the files put in sorted order so the digest is the |
| +// one exportStatic gives the same tree. Every path is opened from the |
| +// workspace root by workResolve. It reads only; past deadline it stops |
| +// with errWorkBusy. |
| +func copyWorkSite(workspace string, st *siteStage, headers string, deadline time.Time) (previewExport, error) { |
| + late := func() bool { return !time.Now().Before(deadline) } |
| + if late() { |
| + return previewExport{}, errWorkBusy |
| + } |
| + w, err := openWorkRoot(workspace) |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + defer w.close() |
| + |
| + cst, err := w.stat(previewConfigPath) |
| + if err != nil || cst.Mode&unix.S_IFMT != unix.S_IFREG { |
| + return previewExport{}, errPreviewConfig |
| + } |
| + raw, err := w.readFile(previewConfigPath, cst, previewMaxConfig) |
| + if err != nil { |
| + return previewExport{}, errPreviewConfig |
| + } |
| + cfg, err := parsePreviewConfig(raw) |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + output := cfg.Output |
| + |
| + type entry struct { |
| + rel string |
| + st unix.Stat_t |
| + } |
| + var entries []entry |
| + budget := newSiteBudget(headers) |
| + // Every name is a file, a directory or a refusal. (The tree's own |
| + // _headers, skipped, takes the name of the file slot the runner's |
| + // takes.) This bounds what one listing holds in memory. |
| + names := previewMaxFiles + previewMaxDirs |
| + dirs := 0 |
| + if ost, err := w.stat(output); err != nil || ost.Mode&unix.S_IFMT != unix.S_IFDIR { |
| + return previewExport{}, errPreviewConfig |
| + } |
| + pending := []string{""} |
| + for len(pending) > 0 { |
| + if late() { |
| + return previewExport{}, errWorkBusy |
| + } |
| + dir := pending[len(pending)-1] |
| + pending = pending[:len(pending)-1] |
| + list, err := w.names(path.Join(output, dir), &names) |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + for _, name := range list { |
| + rel := path.Join(dir, name) |
| + if strings.Count(rel, "/")+1 > previewMaxDepth { |
| + return previewExport{}, errPreviewTooLarge |
| + } |
| + skip, err := siteEntry(rel, headers) |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + est, err := w.stat(output + "/" + rel) |
| + if err != nil { |
| + return previewExport{}, err |
| + } |
| + switch est.Mode & unix.S_IFMT { |
| + case unix.S_IFDIR: |
| + if dirs++; dirs > previewMaxDirs { |
| + return previewExport{}, errPreviewTooLarge |
| + } |
| + pending = append(pending, rel) |
| + case unix.S_IFREG: |
| + if skip { |
| + continue |
| + } |
| + if err := budget.add(est.Size); err != nil { |
| + return previewExport{}, err |
| + } |
| + entries = append(entries, entry{rel, est}) |
| + default: |
| + // A link, a FIFO, a socket, a device: never followed. |
| + return previewExport{}, errPreviewConfig |
| + } |
| + } |
| + } |
| + if len(entries) == 0 { |
| + return previewExport{}, errPreviewConfig |
| + } |
| + if headers != "" { |
| + entries = append(entries, entry{rel: "_headers"}) |
| + } |
| + sort.Slice(entries, func(i, j int) bool { return entries[i].rel < entries[j].rel }) |
| + for _, e := range entries { |
| + if late() { |
| + return previewExport{}, errWorkBusy |
| + } |
| + var blob []byte |
| + if headers != "" && e.rel == "_headers" { |
| + blob = []byte(headers) |
| + } else if blob, err = w.readFile(output+"/"+e.rel, e.st, previewMaxFile); err != nil { |
| + return previewExport{}, err |
| + } |
| + if err := st.put(e.rel, blob); err != nil { |
| + return previewExport{}, err |
| + } |
| + } |
| + return previewExport{Digest: st.digest(), Files: len(entries), Bytes: budget.bytes}, nil |
| +} |
diff --git a/internal/runner/thin/worksnap_linux_test.go b/internal/runner/thin/worksnap_linux_test.go| new file mode 100644 |
| index 00000000..bf310e35 |
| --- /dev/null |
| +++ b/internal/runner/thin/worksnap_linux_test.go |
| @@ -0,0 +1,651 @@ |
| +//go:build linux |
| + |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "io/fs" |
| + "net" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "sort" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/containment" |
| + "amadan.net/oficina/equipo/internal/runner/pause" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// workTree writes files (path to content) under a fresh workspace; links |
| +// (path to target) are made as symlinks. |
| +func workTree(t *testing.T, files, links map[string]string) string { |
| + t.Helper() |
| + ws := t.TempDir() |
| + for rel, content := range files { |
| + p := filepath.Join(ws, rel) |
| + if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(p, []byte(content), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + for rel, target := range links { |
| + p := filepath.Join(ws, rel) |
| + if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink(target, p); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + return ws |
| +} |
| + |
| +// siteFiles is a workspace whose release/preview.json names site, with |
| +// files outside the output too. |
| +func siteFiles() map[string]string { |
| + return map[string]string{ |
| + "release/preview.json": `{"output": "site"}`, |
| + "site/index.html": "<h1>home</h1>", |
| + "site/about/index.html": "<h1>about</h1>", |
| + "site/a/b/c/d.css": "body{}", |
| + "site/_headers": "/*\n X-Tree: 1\n", |
| + "secret.txt": "OUTSIDE-THE-OUTPUT", |
| + "other/notes.md": "OUTSIDE-THE-OUTPUT", |
| + "sitemap/x.html": "OUTSIDE-THE-OUTPUT", |
| + } |
| +} |
| + |
| +// copySite runs copyWorkSite into a fresh stage and returns it. |
| +func copySite(t *testing.T, ws, headers string) (previewExport, string, error) { |
| + t.Helper() |
| + stage := filepath.Join(t.TempDir(), "stage") |
| + st, err := openSiteStage(stage) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer st.close() |
| + ex, err := copyWorkSite(ws, st, headers, time.Now().Add(time.Minute)) |
| + return ex, stage, err |
| +} |
| + |
| +// staged lists the stage's files (path to content) and fails on anything |
| +// but regular files and directories. |
| +func staged(t *testing.T, stage string) map[string]string { |
| + t.Helper() |
| + out := map[string]string{} |
| + filepath.WalkDir(stage, func(p string, d fs.DirEntry, err error) error { |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + info, _ := os.Lstat(p) |
| + if d.IsDir() { |
| + if info.Mode().Perm() != 0o700 { |
| + t.Errorf("stage directory %s mode %v", p, info.Mode()) |
| + } |
| + return nil |
| + } |
| + if !info.Mode().IsRegular() || info.Mode().Perm() != 0o600 { |
| + t.Errorf("stage entry %s mode %v", p, info.Mode()) |
| + } |
| + raw, _ := os.ReadFile(p) |
| + rel, _ := filepath.Rel(stage, p) |
| + out[rel] = string(raw) |
| + return nil |
| + }) |
| + return out |
| +} |
| + |
| +// treeState is every entry under dir with its mode, size, mtime and |
| +// content digest: what "nothing was written" compares. |
| +func treeState(t *testing.T, dir string) string { |
| + t.Helper() |
| + var lines []string |
| + filepath.WalkDir(dir, func(p string, d fs.DirEntry, err error) error { |
| + if err != nil { |
| + return nil |
| + } |
| + info, err := os.Lstat(p) |
| + if err != nil { |
| + return nil |
| + } |
| + sum := "" |
| + if info.Mode().IsRegular() { |
| + raw, _ := os.ReadFile(p) |
| + h := sha256.Sum256(raw) |
| + sum = hex.EncodeToString(h[:]) |
| + } |
| + lines = append(lines, fmt.Sprintf("%s %v %d %d %s", p, info.Mode(), info.Size(), info.ModTime().UnixNano(), sum)) |
| + return nil |
| + }) |
| + sort.Strings(lines) |
| + return strings.Join(lines, "\n") |
| +} |
| + |
| +// Only the output directory is copied, by exportStatic's rules: the |
| +// same files, the same digest as an export of the same tree from git |
| +// objects, the tree's _headers replaced by the runner's; nothing outside |
| +// the output is read into the stage and nothing in the workspace changes. |
| +func TestWorkSiteCopiesOnlyTheOutput(t *testing.T) { |
| + ws := workTree(t, siteFiles(), nil) |
| + before := treeState(t, ws) |
| + headers := "/*\n X-Runner: 1\n" |
| + ex, stage, err := copySite(t, ws, headers) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + got := staged(t, stage) |
| + want := map[string]string{ |
| + "index.html": "<h1>home</h1>", |
| + "about/index.html": "<h1>about</h1>", |
| + "a/b/c/d.css": "body{}", |
| + "_headers": headers, |
| + } |
| + if len(got) != len(want) { |
| + t.Fatalf("staged %v", got) |
| + } |
| + for k, v := range want { |
| + if got[k] != v { |
| + t.Fatalf("staged %s = %q, want %q", k, got[k], v) |
| + } |
| + } |
| + for k, v := range got { |
| + if strings.Contains(v, "OUTSIDE") { |
| + t.Fatalf("a file outside the output was copied: %s", k) |
| + } |
| + } |
| + if ex.Files != 4 || ex.Bytes != int64(len("<h1>home</h1><h1>about</h1>body{}")+len(headers)) { |
| + t.Fatalf("export %+v", ex) |
| + } |
| + if after := treeState(t, ws); after != before { |
| + t.Fatalf("the workspace changed:\n%s\n---\n%s", before, after) |
| + } |
| + |
| + // The same tree exported from git objects has the same digest. |
| + git, err := exec.LookPath("git") |
| + if err != nil { |
| + t.Skip("no git") |
| + } |
| + run := func(args ...string) string { |
| + cmd := exec.Command(git, args...) |
| + cmd.Dir = ws |
| + cmd.Env = []string{"HOME=/nonexistent", "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null", "GIT_AUTHOR_NAME=t", "GIT_AUTHOR_EMAIL=t@example.com", "GIT_COMMITTER_NAME=t", "GIT_COMMITTER_EMAIL=t@example.com"} |
| + out, err := cmd.CombinedOutput() |
| + if err != nil { |
| + t.Fatalf("git %v: %v %s", args, err, out) |
| + } |
| + return strings.TrimSpace(string(out)) |
| + } |
| + gitDir := filepath.Join(t.TempDir(), "git") |
| + run("init", "-q", "--separate-git-dir", gitDir) |
| + run("add", "-A") |
| + run("commit", "-q", "-m", "x") |
| + sha := run("rev-parse", "HEAD") |
| + os.Remove(filepath.Join(ws, ".git")) |
| + cfg, err := readPreviewConfig(context.Background(), git, gitDir, sha) |
| + if err != nil || cfg.Output != "site" { |
| + t.Fatalf("readPreviewConfig %+v %v", cfg, err) |
| + } |
| + fromGit, err := exportStatic(context.Background(), git, gitDir, sha, cfg.Output, filepath.Join(t.TempDir(), "git-stage"), headers) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if fromGit != ex { |
| + t.Fatalf("work %+v, git objects %+v", ex, fromGit) |
| + } |
| +} |
| + |
| +// A link at any depth is never followed: not as release/ or its |
| +// preview.json, not as the output or any directory above or below it, not |
| +// as a file, whether it points inside the workspace or out of it. The |
| +// copy is refused and nothing it names reaches the stage. |
| +func TestWorkSiteFollowsNoLink(t *testing.T) { |
| + outside := t.TempDir() |
| + os.WriteFile(filepath.Join(outside, "preview.json"), []byte(`{"output": "site"}`), 0o644) |
| + os.WriteFile(filepath.Join(outside, "index.html"), []byte("LINKED"), 0o644) |
| + os.MkdirAll(filepath.Join(outside, "deep"), 0o755) |
| + os.WriteFile(filepath.Join(outside, "deep", "index.html"), []byte("LINKED"), 0o644) |
| + base := siteFiles() |
| + without := func(drop ...string) map[string]string { |
| + out := map[string]string{} |
| + for k, v := range base { |
| + out[k] = v |
| + } |
| + for _, d := range drop { |
| + for k := range out { |
| + if k == d || strings.HasPrefix(k, d+"/") { |
| + delete(out, k) |
| + } |
| + } |
| + } |
| + return out |
| + } |
| + with := func(files map[string]string, extra map[string]string) map[string]string { |
| + for k, v := range extra { |
| + files[k] = v |
| + } |
| + return files |
| + } |
| + for name, c := range map[string]struct { |
| + files, links map[string]string |
| + }{ |
| + "release is a link": {without("release"), map[string]string{"release": outside}}, |
| + "preview.json is a link": {without("release/preview.json"), map[string]string{"release/preview.json": filepath.Join(outside, "preview.json")}}, |
| + "the output is a link": {without("site"), map[string]string{"site": outside}}, |
| + "the output is a link inside": {with(without("site"), map[string]string{"real/index.html": "LINKED"}), map[string]string{"site": "real"}}, |
| + "a parent of the output": {with(without("site", "release"), map[string]string{"release/preview.json": `{"output": "web/site"}`}), map[string]string{"web": outside}}, |
| + "release is a link inside": {with(without("release"), map[string]string{"conf/preview.json": `{"output": "site"}`}), map[string]string{"release": "conf"}}, |
| + "a parent of the output, inside": {with(without("site", "release"), map[string]string{"release/preview.json": `{"output": "web/site"}`, "real/site/index.html": "LINKED"}), map[string]string{"web": "real"}}, |
| + "a file at the top": {base, map[string]string{"site/linked.html": filepath.Join(outside, "index.html")}}, |
| + "a file inside the tree": {base, map[string]string{"site/linked.html": "index.html"}}, |
| + "a directory": {base, map[string]string{"site/linked": filepath.Join(outside, "deep")}}, |
| + "a file four deep": {base, map[string]string{"site/a/b/c/linked.html": filepath.Join(outside, "index.html")}}, |
| + "a directory four deep": {base, map[string]string{"site/a/b/c/linked": outside}}, |
| + "a dangling link": {base, map[string]string{"site/a/gone": filepath.Join(outside, "missing")}}, |
| + "a link to /proc": {base, map[string]string{"site/self": "/proc/self/root"}}, |
| + } { |
| + ws := workTree(t, c.files, c.links) |
| + _, stage, err := copySite(t, ws, "") |
| + if !errors.Is(err, errPreviewConfig) { |
| + t.Errorf("%s: %v", name, err) |
| + } |
| + for k, v := range staged(t, stage) { |
| + if v == "LINKED" || strings.Contains(v, "OUTSIDE") { |
| + t.Errorf("%s: %s came through a link", name, k) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// Only regular files and directories: a FIFO (which would block an open |
| +// for reading), a socket, a dot file or directory, a marker's name are |
| +// all refused, and refusing does not hang. |
| +func TestWorkSiteRefusesOtherEntries(t *testing.T) { |
| + cases := map[string]func(ws string) error{ |
| + "a fifo": func(ws string) error { return unix.Mkfifo(filepath.Join(ws, "site/pipe"), 0o644) }, |
| + "a socket": func(ws string) error { |
| + // sun_path is short: bind from inside the directory. |
| + wd, _ := os.Getwd() |
| + defer os.Chdir(wd) |
| + os.Chdir(filepath.Join(ws, "site")) |
| + l, err := net.Listen("unix", "sock") |
| + if err == nil { |
| + l.(*net.UnixListener).SetUnlinkOnClose(false) |
| + l.Close() |
| + } |
| + return err |
| + }, |
| + "a dot file": func(ws string) error { return os.WriteFile(filepath.Join(ws, "site/.env"), []byte("x"), 0o644) }, |
| + "an empty dot directory": func(ws string) error { return os.Mkdir(filepath.Join(ws, "site/.cache"), 0o755) }, |
| + "a nested dot file": func(ws string) error { |
| + return os.WriteFile(filepath.Join(ws, "site/a/.gitleaks.toml"), []byte("x"), 0o644) |
| + }, |
| + "the preview marker": func(ws string) error { |
| + return os.WriteFile(filepath.Join(ws, "site", previewMarker), []byte("{}"), 0o644) |
| + }, |
| + "the site marker": func(ws string) error { return os.WriteFile(filepath.Join(ws, "site", siteMarker), []byte("{}"), 0o644) }, |
| + "a backslash": func(ws string) error { return os.WriteFile(filepath.Join(ws, "site/a\\b"), []byte("x"), 0o644) }, |
| + "a newline": func(ws string) error { return os.WriteFile(filepath.Join(ws, "site/a\nb"), []byte("x"), 0o644) }, |
| + } |
| + for name, build := range cases { |
| + ws := workTree(t, siteFiles(), nil) |
| + if err := build(ws); err != nil { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + done := async(func() error { _, _, err := copySite(t, ws, ""); return err }) |
| + select { |
| + case err := <-done: |
| + if !errors.Is(err, errPreviewConfig) { |
| + t.Errorf("%s: %v", name, err) |
| + } |
| + case <-time.After(10 * time.Second): |
| + t.Fatalf("%s: the copy hung", name) |
| + } |
| + } |
| +} |
| + |
| +func async(f func() error) <-chan error { |
| + c := make(chan error, 1) |
| + go func() { c <- f() }() |
| + return c |
| +} |
| + |
| +// release/preview.json by readPreviewConfig's rules: present, a regular |
| +// file, at most 4 KiB, strictly {"output": <clean path>}; the output a |
| +// directory holding at least one file. |
| +func TestWorkSiteConfig(t *testing.T) { |
| + for name, cfg := range map[string]*string{ |
| + "missing": nil, |
| + "not JSON": ptr(`{"output": `), |
| + "an unknown field": ptr(`{"output": "site", "build": ["make"]}`), |
| + "two values": ptr(`{"output": "site"} {"output": "site"}`), |
| + "too large": ptr(`{"output": "site"}` + strings.Repeat(" ", previewMaxConfig)), |
| + "outside": ptr(`{"output": "../site"}`), |
| + "absolute": ptr(`{"output": "/site"}`), |
| + "a dot output": ptr(`{"output": ".git"}`), |
| + "unclean": ptr(`{"output": "site/"}`), |
| + "a file output": ptr(`{"output": "secret.txt"}`), |
| + "no such output": ptr(`{"output": "missing"}`), |
| + "an empty output": ptr(`{"output": "empty"}`), |
| + "only dirs": ptr(`{"output": "dirs"}`), |
| + } { |
| + files := siteFiles() |
| + delete(files, "release/preview.json") |
| + if cfg != nil { |
| + files["release/preview.json"] = *cfg |
| + } |
| + ws := workTree(t, files, nil) |
| + os.Mkdir(filepath.Join(ws, "empty"), 0o755) |
| + os.MkdirAll(filepath.Join(ws, "dirs/a/b"), 0o755) |
| + if _, _, err := copySite(t, ws, ""); !errors.Is(err, errPreviewConfig) { |
| + t.Errorf("%s: %v", name, err) |
| + } |
| + } |
| + // release/preview.json as a directory or a FIFO. |
| + ws := workTree(t, map[string]string{"site/index.html": "x"}, nil) |
| + os.MkdirAll(filepath.Join(ws, "release/preview.json"), 0o755) |
| + if _, _, err := copySite(t, ws, ""); !errors.Is(err, errPreviewConfig) { |
| + t.Errorf("a directory config: %v", err) |
| + } |
| + ws = workTree(t, map[string]string{"site/index.html": "x"}, nil) |
| + os.Mkdir(filepath.Join(ws, "release"), 0o755) |
| + unix.Mkfifo(filepath.Join(ws, "release/preview.json"), 0o644) |
| + select { |
| + case err := <-async(func() error { _, _, err := copySite(t, ws, ""); return err }): |
| + if !errors.Is(err, errPreviewConfig) { |
| + t.Errorf("a fifo config: %v", err) |
| + } |
| + case <-time.After(10 * time.Second): |
| + t.Fatal("a fifo config hung the copy") |
| + } |
| +} |
| + |
| +func ptr(s string) *string { return &s } |
| + |
| +// The caps of exportStatic (files, bytes, one file's size, the runner's |
| +// _headers counted), and the walk's own (depth, directories), refuse with |
| +// errPreviewTooLarge; at each cap exactly the copy goes through. The tree |
| +// starts with one file of one byte; large files are sparse (the caps read |
| +// sizes, not blocks). |
| +func TestWorkSiteCaps(t *testing.T) { |
| + sparse := func(ws, rel string, size int64) { |
| + p := filepath.Join(ws, rel) |
| + os.MkdirAll(filepath.Dir(p), 0o755) |
| + f, err := os.Create(p) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := f.Truncate(size); err != nil { |
| + t.Fatal(err) |
| + } |
| + f.Close() |
| + } |
| + // bytes fills the output to n bytes beside index.html. |
| + bytes := func(n int64) func(string) { |
| + return func(ws string) { |
| + for i := 0; n > 0; i++ { |
| + size := min(n, previewMaxFile) |
| + sparse(ws, fmt.Sprintf("site/v%d.bin", i), size) |
| + n -= size |
| + } |
| + } |
| + } |
| + files := func(n int) func(string) { |
| + return func(ws string) { |
| + for i := range n { |
| + os.WriteFile(filepath.Join(ws, fmt.Sprintf("site/f%d", i)), nil, 0o644) |
| + } |
| + } |
| + } |
| + dirs := func(n int) func(string) { |
| + return func(ws string) { |
| + for i := range n { |
| + os.Mkdir(filepath.Join(ws, fmt.Sprintf("site/d%d", i)), 0o755) |
| + } |
| + } |
| + } |
| + deep := func(n int) func(string) { |
| + return func(ws string) { |
| + p := filepath.Join(ws, "site") |
| + for range n - 1 { |
| + p = filepath.Join(p, "d") |
| + } |
| + os.MkdirAll(p, 0o755) |
| + os.WriteFile(filepath.Join(p, "x.html"), nil, 0o644) |
| + } |
| + } |
| + const h = "/*\n" // a runner _headers of 3 bytes |
| + for _, c := range []struct { |
| + name string |
| + build func(string) |
| + headers string |
| + refused bool |
| + }{ |
| + {"a file at the cap", func(ws string) { sparse(ws, "site/v.bin", previewMaxFile) }, "", false}, |
| + {"a file too large", func(ws string) { sparse(ws, "site/v.bin", previewMaxFile+1) }, "", true}, |
| + {"bytes at the cap", bytes(previewMaxBytes - 1), "", false}, |
| + {"too many bytes", bytes(previewMaxBytes), "", true}, |
| + {"bytes at the cap with headers", bytes(previewMaxBytes - 1 - 3), h, false}, |
| + {"too many bytes with headers", bytes(previewMaxBytes - 1 - 2), h, true}, |
| + {"files at the cap", files(previewMaxFiles - 1), "", false}, |
| + {"too many files", files(previewMaxFiles), "", true}, |
| + {"files at the cap with headers", files(previewMaxFiles - 2), h, false}, |
| + {"too many files with headers", files(previewMaxFiles - 1), h, true}, |
| + {"depth at the cap", deep(previewMaxDepth), "", false}, |
| + {"too deep", deep(previewMaxDepth + 1), "", true}, |
| + {"directories at the cap", dirs(previewMaxDirs), "", false}, |
| + {"files and directories at the caps, the tree's _headers skipped", func(ws string) { |
| + files(previewMaxFiles - 2)(ws) |
| + dirs(previewMaxDirs)(ws) |
| + os.WriteFile(filepath.Join(ws, "site/_headers"), []byte("/x\n"), 0o644) |
| + }, h, false}, |
| + {"too many directories", dirs(previewMaxDirs + 1), "", true}, |
| + } { |
| + ws := workTree(t, map[string]string{"release/preview.json": `{"output": "site"}`, "site/index.html": "x"}, nil) |
| + c.build(ws) |
| + _, _, err := copySite(t, ws, c.headers) |
| + if c.refused && !errors.Is(err, errPreviewTooLarge) || !c.refused && err != nil { |
| + t.Errorf("%s: %v", c.name, err) |
| + } |
| + } |
| +} |
| + |
| +// Past its deadline the copy stops and refuses with errWorkBusy. |
| +func TestWorkSiteDeadline(t *testing.T) { |
| + ws := workTree(t, siteFiles(), nil) |
| + st, err := openSiteStage(filepath.Join(t.TempDir(), "stage")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer st.close() |
| + if _, err := copyWorkSite(ws, st, "", time.Now().Add(-time.Millisecond)); !errors.Is(err, errWorkBusy) { |
| + t.Fatalf("past the deadline: %v", err) |
| + } |
| +} |
| + |
| +// The handle keeps the sandbox's first process from the record written |
| +// once it runs, not the one written before the launch; a record that |
| +// cannot be written keeps nothing. |
| +func TestRecordedStartKeepsTheSandbox(t *testing.T) { |
| + h := &sandboxHandle{} |
| + f := &recordingStarter{records: []containment.Record{{ID: "ns-1"}, {ID: "ns-1", HostPID: 4242, StartTicks: 99, NamespaceID: "pid:[7]"}}} |
| + var ids []string |
| + if _, err := recordedStartKept(context.Background(), f, provider.Launch{}, []string{"/bin/true"}, func(_ context.Context, id string) error { ids = append(ids, id); return nil }, h); err != nil { |
| + t.Fatal(err) |
| + } |
| + if p, ok := h.current(); !ok || p != (pause.Process{PID: 4242, StartTicks: 99, Namespace: "pid:[7]"}) || len(ids) != 2 { |
| + t.Fatalf("kept %+v %v (ids %v)", p, ok, ids) |
| + } |
| + h.drop() |
| + if _, ok := h.current(); ok { |
| + t.Fatal("kept after drop") |
| + } |
| + if _, err := h.snapshot(t.TempDir(), filepath.Join(t.TempDir(), "s"), ""); !errors.Is(err, errWorkBusy) { |
| + t.Fatalf("a snapshot with no sandbox: %v", err) |
| + } |
| + h = &sandboxHandle{} |
| + f = &recordingStarter{records: []containment.Record{{ID: "ns-1", HostPID: 4242, StartTicks: 99}}} |
| + if _, err := recordedStartKept(context.Background(), f, provider.Launch{}, []string{"/bin/true"}, func(context.Context, string) error { return errors.New("no") }, h); err == nil { |
| + t.Fatal("started without its record") |
| + } |
| + if _, ok := h.current(); ok { |
| + t.Fatal("kept a sandbox whose record failed") |
| + } |
| + // The record written before the launch has no process: nothing kept. |
| + h = &sandboxHandle{} |
| + f = &recordingStarter{records: []containment.Record{{ID: "ns-1"}}} |
| + if _, err := recordedStartKept(context.Background(), f, provider.Launch{}, []string{"/bin/true"}, func(context.Context, string) error { return nil }, h); err != nil { |
| + t.Fatal(err) |
| + } |
| + if p, ok := h.current(); ok { |
| + t.Fatalf("kept the pre-launch record %+v", p) |
| + } |
| + // A nil handle keeps nothing and does not panic. |
| + var none *sandboxHandle |
| + none.keep(containment.Record{HostPID: 1, StartTicks: 1}) |
| + none.drop() |
| +} |
| + |
| +// recordingStarter calls record with each of records in turn, as |
| +// containment does before the launch and once it runs. |
| +type recordingStarter struct{ records []containment.Record } |
| + |
| +func (f *recordingStarter) StartRecorded(ctx context.Context, _ provider.Launch, _ []string, record func(context.Context, containment.Record) error) (provider.Process, error) { |
| + for _, r := range f.records { |
| + if err := record(ctx, r); err != nil { |
| + return nil, err |
| + } |
| + } |
| + return nil, nil |
| +} |
| + |
| +// stepSandbox starts script as the first process of a bubblewrap sandbox |
| +// made with the step sandbox's namespace arguments, and returns it as |
| +// containment records it; it is killed when the test ends. |
| +func stepSandbox(t *testing.T, env []string, script string) containment.Record { |
| + t.Helper() |
| + bwrap, err := exec.LookPath("bwrap") |
| + if err != nil { |
| + t.Skip("no bwrap") |
| + } |
| + status, statusW, err := os.Pipe() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer status.Close() |
| + args := append([]string{"--dev-bind", "/", "/", "--proc", "/proc"}, provider.NamespaceArguments()...) |
| + cmd := exec.Command(bwrap, append(args, "sh", "-c", script)...) |
| + cmd.Env = append([]string{"PATH=/usr/bin:/bin"}, env...) |
| + cmd.ExtraFiles = []*os.File{statusW} |
| + if err := cmd.Start(); err != nil { |
| + t.Fatal(err) |
| + } |
| + statusW.Close() |
| + var msg struct { |
| + PID int `json:"child-pid"` |
| + } |
| + status.SetReadDeadline(time.Now().Add(10 * time.Second)) |
| + if err := json.NewDecoder(status).Decode(&msg); err != nil || msg.PID <= 1 { |
| + cmd.Process.Kill() |
| + cmd.Wait() |
| + t.Skipf("bwrap did not start a sandbox here: %v", err) |
| + } |
| + fd, err := unix.PidfdOpen(msg.PID, 0) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { |
| + unix.PidfdSendSignal(fd, unix.SIGKILL, nil, 0) |
| + unix.Close(fd) |
| + cmd.Process.Kill() |
| + cmd.Wait() |
| + }) |
| + raw, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", msg.PID)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + f := strings.Fields(string(raw[strings.LastIndexByte(string(raw), ')')+1:])) |
| + var start uint64 |
| + fmt.Sscan(f[19], &start) |
| + ns, _ := os.Readlink(fmt.Sprintf("/proc/%d/ns/pid", msg.PID)) |
| + return containment.Record{ID: "ns-1", HostPID: msg.PID, StartTicks: start, NamespaceID: ns} |
| +} |
| + |
| +// A snapshot of a running step: its writer, inside a nested namespace, |
| +// keeps rewriting a page of the site; the copy goes through, holds the |
| +// site, and the writer goes on afterwards. (That nothing runs during the |
| +// copy is the pause package's test.) A record whose process is gone is |
| +// refused as busy. |
| +func TestSnapshotWorkPausesTheStep(t *testing.T) { |
| + if _, err := exec.LookPath("unshare"); err != nil { |
| + t.Skip("no unshare") |
| + } |
| + ws := workTree(t, siteFiles(), nil) |
| + writer := `i=0; while :; do i=$((i+1)); echo $i > "$WS/site/count.txt"; echo $i >> "$LOG"; sleep 0.001; done` |
| + logPath := filepath.Join(t.TempDir(), "log") |
| + r := stepSandbox(t, []string{"WS=" + ws, "LOG=" + logPath, "W=" + writer}, |
| + `until unshare --user --pid --fork sh -c "$W"; do sleep 0.1; done & wait`) |
| + h := &sandboxHandle{} |
| + h.keep(r) |
| + size := func() int64 { info, _ := os.Stat(logPath); return sizeOf(info) } |
| + for deadline := time.Now().Add(10 * time.Second); size() < 64; { |
| + if time.Now().After(deadline) { |
| + t.Fatal("the writer never started") |
| + } |
| + time.Sleep(5 * time.Millisecond) |
| + } |
| + stage := filepath.Join(t.TempDir(), "stage") |
| + ex, err := h.snapshot(ws, stage, "") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + got := staged(t, stage) |
| + if ex.Files != 5 || got["index.html"] != "<h1>home</h1>" { |
| + t.Fatalf("export %+v %v", ex, got) |
| + } |
| + if _, ok := got["count.txt"]; !ok { |
| + t.Fatalf("the written page is missing: %v", got) |
| + } |
| + before := size() |
| + for deadline := time.Now().Add(2 * time.Second); size() == before; { |
| + if time.Now().After(deadline) { |
| + t.Fatal("the writer was not resumed") |
| + } |
| + time.Sleep(5 * time.Millisecond) |
| + } |
| + gone := r |
| + gone.StartTicks++ |
| + h.keep(gone) |
| + if _, err := h.snapshot(ws, stage, ""); !errors.Is(err, errWorkBusy) { |
| + t.Fatalf("a gone sandbox: %v", err) |
| + } |
| + if _, err := os.Lstat(stage); !errors.Is(err, fs.ErrNotExist) { |
| + t.Fatalf("a refused snapshot left its stage: %v", err) |
| + } |
| + // A refused site removes the stage too. |
| + h.keep(r) |
| + os.Remove(filepath.Join(ws, "release/preview.json")) |
| + if _, err := h.snapshot(ws, stage, ""); !errors.Is(err, errPreviewConfig) { |
| + t.Fatalf("no release/preview.json: %v", err) |
| + } |
| + if _, err := os.Lstat(stage); !errors.Is(err, fs.ErrNotExist) { |
| + t.Fatalf("a refused snapshot left its stage: %v", err) |
| + } |
| +} |
| + |
| +func sizeOf(info os.FileInfo) int64 { |
| + if info == nil { |
| + return 0 |
| + } |
| + return info.Size() |
| +} |
diff --git a/internal/runner/thin/worksnap_other.go b/internal/runner/thin/worksnap_other.go| new file mode 100644 |
| index 00000000..5236893d |
| --- /dev/null |
| +++ b/internal/runner/thin/worksnap_other.go |
| @@ -0,0 +1,11 @@ |
| +//go:build !linux |
| + |
| +package thin |
| + |
| +import "amadan.net/oficina/equipo/internal/runner/pause" |
| + |
| +// snapshotWork refuses: only Linux runners pause a sandbox (and only they |
| +// render pages). |
| +func snapshotWork(pause.Process, string, string, string) (previewExport, error) { |
| + return previewExport{}, errWorkBusy |
| +} |