oficina / equipo Public

renderer: sandbox launch for the page renderer (internal/runner/render)

Task 5 of dynamic specialists slice 1 (half 1a).

What changed
- internal/runner/render: Launch(ctx, cfg) verifies the installed tree
  with release.VerifyRenderer, then starts bubblewrap with the spike's
  policy: --unshare-all --unshare-user --die-with-parent --new-session
  --clearenv --cap-drop ALL; the tree's usr read only at /usr with the
  /lib, /lib64 and /bin links into it, its etc/fonts at /etc/fonts; the
  runner binary read only at /runner; the site read only at /site; /out
  read-write; tmpfs /tmp, fresh /proc, minimal /dev; root remounted read
  only; --chdir /. Every bind is an O_PATH descriptor opened with no
  symlink followed (bubblewrap closes each once bound). No --setenv, and
  bubblewrap gets an empty environment.
- Descriptors: the first process holds 0, 1, 2, the browser pipe (3 in,
  4 out) and the status pipe (5). The launcher marks every descriptor of
  its own process close-on-exec (close_range, or /proc/self/fd one at a
  time) before it forks, so a descriptor someone left inheritable never
  reaches bubblewrap, which passes inherited ones through.
- render-sandbox (SandboxMain, wired into cmd/equipo-runner before any
  configuration is read): checks 3-5 are open, marks the rest
  close-on-exec, serves /site on 127.0.0.1 (os.Root, GET and HEAD only),
  starts the browser with --remote-debugging-pipe and
  --host-resolver-rules "MAP * ~NOTFOUND, EXCLUDE 127.0.0.1"
  (HostResolverRules), HOME=/tmp its whole environment, then reports
  ready with the site address, and later the browser's exit, as JSON
  lines on the status pipe. The launcher reads at most 8 lines of 1 KiB,
  only a loopback site address counts as ready.
- Off Linux, Launch returns a RendererError with health missing.

Tests
  CGO_ENABLED=0 go test ./internal/runner/render/ -count=1
  EQUIPO_RENDERER_TREE=<tree from build-renderer-tree.py --tree> \
    CGO_ENABLED=0 go test ./internal/runner/render/ -run TestLaunchRealBrowser
  CGO_ENABLED=0 go test ./cmd/equipo-runner/ -run TestRenderSandboxVerb
The test binary is the sandbox's first process (a probe, or the real
SandboxMain) and, copied into a test tree, a fake browser; no Chromium
needed. From inside: 1.1.1.1:443, [2606:4700:4700::1111]:443, the host's
tailnet address (100.119.180.57 here) and a host 127.0.0.1 listener are
unreachable, the sandbox's own loopback works, only lo exists, no name
resolves; a descriptor left inheritable (fd 20) is not visible; the
environment is empty but bubblewrap's own PWD=/; /site, /usr,
/etc/fonts, /runner and / are read only, /out and /tmp writable; only
the bound paths exist; redirects to cdn.example.com, 1.1.1.1 and an IPv6
address are seen and the follow fails to resolve or connect. The real
browser (built tree, 156.0.8078.79) answers Browser.getVersion on the
pipe and a renderer below bubblewrap runs with Seccomp 2, NoNewPrivs 1.

RED: the launcher and its tests were written in one pass (not test
first), so the RED run is the code with every guard off (--share-net, no launcher or in-sandbox
close-on-exec, no --clearenv with the runner's environment, --bind-fd
site, no --remount-ro, no VerifyRenderer, browser env inherited):
TestBwrapArgs, TestSandboxReachesNoNetwork,
TestSandboxSeesNoParentDescriptor, TestSandboxEnvironmentIsEmpty,
TestSandboxSiteIsReadOnly, TestSandboxRedirectIsReportedNotFollowed,
TestLaunchStartsTheBrowser, TestLaunchRefusesAnUnverifiedTree (4/4)
failed. cmd: TestRenderSandboxVerbNeedsNoConfiguration "exit 1: Runner
error runner.command".
GREEN: 17 passed, TestLaunchRealBrowser skipped without a tree and
passing with one (0.47 s); the cmd test passes.

Mutations (38 scripted, each applied once, tests run, file restored and
checksummed; 37 killed, 1 layered):
- --share-net; --unshare-all dropped: TestSandboxReachesNoNetwork,
  TestSandboxRedirectIsReportedNotFollowed, TestBwrapArgs
- launcher close-on-exec off: TestSandboxSeesNoParentDescriptor. This
  mutation first survived: the test's inheritable fd was 5 and the
  child's dup2 of ExtraFiles replaced it; the test now uses fd 20.
- /proc fallback marks nothing: TestCloseOnExec
- in-sandbox close-on-exec off: TestLaunchStartsTheBrowser (fd 5 seen)
- --clearenv dropped: TestBwrapArgs; bwrap env = runner env alone:
  survived, layered (--clearenv clears it); both: also
  TestSandboxEnvironmentIsEmpty
- --bind-fd for site, usr, fonts or binary; no --remount-ro /:
  TestSandboxSiteIsReadOnly, TestBwrapArgs
- no --die-with-parent: TestCloseKillsTheSandbox (a browser that never
  ends outlives Close), TestBwrapArgs
- no --cap-drop ALL, no --new-session: TestBwrapArgs
- host /usr bound instead of the tree: TestSandboxHoldsNoRunnerState,
  TestLaunchStartsTheBrowser, TestBwrapArgs
- no VerifyRenderer: TestLaunchRefusesAnUnverifiedTree (4/4)
- out not private, out not empty, group-writable dir, another owner
  (/usr), symlinked dir, relative path: TestLaunchRefusesItsInputs
- status: any site, exit before ready, 1 MiB lines, junk skipped:
  TestReadStatus
- browser env inherited, browser dir /, site root /, site on all
  addresses, POST answered: TestLaunchStartsTheBrowser
- resolver rules dropped or weakened: TestHostResolverRules
- --no-sandbox added, a port instead of the pipe:
  TestBrowserArgsKeepTheSandbox; --no-sandbox on the real tree:
  TestLaunchRealBrowser "no renderer under Chromium's own sandbox"
- BrowserPath not renderer.json's program:
  TestBrowserPathIsThePinnedProgram

Gates: darwin/arm64 build and vet of cmd/equipo-runner, internal/runner,
wire and release; linux arm64 vet; staticcheck on both packages; budget
size; lanes check; dead-reference scan (only the 3 known doc lines).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 72f26b775f6968546f73a353d1f477a4985ecc9a parent 4c0d844
12 files changed, +1,863 −0
  • cmd/equipo-runner/main.go +6 −0
  • cmd/equipo-runner/main_test.go +10 −0
  • internal/runner/render/helpers_linux_test.go +286 −0
  • internal/runner/render/helpers_other_test.go +5 −0
  • internal/runner/render/launch_linux.go +384 −0
  • internal/runner/render/launch_linux_test.go +739 −0
  • internal/runner/render/launch_other.go +19 −0
  • internal/runner/render/launch_other_test.go +21 −0
  • internal/runner/render/main_test.go +20 −0
  • internal/runner/render/render.go +189 −0
  • internal/runner/render/render_test.go +65 −0
  • internal/runner/render/sandbox_linux.go +119 −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.2s
ci-box: claude: fetched and verified in 1.5s
ci-box: codex: fetched and verified in 3.4s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.9s
ci-box: pi: installed and verified in 7.4s
ci-box: opencode: installed and verified in 1.9s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.7s
ci-box: clone deepened in 5.5s
ci-box: file times set from content: 3306 files, 214 directories
ci-box: ready in 18.5s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipotest	0.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.1s
+ go list -export -test -tags browser,testbuild -f  ./internal/equipo ./internal/equipotest ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
  3.6s
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 1m19.337s 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 1m16.542s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m16.54s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 63.56, cpu waiting 38.35%, memory waiting 0.00%, io waiting 0.56%
--- 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.706s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m17.759s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m17.76s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 63.56, cpu waiting 38.40%, memory waiting 0.00%, io waiting 0.54%
--- 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 1m20.043s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m17.314s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m7.67s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.1s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.55s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 63.56, cpu waiting 38.40%, memory waiting 0.00%, io waiting 0.54%
--- 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 1m18.507s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m15.971s amadan.net/oficina/equipo/internal/headless
receipt: slow test 39.03s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 18.69s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.31s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
receipt: slow test 8.94s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
machine: 32 CPUs, load 63.00, cpu waiting 38.35%, memory waiting 0.00%, io waiting 0.56%
--- 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.21s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m32.539s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m2.47s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.48s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 8.38s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 7.33s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 4.88s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 58.99, cpu waiting 37.45%, memory waiting 0.00%, io waiting 0.43%
--- 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 3m0.106s 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 2m57.295s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m40.9s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 20.1s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.15s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 7.43s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistantAttachments
receipt: slow test 6.76s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 21.90, cpu waiting 10.00%, memory waiting 0.00%, io waiting 0.10%
--- 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 2m15.725s 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 2m13.025s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 10.1s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.7s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 5s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 3.8s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 2.66s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
machine: 32 CPUs, load 35.88, cpu waiting 20.30%, memory waiting 0.00%, io waiting 0.21%
--- 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.396s 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.694s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.54s amadan.net/oficina/equipo/internal/thintest TestContractRetryPreviewUnverifiedMerge
receipt: slow test 9.08s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 4.91s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.52s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.99s amadan.net/oficina/equipo/internal/thintest TestContractPausedJob
machine: 32 CPUs, load 43.66, cpu waiting 26.34%, memory waiting 0.00%, io waiting 0.28%
--- 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 5m12.903s, over the 45s its record on line 44 allows; reported only, timing fails on CI

receipt: test step 5m18.778s 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 5m12.903s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 37.03s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.88s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.8s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.48s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 10.01s amadan.net/oficina/equipo/internal/runner/thin TestTimeoutKeepsNothingForAnOlderInstance
machine: 32 CPUs, load 4.43, cpu waiting 0.96%, 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 52.086s 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 51.127s amadan.net/oficina/equipo/internal/runner
receipt: slow test 31.1s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.02s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 61.71, cpu waiting 34.72%, memory waiting 0.00%, io waiting 0.87%
--- 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.319s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m0.005s amadan.net/oficina/equipo/internal/runner
receipt: slow test 50s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 44.39s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.43s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.55s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 67.47, cpu waiting 37.97%, memory waiting 0.00%, io waiting 0.76%
--- 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.208s 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.359s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.12s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.29s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.14s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.91s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 46.58, cpu waiting 21.37%, memory waiting 0.00%, io waiting 1.18%
--- 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.0%, load 33.05
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
--- 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
        reference scan: 3018 text files, 3232 matches, 3 failures
--- FAIL: TestDirectDeadReferencesRepository (2.36s)

rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/equipotest (package output)
FAIL
rastrillo-budget/v1 ran 1m7.273s
FAIL	amadan.net/oficina/equipo/internal/equipotest	67.605s


receipt: test step 1m9.305s 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.273s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 28.88s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 28.77s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 26.61s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 23.79s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 23.65s amadan.net/oficina/equipo/internal/equipotest TestAuthorityRejectsMismatchedTarget
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
        reference scan: 3018 text files, 3232 matches, 3 failures
--- FAIL: TestDirectDeadReferencesRepository (2.26s)
FAIL
rastrillo-budget/v1 ran 2.261s
FAIL	amadan.net/oficina/equipo/internal/equipotest	2.425s
FAIL
machine: 32 CPUs, load 56.03, cpu waiting 33.63%, memory waiting 0.00%, io waiting 0.37%
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.0%, load 33.05
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 2m13.352s 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 2m11.03s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 20.11s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 20.08s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 20.08s amadan.net/oficina/equipo/internal/equipotest TestProjectOwnersAreMembers
receipt: slow test 20.06s amadan.net/oficina/equipo/internal/equipotest TestProjectRetryAndRevision
receipt: slow test 20.06s amadan.net/oficina/equipo/internal/equipotest TestProjectsSharedAndGrouped
machine: 32 CPUs, load 28.62, cpu waiting 13.05%, memory waiting 0.00%, io waiting 0.13%
--- 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.0%, load 28.44
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 5m33.523s, over the 5m0s its record on line 15 allows; reported only, timing fails on CI

receipt: test step 5m39.504s 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 5m33.523s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 4m41.54s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.45s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.4s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.36s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.3s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 2.41, cpu waiting 0.41%, 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 40.0%, load 33.05
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 1m9.594s 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.499s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.24s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 25.67s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 25.65s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 23.86s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettingsRollbackAndUnavailable
receipt: slow test 23.73s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsUpgrade
machine: 32 CPUs, load 58.99, cpu waiting 35.74%, memory waiting 0.00%, io waiting 0.40%
--- 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.0%, load 33.05
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.361s 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.878s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.95s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.45s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.8s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.66s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.31s amadan.net/oficina/equipo/internal/plan3test TestPlanMigrationUpgrade
machine: 32 CPUs, load 61.35, cpu waiting 38.49%, memory waiting 0.00%, io waiting 0.49%
--- 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.0%, load 33.05
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/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/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/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/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/forge: 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/provider/opencode: 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/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/pi: its inputs changed
budget note: internal/equipo took 2m23.007s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/chat took 25.777s, 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/idtest took 1m51.695s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/release took 37.819s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/runner/containment took 1m0.158s, over the 15s its record on line 40 allows; reported only, timing fails on CI
budget note: internal/runner/forge took 22.772s, over the 20s its record on line 35 allows; reported only, timing fails on CI
budget note: internal/runner/provider/claude/realcli took 14.168s, over the 10s the default allows; reported only, timing fails on CI

receipt: test step 2m30.798s against a 60s target (the gate's other steps are not in this figure)
receipt: 29 packages ran, 41 cached, 16 without tests, 0 failed
receipt: slow package 2m23.007s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 1m51.695s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 1m9.458s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 1m0.158s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow package 52.946s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 55.7s amadan.net/oficina/equipo/internal/idtest TestDoorRemembersOficinaID
receipt: slow test 46.76s amadan.net/oficina/equipo/internal/idtest TestDoorForgetsOficinaIDForARefusedSession
receipt: slow test 46.43s amadan.net/oficina/equipo/internal/idtest TestDoorStepUpIsLocal
receipt: slow test 46.38s amadan.net/oficina/equipo/internal/idtest TestDoorNeverJudgesANativeSession
receipt: slow test 45.41s amadan.net/oficina/equipo/internal/idtest TestDoorOficinaSettingsUnreadableIsNoLoop
machine: 32 CPUs, load 21.90, cpu waiting 9.67%, memory waiting 0.00%, io waiting 0.09%
--- 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 1m26.456s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m24.172s amadan.net/oficina/equipo/internal/headless
receipt: slow test 38.8s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.86s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.6s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.5s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.46s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 61.35, cpu waiting 38.49%, memory waiting 0.00%, io waiting 0.49%
--- 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

receipt: test step 1m32.851s 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 1m30.431s amadan.net/oficina/equipo/internal/headless
receipt: slow test 28.47s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 21.54s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 13.49s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 9.4s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 8.77s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 60.12, cpu waiting 37.83%, memory waiting 0.00%, io waiting 0.44%
--- 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.73s 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.622s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.9s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.41s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 13.18s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 11.3s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsSignInEmail
receipt: slow test 11.25s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
machine: 32 CPUs, load 46.59, cpu waiting 27.88%, memory waiting 0.00%, io waiting 0.30%
--- 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-28T18:04:52.722Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-28T18:04:52.722Z level=INFO msg="startup phase done" phase=state_lock took=144µs
time=2026-11-28T18:04:52.722Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-28T18:04:52.722Z level=INFO msg="startup phase done" phase=claim_roots took=160µs
time=2026-11-28T18:04:52.722Z level=INFO msg="startup phase" phase=sweep
time=2026-11-28T18:04:52.771Z level=INFO msg="startup phase done" phase=sweep took=49.424ms
time=2026-11-28T18:04:52.771Z level=INFO msg="startup phase" phase=credentials
time=2026-11-28T18:04:52.772Z level=INFO msg="startup phase done" phase=credentials took=133µs
time=2026-11-28T18:04:52.772Z level=INFO msg="startup phase" phase=open_state
time=2026-11-28T18:04:52.826Z level=INFO msg="startup phase done" phase=open_state took=54.141ms
time=2026-11-28T18:04:52.827Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-28T18:04:52.829Z level=INFO msg=connecting host=127.0.0.1:34955 protocol=35
time=2026-11-28T18:04:52.830Z level=INFO msg=connected host=127.0.0.1:34955 took=984µs
time=2026-11-28T18:04:52.830Z level=INFO msg="capabilities gathering"
time=2026-11-28T18:04:52.831Z level=INFO msg="capabilities gathered" took=1.417ms tags=linux,claude,go
time=2026-11-28T18:04:52.834Z level=INFO msg="hello sent" protocol=35
time=2026-11-28T18:04:52.840Z 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: context deadline exceeded)
--- FAIL: TestBrowserCopyContinue (6.43s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m40.166s
FAIL	amadan.net/oficina/equipo/internal/headless	100.414s


receipt: test step 1m42.351s 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 1m40.166s amadan.net/oficina/equipo/internal/headless
receipt: slow test 15.15s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 13.33s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.33s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 9.41s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.49s 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 72f26b775f6968546f73a353d1f477a4985ecc9a 6.43s 56.03
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 53.06, cpu waiting 31.59%, memory waiting 0.00%, io waiting 0.35%
--- 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.648s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.449s amadan.net/oficina/equipo/internal/equipo
receipt: slow test 1.82s amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewPassExchange
receipt: slow test 630ms 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 7.963s 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.336s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 6.34s 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.192s, over the 10s the default allows; reported only, timing fails on CI

receipt: test step 12.929s 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.192s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 9.15s amadan.net/oficina/equipo/internal/idtest TestBrowserSmartDoor
receipt: slow test 2.04s 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 4.29s 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.594s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 2.59s 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 3m34.271s 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 3m31.448s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 25.46s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.41s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.06s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.63s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.07s amadan.net/oficina/equipo/internal/thintest TestBrowserRhythm
machine: 32 CPUs, load 8.73, cpu waiting 3.33%, 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.79s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.29s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 8.62s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 9.05s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 27.23s
+ 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.98s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 11.97s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 10.57s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 18.21s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless   (22s)
ok ./internal/headless TestMixedVersions 19.28s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks   (3s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.90s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin   (3s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.07s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 66.38, cpu waiting 36.73%, memory waiting 0.00%, io waiting 0.81%
--- 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 13.382s 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.725s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 175ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 76ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 6ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow test 5.45s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.8s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 320ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 170ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 120ms 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.077s 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.077s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 300ms 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 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
machine: 32 CPUs, load 26.50, cpu waiting 12.05%, memory waiting 0.00%, io waiting 1.54%
--- 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.0%, load 33.05
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
reference scan: 3018 text files, 3232 matches, 3 failures
make[1]: *** [Makefile:238: runner-dead-references] Error 1
machine: 32 CPUs, load 33.05, cpu waiting 17.91%, memory waiting 0.00%, io waiting 1.26%
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 40.0%, load 33.05
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 61.71, cpu waiting 34.72%, memory waiting 0.00%, io waiting 0.87%
--- 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.0%, load 33.05
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 61.71, cpu waiting 34.72%, memory waiting 0.00%, io waiting 0.87%
--- 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.0%, load 33.05
shard 28: make gitleaks
6:04PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
6:04PM INF 1271 commits scanned.
6:04PM INF scanned ~69017397 bytes (69.02 MB) in 25.3s
6:04PM INF no leaks found
machine: 32 CPUs, load 66.38, cpu waiting 35.84%, memory waiting 0.00%, io waiting 0.84%

amadan: job failed at step check shards 12, 25 of 29 — its output is above, not at the tail of this log
diff --git a/cmd/equipo-runner/main.go b/cmd/equipo-runner/main.go
index 6f714040..19651631 100644
--- a/cmd/equipo-runner/main.go
+++ b/cmd/equipo-runner/main.go
@@ -16,6 +16,7 @@ import (
"amadan.net/oficina/equipo/internal/release"
"amadan.net/oficina/equipo/internal/runner"
"amadan.net/oficina/equipo/internal/runner/mac"
+ "amadan.net/oficina/equipo/internal/runner/render"
runnersetup "amadan.net/oficina/equipo/internal/runner/setup"
"amadan.net/oficina/equipo/internal/runner/thin"
"amadan.net/oficina/equipo/internal/runner/webread"
@@ -34,6 +35,11 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
if len(args) > 0 && args[0] == "webread" {
return webread.Main(args[1:], input, errorOutput)
}
+ // The page renderer's sandbox, its first process: started by the
+ // runner under bubblewrap with no environment and no configuration.
+ if len(args) > 0 && args[0] == render.Subcommand {
+ return render.SandboxMain(args[1:], errorOutput)
+ }
if len(args) > 0 && args[0] == "account" {
return accountLogin(ctx, args[1:], input, output, errorOutput, getenv)
}
diff --git a/cmd/equipo-runner/main_test.go b/cmd/equipo-runner/main_test.go
index a056e12f..1242fecd 100644
--- a/cmd/equipo-runner/main_test.go
+++ b/cmd/equipo-runner/main_test.go
@@ -85,6 +85,16 @@ func TestWebreadVerbNeedsNoConfiguration(t *testing.T) {
}
}
+// The render sandbox's first process reads no configuration either, and
+// takes no arguments.
+func TestRenderSandboxVerbNeedsNoConfiguration(t *testing.T) {
+ var out, log bytes.Buffer
+ getenv := func(k string) string { t.Fatalf("render-sandbox read %s", k); return "" }
+ if code := run(context.Background(), []string{"render-sandbox", "/site"}, strings.NewReader(""), &out, &log, getenv); code != 2 || out.Len() != 0 {
+ t.Fatalf("exit %d: %s", code, log.String())
+ }
+}
+
// install-opencode takes one absolute, clean root and nothing else.
func TestInstallOpenCodeArguments(t *testing.T) {
for _, args := range [][]string{nil, {"relative"}, {"/a/../b"}, {"/a", "/b"}} {
diff --git a/internal/runner/render/helpers_linux_test.go b/internal/runner/render/helpers_linux_test.go
new file mode 100644
index 00000000..451db939
--- /dev/null
+++ b/internal/runner/render/helpers_linux_test.go
@@ -0,0 +1,286 @@
+//go:build linux
+
+package render
+
+import (
+ "bufio"
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "io/fs"
+ "net"
+ "net/http"
+ "os"
+ "path/filepath"
+ "slices"
+ "strconv"
+ "strings"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+func helperMain(args []string) (int, bool) {
+ if len(args) > 0 && filepath.Base(args[0]) == filepath.Base(BrowserPath) {
+ return fakeBrowserMain(args[1:]), true
+ }
+ if len(args) > 1 {
+ switch args[1] {
+ case Subcommand:
+ return SandboxMain(args[2:], os.Stderr), true
+ case "render-probe":
+ return probeMain(args[2:]), true
+ }
+ }
+ return 0, false
+}
+
+// openFDs lists this process's open descriptors. It reads /proc/self/fd
+// with raw system calls: os.Open would start Go's poller, whose own
+// descriptors would then be listed.
+func openFDs() []int {
+ d, err := unix.Open("/proc/self/fd", unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
+ if err != nil {
+ return []int{-1}
+ }
+ defer unix.Close(d)
+ var names []string
+ buf := make([]byte, 8192)
+ for {
+ n, err := unix.ReadDirent(d, buf)
+ if err != nil {
+ return []int{-1}
+ }
+ if n == 0 {
+ break
+ }
+ _, _, names = unix.ParseDirent(buf[:n], -1, names)
+ }
+ var fds []int
+ for _, name := range names {
+ if n, err := strconv.Atoi(name); err == nil && n != d {
+ fds = append(fds, n)
+ }
+ }
+ slices.Sort(fds)
+ return fds
+}
+
+type redirectResult struct {
+ // Location is where the in-sandbox server's redirect pointed, as the
+ // client saw it; Status a response, if one ever came.
+ Location string
+ Status int
+ Err string
+ // Blocked is a follow that failed to resolve or connect.
+ Blocked bool
+}
+
+type probeReport struct {
+ FDs []int
+ Env []string
+ Interfaces []string
+ // Loopback is the error dialing a listener inside the sandbox: ""
+ // when it connects, so the failures below are the sandbox's.
+ Loopback string
+ // Dials is each target's dial error, "" for one that connected.
+ Dials map[string]string
+ // Lookup is the error resolving a public name.
+ Lookup string
+ // Writes is each write's error, "" for one that worked.
+ Writes map[string]string
+ Paths []string
+ Redirects map[string]redirectResult
+}
+
+// probeMain runs as the sandbox's first process in render-sandbox's
+// place and writes what it sees and reaches to /out/probe.json. Its
+// arguments are "dial=<host:port>" and "redirect=<url>".
+func probeMain(args []string) int {
+ r := probeReport{FDs: openFDs(), Env: os.Environ(), Dials: map[string]string{}, Writes: map[string]string{}, Redirects: map[string]redirectResult{}}
+ ifs, _ := net.Interfaces()
+ for _, i := range ifs {
+ r.Interfaces = append(r.Interfaces, i.Name)
+ }
+ filepath.WalkDir("/", func(p string, d fs.DirEntry, err error) error {
+ if err != nil {
+ return nil
+ }
+ if p == "/proc" || p == "/sys" || p == "/dev" || p == "/usr" {
+ return fs.SkipDir
+ }
+ if r.Paths = append(r.Paths, p); len(r.Paths) > 10000 {
+ return fs.SkipAll
+ }
+ return nil
+ })
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ r.Loopback = err.Error()
+ } else {
+ defer ln.Close()
+ go func() {
+ for {
+ c, err := ln.Accept()
+ if err != nil {
+ return
+ }
+ c.Close()
+ }
+ }()
+ r.Loopback = dialErr(ln.Addr().String())
+ }
+ var redirects []string
+ for _, a := range args {
+ switch {
+ case strings.HasPrefix(a, "dial="):
+ r.Dials[a[5:]] = dialErr(a[5:])
+ case strings.HasPrefix(a, "redirect="):
+ redirects = append(redirects, a[9:])
+ default:
+ return 2
+ }
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ _, err = net.DefaultResolver.LookupHost(ctx, "example.com")
+ cancel()
+ r.Lookup = errText(err)
+ for _, target := range redirects {
+ r.Redirects[target] = followRedirect(target)
+ }
+ write := func(name string, op func() error) { r.Writes[name] = errText(op()) }
+ create := func(p string) func() error {
+ return func() error { return os.WriteFile(p, []byte("x"), 0o644) }
+ }
+ for _, p := range []string{"/site/new", "/usr/new", "/etc/fonts/new", "/new", "/out/new", "/tmp/new"} {
+ write("create "+p, create(p))
+ }
+ write("open /site/index.html", func() error {
+ f, err := os.OpenFile("/site/index.html", os.O_WRONLY, 0)
+ if err == nil {
+ f.Close()
+ }
+ return err
+ })
+ // Opening the running binary to write is "text file busy" first.
+ write("chmod "+binaryPath, func() error { return os.Chmod(binaryPath, 0o700) })
+ write("mkdir /site/d", func() error { return os.Mkdir("/site/d", 0o755) })
+ write("chmod /site/index.html", func() error { return os.Chmod("/site/index.html", 0o600) })
+ write("remove /site/index.html", func() error { return os.Remove("/site/index.html") })
+ b, _ := json.Marshal(r)
+ if os.WriteFile(filepath.Join(OutDir, "probe.json"), b, 0o600) != nil {
+ return 1
+ }
+ return 0
+}
+
+func dialErr(addr string) string {
+ c, err := net.DialTimeout("tcp", addr, 2*time.Second)
+ if err == nil {
+ c.Close()
+ }
+ return errText(err)
+}
+
+func errText(err error) string {
+ if err == nil {
+ return ""
+ }
+ if s := err.Error(); s != "" {
+ return s
+ }
+ return "error"
+}
+
+// followRedirect asks a server inside the sandbox for a page that
+// redirects to target, follows the redirect and reports what happened.
+func followRedirect(target string) redirectResult {
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ return redirectResult{Err: err.Error()}
+ }
+ defer ln.Close()
+ srv := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ http.Redirect(w, r, target, http.StatusFound)
+ })}
+ go srv.Serve(ln)
+ defer srv.Close()
+ var res redirectResult
+ client := &http.Client{Timeout: 5 * time.Second, CheckRedirect: func(req *http.Request, via []*http.Request) error {
+ res.Location = req.URL.String()
+ return nil
+ }}
+ resp, err := client.Get("http://" + ln.Addr().String() + "/page")
+ if resp != nil {
+ res.Status = resp.StatusCode
+ resp.Body.Close()
+ }
+ res.Err = errText(err)
+ var dns *net.DNSError
+ var op *net.OpError
+ res.Blocked = err != nil && (errors.As(err, &dns) || errors.As(err, &op) && op.Op == "dial")
+ return res
+}
+
+type browserReport struct {
+ Args []string
+ Env []string
+ FDs []int
+ Dir string
+}
+
+// fakeBrowserMain plays the browser: it writes what it was given to
+// /out/browser.json, then answers NUL-ended messages on its pipe (read
+// on 3, written on 4): "get <url>" fetches the URL and replies with the
+// status and body, "post <url>" posts to it and replies with the status, "hang"
+// never returns, "exit <n>" exits with n, anything else is echoed.
+func fakeBrowserMain(args []string) int {
+ r := browserReport{Args: args, Env: os.Environ(), FDs: openFDs()}
+ r.Dir, _ = os.Getwd()
+ b, _ := json.Marshal(r)
+ if os.WriteFile(filepath.Join(OutDir, "browser.json"), b, 0o600) != nil {
+ return 3
+ }
+ in, out := os.NewFile(3, "in"), os.NewFile(4, "out")
+ read := bufio.NewReader(in)
+ for {
+ msg, err := read.ReadString(0)
+ if err != nil {
+ return 0
+ }
+ msg = strings.TrimSuffix(msg, "\x00")
+ switch {
+ case strings.HasPrefix(msg, "get "):
+ reply := "error"
+ if resp, err := http.Get(msg[4:]); err == nil {
+ body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
+ resp.Body.Close()
+ reply = fmt.Sprintf("%d %s", resp.StatusCode, body)
+ } else {
+ reply = "error " + err.Error()
+ }
+ out.WriteString(reply + "\x00")
+ case strings.HasPrefix(msg, "post "):
+ reply := "error"
+ if resp, err := http.Post(msg[5:], "text/plain", strings.NewReader("x")); err == nil {
+ resp.Body.Close()
+ reply = strconv.Itoa(resp.StatusCode)
+ }
+ out.WriteString(reply + "\x00")
+ case msg == "hang":
+ // A browser that never ends on its own, even when its pipe
+ // closes: only a kill stops it.
+ out.WriteString("hanging\x00")
+ for {
+ time.Sleep(time.Hour)
+ }
+ case strings.HasPrefix(msg, "exit "):
+ n, _ := strconv.Atoi(msg[5:])
+ return n
+ default:
+ out.WriteString(msg + "\x00")
+ }
+ }
+}
diff --git a/internal/runner/render/helpers_other_test.go b/internal/runner/render/helpers_other_test.go
new file mode 100644
index 00000000..70ad5d6c
--- /dev/null
+++ b/internal/runner/render/helpers_other_test.go
@@ -0,0 +1,5 @@
+//go:build !linux
+
+package render
+
+func helperMain([]string) (int, bool) { return 0, false }
diff --git a/internal/runner/render/launch_linux.go b/internal/runner/render/launch_linux.go
new file mode 100644
index 00000000..57940060
--- /dev/null
+++ b/internal/runner/render/launch_linux.go
@@ -0,0 +1,384 @@
+//go:build linux
+
+package render
+
+import (
+ "bufio"
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "math"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+ "runtime"
+ "strconv"
+ "syscall"
+ "time"
+
+ "golang.org/x/sys/unix"
+
+ "amadan.net/oficina/equipo/internal/release"
+)
+
+// Descriptors bubblewrap receives beyond the three the sandbox keeps
+// (fdBrowserIn, fdBrowserOut, fdStatus): each is bound by --ro-bind-fd
+// or --bind-fd, and bubblewrap closes it once bound, so the sandbox's
+// first process never holds one.
+const (
+ fdUsr = 6
+ fdFonts = 7
+ fdBinary = 8
+ fdSite = 9
+ fdOut = 10
+)
+
+// bwrapArgs is the sandbox's launch policy (task 1's spike, which ran the
+// browser with its own sandbox on): every namespace unshared, so loopback
+// is the only interface; the verified tree read only as /usr, with the
+// loader paths as links into it, and its fontconfig at /etc/fonts; the
+// runner's binary read only; the site read only and /out read-write; a
+// tmpfs /tmp, a fresh /proc and bubblewrap's minimal /dev; the root
+// itself read only. No home, environment, credentials or runner state.
+func bwrapArgs(argv ...string) []string {
+ fd := strconv.Itoa
+ return append([]string{
+ "--unshare-all", "--unshare-user",
+ "--die-with-parent", "--new-session", "--clearenv", "--cap-drop", "ALL",
+ "--ro-bind-fd", fd(fdUsr), "/usr",
+ "--symlink", "usr/lib", "/lib",
+ "--symlink", "usr/lib64", "/lib64",
+ "--symlink", "usr/bin", "/bin",
+ "--ro-bind-fd", fd(fdFonts), "/etc/fonts",
+ "--ro-bind-fd", fd(fdBinary), binaryPath,
+ "--ro-bind-fd", fd(fdSite), SiteDir,
+ "--bind-fd", fd(fdOut), OutDir,
+ "--tmpfs", "/tmp",
+ "--proc", "/proc",
+ "--dev", "/dev",
+ "--remount-ro", "/",
+ "--chdir", "/",
+ "--", binaryPath,
+ }, argv...)
+}
+
+// Launch verifies the renderer tree against the pin, starts the sandbox
+// and waits until render-sandbox reports the site served and the browser
+// started. ctx bounds the sandbox's whole life: when it ends, bubblewrap
+// and everything in the sandbox are killed. A tree that does not verify
+// is a *release.RendererError and nothing starts.
+func Launch(ctx context.Context, cfg LaunchConfig) (*Sandbox, error) {
+ s, err := start(ctx, cfg, Subcommand)
+ if err != nil {
+ return nil, err
+ }
+ wait := cfg.StartTimeout
+ if wait <= 0 {
+ wait = StartTimeout
+ }
+ timer := time.NewTimer(wait)
+ defer timer.Stop()
+ select {
+ case st := <-s.ready:
+ if st.Event == "ready" {
+ s.Site = st.Site
+ return s, nil
+ }
+ err = fmt.Errorf("render: the sandbox failed (%s)", st.Reason)
+ case <-s.done:
+ select {
+ case st := <-s.ready:
+ err = fmt.Errorf("render: the sandbox ended (%s %s)", st.Event, st.Reason)
+ default:
+ err = errors.New("render: the sandbox ended before it was ready")
+ }
+ case <-timer.C:
+ err = errors.New("render: the sandbox was not ready in time")
+ case <-ctx.Done():
+ err = ctx.Err()
+ }
+ s.Close()
+ if s.err != nil {
+ err = fmt.Errorf("%w: %v", err, s.err)
+ }
+ return nil, fmt.Errorf("%w: %s", err, bytes.TrimSpace(s.stderr.Bytes()))
+}
+
+// siteURL is the only address render-sandbox may report.
+var siteURL = regexp.MustCompile(`^http://127\.0\.0\.1:[1-9][0-9]{0,4}/$`)
+
+// start starts bubblewrap with argv as the sandbox's first process (a
+// test runs a probe in render-sandbox's place) and returns at once.
+func start(ctx context.Context, cfg LaunchConfig, argv ...string) (*Sandbox, error) {
+ for _, p := range []string{cfg.Bwrap, cfg.Binary, cfg.Tree, cfg.Site, cfg.Out} {
+ if !filepath.IsAbs(p) || filepath.Clean(p) != p {
+ return nil, fmt.Errorf("render: launch path %q", p)
+ }
+ }
+ if err := release.VerifyRenderer(cfg.Tree, cfg.Pin); err != nil {
+ return nil, err
+ }
+ var files []*os.File
+ closeAll := func() {
+ for _, f := range files {
+ f.Close()
+ }
+ }
+ defer closeAll()
+ browserIn, toBrowser, err := os.Pipe()
+ if err != nil {
+ return nil, err
+ }
+ fromBrowser, browserOut, err := os.Pipe()
+ if err != nil {
+ toBrowser.Close()
+ browserIn.Close()
+ return nil, err
+ }
+ statusRead, statusWrite, err := os.Pipe()
+ if err != nil {
+ toBrowser.Close()
+ browserIn.Close()
+ fromBrowser.Close()
+ browserOut.Close()
+ return nil, err
+ }
+ // The child's ends, closed here once bubblewrap has them; ExtraFiles
+ // gives them descriptors 3, 4 and 5 in order.
+ files = append(files, browserIn, browserOut, statusWrite)
+ ours := []*os.File{toBrowser, fromBrowser, statusRead}
+ fail := func(err error) (*Sandbox, error) {
+ for _, f := range ours {
+ f.Close()
+ }
+ return nil, err
+ }
+ usr, fonts, err := pinTree(cfg.Tree)
+ if err != nil {
+ return fail(err)
+ }
+ files = append(files, usr, fonts)
+ binary, err := pinFile(cfg.Binary)
+ if err != nil {
+ return fail(err)
+ }
+ files = append(files, binary)
+ site, err := pinSite(cfg.Site)
+ if err != nil {
+ return fail(err)
+ }
+ files = append(files, site)
+ out, err := pinOutDir(cfg.Out)
+ if err != nil {
+ return fail(err)
+ }
+ files = append(files, out)
+
+ ctx, cancel := context.WithCancel(ctx)
+ s := &Sandbox{ToBrowser: toBrowser, FromBrowser: fromBrowser, done: make(chan struct{}), stop: cancel, ready: make(chan status, 1), stderr: &bounded{max: 8192}}
+ cmd := exec.CommandContext(ctx, cfg.Bwrap, bwrapArgs(argv...)...)
+ cmd.Env = []string{}
+ cmd.Dir = "/"
+ cmd.ExtraFiles = files
+ cmd.Stdout = s.stderr
+ cmd.Stderr = s.stderr
+ cmd.WaitDelay = 5 * time.Second
+ cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL}
+ statusDone := make(chan struct{})
+ started := make(chan error, 1)
+ go func() {
+ // Pdeathsig follows the thread that forked: keep it until the
+ // wait ends.
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+ // Every descriptor of this process is close-on-exec, so the
+ // child gets only 0, 1, 2 and ExtraFiles. Go opens its own that
+ // way; this catches one left inheritable by anyone else.
+ if err := closeOnExecFrom(3); err != nil {
+ started <- err
+ return
+ }
+ if err := cmd.Start(); err != nil {
+ started <- err
+ return
+ }
+ s.pid = cmd.Process.Pid
+ started <- nil
+ err := cmd.Wait()
+ select {
+ case <-statusDone:
+ case <-time.After(5 * time.Second):
+ }
+ statusRead.Close()
+ cancel()
+ if cfg.Stderr != nil {
+ cfg.Stderr.Write(s.stderr.Bytes())
+ }
+ s.err = err
+ close(s.done)
+ }()
+ if err = <-started; err != nil {
+ cancel()
+ return fail(fmt.Errorf("render: start bubblewrap: %w", err))
+ }
+ go s.readStatus(statusRead, statusDone)
+ return s, nil
+}
+
+// readStatus reads render-sandbox's status lines: at most 8, each at most
+// 1 KiB of JSON. The first ready or failed goes to s.ready; an exit is
+// how the browser ended. Anything else ends the reading.
+func (s *Sandbox) readStatus(r *os.File, done chan<- struct{}) {
+ defer close(done)
+ scan := bufio.NewScanner(r)
+ scan.Buffer(make([]byte, 1024), 1024)
+ first := true
+ for n := 0; n < 8 && scan.Scan(); n++ {
+ var st status
+ if json.Unmarshal(scan.Bytes(), &st) != nil {
+ return
+ }
+ switch {
+ case first && st.Event == "ready" && siteURL.MatchString(st.Site),
+ first && st.Event == "failed":
+ first = false
+ s.ready <- st
+ case !first && st.Event == "exit":
+ s.mu.Lock()
+ s.exit = BrowserExit{Known: true, Code: st.Code, Signal: st.Signal}
+ s.mu.Unlock()
+ default:
+ return
+ }
+ }
+}
+
+// closeOnExecFrom marks every descriptor from first up close-on-exec.
+func closeOnExecFrom(first int) error {
+ if unix.CloseRange(uint(first), math.MaxUint32, unix.CLOSE_RANGE_CLOEXEC) == nil {
+ return nil
+ }
+ // Kernels before 5.11: one at a time.
+ return closeOnExecEach(first)
+}
+
+// closeOnExecEach is closeOnExecFrom by /proc/self/fd, one descriptor at
+// a time.
+func closeOnExecEach(first int) error {
+ d, err := os.Open("/proc/self/fd")
+ if err != nil {
+ return err
+ }
+ defer d.Close()
+ names, err := d.Readdirnames(-1)
+ if err != nil {
+ return err
+ }
+ for _, name := range names {
+ n, err := strconv.Atoi(name)
+ if err != nil || n < first {
+ continue
+ }
+ if _, err = unix.FcntlInt(uintptr(n), unix.F_SETFD, unix.FD_CLOEXEC); err != nil && !errors.Is(err, unix.EBADF) {
+ return err
+ }
+ }
+ return nil
+}
+
+// pinTree opens the verified tree's usr and etc/fonts with no symlink
+// followed and nothing outside the tree reached: these descriptors, not
+// paths, are what bubblewrap binds.
+func pinTree(tree string) (usr, fonts *os.File, err error) {
+ root, err := unix.Openat2(unix.AT_FDCWD, tree, &unix.OpenHow{Flags: unix.O_PATH | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS})
+ if err != nil {
+ return nil, nil, fmt.Errorf("render: renderer tree: %w", err)
+ }
+ defer unix.Close(root)
+ open := func(rel string) (*os.File, error) {
+ fd, err := unix.Openat2(root, rel, &unix.OpenHow{Flags: unix.O_PATH | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_BENEATH | unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS})
+ if err != nil {
+ return nil, fmt.Errorf("render: renderer tree %s: %w", rel, err)
+ }
+ return os.NewFile(uintptr(fd), filepath.Join(tree, rel)), nil
+ }
+ if usr, err = open("usr"); err != nil {
+ return nil, nil, err
+ }
+ if fonts, err = open("etc/fonts"); err != nil {
+ usr.Close()
+ return nil, nil, err
+ }
+ return usr, fonts, nil
+}
+
+// pinDir opens dir with no symlink anywhere in its path and checks it is
+// a directory this user owns that nobody else can write.
+func pinDir(dir string) (*os.File, unix.Stat_t, error) {
+ var st unix.Stat_t
+ fd, err := unix.Openat2(unix.AT_FDCWD, dir, &unix.OpenHow{Flags: unix.O_PATH | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS})
+ if err != nil {
+ return nil, st, fmt.Errorf("render: %s: %w", dir, err)
+ }
+ f := os.NewFile(uintptr(fd), dir)
+ if err = unix.Fstat(fd, &st); err != nil || st.Mode&unix.S_IFMT != unix.S_IFDIR || st.Mode&0o022 != 0 || st.Uid != uint32(os.Geteuid()) {
+ f.Close()
+ return nil, st, fmt.Errorf("render: %s is not a directory only this user can write", dir)
+ }
+ return f, st, nil
+}
+
+// pinSite is the site's directory, as pinDir.
+func pinSite(dir string) (*os.File, error) {
+ f, _, err := pinDir(dir)
+ return f, err
+}
+
+// pinOutDir is the output directory, as pinDir, and also private (0700)
+// and empty.
+func pinOutDir(dir string) (*os.File, error) {
+ f, st, err := pinDir(dir)
+ if err != nil {
+ return nil, err
+ }
+ if st.Mode&0o777 != 0o700 {
+ f.Close()
+ return nil, fmt.Errorf("render: output directory %s is not private", dir)
+ }
+ list, err := unix.Openat(int(f.Fd()), ".", unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
+ if err != nil {
+ f.Close()
+ return nil, err
+ }
+ d := os.NewFile(uintptr(list), dir)
+ names, _ := d.Readdirnames(1)
+ d.Close()
+ if len(names) != 0 {
+ f.Close()
+ return nil, fmt.Errorf("render: output directory %s is not empty", dir)
+ }
+ return f, nil
+}
+
+// pinFile resolves path's symlinks on the host, then opens the regular
+// file they name with no symlink followed.
+func pinFile(path string) (*os.File, error) {
+ real, err := filepath.EvalSymlinks(path)
+ if err != nil {
+ return nil, fmt.Errorf("render: %w", err)
+ }
+ fd, err := unix.Openat2(unix.AT_FDCWD, real, &unix.OpenHow{Flags: unix.O_PATH | unix.O_CLOEXEC, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS})
+ if err != nil {
+ return nil, fmt.Errorf("render: %s: %w", path, err)
+ }
+ f := os.NewFile(uintptr(fd), real)
+ var st unix.Stat_t
+ if err = unix.Fstat(fd, &st); err != nil || st.Mode&unix.S_IFMT != unix.S_IFREG {
+ f.Close()
+ return nil, fmt.Errorf("render: %s is not a regular file", path)
+ }
+ return f, nil
+}
diff --git a/internal/runner/render/launch_linux_test.go b/internal/runner/render/launch_linux_test.go
new file mode 100644
index 00000000..92d23a76
--- /dev/null
+++ b/internal/runner/render/launch_linux_test.go
@@ -0,0 +1,739 @@
+//go:build linux
+
+package render
+
+import (
+ "bufio"
+ "context"
+ "crypto/sha256"
+ "debug/elf"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "net"
+ "net/netip"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "slices"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "golang.org/x/sys/unix"
+
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/testci"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// usableBwrap is bubblewrap, when it can make namespaces here, and this
+// test binary, which must be static to run inside a sandbox with no
+// host /usr.
+func usableBwrap(t *testing.T) (bwrap, self string) {
+ t.Helper()
+ testci.Tools(t, "bwrap")
+ bwrap, err := exec.LookPath("bwrap")
+ if err != nil {
+ testci.Absent(t, "bwrap is not installed")
+ }
+ if out, err := exec.Command(bwrap, "--unshare-all", "--ro-bind", "/", "/", "true").CombinedOutput(); err != nil {
+ testci.Absent(t, "bwrap cannot create namespaces here: "+strings.TrimSpace(string(out)))
+ }
+ if self, err = os.Executable(); err != nil {
+ t.Fatal(err)
+ }
+ if self, err = filepath.EvalSymlinks(self); err != nil {
+ t.Fatal(err)
+ }
+ f, err := elf.Open(self)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ for _, p := range f.Progs {
+ if p.Type == elf.PT_INTERP {
+ t.Skip("the test binary is dynamically linked; run with CGO_ENABLED=0 as make does")
+ }
+ }
+ return bwrap, self
+}
+
+func tempDir(t *testing.T) string {
+ t.Helper()
+ dir, err := filepath.EvalSymlinks(t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ return dir
+}
+
+// testTree writes a renderer tree that verifies, with the layout the
+// launch binds (usr, etc/fonts) and, when browser is not "", that file
+// as the browser. It returns the tree and its pin.
+func testTree(t *testing.T, browser string) (dir, pin string) {
+ t.Helper()
+ dir = filepath.Join(tempDir(t), "tree")
+ entries := []string{"dir etc", "dir etc/fonts", "dir usr", "dir usr/lib", "dir usr/lib/chromium"}
+ must(t, os.Mkdir(dir, 0o755))
+ for _, e := range entries {
+ must(t, os.Mkdir(filepath.Join(dir, strings.TrimPrefix(e, "dir ")), 0o755))
+ }
+ if browser != "" {
+ raw, err := os.ReadFile(browser)
+ must(t, err)
+ rel := strings.TrimPrefix(BrowserPath, "/")
+ must(t, os.WriteFile(filepath.Join(dir, rel), raw, 0o755))
+ sum := sha256.Sum256(raw)
+ entries = append(entries, fmt.Sprintf("file %s %x 0755", rel, sum))
+ }
+ manifest := strings.Join(entries, "\n") + "\n"
+ must(t, os.WriteFile(filepath.Join(dir, "MANIFEST"), []byte(manifest), 0o644))
+ sum := sha256.Sum256([]byte(manifest))
+ pin = hex.EncodeToString(sum[:])
+ if err := release.VerifyRenderer(dir, pin); err != nil {
+ t.Fatalf("test tree: %v", err)
+ }
+ return dir, pin
+}
+
+func testSite(t *testing.T) string {
+ t.Helper()
+ dir := filepath.Join(tempDir(t), "site")
+ must(t, os.Mkdir(dir, 0o755))
+ must(t, os.WriteFile(filepath.Join(dir, "index.html"), []byte("<title>shop</title>"), 0o644))
+ return dir
+}
+
+func testOut(t *testing.T) string {
+ t.Helper()
+ dir := filepath.Join(tempDir(t), "out")
+ must(t, os.Mkdir(dir, 0o700))
+ return dir
+}
+
+func must(t *testing.T, errs ...error) {
+ t.Helper()
+ for _, err := range errs {
+ if err != nil && !errors.Is(err, os.ErrExist) {
+ t.Fatal(err)
+ }
+ }
+}
+
+func testConfig(t *testing.T, browser bool) LaunchConfig {
+ t.Helper()
+ bwrap, self := usableBwrap(t)
+ b := ""
+ if browser {
+ b = self
+ }
+ tree, pin := testTree(t, b)
+ return LaunchConfig{Bwrap: bwrap, Binary: self, Tree: tree, Pin: pin, Site: testSite(t), Out: testOut(t)}
+}
+
+// runProbe runs the probe as the sandbox's first process and returns
+// its report.
+func runProbe(t *testing.T, cfg LaunchConfig, args ...string) probeReport {
+ t.Helper()
+ ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
+ defer cancel()
+ s, err := start(ctx, cfg, append([]string{"render-probe"}, args...)...)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = s.Wait(); err != nil {
+ t.Fatalf("probe: %v: %s", err, s.stderr.Bytes())
+ }
+ s.Close()
+ raw, err := os.ReadFile(filepath.Join(cfg.Out, "probe.json"))
+ if err != nil {
+ t.Fatalf("probe report: %v: %s", err, s.stderr.Bytes())
+ }
+ var r probeReport
+ if err = json.Unmarshal(raw, &r); err != nil {
+ t.Fatal(err)
+ }
+ return r
+}
+
+// The policy is the spike's, exactly: no --share-net, nothing from the
+// host but the descriptors it binds, and the environment cleared.
+func TestBwrapArgs(t *testing.T) {
+ want := "--unshare-all --unshare-user --die-with-parent --new-session --clearenv --cap-drop ALL" +
+ " --ro-bind-fd 6 /usr --symlink usr/lib /lib --symlink usr/lib64 /lib64 --symlink usr/bin /bin" +
+ " --ro-bind-fd 7 /etc/fonts --ro-bind-fd 8 /runner --ro-bind-fd 9 /site --bind-fd 10 /out" +
+ " --tmpfs /tmp --proc /proc --dev /dev --remount-ro / --chdir / -- /runner render-sandbox"
+ got := bwrapArgs(Subcommand)
+ if strings.Join(got, " ") != want {
+ t.Fatalf("bwrap args\n got %s\nwant %s", strings.Join(got, " "), want)
+ }
+ for _, a := range got {
+ if strings.HasPrefix(a, "--share") || a == "--setenv" || a == "--bind" || a == "--ro-bind" || a == "--dev-bind" {
+ t.Errorf("bwrap arg %s", a)
+ }
+ }
+}
+
+// tailnetAddr is one of this host's tailnet addresses (100.64.0.0/10),
+// if it has one.
+func tailnetAddr() (netip.Addr, bool) {
+ cgnat := netip.MustParsePrefix("100.64.0.0/10")
+ addrs, _ := net.InterfaceAddrs()
+ for _, a := range addrs {
+ if p, err := netip.ParsePrefix(a.String()); err == nil && cgnat.Contains(p.Addr()) {
+ return p.Addr(), true
+ }
+ }
+ return netip.Addr{}, false
+}
+
+// listen opens a listener on the host that accepts and closes.
+func listen(t *testing.T, addr string) string {
+ t.Helper()
+ ln, err := net.Listen("tcp", addr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { ln.Close() })
+ go func() {
+ for {
+ c, err := ln.Accept()
+ if err != nil {
+ return
+ }
+ c.Close()
+ }
+ }()
+ return ln.Addr().String()
+}
+
+// From inside, only the sandbox's own loopback answers: a public IP, the
+// host's tailnet address and a listener on the host's 127.0.0.1 are
+// unreachable, and no name resolves.
+func TestSandboxReachesNoNetwork(t *testing.T) {
+ cfg := testConfig(t, false)
+ targets := map[string]string{
+ "public IPv4": "1.1.1.1:443",
+ "public IPv6": "[2606:4700:4700::1111]:443",
+ "host loopback": listen(t, "127.0.0.1:0"),
+ }
+ if addr, ok := tailnetAddr(); ok {
+ targets["host tailnet"] = listen(t, netip.AddrPortFrom(addr, 0).String())
+ } else {
+ t.Log("this host has no tailnet address; that case is not run")
+ }
+ var args []string
+ for _, a := range targets {
+ args = append(args, "dial="+a)
+ }
+ r := runProbe(t, cfg, args...)
+ if r.Loopback != "" {
+ t.Fatalf("the sandbox's own loopback does not work: %s", r.Loopback)
+ }
+ if !slices.Equal(r.Interfaces, []string{"lo"}) {
+ t.Errorf("interfaces %q", r.Interfaces)
+ }
+ for name, a := range targets {
+ if e, ok := r.Dials[a]; !ok || e == "" {
+ t.Errorf("%s %s: reached from inside (%q)", name, a, e)
+ }
+ }
+ if r.Lookup == "" {
+ t.Error("a public name resolved from inside")
+ }
+}
+
+// A descriptor the runner left inheritable never reaches the sandbox:
+// its first process holds 0, 1, 2, the browser's pipe and the status
+// pipe, and the runner's own descriptor stays open.
+func TestSandboxSeesNoParentDescriptor(t *testing.T) {
+ cfg := testConfig(t, false)
+ secret := filepath.Join(tempDir(t), "forge.json")
+ must(t, os.WriteFile(secret, []byte(`{"token":"secret"}`), 0o600))
+ opened, err := os.Open(secret)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer opened.Close()
+ // Above the descriptors the launch hands bubblewrap (3 to 10), which
+ // would replace it in the child, and without close-on-exec, as F_DUPFD
+ // leaves it.
+ fd, err := unix.FcntlInt(opened.Fd(), unix.F_DUPFD, 20)
+ if err != nil {
+ t.Fatal(err)
+ }
+ f := os.NewFile(uintptr(fd), secret)
+ defer f.Close()
+ if flags, err := unix.FcntlInt(f.Fd(), unix.F_GETFD, 0); err != nil || flags&unix.FD_CLOEXEC != 0 {
+ t.Fatalf("the descriptor is not inheritable: %d %v", flags, err)
+ }
+ r := runProbe(t, cfg)
+ if want := []int{0, 1, 2, fdBrowserIn, fdBrowserOut, fdStatus}; !slices.Equal(r.FDs, want) {
+ t.Fatalf("descriptors inside %v, want %v (the runner's file is %d)", r.FDs, want, f.Fd())
+ }
+ if _, err = f.Stat(); err != nil {
+ t.Fatalf("the runner's own descriptor: %v", err)
+ }
+}
+
+// The sandbox's first process starts with an empty environment: nothing
+// from the runner's. Bubblewrap itself sets PWD after --chdir.
+func TestSandboxEnvironmentIsEmpty(t *testing.T) {
+ cfg := testConfig(t, false)
+ t.Setenv("EQUIPO_RUNNER_TOKEN", "secret")
+ t.Setenv("HOME", "/home/runner")
+ r := runProbe(t, cfg)
+ if len(r.Env) > 1 || len(r.Env) == 1 && r.Env[0] != "PWD=/" {
+ t.Fatalf("environment %q", r.Env)
+ }
+}
+
+// /site, the tree, the binary and the root are read only; /out and /tmp
+// are the only places the sandbox writes.
+func TestSandboxSiteIsReadOnly(t *testing.T) {
+ cfg := testConfig(t, false)
+ r := runProbe(t, cfg)
+ for op, e := range r.Writes {
+ writable := op == "create /out/new" || op == "create /tmp/new"
+ switch {
+ case writable && e != "":
+ t.Errorf("%s: %s", op, e)
+ case !writable && !strings.Contains(e, "read-only file system"):
+ t.Errorf("%s: %q, want read-only file system", op, e)
+ }
+ }
+ if len(r.Writes) != 11 {
+ t.Errorf("writes %v", r.Writes)
+ }
+ if raw, err := os.ReadFile(filepath.Join(cfg.Site, "index.html")); err != nil || string(raw) != "<title>shop</title>" {
+ t.Errorf("the site changed: %q %v", raw, err)
+ }
+ if _, err := os.Stat(filepath.Join(cfg.Site, "new")); err == nil {
+ t.Error("the sandbox created a file in the site")
+ }
+}
+
+// Nothing of the host but what the launch binds is visible: no home,
+// runner state or credentials.
+func TestSandboxHoldsNoRunnerState(t *testing.T) {
+ cfg := testConfig(t, false)
+ r := runProbe(t, cfg)
+ allowed := map[string]bool{"/": true, "/bin": true, "/lib": true, "/lib64": true, "/etc": true, "/etc/fonts": true, binaryPath: true, "/site": true, "/site/index.html": true, "/out": true, "/tmp": true, "/usr": true, "/proc": true, "/dev": true}
+ for _, p := range r.Paths {
+ if !allowed[p] {
+ t.Errorf("the sandbox shows %s", p)
+ }
+ }
+ if !slices.Contains(r.Paths, "/site/index.html") {
+ t.Errorf("paths %q", r.Paths)
+ }
+}
+
+// A page whose server redirects to an external host gets the redirect,
+// and following it fails to resolve or connect: reported, not followed.
+func TestSandboxRedirectIsReportedNotFollowed(t *testing.T) {
+ cfg := testConfig(t, false)
+ targets := []string{"http://cdn.example.com/app.js", "http://1.1.1.1/", "http://[2606:4700:4700::1111]/"}
+ var args []string
+ for _, u := range targets {
+ args = append(args, "redirect="+u)
+ }
+ r := runProbe(t, cfg, args...)
+ for _, u := range targets {
+ got, ok := r.Redirects[u]
+ if !ok || got.Location != u {
+ t.Errorf("%s: the redirect was not seen: %+v", u, got)
+ continue
+ }
+ if got.Status != 0 || !got.Blocked {
+ t.Errorf("%s: followed: %+v", u, got)
+ }
+ }
+}
+
+// Launch runs the real subcommand: the site served on the sandbox's
+// 127.0.0.1, the browser started with its pipe on 3 and 4 and nothing
+// else, HOME=/tmp its whole environment, and its exit reported.
+func TestLaunchStartsTheBrowser(t *testing.T) {
+ cfg := testConfig(t, true)
+ ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
+ defer cancel()
+ s, err := Launch(ctx, cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer s.Close()
+ if !siteURL.MatchString(s.Site) {
+ t.Fatalf("site %q", s.Site)
+ }
+ from := bufio.NewReader(s.FromBrowser)
+ ask := func(msg string) string {
+ t.Helper()
+ if _, err := s.ToBrowser.WriteString(msg + "\x00"); err != nil {
+ t.Fatal(err)
+ }
+ reply, err := from.ReadString(0)
+ if err != nil {
+ t.Fatalf("%s: %v", msg, err)
+ }
+ return strings.TrimSuffix(reply, "\x00")
+ }
+ if got := ask("ping"); got != "ping" {
+ t.Fatalf("echo %q", got)
+ }
+ if got := ask("get " + s.Site + "index.html"); got != "200 <title>shop</title>" {
+ t.Fatalf("site %q", got)
+ }
+ if got := ask("get " + s.Site + "../../usr/lib/chromium/chromium-headless-shell"); strings.HasPrefix(got, "200") {
+ t.Fatalf("the site server left /site: %.40q", got)
+ }
+ if got := ask("post " + s.Site + "index.html"); got != "405" {
+ t.Fatalf("post %q", got)
+ }
+ s.ToBrowser.WriteString("exit 7\x00")
+ exit, err := s.Wait()
+ if err != nil || exit != (BrowserExit{Known: true, Code: 7}) {
+ t.Fatalf("exit %+v, %v: %s", exit, err, s.stderr.Bytes())
+ }
+ if _, err = from.ReadByte(); err == nil {
+ t.Fatal("the browser's pipe is still open")
+ }
+ raw, err := os.ReadFile(filepath.Join(cfg.Out, "browser.json"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var b browserReport
+ if err = json.Unmarshal(raw, &b); err != nil {
+ t.Fatal(err)
+ }
+ if !slices.Equal(b.Args, browserArgs()) {
+ t.Errorf("browser args %q", b.Args)
+ }
+ if !slices.Equal(b.Env, []string{"HOME=/tmp"}) {
+ t.Errorf("browser environment %q", b.Env)
+ }
+ if !slices.Equal(b.FDs, []int{0, 1, 2, fdBrowserIn, fdBrowserOut}) {
+ t.Errorf("browser descriptors %v", b.FDs)
+ }
+ if b.Dir != "/tmp" {
+ t.Errorf("browser directory %q", b.Dir)
+ }
+}
+
+// Closing a sandbox kills everything in it, a browser that would never
+// end on its own included.
+func TestCloseKillsTheSandbox(t *testing.T) {
+ cfg := testConfig(t, true)
+ ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
+ defer cancel()
+ s, err := Launch(ctx, cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ s.ToBrowser.WriteString("hang\x00")
+ if reply, err := bufio.NewReader(s.FromBrowser).ReadString(0); err != nil || reply != "hanging\x00" {
+ t.Fatalf("hang: %q %v", reply, err)
+ }
+ inside := descendants(s.pid)
+ if len(inside) < 2 {
+ t.Fatalf("processes in the sandbox: %v", inside)
+ }
+ // Should the kill fail, the test still leaves nothing running.
+ t.Cleanup(func() {
+ for _, n := range inside {
+ unix.Kill(n, unix.SIGKILL)
+ }
+ })
+ done := make(chan struct{})
+ go func() { s.Close(); close(done) }()
+ select {
+ case <-done:
+ case <-time.After(20 * time.Second):
+ t.Fatal("Close did not end the sandbox")
+ }
+ if _, err = s.Wait(); err == nil {
+ t.Fatal("a killed sandbox reported success")
+ }
+ // Every process that was in the sandbox (bubblewrap's, the
+ // subcommand, the browser) ends: the kernel kills the rest of a PID
+ // namespace when its first process dies, a moment after bubblewrap.
+ deadline := time.Now().Add(5 * time.Second)
+ for _, n := range inside {
+ for alive(n) && time.Now().Before(deadline) {
+ time.Sleep(20 * time.Millisecond)
+ }
+ if alive(n) {
+ raw, _ := os.ReadFile(filepath.Join("/proc", strconv.Itoa(n), "status"))
+ t.Errorf("process %d outlived the sandbox: %.200s", n, raw)
+ }
+ }
+}
+
+// alive is a process that exists and is not a zombie.
+func alive(pid int) bool {
+ raw, err := os.ReadFile(filepath.Join("/proc", strconv.Itoa(pid), "status"))
+ return err == nil && !strings.Contains(string(raw), "State:\tZ")
+}
+
+// A tree without the browser: render-sandbox reports it and Launch fails.
+func TestLaunchReportsABrowserThatCannotStart(t *testing.T) {
+ cfg := testConfig(t, false)
+ _, err := Launch(context.Background(), cfg)
+ if err == nil || !strings.Contains(err.Error(), "failed ("+reasonBrowser+")") {
+ t.Fatalf("Launch: %v", err)
+ }
+}
+
+// Only a tree that has just verified is mounted: a changed, missing or
+// unpinned tree is the renderer's health and nothing starts.
+func TestLaunchRefusesAnUnverifiedTree(t *testing.T) {
+ for name, c := range map[string]struct {
+ change func(cfg *LaunchConfig)
+ health string
+ }{
+ "tampered": {func(cfg *LaunchConfig) {
+ os.WriteFile(filepath.Join(cfg.Tree, "usr", "lib", "extra"), []byte("x"), 0o644)
+ }, wire.ToolMismatch},
+ "missing": {func(cfg *LaunchConfig) { cfg.Tree = filepath.Join(filepath.Dir(cfg.Tree), "absent") }, wire.ToolMissing},
+ "unpinned": {func(cfg *LaunchConfig) { cfg.Pin = "" }, wire.ToolUnpinned},
+ "other pin": {func(cfg *LaunchConfig) { cfg.Pin = strings.Repeat("a", 64) }, wire.ToolMismatch},
+ } {
+ t.Run(name, func(t *testing.T) {
+ cfg := testConfig(t, false)
+ c.change(&cfg)
+ _, err := Launch(context.Background(), cfg)
+ var re *release.RendererError
+ if !errors.As(err, &re) || re.Health != c.health {
+ t.Fatalf("Launch: %v, want %s", err, c.health)
+ }
+ if names, _ := os.ReadDir(cfg.Out); len(names) != 0 {
+ t.Fatalf("something ran: %v", names)
+ }
+ })
+ }
+}
+
+func TestLaunchRefusesItsInputs(t *testing.T) {
+ base := testConfig(t, false)
+ used := testOut(t)
+ must(t, os.WriteFile(filepath.Join(used, "x"), nil, 0o600))
+ open := testOut(t)
+ must(t, os.Chmod(open, 0o755))
+ link := filepath.Join(tempDir(t), "link")
+ must(t, os.Symlink(testOut(t), link))
+ shared := testSite(t)
+ must(t, os.Chmod(shared, 0o775))
+ siteLink := filepath.Join(tempDir(t), "site-link")
+ must(t, os.Symlink(testSite(t), siteLink))
+ for name, c := range map[string]struct {
+ change func(*LaunchConfig)
+ why string
+ }{
+ "relative bwrap": {func(c *LaunchConfig) { c.Bwrap = "bwrap" }, "launch path"},
+ "relative binary": {func(c *LaunchConfig) { c.Binary = "runner" }, "launch path"},
+ "missing binary": {func(c *LaunchConfig) { c.Binary = "/nonexistent/runner" }, "no such file"},
+ "relative site": {func(c *LaunchConfig) { c.Site = "site" }, "launch path"},
+ "shared site": {func(c *LaunchConfig) { c.Site = shared }, "only this user can write"},
+ "root's site": {func(c *LaunchConfig) { c.Site = "/usr" }, "only this user can write"},
+ "symlinked site": {func(c *LaunchConfig) { c.Site = siteLink }, "symbolic links"},
+ "relative out": {func(c *LaunchConfig) { c.Out = "out" }, "launch path"},
+ "used out": {func(c *LaunchConfig) { c.Out = used }, "not empty"},
+ "open out": {func(c *LaunchConfig) { c.Out = open }, "not private"},
+ "symlinked out": {func(c *LaunchConfig) { c.Out = link }, "symbolic links"},
+ "unclean tree": {func(c *LaunchConfig) { c.Tree += "/" }, "launch path"},
+ } {
+ cfg := base
+ cfg.Out = testOut(t)
+ c.change(&cfg)
+ s, err := Launch(context.Background(), cfg)
+ if err == nil {
+ s.Close()
+ }
+ if err == nil || !strings.Contains(err.Error(), c.why) {
+ t.Errorf("%s: %v, want %q", name, err, c.why)
+ }
+ }
+}
+
+// The status pipe is read strictly: the first line must be ready with a
+// loopback site or failed, lines are bounded, and anything else ends the
+// reading.
+func TestReadStatus(t *testing.T) {
+ for name, c := range map[string]struct {
+ lines string
+ ready string
+ exit BrowserExit
+ }{
+ "ready then exit": {`{"event":"ready","site":"http://127.0.0.1:4100/"}` + "\n" + `{"event":"exit","code":3}` + "\n", "ready", BrowserExit{Known: true, Code: 3}},
+ "failed": {`{"event":"failed","reason":"site"}` + "\n", "failed", BrowserExit{}},
+ "another host": {`{"event":"ready","site":"http://10.0.0.1:4100/"}` + "\n", "", BrowserExit{}},
+ "a path": {`{"event":"ready","site":"http://127.0.0.1:4100/x"}` + "\n", "", BrowserExit{}},
+ "exit first": {`{"event":"exit","code":3}` + "\n", "", BrowserExit{}},
+ "not JSON": {"ready\n" + `{"event":"ready","site":"http://127.0.0.1:4100/"}` + "\n", "", BrowserExit{}},
+ "a long line": {`{"event":"failed","reason":"` + strings.Repeat("x", 2000) + `"}` + "\n", "", BrowserExit{}},
+ "a second ready": {`{"event":"ready","site":"http://127.0.0.1:4100/"}` + "\n" + `{"event":"ready","site":"http://127.0.0.1:4101/"}` + "\n" + `{"event":"exit","code":3}` + "\n", "ready", BrowserExit{}},
+ } {
+ r, w, err := os.Pipe()
+ if err != nil {
+ t.Fatal(err)
+ }
+ go func() { w.WriteString(c.lines); w.Close() }()
+ s := &Sandbox{ready: make(chan status, 1)}
+ done := make(chan struct{})
+ s.readStatus(r, done)
+ r.Close()
+ got := ""
+ select {
+ case st := <-s.ready:
+ got = st.Event
+ default:
+ }
+ if got != c.ready || s.exit != c.exit {
+ t.Errorf("%s: ready %q exit %+v", name, got, s.exit)
+ }
+ }
+}
+
+// Both ways of marking descriptors close-on-exec leave an inheritable
+// descriptor close-on-exec and open.
+func TestCloseOnExec(t *testing.T) {
+ for name, mark := range map[string]func(int) error{"close_range": closeOnExecFrom, "each": closeOnExecEach} {
+ f, err := os.Open(os.DevNull)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fd, err := unix.FcntlInt(f.Fd(), unix.F_DUPFD, 20)
+ f.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = mark(3); err != nil {
+ t.Fatalf("%s: %v", name, err)
+ }
+ flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0)
+ unix.Close(fd)
+ if err != nil || flags&unix.FD_CLOEXEC == 0 {
+ t.Errorf("%s: flags %d, %v", name, flags, err)
+ }
+ }
+}
+
+// The real browser, from a tree scripts/build-renderer-tree.py kept
+// (--tree), starts in the sandbox with its own sandbox on and answers on
+// its pipe. Building a tree downloads about 164 MB, so this runs only
+// when EQUIPO_RENDERER_TREE names one.
+func TestLaunchRealBrowser(t *testing.T) {
+ tree := os.Getenv("EQUIPO_RENDERER_TREE")
+ if tree == "" {
+ t.Skip("set EQUIPO_RENDERER_TREE to a tree built by scripts/build-renderer-tree.py --tree to run the real browser")
+ }
+ bwrap, self := usableBwrap(t)
+ manifest, err := os.ReadFile(filepath.Join(tree, "MANIFEST"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ sum := sha256.Sum256(manifest)
+ var stderr bounded
+ stderr.max = 64 << 10
+ cfg := LaunchConfig{Bwrap: bwrap, Binary: self, Tree: tree, Pin: hex.EncodeToString(sum[:]), Site: testSite(t), Out: testOut(t), Stderr: &stderr}
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ defer cancel()
+ s, err := Launch(ctx, cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer s.Close()
+ from := bufio.NewReader(s.FromBrowser)
+ call := func(id int, method string) map[string]any {
+ t.Helper()
+ msg, _ := json.Marshal(map[string]any{"id": id, "method": method})
+ if _, err := s.ToBrowser.Write(append(msg, 0)); err != nil {
+ t.Fatal(err)
+ }
+ for {
+ raw, err := from.ReadBytes(0)
+ if err != nil {
+ t.Fatalf("%s: %v", method, err)
+ }
+ var reply map[string]any
+ if err = json.Unmarshal(raw[:len(raw)-1], &reply); err != nil {
+ t.Fatalf("%s: %v", method, err)
+ }
+ if reply["id"] == float64(id) {
+ return reply
+ }
+ }
+ }
+ version := call(1, "Browser.getVersion")
+ result, _ := version["result"].(map[string]any)
+ if product, _ := result["product"].(string); !strings.HasPrefix(product, "HeadlessChrome/") {
+ t.Fatalf("version %v", version)
+ }
+ // Chromium's own sandbox is on: a renderer below bubblewrap runs
+ // under its seccomp filter with no new privileges.
+ deadline := time.Now().Add(10 * time.Second)
+ for !sandboxedRenderer(s.pid) {
+ if time.Now().After(deadline) {
+ t.Fatal("no renderer under Chromium's own sandbox")
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+ call(2, "Browser.close")
+ exit, err := s.Wait()
+ if err != nil || exit != (BrowserExit{Known: true}) {
+ t.Fatalf("exit %+v, %v", exit, err)
+ }
+ t.Logf("browser: %v; stderr:\n%s", result["product"], stderr.Bytes())
+}
+
+// descendants lists the processes below pid, read from the host's /proc.
+func descendants(pid int) []int {
+ parent := map[int]int{}
+ entries, _ := os.ReadDir("/proc")
+ for _, e := range entries {
+ n, err := strconv.Atoi(e.Name())
+ if err != nil {
+ continue
+ }
+ raw, err := os.ReadFile(filepath.Join("/proc", e.Name(), "status"))
+ if err != nil {
+ continue
+ }
+ for _, line := range strings.Split(string(raw), "\n") {
+ if v, ok := strings.CutPrefix(line, "PPid:"); ok {
+ parent[n], _ = strconv.Atoi(strings.TrimSpace(v))
+ }
+ }
+ }
+ var below []int
+ for n := range parent {
+ for p, i := parent[n], 0; i < 64 && p > 1; p, i = parent[p], i+1 {
+ if p == pid {
+ below = append(below, n)
+ break
+ }
+ }
+ }
+ return below
+}
+
+// sandboxedRenderer is a process below pid whose command line is a
+// Chromium renderer's and that runs with a seccomp filter (Seccomp 2)
+// and NoNewPrivs 1, read from the host's /proc.
+func sandboxedRenderer(pid int) bool {
+ for _, n := range descendants(pid) {
+ cmdline, _ := os.ReadFile(filepath.Join("/proc", strconv.Itoa(n), "cmdline"))
+ if !strings.Contains(string(cmdline), "--type=renderer") {
+ continue
+ }
+ raw, _ := os.ReadFile(filepath.Join("/proc", strconv.Itoa(n), "status"))
+ st := string(raw)
+ if strings.Contains(st, "\nSeccomp:\t2\n") && strings.Contains(st, "\nNoNewPrivs:\t1\n") {
+ return true
+ }
+ }
+ return false
+}
diff --git a/internal/runner/render/launch_other.go b/internal/runner/render/launch_other.go
new file mode 100644
index 00000000..57f91822
--- /dev/null
+++ b/internal/runner/render/launch_other.go
@@ -0,0 +1,19 @@
+//go:build !linux
+
+package render
+
+import (
+ "context"
+ "io"
+
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// Launch is Linux's alone: elsewhere the renderer is missing.
+func Launch(context.Context, LaunchConfig) (*Sandbox, error) {
+ return nil, &release.RendererError{Health: wire.ToolMissing, Reason: "the renderer runs only on Linux"}
+}
+
+// SandboxMain is Linux's alone.
+func SandboxMain([]string, io.Writer) int { return 2 }
diff --git a/internal/runner/render/launch_other_test.go b/internal/runner/render/launch_other_test.go
new file mode 100644
index 00000000..3e857828
--- /dev/null
+++ b/internal/runner/render/launch_other_test.go
@@ -0,0 +1,21 @@
+//go:build !linux
+
+package render
+
+import (
+ "context"
+ "errors"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// Off Linux there is no renderer: Launch says it is missing.
+func TestLaunchOffLinuxIsMissing(t *testing.T) {
+ _, err := Launch(context.Background(), LaunchConfig{})
+ var re *release.RendererError
+ if !errors.As(err, &re) || re.Health != wire.ToolMissing {
+ t.Fatalf("Launch: %v", err)
+ }
+}
diff --git a/internal/runner/render/main_test.go b/internal/runner/render/main_test.go
new file mode 100644
index 00000000..f6c8aac0
--- /dev/null
+++ b/internal/runner/render/main_test.go
@@ -0,0 +1,20 @@
+package render
+
+import (
+ "os"
+ "testing"
+
+ "amadan.net/rastrillo/rastrillo/budget"
+)
+
+// The test binary doubles as the sandbox's first process and as a fake
+// browser, so the launch tests run under bubblewrap without Chromium:
+// argv "render-sandbox" is SandboxMain, "render-probe ..." reports what
+// the sandbox's first process can see and reach, and a binary named like
+// the browser (BrowserPath, in a test tree) plays the browser.
+func TestMain(m *testing.M) {
+ if code, ok := helperMain(os.Args); ok {
+ os.Exit(code)
+ }
+ os.Exit(budget.Main(m))
+}
diff --git a/internal/runner/render/render.go b/internal/runner/render/render.go
new file mode 100644
index 00000000..5f5fa75e
--- /dev/null
+++ b/internal/runner/render/render.go
@@ -0,0 +1,189 @@
+// Package render runs the page renderer: the pinned headless browser and
+// a server for one exported site, inside a bubblewrap sandbox with no
+// network but its own loopback (spec section 3, "Sandbox").
+//
+// The runner calls Launch. Bubblewrap starts the runner's own binary as
+// the sandbox's first process, its render-sandbox subcommand
+// (SandboxMain), which serves /site on 127.0.0.1 and starts the browser
+// with --remote-debugging-pipe on descriptors 3 and 4. The runner holds
+// the other ends of that pipe and drives the browser over it.
+package render
+
+import (
+ "bytes"
+ "io"
+ "os"
+ "sync"
+ "time"
+)
+
+// Subcommand is the runner's subcommand that is the sandbox's first
+// process.
+const Subcommand = "render-sandbox"
+
+// Paths inside the sandbox.
+const (
+ // BrowserPath is the pinned tree's program (renderer.json "program"),
+ // seen through the tree bound at /usr.
+ BrowserPath = "/usr/lib/chromium/chromium-headless-shell"
+ // SiteDir holds the exported site, read only.
+ SiteDir = "/site"
+ // OutDir is the one directory the sandbox can write that outlives it.
+ OutDir = "/out"
+ // binaryPath is where the runner's own executable is bound, read only.
+ binaryPath = "/runner"
+ // browserHome is the browser's HOME and the parent of its profile:
+ // the sandbox's tmpfs.
+ browserHome = "/tmp"
+)
+
+// HostResolverRules is the browser's --host-resolver-rules: every host
+// name is not found except the site server's own address. Direct IP
+// addresses never reach the resolver; the sandbox has no route for them.
+const HostResolverRules = "MAP * ~NOTFOUND, EXCLUDE 127.0.0.1"
+
+// Descriptors the sandbox's first process inherits, and nothing else
+// beyond 0, 1 and 2.
+const (
+ // fdBrowserIn and fdBrowserOut are the browser's
+ // --remote-debugging-pipe: it reads CDP messages on 3 and writes on 4.
+ fdBrowserIn = 3
+ fdBrowserOut = 4
+ // fdStatus is render-sandbox's status pipe (status lines, JSON).
+ fdStatus = 5
+)
+
+// browserArgs is the browser's command line. Chromium's own sandbox stays
+// on: nothing here turns it off, and a host that cannot nest it fails to
+// start the browser rather than run it unsandboxed.
+func browserArgs() []string {
+ return []string{
+ "--remote-debugging-pipe",
+ "--host-resolver-rules=" + HostResolverRules,
+ "--user-data-dir=" + browserHome + "/profile",
+ "--disable-crash-reporter",
+ "--no-first-run",
+ "--enable-logging=stderr",
+ "about:blank",
+ }
+}
+
+// StartTimeout bounds how long Launch waits for the sandbox to report
+// ready when LaunchConfig.StartTimeout is zero.
+const StartTimeout = 30 * time.Second
+
+// LaunchConfig is how the runner starts a render sandbox.
+type LaunchConfig struct {
+ // Bwrap is the pinned bubblewrap, an absolute path.
+ Bwrap string
+ // Binary is the runner's own executable, which carries the
+ // render-sandbox subcommand. Symlinks are resolved on the host and
+ // the file they name is bound.
+ Binary string
+ // Tree is the installed renderer tree and Pin the SHA-256 of its
+ // MANIFEST that this runner links (release.RendererPin). Launch
+ // verifies the tree against the pin before it mounts anything.
+ Tree, Pin string
+ // Site is the exported site, bound read only at /site. It must be a
+ // directory this user owns that nobody else can write, reached
+ // through no symlink.
+ Site string
+ // Out is an empty directory, mode 0700, owned by this user and
+ // reached through no symlink, bound read-write at /out.
+ Out string
+ // StartTimeout bounds the wait for the sandbox to report ready; zero
+ // means StartTimeout.
+ StartTimeout time.Duration
+ // Stderr receives the sandbox's diagnostics (bubblewrap's, the
+ // subcommand's and the browser's), bounded; nil discards them.
+ Stderr io.Writer
+}
+
+// Sandbox is a running render sandbox.
+type Sandbox struct {
+ // Site is the site server's address inside the sandbox, as
+ // http://127.0.0.1:<port>/. Only the browser can reach it.
+ Site string
+ // ToBrowser and FromBrowser are this side of the browser's
+ // --remote-debugging-pipe: CDP messages, each ended by a NUL byte.
+ ToBrowser *os.File
+ FromBrowser *os.File
+
+ done chan struct{}
+ err error
+ stop func()
+ pid int
+ ready chan status
+ stderr *bounded
+
+ mu sync.Mutex
+ exit BrowserExit
+}
+
+// BrowserExit is how the browser ended, as render-sandbox saw it. Known
+// is false when the sandbox ended without reporting it.
+type BrowserExit struct {
+ Known bool
+ Code int
+ Signal string
+}
+
+// status is one line render-sandbox writes on its status pipe.
+type status struct {
+ // Event is "ready" (the site is served and the browser started),
+ // "exit" (the browser ended) or "failed" (render-sandbox could not
+ // go on; Reason says where).
+ Event string `json:"event"`
+ Site string `json:"site,omitempty"`
+ Code int `json:"code,omitempty"`
+ Signal string `json:"signal,omitempty"`
+ Reason string `json:"reason,omitempty"`
+}
+
+// Reasons in a "failed" status.
+const (
+ reasonDescriptors = "descriptors"
+ reasonSite = "site"
+ reasonBrowser = "browser"
+)
+
+// Wait waits for the sandbox to end and returns how the browser ended.
+// The error is bubblewrap's (killed, or a non-zero exit), or nil.
+func (s *Sandbox) Wait() (BrowserExit, error) {
+ <-s.done
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.exit, s.err
+}
+
+// Close kills the sandbox, everything in it, waits for it to end and
+// closes this side of the browser's pipe.
+func (s *Sandbox) Close() error {
+ s.stop()
+ <-s.done
+ s.ToBrowser.Close()
+ s.FromBrowser.Close()
+ return nil
+}
+
+// bounded keeps the first max bytes written to it.
+type bounded struct {
+ mu sync.Mutex
+ buf bytes.Buffer
+ max int
+}
+
+func (b *bounded) Write(p []byte) (int, error) {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ if room := b.max - b.buf.Len(); room > 0 {
+ b.buf.Write(p[:min(len(p), room)])
+ }
+ return len(p), nil
+}
+
+func (b *bounded) Bytes() []byte {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ return bytes.Clone(b.buf.Bytes())
+}
diff --git a/internal/runner/render/render_test.go b/internal/runner/render/render_test.go
new file mode 100644
index 00000000..0f6a9cf6
--- /dev/null
+++ b/internal/runner/render/render_test.go
@@ -0,0 +1,65 @@
+package render
+
+import (
+ "encoding/json"
+ "os"
+ "slices"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/testci"
+)
+
+// The resolver rule is the one the spec asks for, in one place: every
+// host but the site server's own address is not found.
+func TestHostResolverRules(t *testing.T) {
+ if HostResolverRules != "MAP * ~NOTFOUND, EXCLUDE 127.0.0.1" {
+ t.Fatalf("rules %q", HostResolverRules)
+ }
+ if !slices.Contains(browserArgs(), "--host-resolver-rules="+HostResolverRules) {
+ t.Fatalf("browser args %q lack the resolver rules", browserArgs())
+ }
+}
+
+// The browser is driven over its pipe, never a port, and its own sandbox
+// is never turned off.
+func TestBrowserArgsKeepTheSandbox(t *testing.T) {
+ args := browserArgs()
+ if !slices.Contains(args, "--remote-debugging-pipe") {
+ t.Fatalf("args %q", args)
+ }
+ for _, a := range args {
+ if forbiddenBrowserFlag(a) {
+ t.Errorf("browser flag %q", a)
+ }
+ }
+}
+
+// forbiddenBrowserFlag is a flag that would weaken the browser's sandbox
+// or open another way in.
+func forbiddenBrowserFlag(a string) bool {
+ for _, f := range []string{"--no-sandbox", "--disable-setuid-sandbox", "--no-zygote", "--single-process", "--disable-gpu-sandbox", "--disable-seccomp-filter-sandbox", "--disable-namespace-sandbox", "--remote-debugging-port", "--remote-debugging-address", "--proxy-server", "--proxy-pac-url", "--allow-file-access-from-files"} {
+ if a == f || strings.HasPrefix(a, f+"=") {
+ return true
+ }
+ }
+ return false
+}
+
+// BrowserPath is the pinned tree's program, seen at the root.
+func TestBrowserPathIsThePinnedProgram(t *testing.T) {
+ testci.Files(t, "../../release/renderer.json")
+ raw, err := os.ReadFile("../../release/renderer.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var pin struct {
+ Program string `json:"program"`
+ }
+ if err = json.Unmarshal(raw, &pin); err != nil {
+ t.Fatal(err)
+ }
+ if "/"+pin.Program != BrowserPath {
+ t.Fatalf("renderer.json program %q, BrowserPath %q", pin.Program, BrowserPath)
+ }
+}
diff --git a/internal/runner/render/sandbox_linux.go b/internal/runner/render/sandbox_linux.go
new file mode 100644
index 00000000..a660079b
--- /dev/null
+++ b/internal/runner/render/sandbox_linux.go
@@ -0,0 +1,119 @@
+//go:build linux
+
+package render
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "os"
+ "os/exec"
+ "runtime"
+ "syscall"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+// SandboxMain is the sandbox's first process, the runner's render-sandbox
+// subcommand. Bubblewrap gives it the browser's pipe on descriptors 3 and
+// 4 and its status pipe on 5. It serves /site on 127.0.0.1, starts the
+// browser with that pipe and HOME=/tmp (its environment is otherwise
+// empty), reports ready with the site's address, then the browser's exit,
+// and ends. It takes no arguments and reads nothing else from the host.
+// Exit 0 is a browser that started and ended; 1 a failure it reported; 2
+// a launch that was not the runner's.
+func SandboxMain(args []string, stderr io.Writer) int {
+ if len(args) != 0 {
+ return 2
+ }
+ for _, fd := range []int{fdBrowserIn, fdBrowserOut, fdStatus} {
+ if _, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0); err != nil {
+ return 2
+ }
+ }
+ statusPipe := os.NewFile(fdStatus, "status")
+ report := func(st status) {
+ b, _ := json.Marshal(st)
+ statusPipe.Write(append(b, '\n'))
+ }
+ // The browser gets 0, 1, 2 and its pipe (ExtraFiles) and nothing
+ // else: not the status pipe, not the server's socket.
+ if err := closeOnExecFrom(3); err != nil {
+ report(status{Event: "failed", Reason: reasonDescriptors})
+ return 1
+ }
+ server, site, err := serveSite()
+ if err != nil {
+ fmt.Fprintf(stderr, "render-sandbox: site: %v\n", err)
+ report(status{Event: "failed", Reason: reasonSite})
+ return 1
+ }
+ defer server.Close()
+ browserIn, browserOut := os.NewFile(fdBrowserIn, "browser-in"), os.NewFile(fdBrowserOut, "browser-out")
+ cmd := exec.Command(BrowserPath, browserArgs()...)
+ cmd.Env = []string{"HOME=" + browserHome}
+ cmd.Dir = browserHome
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ cmd.ExtraFiles = []*os.File{browserIn, browserOut}
+ cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL}
+ runtime.LockOSThread()
+ err = cmd.Start()
+ // The browser holds its pipe now; this process keeps no end of it,
+ // so the runner sees the pipe close when the browser ends.
+ browserIn.Close()
+ browserOut.Close()
+ if err != nil {
+ fmt.Fprintf(stderr, "render-sandbox: browser: %v\n", err)
+ report(status{Event: "failed", Reason: reasonBrowser})
+ return 1
+ }
+ report(status{Event: "ready", Site: site})
+ err = cmd.Wait()
+ st := status{Event: "exit"}
+ var exit *exec.ExitError
+ if errors.As(err, &exit) {
+ if ws, ok := exit.Sys().(syscall.WaitStatus); ok && ws.Signaled() {
+ st.Signal = unix.SignalName(ws.Signal())
+ } else {
+ st.Code = exit.ExitCode()
+ }
+ } else if err != nil {
+ st.Code = -1
+ }
+ report(st)
+ return 0
+}
+
+// serveSite serves /site, read only, on 127.0.0.1 at a port the kernel
+// picks. Only GET and HEAD are answered; os.Root keeps every request
+// inside /site.
+func serveSite() (*http.Server, string, error) {
+ root, err := os.OpenRoot(SiteDir)
+ if err != nil {
+ return nil, "", err
+ }
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ root.Close()
+ return nil, "", err
+ }
+ files := http.FileServerFS(root.FS())
+ server := &http.Server{
+ Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet && r.Method != http.MethodHead {
+ w.WriteHeader(http.StatusMethodNotAllowed)
+ return
+ }
+ files.ServeHTTP(w, r)
+ }),
+ ReadHeaderTimeout: 10 * time.Second,
+ MaxHeaderBytes: 64 << 10,
+ }
+ go server.Serve(ln)
+ return server, fmt.Sprintf("http://%s/", ln.Addr()), nil
+}