carlos / platform Public

gvisor slice 1: bound root control's build output; purge any tree

Root control no longer reads a demo build's output into an unbounded
buffer: one transfer at a time, exact-size reads, panic-safe turn
release, the signed job's deadline on writes, and a debug/elf panic is
refused as a failed build (F3). Purge removes trees of any depth with
bounded descriptors and memory by hoisting past the depth bound under
random names; once removal starts, a vanished directory never reads as
"already removed" (F6). Plan slice 1.2 updated to match.

Reviews: Astra and Fable READY at round 3; census approved (Astra).
Box memory, deep-purge and root-runner witnesses are owed at release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from gvisor-slice1-control-purge into main.
claude agent, operated by paul@keymail.dev a52ab35aad5850f02400e2ecaac720d32dee275f parent 9f52923
22 files changed, +1,830 −41
  • docs/superpowers/notes/census-proposal-gvisor-slice1-control-purge.md +39 −0
  • docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md +3 −1
  • internal/activator/hawake.go +5 −1
  • internal/activator/hawake_test.go +14 −7
  • internal/demobuild/gvisor_build_rootrunner_linux_test.go +2 −1
  • internal/demobuild/gvisor_cleanup_test.go +2 −1
  • internal/demobuild/job.go +2 −0
  • internal/demobuild/probe.go +2 −1
  • internal/demobuild/runner.go +53 −1
  • internal/demobuild/transfer.go +39 −0
  • internal/demobuild/transfer_test.go +350 −0
  • internal/demobuild/worker.go +15 −1
  • internal/demobuild/worker_test.go +1 −0
  • internal/host/demo_build_linux_test.go +9 −1
  • internal/instancectl/demo_build.go +9 −1
  • internal/instancectl/demo_build_transfer_test.go +215 −0
  • internal/instancefs/dirs_linux.go +463 −24
  • internal/instancefs/purge_linux.go +1 −1
  • internal/instancefs/purge_linux_test.go +15 −0
  • internal/instancefs/removeall_linux_test.go +564 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-gvisor-slice1-control-purge.tsv +26 −0

CI passed — run details

CI log
=== gate ===
go: downloading go1.26.10 (linux/arm64)
go version go1.26.10 linux/arm64
opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1
  tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz
  tofu: downloaded, digest verified
  aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip
  aws: downloaded, digest verified
  archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip
  archive: downloaded, digest verified
  installed in /tmp/carlos-opentofu-06KEm6
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading golang.org/x/net v0.62.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/config v1.32.6
go: downloading golang.org/x/sys v0.49.0
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1
go: downloading golang.org/x/mod v0.41.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading golang.org/x/text v0.43.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== launchctx (4 s, from +0 s)
ok  	amadan.net/carlos/platform.git/launchctx	0.015s
?   	amadan.net/carlos/platform.git/launchctx/controlname	[no test files]
?   	amadan.net/carlos/platform.git/launchctx/wireid	[no test files]
=== vet (174 s, from +0 s)
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== vet-tags (177 s, from +0 s)
go: downloading github.com/klauspost/compress v1.20.2
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== gofmt (1 s, from +0 s)
gofmt -l .: clean
=== rest (388 s, from +15 s)
ok  	github.com/carlosframework/platform/cmd/carlos-media	123.001s
?   	github.com/carlosframework/platform/cmd/changelog	[no test files]
ok  	github.com/carlosframework/platform/cmd/console	204.491s
ok  	github.com/carlosframework/platform/cmd/mediaimage	40.693s
ok  	github.com/carlosframework/platform/cmd/moveprobe	16.553s
ok  	github.com/carlosframework/platform/cmd/pricebook-export	0.050s
ok  	github.com/carlosframework/platform/cmd/rootfswitness	0.199s
ok  	github.com/carlosframework/platform/cmd/runsc-assets	0.153s
ok  	github.com/carlosframework/platform/cmd/zddprobe	1.005s
ok  	github.com/carlosframework/platform/internal/agentsock	0.108s
ok  	github.com/carlosframework/platform/internal/alerting	0.033s
ok  	github.com/carlosframework/platform/internal/analytics	0.309s
ok  	github.com/carlosframework/platform/internal/appconfig	39.819s
ok  	github.com/carlosframework/platform/internal/apperr	0.388s
ok  	github.com/carlosframework/platform/internal/applog	0.812s
ok  	github.com/carlosframework/platform/internal/apppolicy	2.723s
ok  	github.com/carlosframework/platform/internal/assetcache	0.541s
ok  	github.com/carlosframework/platform/internal/awsinv	0.018s
ok  	github.com/carlosframework/platform/internal/awsmanaged	12.651s
ok  	github.com/carlosframework/platform/internal/awsregiongroup	1.952s
ok  	github.com/carlosframework/platform/internal/awsterminations	0.018s
ok  	github.com/carlosframework/platform/internal/backupswords	0.023s
ok  	github.com/carlosframework/platform/internal/billing	0.055s
ok  	github.com/carlosframework/platform/internal/billing/billingtest	0.068s
ok  	github.com/carlosframework/platform/internal/billingstripe	2.238s
ok  	github.com/carlosframework/platform/internal/boxchoice	0.040s
ok  	github.com/carlosframework/platform/internal/boxid	2.781s
?   	github.com/carlosframework/platform/internal/boxid/boxidtest	[no test files]
?   	github.com/carlosframework/platform/internal/boxid/internal/signtest	[no test files]
ok  	github.com/carlosframework/platform/internal/boxroles	0.015s
ok  	github.com/carlosframework/platform/internal/boxself	0.242s
ok  	github.com/carlosframework/platform/internal/boxvolumes	0.114s
ok  	github.com/carlosframework/platform/internal/caps	4.569s
ok  	github.com/carlosframework/platform/internal/certwarm	0.024s
ok  	github.com/carlosframework/platform/internal/cgroup	1.659s
ok  	github.com/carlosframework/platform/internal/changelog	5.160s
ok  	github.com/carlosframework/platform/internal/clamd	0.090s
?   	github.com/carlosframework/platform/internal/cliflag	[no test files]
ok  	github.com/carlosframework/platform/internal/clireg	0.021s
ok  	github.com/carlosframework/platform/internal/codehealth	17.052s
ok  	github.com/carlosframework/platform/internal/compute	0.015s
ok  	github.com/carlosframework/platform/internal/consolefleet	0.010s
?   	github.com/carlosframework/platform/internal/controlname	[no test files]
?   	github.com/carlosframework/platform/internal/controlsock	[no test files]
ok  	github.com/carlosframework/platform/internal/dbdoor	11.239s
ok  	github.com/carlosframework/platform/internal/dbdoor/dbdoortest	0.063s
ok  	github.com/carlosframework/platform/internal/dbquery	0.027s
ok  	github.com/carlosframework/platform/internal/dbreads	3.007s
?   	github.com/carlosframework/platform/internal/dbreads/dbreadstest	[no test files]
ok  	github.com/carlosframework/platform/internal/dbverify	0.099s
ok  	github.com/carlosframework/platform/internal/demo	0.019s
ok  	github.com/carlosframework/platform/internal/demobuild	4.814s
ok  	github.com/carlosframework/platform/internal/democlaim	0.372s
ok  	github.com/carlosframework/platform/internal/devbox	16.257s
ok  	github.com/carlosframework/platform/internal/dnsrec	0.020s
ok  	github.com/carlosframework/platform/internal/docsite	0.126s
ok  	github.com/carlosframework/platform/internal/domainreg	0.025s
ok  	github.com/carlosframework/platform/internal/domains	71.238s
ok  	github.com/carlosframework/platform/internal/doorkey	0.081s
ok  	github.com/carlosframework/platform/internal/economics	0.046s
ok  	github.com/carlosframework/platform/internal/edgefence	0.159s
ok  	github.com/carlosframework/platform/internal/edgeguard	0.211s
?   	github.com/carlosframework/platform/internal/edgeproof	[no test files]
ok  	github.com/carlosframework/platform/internal/edgesfile	0.076s
ok  	github.com/carlosframework/platform/internal/egressaddr	0.008s
ok  	github.com/carlosframework/platform/internal/execsandbox	102.626s
ok  	github.com/carlosframework/platform/internal/fileacl	0.017s
ok  	github.com/carlosframework/platform/internal/fleetapi	2.300s
ok  	github.com/carlosframework/platform/internal/fleetstore	0.015s
ok  	github.com/carlosframework/platform/internal/fxrate	0.051s
ok  	github.com/carlosframework/platform/internal/gate	5.871s
ok  	github.com/carlosframework/platform/internal/genselect	0.105s
ok  	github.com/carlosframework/platform/internal/geo	0.102s
ok  	github.com/carlosframework/platform/internal/geoip	0.233s
ok  	github.com/carlosframework/platform/internal/groupadmission	0.008s
ok  	github.com/carlosframework/platform/internal/grouprollaws	16.735s
ok  	github.com/carlosframework/platform/internal/hadeparture	0.020s
ok  	github.com/carlosframework/platform/internal/hafresh	0.009s
ok  	github.com/carlosframework/platform/internal/hairpin	0.170s
ok  	github.com/carlosframework/platform/internal/historyreadback	1.172s
ok  	github.com/carlosframework/platform/internal/hostactors	21.465s
ok  	github.com/carlosframework/platform/internal/hostbox	21.999s
ok  	github.com/carlosframework/platform/internal/hostclaim	2.870s
ok  	github.com/carlosframework/platform/internal/hostenv	0.092s
ok  	github.com/carlosframework/platform/internal/hostevidence	0.009s
ok  	github.com/carlosframework/platform/internal/hostexec	21.549s
ok  	github.com/carlosframework/platform/internal/hostfence	0.066s
ok  	github.com/carlosframework/platform/internal/hostfiles	26.847s
ok  	github.com/carlosframework/platform/internal/hostfloor	0.065s
ok  	github.com/carlosframework/platform/internal/hostguard	1.695s
ok  	github.com/carlosframework/platform/internal/hostops	8.750s
?   	github.com/carlosframework/platform/internal/hostops/fencerelease	[no test files]
ok  	github.com/carlosframework/platform/internal/hostops/internal/fencerelease	0.016s
ok  	github.com/carlosframework/platform/internal/hostquarantine	0.019s
ok  	github.com/carlosframework/platform/internal/hostrelocate	2.484s
ok  	github.com/carlosframework/platform/internal/hostresolve	0.617s
ok  	github.com/carlosframework/platform/internal/hostwrite	0.007s
ok  	github.com/carlosframework/platform/internal/infraview	0.013s
ok  	github.com/carlosframework/platform/internal/ingresshealth	0.014s
ok  	github.com/carlosframework/platform/internal/ingresshealth/awstg	0.007s
ok  	github.com/carlosframework/platform/internal/instancectl	65.833s
ok  	github.com/carlosframework/platform/internal/instanceexec	9.273s
ok  	github.com/carlosframework/platform/internal/instancefs	18.313s
ok  	github.com/carlosframework/platform/internal/instancekey	0.013s
ok  	github.com/carlosframework/platform/internal/instanceupdates	0.020s
ok  	github.com/carlosframework/platform/internal/interactive	0.642s
ok  	github.com/carlosframework/platform/internal/launchd	0.013s
ok  	github.com/carlosframework/platform/internal/layout	22.426s
ok  	github.com/carlosframework/platform/internal/layout/pubclass	103.953s
ok  	github.com/carlosframework/platform/internal/lbhealth	0.011s
ok  	github.com/carlosframework/platform/internal/lease	145.104s
ok  	github.com/carlosframework/platform/internal/lease/leasetest	1.426s
ok  	github.com/carlosframework/platform/internal/lease/locktest	0.010s
ok  	github.com/carlosframework/platform/internal/ledger	0.058s
ok  	github.com/carlosframework/platform/internal/mail	1.054s
ok  	github.com/carlosframework/platform/internal/mailer	0.773s
ok  	github.com/carlosframework/platform/internal/mailsubmit	1.967s
ok  	github.com/carlosframework/platform/internal/mailwire	0.010s
ok  	github.com/carlosframework/platform/internal/maintenance	0.247s
ok  	github.com/carlosframework/platform/internal/maintenanceexec	8.773s
ok  	github.com/carlosframework/platform/internal/maintenanceguard	0.372s
ok  	github.com/carlosframework/platform/internal/managedboot	3.809s
?   	github.com/carlosframework/platform/internal/managedboot/boottest	[no test files]
?   	github.com/carlosframework/platform/internal/managedboot/roottest	[no test files]
ok  	github.com/carlosframework/platform/internal/media	1.822s
ok  	github.com/carlosframework/platform/internal/media/mediatest	0.024s
ok  	github.com/carlosframework/platform/internal/mediaaws	61.133s
ok  	github.com/carlosframework/platform/internal/mediahandler	41.417s
ok  	github.com/carlosframework/platform/internal/mediajobs	0.866s
ok  	github.com/carlosframework/platform/internal/medialocal	9.963s
ok  	github.com/carlosframework/platform/internal/metrics	0.118s
ok  	github.com/carlosframework/platform/internal/minorunits	0.014s
ok  	github.com/carlosframework/platform/internal/moves	52.112s
ok  	github.com/carlosframework/platform/internal/moves/archive	2.765s
ok  	github.com/carlosframework/platform/internal/moves/offlinerun	0.109s
ok  	github.com/carlosframework/platform/internal/namedunits	0.075s
ok  	github.com/carlosframework/platform/internal/objstore	2.528s
ok  	github.com/carlosframework/platform/internal/ops	14.527s
ok  	github.com/carlosframework/platform/internal/pageindex	3.990s
ok  	github.com/carlosframework/platform/internal/parity	0.199s
?   	github.com/carlosframework/platform/internal/parity/cmd/parity-doc	[no test files]
ok  	github.com/carlosframework/platform/internal/park	0.818s
ok  	github.com/carlosframework/platform/internal/perf	0.202s
ok  	github.com/carlosframework/platform/internal/plans	0.220s
ok  	github.com/carlosframework/platform/internal/privatefile	0.016s
ok  	github.com/carlosframework/platform/internal/provision	239.976s
ok  	github.com/carlosframework/platform/internal/proxyproto	0.936s
ok  	github.com/carlosframework/platform/internal/publicrelease	0.044s
ok  	github.com/carlosframework/platform/internal/ratelimit	0.173s
ok  	github.com/carlosframework/platform/internal/regionlabel	0.072s
ok  	github.com/carlosframework/platform/internal/regionname	0.068s
ok  	github.com/carlosframework/platform/internal/registrar	0.023s
ok  	github.com/carlosframework/platform/internal/registrar/openprovider	0.812s
?   	github.com/carlosframework/platform/internal/registrar/registrartest	[no test files]
ok  	github.com/carlosframework/platform/internal/registry	83.729s
ok  	github.com/carlosframework/platform/internal/relay	7.526s
ok  	github.com/carlosframework/platform/internal/release	100.930s
ok  	github.com/carlosframework/platform/internal/replicagen	0.037s
ok  	github.com/carlosframework/platform/internal/replicas	0.079s
ok  	github.com/carlosframework/platform/internal/reqrec	8.418s
ok  	github.com/carlosframework/platform/internal/rollout	10.069s
ok  	github.com/carlosframework/platform/internal/rolloutwords	0.059s
ok  	github.com/carlosframework/platform/internal/rootaws	100.888s
ok  	github.com/carlosframework/platform/internal/rootfsimage	1.101s
ok  	github.com/carlosframework/platform/internal/rootparticipation	0.109s
ok  	github.com/carlosframework/platform/internal/rootstate	0.066s
ok  	github.com/carlosframework/platform/internal/runs	0.915s
ok  	github.com/carlosframework/platform/internal/s3compat	0.039s
ok  	github.com/carlosframework/platform/internal/s3fake	1.587s
ok  	github.com/carlosframework/platform/internal/safefile	0.034s
ok  	github.com/carlosframework/platform/internal/schedule	21.433s
ok  	github.com/carlosframework/platform/internal/seeds	0.107s
ok  	github.com/carlosframework/platform/internal/sim/litestreamfacts	4.717s
ok  	github.com/carlosframework/platform/internal/sim/mediajobs	49.343s
ok  	github.com/carlosframework/platform/internal/sim/regionha	20.084s
ok  	github.com/carlosframework/platform/internal/status	0.324s
ok  	github.com/carlosframework/platform/internal/steering	0.235s
ok  	github.com/carlosframework/platform/internal/stopevidence	0.325s
ok  	github.com/carlosframework/platform/internal/storecfg	0.427s
ok  	github.com/carlosframework/platform/internal/svcrole	0.022s
ok  	github.com/carlosframework/platform/internal/systemd	5.832s
?   	github.com/carlosframework/platform/internal/systemdshow	[no test files]
ok  	github.com/carlosframework/platform/internal/team	3.157s
ok  	github.com/carlosframework/platform/internal/teamcontract	0.176s
ok  	github.com/carlosframework/platform/internal/telemetry	0.020s
ok  	github.com/carlosframework/platform/internal/termfence	2.466s
ok  	github.com/carlosframework/platform/internal/timerspec	0.016s
ok  	github.com/carlosframework/platform/internal/tsidentity	4.190s
ok  	github.com/carlosframework/platform/internal/tunnelclient	0.366s
ok  	github.com/carlosframework/platform/internal/unixdial	0.017s
ok  	github.com/carlosframework/platform/internal/updatewords	0.038s
ok  	github.com/carlosframework/platform/internal/upstreamguard	0.020s
?   	github.com/carlosframework/platform/internal/upstreamguard/guardtest	[no test files]
ok  	github.com/carlosframework/platform/internal/usage	0.024s
ok  	github.com/carlosframework/platform/internal/version	0.009s
ok  	github.com/carlosframework/platform/internal/vet	2.977s
ok  	github.com/carlosframework/platform/internal/zonehost	0.021s
ok  	github.com/carlosframework/platform/internal/zonehost/route53zones	0.057s
?   	github.com/carlosframework/platform/internal/zonehost/zonehosttest	[no test files]
?   	github.com/carlosframework/platform/scripts/gitleaks-gate	[no test files]
ok  	github.com/carlosframework/platform/scripts/govulncheck-gate	0.018s
ok  	github.com/carlosframework/platform/scripts/pathmapcheck	0.113s
ok  	github.com/carlosframework/platform/scripts/region-ha-g2/fixture	5.189s
ok  	github.com/carlosframework/platform/scripts/stateless-replicas-drill	1.205s
ok  	github.com/carlosframework/platform/scripts/witness-pointer	0.021s
=== cutover-witness (160 s, from +15 s)
ok  	github.com/carlosframework/platform	2.261s
=== internal_grouproll@0 (274 s, from +73 s)
ok  	github.com/carlosframework/platform/internal/grouproll	272.917s
=== internal_grouproll@1 (279 s, from +73 s)
ok  	github.com/carlosframework/platform/internal/grouproll	277.695s
=== internal_activator@0 (158 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	153.875s
=== internal_activator@1 (133 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	129.021s
=== internal_activator@2 (136 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	131.636s
=== internal_activator@3 (172 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	167.486s
=== root@0 (131 s, from +171 s)
ok  	github.com/carlosframework/platform	124.371s
=== root@1 (112 s, from +171 s)
ok  	github.com/carlosframework/platform	102.651s
=== root@2 (123 s, from +171 s)
ok  	github.com/carlosframework/platform	114.224s
=== root@3 (118 s, from +171 s)
ok  	github.com/carlosframework/platform	110.005s
=== root@4 (102 s, from +171 s)
ok  	github.com/carlosframework/platform	94.545s
=== internal_edge@0 (254 s, from +174 s)
ok  	github.com/carlosframework/platform/internal/edge	244.771s
=== internal_edge@1 (132 s, from +174 s)
ok  	github.com/carlosframework/platform/internal/edge	124.293s
=== internal_edge@2 (156 s, from +174 s)
ok  	github.com/carlosframework/platform/internal/edge	148.605s
=== internal_edge@3 (151 s, from +174 s)
ok  	github.com/carlosframework/platform/internal/edge	142.083s
=== internal_host@0 (180 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/host	176.421s
=== internal_host@1 (142 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/host	137.688s
=== internal_host@2 (210 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/host	205.917s
=== internal_host@3 (227 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/host	222.509s
=== internal_host@4 (258 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/host	253.494s
=== internal_host@5 (171 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/host	166.943s
=== internal_console@0 (161 s, from +222 s)
ok  	github.com/carlosframework/platform/internal/console	153.287s
=== internal_console@1 (173 s, from +222 s)
ok  	github.com/carlosframework/platform/internal/console	166.160s
=== internal_console@2 (206 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	199.623s
=== internal_console@3 (243 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	235.559s
=== internal_console@4 (197 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	189.858s
=== internal_console@5 (225 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	219.238s
=== internal_console@6 (200 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	193.760s
=== internal_console@7 (210 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	203.566s
=== internal_console@8 (225 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	218.448s
=== internal_console@9 (214 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	207.628s
=== internal_console@10 (217 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	210.585s
=== internal_console@11 (240 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	233.680s
=== internal_console@12 (284 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	278.749s
=== internal_console@13 (247 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	240.434s
=== internal_console@14 (239 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	232.119s
=== internal_console@15 (223 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	216.419s
=== internal_console@16 (255 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	248.926s
=== internal_console@17 (204 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	196.124s
=== internal_console@18 (206 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	199.326s
=== internal_console@19 (205 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	197.957s
=== internal_console@20 (213 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	206.761s
=== internal_console@21 (233 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	225.070s
=== internal_console@22 (215 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	208.744s
=== internal_console@23 (226 s, from +223 s)
ok  	github.com/carlosframework/platform/internal/console	219.166s
=== lists: internal_console 222 s, internal_edge 173 s, internal_activator 145 s, internal_host 216 s, root 169 s, internal_grouproll 72 s
=== cpu: the gate used 12828 cpu-seconds in 508 s, about 25.3 of 32 cores; the machine as a whole was 84% busy
=== opentofu ===
opentofu: 39 test files in 11 suites, OpenTofu v1.13.9
  initialised in 14 s
  ok      16 s  infra/modules/box-fence-writer/tests/writer.tftest.hcl  Success! 1 passed, 0 failed.
  ok      13 s  infra/modules/deployment-buckets/tests/console_floors.tftest.hcl  Success! 1 passed, 0 failed.
  ok      26 s  infra/modules/deployment-buckets/tests/data_lifecycle.tftest.hcl  Success! 3 passed, 0 failed.
  ok      16 s  infra/modules/deployment-buckets/tests/db_reads.tftest.hcl  Success! 1 passed, 0 failed.
  ok      17 s  infra/modules/deployment-buckets/tests/evidence.tftest.hcl  Success! 1 passed, 0 failed.
  ok      26 s  infra/modules/deployment-buckets/tests/fence_writers.tftest.hcl  Success! 3 passed, 0 failed.
  ok      25 s  infra/modules/deployment-buckets/tests/media_results.tftest.hcl  Success! 2 passed, 0 failed.
  ok      90 s  infra/modules/media-engine/tests/media_engine.tftest.hcl  Success! 24 passed, 0 failed.
  ok      29 s  infra/modules/pdf-host/tests/computed.tftest.hcl  Success! 2 passed, 0 failed.
  ok      62 s  infra/modules/pdf-host/tests/pdf_host.tftest.hcl  Success! 24 passed, 0 failed.
  ok      45 s  infra/modules/region-group-operator-document/tests/document.tftest.hcl  Success! 12 passed, 0 failed.
  ok      21 s  infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl  Success! 2 passed, 0 failed.
  ok      69 s  infra/modules/region-host/ingress/tests/group_ingress.tftest.hcl  Success! 30 passed, 0 failed.
  ok      47 s  infra/modules/region-host/tests/alert_publish.tftest.hcl  Success! 18 passed, 0 failed.
  ok      46 s  infra/modules/region-host/tests/alerts_topic.tftest.hcl  Success! 16 passed, 0 failed.
  ok      14 s  infra/modules/region-host/tests/analytics_prune.tftest.hcl  Success! 2 passed, 0 failed.
  ok      16 s  infra/modules/region-host/tests/console_mail.tftest.hcl  Success! 4 passed, 0 failed.
  ok       7 s  infra/modules/region-host/tests/fixed_state_unchanged.tftest.hcl  Success! 1 passed, 0 failed.
  ok      72 s  infra/modules/region-host/tests/group.tftest.hcl  Success! 32 passed, 0 failed.
  ok      11 s  infra/modules/region-host/tests/group_alarms.tftest.hcl  Success! 4 passed, 0 failed.
  ok      11 s  infra/modules/region-host/tests/group_iam.tftest.hcl  Success! 4 passed, 0 failed.
  ok       6 s  infra/modules/region-host/tests/group_isolation.tftest.hcl  Success! 1 passed, 0 failed.
  ok      37 s  infra/modules/region-host/tests/group_operator.tftest.hcl  Success! 13 passed, 0 failed.
  ok      10 s  infra/modules/region-host/tests/group_user_data.tftest.hcl  Success! 3 passed, 0 failed.
  ok      31 s  infra/modules/region-host/tests/health_alarms.tftest.hcl  Success! 10 passed, 0 failed.
  ok      14 s  infra/modules/region-host/tests/ingress_drain_read.tftest.hcl  Success! 4 passed, 0 failed.
  ok       8 s  infra/modules/region-host/tests/instance_metadata.tftest.hcl  Success! 1 passed, 0 failed.
  ok      24 s  infra/modules/region-host/tests/mailer.tftest.hcl  Success! 6 passed, 0 failed.
  ok      14 s  infra/modules/region-host/tests/mailer_group.tftest.hcl  Success! 2 passed, 0 failed.
  ok      13 s  infra/modules/region-host/tests/managed_fleets/group_refusal.tftest.hcl  Success! 2 passed, 0 failed.
  ok     104 s  infra/modules/region-host/tests/managed_fleets/managed_fleets.tftest.hcl  Success! 46 passed, 0 failed.
  ok      66 s  infra/modules/region-host/tests/store_conversion.tftest.hcl  Success! 27 passed, 0 failed.
  ok      14 s  infra/modules/region-host/tests/store_scanning.tftest.hcl  Success! 4 passed, 0 failed.
  ok      28 s  infra/modules/region-host/tests/store_versioning.tftest.hcl  Success! 11 passed, 0 failed.
  ok      15 s  infra/modules/region-host/tests/store_write_credentials.tftest.hcl  Success! 4 passed, 0 failed.
  ok      17 s  infra/modules/region-host/tests/user_data_ignored.tftest.hcl  Success! 3 passed, 0 failed.
  ok      13 s  infra/modules/region-remote-host/tests/data_lifecycle.tftest.hcl  Success! 3 passed, 0 failed.
  ok      15 s  infra/modules/region-remote-host/tests/no_deployment_bucket.tftest.hcl  Success! 5 passed, 0 failed.
  ok      28 s  infra/modules/scanner-host/tests/scanner_host.tftest.hcl  Success! 14 passed, 0 failed.
opentofu: 39 files in 209 s
opentofu: PASS
=== cross ===
--- shard 0 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling darwin/arm64
--- shard 1 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling darwin/amd64
--- shard 2 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling linux/arm64
linux/arm64 carlos binary: 66453666 bytes (ceiling 70000000)
--- shard 3 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling windows/amd64
--- shard 4 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling windows/arm64
=== minio-contract ===
go version go1.26.10 linux/arm64
minio contract: arm64, minio RELEASE.2025-09-07T16-13-09Z, mc RELEASE.2025-08-13T08-35-41Z
  minio: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/minio/minio.linux-arm64.RELEASE.2025-09-07T16-13-09Z
  minio: downloaded, digest verified
  mc: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/minio/mc.linux-arm64.RELEASE.2025-08-13T08-35-41Z
  mc: downloaded, digest verified
  minio healthy on 127.0.0.1:39994
Added `local` successfully.
Bucket created successfully `local/contract-bucket`.
Bucket created successfully `local/denied-bucket`.
Created policy `contract-only` successfully.
Added user `scopeduser` successfully.
Attached Policies: [contract-only]
To User: scopeduser
  buckets and scoped user ready
=== RUN   TestDeliveredContractMinio
=== RUN   TestDeliveredContractMinio/put
=== RUN   TestDeliveredContractMinio/get_round-trips_the_body
=== RUN   TestDeliveredContractMinio/list_shows_the_key
=== RUN   TestDeliveredContractMinio/head_and_list_agree_on_the_version
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed
=== RUN   TestDeliveredContractMinio/delete_removes_it
=== RUN   TestDeliveredContractMinio/cross-bucket_denial
--- PASS: TestDeliveredContractMinio (0.03s)
    --- PASS: TestDeliveredContractMinio/put (0.00s)
    --- PASS: TestDeliveredContractMinio/get_round-trips_the_body (0.00s)
    --- PASS: TestDeliveredContractMinio/list_shows_the_key (0.00s)
    --- PASS: TestDeliveredContractMinio/head_and_list_agree_on_the_version (0.00s)
    --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload (0.00s)
    --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route (0.01s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed (0.00s)
    --- PASS: TestDeliveredContractMinio/delete_removes_it (0.00s)
    --- PASS: TestDeliveredContractMinio/cross-bucket_denial (0.00s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.035s
=== RUN   TestT4StorageProbeMinio
2026/11/27 22:10:20 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18EC066DD1B5AF8B, HostID: d446735627f14cabb2c08affa0b720e2d975b5df92a1c4197e9b107b98b80d4b, api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
--- PASS: TestT4StorageProbeMinio (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/host	0.048s
=== RUN   TestS3StoreMinioContract
=== RUN   TestS3StoreMinioContract/conditional_get_and_etag_listing
=== RUN   TestS3StoreMinioContract/bump_through_every_mutation_path
--- PASS: TestS3StoreMinioContract (0.03s)
    --- PASS: TestS3StoreMinioContract/conditional_get_and_etag_listing (0.01s)
    --- PASS: TestS3StoreMinioContract/bump_through_every_mutation_path (0.02s)
PASS
ok  	github.com/carlosframework/platform/internal/release	0.041s
Bucket created successfully `local/analytics-versions`.
local/analytics-versions versioning is enabled
Created policy `analytics-versions` successfully.
Added user `analyticsversions` successfully.
Attached Policies: [analytics-versions]
To User: analyticsversions
=== RUN   TestS3StoreMinioVersions
--- PASS: TestS3StoreMinioVersions (0.03s)
PASS
ok  	github.com/carlosframework/platform/internal/release	0.040s
Bucket created successfully `local/store-versioned`.
local/store-versioned versioning is enabled
Created policy `store-versioned` successfully.
Added user `storeversioned` successfully.
Attached Policies: [store-versioned]
To User: storeversioned
=== RUN   TestVersionedContractMinio
--- PASS: TestVersionedContractMinio (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.020s
Bucket created successfully `local/wc-bucket`.
Created policy `writer` successfully.
Added user `wcwriter` successfully.
Attached Policies: [writer]
To User: wcwriter
=== RUN   TestWriteCredentialContractMinio
=== RUN   TestWriteCredentialContractMinio/put_under_the_prefix
=== RUN   TestWriteCredentialContractMinio/multipart_under_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_put_beside_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_bucket_settings
=== RUN   TestWriteCredentialContractMinio/refused:_list
=== RUN   TestWriteCredentialContractMinio/refused:_delete
=== RUN   TestWriteCredentialContractMinio/refused:_tag
=== RUN   TestWriteCredentialContractMinio/refused:_put_tagged
=== RUN   TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag
=== RUN   TestWriteCredentialContractMinio/refused:_put_to_another_bucket
=== RUN   TestWriteCredentialContractMinio/refused:_copy_from_the_store
=== RUN   TestWriteCredentialContractMinio/refused:_read_under_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_read_elsewhere
=== RUN   TestWriteCredentialContractMinio/refused:_head
=== RUN   TestWriteCredentialContractMinio/refused:_list_uploads
=== RUN   TestWriteCredentialContractMinio/refused:_put_outside_the_prefix
--- PASS: TestWriteCredentialContractMinio (0.04s)
    --- PASS: TestWriteCredentialContractMinio/put_under_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/multipart_under_the_prefix (0.01s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_beside_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_bucket_settings (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_list (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_delete (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_tag (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_tagged (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_to_another_bucket (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_copy_from_the_store (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_read_under_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_read_elsewhere (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_head (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_list_uploads (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_outside_the_prefix (0.00s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.049s
=== RUN   TestEndToEndMinio
=== RUN   TestEndToEndMinio/plan
=== RUN   TestEndToEndMinio/roll
=== RUN   TestEndToEndMinio/replace
=== RUN   TestEndToEndMinio/remove
--- PASS: TestEndToEndMinio (0.46s)
    --- PASS: TestEndToEndMinio/plan (0.01s)
    --- PASS: TestEndToEndMinio/roll (0.12s)
    --- PASS: TestEndToEndMinio/replace (0.15s)
    --- PASS: TestEndToEndMinio/remove (0.15s)
PASS
ok  	github.com/carlosframework/platform/internal/grouproll	0.467s
Bucket created successfully `local/dbf-deploy`.
Bucket created successfully `local/dbf-data-ie`.
Bucket created successfully `local/dbf-data-uk`.
local/dbf-deploy versioning is enabled
Created policy `dbf-console` successfully.
Created policy `dbf-ukbox` successfully.
Added user `dbfconsole` successfully.
Added user `dbfukbox` successfully.
Attached Policies: [dbf-console]
To User: dbfconsole
Attached Policies: [dbf-ukbox]
To User: dbfukbox
=== RUN   TestDBForwardMinio
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/27 22:10:28 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/11/27 22:10:28 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/11/27 22:10:28 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/27 22:10:28 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/27 22:10:28 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/27 22:10:28 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/11/27 22:10:28 console: could not notify member@example.com of a CLI token issue: keymail: lookup member@example.com: keymail: GET /api/federation/lookup?addr=member%40example.com&from=console%40127.0.0.1%3A45749: could not determine target mailbox
    agent.go:136: dbreads: dbr_okq7fqntn72mqpgirtyhojcuxy: planned 3 files (1544 bytes) and restored to 3 in 16ms
    agent.go:136: dbreads: dbr_okq7fqntn72mqpgirtyhojcuxy: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/27 22:10:29 console: db read dbr_okq7fqntn72mqpgirtyhojcuxy: relayed 1 chunks (102 bytes) in 1.005s, ended done
    agent.go:136: dbreads: dbr_obuzwfwupzhrixlamg4fobj76y: planned 1 files (720 bytes) and restored to 1 in 13ms
    agent.go:136: dbreads: dbr_obuzwfwupzhrixlamg4fobj76y: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/27 22:10:30 console: db read dbr_obuzwfwupzhrixlamg4fobj76y: relayed 1 chunks (102 bytes) in 1.005s, ended done
    agent.go:136: dbreads: dbr_qafiuiksjtvdss6xqxdxp4ulbe: planned 3 files (1544 bytes) and held through 3 in 13ms
    agent.go:136: dbreads: dbr_qafiuiksjtvdss6xqxdxp4ulbe: output 1544 bytes in 1 confirmed chunks in 2ms
2026/11/27 22:10:31 console: db read dbr_qafiuiksjtvdss6xqxdxp4ulbe: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN   TestDBForwardMinio/by_disconnect
=== NAME  TestDBForwardMinio
    agent.go:136: dbreads: dbr_mrte7mhdgixm6umujaxbbfvvzm: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/27 22:10:31 console: db read dbr_mrte7mhdgixm6umujaxbbfvvzm: relayed 0 chunks (0 bytes) in 27ms, ended client gone
    agent.go:136: dbreads: dbr_mrte7mhdgixm6umujaxbbfvvzm: output 5 bytes in 1 confirmed chunks in 104ms
=== RUN   TestDBForwardMinio/by_timeout
=== NAME  TestDBForwardMinio
    agent.go:136: dbreads: dbr_yyvfjjh53p74leubuyavg5hnxy: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/27 22:10:52 console: db read dbr_yyvfjjh53p74leubuyavg5hnxy: relayed 0 chunks (0 bytes) in 19.911s, ended no-result
    agent.go:136: dbreads: dbr_yyvfjjh53p74leubuyavg5hnxy: output 5 bytes in 1 confirmed chunks in 19.884s
--- PASS: TestDBForwardMinio (23.60s)
    --- PASS: TestDBForwardMinio/by_disconnect (0.24s)
    --- PASS: TestDBForwardMinio/by_timeout (20.02s)
PASS
ok  	github.com/carlosframework/platform/internal/console	23.641s
Bucket created successfully `local/media-transfers`.
Bucket created successfully `local/media-transfer-results`.
local/media-transfer-results versioning is enabled
Created policy `media-transfers` successfully.
Added user `mediatransfers` successfully.
Attached Policies: [media-transfers]
To User: mediatransfers
=== RUN   TestMediaTransfersMinio
    upload.go:117: codec: the store already holds video.mp4
    upload.go:117: codec: the store already holds video.m3u8
    upload.go:117: codec: the store already holds poster.jpg
--- PASS: TestMediaTransfersMinio (0.07s)
PASS
ok  	github.com/carlosframework/platform/internal/mediaaws	0.074s
Bucket created successfully `local/media-local-store`.
Bucket created successfully `local/media-local-results`.
Created policy `media-local` successfully.
Added user `medialocal` successfully.
Attached Policies: [media-local]
To User: medialocal
=== RUN   TestLocalEndToEndMinio
--- PASS: TestLocalEndToEndMinio (0.55s)
PASS
ok  	github.com/carlosframework/platform/internal/medialocal	0.551s
=== RUN   TestHeldHandoverTwoBoxMinio
2026/11/27 22:10:57 edge: mesh key: minted
2026/11/27 22:10:57 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/27 22:10:57 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/27 22:10:57 tenant admission is open. accepting tenant work
2026/11/27 22:10:57 activator: HA placement host=shop-4bad3e64.example.test kind=Place ref=annie reason=roomiest generation=2026-11-27T22:10:57Z lock_generation=0
2026/11/27 22:10:57 lease: t8-4bad3e64/shop-4bad3e64.example.test: HA lease acquired in 5ms (first wake)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: started carlos-instance@shop\x2d4bad3e64.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 6ms, control socket 0s, key gate 0s, logs 0s) 6ms, launch file 0s, gate 0s, root start 1ms)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: carlos-instance@shop\x2d4bad3e64.example.test.service launched in 7ms, healthy 0s later
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: woke in 22ms: checks 0s, lease 6ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 8ms
2026/11/27 22:10:57 lease: t8-4bad3e64/plain-4bad3e64.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/27 22:10:57 activator: no replica for plain-4bad3e64.example.test in s3://contract-bucket/t8-4bad3e64/plain-4bad3e64.example.test — booting fresh
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test: started carlos-instance@plain\x2d4bad3e64.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 1ms, instance key 0s, env 4ms, control socket 0s, key gate 0s, logs 0s) 5ms, launch file 0s, gate 0s, root start 1ms)
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test: carlos-instance@plain\x2d4bad3e64.example.test.service launched in 6ms, healthy 0s later
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test: woke in 41ms: checks 0s, lease 1ms, restore 17ms, identity 0s, protect 0s, spawn 7ms, replicate 15ms
2026/11/27 22:10:57 lease: t8-4bad3e64/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/11/27 22:10:57 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/27 22:10:57 activator: bot0.shop.bac.sidecar.internal: woke in 17ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, settle 0s, replicate 5ms
2026/11/27 22:10:57 activator: next-due probe plain-4bad3e64.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/27 22:10:57 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:e77b66814eec560ba2ed0a7d1b81c55ab5bcc858ce72be4287babf6dcc02da72) in 5ms: files 1ms, sync 2ms, record 1ms, marker 2ms
2026/11/27 22:10:57 activator: bot0.shop.bac.sidecar.internal hibernated
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test hibernated
2026/11/27 22:10:57 activator: next-due probe shop-4bad3e64.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: released with a marker (clean true, txid 1, files 3:51fbb986a1b91f13594074cd807a46de99a0fc936e3e236fd397383f29fb3adc) in 8ms: files 0s, sync 5ms, record 1ms, marker 2ms
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test hibernated
2026/11/27 22:10:57 lease: t8-4bad3e64/shop-4bad3e64.example.test: HA lease acquired in 3ms (clean marker)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: restored (other-box)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: started carlos-instance@shop\x2d4bad3e64.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 0s, control socket 0s, key gate 0s, logs 0s) 1ms, launch file 0s, gate 0s, root start 1ms)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: carlos-instance@shop\x2d4bad3e64.example.test.service launched in 2ms, healthy 0s later
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: woke in 85ms: checks 0s, lease 3ms, restore 25ms, identity 0s, protect 0s, spawn 2ms, replicate 54ms
2026/11/27 22:10:57 edge: ha-take shop-4bad3e64.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/11/27 22:10:57 edge: forward shop-4bad3e64.example.test: annie handed the request over to betty; sending it there (occurrence #1)
    hadrain_twobox_minio_linux_test.go:1238: drain report: {V:1 Transaction:t8-witness Incarnation:5b6a8c49f57103eec44778d7faf907fb Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-11-27 22:10:57.373179432 +0000 UTC FinishedAt:2026-11-27 22:10:57.521275583 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-4bad3e64.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:bot0.shop.bac.sidecar.internal Kind:worker Marker:true Clean:true Reason:} {Host:plain-4bad3e64.example.test Kind:other Marker:true Clean:true Reason:}] Unclean:[] Left:[] Holds:{LongestMS:130 Todays:0 RefusedAtOnce:1} Closed:0 Quiet:{DrainQuiet:{Waking:0 Stopping:0 Recovering:0 Owed:0} Held:[]}}
    hadrain_twobox_minio_linux_test.go:1239: driver calls: [begin shop-4bad3e64.example.test <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> stop plain-4bad3e64.example.test marker=true clean=true <nil> releasing shop-4bad3e64.example.test <nil> stop shop-4bad3e64.example.test marker=true clean=true <nil> taken shop-4bad3e64.example.test betty <nil> end-moves]
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/bot0.shop.bac.sidecar.internal/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/bot0.shop.bac.sidecar.internal/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/bot0.shop.bac.sidecar.internal/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-4bad3e64/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-4bad3e64/bot0.shop.bac.sidecar.internal/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-4bad3e64/plain-4bad3e64.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/head.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/generations/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0008/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0007/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0006/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0005/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0004/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0008/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0007/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0006/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0005/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0004/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/files/0/manifest.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/files/0/objects/0000000000000001-9a04c93f8dd3ad9e28117bb995a164a87a43f9e648cc0135b0fdb9cb49a82c68
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/files/0/objects/0000000000000003-6f111df9bee50694c05f7243c7b5213306f2b0e94b8810e6ed5a124c73208c4f
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/0000/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-4bad3e64/shop-4bad3e64.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/0000/0000000000000002-0000000000000002.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-4bad3e64/shop-4bad3e64.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1243: drain took 199ms; S3 calls 46 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=30 PUT lock=3 PUT replica=3); deployment store calls 20 (GET edges=14 LIST edges=4 PUT edges=2)
    hadrain_twobox_minio_linux_test.go:1367: the fenced A's start gate answers 503 "This service is unavailable. Try again later.\n" (Retry-After "10")
2026/11/27 22:10:57 lease: t8-4bad3e64/plain-4bad3e64.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test: started carlos-instance@plain\x2d4bad3e64.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 0s, control socket 0s, key gate 0s, logs 0s) 0s, launch file 0s, gate 0s, root start 1ms)
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test: carlos-instance@plain\x2d4bad3e64.example.test.service launched in 1ms, healthy 0s later
2026/11/27 22:10:57 lease: /tmp/carlos-minio-contract-lPyEly/g/dw1742088136/data/instances/plain-4bad3e64.example.test/plain-4bad3e64.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test: woke in 10ms: checks 0s, lease 1ms, restore 0s, identity 0s, protect 1ms, spawn 1ms, replicate 6ms
2026/11/27 22:10:57 activator: next-due probe shop-4bad3e64.example.test: decode /api/next-due: invalid character 'b' looking for beginning of value — recording none (it sleeps until a request)
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test: released with a marker (clean true, txid 2, files 3:51fbb986a1b91f13594074cd807a46de99a0fc936e3e236fd397383f29fb3adc) in 3ms: files 1ms, sync 0s, record 1ms, marker 2ms
2026/11/27 22:10:57 activator: shop-4bad3e64.example.test hibernated
2026/11/27 22:10:57 tenant admission is closed for shutdown
2026/11/27 22:10:57 activator: next-due probe plain-4bad3e64.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/27 22:10:57 activator: plain-4bad3e64.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.52s)
=== RUN   TestHeldHandoverLostLeaseMinio
2026/11/27 22:10:57 edge: mesh key: minted
2026/11/27 22:10:57 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/27 22:10:57 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/27 22:10:57 tenant admission is open. accepting tenant work
2026/11/27 22:10:57 activator: HA placement host=shop-3dd0fc2c.example.test kind=Place ref=annie reason=roomiest generation=2026-11-27T22:10:57Z lock_generation=0
2026/11/27 22:10:57 lease: t8-3dd0fc2c/shop-3dd0fc2c.example.test: HA lease acquired in 3ms (first wake)
2026/11/27 22:10:57 activator: shop-3dd0fc2c.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/27 22:10:57 activator: shop-3dd0fc2c.example.test: started carlos-instance@shop\x2d3dd0fc2c.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 5ms, control socket 0s, key gate 0s, logs 0s) 6ms, launch file 0s, gate 0s, root start 1ms)
2026/11/27 22:10:57 activator: shop-3dd0fc2c.example.test: carlos-instance@shop\x2d3dd0fc2c.example.test.service launched in 7ms, healthy 0s later
2026/11/27 22:10:57 activator: shop-3dd0fc2c.example.test: woke in 17ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 6ms
2026/11/27 22:10:57 activator: next-due probe shop-3dd0fc2c.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/27 22:10:57 activator: final checkpoint shop-3dd0fc2c.example.test: lease: release marker owed for s3://contract-bucket/t8-3dd0fc2c/shop-3dd0fc2c.example.test/lock.json (If-Match "a29c022edc35f05ba8bdc0e893ca1727"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/11/27 22:10:57 activator: shop-3dd0fc2c.example.test hibernated
2026/11/27 22:10:57 activator: handover of shop-3dd0fc2c.example.test left: released without a marker; its held requests get today's answer
    hadrain_twobox_minio_linux_test.go:1469: the held request's hold ended "shop-3dd0fc2c.example.test client 4 "
    hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-3dd0fc2c.example.test <nil> releasing shop-3dd0fc2c.example.test <nil> stop shop-3dd0fc2c.example.test marker=false clean=false <nil> left shop-3dd0fc2c.example.test released without a marker]
    hadrain_twobox_minio_linux_test.go:1487: a request after the loss: 503 "This instance cannot wake right now. Please try again shortly.\n" (Retry-After "10", holder "none", 0s, err <nil>)
2026/11/27 22:10:57 tenant admission is closed for shutdown
2026/11/27 22:10:57 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.27s)
PASS
ok  	github.com/carlosframework/platform/internal/host	0.830s
Bucket created successfully `local/gen-take`.
local/gen-take versioning is enabled
Created policy `gen-take` successfully.
Added user `gentake` successfully.
Attached Policies: [gen-take]
To User: gentake
=== RUN   TestGenerationTakeMinio
=== RUN   TestGenerationTakeMinio/take
2026/11/27 22:10:59 lease: instances/gen-1795817459032783372.shop.example.com: HA lease acquired in 5ms (first wake)
2026/11/27 22:10:59 lease: instances/gen-1795817459032783372.shop.example.com: HA lease acquired in 3ms (holder terminated)
    gentake_minio_test.go:308: a second create-only copy onto instances/gen-1795817459032783372.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/11/27 22:10:59 ERROR retention enforcement failed system=store db=w.example.com.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/27 22:10:59 ERROR retention enforcement failed system=store db=w.example.com.db error="enforce snapshot retention: fetch ltx files: lease: a write has waited too long to reach storage (write fence)"
=== RUN   TestGenerationTakeMinio/switch-412
2026/11/27 22:10:59 lease: instances/gen-1795817459154782279.shop.example.com: HA lease acquired in 4ms (first wake)
2026/11/27 22:10:59 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/27 22:10:59 lease: instances/gen-1795817459154782279.shop.example.com: HA lease acquired in 2ms (clean marker)
=== RUN   TestGenerationTakeMinio/copy-version
=== RUN   TestGenerationTakeMinio/store-time
2026/11/27 22:10:59 lease: instances/gen-1795817459252028610.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/27 22:10:59 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/27 22:10:59 lease: instances/gen-1795817459252028610.shop.example.com: HA lease acquired in 2ms (clean marker)
2026/11/27 22:10:59 lease: instances/gen-1795817459252028610.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/27 22:10:59 lease: instances/gen-1795817459252028610.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/27 22:10:59 lease: instances/gen-1795817459252028610.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/27 22:10:59 lease: instances/gen-1795817459252028610.shop.example.com: HA lease acquired in 2ms (unclean marker)
=== RUN   TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.39s)
    --- PASS: TestGenerationTakeMinio/take (0.12s)
    --- PASS: TestGenerationTakeMinio/switch-412 (0.09s)
    --- PASS: TestGenerationTakeMinio/copy-version (0.01s)
    --- PASS: TestGenerationTakeMinio/store-time (0.16s)
    --- PASS: TestGenerationTakeMinio/skew (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/lease	0.400s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading golang.org/x/sync v0.23.0
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
staticcheck: clean
=== govulncheck ===
go version go1.26.10 linux/arm64
go: downloading golang.org/x/vuln v1.8.0
go: downloading golang.org/x/telemetry v0.0.0-20260908163034-4bcc4b2ee518
go: downloading golang.org/x/tools v0.50.0
govulncheck: scanned github.com/carlosframework/platform, amadan.net/carlos/platform.git/launchctx, carlos-vulnscan
GO-2026-6859  called  stdlib@v1.26.10, fixed in v1.26.11
    HTTP/1 server crash due to MaxBytesReader header race in net/http
    excepted until 2027-01-31 (.amadan/govulncheck-exceptions.tsv:9): net/http MaxBytesReader header race, fixed in go1.26.11. CI and releases stay on go1.26.10 because 1.26.11 deadlocks the edge's Expect: 100-continue path (#897, .amadan/go-toolchain.sh); #904 checked every production MaxBytesReader site and found it unreachable.
GO-2026-5932  required  golang.org/x/crypto@v0.58.0, fixed in v0.58.1-0.20261009181718-2f1f834330b2
    The golang.org/x/crypto/openpgp package is unmaintained, unsafe by design, and has known security issues
    not fatal: no call path to the vulnerable code
govulncheck: clean (2 finding(s), none called outside .amadan/govulncheck-exceptions.tsv)
=== code-health ===
go version go1.26.10 linux/arm64
    codehealth_test.go:42: scanned in 1m51.157s
    codehealth_test.go:107: line metrics (code lines, then physical):
          file-lines  5471  7324  internal/activator activator_test.go
          file-lines  4200  7033  internal/console server.go
          file-lines  4150  6312  . apimode.go
          file-lines  3785  7224  internal/activator activator.go
          file-lines  3530  4459  . apimode_test.go
          file-lines  3261  3864  internal/registry registry_test.go
          file-lines  3209  6403  internal/host agent.go
          file-lines  3094  3992  internal/provision reconcile_test.go
          func-lines   870   891  internal/host plan14InstalledClaimLaunch
          func-lines   810  1277  internal/provision Reconcile
          func-lines   769  1242  internal/console (*Server).handleAPIInstanceCreate
          func-lines   688  1243  internal/host runAgent
          func-lines   571   908  internal/activator (*Service).doWakeOnce
          func-lines   538   546  internal/host runServingParkPeerNamespace
          func-lines   519   712  . runRoute
          func-lines   509   569  internal/host TestPagingIsRateLimited
          func-lines   494   815  internal/release adoptHost
          func-lines   441   500  internal/host TestRootInstanceStopExecStop
          func-lines   421   436  internal/host (*ClaimWakeAssembly).Build
          func-lines   421   437  internal/team TestFixture
          func-lines   412   414  internal/console TestDemoProtectionsSourceToLimitAndTakedown
          func-lines   408   485  . TestFleetAppServesThroughTheHub
          func-lines   402   406  internal/registry (*Registry).haJournal
          func-lines   400   868  internal/provision rootReadArchivedChain
          func-lines   399   732  internal/release PassFilter
          func-lines   390   398  internal/host runFilesSeedPreparationWithLive
          func-lines   383   406  internal/console TestDemoSourceToLiveAndUpdate
          func-lines   378   898  internal/edge (*Edge).ServeHTTP
          func-lines   374   377  internal/host plan14RequiredArtifactsRootRunner
          func-lines   371   417  internal/host TestRootEgressKernelProof
          func-lines   367   584  internal/console (*Server).handleAPIShip
          func-lines   366   636  cmd/console serve
          func-lines   364   371  internal/host testRootMigrationBootstrap
          func-lines   360   362  internal/edge TestDemoAPIAliasBoundary
          func-lines   357   358  internal/registry (*Registry).dispatchRemote
          func-lines   355   372  internal/host TestRootSandboxUpdateFromOldBox
          func-lines   343   354  internal/analytics Prune
          func-lines   340   353  internal/host newColdRootHarness
          func-lines   335   557  internal/console (*Store).migrate
          func-lines   334   334  internal/host TestPlan12RecoveryRestoreSourceDatabase
          func-lines   330   371  internal/edge TestRegionalNameNeverLeavesItsRegion
          func-lines   329   471  . runDeploy
          func-lines   329   329  internal/host TestPlan12RecoveryRestoreSourceDatabase.func1
          func-lines   327   369  internal/edge TestTunnelWebSocketEndToEnd
          func-lines   325   455  internal/objstore TestDeliveredContractMinio
          func-lines   320   654  internal/appconfig SyncExecWithCallbacks
          func-lines   315   318  internal/host plan14TimerIntention
          func-lines   311   314  internal/host plan14TimerIntention.func1
          func-lines   310   315  internal/hostbox ColdHandover.Run
          func-lines   308   309  internal/host rootFilesSeedIsolatedWitness
          func-lines   305   323  internal/host hairpinKernelWitness
          func-lines   304   308  internal/console TestHAP2ProductionDoors
          func-lines   302   329  internal/host TestRootG2PoolIngress
        release-importers: . cmd/console internal/activator internal/analytics internal/appconfig internal/apperr internal/applog internal/apppolicy internal/boxid internal/boxvolumes internal/console internal/dbreads internal/dbreads/dbreadstest internal/dbverify internal/demobuild internal/domains internal/doorkey internal/edge internal/edgeproof internal/edgesfile internal/fleetapi internal/grouproll internal/grouprollaws internal/historyreadback internal/host internal/hostactors internal/hostbox internal/hostclaim internal/hostevidence internal/hostexec internal/hostfence internal/hostfiles internal/hostfloor internal/hostguard internal/hostops internal/hostrelocate internal/hostresolve internal/instancectl internal/instanceupdates internal/interactive internal/layout internal/lease internal/ledger internal/mail internal/mailer internal/mailsubmit internal/metrics internal/moves internal/objstore internal/ops internal/park internal/plans internal/provision internal/relay internal/rollout internal/rootfsimage internal/runs internal/s3fake internal/schedule internal/seeds internal/status internal/telemetry internal/usage internal/vet scripts/pathmapcheck scripts/witness-pointer
        not scanned (216 files):
          cmd/carlos-media/drill_other.go: built only for other systems or tags
          cmd/carlos-media/harden_other.go: built only for other systems or tags
          cmd/console/fleetsocket_other.go: built only for other systems or tags
          cmd/console/servelock_windows.go: built only for other systems or tags
          cmd/moveprobe/detach_windows.go: built only for other systems or tags
          cmd/rootfswitness/mmap_other.go: built only for other systems or tags
          devbox_acl_other.go: built only for other systems or tags
          devbox_envfile_darwin_test.go: built only for other systems or tags
          devbox_envfile_other.go: built only for other systems or tags
          domains_transfer_signals_other.go: built only for other systems or tags
          interactive_term_darwin.go: built only for other systems or tags
          interactive_term_other.go: built only for other systems or tags
          internal/activator/claimprocess_root_other.go: built only for other systems or tags
          internal/activator/escrow_stamp_other.go: built only for other systems or tags
          internal/activator/fleetreserve_other.go: built only for other systems or tags
          internal/activator/harecord_other.go: built only for other systems or tags
          internal/activator/ownenv_other.go: built only for other systems or tags
          internal/activator/pty_other.go: built only for other systems or tags
          internal/activator/race_on_test.go: built only for other systems or tags
          internal/activator/rolelaunch_other.go: built only for other systems or tags
          internal/assetcache/statfs_other.go: built only for other systems or tags
          internal/boxself/io_other.go: built only for other systems or tags
          internal/cgroup/cleanup_other.go: built only for other systems or tags
          internal/cgroup/cleanup_other_test.go: built only for other systems or tags
          internal/cgroup/hostprocs_other.go: built only for other systems or tags
          internal/cgroup/recreate_other.go: built only for other systems or tags
          internal/cgroup/role_other.go: built only for other systems or tags
          internal/cgroup/shim_other.go: built only for other systems or tags
          internal/cgroup/strict_other.go: built only for other systems or tags
          internal/cgroup/verify_other.go: built only for other systems or tags
          internal/console/claim_sql_identity_other.go: built only for other systems or tags
          internal/console/geoipverify_other.go: built only for other systems or tags
          internal/console/hostreports_process_other.go: built only for other systems or tags
          internal/console/replicaview_other.go: built only for other systems or tags
          internal/console/restore_sim_nice_other_test.go: built only for other systems or tags
          internal/console/scalecost_other_test.go: built only for other systems or tags
          internal/console/seedscratch_windows.go: built only for other systems or tags
          internal/dbreads/worker_other.go: built only for other systems or tags
          internal/demobuild/security_other.go: built only for other systems or tags
          internal/democlaim/source_other.go: built only for other systems or tags
          internal/devbox/peer_darwin.go: built only for other systems or tags
          internal/devbox/peer_darwin_test.go: built only for other systems or tags
          internal/devbox/peer_other.go: built only for other systems or tags
          internal/devbox/socketcheck_other.go: built only for other systems or tags
          internal/domains/certimport_read_portable.go: built only for other systems or tags
          internal/edge/devboxpeer_other.go: built only for other systems or tags
          internal/edge/hairpin_other.go: built only for other systems or tags
          internal/edge/heldbudget_other.go: built only for other systems or tags
          internal/edge/purge_listen_unix.go: built only for other systems or tags
          internal/edge/purge_listen_windows.go: built only for other systems or tags
          internal/edge/race_on_test.go: built only for other systems or tags
          internal/edge/replicaconsole_owner_other.go: built only for other systems or tags
          internal/edge/replicaconsole_peer_other.go: built only for other systems or tags
          internal/edge/replicaconsole_socket_other_test.go: built only for other systems or tags
          internal/edge/static_artifact_other.go: built only for other systems or tags
          internal/edge/static_recordlock_other.go: built only for other systems or tags
          internal/edge/static_sweep_other.go: built only for other systems or tags
          internal/execsandbox/cleanup_other.go: built only for other systems or tags
          internal/execsandbox/file_other.go: built only for other systems or tags
          internal/execsandbox/oci_other.go: built only for other systems or tags
          internal/fileacl/fileacl_darwin.go: built only for other systems or tags
          internal/fileacl/fileacl_darwin_amd64.s: built only for other systems or tags
          internal/fileacl/fileacl_darwin_arm64.s: built only for other systems or tags
          internal/fileacl/fileacl_darwin_test.go: built only for other systems or tags
          internal/grouproll/state_other.go: built only for other systems or tags
          internal/grouprollaws/pty_darwin.go: built only for other systems or tags
          internal/grouprollaws/pty_other.go: built only for other systems or tags
          internal/hairpin/native_other.go: built only for other systems or tags
          internal/host/applylock_other_test.go: built only for other systems or tags
          internal/host/bootstrapfs_other.go: built only for other systems or tags
          internal/host/boxroles_config_other.go: built only for other systems or tags
          internal/host/claimfilesseed_delegation_other.go: built only for other systems or tags
          internal/host/claimfilesseed_transport_other.go: built only for other systems or tags
          internal/host/claimjournal_containment_other.go: built only for other systems or tags
          internal/host/claimjournal_migration_other.go: built only for other systems or tags
          internal/host/claimlaunch_kernel_other.go: built only for other systems or tags
          internal/host/claimlaunch_rev2_other_test.go: built only for other systems or tags
          internal/host/claimproduction_other.go: built only for other systems or tags
          internal/host/claimready_other.go: built only for other systems or tags
          internal/host/claimroleassembly_other.go: built only for other systems or tags
          internal/host/claimservingartifact_other.go: built only for other systems or tags
          internal/host/claimservinghandover_reboot_other.go: built only for other systems or tags
          internal/host/claimservinghandover_reboot_other_test.go: built only for other systems or tags
          internal/host/claimservingpark_other.go: built only for other systems or tags
          internal/host/claimstate_other.go: built only for other systems or tags
          internal/host/claimstop_kernel_other.go: built only for other systems or tags
          internal/host/claimtoken_inventory_other.go: built only for other systems or tags
          internal/host/claimunit_dropin_other.go: built only for other systems or tags
          internal/host/claimunit_files_other.go: built only for other systems or tags
          internal/host/claimunit_migrate_other.go: built only for other systems or tags
          internal/host/claimunit_ready_other.go: built only for other systems or tags
          internal/host/claimunit_socket_migration_other.go: built only for other systems or tags
          internal/host/consolefleet_owner_other.go: built only for other systems or tags
          internal/host/dbreads_other.go: built only for other systems or tags
          internal/host/egress_rail_other.go: built only for other systems or tags
          internal/host/fileowner_other.go: built only for other systems or tags
          internal/host/flock_windows.go: built only for other systems or tags
          internal/host/group_config_other.go: built only for other systems or tags
          internal/host/group_maintenance_other.go: built only for other systems or tags
          internal/host/group_maintenance_verbs_other.go: built only for other systems or tags
          internal/host/group_receipt_other.go: built only for other systems or tags
          internal/host/hadrain_call_other.go: built only for other systems or tags
          internal/host/hadrain_socket_other.go: built only for other systems or tags
          internal/host/hadrainfence_other.go: built only for other systems or tags
          internal/host/headroom_other.go: built only for other systems or tags
          internal/host/installchannel_other.go: built only for other systems or tags
          internal/host/managedboot_other.go: built only for other systems or tags
          internal/host/metrics_nested_other.go: built only for other systems or tags
          internal/host/movesfloor_other.go: built only for other systems or tags
          internal/host/movesfloorgate_other.go: built only for other systems or tags
          internal/host/movesheldrelease_other.go: built only for other systems or tags
          internal/host/movesmeasure_other.go: built only for other systems or tags
          internal/host/offcloudcredentials_other.go: built only for other systems or tags
          internal/host/registrychild_exec_other.go: built only for other systems or tags
          internal/host/registrychild_other.go: built only for other systems or tags
          internal/host/registryowner_chown_other.go: built only for other systems or tags
          internal/host/registryowner_descriptor_unix.go: built only for other systems or tags
          internal/host/replicahealth_other.go: built only for other systems or tags
          internal/host/rootgeneration_census_other.go: built only for other systems or tags
          internal/host/rootgeneration_kernel_other.go: built only for other systems or tags
          internal/host/rootgeneration_payload_other.go: built only for other systems or tags
          internal/host/rootgeneration_retired_other.go: built only for other systems or tags
          internal/host/rootmigration_production_other.go: built only for other systems or tags
          internal/host/runscset_other.go: built only for other systems or tags
          internal/host/sandboxenv_other.go: built only for other systems or tags
          internal/host/statfs_windows.go: built only for other systems or tags
          internal/host/systemapply_other.go: built only for other systems or tags
          internal/hostbox/census_vendor_other.go: built only for other systems or tags
          internal/hostbox/inventory_identity_other.go: built only for other systems or tags
          internal/hostbox/journalmigration_other.go: built only for other systems or tags
          internal/hostbox/journalnamespace_other.go: built only for other systems or tags
          internal/hostbox/journaltrust_other.go: built only for other systems or tags
          internal/hostbox/migration_census_other.go: built only for other systems or tags
          internal/hostbox/typedpark_other.go: built only for other systems or tags
          internal/hostenv/group_other.go: built only for other systems or tags
          internal/hostenv/write_other.go: built only for other systems or tags
          internal/hostenv/write_other_test.go: built only for other systems or tags
          internal/hostexec/clock_other.go: built only for other systems or tags
          internal/hostexec/clock_other_test.go: built only for other systems or tags
          internal/hostexec/local_other.go: built only for other systems or tags
          internal/hostexec/pending_other.go: built only for other systems or tags
          internal/hostexec/probe_other.go: built only for other systems or tags
          internal/hostexec/rootprocess_other.go: built only for other systems or tags
          internal/hostfiles/dir_other.go: built only for other systems or tags
          internal/hostfiles/refuse_other.go: built only for other systems or tags
          internal/hostfiles/watch_other.go: built only for other systems or tags
          internal/hostfloor/controllers_other.go: built only for other systems or tags
          internal/hostfloor/image_other.go: built only for other systems or tags
          internal/hostguard/flock_other.go: built only for other systems or tags
          internal/hostguard/flock_other_test.go: built only for other systems or tags
          internal/hostguard/record_other.go: built only for other systems or tags
          internal/instancectl/claimexec_other.go: built only for other systems or tags
          internal/instancectl/claimexec_socket_other.go: built only for other systems or tags
          internal/instancectl/claimlaunch_snapshot_other.go: built only for other systems or tags
          internal/instancectl/claimnetwork_other.go: built only for other systems or tags
          internal/instancectl/demo_snapshot_other.go: built only for other systems or tags
          internal/instancectl/egress_cgroup_other.go: built only for other systems or tags
          internal/instancectl/egress_dropin_other.go: built only for other systems or tags
          internal/instancectl/fleetsize_other.go: built only for other systems or tags
          internal/instancectl/gvisorprobe_other.go: built only for other systems or tags
          internal/instancectl/peer_other.go: built only for other systems or tags
          internal/instancectl/peer_tuple_other.go: built only for other systems or tags
          internal/instancectl/rootfs_identity_other.go: built only for other systems or tags
          internal/instanceexec/claimexec_other.go: built only for other systems or tags
          internal/instanceexec/exec_rootfs_other.go: built only for other systems or tags
          internal/instanceexec/netlink_route_other.go: built only for other systems or tags
          internal/instanceexec/probe_gvisor_other.go: built only for other systems or tags
          internal/instanceexec/probe_hardening_other.go: built only for other systems or tags
          internal/instanceexec/probe_other.go: built only for other systems or tags
          internal/instanceexec/probe_rootfs_other.go: built only for other systems or tags
          internal/instanceexec/sandbox_other.go: built only for other systems or tags
          internal/instanceexec/scope_other.go: built only for other systems or tags
          internal/instanceexec/stop_other.go: built only for other systems or tags
          internal/instanceexec/tty_other.go: built only for other systems or tags
          internal/instancefs/instancefs_other.go: built only for other systems or tags
          internal/launchd/activate_darwin.go: built only for other systems or tags
          internal/launchd/activate_darwin_amd64.s: built only for other systems or tags
          internal/launchd/activate_darwin_arm64.s: built only for other systems or tags
          internal/launchd/activate_darwin_test.go: built only for other systems or tags
          internal/layout/journal_other.go: built only for other systems or tags
          internal/layout/links_other.go: built only for other systems or tags
          internal/mailer/keys_other.go: built only for other systems or tags
          internal/maintenanceexec/run_other.go: built only for other systems or tags
          internal/managedboot/admission_other.go: built only for other systems or tags
          internal/managedboot/identity_other.go: built only for other systems or tags
          internal/mediahandler/collect_other.go: built only for other systems or tags
          internal/mediahandler/procs_other.go: built only for other systems or tags
          internal/medialocal/runner_other.go: built only for other systems or tags
          internal/moves/archive/open_other.go: built only for other systems or tags
          internal/moves/archive/sync_other.go: built only for other systems or tags
          internal/ops/flock_windows.go: built only for other systems or tags
          internal/park/local_other.go: built only for other systems or tags
          internal/privatefile/io_other.go: built only for other systems or tags
          internal/proxyproto/peek_other.go: built only for other systems or tags
          internal/relay/race_on_test.go: built only for other systems or tags
          internal/release/consumedfence_other.go: built only for other systems or tags
          internal/release/digestcache_other.go: built only for other systems or tags
          internal/rootaws/credentials_other.go: built only for other systems or tags
          internal/rootaws/open_darwin.go: built only for other systems or tags
          internal/rootfsimage/dir_other.go: built only for other systems or tags
          internal/rootstate/authoritydir_other.go: built only for other systems or tags
          internal/rootstate/authorityfile_other.go: built only for other systems or tags
          internal/rootstate/file_other.go: built only for other systems or tags
          internal/rootstate/link_other.go: built only for other systems or tags
          internal/rootstate/persistent_other.go: built only for other systems or tags
          internal/rootstate/state_other.go: built only for other systems or tags
          internal/safefile/file_other.go: built only for other systems or tags
          internal/safefile/reap_other.go: built only for other systems or tags
          internal/stopevidence/fds_other.go: built only for other systems or tags
          internal/stopevidence/fds_other_test.go: built only for other systems or tags
          internal/stopevidence/holders_other.go: built only for other systems or tags
          internal/stopevidence/reconstruct_other.go: built only for other systems or tags
          internal/team/storelock_other.go: built only for other systems or tags
          internal/team/storelock_windows.go: built only for other systems or tags
          move_offline_run_other.go: built only for other systems or tags
          system_group_other.go: built only for other systems or tags
        
    codehealth_test.go:115: fatal               1094 at  474 sites  log.Fatal*, (*log.Logger).Fatal* and os.Exit in the root package's production files
    codehealth_test.go:115: sleep               1005 at  811 sites  time.Sleep in test files
    codehealth_test.go:115: db-no-context        885 at  703 sites  database calls with no context (dbOpWithoutContext) in production files
    codehealth_test.go:115: host-context         188 at  142 sites  context.Background and context.TODO in internal/host production files
    codehealth_test.go:115: func-lines         18604 at   45 sites  functions over 300 code lines (blank and comment-only lines not counted)
    codehealth_test.go:115: file-lines         30700 at    8 sites  files over 3,000 code lines, counted the same way
    codehealth_test.go:115: release-importers     66 at    1 sites  packages whose production files import internal/release
    codehealth_test.go:119: below the record: file-lines internal/console server.go -: 4200 in the code, the record allows 4210 (make code-health-record lowers it)
--- PASS: TestCodeHealth (111.16s)
PASS
ok  	github.com/carlosframework/platform/internal/codehealth	112.593s
=== code-health-record ===
go version go1.26.10 linux/arm64
code-health record: HEAD is on main; comparing with its parent 9f5292370dd7cf019afeb7eaf8587ab361eb24e4
=== RUN   TestRecordAgainstBase
--- PASS: TestRecordAgainstBase (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/codehealth	0.008s
code-health record: no line went up without a reason
=== race ===
go version go1.26.10 linux/arm64
GATE_RACE=1 .amadan/test-gate.sh
=== internal_systemd@0 (13 s, from +14 s)
ok  	github.com/carlosframework/platform/internal/systemd	13.205s
=== internal_rootaws@0 (26 s, from +33 s)
ok  	github.com/carlosframework/platform/internal/rootaws	25.348s
=== internal_activator@0 (268 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	265.873s
=== internal_activator@1 (265 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	262.816s
=== internal_activator@2 (276 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	274.010s
=== internal_activator@3 (413 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	411.287s
=== internal_activator@4 (277 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	274.740s
=== internal_activator@5 (310 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	307.851s
=== internal_activator@6 (318 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	316.011s
=== internal_activator@7 (408 s, from +111 s)
ok  	github.com/carlosframework/platform/internal/activator	405.558s
=== internal_edge@0 (84 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	80.946s
=== internal_edge@1 (131 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	127.983s
=== internal_edge@2 (222 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	218.966s
=== internal_edge@3 (132 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	128.023s
=== internal_edge@4 (149 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	145.704s
=== internal_edge@5 (236 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	232.119s
=== internal_edge@6 (213 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	209.884s
=== internal_edge@7 (273 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	269.329s
=== internal_edge@8 (230 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	226.800s
=== internal_edge@9 (268 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	264.254s
=== internal_edge@10 (222 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	218.258s
=== internal_edge@11 (218 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	214.840s
=== internal_edge@12 (243 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	239.583s
=== internal_edge@13 (246 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	242.724s
=== internal_edge@14 (194 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	190.487s
=== internal_edge@15 (231 s, from +132 s)
ok  	github.com/carlosframework/platform/internal/edge	227.545s
=== internal_host@0 (8 s, from +193 s)
ok  	github.com/carlosframework/platform/internal/host	4.669s
=== internal_host@1 (17 s, from +193 s)
ok  	github.com/carlosframework/platform/internal/host	13.421s
=== lists: internal_edge 132 s, internal_activator 110 s, internal_host 192 s, internal_rootaws 33 s, internal_systemd 13 s
=== cpu: the gate used 7609 cpu-seconds in 524 s, about 14.5 of 32 cores; the machine as a whole was 45% busy
=== gitleaks ===
go version go1.26.10 linux/arm64
go: downloading github.com/zricethezav/gitleaks/v8 v8.30.1
go: downloading github.com/rs/zerolog v1.33.0
go: downloading github.com/spf13/cobra v1.9.1
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/spf13/viper v1.19.0
go: downloading golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
go: downloading github.com/BobuSumisu/aho-corasick v1.0.3
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading github.com/charmbracelet/lipgloss v0.5.0
go: downloading github.com/fatih/semgroup v1.2.0
go: downloading github.com/h2non/filetype v1.1.3
go: downloading github.com/gitleaks/go-gitdiff v0.9.1
go: downloading github.com/mholt/archives v0.1.2
go: downloading golang.org/x/sync v0.11.0
go: downloading github.com/spf13/pflag v1.0.6
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading github.com/spf13/cast v1.7.1
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/magiconair/properties v1.8.9
go: downloading github.com/muesli/termenv v0.15.1
go: downloading github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
go: downloading github.com/STARRY-S/zip v0.2.1
go: downloading github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3
go: downloading github.com/bodgit/sevenzip v1.6.0
go: downloading github.com/klauspost/compress v1.17.11
go: downloading github.com/klauspost/pgzip v1.2.6
go: downloading github.com/minio/minlz v1.0.0
go: downloading github.com/nwaples/rardecode/v2 v2.1.0
go: downloading github.com/pierrec/lz4/v4 v4.1.21
go: downloading github.com/sorairolake/lzip-go v0.3.5
go: downloading github.com/therootcompany/xz v1.0.1
go: downloading github.com/ulikunitz/xz v0.5.12
go: downloading golang.org/x/text v0.22.0
go: downloading github.com/mattn/go-colorable v0.1.14
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading golang.org/x/sys v0.30.0
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading github.com/bodgit/plumbing v1.3.0
go: downloading github.com/bodgit/windows v1.0.1
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading go4.org v0.0.0-20230225012048-214862532bf5
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.7
go: downloading dario.cat/mergo v1.0.1
go: downloading github.com/Masterminds/semver/v3 v3.3.0
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.4.0
go: downloading golang.org/x/crypto v0.35.0
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/mitchellh/reflectwalk v1.0.2
self-test: reported source file: a key
self-test: reported source file: a 64-hex key
self-test: reported source file: a census-shaped entry
self-test: reported source file: a key marked gitleaks:allow
self-test: reported source file: a test's fake value outside tests
self-test: reported allowed file: another key beside its allowed value
self-test: reported a tracked file named gitleaks-gate-sentinel.env
self-test: reported 100 near misses of the names notscanned.go lists
self-test: skipped  the 33 files notscanned.go lists
self-test: refused  a notscanned.go entry git does not track
self-test: refused  a config that does not parse
self-test: refused  a config that does not exist
self-test: refused  a missing gitleaks binary
self-test: 6 planted keys reported, 134 tracked files judged, 3 broken setups refused
gitleaks: scanned 11801 tracked files; 33 not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)
gitleaks: clean

landed from gvisor-slice1-control-purge

diff --git a/docs/superpowers/notes/census-proposal-gvisor-slice1-control-purge.md b/docs/superpowers/notes/census-proposal-gvisor-slice1-control-purge.md
new file mode 100644
index 000000000..9cad24a60
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-gvisor-slice1-control-purge.md
@@ -0,0 +1,39 @@
+# Census approval: gvisor-slice1-control-purge
+
+Ruling `census-ruling-gvisor-slice1-control-purge`. The independent reviewer approves or rejects every change below, 5 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/demobuild/runner.go` `Run` | body | unchanged (1) | F3: after the stop proof and before opening out/app, waits (within the build ctx) for the process-wide one-at-a-time output turn; every failure releases it, success hands it to the caller in BuildOutput. Same no-follow OpenBeneath of out/app; validation moves to readOutput. No new read path or input. F3 fix round 1: the output turn's release is deferred right after it is taken and disarmed only when a validated output hands it to the caller, so a panic in validation (debug/elf over the build's bytes) gives it back too. Same no-follow OpenBeneath of out/app and the same bounded read; no new read path or input. |
+| `internal/demobuild/runner.go` `ValidateOutput` | body | unchanged (1) | F3: body split; ELF/segment/digest checks moved verbatim into validateBinary, which ValidateOutput (client side) and readOutput (root) both call. Same bounded ReadAll; checks unchanged. F3 fix round 2: validateBinary recovers a debug/elf panic on the bytes it parses and answers ErrBuild; same bounded read and checks. |
+| `internal/demobuild/worker.go` `Worker.Build` | body | unchanged (1) | F3: when scratch cleanup fails and the output is discarded, releases its output turn first. No read change. F3 fix round 1: the scratch-cleanup defer releases the output turn and poisons the worker if cleanup panics, as it already did when cleanup failed. No read change. |
+
+Envelopes re-pinned: `internal/activator`, `internal/demobuild`, `internal/instancectl`, `internal/instancefs`.
+
+Removed units: the scan finds neither the declaration nor any of its sites.
+
+| unit | recorded disposition | basis | what changed |
+|---|---|---|---|
+| `internal/instancefs/dirs_linux.go` `removeAt` | legacy, task accepted-legacy | accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): reached only through RemoveAllBeneath from internal/runs (staging cleanup, RemoveRunDir, SweepRunDirs), all in the agent's runs worker; removes a run's own directory without following a link | F6: deleted, replaced by treeRemover (same no-follow guarantees, no depth-64 refusal, bounded descriptors and memory). |
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+A removed unit's recorded disposition and basis are in its table above. For a removed unit or a retired envelope, confirm from the diff that the code is deleted and not moved: a read that moved shows on this card as a change to the unit that took it, and a unit moved whole shows as a new unit, a decision. Reject if a check, refusal or validation that root relies on goes with the deleted code and its callers' changes on this card do not account for that.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/demobuild/runner.go` `Run`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Consumes only its private root-prepared invocation, proves stop, then no-follow reads bounded diagnostics/output beneath that job.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain bounded no-follow diagnostics/output reads after termination proof; filter gVisor runtime timestamp lines before returning compiler diagnostics. No new read. Task 9: Log failing steps through root logger before returning exactly ErrBuild. Existing bounded no-follow reads and termination-before-output retained.
+- `internal/demobuild/runner.go` `ValidateOutput`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads bounded bytes, ELF header/program headers and computes their SHA-256; never executes output.
+- `internal/demobuild/worker.go` `Worker.Build`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Holds the build/purge read lock through cleanup; existing bounded source read remains.;rev3=census-ruling-demo-slice-adopt;basis=Before admission, call the admit hook (nil = reconcileBudget); a pending budget change (errBudgetPending) is retried every 2 s until the job deadline, any other error fails at once. reconcileBudget reads the fixed build slice's systemctl show budget, its cgroup limit files and cgroup.events under the fixed root cgroup path, and list-jobs (a listing at the capture limit defers); only with buildPurge held exclusively, the slice empty and no build or slice job queued does it run systemctl stop on the fixed slice name. No tenant, app or agent input names a path or unit.
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/demobuild/runner.go:readOutput`: reads +file:Read, +file:Stat; written legacy, accepted-legacy, frozen
+- new `internal/instancefs/dirs_linux.go:treeRemover.clear`: reads +file:Fstatat; written legacy, accepted-legacy, frozen
+- new `internal/instancefs/dirs_linux.go:treeRemover.open`: reads +file:Openat2; written legacy, accepted-legacy, frozen
+- new `internal/instancefs/dirs_linux.go:treeRemover.remove`: reads +file:Fstatat; written legacy, accepted-legacy, frozen
+- new `internal/instancefs/dirs_linux.go:treeRemover.sameTop`: reads +file:Fstat; written legacy, accepted-legacy, frozen
+
+Seal: `dbdeb2e3a1a89cb8f33584fdb80a3bf1c5adef14ce222fef9d442ed8e059699c` → `a3f8ba38714f1cdeea10b3e5ed4402d290e88cc1cc1f3f3875f446aa46346e82`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-gvisor-slice1-control-purge.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md b/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md
index 6a77d2b51..01fc41cb1 100644
--- a/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md
+++ b/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md
@@ -48,12 +48,14 @@ Both apply today under the native sandbox, so this slice ships first and protect
- **Fix:** an iterative removal with a fixed budget of at most 3 live directory descriptors, temporary ones included.
- It keeps a stack of name components, not fds. To reach a directory it walks from the purge root ONE COMPONENT AT A TIME: `openat2(parentfd, name, RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS|RESOLVE_NO_MAGICLINKS)`, then closes the parent. No joined pathname is ever passed to the kernel, so total path length (beyond PATH_MAX) does not matter. The walk is quadratic in depth, which is accepted.
- It reads entries in batches of 256.
- - The name stack is bounded at 65,536 components (at most about 16 MiB of names). Past that, purge refuses with "too deep", leaves the tree, and marks the demo for operator recovery (`carlos` box verb, documented in the runbook). This is a reachable refusal, accepted; the guest has no directory-depth limit.
+ - The name stack is bounded at 65,536 components (at most about 16 MiB of names). Past that, purge does not refuse: it renames the directory it would descend into up into the purge root (`renameat2` with `RENAME_NOREPLACE`, the root reopened one component at a time and checked by device and inode) under a name of 128 random bits, and carries on. Each move shortens the deepest path, so any depth is removed with the same stack and descriptors, and no name a tenant plants can make every retry fail. An interrupted purge leaves the moved directory as an ordinary entry for the next one. No operator recovery step or box verb is needed.
+ - Once removal has begun, no error reads as "already absent": a directory that goes missing mid-walk (the parent at a move included) was moved, perhaps with data in it, so it is an error, never success.
- **Tests:**
- a tree whose total path is over 64 KiB (long 255-byte names), and a 10,000-deep tree, both purge with `RLIMIT_NOFILE` set to 16;
- a 100k-entry directory purges with bounded memory;
- a directory swapped for a symlink between batches is not followed;
- an interrupted purge (error injected mid-walk) resumes and completes on retry.
+ - with a small depth bound: a purge past it moves directories up and finishes, through `RemoveAllBeneath` and `PurgeProven` alike; planted names (the old `.carlos-removing-0` to `-63` included) do not stop it; a name collision is retried; a purge stopped after a move resumes; and the parent vanishing at a move is an error, not "gone".
The census applies (`internal/demobuild`, `internal/instancefs`, `internal/instancectl` and `internal/host/units`). Release with the usual dev-first roll; the dev demo box witnesses one large build and one deep purge.
diff --git a/internal/activator/hawake.go b/internal/activator/hawake.go
index 31029cb33..79bb47cfb 100644
--- a/internal/activator/hawake.go
+++ b/internal/activator/hawake.go
@@ -1006,8 +1006,12 @@ func removeIfThere(dir, name string) error {
return nil
}
+// removeTreeBeneath is removeAllIfThere's removal, a seam for the test of
+// state that cannot be removed.
+var removeTreeBeneath = instancefs.RemoveAllBeneath
+
func removeAllIfThere(dir, name string) error {
- if err := instancefs.RemoveAllBeneath(dir, name); err != nil && !gone(err) {
+ if err := removeTreeBeneath(dir, name); err != nil && !gone(err) {
return err
}
return nil
diff --git a/internal/activator/hawake_test.go b/internal/activator/hawake_test.go
index 8046b1c29..298622c99 100644
--- a/internal/activator/hawake_test.go
+++ b/internal/activator/hawake_test.go
@@ -1050,6 +1050,8 @@ func TestHASpawnRefusedAfterLayoutChange(t *testing.T) {
// the wake before anything is moved, restored or replicated.
func TestSetAsideFailsWhenLitestreamStateCannotBeRemoved(t *testing.T) {
ctx := context.Background()
+ orig := removeTreeBeneath
+ t.Cleanup(func() { removeTreeBeneath = orig })
for _, meta := range []func(db string) string{
func(db string) string {
return filepath.Join(filepath.Dir(db), ".activator-"+filepath.Base(db)+"-litestream")
@@ -1060,15 +1062,19 @@ func TestSetAsideFailsWhenLitestreamStateCannotBeRemoved(t *testing.T) {
l1 := haFixOf(b).lifetime
writeDBAndRecord(t, b, rt, hafresh.Marker{V: 1, Box: "a", IID: "i-a", Lifetime: l1, TXID: 5, Clean: true})
dir := meta(dbPathOf(b, rt))
- // Deeper than the checked removal descends (64): it refuses, as
- // a directory it cannot write would, for any user, root included.
- deep := dir
- for range 66 {
- deep = filepath.Join(deep, "d")
- }
- if err := os.MkdirAll(deep, 0o700); err != nil {
+ if err := os.MkdirAll(filepath.Join(dir, "d"), 0o700); err != nil {
t.Fatal(err)
}
+ // The removal refuses this tree, as it would one it cannot write,
+ // for any user, root included. (A tree past 64 levels stood in for
+ // that until the removal took any depth, F6.)
+ prev := removeTreeBeneath
+ removeTreeBeneath = func(d, name string) error {
+ if name == filepath.Base(dir) {
+ return errors.New("injected: cannot remove")
+ }
+ return prev(d, name)
+ }
putLockFor(t, b, rt, markerBody(t, "b", "i-b", l1, 6, true))
l, err := b.Acquire(ctx, rt)
if err != nil {
@@ -1078,6 +1084,7 @@ func TestSetAsideFailsWhenLitestreamStateCannotBeRemoved(t *testing.T) {
if _, err := b.Restore(ctx, rt); err == nil {
t.Fatalf("%s: the wake went on over litestream state it could not remove", filepath.Base(dir))
}
+ removeTreeBeneath = prev
if restoreCalls(b) != 0 || !exists(dbPathOf(b, rt)) || exists(dbPathOf(b, rt)+".stale") {
t.Fatalf("%s: the copy was moved or restored over (%d restores)", filepath.Base(dir), restoreCalls(b))
}
diff --git a/internal/demobuild/gvisor_build_rootrunner_linux_test.go b/internal/demobuild/gvisor_build_rootrunner_linux_test.go
index 2c3339a50..e9e9d5b84 100644
--- a/internal/demobuild/gvisor_build_rootrunner_linux_test.go
+++ b/internal/demobuild/gvisor_build_rootrunner_linux_test.go
@@ -205,6 +205,7 @@ func rootrunnerBuild(t *testing.T, capture bool) {
defer func() { systemctl = ctl }()
start = time.Now()
built, err := w.runUnit(ctx, l.dir, lock)
+ built.Release() // the bytes stay readable; only the transfer turn goes back
elapsed := time.Since(start)
if err != nil {
b, _ := os.ReadFile(l.work + "/diagnostics")
@@ -245,7 +246,7 @@ func rootrunnerBuild(t *testing.T, capture bool) {
l, cleanup = prepare(strings.Replace(large, "40<<20", "20<<20", 1))
buildCtx, stop := context.WithCancel(ctx)
done := make(chan error, 1)
- go func() { _, err := w.runUnit(buildCtx, l.dir, lock); done <- err }()
+ go func() { out, err := w.runUnit(buildCtx, l.dir, lock); out.Release(); done <- err }()
active := false
for deadline := time.Now().Add(10 * time.Second); time.Now().Before(deadline); time.Sleep(10 * time.Millisecond) {
out, err := systemctl(ctx, "show", l.unit, "-p", "MainPID,ActiveState")
diff --git a/internal/demobuild/gvisor_cleanup_test.go b/internal/demobuild/gvisor_cleanup_test.go
index ba8d12fa6..6a1543b27 100644
--- a/internal/demobuild/gvisor_cleanup_test.go
+++ b/internal/demobuild/gvisor_cleanup_test.go
@@ -87,7 +87,8 @@ func TestGVisorBuildExitDiagnosticsOnly(t *testing.T) {
return stopBuildContext(ctx, buildLayout{unit: "carlos-demo-build-gvisor@test.service", family: execsandbox.FamilyGVisor})
},
}
- _, err := Run(context.WithValue(t.Context(), runContextKey{}, i), dir, testLock(t))
+ out, err := Run(context.WithValue(t.Context(), runContextKey{}, i), dir, testLock(t))
+ out.Release()
if (err == nil) != (fault == "") {
t.Fatalf("fault=%s fields=%q: %v", fault, fields, err)
}
diff --git a/internal/demobuild/job.go b/internal/demobuild/job.go
index 1c85f761c..e5067e1ea 100644
--- a/internal/demobuild/job.go
+++ b/internal/demobuild/job.go
@@ -157,6 +157,8 @@ type BuildOutput struct {
SHA256 string `json:"sha256"`
Diagnostics []Diagnostic `json:"diagnostics"`
DiagnosticsTruncated bool `json:"diagnostics_truncated,omitempty"`
+ // hold is this output's turn in the one-at-a-time transfer (transfer.go).
+ hold *outputHold
}
// StreamMessage carries signed work or a reconciliation hint. Hints grant no
diff --git a/internal/demobuild/probe.go b/internal/demobuild/probe.go
index 917860a65..2a07bbb5c 100644
--- a/internal/demobuild/probe.go
+++ b/internal/demobuild/probe.go
@@ -35,7 +35,8 @@ func (w *Worker) probeBundle(ctx context.Context) (err error) {
if err != nil {
return err
}
- _, err = w.runUnit(ctx, dir, w.lock)
+ out, err := w.runUnit(ctx, dir, w.lock)
+ out.Release()
return err
}
diff --git a/internal/demobuild/runner.go b/internal/demobuild/runner.go
index 53d35f506..c2608284b 100644
--- a/internal/demobuild/runner.go
+++ b/internal/demobuild/runner.go
@@ -58,6 +58,38 @@ func ValidateOutput(r io.Reader) (BuildOutput, error) {
if err != nil || len(b) > BinaryMaxBytes {
return BuildOutput{}, ErrBuild
}
+ return validateBinary(b)
+}
+
+// readOutput is ValidateOutput for the build's own output file in root. It
+// sizes one buffer from the open file instead of growing one as it reads,
+// so a transfer holds the output once, and it validates and digests exactly
+// the bytes the response will carry. The build has stopped; a file that
+// still grows past its size is refused.
+func readOutput(f *os.File) (BuildOutput, error) {
+ st, err := f.Stat()
+ if err != nil || !st.Mode().IsRegular() || st.Size() > BinaryMaxBytes {
+ return BuildOutput{}, ErrBuild
+ }
+ b := make([]byte, st.Size())
+ if _, err = io.ReadFull(f, b); err != nil {
+ return BuildOutput{}, ErrBuild
+ }
+ if n, _ := f.Read(make([]byte, 1)); n != 0 {
+ return BuildOutput{}, ErrBuild
+ }
+ return validateBinary(b)
+}
+
+// validateBinary parses the build's own bytes. debug/elf can panic on a
+// crafted header; that output is refused like any other bad one, so an
+// anonymous build cannot put a stack trace in root's log.
+func validateBinary(b []byte) (out BuildOutput, err error) {
+ defer func() {
+ if recover() != nil {
+ out, err = BuildOutput{}, ErrBuild
+ }
+ }()
f, err := elf.NewFile(bytes.NewReader(b))
if err != nil {
return BuildOutput{}, ErrBuild
@@ -178,12 +210,32 @@ func Run(ctx context.Context, workDir string, lock Lock) (BuildOutput, error) {
if runErr != nil {
return out, buildFailure("runUnit.start-wait", runErr)
}
+ // The turn is held from here until the caller releases the output after
+ // writing its response. Every other way out hands it back, a panic
+ // included: debug/elf runs over the build's own bytes, and net/http
+ // recovers a handler's panic and keeps the service, so a turn lost to
+ // one would stall every later build until its deadline.
+ held, err := AwaitOutputTransfer(ctx)
+ if err != nil {
+ return out, buildFailure("runUnit.await-transfer", err)
+ }
+ handedOver := false
+ defer func() {
+ if !handedOver {
+ held.Release()
+ }
+ }()
f, err := instancefs.OpenBeneath(workDir, "out/app", os.O_RDONLY, 0)
if err != nil {
return out, buildFailure("runUnit.open-output", err)
}
defer f.Close()
- validated, err := ValidateOutput(f)
+ validated, err := readOutput(f)
+ if err != nil {
+ validated = BuildOutput{}
+ } else {
+ validated.hold, handedOver = held.hold, true
+ }
validated.Diagnostics = out.Diagnostics
validated.DiagnosticsTruncated = out.DiagnosticsTruncated
return validated, buildFailure("runUnit.validate-output", err)
diff --git a/internal/demobuild/transfer.go b/internal/demobuild/transfer.go
new file mode 100644
index 000000000..dad54d6ae
--- /dev/null
+++ b/internal/demobuild/transfer.go
@@ -0,0 +1,39 @@
+package demobuild
+
+import (
+ "context"
+ "sync"
+)
+
+// outputTransfer admits one finished build's output into root's memory at a
+// time (F3). An output is up to BinaryMaxBytes raw and about 4/3 of that
+// again once instance-control JSON-encodes it, so four slots finishing
+// together would hold four of each. The turn is taken before the output is
+// read and given back after its response is written; other finished builds
+// wait for it within their own deadline.
+var outputTransfer = make(chan struct{}, 1)
+
+type outputHold struct{ once sync.Once }
+
+// AwaitOutputTransfer waits for this process's output turn and returns an
+// empty output that holds it until Release. It fails when ctx ends first.
+func AwaitOutputTransfer(ctx context.Context) (BuildOutput, error) {
+ if err := ctx.Err(); err != nil {
+ return BuildOutput{}, err
+ }
+ select {
+ case outputTransfer <- struct{}{}:
+ return BuildOutput{hold: &outputHold{}}, nil
+ case <-ctx.Done():
+ return BuildOutput{}, ctx.Err()
+ }
+}
+
+// Release gives back the output turn o holds, if any. The holder calls it
+// once the output's bytes are no longer needed: after the response is
+// written, or when the output is discarded. Calling it again does nothing.
+func (o BuildOutput) Release() {
+ if o.hold != nil {
+ o.hold.once.Do(func() { <-outputTransfer })
+ }
+}
diff --git a/internal/demobuild/transfer_test.go b/internal/demobuild/transfer_test.go
new file mode 100644
index 000000000..ec256989b
--- /dev/null
+++ b/internal/demobuild/transfer_test.go
@@ -0,0 +1,350 @@
+//go:build linux
+
+package demobuild
+
+import (
+ "bytes"
+ "context"
+ "debug/elf"
+ "encoding/binary"
+ "encoding/json"
+ "errors"
+ "io"
+ "os"
+ "path/filepath"
+ "runtime"
+ "runtime/debug"
+ "sync/atomic"
+ "syscall"
+ "testing"
+ "time"
+)
+
+// arm64ELFOfSize is arm64ELF padded to n bytes, its one load segment
+// covering the whole file.
+func arm64ELFOfSize(n int) []byte {
+ b := append(arm64ELF(), make([]byte, n-120)...)
+ binary.LittleEndian.PutUint64(b[96:], uint64(n))
+ binary.LittleEndian.PutUint64(b[104:], uint64(n))
+ return b
+}
+
+func finishedBuild(t *testing.T, output []byte) (context.Context, string) {
+ t.Helper()
+ dir := t.TempDir()
+ if err := os.Mkdir(filepath.Join(dir, "out"), 0755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(dir, "out/app"), output, 0644); err != nil {
+ t.Fatal(err)
+ }
+ i := &runInvocation{dir: dir, startWait: func(context.Context) error { return nil }, stop: func() error { return nil }}
+ return context.WithValue(t.Context(), runContextKey{}, i), dir
+}
+
+// transferFree reports whether the one-at-a-time output turn is free now.
+func transferFree(t *testing.T) bool {
+ t.Helper()
+ ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond)
+ defer cancel()
+ out, err := AwaitOutputTransfer(ctx)
+ if err != nil {
+ return false
+ }
+ out.Release()
+ return true
+}
+
+// Four builds that finish together read their outputs into memory one at a
+// time: each waits until the previous output is released (after its
+// response is written), and all four succeed.
+func TestDemoBuildOutputTransferSerialises(t *testing.T) {
+ type result struct {
+ out BuildOutput
+ err error
+ }
+ results := make(chan result, 4)
+ for range 4 {
+ ctx, dir := finishedBuild(t, arm64ELFOfSize(1<<20))
+ go func() {
+ out, err := Run(ctx, dir, testLock(t))
+ results <- result{out, err}
+ }()
+ }
+ for n := range 4 {
+ var r result
+ select {
+ case r = <-results:
+ case <-time.After(5 * time.Second):
+ t.Fatalf("build %d never admitted to transfer", n)
+ }
+ if r.err != nil || len(r.out.Binary) != 1<<20 || !ValidDigest(r.out.SHA256) {
+ t.Fatalf("build %d: len=%d err=%v", n, len(r.out.Binary), r.err)
+ }
+ select {
+ case other := <-results:
+ other.out.Release()
+ t.Fatalf("a second output was admitted while build %d held its turn", n)
+ case <-time.After(100 * time.Millisecond):
+ }
+ r.out.Release()
+ r.out.Release() // idempotent
+ }
+ if !transferFree(t) {
+ t.Fatal("turn still held after every release")
+ }
+}
+
+// A refused output and a failed build return the turn themselves.
+func TestDemoBuildOutputTransferReleasedOnFailure(t *testing.T) {
+ ctx, dir := finishedBuild(t, []byte("not an executable"))
+ if _, err := Run(ctx, dir, testLock(t)); err == nil {
+ t.Fatal("accepted invalid output")
+ }
+ if !transferFree(t) {
+ t.Fatal("refused output kept the turn")
+ }
+ ctx, dir = finishedBuild(t, arm64ELFOfSize(BinaryMaxBytes+1))
+ if _, err := Run(ctx, dir, testLock(t)); err == nil {
+ t.Fatal("accepted oversized output")
+ }
+ if !transferFree(t) {
+ t.Fatal("oversized output kept the turn")
+ }
+ // Scratch cleanup failing after a good output discards the output and
+ // must hand its turn back.
+ w, j, key, src := workerFixture(t)
+ w.run = func(ctx context.Context, _ string, _ Lock) (BuildOutput, error) {
+ return AwaitOutputTransfer(ctx)
+ }
+ w.prepare = func(context.Context, string, Source) (func() error, error) {
+ return func() error { return errors.New("cleanup") }, nil
+ }
+ wire, err := SignJob(key, j)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := w.Build(t.Context(), wire, bytes.NewReader(src)); err == nil {
+ t.Fatal("cleanup failure ignored")
+ }
+ if !transferFree(t) {
+ t.Fatal("discarded output kept the turn")
+ }
+}
+
+// The turn waits for the build's own deadline, no longer.
+func TestDemoBuildOutputTransferWaitHonoursDeadline(t *testing.T) {
+ held, err := AwaitOutputTransfer(t.Context())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer held.Release()
+ ctx, dir := finishedBuild(t, arm64ELF())
+ ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
+ defer cancel()
+ if out, err := Run(ctx, dir, testLock(t)); err == nil || len(out.Binary) != 0 {
+ t.Fatal("admitted a second output past its deadline")
+ }
+}
+
+// sparseOutput is a finished build whose out/app is a valid 32 MiB
+// executable written sparse, so the fixture costs no memory of its own.
+func sparseOutput(t *testing.T) (context.Context, string) {
+ t.Helper()
+ ctx, dir := finishedBuild(t, arm64ELF())
+ header := arm64ELF()
+ binary.LittleEndian.PutUint64(header[96:], BinaryMaxBytes)
+ binary.LittleEndian.PutUint64(header[104:], BinaryMaxBytes)
+ f, err := os.Create(filepath.Join(dir, "out/app"))
+ if err == nil {
+ _, err = f.Write(header)
+ }
+ if err == nil {
+ err = f.Truncate(BinaryMaxBytes)
+ }
+ if err == nil {
+ err = f.Close()
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ return ctx, dir
+}
+
+// outputTransferHeapBudget is what output transfers may take the control
+// service's Go heap to at its high water. One transfer holds about 118 MiB
+// live at once: the raw output (32 MiB), its base64 encoding (~43 MiB) and
+// the encoder's copy of it (~43 MiB). At GOGC=100 the collector lets the
+// heap reach twice what was live at its last cycle, and one 43 MiB
+// allocation can overshoot that, so the bound for transfers taken one at a
+// time is about 2 x 118 + 43 = 279 MiB; measured on docs-t1 (amd64,
+// go1.26.10) 181 to 277 MiB. Four admitted together measured 426 to 469
+// MiB. 320 MiB keeps 40 MiB over the bound and fails the second case.
+//
+// It does not fit the base control unit's MemoryMax=256M (#1291), so the
+// build worker's control service keeps its own 1 GiB cap with
+// GOMEMLIMIT=768MiB (claimUnitContent; pinned by TestDemoBuildInstallation):
+// about 700 MiB of room over this budget for the service's baseline.
+const outputTransferHeapBudget = 320 << 20
+
+// F3's heap high-water gate. Four builds finish together, each with a
+// 32 MiB output, under the build worker's GOMEMLIMIT. Each goes through
+// Run's read and validation and the control response's JSON encoding, as
+// handleDemoBuild does, and gives its turn back after. The Go heap's
+// sampled high water above the starting heap stays inside one transfer's
+// budget. The authority for the cap remains the service cgroup's
+// memory.peak on a demo box (plan slice 1.1); this test is what the
+// branch can show without one. Process RSS is logged as a diagnostic.
+func TestDemoBuildOutputTransferHeapHighWater(t *testing.T) {
+ if testing.Short() {
+ t.Skip("reads four 32 MiB outputs")
+ }
+ defer debug.SetMemoryLimit(debug.SetMemoryLimit(768 << 20))
+ type build struct {
+ ctx context.Context
+ dir string
+ }
+ var builds []build
+ for range 4 {
+ ctx, dir := sparseOutput(t)
+ builds = append(builds, build{ctx, dir})
+ }
+ maxRSS := func() int64 {
+ var ru syscall.Rusage
+ _ = syscall.Getrusage(syscall.RUSAGE_SELF, &ru)
+ return ru.Maxrss << 10
+ }
+ runtime.GC()
+ var m runtime.MemStats
+ runtime.ReadMemStats(&m)
+ base := m.HeapAlloc
+ beforeRSS := maxRSS()
+ var peak atomic.Uint64
+ stop := make(chan struct{})
+ sampled := make(chan struct{})
+ go func() {
+ defer close(sampled)
+ var m runtime.MemStats
+ for {
+ runtime.ReadMemStats(&m)
+ if m.HeapAlloc > peak.Load() {
+ peak.Store(m.HeapAlloc)
+ }
+ select {
+ case <-stop:
+ return
+ case <-time.After(time.Millisecond):
+ }
+ }
+ }()
+ errs := make(chan error, len(builds))
+ for _, b := range builds {
+ go func() {
+ out, err := Run(b.ctx, b.dir, testLock(t))
+ defer out.Release()
+ if err == nil && len(out.Binary) != BinaryMaxBytes {
+ err = ErrBuild
+ }
+ if err == nil {
+ err = json.NewEncoder(io.Discard).Encode(out)
+ }
+ errs <- err
+ }()
+ }
+ for range builds {
+ if err := <-errs; err != nil {
+ t.Fatal(err)
+ }
+ }
+ close(stop)
+ <-sampled
+ grew := peak.Load() - min(base, peak.Load())
+ t.Logf("heap high water %d MiB above a %d MiB start (budget %d MiB); maxrss %d -> %d MiB",
+ grew>>20, base>>20, outputTransferHeapBudget>>20, beforeRSS>>20, maxRSS()>>20)
+ if grew > outputTransferHeapBudget {
+ t.Fatalf("four finished builds took the heap %d MiB above its start, past one transfer's %d MiB", grew>>20, outputTransferHeapBudget>>20)
+ }
+}
+
+// shstrndxPanicELF is an AArch64 executable header whose section table
+// makes debug/elf (Go 1.26.10, file.go:596) index past its sections: e_shnum
+// 0 and e_shstrndx SHN_XINDEX send the parser to section 0, whose sh_size
+// (0xff00 sections) and sh_link (string table 0xffff) it accepts without
+// checking one against the other. The table itself is zeros.
+func shstrndxPanicELF() []byte {
+ const shoff, sections = 4096, 0xff00
+ b := arm64ELFOfSize(shoff + sections*64)
+ binary.LittleEndian.PutUint64(b[40:], shoff) // e_shoff
+ binary.LittleEndian.PutUint16(b[58:], 64) // e_shentsize
+ binary.LittleEndian.PutUint16(b[60:], 0) // e_shnum: see section 0
+ binary.LittleEndian.PutUint16(b[62:], 0xffff) // e_shstrndx: SHN_XINDEX
+ binary.LittleEndian.PutUint64(b[shoff+32:], sections)
+ binary.LittleEndian.PutUint32(b[shoff+40:], 0xffff)
+ return b
+}
+
+// panicked runs f and returns what it panicked with, or nil.
+func panicked(f func()) (p any) {
+ defer func() { p = recover() }()
+ f()
+ return nil
+}
+
+// A hostile output that panics debug/elf (a real panic, from the build's
+// own bytes) is a failed build like any other: Run answers ErrBuild and
+// hands the turn back, and nothing unwinds into net/http to write a stack
+// trace per anonymous build into root's log.
+func TestDemoBuildOutputPanickingELFIsErrBuild(t *testing.T) {
+ if panicked(func() { elf.NewFile(bytes.NewReader(shstrndxPanicELF())) }) == nil {
+ t.Fatal("the fixture no longer panics debug/elf; this test needs another panic source")
+ }
+ if _, err := ValidateOutput(bytes.NewReader(shstrndxPanicELF())); !errors.Is(err, ErrBuild) {
+ t.Fatalf("ValidateOutput: err=%v", err)
+ }
+ ctx, dir := finishedBuild(t, shstrndxPanicELF())
+ var err error
+ if p := panicked(func() {
+ var out BuildOutput
+ out, err = Run(ctx, dir, testLock(t))
+ out.Release()
+ }); p != nil {
+ t.Fatalf("validation panicked out of Run: %v", p)
+ }
+ if !errors.Is(err, ErrBuild) {
+ t.Fatalf("Run: err=%v", err)
+ }
+ if !transferFree(t) {
+ t.Fatal("a refused output kept the output turn")
+ }
+}
+
+// A panic in Worker.Build's scratch cleanup, after Run handed it an output
+// holding the turn, must give the turn back, and a later output can take
+// it. The worker is poisoned: its scratch was not proven removed.
+func TestDemoBuildOutputTransferCleanupPanicReleases(t *testing.T) {
+ w, j, key, src := workerFixture(t)
+ bctx, bdir := finishedBuild(t, arm64ELF())
+ i := bctx.Value(runContextKey{}).(*runInvocation)
+ w.run = func(ctx context.Context, _ string, lock Lock) (BuildOutput, error) {
+ return Run(context.WithValue(ctx, runContextKey{}, i), bdir, lock)
+ }
+ w.prepare = func(context.Context, string, Source) (func() error, error) {
+ return func() error { panic("cleanup") }, nil
+ }
+ wire, err := SignJob(key, j)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if p := panicked(func() { w.Build(t.Context(), wire, bytes.NewReader(src)) }); p != "cleanup" {
+ t.Fatalf("panic=%v", p)
+ }
+ if !transferFree(t) {
+ t.Fatal("a cleanup panic kept the output turn")
+ }
+ w.mu.Lock()
+ poisoned := w.poisoned
+ w.mu.Unlock()
+ if !poisoned {
+ t.Fatal("cleanup panicked and the worker was not poisoned")
+ }
+}
diff --git a/internal/demobuild/worker.go b/internal/demobuild/worker.go
index 29c3c4cf2..b0ed86803 100644
--- a/internal/demobuild/worker.go
+++ b/internal/demobuild/worker.go
@@ -270,10 +270,24 @@ func (w *Worker) Build(ctx context.Context, wire []byte, source io.Reader) (out
cleanup, err := w.prepare(ctx, dir, src)
if cleanup != nil {
defer func() {
- if e := cleanup(); e != nil {
+ // out may hold the output turn. A cleanup that panics must not
+ // take it along, and leaves scratch nobody proved removed.
+ cleaned := false
+ defer func() {
+ if !cleaned {
+ w.mu.Lock()
+ w.poisoned = true
+ w.mu.Unlock()
+ out.Release()
+ }
+ }()
+ e := cleanup()
+ cleaned = true
+ if e != nil {
w.mu.Lock()
w.poisoned = true
w.mu.Unlock()
+ out.Release()
out = BuildOutput{}
err = errors.Join(err, e)
}
diff --git a/internal/demobuild/worker_test.go b/internal/demobuild/worker_test.go
index e0cc2ba04..e8a4a73de 100644
--- a/internal/demobuild/worker_test.go
+++ b/internal/demobuild/worker_test.go
@@ -171,6 +171,7 @@ func TestDemoBuildCleanupOrder(t *testing.T) {
return nil
}}
out, err := Run(context.WithValue(context.Background(), runContextKey{}, i), dir, testLock(t))
+ out.Release()
if !stopped || (err == nil) != (failure == "success") {
t.Fatalf("stop=%v err=%v", stopped, err)
}
diff --git a/internal/host/demo_build_linux_test.go b/internal/host/demo_build_linux_test.go
index 25c29850f..788d74857 100644
--- a/internal/host/demo_build_linux_test.go
+++ b/internal/host/demo_build_linux_test.go
@@ -63,11 +63,19 @@ func TestDemoBuildInstallation(t *testing.T) {
for n := 1; n <= 4; n++ {
cfg := claimUnitSettings{demo: demo.Config{Account: "shop", Fleet: "demo", Domain: "example.com", BuildWorker: true, BuildConcurrency: n}}
got := string(claimUnitContent(claimControlUnit, control, cfg))
- for _, want := range []string{"StateDirectory=carlos-demo-builds", "StateDirectoryMode=0700", "ReadWritePaths=/var/lib/carlos-demo-builds", "MemoryMax=1073741824"} {
+ for _, want := range []string{"StateDirectory=carlos-demo-builds", "StateDirectoryMode=0700", "ReadWritePaths=/var/lib/carlos-demo-builds"} {
if !strings.Contains(got, want) {
t.Error(want)
}
}
+ // F3: the build worker's control service holds one 32 MiB output
+ // transfer at a time (demobuild.AwaitOutputTransfer). Its heap high
+ // water is gated at 320 MiB (TestDemoBuildOutputTransferHeapHighWater;
+ // measured 181 to 277 MiB), more than the base unit's 256M (#1291),
+ // so the build worker keeps this cap and collector limit.
+ if strings.Count(got, "\nMemoryMax=") != 1 || !strings.Contains(got, "\nMemoryMax=1073741824\nEnvironment=GOMEMLIMIT=768MiB\n") {
+ t.Errorf("build worker control memory:\n%s", got)
+ }
got = string(claimUnitContent("carlos-demo-builds.slice", slice, cfg))
if !strings.Contains(got, "MemoryMax="+strconv.FormatInt(int64(n)*1073741824, 10)+"\n") {
t.Fatal(got)
diff --git a/internal/instancectl/demo_build.go b/internal/instancectl/demo_build.go
index 18f385aad..eaa014690 100644
--- a/internal/instancectl/demo_build.go
+++ b/internal/instancectl/demo_build.go
@@ -162,9 +162,17 @@ func (s *Server) handleDemoBuild(w http.ResponseWriter, r *http.Request) {
return
}
if grantDeadline.Before(deadline) {
- _ = ctl.SetReadDeadline(grantDeadline)
+ deadline = grantDeadline
+ _ = ctl.SetReadDeadline(deadline)
}
out, err := s.DemoBuilder.Build(ctx, wire, r.Body)
+ // A finished output holds the process's one output turn until its
+ // response is written (demobuild.AwaitOutputTransfer). The write is
+ // bounded so a stalled reader cannot keep the turn past the earlier of
+ // the build window and the signed job's deadline, plus five seconds
+ // (the client gives up five seconds after the window too).
+ defer out.Release()
+ _ = ctl.SetWriteDeadline(deadline.Add(5 * time.Second))
w.Header().Set("Content-Type", "application/json")
if err != nil {
out.Binary = nil
diff --git a/internal/instancectl/demo_build_transfer_test.go b/internal/instancectl/demo_build_transfer_test.go
new file mode 100644
index 000000000..63ab8fdb7
--- /dev/null
+++ b/internal/instancectl/demo_build_transfer_test.go
@@ -0,0 +1,215 @@
+package instancectl
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/binary"
+ "encoding/hex"
+ "io"
+ "net"
+ "net/http/httptest"
+ "path/filepath"
+ "strings"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/demobuild"
+)
+
+// transferBuilder stands in for the worker: each build "finishes" by taking
+// the process's output turn, exactly as demobuild.Run does before it reads
+// the output, and returns an output still holding it.
+type transferBuilder struct {
+ binary []byte
+ turns atomic.Int32
+ // took, when set, hears once from each build that takes the turn.
+ took chan struct{}
+ // grant is how long the signed job has left; zero means a minute.
+ grant time.Duration
+}
+
+func (b *transferBuilder) Initialize(context.Context) error { return nil }
+func (b *transferBuilder) Readiness(context.Context) (demobuild.WorkerReady, error) {
+ return demobuild.WorkerReady{Capability: "anonymous-demo-v1", GOARCH: "arm64", BundleSHA256: strings.Repeat("b", 64), Slots: 4}, nil
+}
+func (b *transferBuilder) GrantDeadline([]byte) (time.Time, error) {
+ if b.grant != 0 {
+ return time.Now().Add(b.grant), nil
+ }
+ return time.Now().Add(time.Minute), nil
+}
+func (b *transferBuilder) Build(ctx context.Context, _ []byte, source io.Reader) (demobuild.BuildOutput, error) {
+ if _, err := io.Copy(io.Discard, source); err != nil {
+ return demobuild.BuildOutput{}, err
+ }
+ out, err := demobuild.AwaitOutputTransfer(ctx)
+ if err != nil {
+ return demobuild.BuildOutput{}, err
+ }
+ b.turns.Add(1)
+ if b.took != nil {
+ b.took <- struct{}{}
+ }
+ sum := sha256.Sum256(b.binary)
+ out.Binary, out.SHA256 = b.binary, hex.EncodeToString(sum[:])
+ return out, nil
+}
+
+func transferELF(n int) []byte {
+ b := make([]byte, n)
+ copy(b, "\x7fELF\x02\x01\x01")
+ binary.LittleEndian.PutUint16(b[16:], 2)
+ binary.LittleEndian.PutUint16(b[18:], 183)
+ binary.LittleEndian.PutUint32(b[20:], 1)
+ binary.LittleEndian.PutUint64(b[24:], 0x400000)
+ binary.LittleEndian.PutUint64(b[32:], 64)
+ binary.LittleEndian.PutUint16(b[52:], 64)
+ binary.LittleEndian.PutUint16(b[54:], 56)
+ binary.LittleEndian.PutUint16(b[56:], 1)
+ binary.LittleEndian.PutUint32(b[64:], 1)
+ binary.LittleEndian.PutUint32(b[68:], 5)
+ binary.LittleEndian.PutUint64(b[80:], 0x400000)
+ binary.LittleEndian.PutUint64(b[96:], uint64(n))
+ binary.LittleEndian.PutUint64(b[104:], uint64(n))
+ return b
+}
+
+// Four builds that finish together each get the output turn in turn: the
+// handler hands it back once the response is written, so all four
+// responses arrive whole. A handler that kept the turn would leave the
+// other three waiting until their deadlines.
+func TestDemoBuildFourFinishedBuildsTakeTurns(t *testing.T) {
+ b := &transferBuilder{binary: transferELF(4 << 20)}
+ s := &Server{DemoBox: true, DemoBuilder: b}
+ srv := httptest.NewServer(s.Handler())
+ defer srv.Close()
+ addr := strings.TrimPrefix(srv.URL, "http://")
+ c := &Client{Path: "control", Dial: func(ctx context.Context, _ string) (net.Conn, error) {
+ return (&net.Dialer{}).DialContext(ctx, "tcp", addr)
+ }}
+ errs := make(chan error, 4)
+ for range 4 {
+ go func() {
+ ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
+ defer cancel()
+ out, err := c.BuildDemo(ctx, []byte("grant"), strings.NewReader("source"))
+ if err == nil && len(out.Binary) != 4<<20 {
+ err = demobuild.ErrBuild
+ }
+ errs <- err
+ }()
+ }
+ for range 4 {
+ if err := <-errs; err != nil {
+ t.Fatal(err)
+ }
+ }
+ if b.turns.Load() != 4 {
+ t.Fatalf("turns=%d", b.turns.Load())
+ }
+ ctx, cancel := context.WithTimeout(t.Context(), time.Second)
+ defer cancel()
+ free, err := demobuild.AwaitOutputTransfer(ctx)
+ if err != nil {
+ t.Fatal("the output turn was not handed back after the last response")
+ }
+ free.Release()
+}
+
+// stalledConn passes writes through and blocks every read until stall
+// closes: a client that sends its build and never reads the answer.
+type stalledConn struct {
+ net.Conn
+ stall chan struct{}
+}
+
+func (c stalledConn) Read([]byte) (int, error) {
+ <-c.stall
+ return 0, net.ErrClosed
+}
+
+// unixControl serves s on a unix socket, as root's control service is
+// served, so the kernel buffers little of a response nobody reads.
+func unixControl(t *testing.T, s *Server) string {
+ t.Helper()
+ sock := filepath.Join(t.TempDir(), "c")
+ l, err := net.Listen("unix", sock)
+ if err != nil {
+ t.Fatal(err)
+ }
+ srv := httptest.NewUnstartedServer(s.Handler())
+ srv.Listener.Close()
+ srv.Listener = l
+ srv.Start()
+ t.Cleanup(srv.Close)
+ return sock
+}
+
+// turnTaken waits until b's build holds the output turn. b.took must be
+// set, with room for the one build.
+func turnTaken(t *testing.T, b *transferBuilder) {
+ t.Helper()
+ select {
+ case <-b.took:
+ case <-time.After(5 * time.Second):
+ t.Fatal("the build never took the output turn")
+ }
+}
+
+// A client that never reads its response holds the turn only until the
+// signed job's own deadline plus five seconds, not the 180 s window: a job
+// with little time left cannot keep every other finished build waiting.
+func TestDemoBuildStalledReaderReturnsTurnByGrantDeadline(t *testing.T) {
+ b := &transferBuilder{binary: transferELF(4 << 20), grant: 300 * time.Millisecond, took: make(chan struct{}, 1)}
+ sock := unixControl(t, &Server{DemoBox: true, DemoBuilder: b})
+ stall := make(chan struct{})
+ done := make(chan struct{})
+ t.Cleanup(func() { close(stall); <-done })
+ c := &Client{Path: sock, Dial: func(ctx context.Context, path string) (net.Conn, error) {
+ conn, err := (&net.Dialer{}).DialContext(ctx, "unix", path)
+ return stalledConn{conn, stall}, err
+ }}
+ go func() {
+ defer close(done)
+ c.BuildDemo(context.Background(), []byte("grant"), strings.NewReader("source"))
+ }()
+ turnTaken(t, b)
+ ctx, cancel := context.WithTimeout(t.Context(), 8*time.Second)
+ defer cancel()
+ free, err := demobuild.AwaitOutputTransfer(ctx)
+ if err != nil {
+ t.Fatal("a stalled reader kept the output turn past its grant deadline plus five seconds")
+ }
+ free.Release()
+}
+
+// A client that hangs up before reading gives the turn back at once.
+func TestDemoBuildDisconnectedReaderReturnsTurn(t *testing.T) {
+ b := &transferBuilder{binary: transferELF(4 << 20), took: make(chan struct{}, 1)}
+ sock := unixControl(t, &Server{DemoBox: true, DemoBuilder: b})
+ stall := make(chan struct{})
+ conns := make(chan net.Conn, 1)
+ done := make(chan struct{})
+ t.Cleanup(func() { close(stall); <-done })
+ c := &Client{Path: sock, Dial: func(ctx context.Context, path string) (net.Conn, error) {
+ conn, err := (&net.Dialer{}).DialContext(ctx, "unix", path)
+ if err == nil {
+ conns <- conn
+ }
+ return stalledConn{conn, stall}, err
+ }}
+ go func() {
+ defer close(done)
+ c.BuildDemo(context.Background(), []byte("grant"), strings.NewReader("source"))
+ }()
+ turnTaken(t, b)
+ (<-conns).Close()
+ ctx, cancel := context.WithTimeout(t.Context(), 2*time.Second)
+ defer cancel()
+ free, err := demobuild.AwaitOutputTransfer(ctx)
+ if err != nil {
+ t.Fatal("the turn was still held after the client hung up")
+ }
+ free.Release()
+}
diff --git a/internal/instancefs/dirs_linux.go b/internal/instancefs/dirs_linux.go
index 6e0334802..47684d0f3 100644
--- a/internal/instancefs/dirs_linux.go
+++ b/internal/instancefs/dirs_linux.go
@@ -3,8 +3,10 @@
package instancefs
import (
+ "crypto/rand"
"errors"
"fmt"
+ "io"
"os"
"path/filepath"
@@ -164,55 +166,492 @@ func RenameBetweenNoReplace(srcDir, srcName, dstDir, dstName string) error {
// tenant sharing the agent's uid can plant links and directories in a run
// directory (run spec §5.2); this is the only way the agent deletes one.
// A missing name is not an error.
+//
+// Neither depth nor width costs descriptors or much memory (F6). The walk
+// holds at most three directory descriptors, dir's included, keeps a stack
+// of names rather than descriptors, and reads entries 256 at a time. At
+// 65,536 levels it moves the directory it would descend into up into name
+// itself and carries on, so any depth is removed with that stack. An
+// interrupted removal leaves a smaller tree that the next call finishes.
func RemoveAllBeneath(dir, name string) error {
if err := bareName(name); err != nil {
return err
}
- dfd, err := openDir(dir)
- if err != nil {
+ r := newTreeRemover(treeRemover{dir: dir, top: name, path: filepath.Join(dir, name)})
+ return r.remove()
+}
+
+// removeAllAt is RemoveAllBeneath for a directory the caller already holds
+// open as parent (path names it, for errors). The walk never reopens
+// parent by path: when it backs up above its anchor it duplicates parent,
+// so every removal stays in the storage the caller opened (PurgeProven).
+func removeAllAt(parent int, name, path string) error {
+ if err := bareName(name); err != nil {
return err
}
- defer unix.Close(dfd)
- return removeAt(dfd, name, filepath.Join(dir, name), 0)
+ r := newTreeRemover(treeRemover{dir: filepath.Dir(path), top: name, path: path, held: parent, holdsDir: true})
+ return r.remove()
+}
+
+// configureRemover, when set, adjusts every walk RemoveAllBeneath and
+// removeAllAt start (a smaller depth bound, hooks). Tests only.
+var configureRemover func(*treeRemover)
+
+func newTreeRemover(r treeRemover) *treeRemover {
+ r.maxDepth = removeMaxDepth
+ if configureRemover != nil {
+ configureRemover(&r)
+ }
+ return &r
+}
+
+const (
+ removeBatch = 256
+ removeMaxDepth = 65536
+ // removeVanishedRetries is how many times in a row the walk looks again
+ // for a directory that went between its listing and the descent.
+ removeVanishedRetries = 64
+ // removeAnchorEvery is how far apart the walk's one kept directory
+ // descriptor (its anchor) sits in a deep tree, so that backing up a
+ // level re-walks at most this many components rather than the whole
+ // depth.
+ removeAnchorEvery = 256
+ // removeHoistTries is how many fresh random names a hoist tries before
+ // it gives up. Each is 128 bits from crypto/rand, so a second try means
+ // a freak collision, not a name anyone planted.
+ removeHoistTries = 4
+)
+
+// treeRemover is one RemoveAllBeneath walk.
+//
+// The directory it works in is named by depth: -1 is dir, 0 is top, and n
+// is the n names of stack below top. It reaches one by walking down from
+// its anchor, one component at a time from the parent's descriptor,
+// closing each parent once the child is open. Nothing joined from the
+// tree's names ever reaches the kernel, so the depth of the tree and the
+// length of its paths do not matter. The anchor is dir's descriptor or a
+// directory on the current stack at a multiple of removeAnchorEvery; to
+// back up above it the walk reopens dir as RemoveAllBeneath first did and
+// checks that top is still the directory it started on. At most three
+// descriptors are open at once: the anchor, the one being walked from and
+// the one being opened.
+type treeRemover struct {
+ dir, top, path string
+ maxDepth int
+ // held is a descriptor for dir the caller keeps open, used only when
+ // holdsDir is set: the walk then duplicates it instead of opening dir
+ // by path.
+ held int
+ holdsDir bool
+ // afterBatch runs after each batch of entries is handled, with the
+ // stack of names below top. Tests only; nil in production.
+ afterBatch func(stack []string) error
+ // beforeOpen runs just before the walk descends into child, and
+ // beforeHoist just before it hoists child. Tests only; nil in
+ // production.
+ beforeOpen func(stack []string, child string)
+ beforeHoist func(stack []string, child string)
+ // hoistName names a hoisted directory; nil means a random name.
+ // Tests only.
+ hoistName func() string
+
+ stack []string
+ anchor int // a descriptor, or -1 for none
+ anchorDepth int
+ topDev uint64
+ topIno uint64
+ live, peak int // directory descriptors open now, and at most
+ hoisted int // directories moved up into top so far
+ buf []byte
+ off, end int
+ names []string
}
-// removeAt removes name under the directory fd parent; path is for errors.
-func removeAt(parent int, name, path string, depth int) error {
- if depth > 64 {
- return fmt.Errorf("instancefs: %s is nested more than 64 deep", path)
+func (r *treeRemover) remove() (err error) {
+ r.anchor = -1
+ defer r.dropAnchor()
+ if err = r.anchorAtDir(); err != nil {
+ return err
}
var st unix.Stat_t
- if err := unix.Fstatat(parent, name, &st, unix.AT_SYMLINK_NOFOLLOW); err != nil {
+ if err := unix.Fstatat(r.anchor, r.top, &st, unix.AT_SYMLINK_NOFOLLOW); err != nil {
if errors.Is(err, unix.ENOENT) {
return nil
}
- return &os.PathError{Op: "fstatat", Path: path, Err: err}
+ return &os.PathError{Op: "fstatat", Path: r.path, Err: err}
}
if st.Mode&unix.S_IFMT != unix.S_IFDIR {
- if err := unix.Unlinkat(parent, name, 0); err != nil && !errors.Is(err, unix.ENOENT) {
- return &os.PathError{Op: "unlinkat", Path: path, Err: err}
+ if err := unix.Unlinkat(r.anchor, r.top, 0); err != nil && !errors.Is(err, unix.ENOENT) {
+ return &os.PathError{Op: "unlinkat", Path: r.path, Err: err}
}
return nil
}
- fd, err := unix.Openat(parent, name, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
+ r.topDev, r.topIno = uint64(st.Dev), uint64(st.Ino)
+ cur, err := r.at(0)
+ if errors.Is(err, unix.ENOENT) {
+ // top went between the stat and the open: nothing of it has been
+ // touched, so this is still "not there".
+ return nil
+ }
if err != nil {
- return &os.PathError{Op: "openat", Path: path, Err: err}
+ return r.walkError(err)
+ }
+ // From here on removal has begun, and every error goes through
+ // changed: none of them may read as "already absent".
+ return r.changed(r.walk(cur))
+}
+
+// walk removes the tree from cur, top's descriptor, down. Its errors are
+// mid-walk errors; remove passes them through changed.
+func (r *treeRemover) walk(cur int) error {
+ vanished := 0
+ for {
+ child, err := r.clear(cur)
+ if err != nil {
+ r.release(cur)
+ return err
+ }
+ if child != "" {
+ if len(r.stack) >= r.maxDepth {
+ if r.beforeHoist != nil {
+ r.beforeHoist(r.stack, child)
+ }
+ err := r.hoist(cur, child)
+ if errors.Is(err, errHoistGone) && vanished < removeVanishedRetries {
+ vanished++ // as for a descent: list cur again
+ continue
+ }
+ if err != nil {
+ r.release(cur)
+ return err
+ }
+ vanished = 0
+ continue
+ }
+ if r.beforeOpen != nil {
+ r.beforeOpen(r.stack, child)
+ }
+ next, err := r.open(cur, child)
+ if errors.Is(err, unix.ENOENT) && vanished < removeVanishedRetries {
+ // It went after the listing: list cur again. It is not
+ // the end of the tree.
+ vanished++
+ continue
+ }
+ r.release(cur)
+ if err != nil {
+ return &os.PathError{Op: "openat2", Path: r.where(child), Err: err}
+ }
+ vanished = 0
+ r.stack = append(r.stack, child)
+ cur = next
+ if d := len(r.stack); d%removeAnchorEvery == 0 {
+ r.setAnchor(cur, d)
+ }
+ continue
+ }
+ // cur is empty: back up a level and remove it from its parent.
+ depth := len(r.stack)
+ if cur == r.anchor {
+ r.dropAnchor()
+ } else {
+ r.release(cur)
+ }
+ name := r.top
+ if depth > 0 {
+ name = r.stack[depth-1]
+ }
+ parent, err := r.at(depth - 1)
+ if err != nil {
+ return r.walkError(err)
+ }
+ if err := unix.Unlinkat(parent, name, unix.AT_REMOVEDIR); err != nil && !errors.Is(err, unix.ENOENT) {
+ r.release(parent)
+ return &os.PathError{Op: "unlinkat", Path: r.where(name), Err: err}
+ }
+ if depth == 0 {
+ r.release(parent)
+ return nil
+ }
+ r.stack = r.stack[:depth-1]
+ cur = parent
+ }
+}
+
+// where names an entry for errors only; it is never opened.
+func (r *treeRemover) where(name string) string {
+ if len(r.stack) == 0 {
+ return filepath.Join(r.path, name)
}
- f := os.NewFile(uintptr(fd), path)
- names, err := f.Readdirnames(-1)
+ return fmt.Sprintf("%s/<%d levels>/%s", r.path, len(r.stack), name)
+}
+
+func (r *treeRemover) walkError(err error) error {
+ var pe *os.PathError
+ if errors.As(err, &pe) || errors.Is(err, ErrSymlink) {
+ return err
+ }
+ return &os.PathError{Op: "openat2", Path: r.where("."), Err: err}
+}
+
+// changed is the one policy for errors once removal has begun: remove
+// passes everything walk returns through it. A directory the walk already
+// stood in (or dir, or top) that is now missing was moved, perhaps out of
+// the tree with what it holds, so "no such file" here is never evidence
+// that the tree is gone: callers map that to success. It keeps the text
+// but drops ENOENT from the chain. Other errors pass unchanged.
+func (r *treeRemover) changed(err error) error {
+ if errors.Is(err, unix.ENOENT) {
+ return fmt.Errorf("instancefs: %s changed during removal: %v", r.path, err)
+ }
+ return err
+}
+
+// errHoistGone is hoist's answer when child went before it could be moved.
+var errHoistGone = errors.New("instancefs: hoisted directory went first")
+
+// hoist moves child, a directory in cur at the depth bound, up into top
+// under a fresh name, so the walk meets it again near the top instead of
+// keeping more names. Both directories are inside the tree being removed;
+// top is reopened from dir as at does, checked to be the directory the walk
+// began on, and renameat2 follows no link and replaces nothing. The name is
+// 128 random bits, so nothing already in top (a tenant's planted names, an
+// interrupted walk's leftovers) can make the move fail every time: each
+// hoist strictly shortens the deepest path and a retry always finds a name.
+// cur stays open. The anchor is dropped unless it is cur, so at most three
+// descriptors are open: cur, dir and top.
+func (r *treeRemover) hoist(cur int, child string) error {
+ if r.anchor != cur {
+ r.dropAnchor()
+ }
+ d, err := r.openDirFD()
if err != nil {
- f.Close()
return err
}
- for _, n := range names {
- if err := removeAt(fd, n, filepath.Join(path, n), depth+1); err != nil {
- f.Close()
- return err
+ top, err := r.open(d, r.top)
+ r.closeDirFD(d)
+ if err == nil {
+ if err = r.sameTop(top); err != nil {
+ r.release(top)
+ }
+ }
+ if err != nil {
+ return r.walkError(err)
+ }
+ defer r.release(top)
+ for range removeHoistTries {
+ name := ".carlos-removing-" + rand.Text()
+ if r.hoistName != nil {
+ name = r.hoistName()
+ }
+ err = unix.Renameat2(cur, child, top, name, unix.RENAME_NOREPLACE)
+ if err == nil {
+ r.hoisted++
+ return nil
+ }
+ if errors.Is(err, unix.ENOENT) {
+ return errHoistGone
+ }
+ if !errors.Is(err, unix.EEXIST) {
+ break
}
}
- f.Close()
- if err := unix.Unlinkat(parent, name, unix.AT_REMOVEDIR); err != nil && !errors.Is(err, unix.ENOENT) {
- return &os.PathError{Op: "unlinkat", Path: path, Err: err}
+ return &os.PathError{Op: "renameat2", Path: r.where(child), Err: err}
+}
+
+// open opens the directory name under parent: exactly one component, never
+// through a symlink and never out of parent.
+func (r *treeRemover) open(parent int, name string) (int, error) {
+ how := unix.OpenHow{
+ Flags: unix.O_RDONLY | unix.O_DIRECTORY | unix.O_NOFOLLOW | unix.O_CLOEXEC,
+ Resolve: unix.RESOLVE_BENEATH | unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS,
+ }
+ var fd int
+ var err error
+ for range 8 {
+ if fd, err = unix.Openat2(parent, name, &how); err != unix.EINTR && err != unix.EAGAIN {
+ break
+ }
+ }
+ if err != nil {
+ return -1, err
+ }
+ r.live++
+ r.peak = max(r.peak, r.live)
+ return fd, nil
+}
+
+// release closes fd unless it is the anchor.
+func (r *treeRemover) release(fd int) {
+ if fd >= 0 && fd != r.anchor {
+ unix.Close(fd)
+ r.live--
+ }
+}
+
+func (r *treeRemover) dropAnchor() {
+ if r.anchor >= 0 {
+ unix.Close(r.anchor)
+ r.live--
+ r.anchor = -1
+ }
+}
+
+func (r *treeRemover) setAnchor(fd, depth int) {
+ r.dropAnchor()
+ r.anchor, r.anchorDepth = fd, depth
+}
+
+// openDirFD opens dir exactly as RemoveAllBeneath's caller named it, or
+// duplicates the caller's held descriptor for it. closeDirFD gives it back.
+func (r *treeRemover) openDirFD() (int, error) {
+ var fd int
+ var err error
+ if r.holdsDir {
+ if fd, err = unix.FcntlInt(uintptr(r.held), unix.F_DUPFD_CLOEXEC, 0); err != nil {
+ return -1, &os.PathError{Op: "dup", Path: r.dir, Err: err}
+ }
+ } else if fd, err = openDir(r.dir); err != nil {
+ return -1, err
+ }
+ r.live++
+ r.peak = max(r.peak, r.live)
+ return fd, nil
+}
+
+func (r *treeRemover) closeDirFD(fd int) {
+ unix.Close(fd)
+ r.live--
+}
+
+// anchorAtDir makes dir the walk's anchor.
+func (r *treeRemover) anchorAtDir() error {
+ r.dropAnchor()
+ fd, err := r.openDirFD()
+ if err != nil {
+ return err
+ }
+ r.anchor, r.anchorDepth = fd, -1
+ return nil
+}
+
+// at returns a descriptor for the directory at depth d, which may be the
+// anchor itself; the caller gives it back with release.
+func (r *treeRemover) at(d int) (int, error) {
+ if r.anchor >= 0 && r.anchorDepth > d {
+ r.dropAnchor()
+ }
+ if r.anchor < 0 {
+ if err := r.anchorAtDir(); err != nil {
+ return -1, err
+ }
+ }
+ keep := d / removeAnchorEvery * removeAnchorEvery
+ fd, depth := r.anchor, r.anchorDepth
+ for depth < d {
+ name := r.top
+ if depth >= 0 {
+ name = r.stack[depth]
+ }
+ next, err := r.open(fd, name)
+ if err == nil && depth == -1 {
+ err = r.sameTop(next)
+ }
+ r.release(fd)
+ if err != nil {
+ if next >= 0 {
+ r.release(next)
+ }
+ return -1, err
+ }
+ fd, depth = next, depth+1
+ if depth > 0 && depth == keep && depth > r.anchorDepth {
+ r.setAnchor(fd, depth)
+ }
+ }
+ return fd, nil
+}
+
+// sameTop refuses a top that is no longer the directory the walk began on.
+func (r *treeRemover) sameTop(fd int) error {
+ var st unix.Stat_t
+ if err := unix.Fstat(fd, &st); err != nil {
+ return err
+ }
+ if uint64(st.Dev) != r.topDev || uint64(st.Ino) != r.topIno {
+ return fmt.Errorf("instancefs: %s was replaced during removal", r.path)
}
return nil
}
+
+// clear removes what it can of the directory fd, reading it from the start
+// in batches: every non-directory, and every directory that is already
+// empty. It returns the first directory that is not, to descend into, or
+// "" once fd is empty.
+func (r *treeRemover) clear(fd int) (string, error) {
+ if _, err := unix.Seek(fd, 0, io.SeekStart); err != nil {
+ return "", &os.PathError{Op: "seek", Path: r.where("."), Err: err}
+ }
+ r.off, r.end = 0, 0
+ for {
+ names, err := r.batch(fd)
+ if err != nil {
+ return "", &os.PathError{Op: "getdents", Path: r.where("."), Err: err}
+ }
+ if len(names) == 0 {
+ return "", nil
+ }
+ for _, name := range names {
+ var st unix.Stat_t
+ if err := unix.Fstatat(fd, name, &st, unix.AT_SYMLINK_NOFOLLOW); err != nil {
+ if errors.Is(err, unix.ENOENT) {
+ continue
+ }
+ return "", &os.PathError{Op: "fstatat", Path: r.where(name), Err: err}
+ }
+ flags := 0
+ if st.Mode&unix.S_IFMT == unix.S_IFDIR {
+ flags = unix.AT_REMOVEDIR
+ }
+ err := unix.Unlinkat(fd, name, flags)
+ if flags != 0 && (errors.Is(err, unix.ENOTEMPTY) || errors.Is(err, unix.EEXIST)) {
+ return name, nil
+ }
+ if err != nil && !errors.Is(err, unix.ENOENT) {
+ return "", &os.PathError{Op: "unlinkat", Path: r.where(name), Err: err}
+ }
+ }
+ if r.afterBatch != nil {
+ if err := r.afterBatch(r.stack); err != nil {
+ return "", err
+ }
+ }
+ }
+}
+
+// batch returns up to removeBatch more names from fd, none at its end.
+func (r *treeRemover) batch(fd int) ([]string, error) {
+ if r.buf == nil {
+ r.buf = make([]byte, 8192)
+ }
+ r.names = r.names[:0]
+ for len(r.names) < removeBatch {
+ if r.off >= r.end {
+ n, err := unix.Getdents(fd, r.buf)
+ for err == unix.EINTR {
+ n, err = unix.Getdents(fd, r.buf)
+ }
+ if err != nil {
+ return nil, err
+ }
+ if n <= 0 {
+ break
+ }
+ r.off, r.end = 0, n
+ }
+ var consumed int
+ consumed, _, r.names = unix.ParseDirent(r.buf[r.off:r.end], removeBatch-len(r.names), r.names)
+ r.off += consumed
+ }
+ return r.names, nil
+}
diff --git a/internal/instancefs/purge_linux.go b/internal/instancefs/purge_linux.go
index d842a69e4..7cbed733d 100644
--- a/internal/instancefs/purge_linux.go
+++ b/internal/instancefs/purge_linux.go
@@ -120,7 +120,7 @@ func PurgeProven(root, rel string, match func(name string) bool) error {
purgeHook("listed")
for _, n := range names {
if match(n) {
- if err := removeAt(dirFD, n, filepath.Join(path, n), 0); err != nil {
+ if err := removeAllAt(dirFD, n, filepath.Join(path, n)); err != nil {
return err
}
}
diff --git a/internal/instancefs/purge_linux_test.go b/internal/instancefs/purge_linux_test.go
index fc5a67d2d..23faa64d4 100644
--- a/internal/instancefs/purge_linux_test.go
+++ b/internal/instancefs/purge_linux_test.go
@@ -235,3 +235,18 @@ func TestPurgeProvenHoldsItsDirectories(t *testing.T) {
}
})
}
+
+// PurgeProven removes a selected tree of any depth (F6), and above the
+// walk's anchor it duplicates the descriptor it holds rather than opening
+// the directory again by path: 1,000 levels make the walk climb past its
+// anchors several times.
+func TestPurgeProvenRemovesDeepTree(t *testing.T) {
+ _, root, inst := purgeRig(t)
+ chain(t, inst, 1000, "d")
+ if err := PurgeProven(root, "instances/abc", func(n string) bool { return n == "top" || seedish(n) }); err != nil {
+ t.Fatal(err)
+ }
+ if got := strings.Join(entries(t, inst), ","); got != "uploads" {
+ t.Fatalf("left %s", got)
+ }
+}
diff --git a/internal/instancefs/removeall_linux_test.go b/internal/instancefs/removeall_linux_test.go
new file mode 100644
index 000000000..55e1e2299
--- /dev/null
+++ b/internal/instancefs/removeall_linux_test.go
@@ -0,0 +1,564 @@
+//go:build linux
+
+package instancefs
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "testing"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+// chain makes depth nested directories named name under dir/top, one
+// component at a time from a parent descriptor, with a file at the bottom.
+// It returns the number of bytes the bottom file's full path would take.
+func chain(t *testing.T, dir string, depth int, name string) int {
+ t.Helper()
+ if err := os.Mkdir(filepath.Join(dir, "top"), 0o700); err != nil {
+ t.Fatal(err)
+ }
+ fd, err := unix.Open(filepath.Join(dir, "top"), unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ length := len(dir) + len("/top")
+ for range depth {
+ if err := unix.Mkdirat(fd, name, 0o700); err != nil {
+ unix.Close(fd)
+ t.Fatal(err)
+ }
+ next, err := unix.Openat(fd, name, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC|unix.O_NOFOLLOW, 0)
+ unix.Close(fd)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fd = next
+ length += 1 + len(name)
+ }
+ defer unix.Close(fd)
+ file, err := unix.Openat(fd, "leaf", unix.O_CREAT|unix.O_WRONLY|unix.O_CLOEXEC, 0o600)
+ if err != nil {
+ t.Fatal(err)
+ }
+ unix.Close(file)
+ return length + len("/leaf")
+}
+
+// lowNofile caps this process's open descriptors at n for the rest of the
+// test, restoring the old limit before the temporary directory's cleanup.
+func lowNofile(t *testing.T, n uint64) {
+ t.Helper()
+ var old unix.Rlimit
+ if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &old); err != nil {
+ t.Fatal(err)
+ }
+ if err := unix.Setrlimit(unix.RLIMIT_NOFILE, &unix.Rlimit{Cur: n, Max: old.Max}); err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { _ = unix.Setrlimit(unix.RLIMIT_NOFILE, &old) })
+}
+
+func gone(t *testing.T, path string) {
+ t.Helper()
+ if _, err := os.Lstat(path); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("%s still there: %v", path, err)
+ }
+}
+
+// F6: a tree 10,000 directories deep purges with only 16 descriptors
+// allowed to the whole process.
+func TestRemoveAllBeneathTenThousandDeepLowNofile(t *testing.T) {
+ if testing.Short() {
+ t.Skip("walks a 10,000-deep tree")
+ }
+ dir := t.TempDir()
+ chain(t, dir, 10000, "d")
+ lowNofile(t, 16)
+ start := time.Now()
+ if err := RemoveAllBeneath(dir, "top"); err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("10,000 deep: %s", time.Since(start))
+ gone(t, filepath.Join(dir, "top"))
+}
+
+// F6: a tree whose deepest path is longer than 64 KiB (well past PATH_MAX)
+// purges: no joined path ever reaches the kernel.
+func TestRemoveAllBeneathPathOver64KiBLowNofile(t *testing.T) {
+ dir := t.TempDir()
+ name := strings.Repeat("n", 255)
+ if n := chain(t, dir, 260, name); n <= 64<<10 {
+ t.Fatalf("fixture path is only %d bytes", n)
+ }
+ lowNofile(t, 16)
+ if err := RemoveAllBeneath(dir, "top"); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, filepath.Join(dir, "top"))
+}
+
+// F6: a directory of 100,000 entries purges in batches: the names are
+// never all in memory at once.
+func TestRemoveAllBeneathHundredThousandEntriesBoundedMemory(t *testing.T) {
+ if testing.Short() {
+ t.Skip("creates 100,000 files")
+ }
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ if err := os.Mkdir(top, 0o700); err != nil {
+ t.Fatal(err)
+ }
+ fd, err := unix.Open(top, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // 100,000 names of 120 bytes: about 13 MiB as Go strings if read whole.
+ pad := strings.Repeat("x", 113)
+ for i := range 100000 {
+ f, err := unix.Openat(fd, fmt.Sprintf("%06d-%s", i, pad), unix.O_CREAT|unix.O_WRONLY|unix.O_CLOEXEC, 0o600)
+ if err != nil {
+ unix.Close(fd)
+ t.Fatal(err)
+ }
+ unix.Close(f)
+ }
+ unix.Close(fd)
+ runtime.GC()
+ var base runtime.MemStats
+ runtime.ReadMemStats(&base)
+ peak := base.HeapAlloc
+ stop := make(chan struct{})
+ sampled := make(chan struct{})
+ go func() {
+ defer close(sampled)
+ var m runtime.MemStats
+ for {
+ runtime.ReadMemStats(&m)
+ peak = max(peak, m.HeapAlloc)
+ select {
+ case <-stop:
+ return
+ case <-time.After(time.Millisecond):
+ }
+ }
+ }()
+ err = RemoveAllBeneath(dir, "top")
+ close(stop)
+ <-sampled
+ if err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+ t.Logf("heap growth during purge: %d KiB", (peak-base.HeapAlloc)>>10)
+ if grew := peak - base.HeapAlloc; grew > 6<<20 {
+ t.Fatalf("heap grew %d KiB while purging", grew>>10)
+ }
+}
+
+func files(t *testing.T, dir string, n int) {
+ t.Helper()
+ if err := os.MkdirAll(dir, 0o700); err != nil {
+ t.Fatal(err)
+ }
+ for i := range n {
+ if err := os.WriteFile(filepath.Join(dir, fmt.Sprintf("f%04d", i)), nil, 0o600); err != nil {
+ t.Fatal(err)
+ }
+ }
+}
+
+// The walk never holds more than three directory descriptors, dir's
+// included, even across its anchors in a deep tree with side branches, and
+// gives every one back.
+func TestRemoveAllBeneathHoldsAtMostThreeDescriptors(t *testing.T) {
+ dir := t.TempDir()
+ chain(t, dir, 700, "d")
+ p := filepath.Join(dir, "top")
+ for depth := range 700 {
+ p = filepath.Join(p, "d")
+ if depth%97 == 0 {
+ files(t, filepath.Join(p, "side", "deeper"), 300)
+ }
+ }
+ lowNofile(t, 16)
+ r := treeRemover{dir: dir, top: "top", path: filepath.Join(dir, "top"), maxDepth: removeMaxDepth}
+ if err := r.remove(); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, filepath.Join(dir, "top"))
+ if r.peak > 3 || r.live != 0 {
+ t.Fatalf("peak=%d live=%d directory descriptors", r.peak, r.live)
+ }
+}
+
+// A directory swapped for a symlink between batches is not followed: the
+// walk refuses the link, and the next removal unlinks it and finishes.
+func TestRemoveAllBeneathSwappedDirectoryNotFollowed(t *testing.T) {
+ dir := t.TempDir()
+ outside := t.TempDir()
+ files(t, filepath.Join(outside, "sub"), 1)
+ files(t, outside, 1)
+ top := filepath.Join(dir, "top")
+ files(t, filepath.Join(top, "D"), 600)
+ files(t, filepath.Join(top, "D", "sub"), 1)
+ swapped := false
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: removeMaxDepth, afterBatch: func(stack []string) error {
+ if !swapped && len(stack) > 0 && stack[0] == "D" {
+ swapped = true
+ if err := os.Rename(filepath.Join(top, "D"), filepath.Join(top, "D2")); err != nil {
+ return err
+ }
+ return os.Symlink(outside, filepath.Join(top, "D"))
+ }
+ return nil
+ }}
+ err := r.remove()
+ if !swapped {
+ t.Fatal("never swapped")
+ }
+ if !errors.Is(err, unix.ELOOP) && !errors.Is(err, unix.ENOTDIR) {
+ t.Fatalf("walked through the swapped-in symlink: %v", err)
+ }
+ t.Logf("refused: %v", err)
+ for _, f := range []string{"f0000", "sub/f0000"} {
+ if _, e := os.Stat(filepath.Join(outside, f)); e != nil {
+ t.Fatalf("followed the symlink: %s: %v (removal said %v)", f, e, err)
+ }
+ }
+ if err := RemoveAllBeneath(dir, "top"); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+ for _, f := range []string{"f0000", "sub/f0000"} {
+ if _, e := os.Stat(filepath.Join(outside, f)); e != nil {
+ t.Fatalf("retry followed the symlink: %s: %v", f, e)
+ }
+ }
+}
+
+// An error mid-walk leaves a smaller tree; the next removal finishes it.
+func TestRemoveAllBeneathInterruptedResumes(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ files(t, top, 300)
+ files(t, filepath.Join(top, "a"), 300)
+ files(t, filepath.Join(top, "b", "c"), 300)
+ injected := errors.New("injected")
+ batches := 0
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: removeMaxDepth, afterBatch: func([]string) error {
+ if batches++; batches == 3 {
+ return injected
+ }
+ return nil
+ }}
+ if err := r.remove(); !errors.Is(err, injected) {
+ t.Fatalf("err=%v", err)
+ }
+ if r.live != 0 {
+ t.Fatalf("%d directory descriptors left open", r.live)
+ }
+ if _, err := os.Lstat(top); err != nil {
+ t.Fatal("interrupted removal already finished")
+ }
+ if err := RemoveAllBeneath(dir, "top"); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+}
+
+// Past the depth bound the walk does not refuse: it moves the directory it
+// would have descended into up into top and carries on, so any depth
+// purges with the same bounded stack and descriptors. The bound sits at an
+// anchor (512) and between anchors (300), and below the first (8).
+func TestRemoveAllBeneathPastDepthBoundHoists(t *testing.T) {
+ for _, c := range []struct{ bound, depth int }{{8, 40}, {300, 1500}, {512, 1500}} {
+ t.Run(fmt.Sprintf("bound=%d", c.bound), func(t *testing.T) {
+ dir := t.TempDir()
+ chain(t, dir, c.depth, "d")
+ files(t, filepath.Join(dir, "top", "d"), 300)
+ lowNofile(t, 16)
+ r := treeRemover{dir: dir, top: "top", path: filepath.Join(dir, "top"), maxDepth: c.bound}
+ if err := r.remove(); err != nil {
+ t.Fatal(err)
+ }
+ if r.live != 0 || r.peak > 3 {
+ t.Fatalf("live=%d peak=%d directory descriptors", r.live, r.peak)
+ }
+ gone(t, filepath.Join(dir, "top"))
+ })
+ }
+}
+
+// A directory on the walk's stack renamed out of the tree mid-walk leaves
+// its contents behind under the new name. The walk cannot reach it again,
+// and its error must not read as "no such file": callers take that for a
+// tree already gone and report the purge done.
+func TestRemoveAllBeneathAncestorMovedIsNotGone(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ files(t, filepath.Join(top, "a", "b", "c"), 300)
+ moved := false
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: removeMaxDepth, afterBatch: func(stack []string) error {
+ if len(stack) == 3 && !moved {
+ moved = true
+ if err := os.Rename(filepath.Join(top, "a"), filepath.Join(dir, "aside")); err != nil {
+ t.Fatal(err)
+ }
+ }
+ return nil
+ }}
+ err := r.remove()
+ if !moved {
+ t.Fatal("the walk never reached c")
+ }
+ if err == nil || errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("err=%v: a tree moved mid-walk reads as removed", err)
+ }
+ if r.live != 0 {
+ t.Fatalf("%d directory descriptors left open", r.live)
+ }
+ // c was emptied through its descriptor but never removed: the walk
+ // could not reach its parent again.
+ if _, err := os.Lstat(filepath.Join(dir, "aside", "b", "c")); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// A directory that goes between the listing and the walk's descent into
+// it is looked for again, not taken for the end of the tree: the rest of
+// top is still removed.
+func TestRemoveAllBeneathChildVanishedBeforeDescent(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ files(t, top, 300)
+ files(t, filepath.Join(top, "x"), 3)
+ files(t, filepath.Join(top, "y"), 3)
+ var vanished string
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: removeMaxDepth, beforeOpen: func(stack []string, child string) {
+ if vanished == "" && len(stack) == 0 {
+ vanished = child
+ if err := os.Rename(filepath.Join(top, child), filepath.Join(dir, "aside")); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }}
+ if err := r.remove(); err != nil {
+ t.Fatalf("err=%v", err)
+ }
+ if vanished == "" {
+ t.Fatal("the walk never descended")
+ }
+ if r.live != 0 {
+ t.Fatalf("%d directory descriptors left open", r.live)
+ }
+ gone(t, top)
+}
+
+// hoistDepth is the reduced depth bound the hoist tests use; deep is a
+// chain comfortably past it.
+const hoistDepth, deep = 4, "a/b/c/d/e/f/g/h/i/j"
+
+// Names already in top cannot stall a hoist. Here the 64 names the walk
+// once used in turn (.carlos-removing-0 to -63) are planted, each holding a
+// chain past the bound, beside one more chain: whichever the listing meets
+// first, its hoist needs a name, and every retry of a predictable sequence
+// would meet the same planted ones.
+func TestRemoveAllBeneathHoistPastPlantedNames(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ for i := range 64 {
+ files(t, filepath.Join(top, fmt.Sprintf(".carlos-removing-%d", i), deep), 1)
+ }
+ files(t, filepath.Join(top, "d", deep), 1)
+ lowNofile(t, 16)
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: hoistDepth}
+ if err := r.remove(); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+ if r.hoisted == 0 || r.live != 0 || r.peak > 3 {
+ t.Fatalf("hoisted=%d live=%d peak=%d", r.hoisted, r.live, r.peak)
+ }
+}
+
+// A hoist whose name is taken by the time it renames tries a fresh one;
+// RENAME_NOREPLACE still replaces nothing. If every try collides the walk
+// stops with an error that is not "no such file", having moved nothing
+// over anything, and the next removal finishes.
+func TestRemoveAllBeneathHoistCollisionRetries(t *testing.T) {
+ collide := func(top string, n *int) func() string {
+ return func() string {
+ *n++
+ name := fmt.Sprintf("taken-%d", *n)
+ files(t, filepath.Join(top, name), 1)
+ return name
+ }
+ }
+ t.Run("once", func(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ files(t, filepath.Join(top, "d", deep), 1)
+ calls := 0
+ taken := collide(top, &calls)
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: hoistDepth, hoistName: func() string {
+ if calls == 0 {
+ return taken()
+ }
+ calls++
+ return fmt.Sprintf("fresh-%d", calls)
+ }}
+ if err := r.remove(); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+ if r.hoisted == 0 || calls != r.hoisted+1 {
+ t.Fatalf("hoisted=%d names=%d: the collision was not retried", r.hoisted, calls)
+ }
+ })
+ t.Run("always", func(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ files(t, filepath.Join(top, "d", deep), 1)
+ calls := 0
+ r := treeRemover{dir: dir, top: "top", path: top, maxDepth: hoistDepth, hoistName: collide(top, &calls)}
+ err := r.remove()
+ if !errors.Is(err, unix.EEXIST) || errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("err=%v", err)
+ }
+ if calls != removeHoistTries || r.live != 0 {
+ t.Fatalf("names=%d live=%d", calls, r.live)
+ }
+ if _, err := os.Lstat(filepath.Join(top, "d", deep, "f0000")); err != nil {
+ t.Fatal(err)
+ }
+ r = treeRemover{dir: dir, top: "top", path: top, maxDepth: hoistDepth}
+ if err := r.remove(); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+ })
+}
+
+// A walk stopped just after a hoist leaves the hoisted directory in top
+// under its random name; the next walk removes it like any other entry.
+func TestRemoveAllBeneathResumesAfterInterruptedHoist(t *testing.T) {
+ dir := t.TempDir()
+ top := filepath.Join(dir, "top")
+ chain(t, dir, 30, "d")
+ injected := errors.New("injected")
+ r := &treeRemover{dir: dir, top: "top", path: top, maxDepth: hoistDepth}
+ r.afterBatch = func([]string) error {
+ if r.hoisted > 0 {
+ return injected
+ }
+ return nil
+ }
+ if err := r.remove(); !errors.Is(err, injected) {
+ t.Fatalf("err=%v", err)
+ }
+ left := 0
+ for _, n := range entries(t, top) {
+ if strings.HasPrefix(n, ".carlos-removing-") {
+ left++
+ }
+ }
+ if left == 0 || r.live != 0 {
+ t.Fatalf("hoisted names left=%d live=%d", left, r.live)
+ }
+ r = &treeRemover{dir: dir, top: "top", path: top, maxDepth: hoistDepth}
+ if err := r.remove(); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, top)
+}
+
+// dir itself going at the moment of a hoist (the walk must reopen it to
+// reach top) is a tree moved mid-walk, not a tree already gone.
+func TestRemoveAllBeneathParentGoneAtHoistIsNotGone(t *testing.T) {
+ base := t.TempDir()
+ dir := filepath.Join(base, "p")
+ if err := os.Mkdir(dir, 0o700); err != nil {
+ t.Fatal(err)
+ }
+ chain(t, dir, 30, "d")
+ moved := false
+ r := treeRemover{dir: dir, top: "top", path: filepath.Join(dir, "top"), maxDepth: hoistDepth, beforeHoist: func([]string, string) {
+ if !moved {
+ moved = true
+ if err := os.Rename(dir, filepath.Join(base, "q")); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }}
+ err := r.remove()
+ if !moved {
+ t.Fatal("the walk never hoisted")
+ }
+ if err == nil || errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("err=%v: a parent gone at the hoist reads as removed", err)
+ }
+ if r.live != 0 {
+ t.Fatalf("%d directory descriptors left open", r.live)
+ }
+ if _, err := os.Lstat(filepath.Join(base, "q", "top", "d")); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// hoistBound makes every RemoveAllBeneath and removeAllAt walk in this
+// test use the hoist tests' depth bound, and returns them.
+func hoistBound(t *testing.T) *[]*treeRemover {
+ t.Helper()
+ var walks []*treeRemover
+ configureRemover = func(r *treeRemover) {
+ r.maxDepth = hoistDepth
+ walks = append(walks, r)
+ }
+ t.Cleanup(func() { configureRemover = nil })
+ return &walks
+}
+
+// The production entry points hoist too: RemoveAllBeneath by path, and
+// removeAllAt from the descriptor PurgeProven holds.
+func TestRemoveAllBeneathEntryPointsHoist(t *testing.T) {
+ t.Run("RemoveAllBeneath", func(t *testing.T) {
+ walks := hoistBound(t)
+ dir := t.TempDir()
+ chain(t, dir, 30, "d")
+ if err := RemoveAllBeneath(dir, "top"); err != nil {
+ t.Fatal(err)
+ }
+ gone(t, filepath.Join(dir, "top"))
+ if len(*walks) != 1 || (*walks)[0].hoisted == 0 {
+ t.Fatal("the walk never hoisted")
+ }
+ })
+ t.Run("PurgeProven", func(t *testing.T) {
+ walks := hoistBound(t)
+ _, root, inst := purgeRig(t)
+ chain(t, inst, 30, "d")
+ files(t, filepath.Join(inst, "top", ".carlos-removing-0", deep), 1)
+ if err := PurgeProven(root, "instances/abc", func(n string) bool { return n == "top" || seedish(n) }); err != nil {
+ t.Fatal(err)
+ }
+ if got := strings.Join(entries(t, inst), ","); got != "uploads" {
+ t.Fatalf("left %s", got)
+ }
+ hoisted := 0
+ for _, w := range *walks {
+ if !w.holdsDir {
+ t.Fatal("PurgeProven walked by path")
+ }
+ hoisted += w.hoisted
+ }
+ if hoisted == 0 {
+ t.Fatal("no walk hoisted")
+ }
+ })
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index c15fd7ce8..81ab925c6 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -302,3 +302,4 @@ plan14-root-reads-replica-read-lock-1443.tsv 4d4fdb77961d811bcfeae751b17089f0104
plan14-root-reads-litestream-pin-1443.tsv 022a082b517b59ada965bbd7673e941be7c8bb4ae7547a5632f6be0570c97551
plan14-root-reads-fleet-first-reconcile-speed-5.tsv dbdeb2e3a1a89cb8f33584fdb80a3bf1c5adef14ce222fef9d442ed8e059699c
plan14-root-reads-cli-contact-prompts.tsv dbdeb2e3a1a89cb8f33584fdb80a3bf1c5adef14ce222fef9d442ed8e059699c
+plan14-root-reads-gvisor-slice1-control-purge.tsv a3f8ba38714f1cdeea10b3e5ed4402d290e88cc1cc1f3f3875f446aa46346e82
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-slice1-control-purge.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-slice1-control-purge.tsv
new file mode 100644
index 000000000..0abfe5e17
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-gvisor-slice1-control-purge.tsv
@@ -0,0 +1,26 @@
+# Census overlay gvisor-slice1-control-purge, written by census-propose (#369). census-ruling-gvisor-slice1-control-purge, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-gvisor-slice1-control-purge.md.
+# 3 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 removed: each unit's declaration, or each envelope's directory, is absent from the scanned tree, so its row goes, a frozen declaration is retired as absent, and an envelope is retired.
+# 5 new dispositions: 0 reads re-frozen at their disposition with the claim, 5 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 53ad57ce6e525e9cd9ae366bd5a559273cac9c5a3dee01da00b27daf260789a5 internal/demobuild/runner.go Run legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Consumes only its private root-prepared invocation, proves stop, then no-follow reads bounded diagnostics/output beneath that job.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain bounded no-follow diagnostics/output reads after termination proof; filter gVisor runtime timestamp lines before returning compiler diagnostics. No new read. Task 9: Log failing steps through root logger before returning exactly ErrBuild. Existing bounded no-follow reads and termination-before-output retained.;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3: after the stop proof and before opening out/app, waits (within the build ctx) for the process-wide one-at-a-time output turn; every failure releases it, success hands it to the caller in BuildOutput. Same no-follow OpenBeneath of out/app; validation moves to readOutput. No new read path or input. F3 fix round 1: the output turn's release is deferred right after it is taken and disarmed only when a validated output hands it to the caller, so a panic in validation (debug/elf over the build's bytes) gives it back too. Same no-follow OpenBeneath of out/app and the same bounded read; no new read path or input. file:ReadAll@584 3d24a0d2e321031f74789cd89ff37010c32ed982b79bf44f3f61465da22e3f17
+@legacy 118ab165a823021e49a60c97782345e57fb1770dae257ac1b7a8c101dc09955d internal/demobuild/runner.go ValidateOutput legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads bounded bytes, ELF header/program headers and computes their SHA-256; never executes output.;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3: body split; ELF/segment/digest checks moved verbatim into validateBinary, which ValidateOutput (client side) and readOutput (root) both call. Same bounded ReadAll; checks unchanged. F3 fix round 2: validateBinary recovers a debug/elf panic on the bytes it parses and answers ErrBuild; same bounded read and checks. file:ReadAll@67 a62ad64a8972e972cf152acca76fe58b0600f9bae50bcd7a988f71672c585cee
+@legacy 380d4df05c08e27ae315aadb157a13f1669ba3af7d9c0809f06eff14a27c62b3 internal/demobuild/worker.go Worker.Build legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Holds the build/purge read lock through cleanup; existing bounded source read remains.;rev3=census-ruling-demo-slice-adopt;basis=Before admission, call the admit hook (nil = reconcileBudget); a pending budget change (errBudgetPending) is retried every 2 s until the job deadline, any other error fails at once. reconcileBudget reads the fixed build slice's systemctl show budget, its cgroup limit files and cgroup.events under the fixed root cgroup path, and list-jobs (a listing at the capture limit defers); only with buildPurge held exclusively, the slice empty and no build or slice job queued does it run systemctl stop on the fixed slice name. No tenant, app or agent input names a path or unit.;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3: when scratch cleanup fails and the output is discarded, releases its output turn first. No read change. F3 fix round 1: the scratch-cleanup defer releases the output turn and poisons the worker if cleanup panics, as it already did when cleanup failed. No read change. file:ReadAll@1087 4687911be61feb14e60cbb801651a3982593de07c2c5430f5676b1174169b179
+@legacy 95eb701b556f8512cdf18075320faab42bfda098a9fe694b02b3449a4aaacc82 internal/demobuild/runner.go readOutput legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3, new: root reads the already-open out/app (from Run's no-follow OpenBeneath) by fstat size into one exact buffer; refuses non-regular or over BinaryMaxBytes, refuses a file still growing past its size, then validateBinary on exactly those bytes. Reads only the fd it is given. file:Read@304,file:Stat@63 9c0196894754b9a9d323ab7622e86ee28c5c4e71c86f5e5610289edfe27103d4
+@legacy 3a12b768f3f978410bfd23a4387d5ebb7721b480485b401dc8f4ddfc47118520 internal/instancefs/dirs_linux.go treeRemover.clear legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new: getdents in batches of 256 on an open dir fd; per entry fstatat AT_SYMLINK_NOFOLLOW then unlinkat (AT_REMOVEDIR for dirs); a non-empty dir is returned to descend into. Never follows an entry. file:Fstatat@448 5c78478ebb13128d4cae7913afa86bd2473385e7ae868eca10e0b4988bea263d
+@legacy 149232ea92f91ea58f48f16d8c3406c80f10bf3ed4f431d55446f27074815f86 internal/instancefs/dirs_linux.go treeRemover.open legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new: openat2(parentfd, one name, O_RDONLY|O_DIRECTORY|O_NOFOLLOW, RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS|RESOLVE_NO_MAGICLINKS); never a joined path; retries EINTR/EAGAIN. file:Openat2@318 907a0219945d5fec7dd63ad909a3b8121375e3afec270b38b1d7adbf24ec224f
+@legacy 991a8e9975e69e9725bf9277b95a53bf04dcdef4bfcc3b1a0dd3809c4b0e78be internal/instancefs/dirs_linux.go treeRemover.remove legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new (replaces removeAt): iterative no-follow removal of a derived child of a root-named dir. fstatat AT_SYMLINK_NOFOLLOW on top; non-dir unlinked; dirs walked by a name stack, each level opened by treeRemover.open from its parent fd; empty dirs removed with unlinkat AT_REMOVEDIR on the parent fd. Re-opens dir only through openDir (RESOLVE_NO_SYMLINKS), as RemoveAllBeneath did, and checks top dev/ino unchanged. F6 fix round 1: at the 65,536-level bound, instead of refusing, hoists the child into top (treeRemover.hoist: reopens dir via openDir or a dup of the caller's held fd, opens top with the same openat2 BENEATH|NO_SYMLINKS|NO_MAGICLINKS and dev/ino check, then renameat2(cur, child, top, .carlos-removing-N, RENAME_NOREPLACE); follows nothing, both ends inside the tree). A child gone before descent re-lists cur (max 64); a missing stack directory on re-walk is an error that is not ErrNotExist. Merge with main: PurgeProven (#1139) now calls removeAllAt instead of removeAt; there dir is PurgeProven's held descriptor, duplicated (F_DUPFD_CLOEXEC) where RemoveAllBeneath would reopen dir by path. Removal-only, no new read. F6 fix round 2: the walk loop moves into treeRemover.walk unchanged in what it opens and removes; remove passes every error walk returns through changed, so once removal has begun no ENOENT (hoist reopening dir included) reads as already absent. Hoist names are .carlos-removing-<128 random bits from crypto/rand> instead of a counter, still renameat2 RENAME_NOREPLACE into the dev/ino-checked top, retried only on a collision (4 tries); a child gone at the hoist re-lists cur within the same 64-try budget as a descent. Same reads; no new read. file:Fstatat@169 5f76afcb90f4c414e993dec067ebd730ab0ff263328a38171cdee6a4da12061e
+@legacy 2575069725632e38b00793d60ee00431588b8d5d4a68f7512280e85ed6395c9f internal/instancefs/dirs_linux.go treeRemover.sameTop legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new: fstat of the re-opened top fd; refuses if dev/ino differ from the top the walk began on. file:Fstat@77 ed275affbeee89c9122580e4df3823be61cd02951040897e9f4e63ee2e624e89
+internal/demobuild/runner.go Run legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Consumes only its private root-prepared invocation, proves stop, then no-follow reads bounded diagnostics/output beneath that job.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain bounded no-follow diagnostics/output reads after termination proof; filter gVisor runtime timestamp lines before returning compiler diagnostics. No new read. Task 9: Log failing steps through root logger before returning exactly ErrBuild. Existing bounded no-follow reads and termination-before-output retained.;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3: after the stop proof and before opening out/app, waits (within the build ctx) for the process-wide one-at-a-time output turn; every failure releases it, success hands it to the caller in BuildOutput. Same no-follow OpenBeneath of out/app; validation moves to readOutput. No new read path or input. F3 fix round 1: the output turn's release is deferred right after it is taken and disarmed only when a validated output hands it to the caller, so a panic in validation (debug/elf over the build's bytes) gives it back too. Same no-follow OpenBeneath of out/app and the same bounded read; no new read path or input. file:ReadAll@584 3d24a0d2e321031f74789cd89ff37010c32ed982b79bf44f3f61465da22e3f17
+internal/demobuild/runner.go ValidateOutput legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads bounded bytes, ELF header/program headers and computes their SHA-256; never executes output.;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3: body split; ELF/segment/digest checks moved verbatim into validateBinary, which ValidateOutput (client side) and readOutput (root) both call. Same bounded ReadAll; checks unchanged. F3 fix round 2: validateBinary recovers a debug/elf panic on the bytes it parses and answers ErrBuild; same bounded read and checks. file:ReadAll@67 a62ad64a8972e972cf152acca76fe58b0600f9bae50bcd7a988f71672c585cee
+internal/demobuild/worker.go Worker.Build legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Holds the build/purge read lock through cleanup; existing bounded source read remains.;rev3=census-ruling-demo-slice-adopt;basis=Before admission, call the admit hook (nil = reconcileBudget); a pending budget change (errBudgetPending) is retried every 2 s until the job deadline, any other error fails at once. reconcileBudget reads the fixed build slice's systemctl show budget, its cgroup limit files and cgroup.events under the fixed root cgroup path, and list-jobs (a listing at the capture limit defers); only with buildPurge held exclusively, the slice empty and no build or slice job queued does it run systemctl stop on the fixed slice name. No tenant, app or agent input names a path or unit.;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3: when scratch cleanup fails and the output is discarded, releases its output turn first. No read change. F3 fix round 1: the scratch-cleanup defer releases the output turn and poisons the worker if cleanup panics, as it already did when cleanup failed. No read change. file:ReadAll@1087 4687911be61feb14e60cbb801651a3982593de07c2c5430f5676b1174169b179
+internal/demobuild/runner.go readOutput legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F3, new: root reads the already-open out/app (from Run's no-follow OpenBeneath) by fstat size into one exact buffer; refuses non-regular or over BinaryMaxBytes, refuses a file still growing past its size, then validateBinary on exactly those bytes. Reads only the fd it is given. file:Read@304,file:Stat@63 9c0196894754b9a9d323ab7622e86ee28c5c4e71c86f5e5610289edfe27103d4
+internal/instancefs/dirs_linux.go treeRemover.clear legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new: getdents in batches of 256 on an open dir fd; per entry fstatat AT_SYMLINK_NOFOLLOW then unlinkat (AT_REMOVEDIR for dirs); a non-empty dir is returned to descend into. Never follows an entry. file:Fstatat@448 5c78478ebb13128d4cae7913afa86bd2473385e7ae868eca10e0b4988bea263d
+internal/instancefs/dirs_linux.go treeRemover.open legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new: openat2(parentfd, one name, O_RDONLY|O_DIRECTORY|O_NOFOLLOW, RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS|RESOLVE_NO_MAGICLINKS); never a joined path; retries EINTR/EAGAIN. file:Openat2@318 907a0219945d5fec7dd63ad909a3b8121375e3afec270b38b1d7adbf24ec224f
+internal/instancefs/dirs_linux.go treeRemover.remove legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new (replaces removeAt): iterative no-follow removal of a derived child of a root-named dir. fstatat AT_SYMLINK_NOFOLLOW on top; non-dir unlinked; dirs walked by a name stack, each level opened by treeRemover.open from its parent fd; empty dirs removed with unlinkat AT_REMOVEDIR on the parent fd. Re-opens dir only through openDir (RESOLVE_NO_SYMLINKS), as RemoveAllBeneath did, and checks top dev/ino unchanged. F6 fix round 1: at the 65,536-level bound, instead of refusing, hoists the child into top (treeRemover.hoist: reopens dir via openDir or a dup of the caller's held fd, opens top with the same openat2 BENEATH|NO_SYMLINKS|NO_MAGICLINKS and dev/ino check, then renameat2(cur, child, top, .carlos-removing-N, RENAME_NOREPLACE); follows nothing, both ends inside the tree). A child gone before descent re-lists cur (max 64); a missing stack directory on re-walk is an error that is not ErrNotExist. Merge with main: PurgeProven (#1139) now calls removeAllAt instead of removeAt; there dir is PurgeProven's held descriptor, duplicated (F_DUPFD_CLOEXEC) where RemoveAllBeneath would reopen dir by path. Removal-only, no new read. F6 fix round 2: the walk loop moves into treeRemover.walk unchanged in what it opens and removes; remove passes every error walk returns through changed, so once removal has begun no ENOENT (hoist reopening dir included) reads as already absent. Hoist names are .carlos-removing-<128 random bits from crypto/rand> instead of a counter, still renameat2 RENAME_NOREPLACE into the dev/ino-checked top, retried only on a collision (4 tries); a child gone at the hoist re-lists cur within the same 64-try budget as a descent. Same reads; no new read. file:Fstatat@169 5f76afcb90f4c414e993dec067ebd730ab0ff263328a38171cdee6a4da12061e
+internal/instancefs/dirs_linux.go treeRemover.sameTop legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-slice1-control-purge;basis=F6, new: fstat of the re-opened top fd; refuses if dev/ino differ from the top the walk began on. file:Fstat@77 ed275affbeee89c9122580e4df3823be61cd02951040897e9f4e63ee2e624e89
+@remove internal/instancefs/dirs_linux.go removeAt
+@removed internal/instancefs/dirs_linux.go removeAt H3 census-ruling-gvisor-slice1-control-purge;absent;basis=F6: deleted, replaced by treeRemover (same no-follow guarantees, no depth-64 refusal, bounded descriptors and memory).
+@coverage internal/activator f6d5f883f0adbe490d06ea7bd5de9fcb5315731c5544b2e6bee46217faacf976
+@coverage internal/demobuild 03d1306fd8a48f5e0b777fe2fdef8f80f43e5cfd1c396e184383182821d1911b
+@coverage internal/instancectl 69ac9f9a1de6330e3412e3bf07a2c3d625acd9c2f7a12d62c0bb816b0be8d7e4
+@coverage internal/instancefs 068c197b9e1f866413e4c5702afb56ba04f485976abe61b36ebc67f1beab1277