Merge remote-tracking branch 'origin/main' into instance-senders-1
# Conflicts: # internal/provision/testdata/plan14-root-reads-chain.tsv
25 files changed,
+3,283
−25
cli.go+45 −0docs/superpowers/notes/census-claims-demo-disk-slice1-retention.tsv+23 −0docs/superpowers/notes/census-proposal-demo-disk-slice1-retention.md+48 −0docs/superpowers/notes/census-proposal-instance-senders-1.md+1 −1internal/host/agent.go+11 −5internal/host/alertsink.go+18 −2internal/host/demodisk_status.go+120 −0internal/host/demodisk_status_test.go+198 −0internal/host/demoretention.go+990 −0internal/host/demoretention_linux_test.go+251 −0internal/host/demoretention_test.go+1,087 −0internal/host/metrics_loop.go+33 −2internal/host/statfs_unix.go+16 −1internal/host/statfs_windows.go+10 −1internal/metrics/alert.go+5 −0internal/provision/testdata/plan14-root-reads-chain.tsv+2 −1internal/provision/testdata/plan14-root-reads-demo-disk-slice1-retention.tsv+51 −0internal/provision/testdata/plan14-root-reads-instance-senders-1.tsv+1 −1internal/release/adopt.go+63 −4internal/release/beforestage_test.go+123 −0internal/status/contract_test.go+12 −1internal/status/demodisk.go+45 −0internal/status/demodisk_test.go+45 −0internal/status/snapshot.go+12 −6statuslive_demodisk_test.go+73 −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-ZAzsay
.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/service/ec2 v1.324.0
go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading golang.org/x/sys v0.49.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/pion/logging v0.2.4
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/pierrec/lz4/v4 v4.1.22
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/aws/aws-sdk-go-v2/service/ssm v1.74.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/pion/dtls/v3 v3.1.4
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 github.com/google/uuid v1.6.0
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading modernc.org/mathutil v1.7.1
=== launchctx (5 s, from +0 s)
ok amadan.net/carlos/platform.git/launchctx 0.016s
? amadan.net/carlos/platform.git/launchctx/controlname [no test files]
? amadan.net/carlos/platform.git/launchctx/wireid [no test files]
=== vet (177 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 modernc.org/mathutil v1.7.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== vet-tags (204 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 modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/google/uuid v1.6.0
=== gofmt (1 s, from +0 s)
gofmt -l .: clean
=== rest (403 s, from +15 s)
ok github.com/carlosframework/platform/cmd/carlos-media 137.738s
? github.com/carlosframework/platform/cmd/changelog [no test files]
ok github.com/carlosframework/platform/cmd/console 224.531s
ok github.com/carlosframework/platform/cmd/mediaimage 43.881s
ok github.com/carlosframework/platform/cmd/moveprobe 15.586s
ok github.com/carlosframework/platform/cmd/pricebook-export 0.053s
ok github.com/carlosframework/platform/cmd/rootfswitness 0.163s
ok github.com/carlosframework/platform/cmd/runsc-assets 0.162s
ok github.com/carlosframework/platform/cmd/zddprobe 1.054s
ok github.com/carlosframework/platform/internal/agentsock 0.086s
ok github.com/carlosframework/platform/internal/alerting 0.023s
ok github.com/carlosframework/platform/internal/analytics 0.462s
ok github.com/carlosframework/platform/internal/appconfig 43.922s
ok github.com/carlosframework/platform/internal/apperr 0.519s
ok github.com/carlosframework/platform/internal/applog 4.351s
ok github.com/carlosframework/platform/internal/apppolicy 2.295s
ok github.com/carlosframework/platform/internal/assetcache 0.695s
ok github.com/carlosframework/platform/internal/awsinv 0.033s
ok github.com/carlosframework/platform/internal/awsmanaged 9.279s
ok github.com/carlosframework/platform/internal/awsregiongroup 0.321s
ok github.com/carlosframework/platform/internal/awsterminations 0.021s
ok github.com/carlosframework/platform/internal/backupswords 0.010s
ok github.com/carlosframework/platform/internal/billing 0.081s
ok github.com/carlosframework/platform/internal/billing/billingtest 0.102s
ok github.com/carlosframework/platform/internal/billingstripe 1.905s
ok github.com/carlosframework/platform/internal/boxchoice 0.040s
ok github.com/carlosframework/platform/internal/boxid 2.464s
? 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.017s
ok github.com/carlosframework/platform/internal/boxself 0.272s
ok github.com/carlosframework/platform/internal/boxvolumes 0.037s
ok github.com/carlosframework/platform/internal/caps 3.594s
ok github.com/carlosframework/platform/internal/certwarm 0.005s
ok github.com/carlosframework/platform/internal/cgroup 1.491s
ok github.com/carlosframework/platform/internal/changelog 4.243s
ok github.com/carlosframework/platform/internal/clamd 0.073s
? github.com/carlosframework/platform/internal/cliflag [no test files]
ok github.com/carlosframework/platform/internal/clireg 0.014s
ok github.com/carlosframework/platform/internal/codehealth 16.539s
ok github.com/carlosframework/platform/internal/compute 0.021s
ok github.com/carlosframework/platform/internal/consolefleet 0.009s
? 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.958s
ok github.com/carlosframework/platform/internal/dbdoor/dbdoortest 0.068s
ok github.com/carlosframework/platform/internal/dbquery 0.016s
ok github.com/carlosframework/platform/internal/dbreads 3.355s
? github.com/carlosframework/platform/internal/dbreads/dbreadstest [no test files]
ok github.com/carlosframework/platform/internal/dbverify 0.043s
ok github.com/carlosframework/platform/internal/demo 0.030s
ok github.com/carlosframework/platform/internal/demobuild 4.870s
ok github.com/carlosframework/platform/internal/democlaim 0.434s
ok github.com/carlosframework/platform/internal/devbox 14.664s
ok github.com/carlosframework/platform/internal/dnsrec 0.012s
ok github.com/carlosframework/platform/internal/docsite 0.136s
ok github.com/carlosframework/platform/internal/domainreg 0.019s
ok github.com/carlosframework/platform/internal/domains 73.924s
ok github.com/carlosframework/platform/internal/doorkey 0.034s
ok github.com/carlosframework/platform/internal/economics 0.041s
ok github.com/carlosframework/platform/internal/edgefence 0.112s
ok github.com/carlosframework/platform/internal/edgeguard 0.395s
? github.com/carlosframework/platform/internal/edgeproof [no test files]
ok github.com/carlosframework/platform/internal/edgesfile 0.144s
ok github.com/carlosframework/platform/internal/egressaddr 0.009s
ok github.com/carlosframework/platform/internal/execsandbox 103.629s
ok github.com/carlosframework/platform/internal/fileacl 0.006s
ok github.com/carlosframework/platform/internal/fleetapi 2.135s
ok github.com/carlosframework/platform/internal/fleetstore 0.018s
ok github.com/carlosframework/platform/internal/fxrate 0.038s
ok github.com/carlosframework/platform/internal/gate 4.259s
ok github.com/carlosframework/platform/internal/genselect 0.138s
ok github.com/carlosframework/platform/internal/geo 0.078s
ok github.com/carlosframework/platform/internal/geoip 0.175s
ok github.com/carlosframework/platform/internal/groupadmission 0.007s
ok github.com/carlosframework/platform/internal/grouprollaws 16.668s
ok github.com/carlosframework/platform/internal/hadeparture 0.012s
ok github.com/carlosframework/platform/internal/hafresh 0.015s
ok github.com/carlosframework/platform/internal/hairpin 0.260s
ok github.com/carlosframework/platform/internal/historyreadback 1.020s
ok github.com/carlosframework/platform/internal/hostactors 21.124s
ok github.com/carlosframework/platform/internal/hostbox 20.958s
ok github.com/carlosframework/platform/internal/hostclaim 2.750s
ok github.com/carlosframework/platform/internal/hostenv 0.044s
ok github.com/carlosframework/platform/internal/hostevidence 0.013s
ok github.com/carlosframework/platform/internal/hostexec 22.647s
ok github.com/carlosframework/platform/internal/hostfence 0.196s
ok github.com/carlosframework/platform/internal/hostfiles 25.045s
ok github.com/carlosframework/platform/internal/hostfloor 0.277s
ok github.com/carlosframework/platform/internal/hostguard 1.521s
ok github.com/carlosframework/platform/internal/hostops 6.531s
? github.com/carlosframework/platform/internal/hostops/fencerelease [no test files]
ok github.com/carlosframework/platform/internal/hostops/internal/fencerelease 0.014s
ok github.com/carlosframework/platform/internal/hostquarantine 0.010s
ok github.com/carlosframework/platform/internal/hostrelocate 2.184s
ok github.com/carlosframework/platform/internal/hostresolve 0.706s
ok github.com/carlosframework/platform/internal/hostwrite 0.009s
ok github.com/carlosframework/platform/internal/identity 0.007s
ok github.com/carlosframework/platform/internal/infraview 0.006s
ok github.com/carlosframework/platform/internal/ingresshealth 0.009s
ok github.com/carlosframework/platform/internal/ingresshealth/awstg 0.023s
ok github.com/carlosframework/platform/internal/instancectl 68.685s
ok github.com/carlosframework/platform/internal/instanceexec 8.968s
ok github.com/carlosframework/platform/internal/instancefs 15.514s
ok github.com/carlosframework/platform/internal/instancekey 0.019s
ok github.com/carlosframework/platform/internal/instanceupdates 0.019s
ok github.com/carlosframework/platform/internal/interactive 0.637s
ok github.com/carlosframework/platform/internal/launchd 0.020s
ok github.com/carlosframework/platform/internal/layout 22.800s
ok github.com/carlosframework/platform/internal/layout/pubclass 109.109s
ok github.com/carlosframework/platform/internal/lbhealth 0.010s
ok github.com/carlosframework/platform/internal/lease 151.173s
ok github.com/carlosframework/platform/internal/lease/leasetest 1.081s
ok github.com/carlosframework/platform/internal/lease/locktest 0.015s
ok github.com/carlosframework/platform/internal/ledger 0.047s
ok github.com/carlosframework/platform/internal/mail 3.227s
ok github.com/carlosframework/platform/internal/mailer 0.868s
ok github.com/carlosframework/platform/internal/mailsubmit 1.210s
ok github.com/carlosframework/platform/internal/mailwire 0.009s
ok github.com/carlosframework/platform/internal/maintenance 0.170s
ok github.com/carlosframework/platform/internal/maintenanceexec 8.023s
ok github.com/carlosframework/platform/internal/maintenanceguard 0.321s
ok github.com/carlosframework/platform/internal/managedboot 3.734s
? 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.919s
ok github.com/carlosframework/platform/internal/media/mediatest 0.009s
ok github.com/carlosframework/platform/internal/mediaaws 63.955s
ok github.com/carlosframework/platform/internal/mediahandler 44.549s
ok github.com/carlosframework/platform/internal/mediajobs 1.017s
ok github.com/carlosframework/platform/internal/medialocal 9.924s
ok github.com/carlosframework/platform/internal/metrics 0.147s
ok github.com/carlosframework/platform/internal/minorunits 0.006s
ok github.com/carlosframework/platform/internal/moves 56.521s
ok github.com/carlosframework/platform/internal/moves/archive 2.791s
ok github.com/carlosframework/platform/internal/moves/offlinerun 0.136s
ok github.com/carlosframework/platform/internal/namedunits 0.030s
ok github.com/carlosframework/platform/internal/objstore 2.837s
ok github.com/carlosframework/platform/internal/ops 13.495s
ok github.com/carlosframework/platform/internal/pageindex 4.037s
ok github.com/carlosframework/platform/internal/parity 0.162s
? github.com/carlosframework/platform/internal/parity/cmd/parity-doc [no test files]
ok github.com/carlosframework/platform/internal/park 0.668s
ok github.com/carlosframework/platform/internal/perf 0.184s
ok github.com/carlosframework/platform/internal/plans 0.139s
ok github.com/carlosframework/platform/internal/privatefile 0.019s
ok github.com/carlosframework/platform/internal/provision 248.348s
ok github.com/carlosframework/platform/internal/proxyproto 0.937s
ok github.com/carlosframework/platform/internal/publicrelease 0.082s
ok github.com/carlosframework/platform/internal/ratelimit 0.194s
ok github.com/carlosframework/platform/internal/regionlabel 0.097s
ok github.com/carlosframework/platform/internal/regionname 0.073s
ok github.com/carlosframework/platform/internal/registrar 0.036s
ok github.com/carlosframework/platform/internal/registrar/openprovider 0.713s
? github.com/carlosframework/platform/internal/registrar/registrartest [no test files]
ok github.com/carlosframework/platform/internal/registry 87.603s
ok github.com/carlosframework/platform/internal/relay 7.531s
ok github.com/carlosframework/platform/internal/release 134.196s
? github.com/carlosframework/platform/internal/release/requestwitness [no test files]
ok github.com/carlosframework/platform/internal/replicagen 0.036s
ok github.com/carlosframework/platform/internal/replicas 0.122s
ok github.com/carlosframework/platform/internal/reqrec 9.457s
ok github.com/carlosframework/platform/internal/rollout 11.296s
ok github.com/carlosframework/platform/internal/rolloutwords 0.071s
ok github.com/carlosframework/platform/internal/rootaws 106.528s
ok github.com/carlosframework/platform/internal/rootfsimage 1.173s
ok github.com/carlosframework/platform/internal/rootparticipation 0.122s
ok github.com/carlosframework/platform/internal/rootstate 0.053s
ok github.com/carlosframework/platform/internal/runs 0.791s
ok github.com/carlosframework/platform/internal/s3compat 0.028s
ok github.com/carlosframework/platform/internal/s3fake 1.369s
ok github.com/carlosframework/platform/internal/s3meter 0.444s
ok github.com/carlosframework/platform/internal/safefile 0.043s
ok github.com/carlosframework/platform/internal/schedule 24.752s
ok github.com/carlosframework/platform/internal/seeds 0.069s
ok github.com/carlosframework/platform/internal/share 0.035s
ok github.com/carlosframework/platform/internal/sim/litestreamfacts 4.772s
ok github.com/carlosframework/platform/internal/sim/mediajobs 54.960s
ok github.com/carlosframework/platform/internal/sim/regionha 23.939s
ok github.com/carlosframework/platform/internal/status 0.244s
ok github.com/carlosframework/platform/internal/steering 0.188s
ok github.com/carlosframework/platform/internal/stopevidence 0.622s
ok github.com/carlosframework/platform/internal/storecfg 0.365s
ok github.com/carlosframework/platform/internal/svcrole 0.011s
ok github.com/carlosframework/platform/internal/systemd 6.874s
? github.com/carlosframework/platform/internal/systemdshow [no test files]
ok github.com/carlosframework/platform/internal/team 4.027s
ok github.com/carlosframework/platform/internal/teamcontract 0.309s
ok github.com/carlosframework/platform/internal/telemetry 0.052s
ok github.com/carlosframework/platform/internal/termfence 3.708s
ok github.com/carlosframework/platform/internal/timerspec 0.019s
ok github.com/carlosframework/platform/internal/tsidentity 4.175s
ok github.com/carlosframework/platform/internal/tunnelclient 0.391s
ok github.com/carlosframework/platform/internal/unixdial 0.017s
ok github.com/carlosframework/platform/internal/updatewords 0.046s
ok github.com/carlosframework/platform/internal/upstreamguard 0.013s
? github.com/carlosframework/platform/internal/upstreamguard/guardtest [no test files]
ok github.com/carlosframework/platform/internal/usage 0.168s
ok github.com/carlosframework/platform/internal/version 0.017s
ok github.com/carlosframework/platform/internal/vet 2.972s
ok github.com/carlosframework/platform/internal/zonehost 0.015s
ok github.com/carlosframework/platform/internal/zonehost/route53zones 0.064s
? 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.016s
ok github.com/carlosframework/platform/scripts/pathmapcheck 0.081s
ok github.com/carlosframework/platform/scripts/region-ha-g2/fixture 5.227s
ok github.com/carlosframework/platform/scripts/stateless-replicas-drill 1.191s
ok github.com/carlosframework/platform/scripts/witness-pointer 0.022s
=== cutover-witness (171 s, from +15 s)
ok github.com/carlosframework/platform 2.743s
=== internal_grouproll@0 (273 s, from +76 s)
ok github.com/carlosframework/platform/internal/grouproll 271.517s
=== internal_grouproll@1 (291 s, from +76 s)
ok github.com/carlosframework/platform/internal/grouproll 288.845s
=== internal_activator@0 (153 s, from +150 s)
ok github.com/carlosframework/platform/internal/activator 148.680s
=== internal_activator@1 (136 s, from +150 s)
ok github.com/carlosframework/platform/internal/activator 131.770s
=== internal_activator@2 (144 s, from +150 s)
ok github.com/carlosframework/platform/internal/activator 139.713s
=== internal_activator@3 (174 s, from +150 s)
ok github.com/carlosframework/platform/internal/activator 169.324s
=== root@0 (127 s, from +181 s)
ok github.com/carlosframework/platform 114.291s
=== root@1 (115 s, from +181 s)
ok github.com/carlosframework/platform 102.297s
=== root@2 (123 s, from +181 s)
ok github.com/carlosframework/platform 113.095s
=== root@3 (122 s, from +181 s)
ok github.com/carlosframework/platform 111.661s
=== root@4 (115 s, from +181 s)
ok github.com/carlosframework/platform 103.349s
=== internal_edge@0 (205 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 193.644s
=== internal_edge@1 (148 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 135.024s
=== internal_edge@2 (154 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 146.751s
=== internal_edge@3 (225 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 215.422s
=== internal_host@0 (197 s, from +230 s)
ok github.com/carlosframework/platform/internal/host 191.061s
=== internal_host@1 (275 s, from +231 s)
ok github.com/carlosframework/platform/internal/host 270.757s
=== internal_host@2 (201 s, from +231 s)
ok github.com/carlosframework/platform/internal/host 196.293s
=== internal_host@3 (169 s, from +231 s)
ok github.com/carlosframework/platform/internal/host 164.794s
=== internal_host@4 (232 s, from +231 s)
ok github.com/carlosframework/platform/internal/host 227.829s
=== internal_host@5 (156 s, from +231 s)
ok github.com/carlosframework/platform/internal/host 151.644s
=== internal_console@0 (179 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 172.722s
=== internal_console@1 (233 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 226.223s
=== internal_console@2 (213 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 205.604s
=== internal_console@3 (260 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 253.745s
=== internal_console@4 (216 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 209.680s
=== internal_console@5 (220 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 213.059s
=== internal_console@6 (228 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 221.494s
=== internal_console@7 (222 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 214.138s
=== internal_console@8 (257 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 250.097s
=== internal_console@9 (232 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 226.064s
=== internal_console@10 (236 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 228.660s
=== internal_console@11 (257 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 249.719s
=== internal_console@12 (340 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 332.016s
=== internal_console@13 (248 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 240.441s
=== internal_console@14 (238 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 230.330s
=== internal_console@15 (241 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 234.523s
=== internal_console@16 (239 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 232.806s
=== internal_console@17 (255 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 247.746s
=== internal_console@18 (227 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 219.705s
=== internal_console@19 (228 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 220.598s
=== internal_console@20 (265 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 257.140s
=== internal_console@21 (277 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 270.093s
=== internal_console@22 (277 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 269.925s
=== internal_console@23 (256 s, from +238 s)
ok github.com/carlosframework/platform/internal/console 247.663s
=== lists: internal_console 237 s, internal_edge 180 s, internal_activator 148 s, internal_host 230 s, root 179 s, internal_grouproll 76 s
=== cpu: the gate used 13665 cpu-seconds in 578 s, about 23.6 of 32 cores; the machine as a whole was 79% busy
=== opentofu ===
opentofu: 40 test files in 11 suites, OpenTofu v1.13.9
initialised in 15 s
ok 19 s infra/modules/box-fence-writer/tests/writer.tftest.hcl Success! 1 passed, 0 failed.
ok 20 s infra/modules/deployment-buckets/tests/console_floors.tftest.hcl Success! 1 passed, 0 failed.
ok 30 s infra/modules/deployment-buckets/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 22 s infra/modules/deployment-buckets/tests/db_reads.tftest.hcl Success! 1 passed, 0 failed.
ok 19 s infra/modules/deployment-buckets/tests/evidence.tftest.hcl Success! 1 passed, 0 failed.
ok 31 s infra/modules/deployment-buckets/tests/fence_writers.tftest.hcl Success! 3 passed, 0 failed.
ok 28 s infra/modules/deployment-buckets/tests/media_results.tftest.hcl Success! 2 passed, 0 failed.
ok 33 s infra/modules/deployment-buckets/tests/published_floors.tftest.hcl Success! 3 passed, 0 failed.
ok 78 s infra/modules/media-engine/tests/media_engine.tftest.hcl Success! 24 passed, 0 failed.
ok 25 s infra/modules/pdf-host/tests/computed.tftest.hcl Success! 2 passed, 0 failed.
ok 60 s infra/modules/pdf-host/tests/pdf_host.tftest.hcl Success! 24 passed, 0 failed.
ok 41 s infra/modules/region-group-operator-document/tests/document.tftest.hcl Success! 12 passed, 0 failed.
ok 16 s infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl Success! 2 passed, 0 failed.
ok 68 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 43 s infra/modules/region-host/tests/alerts_topic.tftest.hcl Success! 16 passed, 0 failed.
ok 11 s infra/modules/region-host/tests/analytics_prune.tftest.hcl Success! 2 passed, 0 failed.
ok 17 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 74 s infra/modules/region-host/tests/group.tftest.hcl Success! 32 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/group_alarms.tftest.hcl Success! 4 passed, 0 failed.
ok 13 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 36 s infra/modules/region-host/tests/group_operator.tftest.hcl Success! 13 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/group_user_data.tftest.hcl Success! 3 passed, 0 failed.
ok 30 s infra/modules/region-host/tests/health_alarms.tftest.hcl Success! 10 passed, 0 failed.
ok 15 s infra/modules/region-host/tests/ingress_drain_read.tftest.hcl Success! 4 passed, 0 failed.
ok 9 s infra/modules/region-host/tests/instance_metadata.tftest.hcl Success! 1 passed, 0 failed.
ok 22 s infra/modules/region-host/tests/mailer.tftest.hcl Success! 6 passed, 0 failed.
ok 12 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 109 s infra/modules/region-host/tests/managed_fleets/managed_fleets.tftest.hcl Success! 46 passed, 0 failed.
ok 75 s infra/modules/region-host/tests/store_conversion.tftest.hcl Success! 27 passed, 0 failed.
ok 15 s infra/modules/region-host/tests/store_scanning.tftest.hcl Success! 4 passed, 0 failed.
ok 29 s infra/modules/region-host/tests/store_versioning.tftest.hcl Success! 11 passed, 0 failed.
ok 17 s infra/modules/region-host/tests/store_write_credentials.tftest.hcl Success! 4 passed, 0 failed.
ok 20 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 27 s infra/modules/scanner-host/tests/scanner_host.tftest.hcl Success! 14 passed, 0 failed.
opentofu: 40 files in 221 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: 66912418 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:38008
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.02s)
--- 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.043s
=== RUN TestT4StorageProbeMinio
2026/12/01 05:24:35 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18ED09DDF3CC6047, HostID: 1ac863c9eee90cd53767a6abdccebfffef2e350d1ba63be341af192efde790bc, 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.049s
=== RUN TestS3StoreMinioContract
=== RUN TestS3StoreMinioContract/conditional_get_and_etag_listing
=== RUN TestS3StoreMinioContract/bump_through_every_mutation_path
--- PASS: TestS3StoreMinioContract (0.04s)
--- 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.045s
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.04s)
PASS
ok github.com/carlosframework/platform/internal/release 0.048s
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.022s
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:_read_elsewhere
=== RUN TestWriteCredentialContractMinio/refused:_head
=== RUN TestWriteCredentialContractMinio/refused:_list_uploads
=== RUN TestWriteCredentialContractMinio/refused:_delete
=== RUN TestWriteCredentialContractMinio/refused:_put_tagged
=== RUN TestWriteCredentialContractMinio/refused:_put_outside_the_prefix
=== RUN TestWriteCredentialContractMinio/refused:_put_to_another_bucket
=== RUN TestWriteCredentialContractMinio/refused:_bucket_settings
=== RUN TestWriteCredentialContractMinio/refused:_read_under_the_prefix
=== RUN TestWriteCredentialContractMinio/refused:_list
=== RUN TestWriteCredentialContractMinio/refused:_tag
=== RUN TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag
=== RUN TestWriteCredentialContractMinio/refused:_put_beside_the_prefix
=== RUN TestWriteCredentialContractMinio/refused:_copy_from_the_store
--- PASS: TestWriteCredentialContractMinio (0.04s)
--- PASS: TestWriteCredentialContractMinio/put_under_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/multipart_under_the_prefix (0.01s)
--- PASS: TestWriteCredentialContractMinio/refused:_read_elsewhere (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_head (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_list_uploads (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_delete (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_tagged (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_outside_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_to_another_bucket (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_bucket_settings (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_read_under_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_list (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_tag (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_beside_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_copy_from_the_store (0.00s)
PASS
ok github.com/carlosframework/platform/internal/objstore 0.055s
=== RUN TestEndToEndMinio
=== RUN TestEndToEndMinio/plan
=== RUN TestEndToEndMinio/roll
=== RUN TestEndToEndMinio/replace
=== RUN TestEndToEndMinio/remove
--- PASS: TestEndToEndMinio (0.53s)
--- PASS: TestEndToEndMinio/plan (0.01s)
--- PASS: TestEndToEndMinio/roll (0.14s)
--- PASS: TestEndToEndMinio/replace (0.17s)
--- PASS: TestEndToEndMinio/remove (0.17s)
PASS
ok github.com/carlosframework/platform/internal/grouproll 0.535s
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/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/12/01 05:24:44 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/12/01 05:24:44 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/12/01 05:24:44 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/12/01 05:24:44 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/12/01 05:24:44 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/12/01 05:24:44 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/12/01 05:24:44 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%3A39239: could not determine target mailbox
agent.go:136: dbreads: dbr_vtzevbf4hst4gfyj3442nagfty: planned 3 files (1544 bytes) and restored to 3 in 14ms
agent.go:136: dbreads: dbr_vtzevbf4hst4gfyj3442nagfty: output 5 bytes in 1 confirmed chunks in 2ms
2026/12/01 05:24:45 console: db read dbr_vtzevbf4hst4gfyj3442nagfty: relayed 1 chunks (102 bytes) in 1.006s, ended done
agent.go:136: dbreads: dbr_frnjnsa4dpjce3mhsryijf6em4: planned 1 files (720 bytes) and restored to 1 in 12ms
agent.go:136: dbreads: dbr_frnjnsa4dpjce3mhsryijf6em4: output 5 bytes in 1 confirmed chunks in 2ms
2026/12/01 05:24:46 console: db read dbr_frnjnsa4dpjce3mhsryijf6em4: relayed 1 chunks (102 bytes) in 1.005s, ended done
agent.go:136: dbreads: dbr_mzctmmlniile5rt6vyagj6bbze: planned 3 files (1544 bytes) and held through 3 in 14ms
agent.go:136: dbreads: dbr_mzctmmlniile5rt6vyagj6bbze: output 1544 bytes in 1 confirmed chunks in 1ms
2026/12/01 05:24:47 console: db read dbr_mzctmmlniile5rt6vyagj6bbze: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN TestDBForwardMinio/by_disconnect
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_t3jvu6ik54rr54qfxvuh423oji: planned 3 files (1544 bytes) and restored to 3 in 15ms
2026/12/01 05:24:47 console: db read dbr_t3jvu6ik54rr54qfxvuh423oji: relayed 0 chunks (0 bytes) in 27ms, ended client gone
agent.go:136: dbreads: dbr_t3jvu6ik54rr54qfxvuh423oji: output 5 bytes in 1 confirmed chunks in 105ms
=== RUN TestDBForwardMinio/by_timeout
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_d36aiqkxcfyjd3frv4wp73guve: planned 3 files (1544 bytes) and restored to 3 in 14ms
2026/12/01 05:25:08 console: db read dbr_d36aiqkxcfyjd3frv4wp73guve: relayed 0 chunks (0 bytes) in 19.817s, ended no-result
agent.go:136: dbreads: dbr_d36aiqkxcfyjd3frv4wp73guve: output 5 bytes in 1 confirmed chunks in 19.79s
--- PASS: TestDBForwardMinio (23.53s)
--- PASS: TestDBForwardMinio/by_disconnect (0.24s)
--- PASS: TestDBForwardMinio/by_timeout (19.93s)
PASS
ok github.com/carlosframework/platform/internal/console 23.583s
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.08s)
PASS
ok github.com/carlosframework/platform/internal/mediaaws 0.086s
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.61s)
PASS
ok github.com/carlosframework/platform/internal/medialocal 0.613s
=== RUN TestHeldHandoverTwoBoxMinio
2026/12/01 05:25:13 edge: mesh key: minted
2026/12/01 05:25:13 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/12/01 05:25:13 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/12/01 05:25:13 tenant admission is open. accepting tenant work
2026/12/01 05:25:13 activator: HA placement host=shop-ca9d7b60.example.test kind=Place ref=annie reason=roomiest generation=2026-12-01T05:25:13Z lock_generation=0
2026/12/01 05:25:13 lease: t8-ca9d7b60/shop-ca9d7b60.example.test: HA lease acquired in 4ms (first wake)
2026/12/01 05:25:13 activator: shop-ca9d7b60.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/12/01 05:25:13 activator: shop-ca9d7b60.example.test: started carlos-instance@shop\x2dca9d7b60.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 7ms, control socket 0s, key gate 0s, logs 0s) 8ms, launch file 0s, gate 0s, root start 1ms)
2026/12/01 05:25:13 activator: shop-ca9d7b60.example.test: carlos-instance@shop\x2dca9d7b60.example.test.service launched in 9ms, healthy 0s later
2026/12/01 05:25:13 activator: shop-ca9d7b60.example.test: woke in 24ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 9ms, replicate 8ms
2026/12/01 05:25:13 lease: t8-ca9d7b60/plain-ca9d7b60.example.test: acquired in 2ms (client 0s, lock read and write 1ms)
2026/12/01 05:25:13 activator: no replica for plain-ca9d7b60.example.test in s3://contract-bucket/t8-ca9d7b60/plain-ca9d7b60.example.test — booting fresh
2026/12/01 05:25:13 activator: plain-ca9d7b60.example.test: started carlos-instance@plain\x2dca9d7b60.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/12/01 05:25:13 activator: plain-ca9d7b60.example.test: carlos-instance@plain\x2dca9d7b60.example.test.service launched in 7ms, healthy 0s later
2026/12/01 05:25:13 activator: plain-ca9d7b60.example.test: woke in 46ms: checks 0s, lease 2ms, restore 19ms, identity 0s, protect 0s, spawn 7ms, replicate 19ms
2026/12/01 05:25:13 lease: t8-ca9d7b60/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/12/01 05:25:13 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/12/01 05:25:13 activator: bot0.shop.bac.sidecar.internal: woke in 69ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 8ms, settle 0s, replicate 55ms
2026/12/01 05:25:13 activator: next-due probe plain-ca9d7b60.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/12/01 05:25:13 activator: plain-ca9d7b60.example.test hibernated
2026/12/01 05:25:13 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:68c89b270bae648224af5ea9befde8cfb5d3db1ac2628be2ab8982790609af56) in 8ms: files 1ms, sync 4ms, record 1ms, marker 2ms
2026/12/01 05:25:13 activator: bot0.shop.bac.sidecar.internal hibernated
2026/12/01 05:25:13 activator: next-due probe shop-ca9d7b60.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test: released with a marker (clean true, txid 1, files 3:e1c74e3e22053036504b37c1f0a42a201f082138729d43769d519d4ad43e4c16) in 6ms: files 1ms, sync 3ms, record 1ms, marker 2ms
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test hibernated
2026/12/01 05:25:14 lease: t8-ca9d7b60/shop-ca9d7b60.example.test: HA lease acquired in 3ms (clean marker)
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test: restored (other-box)
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test: started carlos-instance@shop\x2dca9d7b60.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 1ms, control socket 0s, key gate 0s, logs 0s) 1ms, launch file 0s, gate 0s, root start 1ms)
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test: carlos-instance@shop\x2dca9d7b60.example.test.service launched in 2ms, healthy 0s later
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test: woke in 92ms: checks 0s, lease 4ms, restore 30ms, identity 0s, protect 1ms, spawn 2ms, replicate 55ms
2026/12/01 05:25:14 edge: ha-take shop-ca9d7b60.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/12/01 05:25:14 edge: forward shop-ca9d7b60.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:8da305211eb43cb69f5aadf605c317f2 Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-12-01 05:25:13.973905432 +0000 UTC FinishedAt:2026-12-01 05:25:14.121928967 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-ca9d7b60.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:plain-ca9d7b60.example.test Kind:other Marker:true Clean:true Reason:} {Host:bot0.shop.bac.sidecar.internal Kind:worker Marker:true Clean:true Reason:}] Unclean:[] Left:[] Holds:{LongestMS:125 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-ca9d7b60.example.test <nil> stop plain-ca9d7b60.example.test marker=true clean=true <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> releasing shop-ca9d7b60.example.test <nil> stop shop-ca9d7b60.example.test marker=true clean=true <nil> taken shop-ca9d7b60.example.test betty <nil> end-moves]
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-ca9d7b60/plain-ca9d7b60.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-ca9d7b60/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-ca9d7b60/bot0.shop.bac.sidecar.internal/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/head.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/generations/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/files/0/manifest.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/files/0/objects/0000000000000001-b3f1d7da3de4c27e93348a4fed4d2c6013e71207ae7651c38cd47e5f46e8ef3d
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/files/0/objects/0000000000000003-8f98250c03b393bb3a5f03a1b4ccd893ee6669de870482708fead7fc0a895b99
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/0000/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-ca9d7b60/shop-ca9d7b60.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/0000/0000000000000002-0000000000000002.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-ca9d7b60/shop-ca9d7b60.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1243: drain took 188ms; S3 calls 43 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=27 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/12/01 05:25:14 lease: t8-ca9d7b60/plain-ca9d7b60.example.test: acquired in 2ms (client 0s, lock read and write 2ms)
2026/12/01 05:25:14 activator: plain-ca9d7b60.example.test: started carlos-instance@plain\x2dca9d7b60.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/12/01 05:25:14 activator: plain-ca9d7b60.example.test: carlos-instance@plain\x2dca9d7b60.example.test.service launched in 1ms, healthy 0s later
2026/12/01 05:25:14 lease: /tmp/carlos-minio-contract-Gj1qMH/g/dw2926642414/data/instances/plain-ca9d7b60.example.test/plain-ca9d7b60.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/12/01 05:25:14 activator: plain-ca9d7b60.example.test: woke in 9ms: checks 0s, lease 2ms, restore 0s, identity 0s, protect 1ms, spawn 2ms, replicate 5ms
2026/12/01 05:25:14 activator: next-due probe shop-ca9d7b60.example.test: decode /api/next-due: invalid character 'b' looking for beginning of value — recording none (it sleeps until a request)
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test: released with a marker (clean true, txid 2, files 3:e1c74e3e22053036504b37c1f0a42a201f082138729d43769d519d4ad43e4c16) in 5ms: files 1ms, sync 1ms, record 1ms, marker 3ms
2026/12/01 05:25:14 activator: shop-ca9d7b60.example.test hibernated
2026/12/01 05:25:14 tenant admission is closed for shutdown
2026/12/01 05:25:14 activator: next-due probe plain-ca9d7b60.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/12/01 05:25:14 activator: plain-ca9d7b60.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.58s)
=== RUN TestHeldHandoverLostLeaseMinio
2026/12/01 05:25:14 edge: mesh key: minted
2026/12/01 05:25:14 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/12/01 05:25:14 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/12/01 05:25:14 tenant admission is open. accepting tenant work
2026/12/01 05:25:14 activator: HA placement host=shop-26b2e8bf.example.test kind=Place ref=annie reason=roomiest generation=2026-12-01T05:25:14Z lock_generation=0
2026/12/01 05:25:14 lease: t8-26b2e8bf/shop-26b2e8bf.example.test: HA lease acquired in 4ms (first wake)
2026/12/01 05:25:14 activator: shop-26b2e8bf.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/12/01 05:25:14 activator: shop-26b2e8bf.example.test: started carlos-instance@shop\x2d26b2e8bf.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 7ms, control socket 0s, key gate 0s, logs 0s) 7ms, launch file 0s, gate 0s, root start 1ms)
2026/12/01 05:25:14 activator: shop-26b2e8bf.example.test: carlos-instance@shop\x2d26b2e8bf.example.test.service launched in 8ms, healthy 0s later
2026/12/01 05:25:14 activator: shop-26b2e8bf.example.test: woke in 69ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 9ms, replicate 55ms
2026/12/01 05:25:14 activator: next-due probe shop-26b2e8bf.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/12/01 05:25:14 activator: final checkpoint shop-26b2e8bf.example.test: lease: release marker owed for s3://contract-bucket/t8-26b2e8bf/shop-26b2e8bf.example.test/lock.json (If-Match "0378210df52e2cc1f0a03d0df030b90d"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/12/01 05:25:14 activator: shop-26b2e8bf.example.test hibernated
2026/12/01 05:25:14 activator: handover of shop-26b2e8bf.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-26b2e8bf.example.test client 4 "
hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-26b2e8bf.example.test <nil> releasing shop-26b2e8bf.example.test <nil> stop shop-26b2e8bf.example.test marker=false clean=false <nil> left shop-26b2e8bf.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/12/01 05:25:14 tenant admission is closed for shutdown
2026/12/01 05:25:14 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.33s)
PASS
ok github.com/carlosframework/platform/internal/host 0.953s
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/12/01 05:25:15 lease: instances/gen-1796102715804055717.shop.example.com: HA lease acquired in 5ms (first wake)
2026/12/01 05:25:15 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/12/01 05:25:15 lease: instances/gen-1796102715804055717.shop.example.com: HA lease acquired in 3ms (holder terminated)
gentake_minio_test.go:308: a second create-only copy onto instances/gen-1796102715804055717.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/12/01 05:25:15 ERROR retention enforcement failed system=store db=w.example.com.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
=== RUN TestGenerationTakeMinio/switch-412
2026/12/01 05:25:16 lease: instances/gen-1796102716006697755.shop.example.com: HA lease acquired in 4ms (first wake)
2026/12/01 05:25:16 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/12/01 05:25:16 lease: instances/gen-1796102716006697755.shop.example.com: HA lease acquired in 4ms (clean marker)
=== RUN TestGenerationTakeMinio/copy-version
=== RUN TestGenerationTakeMinio/store-time
2026/12/01 05:25:16 lease: instances/gen-1796102716122099145.shop.example.com: HA lease acquired in 4ms (first wake)
2026/12/01 05:25:16 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: fetch ltx files: lease: a write has waited too long to reach storage (write fence)"
2026/12/01 05:25:16 lease: instances/gen-1796102716122099145.shop.example.com: HA lease acquired in 3ms (clean marker)
2026/12/01 05:25:16 lease: instances/gen-1796102716122099145.shop.example.com: HA lease acquired in 3ms (unclean marker)
2026/12/01 05:25:16 lease: instances/gen-1796102716122099145.shop.example.com: HA lease acquired in 3ms (unclean marker)
2026/12/01 05:25:16 lease: instances/gen-1796102716122099145.shop.example.com: HA lease acquired in 3ms (unclean marker)
2026/12/01 05:25:16 lease: instances/gen-1796102716122099145.shop.example.com: HA lease acquired in 3ms (unclean marker)
=== RUN TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.46s)
--- PASS: TestGenerationTakeMinio/take (0.20s)
--- PASS: TestGenerationTakeMinio/switch-412 (0.10s)
--- PASS: TestGenerationTakeMinio/copy-version (0.01s)
--- PASS: TestGenerationTakeMinio/store-time (0.12s)
--- PASS: TestGenerationTakeMinio/skew (0.02s)
PASS
ok github.com/carlosframework/platform/internal/lease 0.468s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
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/tools v0.50.0
go: downloading golang.org/x/telemetry v0.0.0-20260908163034-4bcc4b2ee518
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 1m58.612s
codehealth_test.go:107: line metrics (code lines, then physical):
file-lines 5471 7324 internal/activator activator_test.go
file-lines 4160 6981 internal/console server.go
file-lines 4120 6283 . 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 3175 6348 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 683 1238 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 817 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 733 internal/release PassFilter
func-lines 390 398 internal/host runFilesSeedPreparationWithLive
func-lines 383 406 internal/console TestDemoSourceToLiveAndUpdate
func-lines 374 377 internal/host plan14RequiredArtifactsRootRunner
func-lines 371 417 internal/host TestRootEgressKernelProof
func-lines 369 883 internal/edge (*Edge).ServeHTTP
func-lines 367 584 internal/console (*Server).handleAPIShip
func-lines 364 371 internal/host testRootMigrationBootstrap
func-lines 360 362 internal/edge TestDemoAPIAliasBoundary
func-lines 358 628 cmd/console serve
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 (217 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/schedule/envfile_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 1089 at 473 sites log.Fatal*, (*log.Logger).Fatal* and os.Exit in the root package's production files
codehealth_test.go:115: sleep 1006 at 812 sites time.Sleep in test files
codehealth_test.go:115: db-no-context 873 at 696 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 18582 at 45 sites functions over 300 code lines (blank and comment-only lines not counted)
codehealth_test.go:115: file-lines 30596 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: func-lines cmd/console serve -: 358 in the code, the record allows 362 (make code-health-record lowers it)
codehealth_test.go:119: below the record: file-lines . apimode.go -: 4120 in the code, the record allows 4147 (make code-health-record lowers it)
codehealth_test.go:119: below the record: file-lines internal/console server.go -: 4160 in the code, the record allows 4191 (make code-health-record lowers it)
codehealth_test.go:119: below the record: file-lines internal/host agent.go -: 3175 in the code, the record allows 3204 (make code-health-record lowers it)
--- PASS: TestCodeHealth (118.62s)
PASS
ok github.com/carlosframework/platform/internal/codehealth 120.398s
=== code-health-record ===
go version go1.26.10 linux/arm64
code-health record: comparing with the merge base b9ddd8ed49ff85b07e4efdfe3ecffecc9d7a0db1 (main is 91ed762d1a6142fe37bc65214345b57578f68043)
=== RUN TestRecordAgainstBase
--- PASS: TestRecordAgainstBase (0.01s)
PASS
ok github.com/carlosframework/platform/internal/codehealth 0.009s
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 (14 s, from +14 s)
ok github.com/carlosframework/platform/internal/systemd 13.960s
=== internal_rootaws@0 (27 s, from +36 s)
ok github.com/carlosframework/platform/internal/rootaws 26.272s
=== internal_activator@0 (259 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 256.497s
=== internal_activator@1 (287 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 284.630s
=== internal_activator@2 (307 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 304.846s
=== internal_activator@3 (377 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 374.997s
=== internal_activator@4 (322 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 319.635s
=== internal_activator@5 (312 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 309.928s
=== internal_activator@6 (316 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 313.515s
=== internal_activator@7 (415 s, from +119 s)
ok github.com/carlosframework/platform/internal/activator 412.604s
=== internal_edge@0 (87 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 83.332s
=== internal_edge@1 (104 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 100.782s
=== internal_edge@2 (214 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 210.548s
=== internal_edge@3 (168 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 163.767s
=== internal_edge@4 (194 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 190.518s
=== internal_edge@5 (233 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 228.872s
=== internal_edge@6 (208 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 204.497s
=== internal_edge@7 (219 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 215.096s
=== internal_edge@8 (270 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 266.666s
=== internal_edge@9 (293 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 288.900s
=== internal_edge@10 (232 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 227.742s
=== internal_edge@11 (228 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 224.265s
=== internal_edge@12 (258 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 253.836s
=== internal_edge@13 (262 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 258.306s
=== internal_edge@14 (179 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 175.640s
=== internal_edge@15 (263 s, from +143 s)
ok github.com/carlosframework/platform/internal/edge 259.232s
=== internal_host@0 (16 s, from +209 s)
ok github.com/carlosframework/platform/internal/host 11.726s
=== internal_host@1 (10 s, from +209 s)
ok github.com/carlosframework/platform/internal/host 6.084s
=== lists: internal_edge 143 s, internal_activator 118 s, internal_host 208 s, internal_rootaws 35 s, internal_systemd 14 s
=== cpu: the gate used 7871 cpu-seconds in 534 s, about 14.7 of 32 cores; the machine as a whole was 46% 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/spf13/viper v1.19.0
go: downloading github.com/BobuSumisu/aho-corasick v1.0.3
go: downloading github.com/gitleaks/go-gitdiff v0.9.1
go: downloading github.com/fatih/semgroup v1.2.0
go: downloading github.com/h2non/filetype v1.1.3
go: downloading golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
go: downloading github.com/charmbracelet/lipgloss v0.5.0
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/mholt/archives v0.1.2
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading golang.org/x/sync v0.11.0
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/mattn/go-runewidth v0.0.14
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading github.com/spf13/cast v1.7.1
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/spf13/pflag v1.0.6
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading github.com/magiconair/properties v1.8.9
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/mattn/go-colorable v0.1.14
go: downloading golang.org/x/sys v0.30.0
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading golang.org/x/text v0.22.0
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading dario.cat/mergo v1.0.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/Masterminds/semver/v3 v3.3.0
go: downloading github.com/therootcompany/xz v1.0.1
go: downloading github.com/klauspost/compress v1.17.11
go: downloading github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3
go: downloading github.com/minio/minlz v1.0.0
go: downloading github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
go: downloading github.com/nwaples/rardecode/v2 v2.1.0
go: downloading github.com/pierrec/lz4/v4 v4.1.21
go: downloading github.com/klauspost/pgzip v1.2.6
go: downloading github.com/STARRY-S/zip v0.2.1
go: downloading github.com/bodgit/sevenzip v1.6.0
go: downloading github.com/sorairolake/lzip-go v0.3.5
go: downloading github.com/ulikunitz/xz v0.5.12
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/bodgit/plumbing v1.3.0
go: downloading go4.org v0.0.0-20230225012048-214862532bf5
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.7
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/bodgit/windows v1.0.1
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading github.com/hashicorp/errwrap v1.1.0
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 103 near misses of the names notscanned.go lists
self-test: skipped the 34 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, 138 tracked files judged, 3 broken setups refused
gitleaks: scanned 12210 tracked files; 34 not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)
gitleaks: clean
diff --git a/cli.go b/cli.go| index c47d31e84..2dd74ca98 100644 |
| --- a/cli.go |
| +++ b/cli.go |
| @@ -4197,6 +4197,7 @@ func printLiveBoxesWith(w io.Writer, boxes []status.Box, now time.Time, places l |
| b.Label, orDash(liveRegion(b, places)), orDash(m.Release), orDash(m.Tunnel), |
| humanBytes(m.MemAvailBytes), humanBytes(m.MemTotalBytes), |
| humanFloat(m.Load1), humanBytes(m.DiskFreeBytes), alertsWord(m.Alerts), engineBeatWord(m.Alerts)) |
| + printDemoDisk(w, m.DemoDisk, now) |
| for _, r := range m.ReleaseRefusals { |
| if r.Kind == release.RefusalWrongProgram { |
| fmt.Fprintf(w, " refused %s %s since %s: wrong program (%s)\n", r.Host, r.Version, r.RefusedAt.UTC().Format(time.RFC3339), strings.TrimPrefix(r.Reason, "wrong program: ")) |
| @@ -4235,6 +4236,50 @@ func printLiveBoxesWith(w io.Writer, boxes []status.Box, now time.Time, places l |
| } |
| } |
| +// printDemoDisk is a demo box's disk numbers under its line (demo disk |
| +// bound, slice 1): the room on /data and /run, the demo builds root keeps, |
| +// and its retention backlog, with a line of its own once that is a day old. |
| +// Only what the box read; nothing at all for any other box. |
| +func printDemoDisk(w io.Writer, d *status.DemoDisk, now time.Time) { |
| + if d == nil { |
| + return |
| + } |
| + var rooms []string |
| + for _, fs := range []struct { |
| + name string |
| + room *status.FilesystemRoom |
| + }{{"/data", d.Data}, {"/run", d.Run}} { |
| + if fs.room != nil { |
| + free := fs.room.FreeBytes |
| + rooms = append(rooms, fmt.Sprintf("%s %s and %d inodes", fs.name, humanBytes(&free), fs.room.FreeInodes)) |
| + } |
| + } |
| + if len(rooms) > 0 { |
| + fmt.Fprintf(w, " free: %s\n", strings.Join(rooms, "; ")) |
| + } |
| + b := d.Builds |
| + if b == nil { |
| + return |
| + } |
| + held := b.OutputBytes |
| + fmt.Fprintf(w, " demo builds kept: %d (%s) as of %s\n", b.Outputs, humanBytes(&held), b.At.UTC().Format(time.RFC3339)) |
| + if b.Backlog > 0 { |
| + // A held app's builds stay until an operator clears the hold, so the |
| + // next pass is only promised when nothing is held. |
| + next := "; the next adopt pass tries again" |
| + if len(b.Held) > 0 { |
| + next = "" |
| + } |
| + fmt.Fprintf(w, " demo builds over the limit: %d since %s%s\n", b.Backlog, b.BacklogSince.UTC().Format(time.RFC3339), next) |
| + if !b.BacklogSince.IsZero() && now.Sub(b.BacklogSince) > status.DemoBacklogStale { |
| + fmt.Fprintln(w, " demo build cleanup has been behind for over 24 hours: check the adopt pass log on this box") |
| + } |
| + } |
| + for _, h := range b.Held { |
| + fmt.Fprintf(w, " demo updates refused for %s; its builds stay until that is fixed\n", h) |
| + } |
| +} |
| + |
| // alertsWord renders a box's alert-sink answer for the live listing. "not |
| // delivered" is spelled out because it is the state discussion #192 found |
| // silent for weeks: a box whose own disk, memory and cpu rules have nowhere |
diff --git a/docs/superpowers/notes/census-claims-demo-disk-slice1-retention.tsv b/docs/superpowers/notes/census-claims-demo-disk-slice1-retention.tsv| new file mode 100644 |
| index 000000000..21e4226c2 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-claims-demo-disk-slice1-retention.tsv |
| @@ -0,0 +1,23 @@ |
| +internal/host/agent.go:statusLoop the agent (carlos-edge.service, user carlos): the status tick also fills Probes.DemoDisk from readDemoDisk(), nil unless CARLOS_DEMO_BOX is set; statfs of /data and /run, and root's public retention record (readDemoBuilds); report only; no store request added; read sites unchanged |
| +internal/status/snapshot.go:CollectBox copies Probes.DemoDisk into BoxMetrics.DemoDisk (json demo_disk, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added |
| +internal/host/demodisk_status.go:productionDemoDiskProbe the agent (user carlos), not root: opens root's public record directory /var/lib/carlos-release/demo-retention read-only through rootstate.Open(dir, false, true) (every ancestor root-owned, not group or world writable); report only |
| +internal/host/statfs_unix.go:filesystemRoom the agent (user carlos): statfs of /data and /run for status and the disk alert; numbers only |
| +internal/release/adopt.go:passConfig.stageWriteCheck root adopt pass and agent passes: generationWriteCheck unchanged first; then, only when WithBeforeStage is set (root's adopt pass only), Lstat of the VersionPath about to be written and the callback when nothing is there; an error fails the stage (nothing written, route unchanged) |
| +internal/host/demoretention.go:demoRetention.listOutputs root adopt pass: ReadDir of <opt>/versions (root-owned) and of <opt>/versions/<ver>/<demo account> for each ValidVersion directory; each entry name, less .manifest.json, must pass validDemoName (tmp-demo- + demo.ValidPublicName: one path component, no "." or "..") before it is used; DirEntry.Info for sizes. ENOENT/ENOTDIR skip. Reads no registry input |
| +internal/host/demoretention.go:linkTargets root adopt pass: ReadDir, Readlink and EvalSymlinks of the root-owned <opt>/previous and <opt>/live links, as release.LivePins reads them for the sweep (replaces previousLinkPins, same reads); an unreadable link is an error and nothing is deleted |
| +internal/host/demoretention.go:demoOutput.spellings root adopt pass: EvalSymlinks of an output's directory <opt>/versions/<ver>/<demo account>, every component validated (ValidVersion, BoxConfig account, validDemoName), so an output is compared under the store's spelling and its real path; reads no registry input |
| +internal/host/demoretention.go:demoRetention.validDemoRow root adopt pass: reads a registry row's demo descriptor (DemoID, DemoHost, DemoLifetime, DemoExpiresAt), Host, App and account and checks it with demo.Config.ValidateBinding against host.env's tuple. Its only effect is protection: a row of the demo account that fails keeps all of its app's builds; it never makes anything eligible |
| +internal/host/demoretention.go:demoRetention.demoAdoptions root adopt pass: lists the registry and keeps the Host and Version of each row of the demo account whose App has the tmp-demo- prefix, to tell after the pass whether it adopted a demo version; decides only whether retention runs, never what it removes |
| +internal/host/agent.go:runAdoptUnderRootRelease demo disk bound slice 1, fix round 3: release.Pass runs inside adoptPassAround(ctx, configOnly, restartOnly, stageOnly, passLockErr, productionDemoRetentionFor(reg, generationPins), pass), still inside pr.around and under the adopt pass lock taken at the top; pass now receives two demo options, release.WithRouteAdmission(admitRoute) and release.WithBeforeStage(beforeStage). adoptPassRetention composes mode and lock (nil on -config-only/-restart-only, which also return before this line; locked = passLockErr == nil; hourly = !stageOnly). Witnessed through adoptPassAround around a real release.Pass (TestAdoptPassAroundGatesDemoAdoptionOnTheLock). No read added in this unit; read sites unchanged |
| +internal/release/adopt.go:PassFilter the stage check's beforeWrite is cfg.stageWriteCheck (unchanged from round 1); fix round 3: the recovery loop and the adopts predicate also require cfg.routeAdmitted(rt), so a route WithRouteAdmission refuses is kept out of recovery, selection, staging, restaging, reuse and the repoint for the whole pass, exactly as a non-adoptable route is. The two added sites pass the Route already in hand to the admission callback; no new read, and nil admission (every caller but root's adopt pass) admits every route as before |
| +internal/release/adopt.go:type passConfig adds the beforeStage callback field (WithBeforeStage) and the admitRoute field (WithRouteAdmission), both set only by root's adopt pass; reads nothing |
| +internal/release/adopt.go:WithRouteAdmission new PassOption: wraps fn so a refusal is printed once per host (rt.Host) and returns whether the route is admitted; reads only the Route handed to it, no file, store or registry read |
| +internal/release/adopt.go:passConfig.routeAdmitted new: true without an admission option, otherwise the admission's answer for the Route in hand; reads nothing else |
| +internal/host/demoretention.go:productionDemoRetention root adopt pass: demo.BoxConfig from host.env (root-owned), now also keeping its error (boxErr) so a box that says it is a demo box with invalid settings refuses demo adoption; the version store and generations file paths, root's generation ledger, and the record store opener rootstate.Open(/var/lib/carlos-release/demo-retention, true, true) |
| +internal/host/demodisk_status.go:const#1 the agent (user carlos): diskWhereData, diskWhereDataInodes, diskWhereRun, diskWhereRunInodes, the names the disk alert gives what it measured; literals only |
| +cli.go:printDemoDisk operator CLI (carlos status --live), not root: prints a published box snapshot's demo_disk numbers; final round: also prints each held app (DemoBuilds.Held) even at zero backlog, and drops "the next adopt pass tries again" when an app is held; reads only the decoded snapshot in hand |
| +internal/host/demodisk_status.go:readDemoBuilds the agent (user carlos): reads the record 'status' from root's public rootstate store (descriptor read, trusted owner, 1 MiB cap) and decodes it; schema 1 or an error; final round: also carries the record's Held list into status.DemoBuilds; report only, nothing reads it as authority |
| +internal/host/demoretention.go:demoRetention.admitRoute root adopt pass: the demo admission asked of every route before the release pass does anything with it; refuses a tmp-demo- route on a box whose host.env demo settings do not validate (boxErr; the message now names CARLOS_DEMO_BOX and the tuple), and on a demo box a route of the demo account when the demo account is the ops account, the name is not a demo name, or the pass does not hold the adopt pass lock. Only refuses; reads only the Route in hand and root's own config |
| +internal/host/demoretention.go:demoRetention.pinSet root adopt pass: the pin set from every source: release.BoxPins over every registry row (live link chains; Version, PrevVersion, GoodVersion, settings references), previous links (linkTargets), release.GenerationPins over the generations file, and root's generation ledger. Final round: the two generation sources' pins are also returned apart (reserved), so the backlog can count an app's reserved outputs toward its G + R; the same reads. Strict: any source that does not read in full is an error, except BoxPins' IncompleteRefsError, returned for the caller to hold the apps it covers. Pins only ever keep builds; agent-writable inputs only ADD protection |
| +internal/host/demoretention.go:demoRetention.saveStatus root adopt pass: reads its own previous record from the public root store /var/lib/carlos-release/demo-retention to carry the backlog's start, and writes the new record there; final round: the record also carries Held (each held app and why), kept from the previous record when nothing read; status only, never read back as a pin or a decision |
| +internal/host/demoretention.go:demoRetention.selection root adopt pass: eligibility only from root's facts (demoAccount, listOutputs' listing of its own store). Registry rows (List; App, Version, the route for RouteAccount and validDemoRow) only ADD protection: pins, and holds. Final round: the added sites list the held apps of the demo account for the record (a row's App, validated by validDemoName, and its account), whether or not they have outputs, and mark outputs covered by the generation sources as reserved for the backlog. No registry string reaches a filesystem path; nothing here makes an output eligible |
diff --git a/docs/superpowers/notes/census-proposal-demo-disk-slice1-retention.md b/docs/superpowers/notes/census-proposal-demo-disk-slice1-retention.md| new file mode 100644 |
| index 000000000..f0682a46a |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-demo-disk-slice1-retention.md |
| @@ -0,0 +1,48 @@ |
| +# Census approval: demo-disk-slice1-retention |
| + |
| +Ruling `census-ruling-demo-disk-slice1-retention`. The independent reviewer approves or rejects every change below, 18 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/host/agent.go` `runAdoptUnderRootRelease` | body | unchanged (4) | demo disk bound slice 1, fix round 3: release.Pass runs inside adoptPassAround(ctx, configOnly, restartOnly, stageOnly, passLockErr, productionDemoRetentionFor(reg, generationPins), pass), still inside pr.around and under the adopt pass lock taken at the top; pass now receives two demo options, release.WithRouteAdmission(admitRoute) and release.WithBeforeStage(beforeStage). adoptPassRetention composes mode and lock (nil on -config-only/-restart-only, which also return before this line; locked = passLockErr == nil; hourly = !stageOnly). Witnessed through adoptPassAround around a real release.Pass (TestAdoptPassAroundGatesDemoAdoptionOnTheLock). No read added in this unit; read sites unchanged | |
| +| `internal/host/agent.go` `statusLoop` | body | unchanged (7) | the agent (carlos-edge.service, user carlos): the status tick also fills Probes.DemoDisk from readDemoDisk(), nil unless CARLOS_DEMO_BOX is set; statfs of /data and /run, and root's public retention record (readDemoBuilds); report only; no store request added; read sites unchanged | |
| +| `internal/release/adopt.go` `type passConfig` | body | unchanged (0) | adds the beforeStage callback field (WithBeforeStage) and the admitRoute field (WithRouteAdmission), both set only by root's adopt pass; reads nothing | |
| +| `internal/status/snapshot.go` `CollectBox` | body | unchanged (28) | copies Probes.DemoDisk into BoxMetrics.DemoDisk (json demo_disk, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added | |
| +| `internal/release/adopt.go` `PassFilter` | sites | +whole:Route ×2 | the stage check's beforeWrite is cfg.stageWriteCheck (unchanged from round 1); fix round 3: the recovery loop and the adopts predicate also require cfg.routeAdmitted(rt), so a route WithRouteAdmission refuses is kept out of recovery, selection, staging, restaging, reuse and the repoint for the whole pass, exactly as a non-adoptable route is. The two added sites pass the Route already in hand to the admission callback; no new read, and nil admission (every caller but root's adopt pass) admits every route as before | |
| + |
| +Envelopes re-pinned: `.`, `internal/host`, `internal/metrics`, `internal/release`, `internal/status`. |
| + |
| +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. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/host/agent.go` `runAdoptUnderRootRelease`: authority, task B3,E1,E2,E3. Basis: rev3=census-ruling-self-serve-moves-1;basis=root claim/adopt/update controller uid 0: builds root's lifetime judge once from the host-claim switch and hands it to both productionRestartRequestPass calls; read sites unchanged, offsets moved; the preceding B3,E1,E2,E3 classification retained;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the claims shutdown timeout is the host constant claimsShutdownLimit (120s) instead of hostbox.RequestLimit (120s); no read added or changed;rev3=census-ruling-named-unit-delivery-114;basis=config sync is appconfig.SyncUnits with productionUnitOps (drop-in root /etc/systemd/system, base dir /etc/carlos/units, the declaration file /etc/carlos/named-units.json, systemctl probe/reload/restart, the config flock); no proof binding and no bucket read for delivery (Paul's ruling on #114: a root-owned declaration decides); the comment at the restart callback rewritten; read sites unchanged;rev3=census-ruling-sr-followups;basis=#966 census fix: the SyncUnits ack callback is configAckRootFunc(ctx, store) instead of configAckFunc(ctx, store, "adopt"). configAckRootFunc (new, agent.go): on a box with a bucket or dir (doorFleet empty: no fleet identity, or CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR set in the process environment) it returns configAckFunc(ctx, store, "adopt"), the same callback as before #966 (platform-root key, read-then-CAS). On a door box it writes each ack through appconfig.ReplaceConfigAckBlind (new, configack.go) under NewPrefixStore(store, "fleets/<fleet>/"): s.Delete(key) then a create-only s.Put(key, body, ""), returning only errors, which are logged. THE ROOT PASS NO LONGER READS THE FLEET CORNER: it sends exactly DELETE and PUT for fleets/<F>/control/config-ack/<label>/<host>.json and no GET, Open or HEAD of any fleet key; it inspects no body, ETag or listing. Reads only the process environment (doorFleet, BoxLabel), as configAckFunc did. Read sites unchanged;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 4/5: after the restart-only return, calls runNamedUnitsStep, which runs adoptNamedUnitsStep (root reads its own IMDSv2 identity; ssm:GetParameter of /carlos/host/named-units/<instance-id> in that region, operator-written, box role read-only; trusted rootstate reads of /etc/carlos/named-units.json, the console guard marker, root's rollback journal and root history; installs under the config-sync flock), logs, and writes writeNamedUnitsStatus (public root store /var/lib/carlos-named-units), all before ParsePublicKey; config sync moved into adoptConfigSync with a second status write; no input a tenant, app or box agent can write selects the parameter or authorises the install; read sites unchanged;rev3=census-ruling-console-addr-from-install;basis=calls adoptConsoleFleetStep after the named-units step, never fatal (spec §4); no read added here;rev3=census-ruling-managed-fleets-2b2;basis=builds managedRootGate("/") (root's RootAdmission: identity + root 0700 admission files, re-verified) and wraps the round-1 start/selected-restart/rollback callbacks, SyncUnits' UnitOps.Restart and named-unit recovery with it; BYO answers admitted, so nothing changes there; merge of origin/main 65951fbb: main's configAckRootFunc ack, the named-units step (runNamedUnitsStep) with adoptConfigSync, and adoptConsoleFleetStep, not this branch; resolution: adoptConfigSync is handed managedGatedUnitOps(managedGate, productionUnitOps(...)), so SyncUnits' UnitOps.Restart keeps root's gate |
| +- `internal/host/agent.go` `statusLoop`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's context carries the box's lifetime judge; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 953b9fda (its later changes, regional box names and self-serve moves plan 1 among them, under main's own census rulings), where the tick fills rootfs_ready and rootfs_blocked from armedRootfs.Load().probe, which each tick runs NestedOK's checks and asks the control socket's GET /ready/rootfs (never the store); the same four direct sites;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: takes root's GET /egress reader and fills p.Egress = egressStatusProbe(egressStatus, routes, provision.PolicyReadStates()) and p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes); the two added whole:Route sites are the tick's own registry list handed to those two units (decision rows), which read root's control socket and the activator's memory; no store request added; the four existing sites unchanged, offsets moved.;rev3=census-ruling-fleet-alerts-1;basis=the agent (carlos-edge.service, user carlos): the status tick passes os.Geteuid() to alertDeliveryProbe, which fills AlertDelivery.EngineBeat/EngineBeatWhy from engineBeatArmed (the env value and the euid only, no file access, root refused before the path is looked at), and fills Probes.DiskFullETAHours from diskETAProbe(&processDiskTrend, now), a Theil-Sen fit over the metrics loop's in-memory ring of disk readings; the same six sites, no read added, no store request added;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's Probes gain HeldStreams: heldStreamsState(), which calls the edge's in-memory counters function (nil until the edge is ready). No file, bucket or registry access added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: read the detached in-memory replica snapshot source into Probes.ReplicaCopies on the existing five-minute tick. Existing six direct read sites unchanged. No additional bucket request, changed cadence or app lifecycle action.;rev3=census-ruling-agent-start-demo-3;basis=Report moved capability only when the serving edge reports readiness; report claim-seed support only with CARLOS_DEMO_CLAIM=1. Reads the explicit capability flag from the process environment; no new filesystem or registry read.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 fix round 1 (#511 R16 amendment): the status tick also fills Probes.ApplyFinished from systemApplyFinished(release.OptDir()), an Lstat of root's apply journal <opt>/system/router/journal.json in the root-owned, world-readable state directory: finished only when the journal is absent, any other answer unknown and so unfinished. Round 0: Probes.PrevRelease from prevReleaseOf (carlos.prev and carlos.prev.version, the files withMovesFields already reads). Reported in the private BoxMetrics block; no bucket request or cadence change.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the agent (carlos-edge.service, user carlos): the status tick fills p.OfflineMove = offlineMoveFactsProbe(routes); the added whole:Route site is the tick's own registry list handed to that unit, which under a non-root euid lists the names of root's <opt>/live and nothing else; no store request added.;rev3=census-ruling-platform-mail-submission;basis=Task 3 (plan gap G6 (b)): the status tick also fills Probes.MailerArmed from mailerArmed(mailwire.MailerSocket, 2s): a stat of /run/carlos-mailer/mailer.sock and, only when it is a socket, GET /v1/health on it. The agent (carlos-edge.service, user carlos), not root; reported in the private BoxMetrics block only. The same seven sites; no store request, no read of /etc/carlos-mailer (which uid carlos cannot traverse).;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 6: the agent (carlos-edge.service, user carlos) fills Probes.NamedUnits from readNamedUnitsStatus: rootstate.Open(/var/lib/carlos-named-units, false, true) status.json, 64 KiB cap, any error nil; report only, nothing reads it as authority; no store request added; the same sites;rev3=census-ruling-console-addr-from-install;basis=sets Probes.ConsoleFleet from consoleFleetProbe (root public store read, edge in-memory state); no read added in this unit;rev3=census-ruling-instance-usage;basis=the status tick adds one Probes field, InstanceUsageDroppedBytes, from instanceUsageDroppedBytes(): an in-process atomic counter of the per-instance flusher (0 when off); no new read of root-owned state, the same 7 read sites |
| +- `internal/release/adopt.go` `type passConfig`: authority, task E2,E3. Basis: E19: both destructive readers use the root reservation snapshot under existing release exclusion. Exact artifact and containing-tree identities are retained; missing completeness refuses destruction. Production installation/launch/kernel completeness and verified retirement remain unfinished. Fixtures: TestPlan14GenerationDeletionCannotUnpin, TestPlan14GenerationSnapshotCompleteness, TestPlan14GenerationSnapshotPermitsUnreservedRestage, TestPlan14GenerationSnapshotPinsContainingTree, TestPlan14GenerationSnapshotEmptyIsUnknown, TestPlan14GenerationConsumerMode, TestPlan14GenerationProductionModeGate, TestPlan14GenerationSnapshotPermitsFreshTree.;rev3=PROPOSED-p3;run=8;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=stores the typed census-only root update provider and per-pass resolved input authority;rev3=census-ruling-315;identity=legacy agent pass uid carlos (RootRestartsUnits; never set on carlos adopt);basis=adds the unitsToRoot bool set by RootRestartsUnits; reads nothing;rev3=PROPOSED-s3-change-index;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=adds the pointerGate field, set only by WithPointerGate (the agent's fast sweep); reads nothing |
| +- `internal/status/snapshot.go` `CollectBox`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=copies Probes.RootfsReady and RootfsBlocked into BoxMetrics (private, like Layout); the same 28 sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: copies Probes.Egress and Probes.SizeCommittedMiB into BoxMetrics (private, like Layout) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate count is left as is (display);rev3=census-ruling-regional-domains-447;basis=#447 Task 7: copies Probes.AliasesRead into BoxMetrics.AliasesRead (json aliases_read, omitempty) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-alerts-1;basis=copies Probes.DiskFullETAHours into BoxMetrics.DiskFullETAHours (json disk_full_eta_hours, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-edge-held-streams;basis=copies Probes.HeldStreams into BoxMetrics.HeldStreams (json held_streams, omitempty, additive) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: carry already-supplied ReplicaCopies into a separate optional private BoxMetrics replica_copies field; allow copy evidence alone to create the metrics block. Upstreams retains address probes only. Existing 28 Route read sites unchanged; no filesystem, bucket, console or CLI read.;rev3=census-ruling-agent-start-demo-3;basis=Report claim-seed protocol capability only when explicitly configured and runtime moved readiness only when armed; dormant status keeps its original JSON shape. Census read-site delta: unchanged (28).;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 (#511 R16 and its amendment): copies Probes.PrevRelease and Probes.ApplyFinished into BoxMetrics (json prev_release and apply_finished, omitempty; private, like Release) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: copies Probes.OfflineMove into BoxMetrics.OfflineMove (json offline_move, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-platform-mail-submission;basis=Task 3: copies Probes.MailerArmed into BoxMetrics.MailerArmed (json mailer_armed, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 6: copies Probes.NamedUnits into BoxMetrics.NamedUnits (json named_units, omitempty; private) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-seeded-create-2;basis=Copies Probes.SeedsFloor into BoxMetrics.SeedsFloor and counts it in the metrics gate; a pure copy of a value the agent filled, the same 28 read sites, no read added.;rev3=census-ruling-console-addr-from-install;basis=copies Probes.ConsoleFleet into BoxMetrics (private); no read added;rev3=census-ruling-instance-usage;basis=copies Probes.InstanceUsageDroppedBytes into Box.InstanceUsageDroppedBytes (omitempty, a count only); the same 28 sites, no read added |
| +- `internal/release/adopt.go` `PassFilter`: authority, task B3,E3,J1,E1,E2. Basis: Signed named-unit recovery is independent of release and health history. Root rechecks canonical source, unit, process, signed target and trusted live pointer; captures attempt authority before publication; verifies readiness and resumes without repeated effects. Fixtures: TestPlan14SignedActiveFixIgnoresHistory, TestPlan14SignedActiveFixAuthority, TestPlan14SignedFixSupersedesOlderAttempt, TestPlan14ActiveRecoveryProcessCrash, TestPlan14SignedRestartWithoutHealthHistory, TestPlan14CapturedRollbackWithoutHealthHistory, TestPlan14SignedRestartRequiresTrustedLiveLink. E7 applies merge ruling 4: unbound no-census routes use the legacy pass and restart; ordinary candidates make no binding store call. Fixtures: TestR2UnguardedERecoveryUpdate, TestR2UnguardedERecoveryIncidentRecipe, TestPlan14ERecoveryBindingRefusalKeepsPromotedFix. E19: both destructive readers use the root reservation snapshot under existing release exclusion. Exact artifact and containing-tree identities are retained; missing completeness refuses destruction. Production installation/launch/kernel completeness and verified retirement remain unfinished. Fixtures: TestPlan14GenerationDeletionCannotUnpin, TestPlan14GenerationSnapshotCompleteness, TestPlan14GenerationSnapshotPermitsUnreservedRestage, TestPlan14GenerationSnapshotPinsContainingTree, TestPlan14GenerationSnapshotEmptyIsUnknown, TestPlan14GenerationConsumerMode.;rev3=PROPOSED-p3;run=8;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=resolves protected route inputs before filters, recovery and dispatch on census boxes and bypasses service-owned failure opener only there;rev3=PROPOSED-s3-change-index;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=asks the optional pointer gate (gatePointers) once per channel group before selection and reports each group's pointer outcome to it; only the agent's fast sweep arms a gate (WithPointerGate), so under carlos adopt the gate is nil and the pass is unchanged; a gate can only leave a group out of the pass, never add one; one whole-Route site added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate check is left as is for a resident;rev3=census-ruling-hunt-release-chain-integrity;basis=a digestless head is bound to its signed promotion record through stagePointerHead, and a pointer without an account binding is refused on read (verifyPointer); the ratchet it consults (Admit) now also holds a per-channel promoted_at floor that admits only a strictly later stamp or the very pointer it recorded (PointerIdentity, fix round 1), which root reads only from its own root-owned <opt>/pointer-digests and never from the agent's data dir, through instancefs.ReadBeneathLimitOrAbsent (openat2 RESOLVE_BENEATH|NO_SYMLINKS|NO_MAGICLINKS, O_NONBLOCK, regular file only, 4 KiB cap); fix round 2: the floor's identity is the sha256 of the exact signed wrapper the pointer was verified from (set at the parse site), and a floor with no identity admits nothing at its own stamp, so the floor only refuses more; no read kind is added to the unit; CI fix: an app channel pointer is now stamped to the millisecond (pointerStampGrain) so a signer's wait past the head it replaces is at most a millisecond; the floor still admits only a strictly later stamp or the pointer it recorded, compared as time.Time, so the rule and the reads are unchanged |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `cli.go:printDemoDisk`: reads +data-literal; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demodisk_status.go:const#1`: reads +data-literal ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demodisk_status.go:productionDemoDiskProbe`: reads +file:Open; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demodisk_status.go:readDemoBuilds`: reads +file:Read; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoOutput.spellings`: reads +file:EvalSymlinks; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.admitRoute`: reads +registry:App ×3, +whole:Route; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.demoAdoptions`: reads +registry:App, +registry:Host, +registry:Version, +whole:Route ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.listOutputs`: reads +file:ReadDir ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.pinSet`: reads +registry:App ×2, +registry:GoodVersion, +registry:PrevVersion, +registry:Version, +whole:Route ×5; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.saveStatus`: reads +file:Read; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.selection`: reads +registry:App ×6, +registry:Version ×2, +whole:Route ×8; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:demoRetention.validDemoRow`: reads +registry:App, +registry:DemoExpiresAt, +registry:DemoHost, +registry:DemoID, +registry:DemoLifetime ×2, +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:linkTargets`: reads +file:EvalSymlinks, +file:ReadDir, +file:Readlink; written legacy, accepted-legacy, frozen |
| +- new `internal/host/demoretention.go:productionDemoRetention`: reads +file:Open; written legacy, accepted-legacy, frozen |
| +- new `internal/host/statfs_unix.go:filesystemRoom`: reads +file:Statfs; written legacy, accepted-legacy, frozen |
| +- new `internal/release/adopt.go:WithRouteAdmission`: reads +registry:Host ×3, +whole:Route; written legacy, accepted-legacy, frozen |
| +- new `internal/release/adopt.go:passConfig.routeAdmitted`: reads +whole:Route; written legacy, accepted-legacy, frozen |
| +- new `internal/release/adopt.go:passConfig.stageWriteCheck`: reads +file:Lstat; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `161480ee42d34728c5aed23cb86d36aa5651ed915b43d28eb659f84d7702e897` → `0586b6f6d50249a42fbf72bb02545476c042d1c8a357c91d75432315997ae7a3`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-demo-disk-slice1-retention.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-proposal-instance-senders-1.md b/docs/superpowers/notes/census-proposal-instance-senders-1.md| index 04508e7d7..d5cd6376d 100644 |
| --- a/docs/superpowers/notes/census-proposal-instance-senders-1.md |
| +++ b/docs/superpowers/notes/census-proposal-instance-senders-1.md |
| @@ -6,6 +6,6 @@ Envelopes re-pinned: `.`, `internal/mailer`, `internal/mailsubmit`, `internal/ma |
| 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. |
| -Seal: `161480ee42d34728c5aed23cb86d36aa5651ed915b43d28eb659f84d7702e897` → `161480ee42d34728c5aed23cb86d36aa5651ed915b43d28eb659f84d7702e897`. |
| +Seal: `0586b6f6d50249a42fbf72bb02545476c042d1c8a357c91d75432315997ae7a3` → `0586b6f6d50249a42fbf72bb02545476c042d1c8a357c91d75432315997ae7a3`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-instance-senders-1.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 386b5c544..9af6cbe4a 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -5183,8 +5183,10 @@ func statusLoop(reg *registry.Registry, svc *activator.Service, buildStates func |
| MemTotalBytes: memTotal, |
| MemAvailBytes: memAvail, |
| Load1: readLoad1(), |
| - DiskFreeBytes: readDiskFreeBytes(), |
| - Release: version.Build, |
| + // DemoDisk: a demo box's room on /data and /run and its kept |
| + // demo builds (demo disk bound, slice 1); nil on any other box. |
| + DiskFreeBytes: readDiskFreeBytes(), DemoDisk: readDemoDisk(), |
| + Release: version.Build, |
| // carlos.prev's release, so the console can tell whether a |
| // failed apply here could restore a build below the |
| // stateless replicas floor (#511 R16). |
| @@ -6307,9 +6309,13 @@ func runAdoptUnderRootRelease(args []string, buildClaims ClaimFactory, ensureUni |
| // adopt a proven head over it (final review H4). After it, mint on a |
| // proving box and, on the hourly pass, say when a requirement is off; |
| // a route the pass changed is looked at again first. |
| - passErr := pr.around(ctx, func() error { |
| - return release.Pass(ctx, reg, store, pub, release.OptDir(), restart, passOpts...) |
| - }) |
| + // The demo disk bound's build-output retention (demoretention.go): the |
| + // pending-output cleanup before a demo app's new output is staged, and |
| + // retention after a pass that adopted a demo version, or on the hourly |
| + // pass. Both only under this pass's lock, held until the pass returns. |
| + passErr := pr.around(ctx, adoptPassAround(ctx, *configOnly, *restartOnly, *stageOnly, passLockErr, productionDemoRetentionFor(reg, generationPins), func(demo ...release.PassOption) error { |
| + return release.Pass(ctx, reg, store, pub, release.OptDir(), restart, append(passOpts, demo...)...) |
| + })) |
| if passErr != nil { |
| log.Printf("adopt: %v", passErr) |
| } |
diff --git a/internal/host/alertsink.go b/internal/host/alertsink.go| index d07e3d421..89ac9e7da 100644 |
| --- a/internal/host/alertsink.go |
| +++ b/internal/host/alertsink.go |
| @@ -419,7 +419,15 @@ func alertSentence(ev metrics.Event) string { |
| name, subject := metrics.SplitRule(ev.Rule) |
| switch name { |
| case "disk": |
| - return fmt.Sprintf("disk is %s full on %s", pct(ev.Value), ev.Box) |
| + fs, inodes := strings.CutSuffix(ev.Where, " inodes") |
| + switch { |
| + case ev.Where == "": |
| + return fmt.Sprintf("disk is %s full on %s", pct(ev.Value), ev.Box) |
| + case inodes: |
| + return fmt.Sprintf("%s has used %s of its inodes on %s", fs, pct(ev.Value), ev.Box) |
| + default: |
| + return fmt.Sprintf("%s is %s full on %s", ev.Where, pct(ev.Value), ev.Box) |
| + } |
| case "mem": |
| return fmt.Sprintf("memory use is %s on %s", pct(ev.Value), ev.Box) |
| case "cpu": |
| @@ -443,7 +451,15 @@ func alertClearSentence(ev metrics.Event) string { |
| name, subject := metrics.SplitRule(ev.Rule) |
| switch name { |
| case "disk": |
| - return fmt.Sprintf("disk is back to %s full on %s", pct(ev.Value), ev.Box) |
| + fs, inodes := strings.CutSuffix(ev.Where, " inodes") |
| + switch { |
| + case ev.Where == "": |
| + return fmt.Sprintf("disk is back to %s full on %s", pct(ev.Value), ev.Box) |
| + case inodes: |
| + return fmt.Sprintf("%s is back to %s of its inodes used on %s", fs, pct(ev.Value), ev.Box) |
| + default: |
| + return fmt.Sprintf("%s is back to %s full on %s", ev.Where, pct(ev.Value), ev.Box) |
| + } |
| case "mem": |
| return fmt.Sprintf("memory use is back to %s on %s", pct(ev.Value), ev.Box) |
| case "cpu": |
diff --git a/internal/host/demodisk_status.go b/internal/host/demodisk_status.go| new file mode 100644 |
| index 000000000..a27652e34 |
| --- /dev/null |
| +++ b/internal/host/demodisk_status.go |
| @@ -0,0 +1,120 @@ |
| +// A demo box's disk numbers (demo disk bound plan, slice 1): box status |
| +// reports the room on /data and /run in bytes and inodes and the demo |
| +// builds root keeps, and the disk alert reads the highest use of any of |
| +// them, so a demo that fills the inodes or /run is warned about before the |
| +// box goes down. |
| +package host |
| + |
| +import ( |
| + "encoding/json" |
| + "os" |
| + |
| + "github.com/carlosframework/platform/internal/rootstate" |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| + |
| +// demoRunDir is the tmpfs demo run dirs live on today (/run/carlos/instances). |
| +const demoRunDir = "/run" |
| + |
| +// demoDiskProbe is the status tick's and the alert loop's reading on a demo |
| +// box (CARLOS_DEMO_BOX set, valid or not: a misconfigured demo box is still |
| +// one), nil on any other. room is a filesystem's statfs; builds is root's |
| +// retention record. A part that does not read is absent. |
| +func demoDiskProbe(getenv func(string) string, room func(string) (*status.FilesystemRoom, error), builds func() (*status.DemoBuilds, error)) func() *status.DemoDisk { |
| + if getenv("CARLOS_DEMO_BOX") == "" { |
| + return nil |
| + } |
| + return func() *status.DemoDisk { |
| + d := &status.DemoDisk{} |
| + if r, err := room(dataDir()); err == nil { |
| + d.Data = r |
| + } |
| + if r, err := room(demoRunDir); err == nil { |
| + d.Run = r |
| + } |
| + if b, err := builds(); err == nil { |
| + d.Builds = b |
| + } |
| + return d |
| + } |
| +} |
| + |
| +// productionDemoDiskProbe is demoDiskProbe on this box. |
| +func productionDemoDiskProbe() func() *status.DemoDisk { |
| + return demoDiskProbe(os.Getenv, filesystemRoom, func() (*status.DemoBuilds, error) { |
| + return readDemoBuilds(func() (rootstate.Store, error) { return rootstate.Open(demoRetentionDir, false, true) }) |
| + }) |
| +} |
| + |
| +// readDemoBuilds reads root's retention record (demoretention.go) as the |
| +// agent may: a root-owned public directory, by descriptor. |
| +func readDemoBuilds(open func() (rootstate.Store, error)) (*status.DemoBuilds, error) { |
| + s, err := open() |
| + if err != nil { |
| + return nil, err |
| + } |
| + defer s.Close() |
| + raw, err := s.Read(demoRetentionRecord) |
| + if err != nil { |
| + return nil, err |
| + } |
| + var rec demoRetentionStatus |
| + if err := json.Unmarshal(raw, &rec); err != nil { |
| + return nil, err |
| + } |
| + if rec.Schema != 1 { |
| + return nil, os.ErrInvalid |
| + } |
| + return &status.DemoBuilds{Outputs: rec.Outputs, OutputBytes: rec.OutputBytes, At: rec.At, Backlog: rec.Backlog, BacklogSince: rec.BacklogSince, Held: rec.Held}, nil |
| +} |
| + |
| +// diskReading is one filesystem's use and what was measured, which the |
| +// disk alert names. |
| +type diskReading struct { |
| + frac float64 |
| + where string |
| +} |
| + |
| +// What a demo box's disk alert measured (alertSentence names it). |
| +const ( |
| + diskWhereData = "/data" |
| + diskWhereDataInodes = "/data inodes" |
| + diskWhereRun = "/run" |
| + diskWhereRunInodes = "/run inodes" |
| +) |
| + |
| +// demoDiskFill is the highest use of anything d read: /data's blocks and |
| +// inodes, and /run's bytes and inodes. nil when d read nothing. |
| +func demoDiskFill(d *status.DemoDisk) *diskReading { |
| + if d == nil { |
| + return nil |
| + } |
| + var fill *diskReading |
| + higher := func(free, total int64, where string) { |
| + if total <= 0 || free < 0 || free > total { |
| + return |
| + } |
| + f := 1 - float64(free)/float64(total) |
| + if fill == nil || f > fill.frac { |
| + fill = &diskReading{frac: f, where: where} |
| + } |
| + } |
| + if r := d.Data; r != nil { |
| + higher(r.FreeBytes, r.Bytes, diskWhereData) |
| + higher(r.FreeInodes, r.Inodes, diskWhereDataInodes) |
| + } |
| + if r := d.Run; r != nil { |
| + higher(r.FreeBytes, r.Bytes, diskWhereRun) |
| + higher(r.FreeInodes, r.Inodes, diskWhereRunInodes) |
| + } |
| + return fill |
| +} |
| + |
| +// readDemoDisk is the status tick's reading: nil on a box that is not a |
| +// demo box. |
| +func readDemoDisk() *status.DemoDisk { |
| + if p := productionDemoDiskProbe(); p != nil { |
| + return p() |
| + } |
| + return nil |
| +} |
diff --git a/internal/host/demodisk_status_test.go b/internal/host/demodisk_status_test.go| new file mode 100644 |
| index 000000000..77a3ac3ed |
| --- /dev/null |
| +++ b/internal/host/demodisk_status_test.go |
| @@ -0,0 +1,198 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "math" |
| + "os" |
| + "path/filepath" |
| + "reflect" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/metrics" |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/rootstate" |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| + |
| +func demoBoxEnv(on bool) func(string) string { |
| + return func(k string) string { |
| + if on && k == "CARLOS_DEMO_BOX" { |
| + return "1" |
| + } |
| + return "" |
| + } |
| +} |
| + |
| +// The status numbers are read only on a demo box: /data and /run by statfs, |
| +// and the kept builds from root's retention record. |
| +func TestDemoDiskProbeReadsDataRunAndTheRecord(t *testing.T) { |
| + rooms := map[string]*status.FilesystemRoom{ |
| + dataDir(): {FreeBytes: 10, Bytes: 100, FreeInodes: 5, Inodes: 50}, |
| + "/run": {FreeBytes: 1, Bytes: 2, FreeInodes: 3, Inodes: 4}, |
| + } |
| + room := func(dir string) (*status.FilesystemRoom, error) { |
| + if r, ok := rooms[dir]; ok { |
| + return r, nil |
| + } |
| + return nil, os.ErrNotExist |
| + } |
| + since := time.Date(2026, 11, 29, 1, 0, 0, 0, time.UTC) |
| + builds := func() (*status.DemoBuilds, error) { |
| + return &status.DemoBuilds{Outputs: 2, OutputBytes: 64, Backlog: 1, BacklogSince: since}, nil |
| + } |
| + if p := demoDiskProbe(demoBoxEnv(false), room, builds); p != nil { |
| + t.Fatal("a box that is not a demo box has a demo disk probe") |
| + } |
| + got := demoDiskProbe(demoBoxEnv(true), room, builds)() |
| + if got == nil || *got.Data != *rooms[dataDir()] || *got.Run != *rooms["/run"] || got.Builds.Outputs != 2 || !got.Builds.BacklogSince.Equal(since) { |
| + t.Fatalf("probe = %+v", got) |
| + } |
| + // Each part that does not read is absent, never zero. |
| + none := demoDiskProbe(demoBoxEnv(true), func(string) (*status.FilesystemRoom, error) { return nil, os.ErrPermission }, |
| + func() (*status.DemoBuilds, error) { return nil, os.ErrNotExist })() |
| + if none == nil || none.Data != nil || none.Run != nil || none.Builds != nil { |
| + t.Fatalf("unread parts = %+v", none) |
| + } |
| +} |
| + |
| +// The record root writes is what the agent reads back, field for field. |
| +func TestDemoBuildsReadsRootsRecord(t *testing.T) { |
| + disk := &rollbackDisk{dir: t.TempDir()} |
| + since := time.Date(2026, 11, 29, 1, 0, 0, 0, time.UTC) |
| + r := &demoRetention{box: retentionDemo, record: func() (rootstate.Store, error) { return disk, nil }, now: func() time.Time { return since }, logf: t.Logf} |
| + r.saveStatus(demoRetentionResult{outputs: 3, outputBytes: 96, backlog: 2, err: errors.New("lock")}) |
| + got, err := readDemoBuilds(func() (rootstate.Store, error) { return disk, nil }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + want := status.DemoBuilds{Outputs: 3, OutputBytes: 96, At: since, Backlog: 2, BacklogSince: since} |
| + if !reflect.DeepEqual(*got, want) { |
| + t.Fatalf("read %+v, want %+v", *got, want) |
| + } |
| + if _, err := readDemoBuilds(func() (rootstate.Store, error) { return &rollbackDisk{dir: t.TempDir()}, nil }); err == nil { |
| + t.Fatal("no record read as a record") |
| + } |
| +} |
| + |
| +// The disk alert's reading on a demo box is the highest use of blocks and |
| +// inodes over /data and /run: inodes alone can carry it. |
| +func TestDemoDiskFillIsTheHighestUse(t *testing.T) { |
| + d := &status.DemoDisk{ |
| + Data: &status.FilesystemRoom{FreeBytes: 90, Bytes: 100, FreeInodes: 4, Inodes: 100}, |
| + Run: &status.FilesystemRoom{FreeBytes: 50, Bytes: 100, FreeInodes: 80, Inodes: 100}, |
| + } |
| + if got := demoDiskFill(d); got == nil || math.Abs(got.frac-0.96) > 1e-9 || got.where != diskWhereDataInodes { |
| + t.Fatalf("fill = %+v, want the /data inodes' 0.96", got) |
| + } |
| + d.Run.FreeBytes = 1 |
| + if got := demoDiskFill(d); got == nil || math.Abs(got.frac-0.99) > 1e-9 || got.where != diskWhereRun { |
| + t.Fatalf("fill = %+v, want /run bytes' 0.99", got) |
| + } |
| + d.Run.FreeBytes, d.Data.FreeBytes = 50, 0 |
| + if got := demoDiskFill(d); got == nil || got.frac != 1 || got.where != diskWhereData { |
| + t.Fatalf("fill = %+v, want /data's blocks", got) |
| + } |
| + d.Data.FreeBytes, d.Run.FreeInodes = 90, 0 |
| + if got := demoDiskFill(d); got == nil || got.frac != 1 || got.where != diskWhereRunInodes { |
| + t.Fatalf("fill = %+v, want /run's inodes", got) |
| + } |
| + if demoDiskFill(nil) != nil || demoDiskFill(&status.DemoDisk{Data: &status.FilesystemRoom{}}) != nil { |
| + t.Fatal("no reading made a fill") |
| + } |
| +} |
| + |
| +// The disk incident on a demo box fires on inodes alone, and clears when |
| +// they are freed, through the alerts engine (alertTick) as the loop runs it. |
| +func TestAlertTickFiresDiskOnInodesAlone(t *testing.T) { |
| + ctx := context.Background() |
| + s := release.NewDirStore(t.TempDir()) |
| + statePath := filepath.Join(t.TempDir(), "alerts.json") |
| + st := metrics.AlertState{V: 1, Box: "box-1", Rules: map[string]metrics.RuleState{}} |
| + rules := metrics.DefaultRules() |
| + blocks := 0.10 |
| + at := time.Date(2026, 11, 29, 12, 0, 0, 0, time.UTC) |
| + tick := func(fill *diskReading) { |
| + t.Helper() |
| + at = at.Add(time.Minute) |
| + if err := alertTick(ctx, s, "box-1", rules, &st, metrics.Sample{At: at, Host: metrics.HostSample{DiskFrac: &blocks}}, alertReadings{demoFill: fill}, statePath, nil, nil, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + tick(nil) |
| + if st.Rules["disk"].Firing { |
| + t.Fatal("disk fired at 10% blocks") |
| + } |
| + tick(&diskReading{frac: 0.97, where: diskWhereDataInodes}) |
| + if !st.Rules["disk"].Firing { |
| + t.Fatalf("disk did not fire with inodes 97%% used: %+v", st.Rules["disk"]) |
| + } |
| + tick(&diskReading{frac: 0.30, where: diskWhereDataInodes}) |
| + if st.Rules["disk"].Firing { |
| + t.Fatalf("disk still firing after the inodes were freed: %+v", st.Rules["disk"]) |
| + } |
| + raw, err := os.ReadFile(statePath) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var persisted metrics.AlertState |
| + if err := json.Unmarshal(raw, &persisted); err != nil || persisted.Rules["disk"].Firing { |
| + t.Fatalf("persisted state: %s %v", raw, err) |
| + } |
| +} |
| + |
| +// With no host disk reading on a tick, a full /run alone still fires the |
| +// disk incident: the rule reads the highest of the readings it has. The |
| +// message names /run, the filesystem it measured. |
| +func TestAlertTickFiresDiskOnRunWithoutAHostReading(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + st := metrics.AlertState{V: 1, Box: "box-1", Rules: map[string]metrics.RuleState{}} |
| + var bodies [][]byte |
| + sinks := webhookSinks("https://example.test/hook", func(_ string, body []byte) error { |
| + bodies = append(bodies, body) |
| + return nil |
| + }) |
| + at := time.Date(2026, 11, 29, 12, 0, 0, 0, time.UTC) |
| + if err := alertTick(context.Background(), s, "box-1", metrics.DefaultRules(), &st, metrics.Sample{At: at}, alertReadings{demoFill: &diskReading{frac: 0.99, where: diskWhereRun}}, filepath.Join(t.TempDir(), "alerts.json"), sinks, nil, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !st.Rules["disk"].Firing { |
| + t.Fatalf("disk did not fire with /run 99%% used and no host reading: %+v", st.Rules["disk"]) |
| + } |
| + var ev metrics.Event |
| + if len(bodies) != 1 || json.Unmarshal(bodies[0], &ev) != nil || ev.Where != diskWhereRun { |
| + t.Fatalf("delivered %s, want the event naming /run", bodies) |
| + } |
| + subject, _ := formatAlert(metrics.DefaultRules(), at, ev) |
| + if want := "carlos alert: /run is 99% full on box-1"; subject != want { |
| + t.Fatalf("subject %q, want %q", subject, want) |
| + } |
| +} |
| + |
| +// A demo box's disk message names what it measured; any other box's is as |
| +// it was. |
| +func TestFormatAlertNamesTheFilesystemMeasured(t *testing.T) { |
| + at := time.Date(2026, 11, 29, 12, 0, 0, 0, time.UTC) |
| + for _, c := range []struct { |
| + where string |
| + firing bool |
| + wantSubject string |
| + }{ |
| + {"", true, "carlos alert: disk is 97% full on box-1"}, |
| + {diskWhereData, true, "carlos alert: /data is 97% full on box-1"}, |
| + {diskWhereDataInodes, true, "carlos alert: /data has used 97% of its inodes on box-1"}, |
| + {diskWhereRun, true, "carlos alert: /run is 97% full on box-1"}, |
| + {diskWhereRunInodes, true, "carlos alert: /run has used 97% of its inodes on box-1"}, |
| + {diskWhereRunInodes, false, "carlos alert cleared: /run is back to 97% of its inodes used on box-1"}, |
| + {diskWhereDataInodes, false, "carlos alert cleared: /data is back to 97% of its inodes used on box-1"}, |
| + {diskWhereRun, false, "carlos alert cleared: /run is back to 97% full on box-1"}, |
| + } { |
| + subject, body := formatAlert(metrics.DefaultRules(), at, metrics.Event{Rule: "disk", Firing: c.firing, Value: 0.97, Box: "box-1", Where: c.where}) |
| + if subject != c.wantSubject || !strings.Contains(body, strings.TrimPrefix(strings.TrimPrefix(c.wantSubject, "carlos alert cleared: "), "carlos alert: ")) { |
| + t.Errorf("%q firing=%v: subject %q, body %q", c.where, c.firing, subject, body) |
| + } |
| + } |
| +} |
diff --git a/internal/host/demoretention.go b/internal/host/demoretention.go| new file mode 100644 |
| index 000000000..18f1185ff |
| --- /dev/null |
| +++ b/internal/host/demoretention.go |
| @@ -0,0 +1,990 @@ |
| +// Bounded build-output retention for demo apps (demo disk bound plan, |
| +// slice 1; spec 2026-11-29-demo-disk-bound-design.md §15 Q4). |
| +// |
| +// Every demo update stages a new build of up to 32 MiB under |
| +// <opt>/versions/<ver>/<account>/<app>, and before this nothing removed one |
| +// until the demo's purge: up to 61 builds a demo. Retention deletes a demo |
| +// app's outputs that nothing on the box still names, after every adoption of |
| +// a demo version and on the hourly pass, and the pending-output cleanup |
| +// below keeps at most one unpinned output a demo app has not adopted. |
| +// |
| +// The deletion-safety contract: |
| +// - what may be deleted is decided from root's own facts only: the box's |
| +// demo account from host.env (demo.BoxConfig, the whole tuple valid) |
| +// and the tmp-demo-<public name> outputs root lists under |
| +// <ver>/<demo account>/ in its own version store, each name validated |
| +// (demo.ValidPublicName: one path component, no "." or "..") before it |
| +// is used in any path. The demo account is the dedicated holding |
| +// account (README, demo setup); the console reserves the tmp-demo- |
| +// prefix for demos in every account (reservedAppName) and never places |
| +// a demo in the ops account. Registry rows are the service's, so they |
| +// only ADD protection: their pins, and a row that runs one of these |
| +// apps as anything but a valid demo binding keeps all of its builds; |
| +// - pins from every source, read in full: the live links (and their |
| +// previous links), every registry row's Version, PrevVersion and |
| +// GoodVersion and its settings references (release.BoxPins), the |
| +// generations file (release.GenerationPins) and root's generation |
| +// ledger (productionRootGenerationPins). A source that does not read in |
| +// full deletes nothing, except that an app whose own settings |
| +// references did not read (release.IncompleteRefsError) holds only |
| +// that app. A pin keeps every output at, inside or beneath it, under |
| +// the store's spelling or its real path, so a reserved tree |
| +// (<ver>/<account>, <ver>) keeps everything in it; |
| +// - only with the adopt pass lock held (lockAdoptPass), which RunAdopt |
| +// holds from before the first pin read until after the last removal; |
| +// - per app: <ver>/<account>/<app> and its .manifest.json, beneath the |
| +// version store with no symlinks, as purgeDemoVersions removes them. |
| +// Never a whole version directory, which can hold other apps; the |
| +// time-graced sweep (release.SweepStaged) stays the only remover of |
| +// those; |
| +// - pending outputs: a version staged after every version the app's live |
| +// links name is in flight. Retention keeps the newest one and removes |
| +// older ones (a box upgraded with failed outputs piled up); names it |
| +// cannot order are kept and counted as backlog; |
| +// - non-demo apps are never touched. |
| +// |
| +// Outside the lock and the hook: the agent's own stage passes (adoptLoop |
| +// and fastTick in agent.go, passLegs.run in changeindex.go) stage without |
| +// lockAdoptPass and without beforeStage, and a move's held stage |
| +// (heldStagePass, release.stageHeld in internal/release/materializeheld.go) |
| +// stages without beforeStage. This is safe only because a hardened demo |
| +// box's agent cannot write the version store: there every demo stage is |
| +// root's adopt pass, relayed through carlos-stage.service. Where an agent |
| +// could write the store, neither the pending-output bound nor the lock |
| +// would hold, and a cleanup could remove a build an agent pass is |
| +// adopting. |
| +// |
| +// Admission and holds: a demo route is adopted, reused or restaged only by |
| +// a pass that holds the lock on a correctly configured demo box |
| +// (admitRoute, release.WithRouteAdmission, before the pass touches it). An |
| +// app held by a registry row that is not a valid demo binding, or by |
| +// unread settings references, keeps every build, is named with the reason |
| +// in the record and in box status, and stages nothing new until the hold |
| +// clears. |
| +// |
| +// The backlog is an accounting invariant (demoBacklog), not a by-product of |
| +// what retention may delete: for each app, the larger of the outputs it |
| +// keeps above its bound (8 plus those a generation reserves), however they |
| +// are pinned or held, and the outputs retention should have removed and |
| +// did not. |
| +// |
| +// The bound per demo app is (8 + G + R) x 32 MiB: six registry and |
| +// settings pins (Version, PrevVersion, GoodVersion, the settings pin, |
| +// LastExecuted, the resolved target), the previous link (after a failed |
| +// adoption rolls back it names the failed build, which no row names), one |
| +// pending output, G generations-file pins for the app, and R, the reserved |
| +// trees on the box that cover one of the app's outputs. A root |
| +// generation's Tree is the directory of its executable, <ver>/<demo |
| +// account>, shared by every demo, and demo versions all count from 1, so |
| +// one native demo's reservation at demo.n keeps every demo's demo.n output: |
| +// R can be as large as the number of distinct reserved versions on the box. |
| +// - gVisor demos (no generations): G = R = 0, 256 MiB a demo, 5.0 GiB for |
| +// 20. |
| +// - native demos, one reservation each at distinct versions and G = 1: |
| +// R <= 20 with 20 demos, (8 + 1 + 20) x 32 MiB = 928 MiB a demo, about |
| +// 18.1 GiB for 20. |
| +// |
| +// Assumptions: executable bytes only (manifests, directories and |
| +// filesystem overhead are extra); the live link names the row's Version, |
| +// which is not so after a repoint whose registry stamp failed |
| +// (release.adoptHost): then the live link's build is one more until the |
| +// next stamp. |
| +package host |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "log" |
| + "os" |
| + "path/filepath" |
| + "slices" |
| + "sort" |
| + "strconv" |
| + "strings" |
| + "syscall" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/demo" |
| + "github.com/carlosframework/platform/internal/instancefs" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/rootstate" |
| +) |
| + |
| +// demoRetentionDir is root's public record of the last retention run, which |
| +// the agent reads for box status. Root-owned and written by descriptor |
| +// (rootstate), so nothing the agent can write is ever read back by root as |
| +// a pin or a decision: the record is status only. |
| +const ( |
| + demoRetentionDir = "/var/lib/carlos-release/demo-retention" |
| + demoRetentionRecord = "status" |
| +) |
| + |
| +// demoRetentionStatus is the record: what the last run left, and the |
| +// backlog, the demo outputs held beyond the bound because a run could not |
| +// delete them, with when that began. |
| +type demoRetentionStatus struct { |
| + Schema int `json:"schema"` |
| + At time.Time `json:"at"` |
| + Outputs int `json:"outputs"` |
| + OutputBytes int64 `json:"output_bytes"` |
| + Backlog int `json:"backlog"` |
| + BacklogSince time.Time `json:"backlog_since,omitzero"` |
| + Reason string `json:"reason,omitempty"` |
| + // Held is every held app as "<app>: <why>": it keeps every build and |
| + // its updates are refused until the hold is cleared. |
| + Held []string `json:"held,omitempty"` |
| +} |
| + |
| +type demoRetention struct { |
| + box demo.Config |
| + // boxErr: host.env says this is a demo box (CARLOS_DEMO_BOX) but its |
| + // demo settings are invalid (demo.BoxConfig). |
| + boxErr error |
| + reg routeLister |
| + optDir string |
| + genPath string |
| + rootPins release.PinSource |
| + // locked: the caller holds the adopt pass lock. Without it retention |
| + // deletes nothing and the pending-output cleanup refuses the stage. |
| + locked bool |
| + record func() (rootstate.Store, error) |
| + now func() time.Time |
| + remove func(dir, name string) error |
| + logf func(string, ...any) |
| + // Witness seams: called before the first pin read of a selection and |
| + // before each removal. |
| + onPins func() |
| + onRemove func(path string) |
| +} |
| + |
| +// productionDemoRetention is RunAdopt's: the box's demo settings from |
| +// host.env, the version store and generations file, root's generation |
| +// ledger and its public record directory. |
| +func productionDemoRetention(reg routeLister, rootPins release.PinSource, locked bool) *demoRetention { |
| + box, err := demo.BoxConfig(os.Getenv) |
| + if err != nil { |
| + log.Printf("adopt: demo build retention off: %v", err) |
| + box = demo.Config{} |
| + } |
| + return &demoRetention{box: box, boxErr: err, reg: reg, optDir: release.OptDir(), genPath: release.GenerationsPath(dataDir()), |
| + rootPins: rootPins, locked: locked, now: time.Now, remove: instancefs.RemoveAllBeneath, logf: log.Printf, |
| + record: func() (rootstate.Store, error) { return rootstate.Open(demoRetentionDir, true, true) }} |
| +} |
| + |
| +type demoAppKey struct{ acct, app string } |
| + |
| +// demoOutput is one app's build at one version: the executable and its |
| +// manifest, either of which may be all that is left. |
| +type demoOutput struct { |
| + demoAppKey |
| + version string |
| + bytes int64 |
| + // pinned: a pin names it or a path above or inside it, or it is the |
| + // version about to be staged. |
| + pinned bool |
| + // held says why nothing of its app is removed and its app stages |
| + // nothing new: a registry row runs the app as something other than a |
| + // valid demo binding, or its settings references did not read in full |
| + // (release.IncompleteRefsError). "" when neither. |
| + held string |
| + // inFlight: staged after every version its app's live links name. |
| + inFlight bool |
| + // reserved: a generations-file or root generation pin covers it, so it |
| + // counts toward its app's G + R rather than against the bound. |
| + reserved bool |
| +} |
| + |
| +// demoOutputBound is the outputs a demo app may keep besides those a |
| +// generation reserves: six registry and settings pins, the previous link |
| +// and one pending output (the 8 of 8 + G + R). |
| +const demoOutputBound = 8 |
| + |
| +func (o demoOutput) path(optDir string) string { |
| + return release.VersionPath(optDir, o.acct, o.version, o.app) |
| +} |
| + |
| +// spellings is the output's path under the store's own name and, when its |
| +// directory resolves, under its real path. |
| +func (o demoOutput) spellings(optDir string) []string { |
| + exe := o.path(optDir) |
| + out := []string{exe} |
| + if real, err := filepath.EvalSymlinks(filepath.Dir(exe)); err == nil { |
| + if p := filepath.Join(real, o.app); p != exe { |
| + out = append(out, p) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// errDemoAccountIsOps refuses a demo box whose demo account is the ops |
| +// account: its builds would share <ver>/ with every ops app (VersionPath's |
| +// pre-accounts layout), and the console never places a demo there |
| +// (internal/console demo_store.go refuses the ops account), so such a box is |
| +// misconfigured. Every demo stage is refused and retention deletes nothing. |
| +var errDemoAccountIsOps = errors.New("the demo account is the ops account, which never holds demos; demo builds are refused on this box until CARLOS_DEMO_ACCOUNT names the holding account") |
| + |
| +// demoAccount is the account whose tmp-demo- apps are this box's demos: |
| +// host.env's CARLOS_DEMO_ACCOUNT, which demo.BoxConfig validated with the |
| +// rest of the tuple, and never the ops account. |
| +func (r *demoRetention) demoAccount() (string, error) { |
| + acct := r.box.Account |
| + if acct == release.OpsAccount { |
| + return "", errDemoAccountIsOps |
| + } |
| + if !oneStoreName(acct) { |
| + return "", fmt.Errorf("the demo account %q is not one path name", acct) |
| + } |
| + return acct, nil |
| +} |
| + |
| +// oneStoreName: s is exactly one path component, neither "." nor "..". |
| +func oneStoreName(s string) bool { |
| + return s != "" && s != "." && s != ".." && !strings.ContainsAny(s, "/\\\x00") |
| +} |
| + |
| +// validDemoName reports whether app is a demo app name the console makes: |
| +// tmp-demo- and a public name (demo.ValidPublicName, words and two digits |
| +// joined by hyphens), so one path component with no dots. Checked before a |
| +// name is used in any path. |
| +func validDemoName(app string) bool { |
| + name, ok := strings.CutPrefix(app, demo.AppPrefix) |
| + return ok && oneStoreName(app) && demo.ValidPublicName(name) |
| +} |
| + |
| +// validDemoRow reports whether rt is a complete, valid demo binding of this |
| +// box (demo.Config.ValidateBinding over its descriptor). Only a row that is |
| +// not protects anything more: it never makes a build eligible. |
| +func (r *demoRetention) validDemoRow(rt registry.Route) bool { |
| + d := demo.Descriptor{ID: rt.DemoID, Host: rt.DemoHost, Lifetime: rt.DemoLifetime, ExpiresAt: rt.DemoExpiresAt} |
| + return rt.IsDemo() && r.box.ValidateBinding(d, release.RouteAccount(rt), rt.App, rt.Host, rt.DemoLifetime, r.box.Fleet) == nil |
| +} |
| + |
| +// demoGeneration reads the console's demo version name (v0.0.0-demo.<n>, |
| +// internal/console's demoVersion) as its generation. |
| +func demoGeneration(v string) (uint64, bool) { |
| + rest, ok := strings.CutPrefix(v, "v0.0.0-demo.") |
| + if !ok { |
| + return 0, false |
| + } |
| + n, err := strconv.ParseUint(rest, 10, 64) |
| + if err != nil || strconv.FormatUint(n, 10) != rest { |
| + return 0, false |
| + } |
| + return n, true |
| +} |
| + |
| +// inFlight: v was staged after every version the app's live links name. A |
| +// name this cannot order is in flight: the cautious answer. |
| +func inFlight(v string, adopted []string) bool { |
| + g, ok := demoGeneration(v) |
| + if !ok { |
| + return true |
| + } |
| + for _, a := range adopted { |
| + n, ok := demoGeneration(a) |
| + if !ok { |
| + return true |
| + } |
| + if n >= g { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +// pinSet is every pin path from every source. strict: any source that does |
| +// not read in full is an error, except BoxPins' IncompleteRefsError, whose |
| +// pins are complete for every app it does not cover and which is returned |
| +// for the caller to hold those apps. Otherwise (the backlog estimate) a |
| +// failed source adds nothing. |
| +func (r *demoRetention) pinSet(ctx context.Context, routes []registry.Route, strict bool) (out, reserved []string, _ *release.IncompleteRefsError, _ error) { |
| + add := func(name string, paths release.StagedPaths, err error) error { |
| + if err != nil { |
| + if strict { |
| + return fmt.Errorf("%s: %w", name, err) |
| + } |
| + return nil |
| + } |
| + for p := range paths { |
| + out = append(out, filepath.Clean(p)) |
| + } |
| + return nil |
| + } |
| + // The generation sources' pins are also kept apart: they are G and R. |
| + addReserved := func(name string, paths release.StagedPaths, err error) error { |
| + if err == nil { |
| + for p := range paths { |
| + reserved = append(reserved, filepath.Clean(p)) |
| + } |
| + } |
| + return add(name, paths, err) |
| + } |
| + box, err := release.BoxPins(r.optDir, routes) |
| + var inc *release.IncompleteRefsError |
| + if errors.As(err, &inc) && box != nil { |
| + err = nil |
| + } else { |
| + inc = nil |
| + } |
| + if err := add("live links and registry rows", box, err); err != nil { |
| + return nil, nil, nil, err |
| + } |
| + if !strict { |
| + // BoxPins answers nothing when one live link does not read; the |
| + // estimate still knows what the rows name. |
| + for _, rt := range routes { |
| + refs, _ := release.SettingsRefs(rt) |
| + for _, v := range append([]string{rt.Version, rt.PrevVersion, rt.GoodVersion}, refs...) { |
| + if rt.App != "" && release.ValidVersion(v) { |
| + out = append(out, release.VersionPath(r.optDir, release.RouteAccount(rt), v, rt.App)) |
| + } |
| + } |
| + } |
| + } |
| + prev, err := linkTargets(filepath.Join(r.optDir, "previous")) |
| + if err := add("previous links", prev, err); err != nil { |
| + return nil, nil, nil, err |
| + } |
| + gen, err := release.GenerationPins(r.genPath, func() ([]registry.Route, error) { return routes, nil }).StagedPins(ctx, r.optDir) |
| + if err := addReserved("generations file", gen, err); err != nil { |
| + return nil, nil, nil, err |
| + } |
| + var root release.StagedPaths |
| + err = os.ErrPermission |
| + if r.rootPins != nil { |
| + root, err = r.rootPins.StagedPins(ctx, r.optDir) |
| + } |
| + if err := addReserved("root generation pins", root, err); err != nil { |
| + return nil, nil, nil, err |
| + } |
| + return out, reserved, inc, nil |
| +} |
| + |
| +// linkTargets is every link's target in dir (<opt>/previous or <opt>/live, |
| +// both root's), as release.LivePins reads them for the sweep, at the path |
| +// it names and its real path. |
| +func linkTargets(dir string) (release.StagedPaths, error) { |
| + entries, err := os.ReadDir(dir) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return release.StagedPaths{}, nil |
| + } |
| + if err != nil { |
| + return nil, err |
| + } |
| + pins := release.StagedPaths{} |
| + for _, e := range entries { |
| + link := filepath.Join(dir, e.Name()) |
| + target, err := os.Readlink(link) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if !filepath.IsAbs(target) { |
| + target = filepath.Join(dir, target) |
| + } |
| + pins[filepath.Clean(target)] = true |
| + real, err := filepath.EvalSymlinks(link) |
| + if err != nil && !errors.Is(err, os.ErrNotExist) { |
| + return nil, err |
| + } |
| + if err == nil { |
| + pins[real] = true |
| + } |
| + } |
| + return pins, nil |
| +} |
| + |
| +// pinned: a pin names the output or its manifest, a path inside it, or a |
| +// directory above it (a root generation's reserved Tree, <ver>/<account> |
| +// or <ver>, keeps everything in it, as generationWriteCheck refuses writes |
| +// there), under the store's own spelling or its real path. |
| +func pinned(pins []string, optDir string, o demoOutput) bool { |
| + var names []string |
| + for _, p := range o.spellings(optDir) { |
| + names = append(names, p, p+".manifest.json") |
| + } |
| + for _, p := range pins { |
| + for _, n := range names { |
| + if within(n, p) || within(p, n) { |
| + return true |
| + } |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// within: path is base or beneath it. |
| +func within(path, base string) bool { |
| + return path == base || strings.HasPrefix(path, strings.TrimSuffix(base, string(filepath.Separator))+string(filepath.Separator)) |
| +} |
| + |
| +// listOutputs is root's own listing of the demo account's outputs in the |
| +// version store: every <ver>/<acct>/<name> (and its manifest) whose name is |
| +// a valid demo app name (only that app, when only is set). Names come from |
| +// the listing and are validated before any further use, so nothing a |
| +// registry row says reaches a path here. |
| +func (r *demoRetention) listOutputs(acct, only string) ([]demoOutput, error) { |
| + root := filepath.Join(r.optDir, "versions") |
| + versions, err := os.ReadDir(root) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return nil, nil |
| + } |
| + if err != nil { |
| + return nil, err |
| + } |
| + var out []demoOutput |
| + for _, v := range versions { |
| + if !v.IsDir() || !release.ValidVersion(v.Name()) { |
| + continue |
| + } |
| + entries, err := os.ReadDir(filepath.Join(root, v.Name(), acct)) |
| + // ENOTDIR: <ver>/<account> is an ops app's file of that name. |
| + if errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) { |
| + continue |
| + } |
| + if err != nil { |
| + return nil, err |
| + } |
| + at := map[string]int{} |
| + for _, e := range entries { |
| + app := strings.TrimSuffix(e.Name(), ".manifest.json") |
| + if !validDemoName(app) || (only != "" && app != only) { |
| + continue |
| + } |
| + info, err := e.Info() |
| + if errors.Is(err, os.ErrNotExist) { |
| + continue |
| + } |
| + if err != nil { |
| + return nil, err |
| + } |
| + i, ok := at[app] |
| + if !ok { |
| + i = len(out) |
| + at[app] = i |
| + out = append(out, demoOutput{demoAppKey: demoAppKey{acct, app}, version: v.Name()}) |
| + } |
| + if info.Mode().IsRegular() { |
| + out[i].bytes += info.Size() |
| + } |
| + } |
| + } |
| + return out, nil |
| +} |
| + |
| +// Why an app is held (demoOutput.held). |
| +const ( |
| + heldByRow = "a registry row runs it as something other than a valid demo" |
| + heldByRefs = "its settings references could not be read in full" |
| +) |
| + |
| +// demoSelection is one look at the store for the demo account's apps. |
| +type demoSelection struct { |
| + // outs is every output present, marked. |
| + outs []demoOutput |
| + // hold says why an app is held, "" when it is not, for any app, |
| + // whether or not it has outputs. |
| + hold func(app string) string |
| + // held is every held app of the demo account, outputs or not, as |
| + // "<app>: <why>". |
| + held []string |
| +} |
| + |
| +// selection is one look at the store for the demo account's apps (only, |
| +// when set). except is the version about to be staged, which is kept. |
| +func (r *demoRetention) selection(ctx context.Context, only, except string, strict bool) (sel demoSelection, err error) { |
| + if r.onPins != nil { |
| + r.onPins() |
| + } |
| + acct, err := r.demoAccount() |
| + if err != nil { |
| + return sel, err |
| + } |
| + if r.reg == nil { |
| + return sel, os.ErrPermission |
| + } |
| + routes, err := r.reg.List() |
| + if err != nil { |
| + return sel, fmt.Errorf("list routes: %w", err) |
| + } |
| + pins, reserved, inc, err := r.pinSet(ctx, routes, strict) |
| + if err != nil { |
| + return sel, err |
| + } |
| + live, liveErr := linkTargets(filepath.Join(r.optDir, "live")) |
| + if liveErr != nil { |
| + if strict { |
| + return sel, fmt.Errorf("live links: %w", liveErr) |
| + } |
| + live = release.StagedPaths{} |
| + } |
| + guarded := map[string]bool{} |
| + for _, rt := range routes { |
| + if release.RouteAccount(rt) == acct && !r.validDemoRow(rt) { |
| + guarded[rt.App] = true |
| + } |
| + } |
| + hold := func(app string) string { |
| + switch { |
| + case guarded[app]: |
| + return heldByRow |
| + case inc != nil && inc.Covers(acct, app): |
| + return heldByRefs |
| + } |
| + return "" |
| + } |
| + outs, err := r.listOutputs(acct, only) |
| + if err != nil { |
| + return sel, err |
| + } |
| + adopted := map[string][]string{} |
| + for _, o := range outs { |
| + for _, p := range o.spellings(r.optDir) { |
| + if live[p] { |
| + adopted[o.app] = append(adopted[o.app], o.version) |
| + break |
| + } |
| + } |
| + } |
| + if liveErr != nil { |
| + // The estimate, with the live links unread: what the rows say was |
| + // adopted. It only counts. |
| + for _, rt := range routes { |
| + if release.RouteAccount(rt) == acct && release.ValidVersion(rt.Version) { |
| + adopted[rt.App] = append(adopted[rt.App], rt.Version) |
| + } |
| + } |
| + } |
| + for i := range outs { |
| + o := &outs[i] |
| + o.pinned = o.version == except || pinned(pins, r.optDir, *o) |
| + o.held = hold(o.app) |
| + o.inFlight = inFlight(o.version, adopted[o.app]) |
| + o.reserved = pinned(reserved, r.optDir, *o) |
| + } |
| + var held []string |
| + note := func(app string) { |
| + if why := hold(app); why != "" && !slices.Contains(held, app+": "+why) { |
| + held = append(held, app+": "+why) |
| + } |
| + } |
| + for _, rt := range routes { |
| + if release.RouteAccount(rt) == acct && validDemoName(rt.App) && (only == "" || rt.App == only) { |
| + note(rt.App) |
| + } |
| + } |
| + for _, o := range outs { |
| + note(o.app) |
| + } |
| + sort.Strings(held) |
| + return demoSelection{outs: outs, hold: hold, held: held}, nil |
| +} |
| + |
| +// planRemovals is what retention removes from outs: every output nothing |
| +// pins that is not its app's newest pending output, and nothing of a held |
| +// app. unremoved counts, per app, what it should remove and keeps: a held |
| +// app's outputs it would otherwise remove, and pending outputs beyond one |
| +// where the names cannot be ordered. |
| +func planRemovals(outs []demoOutput) (remove []int, unremoved map[string]int) { |
| + unremoved = map[string]int{} |
| + pending := map[string][]int{} |
| + var apps []string |
| + for i, o := range outs { |
| + switch { |
| + case o.pinned: |
| + case o.inFlight: |
| + if pending[o.app] == nil { |
| + apps = append(apps, o.app) |
| + } |
| + pending[o.app] = append(pending[o.app], i) |
| + case o.held != "": |
| + unremoved[o.app]++ |
| + default: |
| + remove = append(remove, i) |
| + } |
| + } |
| + for _, app := range apps { |
| + idx := pending[app] |
| + newest, ordered := -1, true |
| + var top uint64 |
| + for _, i := range idx { |
| + g, ok := demoGeneration(outs[i].version) |
| + if !ok { |
| + ordered = false |
| + break |
| + } |
| + if newest < 0 || g > top { |
| + newest, top = i, g |
| + } |
| + } |
| + if !ordered { |
| + unremoved[app] += len(idx) - 1 |
| + continue |
| + } |
| + for _, i := range idx { |
| + switch { |
| + case i == newest: |
| + case outs[i].held != "": |
| + unremoved[app]++ |
| + default: |
| + remove = append(remove, i) |
| + } |
| + } |
| + } |
| + sort.Ints(remove) |
| + return remove, unremoved |
| +} |
| + |
| +// demoBacklog is the accounting invariant behind the backlog: for each app, |
| +// the larger of the outputs it keeps above its bound (demoOutputBound plus |
| +// those a generation reserves), however they are pinned or held, and the |
| +// outputs retention should have removed and did not. So an app above its |
| +// bound always shows, whatever kept its outputs. |
| +func demoBacklog(kept []demoOutput, unremoved map[string]int) int { |
| + count, reserved := map[string]int{}, map[string]int{} |
| + for _, o := range kept { |
| + count[o.app]++ |
| + if o.reserved { |
| + reserved[o.app]++ |
| + } |
| + } |
| + for app := range unremoved { |
| + if _, ok := count[app]; !ok { |
| + count[app] = 0 |
| + } |
| + } |
| + total := 0 |
| + for app, n := range count { |
| + total += max(n-demoOutputBound-reserved[app], unremoved[app], 0) |
| + } |
| + return total |
| +} |
| + |
| +// removeOutput deletes one output beneath its version directory, the |
| +// executable first, as purgeDemoVersions does. |
| +func (r *demoRetention) removeOutput(o demoOutput) error { |
| + exe := o.path(r.optDir) |
| + if r.onRemove != nil { |
| + r.onRemove(exe) |
| + } |
| + for _, name := range []string{o.app, o.app + ".manifest.json"} { |
| + if err := r.remove(filepath.Dir(exe), name); err != nil && !errors.Is(err, os.ErrNotExist) { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// demoRetentionResult is one run's outcome, for the log and the record. |
| +type demoRetentionResult struct { |
| + removed []string |
| + outputs int |
| + outputBytes int64 |
| + backlog int |
| + // held is every held app, as "<app>: <why>" (demoSelection.held). |
| + held []string |
| + err error |
| +} |
| + |
| +// retain is one retention run, deleting only under the lock and on a |
| +// complete pin set. |
| +func (r *demoRetention) retain(ctx context.Context) demoRetentionResult { |
| + var res demoRetentionResult |
| + var sel demoSelection |
| + if !r.locked { |
| + res.err = errors.New("the adopt pass lock is not held") |
| + } else { |
| + sel, res.err = r.selection(ctx, "", "", true) |
| + } |
| + if res.err != nil { |
| + // Deletes nothing. The backlog is estimated on what does read. |
| + est, err := r.selection(ctx, "", "", false) |
| + if err != nil { |
| + res.backlog = -1 |
| + return res |
| + } |
| + remove, unremoved := planRemovals(est.outs) |
| + for _, i := range remove { |
| + unremoved[est.outs[i].app]++ |
| + } |
| + res.backlog, res.held = demoBacklog(est.outs, unremoved), est.held |
| + for _, o := range est.outs { |
| + res.outputs++ |
| + res.outputBytes += o.bytes |
| + } |
| + return res |
| + } |
| + outs := sel.outs |
| + remove, unremoved := planRemovals(outs) |
| + gone := map[int]bool{} |
| + var failed []error |
| + for _, i := range remove { |
| + o := outs[i] |
| + if err := r.removeOutput(o); err != nil { |
| + failed = append(failed, fmt.Errorf("%s: %w", o.path(r.optDir), err)) |
| + unremoved[o.app]++ |
| + continue |
| + } |
| + gone[i] = true |
| + res.removed = append(res.removed, o.app+"@"+o.version) |
| + } |
| + var kept []demoOutput |
| + for i, o := range outs { |
| + if !gone[i] { |
| + kept = append(kept, o) |
| + res.outputs++ |
| + res.outputBytes += o.bytes |
| + } |
| + } |
| + res.backlog, res.held = demoBacklog(kept, unremoved), sel.held |
| + if len(sel.held) > 0 { |
| + failed = append(failed, fmt.Errorf("kept every build of %s", strings.Join(sel.held, "; "))) |
| + } |
| + if len(failed) > 0 { |
| + res.err = errors.Join(failed...) |
| + } |
| + return res |
| +} |
| + |
| +// run is retention as RunAdopt calls it: retain, log, and record. |
| +func (r *demoRetention) run(ctx context.Context) demoRetentionResult { |
| + if r == nil || !r.box.BoxMode() { |
| + return demoRetentionResult{} |
| + } |
| + res := r.retain(ctx) |
| + if len(res.removed) > 0 { |
| + r.logf("adopt: demo build retention: removed %d demo builds, %d kept (%d bytes): %v", len(res.removed), res.outputs, res.outputBytes, res.removed) |
| + } |
| + if res.err != nil { |
| + r.logf("adopt: demo build retention kept every build it could not prove was unused: %v (backlog %d)", res.err, res.backlog) |
| + } |
| + r.saveStatus(res) |
| + return res |
| +} |
| + |
| +// saveStatus records res, carrying the backlog's start across runs. A |
| +// record that cannot be written is logged: it is status, never a gate. |
| +func (r *demoRetention) saveStatus(res demoRetentionResult) { |
| + if r.record == nil { |
| + return |
| + } |
| + s, err := r.record() |
| + if err != nil { |
| + r.logf("adopt: demo build retention: record: %v", err) |
| + return |
| + } |
| + defer s.Close() |
| + now := r.now().UTC() |
| + var prev demoRetentionStatus |
| + if raw, err := s.Read(demoRetentionRecord); err == nil { |
| + _ = json.Unmarshal(raw, &prev) |
| + } |
| + next := demoRetentionStatus{Schema: 1, At: now, Outputs: res.outputs, OutputBytes: res.outputBytes, Backlog: res.backlog, Held: res.held} |
| + if res.backlog < 0 { |
| + // Nothing read at all: keep the last known numbers. |
| + next.Outputs, next.OutputBytes, next.Backlog, next.Held = prev.Outputs, prev.OutputBytes, max(prev.Backlog, 1), prev.Held |
| + } |
| + if res.err != nil { |
| + next.Reason = res.err.Error() |
| + } |
| + if next.Backlog > 0 { |
| + next.BacklogSince = now |
| + if prev.Backlog > 0 && !prev.BacklogSince.IsZero() { |
| + next.BacklogSince = prev.BacklogSince |
| + } |
| + } |
| + raw, err := json.Marshal(next) |
| + if err == nil { |
| + err = s.Write(demoRetentionRecord, raw) |
| + } |
| + if err != nil { |
| + r.logf("adopt: demo build retention: record: %v", err) |
| + } |
| +} |
| + |
| +// beforeStage is the pending-output cleanup (plan slice 1, step 4), run |
| +// through release.WithBeforeStage before a new output is staged: for a |
| +// demo app, every staged output of that app that nothing pins (a failed |
| +// job's leftover) goes first. If that cannot run in full, the stage is |
| +// refused and nothing is deleted; the next attempt retries. |
| +// |
| +// path is the VersionPath about to be written, in either layout |
| +// (<ver>/<account>/<app>, or the ops account's <ver>/<app>). A path that is |
| +// not the demo account's tmp-demo- app is left to stage. One that is, on a |
| +// box that cannot bound it (the demo account is the ops account, or the |
| +// name is not a demo name), is refused. |
| +func (r *demoRetention) beforeStage(ctx context.Context, path string) error { |
| + if r == nil || !r.box.BoxMode() { |
| + return nil |
| + } |
| + ver, k, ok := r.outputAt(path) |
| + if !ok || k.acct != r.box.Account || !strings.HasPrefix(k.app, demo.AppPrefix) { |
| + return nil |
| + } |
| + if _, err := r.demoAccount(); err != nil { |
| + return fmt.Errorf("demo build cleanup: %w", err) |
| + } |
| + if !validDemoName(k.app) { |
| + return fmt.Errorf("demo build cleanup: %q is not a demo app name, so its build is not staged", k.app) |
| + } |
| + if !r.locked { |
| + return errors.New("demo build cleanup: the adopt pass lock is not held") |
| + } |
| + sel, err := r.selection(ctx, k.app, ver, true) |
| + if err != nil { |
| + return fmt.Errorf("demo build cleanup: %w", err) |
| + } |
| + outs := sel.outs |
| + if why := sel.hold(k.app); why != "" { |
| + return fmt.Errorf("demo build cleanup: %s: %s, so its build is not staged", k.app, why) |
| + } |
| + for _, o := range outs { |
| + if o.pinned { |
| + continue |
| + } |
| + if err := r.removeOutput(o); err != nil { |
| + return fmt.Errorf("demo build cleanup: %s: %w", o.path(r.optDir), err) |
| + } |
| + r.logf("adopt: demo build cleanup: removed %s@%s, which nothing pins, before staging %s", o.app, o.version, ver) |
| + } |
| + return nil |
| +} |
| + |
| +// admitRoute is the demo admission, asked of every route before the |
| +// release pass does anything with it (release.WithRouteAdmission), so no |
| +// pass can stage, restage, reuse or adopt a demo output unless it holds the |
| +// adopt pass lock on a correctly configured demo box. Without it a pass |
| +// that could not take the lock could adopt an output a locked pass is |
| +// removing. A demo route here is a tmp-demo- app of the demo account; on a |
| +// box whose demo settings do not validate, any tmp-demo- app. Every other |
| +// route is admitted. |
| +func (r *demoRetention) admitRoute(rt registry.Route) error { |
| + if r == nil || !strings.HasPrefix(rt.App, demo.AppPrefix) { |
| + return nil |
| + } |
| + if r.boxErr != nil { |
| + return fmt.Errorf("host.env sets CARLOS_DEMO_BOX, but the demo settings (CARLOS_DEMO_BOX, CARLOS_DEMO_ACCOUNT, CARLOS_DEMO_FLEET, CARLOS_DEMO_DOMAIN) are invalid (%v), so no demo build is adopted", r.boxErr) |
| + } |
| + if !r.box.BoxMode() || release.RouteAccount(rt) != r.box.Account { |
| + return nil |
| + } |
| + if _, err := r.demoAccount(); err != nil { |
| + return err |
| + } |
| + if !validDemoName(rt.App) { |
| + return fmt.Errorf("%q is not a demo app name, so its builds are not adopted", rt.App) |
| + } |
| + if !r.locked { |
| + return errors.New("this pass does not hold the adopt pass lock, so no demo build is adopted; the next pass tries again") |
| + } |
| + return nil |
| +} |
| + |
| +// outputAt reads path as a canonical VersionPath in either layout: the |
| +// version, account and app it names. |
| +func (r *demoRetention) outputAt(path string) (string, demoAppKey, bool) { |
| + rel, err := filepath.Rel(filepath.Join(r.optDir, "versions"), path) |
| + if err != nil { |
| + return "", demoAppKey{}, false |
| + } |
| + parts := strings.Split(rel, string(filepath.Separator)) |
| + var k demoAppKey |
| + switch len(parts) { |
| + case 2: |
| + k = demoAppKey{release.OpsAccount, parts[1]} |
| + case 3: |
| + k = demoAppKey{parts[1], parts[2]} |
| + default: |
| + return "", demoAppKey{}, false |
| + } |
| + ver := parts[0] |
| + if !release.ValidVersion(ver) || release.VersionPath(r.optDir, k.acct, ver, k.app) != filepath.Clean(path) { |
| + return "", demoAppKey{}, false |
| + } |
| + return ver, k, true |
| +} |
| + |
| +// demoAdoptions is the demo account's tmp-demo- routes' adopted versions by |
| +// host, read before a pass so afterPass can tell whether it adopted one. |
| +// It decides only whether retention runs, never what it removes. nil when |
| +// there is nothing to compare (no demo box, or the registry did not list). |
| +func (r *demoRetention) demoAdoptions() map[string]string { |
| + if r == nil || !r.box.BoxMode() || r.reg == nil { |
| + return nil |
| + } |
| + routes, err := r.reg.List() |
| + if err != nil { |
| + return nil |
| + } |
| + out := map[string]string{} |
| + for _, rt := range routes { |
| + if release.RouteAccount(rt) == r.box.Account && strings.HasPrefix(rt.App, demo.AppPrefix) { |
| + out[rt.Host] = rt.Version |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// adoptPassRetention is the demo build retention a root adopt pass runs, |
| +// from its mode flags and whether it took the adopt pass lock: none on a |
| +// -config-only or -restart-only pass, which adopts nothing; locked only |
| +// when the lock was taken (without it retention deletes nothing and a demo |
| +// stage is refused); hourly (retention runs even when the pass adopted no |
| +// demo version) unless -stage-only. build makes the retention for a lock |
| +// state. |
| +func adoptPassRetention(configOnly, restartOnly, stageOnly bool, lockErr error, build func(locked bool) *demoRetention) (*demoRetention, bool) { |
| + if configOnly || restartOnly { |
| + return nil, false |
| + } |
| + return build(lockErr == nil), !stageOnly |
| +} |
| + |
| +// adoptPassAround is runAdoptUnderRootRelease's release pass inside the |
| +// demo build retention its mode and lock allow (adoptPassRetention). build |
| +// makes the retention for a lock state (productionDemoRetentionFor). |
| +func adoptPassAround(ctx context.Context, configOnly, restartOnly, stageOnly bool, lockErr error, build func(locked bool) *demoRetention, pass func(demo ...release.PassOption) error) func() error { |
| + r, hourly := adoptPassRetention(configOnly, restartOnly, stageOnly, lockErr, build) |
| + return r.around(ctx, hourly, pass) |
| +} |
| + |
| +// productionDemoRetentionFor is adoptPassAround's build on this box. |
| +func productionDemoRetentionFor(reg routeLister, rootPins release.PinSource) func(locked bool) *demoRetention { |
| + return func(locked bool) *demoRetention { return productionDemoRetention(reg, rootPins, locked) } |
| +} |
| + |
| +// afterPass runs retention after a pass that adopted a demo version, and |
| +// on every hourly pass as the backstop. before is demoAdoptions from before |
| +// the pass; nil (unknown) counts as an adoption. |
| +func (r *demoRetention) afterPass(ctx context.Context, hourly bool, before map[string]string) { |
| + if r == nil || !r.box.BoxMode() { |
| + return |
| + } |
| + if !hourly && before != nil { |
| + after := r.demoAdoptions() |
| + changed := after == nil |
| + for host, v := range after { |
| + if before[host] != v { |
| + changed = true |
| + } |
| + } |
| + if !changed { |
| + return |
| + } |
| + } |
| + r.run(ctx) |
| +} |
| + |
| +// around is one release pass as RunAdopt runs it on any box: pass gets the |
| +// demo admission (WithRouteAdmission, admitRoute) and the pending-output |
| +// cleanup (WithBeforeStage) as its options, and retention runs after it |
| +// when it adopted a demo version, or on the hourly pass. |
| +func (r *demoRetention) around(ctx context.Context, hourly bool, pass func(demo ...release.PassOption) error) func() error { |
| + return func() error { |
| + before := r.demoAdoptions() |
| + err := pass(release.WithRouteAdmission(r.admitRoute), release.WithBeforeStage(r.beforeStage)) |
| + r.afterPass(ctx, hourly, before) |
| + return err |
| + } |
| +} |
diff --git a/internal/host/demoretention_linux_test.go b/internal/host/demoretention_linux_test.go| new file mode 100644 |
| index 000000000..c27a4fb45 |
| --- /dev/null |
| +++ b/internal/host/demoretention_linux_test.go |
| @@ -0,0 +1,251 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "os" |
| + "path/filepath" |
| + "slices" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/rootstate" |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// A demo build that only root's generation ledger names (a worker launched |
| +// from it, and the row and the links have moved on) survives retention. |
| +// The pin comes from the production source (generationPinSource over the |
| +// ledger), not a stand-in. |
| +func TestDemoRetentionKeepsARootOnlyGenerationPin(t *testing.T) { |
| + f, disk, _ := generationLaunchFixture(t) |
| + permit, err := f.root.generations.reserve(t.Context(), f.root, f.peer, f.req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + b := newRetentionBox(t, f.root.generations.optDir) |
| + b.rootPins = generationPinSource{open: func() (rootstate.Store, error) { return disk, nil }, verify: func(context.Context, []release.GenerationReservation) error { return nil }} |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + b.ship("shop", app, demoVer(1)) |
| + b.pass(b.retention(true), true) |
| + |
| + held := permit.reservation.Binding |
| + held.Attempt, held.Invocation = "demo-worker", "demo-worker" |
| + held.Binding.Account, held.Binding.App, held.Version = "shop", app, demoVer(1) |
| + held.Path = release.VersionPath(b.opt, "shop", demoVer(1), app) |
| + held.Tree = filepath.Dir(held.Path) |
| + for path, dst := range map[string]*rootstate.FileIdentity{held.Path: &held.Executable, held.Tree: &held.TreeIdentity} { |
| + file, err := os.Open(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + *dst, err = rootstate.Identity(file) |
| + file.Close() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if _, err := permit.ledger.Reserve(held); err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 2; i <= 4; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + rt := b.route("red") |
| + if slices.Contains(rowPins(rt), demoVer(1)) { |
| + t.Fatalf("fixture: the row still names v1: %+v", rowPins(rt)) |
| + } |
| + got := b.outputs("shop", app) |
| + if !slices.Contains(got, demoVer(1)) { |
| + t.Fatalf("the root generation's build was removed: %v", got) |
| + } |
| + if slices.Contains(got, demoVer(2)) { |
| + t.Fatalf("v2, which nothing names, survived: %v", got) |
| + } |
| +} |
| + |
| +// lockHeld reports whether some other open file description holds the adopt |
| +// pass lock: a non-blocking exclusive flock from a fresh descriptor fails. |
| +func lockHeld(t *testing.T, dataDir string) bool { |
| + t.Helper() |
| + f, err := os.OpenFile(adoptPassLockPath(dataDir), os.O_RDWR|os.O_CREATE, 0o644) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer f.Close() |
| + err = unix.Flock(int(f.Fd()), unix.LOCK_EX|unix.LOCK_NB) |
| + if err == nil { |
| + _ = unix.Flock(int(f.Fd()), unix.LOCK_UN) |
| + return false |
| + } |
| + if !errors.Is(err, unix.EWOULDBLOCK) { |
| + t.Fatal(err) |
| + } |
| + return true |
| +} |
| + |
| +// Concurrent adoption. The first pass holds the adopt pass lock (as RunAdopt |
| +// takes it) from before its first pin read until after its last removal: |
| +// at each of those seams, a second pass cannot take it. The second pass, |
| +// blocked on the lock until the first releases it, then runs its own |
| +// adoption and retention and deletes nothing the first adopted. |
| +func TestDemoRetentionConcurrentAdoptionIsSerialized(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + b.addDemo("blue", true) |
| + for i := 1; i <= 2; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + b.ship("shop", app, demoVer(3)) |
| + |
| + unlock, err := lockAdoptPass(b.data) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + first := b.retention(true) |
| + var seams, removals int |
| + first.onPins = func() { |
| + seams++ |
| + if !lockHeld(t, b.data) { |
| + t.Error("a pin read ran without the adopt pass lock held") |
| + } |
| + } |
| + first.onRemove = func(string) { |
| + removals++ |
| + if !lockHeld(t, b.data) { |
| + t.Error("a removal ran without the adopt pass lock held") |
| + } |
| + } |
| + // The second pass starts now and blocks on the lock. |
| + b.ship("shop", demoAppName("blue"), demoVer(1)) |
| + waiting := make(chan struct{}) |
| + done := make(chan []string) |
| + go func() { |
| + close(waiting) |
| + unlock2, err := lockAdoptPass(b.data) |
| + if err != nil { |
| + t.Error(err) |
| + done <- nil |
| + return |
| + } |
| + defer unlock2() |
| + second := b.retention(true) |
| + ctx := context.Background() |
| + if err := second.around(ctx, false, func(demo ...release.PassOption) error { |
| + return release.Pass(ctx, b.reg, b.store, b.pub, b.opt, nil, append([]release.PassOption{release.BakeDir(b.data)}, demo...)...) |
| + })(); err != nil { |
| + t.Error(err) |
| + } |
| + done <- b.outputs("shop", app) |
| + }() |
| + <-waiting |
| + b.pass(first, false) |
| + if seams == 0 || removals == 0 { |
| + t.Fatalf("the first pass read pins %d times and removed %d builds; the witness needs both", seams, removals) |
| + } |
| + adopted := b.route("red") |
| + unlock() |
| + got := <-done |
| + if adopted.Version != demoVer(3) { |
| + t.Fatalf("first pass left red at %q", adopted.Version) |
| + } |
| + for _, v := range rowPins(adopted) { |
| + if !slices.Contains(got, v) { |
| + t.Fatalf("the second pass deleted %s, which the first adopted or kept as its rollback: %v", v, got) |
| + } |
| + } |
| + if b.route("blue").Version != demoVer(1) { |
| + t.Fatal("the second pass did not run") |
| + } |
| +} |
| + |
| +// A sibling app's root generation reserves the tree that holds the demo's |
| +// output (<ver>/<account>, its Tree): retention keeps every output inside |
| +// it, as generationWriteCheck refuses writes there (Astra round 1 P1-1). |
| +// The reservation is a real one in root's ledger, read through the |
| +// production source. |
| +func TestDemoRetentionKeepsOutputsInsideAReservedTree(t *testing.T) { |
| + f, disk, _ := generationLaunchFixture(t) |
| + permit, err := f.root.generations.reserve(t.Context(), f.root, f.peer, f.req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + b := newRetentionBox(t, f.root.generations.optDir) |
| + b.rootPins = generationPinSource{open: func() (rootstate.Store, error) { return disk, nil }, verify: func(context.Context, []release.GenerationReservation) error { return nil }} |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + b.ship("shop", app, demoVer(1)) |
| + b.pass(b.retention(true), true) |
| + if err := release.StageArtifact(b.opt, "shop", demoVer(1), "blog", []byte("blog build")); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + held := permit.reservation.Binding |
| + held.Attempt, held.Invocation = "blog-worker", "blog-worker" |
| + held.Binding.Account, held.Binding.App, held.Version = "shop", "blog", demoVer(1) |
| + held.Path = release.VersionPath(b.opt, "shop", demoVer(1), "blog") |
| + held.Tree = filepath.Dir(held.Path) |
| + for path, dst := range map[string]*rootstate.FileIdentity{held.Path: &held.Executable, held.Tree: &held.TreeIdentity} { |
| + file, err := os.Open(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + *dst, err = rootstate.Identity(file) |
| + file.Close() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if _, err := permit.ledger.Reserve(held); err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 2; i <= 4; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + got := b.outputs("shop", app) |
| + if !slices.Contains(got, demoVer(1)) { |
| + t.Fatalf("the demo output inside the reserved tree was removed: %v", got) |
| + } |
| + if slices.Contains(got, demoVer(2)) { |
| + t.Fatalf("v2, outside every reserved tree, survived: %v", got) |
| + } |
| +} |
| + |
| +// A pin on any directory above an output keeps it, whether the pin and the |
| +// output are spelled through the store's own path or its real path. |
| +func TestDemoRetentionPinnedByAnAncestorUnderEitherSpelling(t *testing.T) { |
| + real := t.TempDir() |
| + opt := filepath.Join(t.TempDir(), "opt") |
| + if err := os.Symlink(real, opt); err != nil { |
| + t.Fatal(err) |
| + } |
| + app := demoAppName("red") |
| + if err := os.MkdirAll(filepath.Join(real, "versions", demoVer(1), "shop"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(release.VersionPath(real, "shop", demoVer(1), app), []byte("build"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + o := demoOutput{demoAppKey: demoAppKey{"shop", app}, version: demoVer(1)} |
| + for _, c := range []struct { |
| + pin string |
| + want bool |
| + }{ |
| + {filepath.Join(opt, "versions", demoVer(1), "shop"), true}, |
| + {filepath.Join(opt, "versions", demoVer(1)), true}, |
| + {filepath.Join(real, "versions", demoVer(1), "shop"), true}, |
| + {filepath.Join(real, "versions", demoVer(1)), true}, |
| + {filepath.Join(opt, "versions", demoVer(1), "shop", "blog"), false}, |
| + {filepath.Join(opt, "versions", demoVer(2), "shop"), false}, |
| + {filepath.Join(opt, "versions", demoVer(1), "sho"), false}, |
| + } { |
| + if got := pinned([]string{c.pin}, opt, o); got != c.want { |
| + t.Errorf("pin %s: pinned = %v, want %v", c.pin, got, c.want) |
| + } |
| + } |
| +} |
diff --git a/internal/host/demoretention_test.go b/internal/host/demoretention_test.go| new file mode 100644 |
| index 000000000..0ff2a8697 |
| --- /dev/null |
| +++ b/internal/host/demoretention_test.go |
| @@ -0,0 +1,1087 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "crypto/ed25519" |
| + "crypto/sha256" |
| + "encoding/base64" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "math/rand/v2" |
| + "os" |
| + "path/filepath" |
| + "runtime" |
| + "slices" |
| + "sort" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/demo" |
| + "github.com/carlosframework/platform/internal/instancefs" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/rootstate" |
| +) |
| + |
| +// retentionBox is a demo box for the retention witnesses: a real registry, |
| +// a real release store and version store, root's adopt pass as RunAdopt |
| +// runs it (release.Pass inside demoRetention.around), and root generation |
| +// pins from whatever source the test hands it. |
| +type retentionBox struct { |
| + t *testing.T |
| + store release.Store |
| + pub ed25519.PublicKey |
| + priv ed25519.PrivateKey |
| + reg *registry.Registry |
| + lister routeLister |
| + opt string |
| + data string |
| + record *rollbackDisk |
| + rootPins release.PinSource |
| + clock time.Time |
| + restart func(host string) error |
| +} |
| + |
| +var retentionDemo = demo.Config{Account: "shop", Fleet: "demo", Domain: "example.com"} |
| + |
| +func newRetentionBox(t *testing.T, opt string) *retentionBox { |
| + t.Helper() |
| + pub, priv, err := ed25519.GenerateKey(nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if opt == "" { |
| + opt = t.TempDir() |
| + } |
| + b := &retentionBox{t: t, store: release.NewDirStore(t.TempDir()), pub: pub, priv: priv, reg: restartTestRegistry(t), |
| + opt: opt, data: t.TempDir(), record: &rollbackDisk{dir: t.TempDir()}, clock: time.Date(2026, 11, 29, 12, 0, 0, 0, time.UTC), |
| + rootPins: release.PinSourceFunc(func(context.Context, string) (release.StagedPaths, error) { return release.StagedPaths{}, nil })} |
| + b.lister = b.reg |
| + return b |
| +} |
| + |
| +// retention is productionDemoRetention with this box's paths. |
| +func (b *retentionBox) retention(locked bool) *demoRetention { |
| + return &demoRetention{box: retentionDemo, reg: b.lister, optDir: b.opt, genPath: release.GenerationsPath(b.data), |
| + rootPins: b.rootPins, locked: locked, now: func() time.Time { return b.clock }, remove: instancefs.RemoveAllBeneath, |
| + logf: b.t.Logf, record: func() (rootstate.Store, error) { return b.record, nil }} |
| +} |
| + |
| +// demoPublicNames gives each test demo the public name the console would |
| +// (demo.ValidPublicName): retention only ever selects those. |
| +var demoPublicNames = map[string]string{"red": "amber-acorn-01", "blue": "azure-apple-02"} |
| + |
| +func demoHost(name string) string { return demoPublicNames[name] + "." + retentionDemo.Domain } |
| +func demoAppName(name string) string { return demo.AppPrefix + demoPublicNames[name] } |
| + |
| +// demoRow is the registry row the console's placement writes for a demo: |
| +// a complete, valid descriptor (demo.Config.ValidateBinding). |
| +func (b *retentionBox) demoRow(name string, hibernate bool) registry.Route { |
| + id := sha256.Sum256([]byte(name)) |
| + return registry.Route{Host: demoHost(name), Kind: "instance", Account: retentionDemo.Account, App: demoAppName(name), |
| + Channel: "edge", Status: "ready", Hibernate: hibernate, Socket: provision.NestedSocket(demoHost(name)), |
| + DemoID: base64.RawURLEncoding.EncodeToString(id[:16]), DemoHost: demoHost(name), DemoLifetime: "24h", |
| + DemoExpiresAt: b.clock.Add(24 * time.Hour).Unix()} |
| +} |
| + |
| +func (b *retentionBox) addDemo(name string, hibernate bool) { |
| + b.t.Helper() |
| + if err := b.reg.Upsert(b.demoRow(name, hibernate)); err != nil { |
| + b.t.Fatal(err) |
| + } |
| +} |
| + |
| +func demoVer(n int) string { return fmt.Sprintf("v0.0.0-demo.%d", n) } |
| + |
| +func (b *retentionBox) ship(acct, app, ver string) { |
| + b.t.Helper() |
| + plat := runtime.GOOS + "-" + runtime.GOARCH |
| + ctx := context.Background() |
| + m := release.Manifest{App: app, Version: ver, Kind: "binary", Artifacts: map[string]release.Artifact{plat: {}}} |
| + if err := release.Ship(ctx, b.store, acct, m, map[string][]byte{plat: []byte(app + " build " + ver)}); err != nil { |
| + b.t.Fatal(err) |
| + } |
| + if err := release.Promote(ctx, b.store, b.priv, acct, app, "edge", ver); err != nil { |
| + b.t.Fatal(err) |
| + } |
| +} |
| + |
| +// pass is one root adopt pass as RunAdopt runs it: hourly, or -stage-only. |
| +func (b *retentionBox) pass(r *demoRetention, hourly bool) { |
| + b.t.Helper() |
| + ctx := context.Background() |
| + err := r.around(ctx, hourly, func(demo ...release.PassOption) error { |
| + return release.Pass(ctx, b.reg, b.store, b.pub, b.opt, b.restart, append([]release.PassOption{release.BakeDir(b.data)}, demo...)...) |
| + })() |
| + if err != nil { |
| + b.t.Fatalf("pass: %v", err) |
| + } |
| +} |
| + |
| +// outputs is every version the store holds an output of app at. |
| +func (b *retentionBox) outputs(acct, app string) []string { |
| + b.t.Helper() |
| + entries, err := os.ReadDir(filepath.Join(b.opt, "versions")) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return nil |
| + } |
| + if err != nil { |
| + b.t.Fatal(err) |
| + } |
| + var out []string |
| + for _, e := range entries { |
| + for _, p := range []string{release.VersionPath(b.opt, acct, e.Name(), app), release.VersionPath(b.opt, acct, e.Name(), app) + ".manifest.json"} { |
| + if _, err := os.Lstat(p); err == nil { |
| + out = append(out, e.Name()) |
| + break |
| + } |
| + } |
| + } |
| + sort.Strings(out) |
| + return out |
| +} |
| + |
| +func (b *retentionBox) route(name string) registry.Route { |
| + b.t.Helper() |
| + rt, err := b.reg.Get(demoHost(name)) |
| + if err != nil || rt == nil { |
| + b.t.Fatalf("route %s: %+v %v", name, rt, err) |
| + } |
| + return *rt |
| +} |
| + |
| +func (b *retentionBox) status() demoRetentionStatus { |
| + b.t.Helper() |
| + raw, err := b.record.Read(demoRetentionRecord) |
| + if err != nil { |
| + b.t.Fatalf("retention record: %v", err) |
| + } |
| + var s demoRetentionStatus |
| + if err := json.Unmarshal(raw, &s); err != nil { |
| + b.t.Fatal(err) |
| + } |
| + return s |
| +} |
| + |
| +func sameSet(got, want []string) bool { |
| + g, w := slices.Clone(got), slices.Clone(want) |
| + sort.Strings(g) |
| + sort.Strings(w) |
| + return slices.Equal(slices.Compact(g), slices.Compact(w)) |
| +} |
| + |
| +// rowPins is the set of versions a route's own row pins. |
| +func rowPins(rt registry.Route) []string { |
| + var out []string |
| + for _, v := range []string{rt.Version, rt.PrevVersion, rt.GoodVersion} { |
| + if v != "" { |
| + out = append(out, v) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// Sixty-one updates of one demo through the hourly pass: after each, the |
| +// store holds the demo's row pins and nothing else, and at the end that is |
| +// the live build and its rollback. An ordinary app in the same store keeps |
| +// every build. |
| +func TestDemoRetentionSixtyOneUpdatesKeepPinsAndOneRollback(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + if err := b.reg.Upsert(registry.Route{Host: "blog.example.org", Kind: "instance", Account: "other", App: "blog", Channel: "edge", Status: "ready", Hibernate: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 1; i <= 61; i++ { |
| + b.ship("shop", demoAppName("red"), demoVer(i)) |
| + b.ship("other", "blog", demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + rt := b.route("red") |
| + if rt.Version != demoVer(i) { |
| + t.Fatalf("update %d: route at %q", i, rt.Version) |
| + } |
| + if got := b.outputs("shop", demoAppName("red")); !sameSet(got, rowPins(rt)) { |
| + t.Fatalf("update %d: store holds %v, want the row's pins %v", i, got, rowPins(rt)) |
| + } |
| + } |
| + if got, want := b.outputs("shop", demoAppName("red")), []string{demoVer(60), demoVer(61)}; !sameSet(got, want) { |
| + t.Fatalf("after 61 updates the demo keeps %v, want %v", got, want) |
| + } |
| + if got := b.outputs("other", "blog"); len(got) != 61 { |
| + t.Fatalf("the ordinary app kept %d builds, want all 61 (retention is demo-only)", len(got)) |
| + } |
| + if s := b.status(); s.Outputs != 2 || s.Backlog != 0 || s.OutputBytes <= 0 { |
| + t.Fatalf("record = %+v", s) |
| + } |
| +} |
| + |
| +// Ten relayed updates in a row, each through a -stage-only pass and no |
| +// hourly pass between them: the bound holds after every one. |
| +func TestDemoRetentionSuccessiveRelayedUpdatesWithoutAnHourlyPass(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + for i := 1; i <= 10; i++ { |
| + b.ship("shop", demoAppName("red"), demoVer(i)) |
| + b.pass(b.retention(true), false) |
| + rt := b.route("red") |
| + if got := b.outputs("shop", demoAppName("red")); rt.Version != demoVer(i) || !sameSet(got, rowPins(rt)) || len(got) > 3 { |
| + t.Fatalf("relayed update %d: route %q, store %v, want %v", i, rt.Version, got, rowPins(rt)) |
| + } |
| + } |
| +} |
| + |
| +// A -stage-only pass that adopted no demo version does not run retention; |
| +// the hourly pass does, as the backstop. |
| +func TestDemoRetentionRunsAfterAnAdoptionAndOnTheHourlyPass(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.ship("shop", demoAppName("red"), demoVer(1)) |
| + b.pass(b.retention(true), false) |
| + // A leftover nobody names, older than the live build. |
| + if err := release.StageArtifact(b.opt, "shop", "v0.0.0-demo.0", demoAppName("red"), []byte("old")); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.pass(b.retention(true), false) |
| + if got := b.outputs("shop", demoAppName("red")); !slices.Contains(got, "v0.0.0-demo.0") { |
| + t.Fatalf("a stage-only pass that adopted nothing ran retention: %v", got) |
| + } |
| + b.pass(b.retention(true), true) |
| + if got := b.outputs("shop", demoAppName("red")); slices.Contains(got, "v0.0.0-demo.0") { |
| + t.Fatalf("the hourly backstop kept an unpinned build: %v", got) |
| + } |
| +} |
| + |
| +// A version staged and not yet adopted (the pass that staged it ended |
| +// before it repointed, so no link names it) is in flight: retention keeps |
| +// it, on the hourly pass and after another demo's adoption, until a later |
| +// version of its app is staged and adopted. |
| +func TestDemoRetentionKeepsAStagedNotYetAdoptedVersion(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.addDemo("blue", true) |
| + for i := 1; i <= 2; i++ { |
| + b.ship("shop", demoAppName("red"), demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + if err := release.StageArtifact(b.opt, "shop", demoVer(3), demoAppName("red"), []byte("staged, not adopted")); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.pass(b.retention(true), true) |
| + b.ship("shop", demoAppName("blue"), demoVer(1)) |
| + b.pass(b.retention(true), false) |
| + if b.route("blue").Version != demoVer(1) { |
| + t.Fatal("fixture: blue did not adopt") |
| + } |
| + if got := b.outputs("shop", demoAppName("red")); !slices.Contains(got, demoVer(3)) { |
| + t.Fatalf("the in-flight build was removed: %v", got) |
| + } |
| + b.ship("shop", demoAppName("red"), demoVer(4)) |
| + b.pass(b.retention(true), false) |
| + rt := b.route("red") |
| + if got := b.outputs("shop", demoAppName("red")); rt.Version != demoVer(4) || !sameSet(got, rowPins(rt)) { |
| + t.Fatalf("superseded: route %q, store %v, want %v", rt.Version, got, rowPins(rt)) |
| + } |
| +} |
| + |
| +// A version directory shared with an ordinary app (and another demo) loses |
| +// only the retired demo's files: the directory and its other apps stay. |
| +func TestDemoRetentionSharedVersionKeepsTheOtherApps(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.addDemo("blue", true) |
| + if err := b.reg.Upsert(registry.Route{Host: "blog.example.org", Kind: "instance", Account: "shop", App: "blog", Channel: "edge", Status: "ready", Hibernate: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.ship("shop", demoAppName("red"), demoVer(1)) |
| + b.ship("shop", demoAppName("blue"), demoVer(1)) |
| + b.ship("shop", "blog", demoVer(1)) |
| + // An ops-account app named like the demo account: <ver>/shop is a file. |
| + if err := release.StageArtifact(b.opt, "", "v9", "shop", []byte("ops")); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.pass(b.retention(true), true) |
| + if got := b.outputs("shop", demoAppName("red")); !slices.Equal(got, []string{demoVer(1)}) { |
| + t.Fatalf("fixture: red holds %v", got) |
| + } |
| + // red moves on twice; v1 is now nobody's but blue's and blog's. |
| + for i := 2; i <= 3; i++ { |
| + b.ship("shop", demoAppName("red"), demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + if got := b.outputs("shop", demoAppName("red")); slices.Contains(got, demoVer(1)) { |
| + t.Fatalf("red's v1 survived: %v", got) |
| + } |
| + for _, app := range []string{demoAppName("blue"), "blog"} { |
| + if got := b.outputs("shop", app); !slices.Contains(got, demoVer(1)) { |
| + t.Fatalf("%s lost its v1 with red's: %v", app, got) |
| + } |
| + } |
| + if _, err := os.Stat(filepath.Join(b.opt, "versions", demoVer(1))); err != nil { |
| + t.Fatalf("the shared version directory: %v", err) |
| + } |
| + if _, err := os.Stat(release.VersionPath(b.opt, "", "v9", "shop")); err != nil { |
| + t.Fatalf("the ops app: %v", err) |
| + } |
| + if s := b.status(); s.Reason != "" { |
| + t.Fatalf("record = %+v", s) |
| + } |
| +} |
| + |
| +// Every distinct pin of one demo route names a different build: Version, |
| +// PrevVersion, GoodVersion, the settings pin, last_executed and the |
| +// resolved target, plus a root generation pin on a seventh. All seven |
| +// survive the hourly pass; the two older builds nothing names go. |
| +func TestDemoRetentionDistinctPinValues(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + for i := 1; i <= 9; i++ { |
| + if err := release.StageArtifact(b.opt, "shop", demoVer(i), app, []byte("build")); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + b.addDemo("red", true) |
| + settings, err := json.Marshal(release.UpdateSettings{Updates: release.UpdatesManual, Pin: demoVer(6)}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + state := release.BuildStateCopy{Known: true, State: &release.BuildState{Schema: 1, Host: demoHost("red"), LastExecuted: demoVer(5), |
| + Resolved: &release.ResolvedRequest{ID: 1, Target: demoVer(4)}}} |
| + if err := b.reg.SetUpdateSettings(demoHost("red"), string(settings)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := b.reg.SetBuildState(demoHost("red"), state.Column()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := b.reg.SetVersions(demoHost("red"), demoVer(9), demoVer(8)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := b.reg.SetGoodBuild(demoHost("red"), registry.GoodBuild{}, registry.GoodBuild{Version: demoVer(7)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := release.PointLive(context.Background(), nil, b.opt, demoHost("red"), "shop", demoVer(9), app); err != nil { |
| + t.Fatal(err) |
| + } |
| + root := release.VersionPath(b.opt, "shop", demoVer(3), app) |
| + b.rootPins = release.PinSourceFunc(func(context.Context, string) (release.StagedPaths, error) { |
| + return release.StagedPaths{root: true}, nil |
| + }) |
| + rt := b.route("red") |
| + if rt.Version != demoVer(9) || rt.PrevVersion != demoVer(8) || rt.GoodVersion != demoVer(7) { |
| + t.Fatalf("row = %q %q %q", rt.Version, rt.PrevVersion, rt.GoodVersion) |
| + } |
| + b.pass(b.retention(true), true) |
| + want := []string{demoVer(3), demoVer(4), demoVer(5), demoVer(6), demoVer(7), demoVer(8), demoVer(9)} |
| + if got := b.outputs("shop", app); !sameSet(got, want) { |
| + t.Fatalf("store holds %v, want exactly the seven pinned %v", got, want) |
| + } |
| +} |
| + |
| +// A build that only the settings pin names survives. |
| +func TestDemoRetentionKeepsASettingsOnlyPin(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + b.ship("shop", app, demoVer(1)) |
| + b.pass(b.retention(true), true) |
| + settings, _ := json.Marshal(release.UpdateSettings{Updates: release.UpdatesManual, Pin: demoVer(1)}) |
| + if err := b.reg.SetUpdateSettings(demoHost("red"), string(settings)); err != nil { |
| + t.Fatal(err) |
| + } |
| + state := release.BuildStateCopy{Known: true, State: &release.BuildState{Schema: 1, Host: demoHost("red")}} |
| + if err := b.reg.SetBuildState(demoHost("red"), state.Column()); err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 2; i <= 4; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + if got := b.outputs("shop", app); !sameSet(got, []string{demoVer(1), demoVer(3), demoVer(4)}) { |
| + t.Fatalf("store holds %v, want the settings pin v1 kept beside v3 and v4", got) |
| + } |
| +} |
| + |
| +type failingLister struct{ err error } |
| + |
| +func (f failingLister) List() ([]registry.Route, error) { return nil, f.err } |
| + |
| +// Any pin source that does not read in full deletes nothing, and the record |
| +// says why and how much is held beyond the bound. |
| +func TestDemoRetentionUnreadableSourceDeletesNothing(t *testing.T) { |
| + for _, source := range []string{"registry", "live", "previous", "generations", "root", "settings"} { |
| + t.Run(source, func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + for i := 1; i <= 3; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + b.pass(b.retention(true), true) |
| + } |
| + // v1 is beyond the bound again: an output nothing names. |
| + if err := release.StageArtifact(b.opt, "shop", demoVer(1), app, []byte("left over")); err != nil { |
| + t.Fatal(err) |
| + } |
| + before := b.outputs("shop", app) |
| + if len(before) != 3 { |
| + t.Fatalf("fixture: %v", before) |
| + } |
| + r := b.retention(true) |
| + switch source { |
| + case "registry": |
| + r.reg = failingLister{errors.New("registry busy")} |
| + case "live": |
| + if err := os.WriteFile(filepath.Join(b.opt, "live", "broken"), []byte("not a link"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + case "previous": |
| + if err := os.MkdirAll(filepath.Join(b.opt, "previous"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(b.opt, "previous", "broken"), []byte("not a link"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + case "generations": |
| + gen := release.GenerationsPath(b.data) |
| + if err := os.MkdirAll(filepath.Dir(gen), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(gen, []byte(`{"schema":1,"hosts":{"x`), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + case "root": |
| + r.rootPins = release.PinSourceFunc(func(context.Context, string) (release.StagedPaths, error) { |
| + return nil, errors.New("ledger unreadable") |
| + }) |
| + case "settings": |
| + settings, _ := json.Marshal(release.UpdateSettings{Updates: release.UpdatesManual}) |
| + if err := b.reg.SetUpdateSettings(demoHost("red"), string(settings)); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + res := r.run(context.Background()) |
| + if res.err == nil { |
| + t.Fatal("an unreadable source was not reported") |
| + } |
| + if got := b.outputs("shop", app); !slices.Equal(got, before) { |
| + t.Fatalf("deleted with an incomplete pin set: %v -> %v", before, got) |
| + } |
| + if s := b.status(); s.Reason == "" || (source != "registry" && s.Backlog != 1) || s.BacklogSince.IsZero() { |
| + t.Fatalf("record = %+v", s) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Without the adopt pass lock, retention deletes nothing and the cleanup |
| +// refuses the stage. |
| +func TestDemoRetentionWithoutTheLockDeletesNothing(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + for i := 1; i <= 4; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + b.pass(b.retention(i < 4), true) |
| + } |
| + // The fourth pass had no lock: its cleanup refused v4's stage. |
| + if rt := b.route("red"); rt.Version != demoVer(3) { |
| + t.Fatalf("a stage ran without the lock: route at %q", rt.Version) |
| + } |
| + got := b.outputs("shop", app) |
| + if !sameSet(got, []string{demoVer(2), demoVer(3)}) { |
| + t.Fatalf("store = %v", got) |
| + } |
| + b.retention(false).run(context.Background()) |
| + if again := b.outputs("shop", app); !slices.Equal(again, got) { |
| + t.Fatalf("an unlocked run deleted: %v -> %v", got, again) |
| + } |
| +} |
| + |
| +// A failed run (no lock), then another (an unreadable source), deletes |
| +// nothing and reports a backlog that keeps its start; the next good run |
| +// clears it. |
| +func TestDemoRetentionBacklogAcrossFailedRuns(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + // Four builds staged, v4 adopted over v3: v1 and v2 are beyond the bound. |
| + b.adoptedAt("red", 4, 3, 4) |
| + start := b.clock |
| + b.retention(false).run(context.Background()) |
| + if s := b.status(); s.Backlog != 2 || !s.BacklogSince.Equal(start) { |
| + t.Fatalf("after the lock-less run: %+v", s) |
| + } |
| + b.clock = b.clock.Add(25 * time.Hour) |
| + r := b.retention(true) |
| + r.rootPins = release.PinSourceFunc(func(context.Context, string) (release.StagedPaths, error) { return nil, os.ErrPermission }) |
| + r.run(context.Background()) |
| + if s := b.status(); s.Backlog != 2 || !s.BacklogSince.Equal(start) || len(b.outputs("shop", app)) != 4 { |
| + t.Fatalf("after the unreadable-source run: %+v, store %v", s, b.outputs("shop", app)) |
| + } |
| + b.clock = b.clock.Add(time.Hour) |
| + b.retention(true).run(context.Background()) |
| + if s := b.status(); s.Backlog != 0 || !s.BacklogSince.IsZero() || s.Reason != "" { |
| + t.Fatalf("after the good run: %+v", s) |
| + } |
| + if got := b.outputs("shop", app); !sameSet(got, []string{demoVer(3), demoVer(4)}) { |
| + t.Fatalf("store = %v", got) |
| + } |
| +} |
| + |
| +// Three jobs for one demo each stage an output that is never adopted (the |
| +// restart fails, so settlement fails). Before each next stage the previous |
| +// leftover goes, so the store holds the pins plus at most one unadopted |
| +// output after every step. A cleanup that cannot read a pin source refuses |
| +// the stage and deletes nothing. |
| +func TestDemoRetentionFailedOutputsDoNotAccumulate(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", false) |
| + b.restart = func(string) error { return nil } |
| + b.ship("shop", app, demoVer(1)) |
| + b.pass(b.retention(true), false) |
| + b.restart = func(string) error { return errors.New("did not come up") } |
| + for job := 2; job <= 4; job++ { |
| + b.ship("shop", app, demoVer(job)) |
| + b.pass(b.retention(true), false) |
| + rt := b.route("red") |
| + got := b.outputs("shop", app) |
| + routes, err := b.reg.List() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + pins, _, _, err := b.retention(true).pinSet(context.Background(), routes, true) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var loose []string |
| + for _, v := range got { |
| + if !pinned(pins, b.opt, demoOutput{demoAppKey: demoAppKey{"shop", app}, version: v}) { |
| + loose = append(loose, v) |
| + } |
| + } |
| + if rt.Version != demoVer(1) || len(loose) > 1 || !slices.Contains(got, demoVer(job)) { |
| + t.Fatalf("job %d: route %q, store %v (unadopted and unpinned %v)", job, rt.Version, got, loose) |
| + } |
| + } |
| + before := b.outputs("shop", app) |
| + r := b.retention(true) |
| + r.rootPins = release.PinSourceFunc(func(context.Context, string) (release.StagedPaths, error) { return nil, os.ErrPermission }) |
| + b.ship("shop", app, demoVer(5)) |
| + b.pass(r, false) |
| + if got := b.outputs("shop", app); !slices.Equal(got, before) { |
| + t.Fatalf("an unreadable pin source: store %v -> %v (want the stage refused and nothing deleted)", before, got) |
| + } |
| +} |
| + |
| +// The cleanup and retention touch only demo apps of this box's demo |
| +// account, and nothing at all on a box that is not a demo box. |
| +func TestDemoRetentionLeavesNonDemoBoxesAndAppsAlone(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + for i := 1; i <= 4; i++ { |
| + b.ship("shop", app, demoVer(i)) |
| + r := b.retention(true) |
| + r.box = demo.Config{} |
| + b.pass(r, true) |
| + } |
| + if got := b.outputs("shop", app); len(got) != 4 { |
| + t.Fatalf("a box that is not a demo box ran retention: %v", got) |
| + } |
| + if _, err := b.record.Read(demoRetentionRecord); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("a non-demo box wrote the record: %v", err) |
| + } |
| +} |
| + |
| +// adoptedAt stages builds 1..staged of name's app and leaves the demo at |
| +// live (adopted through its live link, the row naming live and prev), as |
| +// a box would after those updates: the builds below prev are beyond the |
| +// bound, and those above live were never adopted. |
| +func (b *retentionBox) adoptedAt(name string, staged, prev, live int) { |
| + b.t.Helper() |
| + app := demoAppName(name) |
| + for i := 1; i <= staged; i++ { |
| + if err := release.StageArtifact(b.opt, retentionDemo.Account, demoVer(i), app, []byte("build "+demoVer(i))); err != nil { |
| + b.t.Fatal(err) |
| + } |
| + } |
| + if err := b.reg.SetVersions(demoHost(name), demoVer(live), demoVer(prev)); err != nil { |
| + b.t.Fatal(err) |
| + } |
| + for _, v := range []int{prev, live} { |
| + if err := release.PointLive(context.Background(), nil, b.opt, demoHost(name), retentionDemo.Account, demoVer(v), app); err != nil { |
| + b.t.Fatal(err) |
| + } |
| + } |
| +} |
| + |
| +// forgedLister is the registry with rows the service could write: a forged |
| +// row replaces the real row of its host, or is added. Retention must read |
| +// them as protection only. |
| +type forgedLister struct { |
| + reg routeLister |
| + rows []registry.Route |
| +} |
| + |
| +func (f forgedLister) List() ([]registry.Route, error) { |
| + rows, err := f.reg.List() |
| + added := slices.Clone(f.rows) |
| + for i, rt := range rows { |
| + for j, forged := range added { |
| + if forged.Host == rt.Host { |
| + rows[i] = forged |
| + added = slices.Delete(added, j, j+1) |
| + break |
| + } |
| + } |
| + } |
| + return append(rows, added...), err |
| +} |
| + |
| +// Registry rows are service-owned, so they may only add protection (Astra |
| +// round 1 P1-2). What makes an output eligible is root's: the box's demo |
| +// account from host.env and a tmp-demo- name it lists in its own store. |
| +// A malformed descriptor, a second row running the app as something other |
| +// than a demo, and a name that climbs out of the store select nothing. |
| +func TestDemoRetentionRegistryRowsOnlyAddProtection(t *testing.T) { |
| + cases := []struct { |
| + name string |
| + forge func(b *retentionBox) []registry.Route |
| + kept bool |
| + }{ |
| + {"valid demo row", func(b *retentionBox) []registry.Route { return nil }, false}, |
| + {"malformed descriptor", func(b *retentionBox) []registry.Route { |
| + rt := b.route("red") |
| + rt.DemoID = "not-a-demo-id" |
| + return []registry.Route{rt} |
| + }, true}, |
| + {"conflicting non-demo row", func(b *retentionBox) []registry.Route { |
| + rt := b.demoRow("red", true) |
| + rt.Host, rt.Socket = "shop.example.org", provision.NestedSocket("shop.example.org") |
| + rt.DemoID, rt.DemoHost, rt.DemoLifetime, rt.DemoExpiresAt = "", "", "", 0 |
| + return []registry.Route{rt} |
| + }, true}, |
| + } |
| + for _, c := range cases { |
| + t.Run(c.name, func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 4, 3, 4) |
| + if rows := c.forge(b); rows != nil { |
| + b.lister = forgedLister{reg: b.reg, rows: rows} |
| + } |
| + res := b.retention(true).run(context.Background()) |
| + got := b.outputs("shop", demoAppName("red")) |
| + if c.kept && len(got) != 4 { |
| + t.Fatalf("a registry row made builds eligible: store %v (%+v)", got, res) |
| + } |
| + if !c.kept { |
| + if !sameSet(got, []string{demoVer(3), demoVer(4)}) { |
| + t.Fatalf("control: store %v, want v3 and v4 (%+v)", got, res) |
| + } |
| + return |
| + } |
| + // The app is held, not pinned: what it keeps beyond the bound is |
| + // backlog, the record names it and why, and its next stages are |
| + // refused, so successive updates do not grow the store. |
| + if s := b.status(); s.Backlog != 2 || !strings.Contains(s.Reason, demoAppName("red")) || s.BacklogSince.IsZero() { |
| + t.Fatalf("held app's record %+v", s) |
| + } |
| + for i := 5; i <= 7; i++ { |
| + b.ship("shop", demoAppName("red"), demoVer(i)) |
| + b.pass(b.retention(true), false) |
| + if v, got := b.route("red").Version, b.outputs("shop", demoAppName("red")); v != demoVer(4) || len(got) != 4 { |
| + t.Fatalf("update %d of a held app: route %q, store %v (want the stage refused)", i, v, got) |
| + } |
| + if s := b.status(); s.Backlog != 2 || !strings.Contains(s.Reason, demoAppName("red")) { |
| + t.Fatalf("update %d: record %+v", i, s) |
| + } |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// A demo-marked row whose app climbs out of the version store makes root |
| +// neither read nor count nor remove anything outside it: names come from |
| +// root's listing of its own store, validated before any use. |
| +func TestDemoRetentionTraversalNameReachesNothingOutsideTheStore(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 4, 3, 4) |
| + outside := filepath.Join(b.opt, "outside") |
| + if err := os.WriteFile(outside, []byte("not a build"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + rt := b.demoRow("red", true) |
| + rt.Host, rt.DemoHost = "climb."+retentionDemo.Domain, "climb."+retentionDemo.Domain |
| + rt.App = demo.AppPrefix + "x/../../../../outside" |
| + rt.Version = demoVer(99) |
| + b.lister = forgedLister{reg: b.reg, rows: []registry.Route{rt}} |
| + r := b.retention(true) |
| + var removed []string |
| + r.onRemove = func(p string) { removed = append(removed, p) } |
| + res := r.run(context.Background()) |
| + if _, err := os.Stat(outside); err != nil { |
| + t.Fatalf("the file outside the store: %v", err) |
| + } |
| + for _, p := range removed { |
| + if rel, err := filepath.Rel(filepath.Join(b.opt, "versions"), p); err != nil || strings.HasPrefix(rel, "..") { |
| + t.Fatalf("a removal outside the store: %s", p) |
| + } |
| + } |
| + if res.err != nil || res.outputs != 2 { |
| + t.Fatalf("retention counted or tried something outside the store: %+v", res) |
| + } |
| + if got := b.outputs("shop", demoAppName("red")); !sameSet(got, []string{demoVer(3), demoVer(4)}) { |
| + t.Fatalf("store %v", got) |
| + } |
| +} |
| + |
| +// The ops account keeps the pre-accounts layout (<ver>/<app>), shared with |
| +// every ops app, and the console never places demos there. A demo box |
| +// configured with it refuses loudly: every demo stage is refused and the |
| +// retention record says why. Nothing is skipped silently. |
| +func TestDemoRetentionRefusesADemoAccountOnTheOpsLayout(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + rt := b.demoRow("red", true) |
| + rt.Account = release.OpsAccount |
| + if err := b.reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.ship(release.OpsAccount, app, demoVer(1)) |
| + // Already staged with the release's bytes: the pass would reuse it, not |
| + // write it, so the refusal must come before reuse. |
| + if err := release.StageArtifact(b.opt, release.OpsAccount, demoVer(1), app, []byte(app+" build "+demoVer(1))); err != nil { |
| + t.Fatal(err) |
| + } |
| + r := b.retention(true) |
| + r.box.Account = release.OpsAccount |
| + b.pass(r, false) |
| + if v := b.route("red").Version; v != "" { |
| + t.Fatalf("a demo build was adopted on the ops layout: route at %q", v) |
| + } |
| + err := r.beforeStage(context.Background(), release.VersionPath(b.opt, release.OpsAccount, demoVer(2), app)) |
| + if err == nil || !strings.Contains(err.Error(), "ops account") { |
| + t.Fatalf("beforeStage = %v, want a refusal naming the ops account", err) |
| + } |
| + res := r.run(context.Background()) |
| + if res.err == nil || !strings.Contains(b.status().Reason, "ops account") { |
| + t.Fatalf("retention did not refuse: %+v, record %+v", res, b.status()) |
| + } |
| +} |
| + |
| +// A box upgraded with failed outputs already piled up: retention keeps the |
| +// pins and the newest output never adopted, and removes the older pending |
| +// ones under the lock. Pending names it cannot order are kept and counted |
| +// as backlog. |
| +func TestDemoRetentionPreExistingPendingOutputs(t *testing.T) { |
| + t.Run("ordered", func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 6, 2, 3) |
| + res := b.retention(true).run(context.Background()) |
| + if got := b.outputs("shop", demoAppName("red")); !sameSet(got, []string{demoVer(2), demoVer(3), demoVer(6)}) { |
| + t.Fatalf("store %v, want the pins v2 and v3 and the newest pending v6 (%+v)", got, res) |
| + } |
| + if s := b.status(); s.Backlog != 0 || s.Outputs != 3 { |
| + t.Fatalf("record %+v", s) |
| + } |
| + }) |
| + t.Run("unordered", func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 3, 2, 3) |
| + for _, v := range []string{"v8-custom", "v9-custom"} { |
| + if err := release.StageArtifact(b.opt, "shop", v, demoAppName("red"), []byte("build")); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + b.retention(true).run(context.Background()) |
| + if got := b.outputs("shop", demoAppName("red")); !sameSet(got, []string{demoVer(2), demoVer(3), "v8-custom", "v9-custom"}) { |
| + t.Fatalf("store %v", got) |
| + } |
| + if s := b.status(); s.Backlog != 1 || s.BacklogSince.IsZero() { |
| + t.Fatalf("record %+v, want one pending output reported beyond the bound", s) |
| + } |
| + }) |
| +} |
| + |
| +// BoxPins reports another app's unreadable settings references with the |
| +// pins it did read (IncompleteRefsError). Retention keeps those pins and |
| +// holds only the apps the error covers: another app's bad column does not |
| +// stop the demo's retention; the demo's own stops its retention and |
| +// refuses its next stage. |
| +func TestDemoRetentionIncompleteReferencesStopOnlyTheirApp(t *testing.T) { |
| + manual, err := json.Marshal(release.UpdateSettings{Updates: release.UpdatesManual}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Run("another app", func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.addDemo("blue", true) |
| + b.adoptedAt("red", 4, 3, 4) |
| + if err := b.reg.Upsert(registry.Route{Host: "blog.example.org", Kind: "instance", Account: "other", App: "blog", Channel: "edge", Status: "ready"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, host := range []string{"blog.example.org", demoHost("blue")} { |
| + if err := b.reg.SetUpdateSettings(host, string(manual)); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + res := b.retention(true).run(context.Background()) |
| + if got := b.outputs("shop", demoAppName("red")); !sameSet(got, []string{demoVer(3), demoVer(4)}) { |
| + t.Fatalf("another app's references stopped the demo's retention: store %v (%+v)", got, res) |
| + } |
| + }) |
| + t.Run("its own", func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 4, 3, 4) |
| + if err := b.reg.SetUpdateSettings(demoHost("red"), string(manual)); err != nil { |
| + t.Fatal(err) |
| + } |
| + r := b.retention(true) |
| + res := r.run(context.Background()) |
| + if got := b.outputs("shop", demoAppName("red")); len(got) != 4 { |
| + t.Fatalf("the demo's own unread references deleted builds: %v", got) |
| + } |
| + if s := b.status(); res.err == nil || s.Backlog != 2 || s.Reason == "" { |
| + t.Fatalf("result %+v, record %+v", res, s) |
| + } |
| + if err := r.beforeStage(context.Background(), release.VersionPath(b.opt, "shop", demoVer(5), demoAppName("red"))); err == nil { |
| + t.Fatal("the demo's next stage was not refused") |
| + } |
| + }) |
| +} |
| + |
| +// The composition runAdoptUnderRootRelease uses: no retention on the narrow |
| +// passes, locked only when the pass lock was taken, hourly unless |
| +// -stage-only. |
| +func TestAdoptPassRetentionFollowsTheModeAndTheLock(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + built := 0 |
| + build := func(locked bool) *demoRetention { built++; return b.retention(locked) } |
| + lockErr := errors.New("lock file unavailable") |
| + for _, c := range []struct { |
| + name string |
| + configOnly, restartOnly, stage bool |
| + lockErr error |
| + wantNil, wantLocked, wantHourly bool |
| + }{ |
| + {name: "normal", wantLocked: true, wantHourly: true}, |
| + {name: "stage-only", stage: true, wantLocked: true}, |
| + {name: "lock failure", lockErr: lockErr, wantHourly: true}, |
| + {name: "config-only", configOnly: true, wantNil: true}, |
| + {name: "restart-only", restartOnly: true, wantNil: true}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + built = 0 |
| + r, hourly := adoptPassRetention(c.configOnly, c.restartOnly, c.stage, c.lockErr, build) |
| + if c.wantNil { |
| + if r != nil || built != 0 { |
| + t.Fatalf("a narrow pass built retention: %v (%d)", r, built) |
| + } |
| + return |
| + } |
| + if r == nil || r.locked != c.wantLocked || hourly != c.wantHourly { |
| + t.Fatalf("retention %+v hourly %v", r, hourly) |
| + } |
| + }) |
| + } |
| + // Without the lock it deletes nothing and refuses a demo stage. |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 4, 3, 4) |
| + r, _ := adoptPassRetention(false, false, false, lockErr, build) |
| + r.run(context.Background()) |
| + if got := b.outputs("shop", demoAppName("red")); len(got) != 4 { |
| + t.Fatalf("retention without the lock deleted: %v", got) |
| + } |
| + if err := r.beforeStage(context.Background(), release.VersionPath(b.opt, "shop", demoVer(5), demoAppName("red"))); err == nil { |
| + t.Fatal("a stage without the lock was not refused") |
| + } |
| +} |
| + |
| +// The production orchestration (adoptPassAround around a real |
| +// release.Pass) gates every demo adoption on the adopt pass lock before |
| +// release processing reaches the output: the next build already staged |
| +// with the release's bytes (reuse) or with other bytes (restage) is not |
| +// adopted without the lock, and is with it. A -config-only or |
| +// -restart-only composition builds no retention, so its pass is the plain |
| +// release pass, as before (and production returns before it anyway). |
| +func TestAdoptPassAroundGatesDemoAdoptionOnTheLock(t *testing.T) { |
| + app := demoAppName("red") |
| + lockErr := errors.New("lock file unavailable") |
| + release2 := []byte(app + " build " + demoVer(2)) |
| + for _, c := range []struct { |
| + name string |
| + staged []byte |
| + configOnly, restartOnly bool |
| + lockErr error |
| + want string |
| + }{ |
| + {name: "reuse without the lock", staged: release2, lockErr: lockErr, want: demoVer(1)}, |
| + {name: "restage without the lock", staged: []byte("other bytes"), lockErr: lockErr, want: demoVer(1)}, |
| + {name: "reuse with the lock", staged: release2, want: demoVer(2)}, |
| + {name: "restage with the lock", staged: []byte("other bytes"), want: demoVer(2)}, |
| + {name: "config-only", staged: release2, configOnly: true, lockErr: lockErr, want: demoVer(2)}, |
| + {name: "restart-only", staged: release2, restartOnly: true, lockErr: lockErr, want: demoVer(2)}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + b.addDemo("red", true) |
| + b.ship("shop", app, demoVer(1)) |
| + b.pass(b.retention(true), true) |
| + b.ship("shop", app, demoVer(2)) |
| + if err := release.StageArtifact(b.opt, "shop", demoVer(2), app, c.staged); err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx := context.Background() |
| + err := adoptPassAround(ctx, c.configOnly, c.restartOnly, false, c.lockErr, b.retention, func(demo ...release.PassOption) error { |
| + return release.Pass(ctx, b.reg, b.store, b.pub, b.opt, b.restart, append([]release.PassOption{release.BakeDir(b.data)}, demo...)...) |
| + })() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if v := b.route("red").Version; v != c.want { |
| + t.Fatalf("route at %q, want %q", v, c.want) |
| + } |
| + if got := b.outputs("shop", app); !slices.Contains(got, demoVer(2)) { |
| + t.Fatalf("v2's output is gone: %v", got) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// A box whose host.env says it is a demo box but whose demo settings do not |
| +// validate adopts no demo build at all: it cannot tell which are its demo |
| +// outputs, so it neither bounds nor protects them. |
| +func TestAdoptPassAroundRefusesDemoBuildsOnAMisconfiguredDemoBox(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + b.ship("shop", app, demoVer(1)) |
| + if err := release.StageArtifact(b.opt, "shop", demoVer(1), app, []byte(app+" build "+demoVer(1))); err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx := context.Background() |
| + build := func(locked bool) *demoRetention { |
| + r := b.retention(locked) |
| + r.box, r.boxErr = demo.Config{}, demo.ErrConfig |
| + return r |
| + } |
| + if err := adoptPassAround(ctx, false, false, false, nil, build, func(demo ...release.PassOption) error { |
| + return release.Pass(ctx, b.reg, b.store, b.pub, b.opt, b.restart, append([]release.PassOption{release.BakeDir(b.data)}, demo...)...) |
| + })(); err != nil { |
| + t.Fatal(err) |
| + } |
| + if v := b.route("red").Version; v != "" { |
| + t.Fatalf("a misconfigured demo box adopted a demo build: %q", v) |
| + } |
| +} |
| + |
| +// Backlog is an accounting invariant, not a by-product of deletion: every |
| +// output an app keeps above its bound (8 plus what generations reserve) |
| +// counts, however it is pinned. Twelve outputs, the real row pinning the |
| +// newest, three conflicting non-demo rows pinning the nine oldest through |
| +// their Version, PrevVersion and GoodVersion: all twelve stay, the app is |
| +// held and its stage refused, and the backlog is the four above the bound. |
| +func TestDemoRetentionBacklogCountsAHeldAppsPinnedExcess(t *testing.T) { |
| + b := newRetentionBox(t, "") |
| + app := demoAppName("red") |
| + b.addDemo("red", true) |
| + b.adoptedAt("red", 12, 11, 12) |
| + var rows []registry.Route |
| + for i, host := range []string{"a.example.org", "b.example.org", "c.example.org"} { |
| + rt := b.demoRow("red", true) |
| + rt.Host, rt.Socket = host, provision.NestedSocket(host) |
| + rt.DemoID, rt.DemoHost, rt.DemoLifetime, rt.DemoExpiresAt = "", "", "", 0 |
| + rt.Version, rt.PrevVersion, rt.GoodVersion = demoVer(3*i+1), demoVer(3*i+2), demoVer(3*i+3) |
| + rows = append(rows, rt) |
| + } |
| + b.lister = forgedLister{reg: b.reg, rows: rows} |
| + r := b.retention(true) |
| + r.run(context.Background()) |
| + if got := b.outputs("shop", app); len(got) != 12 { |
| + t.Fatalf("store %v, want all twelve kept", got) |
| + } |
| + if s := b.status(); s.Backlog != 4 || s.BacklogSince.IsZero() || !strings.Contains(s.Reason, app) { |
| + t.Fatalf("record %+v, want backlog 4 (twelve kept, bound eight) and the hold named", s) |
| + } |
| + if err := r.beforeStage(context.Background(), release.VersionPath(b.opt, "shop", demoVer(13), app)); err == nil { |
| + t.Fatal("the held app's next stage was not refused") |
| + } |
| + published, err := readDemoBuilds(func() (rootstate.Store, error) { return b.record, nil }) |
| + if want := []string{app + ": " + heldByRow}; err != nil || published.Backlog != 4 || !slices.Equal(published.Held, want) { |
| + t.Fatalf("published %+v (%v), want backlog 4 and held %v", published, err, want) |
| + } |
| +} |
| + |
| +// The accounting invariant, as a guard: whatever pins, holds, pending |
| +// state and reservations the outputs carry, and whichever removals fail, |
| +// the backlog is at least every app's kept outputs above its bound |
| +// (demoOutputBound plus its reserved ones), and at least what retention |
| +// should have removed and kept. |
| +func TestDemoBacklogCoversEveryOutputAboveTheBound(t *testing.T) { |
| + rng := rand.New(rand.NewPCG(1, 2)) |
| + sawOver := 0 |
| + for trial := 0; trial < 2000; trial++ { |
| + var outs []demoOutput |
| + for app := 0; app < 3; app++ { |
| + n := rng.IntN(24) |
| + for v := 1; v <= n; v++ { |
| + o := demoOutput{demoAppKey: demoAppKey{"shop", fmt.Sprintf("app%d", app)}, version: demoVer(v)} |
| + o.pinned, o.inFlight, o.reserved = rng.IntN(2) == 0, rng.IntN(3) == 0, rng.IntN(5) == 0 |
| + if rng.IntN(4) == 0 { |
| + o.held = heldByRow |
| + } |
| + outs = append(outs, o) |
| + } |
| + } |
| + remove, unremoved := planRemovals(outs) |
| + gone := map[int]bool{} |
| + for _, i := range remove { |
| + if rng.IntN(4) == 0 { |
| + unremoved[outs[i].app]++ // a removal that failed |
| + continue |
| + } |
| + gone[i] = true |
| + } |
| + var kept []demoOutput |
| + count, reserved := map[string]int{}, map[string]int{} |
| + for i, o := range outs { |
| + if gone[i] { |
| + continue |
| + } |
| + kept = append(kept, o) |
| + count[o.app]++ |
| + if o.reserved { |
| + reserved[o.app]++ |
| + } |
| + } |
| + backlog := demoBacklog(kept, unremoved) |
| + over, owed := 0, 0 |
| + for app, n := range count { |
| + over += max(n-demoOutputBound-reserved[app], 0) |
| + } |
| + for _, n := range unremoved { |
| + owed += n |
| + } |
| + if over > 0 { |
| + sawOver++ |
| + } |
| + if backlog < over || backlog < owed { |
| + t.Fatalf("trial %d: backlog %d, but %d outputs are above the bound and %d were not removed", trial, backlog, over, owed) |
| + } |
| + for i := range outs { |
| + if gone[i] && (outs[i].pinned || outs[i].held != "") { |
| + t.Fatalf("trial %d: removed a pinned or held output %+v", trial, outs[i]) |
| + } |
| + } |
| + } |
| + if sawOver < 100 { |
| + t.Fatalf("only %d trials kept an app above its bound; the guard needs many", sawOver) |
| + } |
| +} |
diff --git a/internal/host/metrics_loop.go b/internal/host/metrics_loop.go| index 8d077a615..8ac3df446 100644 |
| --- a/internal/host/metrics_loop.go |
| +++ b/internal/host/metrics_loop.go |
| @@ -44,7 +44,10 @@ type sampleProbes struct { |
| owners func() map[string]metrics.Vouch |
| // restarts is each platform unit's systemd restart counter (see |
| // restartWatch). A nil func, or a nil map from it, is "could not ask". |
| - restarts func() map[string]unitRestartState |
| + restarts func() map[string]unitRestartState |
| + // demoDisk is a demo box's disk numbers for the disk rule |
| + // (demoDiskProbe); nil on any other box. |
| + demoDisk func() *status.DemoDisk |
| now func() time.Time |
| departures func() *metrics.DepartureSample |
| } |
| @@ -536,11 +539,26 @@ func alertTick(ctx context.Context, s release.Store, box string, rules metrics.R |
| sinks *alertSinks, trend *diskTrend, beat *engineBeatWatch) error { |
| rules.DiskFrac = diskAlertFrac(rules.DiskFrac, extra.diskTotal, extra.staticTree) |
| + // A demo box's disk rule reads the highest of the readings it has: the |
| + // data disk's blocks from the host sample, and demoFill (/data's blocks |
| + // and inodes, /run's bytes and inodes). Either alone is an observation; |
| + // with neither the rule stays as it was. |
| + var disk *diskReading |
| + if latest.Host.DiskFrac != nil { |
| + disk = &diskReading{frac: *latest.Host.DiskFrac, where: diskWhereData} |
| + } |
| + if extra.demoFill != nil && (disk == nil || extra.demoFill.frac > disk.frac) { |
| + disk = extra.demoFill |
| + } |
| + var diskFrac *float64 |
| + if disk != nil { |
| + diskFrac = &disk.frac |
| + } |
| obs := metrics.Observation{ |
| At: latest.At, |
| CPUFrac: latest.Host.CPUFrac, |
| MemFrac: latest.Host.MemFrac, |
| - DiskFrac: latest.Host.DiskFrac, |
| + DiskFrac: diskFrac, |
| LagSecs: nil, // v1: no lag reading feeds the agent loop yet |
| GeoIP: geoIPAlertReading(latest.At), |
| Restarts: extra.restarts, |
| @@ -581,6 +599,10 @@ func alertTick(ctx context.Context, s release.Store, box string, rules metrics.R |
| if !boxSinkRule(ev.Rule) { |
| continue |
| } |
| + if ev.Rule == "disk" && extra.demoFill != nil && disk != nil { |
| + // A demo box's message names the filesystem it measured. |
| + ev.Where = disk.where |
| + } |
| sinks.deliver(ctx, rules, latest.At, ev) |
| } |
| @@ -613,6 +635,11 @@ type alertReadings struct { |
| // verify is the restore drill's standing, read from its local copy |
| // each tick (verifyWatch); nil leaves the verify rules as they were. |
| verify *metrics.VerifyReading |
| + // demoFill is a demo box's highest use of /data's blocks and inodes and |
| + // /run's bytes and inodes, and which it was (demoDiskFill); the disk |
| + // rule reads the higher of it and the data disk's blocks. nil on any |
| + // other box. |
| + demoFill *diskReading |
| } |
| // verifyWatch reads the restore drill's local copy of this box's record |
| @@ -780,6 +807,7 @@ func realSampleProbes(execRoot string, src unitSources, owners func() map[string |
| }, |
| owners: owners, |
| restarts: platformUnitRestarts, |
| + demoDisk: productionDemoDiskProbe(), |
| now: time.Now, |
| } |
| } |
| @@ -1004,6 +1032,9 @@ func metricsLoop(execRoot string, src unitSources, owners func() map[string]metr |
| } |
| restartTick := func(at time.Time) alertReadings { |
| extra := alertReadings{restarts: restarts.tick(at, probes.restarts()), verify: verify.read(at)} |
| + if probes.demoDisk != nil { |
| + extra.demoFill = demoDiskFill(probes.demoDisk()) |
| + } |
| if _, total, ok := probes.diskBytes(); ok { |
| extra.diskTotal, extra.staticTree = total, largestStaticTree() |
| } |
diff --git a/internal/host/statfs_unix.go b/internal/host/statfs_unix.go| index a57f9ceba..226b2e835 100644 |
| --- a/internal/host/statfs_unix.go |
| +++ b/internal/host/statfs_unix.go |
| @@ -2,7 +2,11 @@ |
| package host |
| -import "syscall" |
| +import ( |
| + "syscall" |
| + |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| // diskBytes reports the total and available bytes of the filesystem holding |
| // dir. |
| @@ -19,3 +23,14 @@ func diskBytes(dir string) (total, avail uint64, err error) { |
| } |
| return uint64(st.Blocks) * uint64(st.Bsize), uint64(st.Bavail) * uint64(st.Bsize), nil |
| } |
| + |
| +// filesystemRoom is dir's filesystem in bytes and inodes: free to an |
| +// unprivileged writer (Bavail), and the totals. |
| +func filesystemRoom(dir string) (*status.FilesystemRoom, error) { |
| + var st syscall.Statfs_t |
| + if err := syscall.Statfs(dir, &st); err != nil { |
| + return nil, err |
| + } |
| + return &status.FilesystemRoom{FreeBytes: int64(uint64(st.Bavail) * uint64(st.Bsize)), Bytes: int64(uint64(st.Blocks) * uint64(st.Bsize)), |
| + FreeInodes: int64(uint64(st.Ffree)), Inodes: int64(uint64(st.Files))}, nil |
| +} |
diff --git a/internal/host/statfs_windows.go b/internal/host/statfs_windows.go| index 00777bc67..c9849f3a1 100644 |
| --- a/internal/host/statfs_windows.go |
| +++ b/internal/host/statfs_windows.go |
| @@ -2,7 +2,11 @@ |
| package host |
| -import "errors" |
| +import ( |
| + "errors" |
| + |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| // diskBytes has no Windows implementation: this package's disk readings |
| // describe a CARLOS box's /data volume, and boxes are Linux. Windows builds |
| @@ -13,3 +17,8 @@ import "errors" |
| func diskBytes(dir string) (total, avail uint64, err error) { |
| return 0, 0, errors.New("disk readings are box-side (linux) only") |
| } |
| + |
| +// filesystemRoom has no Windows implementation, for the same reason. |
| +func filesystemRoom(dir string) (*status.FilesystemRoom, error) { |
| + return nil, errors.New("disk readings are box-side (linux) only") |
| +} |
diff --git a/internal/metrics/alert.go b/internal/metrics/alert.go| index d28256cce..c9077f902 100644 |
| --- a/internal/metrics/alert.go |
| +++ b/internal/metrics/alert.go |
| @@ -195,6 +195,11 @@ type Event struct { |
| Firing bool `json:"firing"` // true=fired, false=cleared |
| Value float64 `json:"value"` |
| Box string `json:"box"` |
| + // Where is what a disk event measured, when the box says ("/data", |
| + // "/data inodes", "/run", "/run inodes"): a demo box's disk rule reads |
| + // several filesystems, and its message names the one it read. Evaluate |
| + // never sets it. |
| + Where string `json:"where,omitempty"` |
| } |
| // AlertKey is the bucket key an AlertState for box is stored/published |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index a498ea6e7..418257483 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -322,4 +322,5 @@ plan14-root-reads-sec-h3-m2-scoped-key.tsv 4f307fb962a2aac71640ebc18058c02a29d6c |
| plan14-root-reads-sec-h4-m11-stepup-fold.tsv 13d05e2a4038ca4978d27a38be07e96025ee6f00f39519c41a3000e2dda3b387 |
| plan14-root-reads-sec-h3-m6-leftover-host.tsv 8e42c8ece77bba4ec895af4d7cae0aa80aec06885b7614cc1c5c572f9ef9ebc4 |
| plan14-root-reads-sec-h2-flat-tier.tsv 161480ee42d34728c5aed23cb86d36aa5651ed915b43d28eb659f84d7702e897 |
| -plan14-root-reads-instance-senders-1.tsv 161480ee42d34728c5aed23cb86d36aa5651ed915b43d28eb659f84d7702e897 |
| +plan14-root-reads-demo-disk-slice1-retention.tsv 0586b6f6d50249a42fbf72bb02545476c042d1c8a357c91d75432315997ae7a3 |
| +plan14-root-reads-instance-senders-1.tsv 0586b6f6d50249a42fbf72bb02545476c042d1c8a357c91d75432315997ae7a3 |
diff --git a/internal/provision/testdata/plan14-root-reads-demo-disk-slice1-retention.tsv b/internal/provision/testdata/plan14-root-reads-demo-disk-slice1-retention.tsv| new file mode 100644 |
| index 000000000..c4f324e17 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-demo-disk-slice1-retention.tsv |
| @@ -0,0 +1,51 @@ |
| +# Census overlay demo-disk-slice1-retention, written by census-propose (#369). census-ruling-demo-disk-slice1-retention, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-demo-disk-slice1-retention.md. |
| +# 4 body, 1 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 18 new dispositions: 0 reads re-frozen at their disposition with the claim, 18 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy dfdac780af1ba03d1e9b022e0709ef33c6ba04e44a7741616d64490fac67c020 internal/host/agent.go statusLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's context carries the box's lifetime judge; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 953b9fda (its later changes, regional box names and self-serve moves plan 1 among them, under main's own census rulings), where the tick fills rootfs_ready and rootfs_blocked from armedRootfs.Load().probe, which each tick runs NestedOK's checks and asks the control socket's GET /ready/rootfs (never the store); the same four direct sites;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: takes root's GET /egress reader and fills p.Egress = egressStatusProbe(egressStatus, routes, provision.PolicyReadStates()) and p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes); the two added whole:Route sites are the tick's own registry list handed to those two units (decision rows), which read root's control socket and the activator's memory; no store request added; the four existing sites unchanged, offsets moved.;rev3=census-ruling-fleet-alerts-1;basis=the agent (carlos-edge.service, user carlos): the status tick passes os.Geteuid() to alertDeliveryProbe, which fills AlertDelivery.EngineBeat/EngineBeatWhy from engineBeatArmed (the env value and the euid only, no file access, root refused before the path is looked at), and fills Probes.DiskFullETAHours from diskETAProbe(&processDiskTrend, now), a Theil-Sen fit over the metrics loop's in-memory ring of disk readings; the same six sites, no read added, no store request added;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's Probes gain HeldStreams: heldStreamsState(), which calls the edge's in-memory counters function (nil until the edge is ready). No file, bucket or registry access added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: read the detached in-memory replica snapshot source into Probes.ReplicaCopies on the existing five-minute tick. Existing six direct read sites unchanged. No additional bucket request, changed cadence or app lifecycle action.;rev3=census-ruling-agent-start-demo-3;basis=Report moved capability only when the serving edge reports readiness; report claim-seed support only with CARLOS_DEMO_CLAIM=1. Reads the explicit capability flag from the process environment; no new filesystem or registry read.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 fix round 1 (#511 R16 amendment): the status tick also fills Probes.ApplyFinished from systemApplyFinished(release.OptDir()), an Lstat of root's apply journal <opt>/system/router/journal.json in the root-owned, world-readable state directory: finished only when the journal is absent, any other answer unknown and so unfinished. Round 0: Probes.PrevRelease from prevReleaseOf (carlos.prev and carlos.prev.version, the files withMovesFields already reads). Reported in the private BoxMetrics block; no bucket request or cadence change.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the agent (carlos-edge.service, user carlos): the status tick fills p.OfflineMove = offlineMoveFactsProbe(routes); the added whole:Route site is the tick's own registry list handed to that unit, which under a non-root euid lists the names of root's <opt>/live and nothing else; no store request added.;rev3=census-ruling-platform-mail-submission;basis=Task 3 (plan gap G6 (b)): the status tick also fills Probes.MailerArmed from mailerArmed(mailwire.MailerSocket, 2s): a stat of /run/carlos-mailer/mailer.sock and, only when it is a socket, GET /v1/health on it. The agent (carlos-edge.service, user carlos), not root; reported in the private BoxMetrics block only. The same seven sites; no store request, no read of /etc/carlos-mailer (which uid carlos cannot traverse).;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 6: the agent (carlos-edge.service, user carlos) fills Probes.NamedUnits from readNamedUnitsStatus: rootstate.Open(/var/lib/carlos-named-units, false, true) status.json, 64 KiB cap, any error nil; report only, nothing reads it as authority; no store request added; the same sites;rev3=census-ruling-console-addr-from-install;basis=sets Probes.ConsoleFleet from consoleFleetProbe (root public store read, edge in-memory state); no read added in this unit;rev3=census-ruling-instance-usage;basis=the status tick adds one Probes field, InstanceUsageDroppedBytes, from instanceUsageDroppedBytes(): an in-process atomic counter of the per-instance flusher (0 when off); no new read of root-owned state, the same 7 read sites;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (carlos-edge.service, user carlos): the status tick also fills Probes.DemoDisk from readDemoDisk(), nil unless CARLOS_DEMO_BOX is set; statfs of /data and /run, and root's public retention record (readDemoBuilds); report only; no store request added; read sites unchanged whole:Route@10894,whole:Route@12968,whole:Route@13249,whole:Route@13607,whole:Route@6583,whole:Route@6610,whole:Route@7918 e77f5014b5439067462d2cc10da8bee12088798c4ca0f98236ea0c8c97a01b5c |
| +@legacy 6fa1f10d70f0321c9d4efbc4f8dd7e0d78b85d91c4dc0a2050cf27c6f85829db internal/status/snapshot.go CollectBox legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=copies Probes.RootfsReady and RootfsBlocked into BoxMetrics (private, like Layout); the same 28 sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: copies Probes.Egress and Probes.SizeCommittedMiB into BoxMetrics (private, like Layout) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate count is left as is (display);rev3=census-ruling-regional-domains-447;basis=#447 Task 7: copies Probes.AliasesRead into BoxMetrics.AliasesRead (json aliases_read, omitempty) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-alerts-1;basis=copies Probes.DiskFullETAHours into BoxMetrics.DiskFullETAHours (json disk_full_eta_hours, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-edge-held-streams;basis=copies Probes.HeldStreams into BoxMetrics.HeldStreams (json held_streams, omitempty, additive) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: carry already-supplied ReplicaCopies into a separate optional private BoxMetrics replica_copies field; allow copy evidence alone to create the metrics block. Upstreams retains address probes only. Existing 28 Route read sites unchanged; no filesystem, bucket, console or CLI read.;rev3=census-ruling-agent-start-demo-3;basis=Report claim-seed protocol capability only when explicitly configured and runtime moved readiness only when armed; dormant status keeps its original JSON shape. Census read-site delta: unchanged (28).;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 (#511 R16 and its amendment): copies Probes.PrevRelease and Probes.ApplyFinished into BoxMetrics (json prev_release and apply_finished, omitempty; private, like Release) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: copies Probes.OfflineMove into BoxMetrics.OfflineMove (json offline_move, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-platform-mail-submission;basis=Task 3: copies Probes.MailerArmed into BoxMetrics.MailerArmed (json mailer_armed, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 6: copies Probes.NamedUnits into BoxMetrics.NamedUnits (json named_units, omitempty; private) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-seeded-create-2;basis=Copies Probes.SeedsFloor into BoxMetrics.SeedsFloor and counts it in the metrics gate; a pure copy of a value the agent filled, the same 28 read sites, no read added.;rev3=census-ruling-console-addr-from-install;basis=copies Probes.ConsoleFleet into BoxMetrics (private); no read added;rev3=census-ruling-instance-usage;basis=copies Probes.InstanceUsageDroppedBytes into Box.InstanceUsageDroppedBytes (omitempty, a count only); the same 28 sites, no read added;rev3=census-ruling-demo-disk-slice1-retention;basis=copies Probes.DemoDisk into BoxMetrics.DemoDisk (json demo_disk, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added registry:Alias@4543,registry:CertExpiresAt@3160,registry:CertExpiresAt@3396,registry:CertExpiresAt@4658,registry:DBPath@2495,registry:DBPath@2553,registry:DNSCheckedAt@3365,registry:DNSCheckedAt@4627,registry:DNSStatus@3139,registry:DNSStatus@3334,registry:DNSStatus@4597,registry:Hibernate@3853,registry:Host@2295,registry:Host@2437,registry:Host@2666,registry:Host@3280,registry:Host@3315,registry:Host@4578,registry:Kind@2473,registry:Kind@3807,registry:Platform@2152,registry:ServingVersion@2324,registry:ServingVersion@2447,registry:Socket@4066,registry:Version@2186,registry:Version@2305,whole:Route@1581,whole:RouteAlias@4440 1f4a0869e4d36735afc9a9dc87001be8b8d7893b04fbf2a9f23617456bd5b431 |
| +@legacy 33e9339fd9c68f8111a3752a6c4f4a231701da32dc326e871f3bf6db056c705c cli.go printDemoDisk legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=operator CLI (carlos status --live), not root: prints a published box snapshot's demo_disk numbers; final round: also prints each held app (DemoBuilds.Held) even at zero backlog, and drops "the next adopt pass tries again" when an app is held; reads only the decoded snapshot in hand data-literal@195 cb3b0e70cb743b0008caa2192534c3e5b10c3d18f77d76b7be3270a5c008db25 |
| +@legacy ab78a1ae4f96b53be710038f91ee604c98f454164713853d5197c6c5e63113fe internal/host/demodisk_status.go const#1 legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos): diskWhereData, diskWhereDataInodes, diskWhereRun, diskWhereRunInodes, the names the disk alert gives what it measured; literals only data-literal@31,data-literal@62 8f6c997ccd711c80af2e16ffd9f9f1a5e70ae76a3f9936473baba389f9f0e92a |
| +@legacy 247e50229523fd4ee12c49fd765420996ceb6a5bc27924b5f0e0c496faf16b5b internal/host/demodisk_status.go productionDemoDiskProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos), not root: opens root's public record directory /var/lib/carlos-release/demo-retention read-only through rootstate.Open(dir, false, true) (every ancestor root-owned, not group or world writable); report only file:Open@208 f8df171d9a2ff2d96b73c63f4618d035230acc4b8f244dd7f377184686e4933f |
| +@legacy e3040c2b2f48acc545d68138008bee438e17fb174c6c4f64ae35a01bc2995225 internal/host/demodisk_status.go readDemoBuilds legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos): reads the record 'status' from root's public rootstate store (descriptor read, trusted owner, 1 MiB cap) and decodes it; schema 1 or an error; final round: also carries the record's Held list into status.DemoBuilds; report only, nothing reads it as authority file:Read@174 15a3c227b3a4736eb19d12d14b8318e49c092516d5584e04b216ea09a4da110c |
| +@legacy 0ac932962fab419bed6119c5551a9e092609eb41a00e2af64a6c480887b72b5c internal/host/demoretention.go demoOutput.spellings legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: EvalSymlinks of an output's directory <opt>/versions/<ver>/<demo account>, every component validated (ValidVersion, BoxConfig account, validDemoName), so an output is compared under the store's spelling and its real path; reads no registry input file:EvalSymlinks@118 abd6ff6fe0d0ffdd5989669aee8fcfc27713785a0a1bb6eb168bffa6a9975619 |
| +@legacy 55a515e9c574540696aeeae0772d4765551383ab309c8657c87b843b8d35311a internal/host/demoretention.go demoRetention.admitRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: the demo admission asked of every route before the release pass does anything with it; refuses a tmp-demo- route on a box whose host.env demo settings do not validate (boxErr; the message now names CARLOS_DEMO_BOX and the tuple), and on a demo box a route of the demo account when the demo account is the ops account, the name is not a demo name, or the pass does not hold the adopt pass lock. Only refuses; reads only the Route in hand and root's own config registry:App@537,registry:App@627,registry:App@97,whole:Route@419 1ac86a2725440d387be4e9e543c5c678c975100fd6635ec70d2c190269d84e34 |
| +@legacy df495c4d0cc6f5494f9a12341c1bdfce091f16df8b457eb18e3831a7ab81b4a0 internal/host/demoretention.go demoRetention.demoAdoptions legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: lists the registry and keeps the Host and Version of each row of the demo account whose App has the tmp-demo- prefix, to tell after the pass whether it adopted a demo version; decides only whether retention runs, never what it removes registry:App@314,registry:Host@347,registry:Version@358,whole:Route@237,whole:Route@272 1473fe874967ccf4538aed1887b15a9104427e1d0a6e1a537346146e7f7a5ea3 |
| +@legacy bba2b7a4d6bcc185d81068b0d2a0b1c8fa54b5109ab775561471222c3e018607 internal/host/demoretention.go demoRetention.listOutputs legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: ReadDir of <opt>/versions (root-owned) and of <opt>/versions/<ver>/<demo account> for each ValidVersion directory; each entry name, less .manifest.json, must pass validDemoName (tmp-demo- + demo.ValidPublicName: one path component, no "." or "..") before it is used; DirEntry.Info for sizes. ENOENT/ENOTDIR skip. Reads no registry input file:ReadDir@142,file:ReadDir@394 4febf4eebc952074eee6b0e52a97270a3e8c850e009a1db35f406c856a90a4f8 |
| +@legacy f60b04c33eff198ca9dfc5bf8731b6dbb4654f934ab5d57309205ea1caadef05 internal/host/demoretention.go demoRetention.pinSet legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: the pin set from every source: release.BoxPins over every registry row (live link chains; Version, PrevVersion, GoodVersion, settings references), previous links (linkTargets), release.GenerationPins over the generations file, and root's generation ledger. Final round: the two generation sources' pins are also returned apart (reserved), so the backlog can count an app's reserved outputs toward its G + R; the same reads. Strict: any source that does not read in full is an error, except BoxPins' IncompleteRefsError, returned for the caller to hold the apps it covers. Pins only ever keep builds; agent-writable inputs only ADD protection registry:App@1265,registry:App@1389,registry:GoodVersion@1230,registry:PrevVersion@1214,registry:Version@1202,whole:Route@1117,whole:Route@1161,whole:Route@1381,whole:Route@1657,whole:Route@743 83aaa6181597a48be05e8e2477c96284b2f3cabad5fc8450e76380a19f0aaea7 |
| +@legacy 1c435ce5cac8299a59e9da5224c119661436172b8841a31194ecc10c29386b5d internal/host/demoretention.go demoRetention.saveStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: reads its own previous record from the public root store /var/lib/carlos-release/demo-retention to carry the backlog's start, and writes the new record there; final round: the record also carries Held (each held app and why), kept from the previous record when nothing read; status only, never read back as a pin or a decision file:Read@289 069982567658454b581e2a626d68e8c5f289a5f01c58815f58c9a9ae9dd4baa5 |
| +@legacy 1cf1606aa1d518f12ae5ca8ad3c288cbe9d11d8ce2677d73ebb1d9e52b970f9e internal/host/demoretention.go demoRetention.selection legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: eligibility only from root's facts (demoAccount, listOutputs' listing of its own store). Registry rows (List; App, Version, the route for RouteAccount and validDemoRow) only ADD protection: pins, and holds. Final round: the added sites list the held apps of the demo account for the record (a row's App, validated by validDemoName, and its account), whether or not they have outputs, and mark outputs covered by the generation sources as reserved for the backlog. No registry string reaches a filesystem path; nothing here makes an output eligible registry:App@1505,registry:App@1530,registry:App@2038,registry:App@2064,registry:App@2090,registry:App@798,registry:Version@1479,registry:Version@1539,whole:Route@1407,whole:Route@1443,whole:Route@1974,whole:Route@2009,whole:Route@422,whole:Route@715,whole:Route@750,whole:Route@781 d08029b4f57ebf1d789670f78ae19d06dfdec68d6c9501135fff28c5d7183af1 |
| +@legacy 27ae0ae1be154c3291478034dd254fa832cfb41a0dd2f80ac91c3455d517c1a4 internal/host/demoretention.go demoRetention.validDemoRow legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: reads a registry row's demo descriptor (DemoID, DemoHost, DemoLifetime, DemoExpiresAt), Host, App and account and checks it with demo.Config.ValidateBinding against host.env's tuple. Its only effect is protection: a row of the demo account that fails keeps all of its app's builds; it never makes anything eligible registry:App@249,registry:DemoExpiresAt@157,registry:DemoHost@106,registry:DemoID@89,registry:DemoLifetime@129,registry:DemoLifetime@266,registry:Host@257,whole:Route@244 af1de52349984707d82e62de4f196c0be50ac9a29885e42f66beed160fa5f21a |
| +@legacy 7d960279e9455032ecf072dde3ce95035cc673ac8cd34f094d20a8304961c847 internal/host/demoretention.go linkTargets legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: ReadDir, Readlink and EvalSymlinks of the root-owned <opt>/previous and <opt>/live links, as release.LivePins reads them for the sweep (replaces previousLinkPins, same reads); an unreadable link is an error and nothing is deleted file:EvalSymlinks@509,file:ReadDir@77,file:Readlink@323 0174dc32626a8c188a893e048dcc68638192656b854c45e206076bff0b290537 |
| +@legacy 4cf360d827e1cc3aec8e519f527aafc500528e22a163a3cc0716cdd7bf978691 internal/host/demoretention.go productionDemoRetention legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: demo.BoxConfig from host.env (root-owned), now also keeping its error (boxErr) so a box that says it is a demo box with invalid settings refuses demo adoption; the version store and generations file paths, root's generation ledger, and the record store opener rootstate.Open(/var/lib/carlos-release/demo-retention, true, true) file:Open@528 100a780d488f0c1f9ace717410a5df3bdf8259014de08b456dc3ad4b43b2a02b |
| +@legacy 3b974d675442a49c90a22cacd91c82f61317b0a74a137f931aacca7abb9a38cb internal/host/statfs_unix.go filesystemRoom legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos): statfs of /data and /run for status and the disk alert; numbers only file:Statfs@102 bc0b7000ddb11715edd58a955d7950a1c19bfacb315b47d9575f7ac0a0a4a732 |
| +@legacy 22875aadec223885bd39acf3fbe0730e4938e3ca92e9ee1465a09425213c198d internal/release/adopt.go WithRouteAdmission legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=new PassOption: wraps fn so a refusal is printed once per host (rt.Host) and returns whether the route is admitted; reads only the Route handed to it, no file, store or registry read registry:Host@222,registry:Host@245,registry:Host@313,whole:Route@189 f2892b15ee19d20bc2f06f0fbb91a4c1e9bc04950560c1fa42043c2ef8cb3336 |
| +@legacy 4690fdc3a46578873b4782865046f5535e73bde7f6213d464db2d01390ad3bca internal/release/adopt.go passConfig.routeAdmitted legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=new: true without an admission option, otherwise the admission's answer for the Route in hand; reads nothing else whole:Route@111 52cc8b59fb4addc2753c3fbf2c20df81b4021045820eec27af5bb07c188a9503 |
| +@legacy 36814a480e2c91b2833082a70a5a01292608196aa1c5850793697ae572e3ae00 internal/release/adopt.go passConfig.stageWriteCheck legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass and agent passes: generationWriteCheck unchanged first; then, only when WithBeforeStage is set (root's adopt pass only), Lstat of the VersionPath about to be written and the callback when nothing is there; an error fails the stage (nothing written, route unchanged) file:Lstat@233 92aa097f88dc4c665a3564a8cd981537d2394857967be73230a0ef39648c48fd |
| +internal/host/agent.go runAdoptUnderRootRelease authority B3,E1,E2,E3 rev3=census-ruling-self-serve-moves-1;basis=root claim/adopt/update controller uid 0: builds root's lifetime judge once from the host-claim switch and hands it to both productionRestartRequestPass calls; read sites unchanged, offsets moved; the preceding B3,E1,E2,E3 classification retained;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the claims shutdown timeout is the host constant claimsShutdownLimit (120s) instead of hostbox.RequestLimit (120s); no read added or changed;rev3=census-ruling-named-unit-delivery-114;basis=config sync is appconfig.SyncUnits with productionUnitOps (drop-in root /etc/systemd/system, base dir /etc/carlos/units, the declaration file /etc/carlos/named-units.json, systemctl probe/reload/restart, the config flock); no proof binding and no bucket read for delivery (Paul's ruling on #114: a root-owned declaration decides); the comment at the restart callback rewritten; read sites unchanged;rev3=census-ruling-sr-followups;basis=#966 census fix: the SyncUnits ack callback is configAckRootFunc(ctx, store) instead of configAckFunc(ctx, store, "adopt"). configAckRootFunc (new, agent.go): on a box with a bucket or dir (doorFleet empty: no fleet identity, or CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR set in the process environment) it returns configAckFunc(ctx, store, "adopt"), the same callback as before #966 (platform-root key, read-then-CAS). On a door box it writes each ack through appconfig.ReplaceConfigAckBlind (new, configack.go) under NewPrefixStore(store, "fleets/<fleet>/"): s.Delete(key) then a create-only s.Put(key, body, ""), returning only errors, which are logged. THE ROOT PASS NO LONGER READS THE FLEET CORNER: it sends exactly DELETE and PUT for fleets/<F>/control/config-ack/<label>/<host>.json and no GET, Open or HEAD of any fleet key; it inspects no body, ETag or listing. Reads only the process environment (doorFleet, BoxLabel), as configAckFunc did. Read sites unchanged;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 4/5: after the restart-only return, calls runNamedUnitsStep, which runs adoptNamedUnitsStep (root reads its own IMDSv2 identity; ssm:GetParameter of /carlos/host/named-units/<instance-id> in that region, operator-written, box role read-only; trusted rootstate reads of /etc/carlos/named-units.json, the console guard marker, root's rollback journal and root history; installs under the config-sync flock), logs, and writes writeNamedUnitsStatus (public root store /var/lib/carlos-named-units), all before ParsePublicKey; config sync moved into adoptConfigSync with a second status write; no input a tenant, app or box agent can write selects the parameter or authorises the install; read sites unchanged;rev3=census-ruling-console-addr-from-install;basis=calls adoptConsoleFleetStep after the named-units step, never fatal (spec §4); no read added here;rev3=census-ruling-managed-fleets-2b2;basis=builds managedRootGate("/") (root's RootAdmission: identity + root 0700 admission files, re-verified) and wraps the round-1 start/selected-restart/rollback callbacks, SyncUnits' UnitOps.Restart and named-unit recovery with it; BYO answers admitted, so nothing changes there; merge of origin/main 65951fbb: main's configAckRootFunc ack, the named-units step (runNamedUnitsStep) with adoptConfigSync, and adoptConsoleFleetStep, not this branch; resolution: adoptConfigSync is handed managedGatedUnitOps(managedGate, productionUnitOps(...)), so SyncUnits' UnitOps.Restart keeps root's gate;rev3=census-ruling-demo-disk-slice1-retention;basis=demo disk bound slice 1, fix round 3: release.Pass runs inside adoptPassAround(ctx, configOnly, restartOnly, stageOnly, passLockErr, productionDemoRetentionFor(reg, generationPins), pass), still inside pr.around and under the adopt pass lock taken at the top; pass now receives two demo options, release.WithRouteAdmission(admitRoute) and release.WithBeforeStage(beforeStage). adoptPassRetention composes mode and lock (nil on -config-only/-restart-only, which also return before this line; locked = passLockErr == nil; hourly = !stageOnly). Witnessed through adoptPassAround around a real release.Pass (TestAdoptPassAroundGatesDemoAdoptionOnTheLock). No read added in this unit; read sites unchanged whole:Route@12586,whole:Route@20495,whole:Route@20531,whole:Route@8743 230707a96d0b7b141acac2a63faec13ff7dc3de6c33e97675ce5812f6d1f7113 |
| +internal/host/agent.go statusLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's context carries the box's lifetime judge; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 953b9fda (its later changes, regional box names and self-serve moves plan 1 among them, under main's own census rulings), where the tick fills rootfs_ready and rootfs_blocked from armedRootfs.Load().probe, which each tick runs NestedOK's checks and asks the control socket's GET /ready/rootfs (never the store); the same four direct sites;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: takes root's GET /egress reader and fills p.Egress = egressStatusProbe(egressStatus, routes, provision.PolicyReadStates()) and p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes); the two added whole:Route sites are the tick's own registry list handed to those two units (decision rows), which read root's control socket and the activator's memory; no store request added; the four existing sites unchanged, offsets moved.;rev3=census-ruling-fleet-alerts-1;basis=the agent (carlos-edge.service, user carlos): the status tick passes os.Geteuid() to alertDeliveryProbe, which fills AlertDelivery.EngineBeat/EngineBeatWhy from engineBeatArmed (the env value and the euid only, no file access, root refused before the path is looked at), and fills Probes.DiskFullETAHours from diskETAProbe(&processDiskTrend, now), a Theil-Sen fit over the metrics loop's in-memory ring of disk readings; the same six sites, no read added, no store request added;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's Probes gain HeldStreams: heldStreamsState(), which calls the edge's in-memory counters function (nil until the edge is ready). No file, bucket or registry access added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: read the detached in-memory replica snapshot source into Probes.ReplicaCopies on the existing five-minute tick. Existing six direct read sites unchanged. No additional bucket request, changed cadence or app lifecycle action.;rev3=census-ruling-agent-start-demo-3;basis=Report moved capability only when the serving edge reports readiness; report claim-seed support only with CARLOS_DEMO_CLAIM=1. Reads the explicit capability flag from the process environment; no new filesystem or registry read.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 fix round 1 (#511 R16 amendment): the status tick also fills Probes.ApplyFinished from systemApplyFinished(release.OptDir()), an Lstat of root's apply journal <opt>/system/router/journal.json in the root-owned, world-readable state directory: finished only when the journal is absent, any other answer unknown and so unfinished. Round 0: Probes.PrevRelease from prevReleaseOf (carlos.prev and carlos.prev.version, the files withMovesFields already reads). Reported in the private BoxMetrics block; no bucket request or cadence change.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the agent (carlos-edge.service, user carlos): the status tick fills p.OfflineMove = offlineMoveFactsProbe(routes); the added whole:Route site is the tick's own registry list handed to that unit, which under a non-root euid lists the names of root's <opt>/live and nothing else; no store request added.;rev3=census-ruling-platform-mail-submission;basis=Task 3 (plan gap G6 (b)): the status tick also fills Probes.MailerArmed from mailerArmed(mailwire.MailerSocket, 2s): a stat of /run/carlos-mailer/mailer.sock and, only when it is a socket, GET /v1/health on it. The agent (carlos-edge.service, user carlos), not root; reported in the private BoxMetrics block only. The same seven sites; no store request, no read of /etc/carlos-mailer (which uid carlos cannot traverse).;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 6: the agent (carlos-edge.service, user carlos) fills Probes.NamedUnits from readNamedUnitsStatus: rootstate.Open(/var/lib/carlos-named-units, false, true) status.json, 64 KiB cap, any error nil; report only, nothing reads it as authority; no store request added; the same sites;rev3=census-ruling-console-addr-from-install;basis=sets Probes.ConsoleFleet from consoleFleetProbe (root public store read, edge in-memory state); no read added in this unit;rev3=census-ruling-instance-usage;basis=the status tick adds one Probes field, InstanceUsageDroppedBytes, from instanceUsageDroppedBytes(): an in-process atomic counter of the per-instance flusher (0 when off); no new read of root-owned state, the same 7 read sites;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (carlos-edge.service, user carlos): the status tick also fills Probes.DemoDisk from readDemoDisk(), nil unless CARLOS_DEMO_BOX is set; statfs of /data and /run, and root's public retention record (readDemoBuilds); report only; no store request added; read sites unchanged whole:Route@10894,whole:Route@12968,whole:Route@13249,whole:Route@13607,whole:Route@6583,whole:Route@6610,whole:Route@7918 e77f5014b5439067462d2cc10da8bee12088798c4ca0f98236ea0c8c97a01b5c |
| +internal/release/adopt.go type passConfig authority E2,E3 E19: both destructive readers use the root reservation snapshot under existing release exclusion. Exact artifact and containing-tree identities are retained; missing completeness refuses destruction. Production installation/launch/kernel completeness and verified retirement remain unfinished. Fixtures: TestPlan14GenerationDeletionCannotUnpin, TestPlan14GenerationSnapshotCompleteness, TestPlan14GenerationSnapshotPermitsUnreservedRestage, TestPlan14GenerationSnapshotPinsContainingTree, TestPlan14GenerationSnapshotEmptyIsUnknown, TestPlan14GenerationConsumerMode, TestPlan14GenerationProductionModeGate, TestPlan14GenerationSnapshotPermitsFreshTree.;rev3=PROPOSED-p3;run=8;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=stores the typed census-only root update provider and per-pass resolved input authority;rev3=census-ruling-315;identity=legacy agent pass uid carlos (RootRestartsUnits; never set on carlos adopt);basis=adds the unitsToRoot bool set by RootRestartsUnits; reads nothing;rev3=PROPOSED-s3-change-index;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=adds the pointerGate field, set only by WithPointerGate (the agent's fast sweep); reads nothing;rev3=census-ruling-demo-disk-slice1-retention;basis=adds the beforeStage callback field (WithBeforeStage) and the admitRoute field (WithRouteAdmission), both set only by root's adopt pass; reads nothing 00a3c9397817c34ca0712bf64ed40ae5c65909e63ece3be7cb530addaef6c8f5 |
| +internal/status/snapshot.go CollectBox legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=copies Probes.RootfsReady and RootfsBlocked into BoxMetrics (private, like Layout); the same 28 sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: copies Probes.Egress and Probes.SizeCommittedMiB into BoxMetrics (private, like Layout) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate count is left as is (display);rev3=census-ruling-regional-domains-447;basis=#447 Task 7: copies Probes.AliasesRead into BoxMetrics.AliasesRead (json aliases_read, omitempty) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-alerts-1;basis=copies Probes.DiskFullETAHours into BoxMetrics.DiskFullETAHours (json disk_full_eta_hours, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-edge-held-streams;basis=copies Probes.HeldStreams into BoxMetrics.HeldStreams (json held_streams, omitempty, additive) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: carry already-supplied ReplicaCopies into a separate optional private BoxMetrics replica_copies field; allow copy evidence alone to create the metrics block. Upstreams retains address probes only. Existing 28 Route read sites unchanged; no filesystem, bucket, console or CLI read.;rev3=census-ruling-agent-start-demo-3;basis=Report claim-seed protocol capability only when explicitly configured and runtime moved readiness only when armed; dormant status keeps its original JSON shape. Census read-site delta: unchanged (28).;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 (#511 R16 and its amendment): copies Probes.PrevRelease and Probes.ApplyFinished into BoxMetrics (json prev_release and apply_finished, omitempty; private, like Release) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: copies Probes.OfflineMove into BoxMetrics.OfflineMove (json offline_move, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-platform-mail-submission;basis=Task 3: copies Probes.MailerArmed into BoxMetrics.MailerArmed (json mailer_armed, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-named-units-param-114;basis=named-units-param-114 Task 6: copies Probes.NamedUnits into BoxMetrics.NamedUnits (json named_units, omitempty; private) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-seeded-create-2;basis=Copies Probes.SeedsFloor into BoxMetrics.SeedsFloor and counts it in the metrics gate; a pure copy of a value the agent filled, the same 28 read sites, no read added.;rev3=census-ruling-console-addr-from-install;basis=copies Probes.ConsoleFleet into BoxMetrics (private); no read added;rev3=census-ruling-instance-usage;basis=copies Probes.InstanceUsageDroppedBytes into Box.InstanceUsageDroppedBytes (omitempty, a count only); the same 28 sites, no read added;rev3=census-ruling-demo-disk-slice1-retention;basis=copies Probes.DemoDisk into BoxMetrics.DemoDisk (json demo_disk, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added registry:Alias@4543,registry:CertExpiresAt@3160,registry:CertExpiresAt@3396,registry:CertExpiresAt@4658,registry:DBPath@2495,registry:DBPath@2553,registry:DNSCheckedAt@3365,registry:DNSCheckedAt@4627,registry:DNSStatus@3139,registry:DNSStatus@3334,registry:DNSStatus@4597,registry:Hibernate@3853,registry:Host@2295,registry:Host@2437,registry:Host@2666,registry:Host@3280,registry:Host@3315,registry:Host@4578,registry:Kind@2473,registry:Kind@3807,registry:Platform@2152,registry:ServingVersion@2324,registry:ServingVersion@2447,registry:Socket@4066,registry:Version@2186,registry:Version@2305,whole:Route@1581,whole:RouteAlias@4440 1f4a0869e4d36735afc9a9dc87001be8b8d7893b04fbf2a9f23617456bd5b431 |
| +cli.go printDemoDisk legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=operator CLI (carlos status --live), not root: prints a published box snapshot's demo_disk numbers; final round: also prints each held app (DemoBuilds.Held) even at zero backlog, and drops "the next adopt pass tries again" when an app is held; reads only the decoded snapshot in hand data-literal@195 cb3b0e70cb743b0008caa2192534c3e5b10c3d18f77d76b7be3270a5c008db25 |
| +internal/host/demodisk_status.go const#1 legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos): diskWhereData, diskWhereDataInodes, diskWhereRun, diskWhereRunInodes, the names the disk alert gives what it measured; literals only data-literal@31,data-literal@62 8f6c997ccd711c80af2e16ffd9f9f1a5e70ae76a3f9936473baba389f9f0e92a |
| +internal/host/demodisk_status.go productionDemoDiskProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos), not root: opens root's public record directory /var/lib/carlos-release/demo-retention read-only through rootstate.Open(dir, false, true) (every ancestor root-owned, not group or world writable); report only file:Open@208 f8df171d9a2ff2d96b73c63f4618d035230acc4b8f244dd7f377184686e4933f |
| +internal/host/demodisk_status.go readDemoBuilds legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos): reads the record 'status' from root's public rootstate store (descriptor read, trusted owner, 1 MiB cap) and decodes it; schema 1 or an error; final round: also carries the record's Held list into status.DemoBuilds; report only, nothing reads it as authority file:Read@174 15a3c227b3a4736eb19d12d14b8318e49c092516d5584e04b216ea09a4da110c |
| +internal/host/demoretention.go demoOutput.spellings legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: EvalSymlinks of an output's directory <opt>/versions/<ver>/<demo account>, every component validated (ValidVersion, BoxConfig account, validDemoName), so an output is compared under the store's spelling and its real path; reads no registry input file:EvalSymlinks@118 abd6ff6fe0d0ffdd5989669aee8fcfc27713785a0a1bb6eb168bffa6a9975619 |
| +internal/host/demoretention.go demoRetention.admitRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: the demo admission asked of every route before the release pass does anything with it; refuses a tmp-demo- route on a box whose host.env demo settings do not validate (boxErr; the message now names CARLOS_DEMO_BOX and the tuple), and on a demo box a route of the demo account when the demo account is the ops account, the name is not a demo name, or the pass does not hold the adopt pass lock. Only refuses; reads only the Route in hand and root's own config registry:App@537,registry:App@627,registry:App@97,whole:Route@419 1ac86a2725440d387be4e9e543c5c678c975100fd6635ec70d2c190269d84e34 |
| +internal/host/demoretention.go demoRetention.demoAdoptions legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: lists the registry and keeps the Host and Version of each row of the demo account whose App has the tmp-demo- prefix, to tell after the pass whether it adopted a demo version; decides only whether retention runs, never what it removes registry:App@314,registry:Host@347,registry:Version@358,whole:Route@237,whole:Route@272 1473fe874967ccf4538aed1887b15a9104427e1d0a6e1a537346146e7f7a5ea3 |
| +internal/host/demoretention.go demoRetention.listOutputs legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: ReadDir of <opt>/versions (root-owned) and of <opt>/versions/<ver>/<demo account> for each ValidVersion directory; each entry name, less .manifest.json, must pass validDemoName (tmp-demo- + demo.ValidPublicName: one path component, no "." or "..") before it is used; DirEntry.Info for sizes. ENOENT/ENOTDIR skip. Reads no registry input file:ReadDir@142,file:ReadDir@394 4febf4eebc952074eee6b0e52a97270a3e8c850e009a1db35f406c856a90a4f8 |
| +internal/host/demoretention.go demoRetention.pinSet legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: the pin set from every source: release.BoxPins over every registry row (live link chains; Version, PrevVersion, GoodVersion, settings references), previous links (linkTargets), release.GenerationPins over the generations file, and root's generation ledger. Final round: the two generation sources' pins are also returned apart (reserved), so the backlog can count an app's reserved outputs toward its G + R; the same reads. Strict: any source that does not read in full is an error, except BoxPins' IncompleteRefsError, returned for the caller to hold the apps it covers. Pins only ever keep builds; agent-writable inputs only ADD protection registry:App@1265,registry:App@1389,registry:GoodVersion@1230,registry:PrevVersion@1214,registry:Version@1202,whole:Route@1117,whole:Route@1161,whole:Route@1381,whole:Route@1657,whole:Route@743 83aaa6181597a48be05e8e2477c96284b2f3cabad5fc8450e76380a19f0aaea7 |
| +internal/host/demoretention.go demoRetention.saveStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: reads its own previous record from the public root store /var/lib/carlos-release/demo-retention to carry the backlog's start, and writes the new record there; final round: the record also carries Held (each held app and why), kept from the previous record when nothing read; status only, never read back as a pin or a decision file:Read@289 069982567658454b581e2a626d68e8c5f289a5f01c58815f58c9a9ae9dd4baa5 |
| +internal/host/demoretention.go demoRetention.selection legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: eligibility only from root's facts (demoAccount, listOutputs' listing of its own store). Registry rows (List; App, Version, the route for RouteAccount and validDemoRow) only ADD protection: pins, and holds. Final round: the added sites list the held apps of the demo account for the record (a row's App, validated by validDemoName, and its account), whether or not they have outputs, and mark outputs covered by the generation sources as reserved for the backlog. No registry string reaches a filesystem path; nothing here makes an output eligible registry:App@1505,registry:App@1530,registry:App@2038,registry:App@2064,registry:App@2090,registry:App@798,registry:Version@1479,registry:Version@1539,whole:Route@1407,whole:Route@1443,whole:Route@1974,whole:Route@2009,whole:Route@422,whole:Route@715,whole:Route@750,whole:Route@781 d08029b4f57ebf1d789670f78ae19d06dfdec68d6c9501135fff28c5d7183af1 |
| +internal/host/demoretention.go demoRetention.validDemoRow legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: reads a registry row's demo descriptor (DemoID, DemoHost, DemoLifetime, DemoExpiresAt), Host, App and account and checks it with demo.Config.ValidateBinding against host.env's tuple. Its only effect is protection: a row of the demo account that fails keeps all of its app's builds; it never makes anything eligible registry:App@249,registry:DemoExpiresAt@157,registry:DemoHost@106,registry:DemoID@89,registry:DemoLifetime@129,registry:DemoLifetime@266,registry:Host@257,whole:Route@244 af1de52349984707d82e62de4f196c0be50ac9a29885e42f66beed160fa5f21a |
| +internal/host/demoretention.go linkTargets legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: ReadDir, Readlink and EvalSymlinks of the root-owned <opt>/previous and <opt>/live links, as release.LivePins reads them for the sweep (replaces previousLinkPins, same reads); an unreadable link is an error and nothing is deleted file:EvalSymlinks@509,file:ReadDir@77,file:Readlink@323 0174dc32626a8c188a893e048dcc68638192656b854c45e206076bff0b290537 |
| +internal/host/demoretention.go productionDemoRetention legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass: demo.BoxConfig from host.env (root-owned), now also keeping its error (boxErr) so a box that says it is a demo box with invalid settings refuses demo adoption; the version store and generations file paths, root's generation ledger, and the record store opener rootstate.Open(/var/lib/carlos-release/demo-retention, true, true) file:Open@528 100a780d488f0c1f9ace717410a5df3bdf8259014de08b456dc3ad4b43b2a02b |
| +internal/host/statfs_unix.go filesystemRoom legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=the agent (user carlos): statfs of /data and /run for status and the disk alert; numbers only file:Statfs@102 bc0b7000ddb11715edd58a955d7950a1c19bfacb315b47d9575f7ac0a0a4a732 |
| +internal/release/adopt.go WithRouteAdmission legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=new PassOption: wraps fn so a refusal is printed once per host (rt.Host) and returns whether the route is admitted; reads only the Route handed to it, no file, store or registry read registry:Host@222,registry:Host@245,registry:Host@313,whole:Route@189 f2892b15ee19d20bc2f06f0fbb91a4c1e9bc04950560c1fa42043c2ef8cb3336 |
| +internal/release/adopt.go passConfig.routeAdmitted legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=new: true without an admission option, otherwise the admission's answer for the Route in hand; reads nothing else whole:Route@111 52cc8b59fb4addc2753c3fbf2c20df81b4021045820eec27af5bb07c188a9503 |
| +internal/release/adopt.go passConfig.stageWriteCheck legacy accepted-legacy accepted-legacy;rev3=census-ruling-demo-disk-slice1-retention;basis=root adopt pass and agent passes: generationWriteCheck unchanged first; then, only when WithBeforeStage is set (root's adopt pass only), Lstat of the VersionPath about to be written and the callback when nothing is there; an error fails the stage (nothing written, route unchanged) file:Lstat@233 92aa097f88dc4c665a3564a8cd981537d2394857967be73230a0ef39648c48fd |
| +internal/release/adopt.go PassFilter authority B3,E3,J1,E1,E2 Signed named-unit recovery is independent of release and health history. Root rechecks canonical source, unit, process, signed target and trusted live pointer; captures attempt authority before publication; verifies readiness and resumes without repeated effects. Fixtures: TestPlan14SignedActiveFixIgnoresHistory, TestPlan14SignedActiveFixAuthority, TestPlan14SignedFixSupersedesOlderAttempt, TestPlan14ActiveRecoveryProcessCrash, TestPlan14SignedRestartWithoutHealthHistory, TestPlan14CapturedRollbackWithoutHealthHistory, TestPlan14SignedRestartRequiresTrustedLiveLink. E7 applies merge ruling 4: unbound no-census routes use the legacy pass and restart; ordinary candidates make no binding store call. Fixtures: TestR2UnguardedERecoveryUpdate, TestR2UnguardedERecoveryIncidentRecipe, TestPlan14ERecoveryBindingRefusalKeepsPromotedFix. E19: both destructive readers use the root reservation snapshot under existing release exclusion. Exact artifact and containing-tree identities are retained; missing completeness refuses destruction. Production installation/launch/kernel completeness and verified retirement remain unfinished. Fixtures: TestPlan14GenerationDeletionCannotUnpin, TestPlan14GenerationSnapshotCompleteness, TestPlan14GenerationSnapshotPermitsUnreservedRestage, TestPlan14GenerationSnapshotPinsContainingTree, TestPlan14GenerationSnapshotEmptyIsUnknown, TestPlan14GenerationConsumerMode.;rev3=PROPOSED-p3;run=8;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=resolves protected route inputs before filters, recovery and dispatch on census boxes and bypasses service-owned failure opener only there;rev3=PROPOSED-s3-change-index;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=asks the optional pointer gate (gatePointers) once per channel group before selection and reports each group's pointer outcome to it; only the agent's fast sweep arms a gate (WithPointerGate), so under carlos adopt the gate is nil and the pass is unchanged; a gate can only leave a group out of the pass, never add one; one whole-Route site added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate check is left as is for a resident;rev3=census-ruling-hunt-release-chain-integrity;basis=a digestless head is bound to its signed promotion record through stagePointerHead, and a pointer without an account binding is refused on read (verifyPointer); the ratchet it consults (Admit) now also holds a per-channel promoted_at floor that admits only a strictly later stamp or the very pointer it recorded (PointerIdentity, fix round 1), which root reads only from its own root-owned <opt>/pointer-digests and never from the agent's data dir, through instancefs.ReadBeneathLimitOrAbsent (openat2 RESOLVE_BENEATH|NO_SYMLINKS|NO_MAGICLINKS, O_NONBLOCK, regular file only, 4 KiB cap); fix round 2: the floor's identity is the sha256 of the exact signed wrapper the pointer was verified from (set at the parse site), and a floor with no identity admits nothing at its own stamp, so the floor only refuses more; no read kind is added to the unit; CI fix: an app channel pointer is now stamped to the millisecond (pointerStampGrain) so a signer's wait past the head it replaces is at most a millisecond; the floor still admits only a strictly later stamp or the pointer it recorded, compared as time.Time, so the rule and the reads are unchanged;rev3=census-ruling-demo-disk-slice1-retention;basis=the stage check's beforeWrite is cfg.stageWriteCheck (unchanged from round 1); fix round 3: the recovery loop and the adopts predicate also require cfg.routeAdmitted(rt), so a route WithRouteAdmission refuses is kept out of recovery, selection, staging, restaging, reuse and the repoint for the whole pass, exactly as a non-adoptable route is. The two added sites pass the Route already in hand to the admission callback; no new read, and nil admission (every caller but root's adopt pass) admits every route as before registry:App@10044,registry:App@10185,registry:App@27224,registry:App@29681,registry:App@30368,registry:App@30605,registry:App@32012,registry:App@6786,registry:Hibernate@30251,registry:Host@1087,registry:Host@1452,registry:Host@30421,registry:Host@31337,registry:Host@32065,registry:Host@3464,registry:Host@3531,registry:Host@3627,registry:Host@3662,registry:UpdateSettings@9922,whole:Route@10032,whole:Route@1014,whole:Route@10180,whole:Route@1072,whole:Route@1190,whole:Route@1214,whole:Route@1487,whole:Route@1648,whole:Route@27219,whole:Route@2752,whole:Route@2794,whole:Route@2903,whole:Route@2927,whole:Route@2958,whole:Route@29676,whole:Route@2984,whole:Route@29934,whole:Route@29956,whole:Route@30003,whole:Route@30021,whole:Route@30031,whole:Route@30269,whole:Route@30290,whole:Route@30303,whole:Route@30363,whole:Route@30389,whole:Route@30463,whole:Route@30502,whole:Route@30518,whole:Route@30546,whole:Route@30600,whole:Route@30626,whole:Route@3125,whole:Route@31379,whole:Route@31433,whole:Route@31449,whole:Route@3190,whole:Route@31956,whole:Route@32007,whole:Route@32033,whole:Route@32107,whole:Route@32142,whole:Route@32158,whole:Route@3276,whole:Route@3298,whole:Route@3398,whole:Route@4476,whole:Route@5123,whole:Route@6708,whole:Route@6730,whole:Route@6781,whole:Route@6807,whole:Route@761,whole:Route@803,whole:Route@950,whole:Route@9873,whole:Route@988,whole:Route@9987 38533dde4de3f5af3e612792019549550536cbb1d130d6249bf2fa4d3ef1dbfb |
| +@coverage . f4c1edbdb596c6291c2009545d018c44cf26f37f02a0862324dcac865e8454fa |
| +@coverage internal/host 5a2e7a18310412240a18a9f6346ac894d6fa6f1d34689f1a06621a541bfd0f70 |
| +@coverage internal/metrics e217708d05d3b3abf99a5f5b3f7c1770208f269c6d2008a8844ec4455b67a77e |
| +@coverage internal/release 593bc12ab1f6565fd79c5ee528b60148233c2d63aa419d779e85e2c8b28009fd |
| +@coverage internal/status 23c2b722b9b6f8fbfa45a9edfd5a0577935aba8d4b77043cb239a11736aad7da |
diff --git a/internal/provision/testdata/plan14-root-reads-instance-senders-1.tsv b/internal/provision/testdata/plan14-root-reads-instance-senders-1.tsv| index 80462cb0e..dc64fdcd2 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-instance-senders-1.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-instance-senders-1.tsv |
| @@ -1,6 +1,6 @@ |
| # Census overlay instance-senders-1, written by census-propose (#369). census-ruling-instance-senders-1, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-instance-senders-1.md. |
| # 0 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -@coverage . 898ee642166cef891b954b5725a1332bfa370df460f9c6a92940e318823ff7e4 |
| +@coverage . 41990bf9a2f306b15dc5887f855cd3d3f587956f0355dc47f2784383fa599b90 |
| @coverage internal/mailer 7faad983d368293409cd67c257a99faf7814075cc0bf9dad034955ce849dce26 |
| @coverage internal/mailsubmit 293b1864d19aa444237d4976d8e4d5bcffbed8b268c9c4fd7fade244d0b0f604 |
| @coverage internal/mailwire a080b525495cc7762aa536a015ce961f6263c3e89d69bb115adb5a64978d84d6 |
diff --git a/internal/release/adopt.go b/internal/release/adopt.go| index 19cb0b806..3fb3eda9c 100644 |
| --- a/internal/release/adopt.go |
| +++ b/internal/release/adopt.go |
| @@ -116,7 +116,11 @@ type passConfig struct { |
| // pins is WithPinSource's provider: staged copies that something beyond |
| // the registry rows, the live links and the generations file still |
| // refers to. nil adds nothing. |
| - pins PinSource |
| + pins PinSource |
| + beforeStage func(context.Context, string) error |
| + // admitRoute, set by WithRouteAdmission: false keeps a route out of the |
| + // whole pass. nil admits every route. |
| + admitRoute func(registry.Route) bool |
| generationPins PinSource |
| // stage is what ensureStagedChecked needs to judge a staged copy it is |
| @@ -488,6 +492,61 @@ func WithPinSource(src PinSource) PassOption { |
| return func(c *passConfig) { c.pins = src } |
| } |
| +// WithBeforeStage runs fn just before the pass writes a new output into the |
| +// version store: path is the VersionPath it is about to stage, which holds |
| +// nothing yet (a restage of a copy already there does not call it). An |
| +// error fails the stage, so the version is not adopted this pass and the |
| +// route stays where it was; the next pass asks again. Root's adopt pass sets |
| +// it for the demo disk bound's pending-output cleanup |
| +// (internal/host/demoretention.go): a demo app keeps at most one output that |
| +// was never adopted. |
| +func WithBeforeStage(fn func(ctx context.Context, path string) error) PassOption { |
| + return func(c *passConfig) { c.beforeStage = fn } |
| +} |
| + |
| +// WithRouteAdmission asks fn about every route before the pass does |
| +// anything with it: an error keeps the route out of the whole pass, as if |
| +// it were not adoptable, so nothing of its is staged, restaged, reused, |
| +// recovered or pointed live this pass; the error is printed once per host. |
| +// Root's adopt pass sets it for the demo disk bound |
| +// (internal/host/demoretention.go): a demo app is adopted only by a pass |
| +// that holds the adopt pass lock on a correctly configured demo box, so no |
| +// pass can adopt an output another is removing. |
| +func WithRouteAdmission(fn func(registry.Route) error) PassOption { |
| + refused := map[string]bool{} |
| + return func(c *passConfig) { |
| + c.admitRoute = func(rt registry.Route) bool { |
| + err := fn(rt) |
| + if err != nil && !refused[rt.Host] { |
| + refused[rt.Host] = true |
| + fmt.Printf(" %s: not adopted this pass: %v\n", rt.Host, err) |
| + } |
| + return err == nil |
| + } |
| + } |
| +} |
| + |
| +// routeAdmitted is WithRouteAdmission's answer for rt; true without one. |
| +func (cfg *passConfig) routeAdmitted(rt registry.Route) bool { |
| + return cfg.admitRoute == nil || cfg.admitRoute(rt) |
| +} |
| + |
| +// stageWriteCheck is the pass's check before a staged write to path: the |
| +// generation pins (generationWriteCheck), then WithBeforeStage's callback |
| +// for a path that holds nothing yet. |
| +func (cfg *passConfig) stageWriteCheck(ctx context.Context, optDir, path string) error { |
| + if err := cfg.generationWriteCheck(ctx, optDir, path); err != nil { |
| + return err |
| + } |
| + if cfg.beforeStage == nil { |
| + return nil |
| + } |
| + if _, err := os.Lstat(path); !errors.Is(err, os.ErrNotExist) { |
| + return err |
| + } |
| + return cfg.beforeStage(ctx, path) |
| +} |
| + |
| // stageBlocked reports whether err is the version store refusing a write to |
| // THIS uid, rather than any of the many other ways staging fails. errors.Is |
| // unwraps the *os.PathError that mkdir/openat return. |
| @@ -582,7 +641,7 @@ func PassFilter(ctx context.Context, reg *registry.Registry, s Store, pub ed2551 |
| var failures []error |
| remaining := false |
| for _, rt := range routes { |
| - if extra != nil && !extra(rt) { |
| + if extra != nil && !extra(rt) || !cfg.routeAdmitted(rt) { |
| continue |
| } |
| done, err := cfg.recovery(ctx, rt) |
| @@ -643,7 +702,7 @@ func PassFilter(ctx context.Context, reg *registry.Registry, s Store, pub ed2551 |
| } |
| } |
| adopts := func(rt registry.Route) bool { |
| - return (Adoptable(rt) || SidecarAdoptable(rt)) && (extra == nil || extra(rt)) |
| + return (Adoptable(rt) || SidecarAdoptable(rt)) && (extra == nil || extra(rt)) && cfg.routeAdmitted(rt) |
| } |
| // WithPointerGate: a skipped group leaves the pass before anything is |
| // selected for it. |
| @@ -674,7 +733,7 @@ func PassFilter(ctx context.Context, reg *registry.Registry, s Store, pub ed2551 |
| // release, so a healthy pass never pays for it, and it reads fresh then, |
| // so a host this pass has already repointed counts. |
| cfg.stage = stageCheck{ |
| - beforeWrite: func(path string) error { return cfg.generationWriteCheck(ctx, optDir, path) }, |
| + beforeWrite: func(path string) error { return cfg.stageWriteCheck(ctx, optDir, path) }, |
| verified: map[string]string{}, |
| refs: func() (StagedPaths, error) { |
| rows, err := reg.List() |
diff --git a/internal/release/beforestage_test.go b/internal/release/beforestage_test.go| new file mode 100644 |
| index 000000000..b4759bad3 |
| --- /dev/null |
| +++ b/internal/release/beforestage_test.go |
| @@ -0,0 +1,123 @@ |
| +package release |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "os" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// The demo disk bound's pending-output cleanup (plan slice 1, step 4): the |
| +// box runs WithBeforeStage's callback with the path before it writes a |
| +// version it has not staged, and a callback that fails leaves the version |
| +// unstaged and the route where it was. A version already in the store never |
| +// calls it: there is no new output to make room for. |
| +func TestPassBeforeStageRunsOnlyForANewOutputAndRefusesTheStage(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + ctx := context.Background() |
| + priv, pub := testKeys(t) |
| + opt := t.TempDir() |
| + reg := testRegistry(t) |
| + addRoute(t, reg, "shop.example.com", "shop", "canary/x", true) |
| + |
| + var calls []string |
| + refuse := errors.New("cleanup could not read a pin source") |
| + hook := func(fail bool) PassOption { |
| + return WithBeforeStage(func(_ context.Context, path string) error { |
| + calls = append(calls, path) |
| + if fail { |
| + return refuse |
| + } |
| + return nil |
| + }) |
| + } |
| + |
| + shipRelease(t, s, "bab", "shop", "v1", adoptPlatform, []byte("one")) |
| + if err := Promote(ctx, s, priv, "bab", "shop", "canary/x", "v1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := Pass(ctx, reg, s, pub, opt, nil, hook(true)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if len(calls) != 1 || calls[0] != VersionPath(opt, "bab", "v1", "shop") { |
| + t.Fatalf("calls = %v, want one for v1", calls) |
| + } |
| + if _, err := os.Lstat(VersionPath(opt, "bab", "v1", "shop")); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("v1 staged although its cleanup failed: %v", err) |
| + } |
| + if rt, _ := reg.Get("shop.example.com"); rt == nil || rt.Version != "" { |
| + t.Fatalf("route moved although nothing was staged: %+v", rt) |
| + } |
| + |
| + // The retry runs the cleanup first again, and stages once it passes. |
| + if err := Pass(ctx, reg, s, pub, opt, nil, hook(false)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if len(calls) != 2 { |
| + t.Fatalf("calls = %v, want the retry to run the cleanup", calls) |
| + } |
| + if rt, _ := reg.Get("shop.example.com"); rt == nil || rt.Version != "v1" { |
| + t.Fatalf("route = %+v, want v1 once the cleanup passed", rt) |
| + } |
| + |
| + // Already staged and live: nothing new to stage, no call. |
| + if err := Pass(ctx, reg, s, pub, opt, nil, hook(true)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if len(calls) != 2 { |
| + t.Fatalf("calls = %v, want none for a version already staged", calls) |
| + } |
| +} |
| + |
| +// WithRouteAdmission keeps a refused route out of the whole pass: a build |
| +// already staged with the release's bytes is not reused and the route is |
| +// not pointed live, while an admitted route in the same pass adopts. Once |
| +// admitted, the refused route adopts its staged build. |
| +func TestPassRouteAdmissionKeepsARefusedRouteOutOfThePass(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + ctx := context.Background() |
| + priv, pub := testKeys(t) |
| + opt := t.TempDir() |
| + reg := testRegistry(t) |
| + addRoute(t, reg, "shop.example.com", "shop", "canary/x", true) |
| + addRoute(t, reg, "blog.example.com", "blog", "canary/x", true) |
| + for _, app := range []string{"shop", "blog"} { |
| + shipRelease(t, s, "bab", app, "v1", adoptPlatform, []byte(app+" one")) |
| + if err := Promote(ctx, s, priv, "bab", app, "canary/x", "v1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if err := StageArtifact(opt, "bab", "v1", "shop", []byte("shop one")); err != nil { |
| + t.Fatal(err) |
| + } |
| + asked := 0 |
| + admit := func(refuse bool) PassOption { |
| + return WithRouteAdmission(func(rt registry.Route) error { |
| + asked++ |
| + if refuse && rt.App == "shop" { |
| + return errors.New("not admitted") |
| + } |
| + return nil |
| + }) |
| + } |
| + if err := Pass(ctx, reg, s, pub, opt, nil, admit(true)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt, _ := reg.Get("shop.example.com"); rt == nil || rt.Version != "" { |
| + t.Fatalf("a refused route adopted its staged build: %+v", rt) |
| + } |
| + if rt, _ := reg.Get("blog.example.com"); rt == nil || rt.Version != "v1" { |
| + t.Fatalf("an admitted route did not adopt: %+v", rt) |
| + } |
| + if v, _ := LiveVersion(opt, "shop.example.com"); v != "" || asked == 0 { |
| + t.Fatalf("refused route's live link %q (asked %d)", v, asked) |
| + } |
| + if err := Pass(ctx, reg, s, pub, opt, nil, admit(false)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt, _ := reg.Get("shop.example.com"); rt == nil || rt.Version != "v1" { |
| + t.Fatalf("admitted, the route did not adopt: %+v", rt) |
| + } |
| +} |
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go| index cee5ea4f5..60631882d 100644 |
| --- a/internal/status/contract_test.go |
| +++ b/internal/status/contract_test.go |
| @@ -83,7 +83,7 @@ var allowedBoxKeys = map[string][]string{ |
| "routes": {"static", "resident", "hibernating", "awake", "asleep"}, |
| "replication": {"healthy", "lag_seconds"}, |
| // capabilities names supported protocols only, in the bucket-private metrics. |
| - "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib", "offline_move"}, |
| + "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib", "offline_move", "demo_disk"}, |
| "metrics.route_versions": {wildcardAnyKey}, |
| "metrics.upstreams": {wildcardAnyKey}, |
| "metrics.upstreams.*[]": {"addr", "up", "since", "fails", "last_error"}, |
| @@ -120,6 +120,13 @@ var allowedBoxKeys = map[string][]string{ |
| // read: the hosts this box keeps a stale live link for, bounded, and |
| // whether it holds more. Private block only, pinned to the field level. |
| "metrics.offline_move": {"stale_live_links", "stale_live_links_overflow"}, |
| + // demo_disk (demo disk bound, slice 1) is a demo box's room on /data and |
| + // /run and its kept demo builds, numbers only, in the private block; |
| + // pinned to the field level. |
| + "metrics.demo_disk": {"data", "run", "builds"}, |
| + "metrics.demo_disk.data": {"free_bytes", "bytes", "free_inodes", "inodes"}, |
| + "metrics.demo_disk.run": {"free_bytes", "bytes", "free_inodes", "inodes"}, |
| + "metrics.demo_disk.builds": {"outputs", "output_bytes", "at", "backlog", "backlog_since"}, |
| } |
| // allowedFleetKeys are THE schema for Fleet's JSON output. Same friction as |
| @@ -393,6 +400,10 @@ func fixtureProbes() status.Probes { |
| // The offline move facts, so metrics.offline_move is exercised by |
| // the allowlist walk too (#339). |
| OfflineMove: &status.OfflineMoveFacts{StaleLiveLinks: []string{"contract-left.internal"}, StaleLiveLinksOverflow: true}, |
| + // A demo box's disk numbers (demo disk bound, slice 1), so |
| + // metrics.demo_disk is exercised by the allowlist walk too. |
| + DemoDisk: &status.DemoDisk{Data: &status.FilesystemRoom{FreeBytes: 1, Bytes: 2, FreeInodes: 3, Inodes: 4}, Run: &status.FilesystemRoom{FreeBytes: 5, Bytes: 6, FreeInodes: 7, Inodes: 8}, |
| + Builds: &status.DemoBuilds{Outputs: 9, OutputBytes: 10, At: time.Unix(11, 0), Backlog: 12, BacklogSince: time.Unix(13, 0)}}, |
| ConfigGuard: "bypassed (CARLOS_NO_SEALED_CONFIG)", |
| MemFrac: &memFrac, |
diff --git a/internal/status/demodisk.go b/internal/status/demodisk.go| new file mode 100644 |
| index 000000000..dd3c711b1 |
| --- /dev/null |
| +++ b/internal/status/demodisk.go |
| @@ -0,0 +1,45 @@ |
| +package status |
| + |
| +import "time" |
| + |
| +// DemoDisk is a demo box's disk numbers (demo disk bound plan, slice 1): |
| +// the room left on /data and on /run, in bytes and inodes, and the demo |
| +// builds the box keeps. It rides in the bucket-private Metrics block only |
| +// on demo boxes; nil everywhere else and on boxes from before it. |
| +type DemoDisk struct { |
| + // Data and Run are /data and the /run tmpfs. nil: not read. |
| + Data *FilesystemRoom `json:"data,omitempty"` |
| + Run *FilesystemRoom `json:"run,omitempty"` |
| + // Builds is root's record of its last demo build retention run. nil: |
| + // no record read. |
| + Builds *DemoBuilds `json:"builds,omitempty"` |
| +} |
| + |
| +// FilesystemRoom is one filesystem's statfs numbers: what is free to an |
| +// unprivileged writer, and the totals. A zero is a reading, not unknown. |
| +type FilesystemRoom struct { |
| + FreeBytes int64 `json:"free_bytes"` |
| + Bytes int64 `json:"bytes"` |
| + FreeInodes int64 `json:"free_inodes"` |
| + Inodes int64 `json:"inodes"` |
| +} |
| + |
| +// DemoBacklogStale is how old a demo build retention backlog may get |
| +// before box status gives it a line of its own (plan slice 1). |
| +const DemoBacklogStale = 24 * time.Hour |
| + |
| +// DemoBuilds is the staged demo build outputs root's last retention run |
| +// left, and its backlog: for each demo app, the larger of the outputs it |
| +// keeps above its bound and those the run could not delete, with when that |
| +// began (zero when there is none). |
| +type DemoBuilds struct { |
| + Outputs int `json:"outputs"` |
| + OutputBytes int64 `json:"output_bytes"` |
| + At time.Time `json:"at"` |
| + Backlog int `json:"backlog"` |
| + BacklogSince time.Time `json:"backlog_since,omitzero"` |
| + // Held is every demo app whose builds are all kept and whose updates |
| + // are refused until an operator clears the cause, as "<app>: <why>". |
| + // Shown even with no backlog. |
| + Held []string `json:"held,omitempty"` |
| +} |
diff --git a/internal/status/demodisk_test.go b/internal/status/demodisk_test.go| new file mode 100644 |
| index 000000000..0ef2dc8d6 |
| --- /dev/null |
| +++ b/internal/status/demodisk_test.go |
| @@ -0,0 +1,45 @@ |
| +package status_test |
| + |
| +import ( |
| + "encoding/json" |
| + "reflect" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| + |
| +// A demo box's disk numbers ride in the private metrics block as one new, |
| +// additive key: a box without them publishes exactly what it did before, |
| +// and the numbers round-trip. |
| +func TestDemoDiskIsAdditive(t *testing.T) { |
| + without := status.CollectBox(nil, status.Probes{MachineID: "m", Release: "r"}, time.Now()) |
| + raw, err := json.Marshal(without) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var shape struct { |
| + Metrics map[string]any `json:"metrics"` |
| + } |
| + if err := json.Unmarshal(raw, &shape); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, ok := shape.Metrics["demo_disk"]; ok || shape.Metrics == nil { |
| + t.Fatalf("a box without demo disk numbers publishes demo_disk: %s", raw) |
| + } |
| + since := time.Date(2026, 11, 29, 1, 2, 3, 0, time.UTC) |
| + d := &status.DemoDisk{Data: &status.FilesystemRoom{FreeBytes: 1, Bytes: 2, FreeInodes: 3, Inodes: 4}, Run: &status.FilesystemRoom{FreeBytes: 5, Bytes: 6, FreeInodes: 7, Inodes: 8}, |
| + Builds: &status.DemoBuilds{Outputs: 9, OutputBytes: 10, At: since, Backlog: 12, BacklogSince: since}} |
| + with := status.CollectBox(nil, status.Probes{MachineID: "m", DemoDisk: d}, time.Now()) |
| + raw, err = json.Marshal(with) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var back status.Box |
| + if err := json.Unmarshal(raw, &back); err != nil { |
| + t.Fatal(err) |
| + } |
| + if back.Metrics == nil || back.Metrics.DemoDisk == nil || !reflect.DeepEqual(back.Metrics.DemoDisk, d) { |
| + t.Fatalf("round trip: %s", raw) |
| + } |
| +} |
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go| index 826894a35..4321238fa 100644 |
| --- a/internal/status/snapshot.go |
| +++ b/internal/status/snapshot.go |
| @@ -129,6 +129,9 @@ type Probes struct { |
| MemAvailBytes *int64 |
| Load1 *float64 |
| DiskFreeBytes *int64 |
| + // DemoDisk is a demo box's disk numbers (BoxMetrics.DemoDisk); nil on |
| + // every other box. |
| + DemoDisk *DemoDisk |
| // Release is the running binary's version.Build (a short sha or similar), |
| // and Tunnel is one of ""|"connected"|"reconnecting" — both land in |
| // Box.Metrics unbanded, like the four numeric fields above. "" means |
| @@ -709,10 +712,13 @@ type BoxMetrics struct { |
| HostClaimEnabled bool `json:"host_claim_enabled,omitempty"` |
| RetirementReceiptSHA256 string `json:"retirement_receipt_sha256,omitempty"` |
| - MemTotalBytes *int64 `json:"mem_total_bytes,omitempty"` |
| - MemAvailBytes *int64 `json:"mem_avail_bytes,omitempty"` |
| - Load1 *float64 `json:"load1,omitempty"` |
| - DiskFreeBytes *int64 `json:"disk_free_bytes,omitempty"` |
| + MemTotalBytes *int64 `json:"mem_total_bytes,omitempty"` |
| + MemAvailBytes *int64 `json:"mem_avail_bytes,omitempty"` |
| + Load1 *float64 `json:"load1,omitempty"` |
| + DiskFreeBytes *int64 `json:"disk_free_bytes,omitempty"` |
| + // DemoDisk is a demo box's room on /data and /run and the demo builds it |
| + // keeps (demo disk bound plan, slice 1). Absent on any other box. |
| + DemoDisk *DemoDisk `json:"demo_disk,omitempty"` |
| Release string `json:"release,omitempty"` // running binary's version.Build |
| PrevRelease string `json:"prev_release,omitempty"` // carlos.prev's release; "none": no carlos.prev |
| ApplyFinished bool `json:"apply_finished,omitempty"` // no open system apply journal; absent: unfinished or unknown |
| @@ -1368,7 +1374,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box { |
| len(routeDBBytes) > 0 || p.Layout != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" || |
| p.Alerts != nil || p.GeoIP != nil || p.HeldStreams != nil || len(p.BuildStates) > 0 || p.BuildStatesErr != "" || |
| p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil || |
| - p.MailerArmed || p.OfflineMove != nil || p.NamedUnits != nil || p.SeedsFloor != nil || p.ConsoleFleet != nil { |
| + p.MailerArmed || p.OfflineMove != nil || p.NamedUnits != nil || p.SeedsFloor != nil || p.ConsoleFleet != nil || p.DemoDisk != nil { |
| var capabilities []string |
| if p.DemoClaimSeedReady { |
| capabilities = append(capabilities, seeds.DemoClaimCapability) |
| @@ -1393,7 +1399,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box { |
| RetirementReceiptSHA256: p.RetirementReceiptSHA256, |
| MemTotalBytes: p.MemTotalBytes, MemAvailBytes: p.MemAvailBytes, |
| - Load1: p.Load1, DiskFreeBytes: p.DiskFreeBytes, DiskFullETAHours: p.DiskFullETAHours, |
| + Load1: p.Load1, DiskFreeBytes: p.DiskFreeBytes, DiskFullETAHours: p.DiskFullETAHours, DemoDisk: p.DemoDisk, |
| Release: p.Release, PrevRelease: p.PrevRelease, ApplyFinished: p.ApplyFinished, Tunnel: p.Tunnel, GeoIP: p.GeoIP, HeldStreams: p.HeldStreams, |
| Platform: p.Platform, SystemChannel: p.SystemChannel, System: p.System, |
| InstanceID: p.InstanceID, |
diff --git a/statuslive_demodisk_test.go b/statuslive_demodisk_test.go| new file mode 100644 |
| index 000000000..f190f4e1e |
| --- /dev/null |
| +++ b/statuslive_demodisk_test.go |
| @@ -0,0 +1,73 @@ |
| +package main |
| + |
| +import ( |
| + "bytes" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| + |
| +// A demo box's disk numbers read as lines under the box: the room on /data |
| +// and /run in bytes and inodes, the demo builds kept, a backlog with its |
| +// start, and a line of its own once the backlog is a day old. A box without |
| +// them prints exactly what it did before. |
| +func TestPrintLiveBoxesShowsADemoBoxsDisk(t *testing.T) { |
| + now := time.Date(2026, 11, 30, 12, 0, 0, 0, time.UTC) |
| + box := func(d *status.DemoDisk) string { |
| + var buf bytes.Buffer |
| + printLiveBoxes(&buf, []status.Box{{GeneratedAt: now, Label: "demo-box", Metrics: &status.BoxMetrics{Tunnel: "connected", DemoDisk: d}}}, now) |
| + return buf.String() |
| + } |
| + plain := box(nil) |
| + if strings.Count(plain, "\n") != 1 { |
| + t.Fatalf("a box without demo disk numbers printed more than its line:\n%s", plain) |
| + } |
| + at := time.Date(2026, 11, 30, 11, 0, 0, 0, time.UTC) |
| + d := &status.DemoDisk{ |
| + Data: &status.FilesystemRoom{FreeBytes: 3 << 30, Bytes: 30 << 30, FreeInodes: 1200000, Inodes: 1900000}, |
| + Run: &status.FilesystemRoom{FreeBytes: 180 << 20, Bytes: 190 << 20, FreeInodes: 230000, Inodes: 237937}, |
| + Builds: &status.DemoBuilds{Outputs: 12, OutputBytes: 380 << 20, At: at}, |
| + } |
| + got := box(d) |
| + for _, want := range []string{ |
| + " free: /data 3.0GB and 1200000 inodes; /run 180.0MB and 230000 inodes\n", |
| + " demo builds kept: 12 (380.0MB) as of 2026-11-30T11:00:00Z\n", |
| + } { |
| + if !strings.Contains(got, want) { |
| + t.Fatalf("missing %q in:\n%s", want, got) |
| + } |
| + } |
| + if strings.Contains(got, "over the limit") { |
| + t.Fatalf("a backlog line with no backlog:\n%s", got) |
| + } |
| + d.Builds.Backlog, d.Builds.BacklogSince = 3, now.Add(-2*time.Hour) |
| + got = box(d) |
| + if want := " demo builds over the limit: 3 since 2026-11-30T10:00:00Z; the next adopt pass tries again\n"; !strings.Contains(got, want) { |
| + t.Fatalf("missing %q in:\n%s", want, got) |
| + } |
| + if strings.Contains(got, "24 hours") { |
| + t.Fatalf("a fresh backlog got the stale line:\n%s", got) |
| + } |
| + d.Builds.BacklogSince = now.Add(-25 * time.Hour) |
| + if want := " demo build cleanup has been behind for over 24 hours: check the adopt pass log on this box\n"; !strings.Contains(box(d), want) { |
| + t.Fatalf("missing %q in:\n%s", want, box(d)) |
| + } |
| + // A held app is shown even with no backlog, and a backlog beside a |
| + // hold does not promise the next pass clears it. |
| + d.Builds.Backlog, d.Builds.BacklogSince = 0, time.Time{} |
| + d.Builds.Held = []string{"tmp-demo-amber-acorn-01: a registry row runs it as something other than a valid demo"} |
| + if want := " demo updates refused for tmp-demo-amber-acorn-01: a registry row runs it as something other than a valid demo; its builds stay until that is fixed\n"; !strings.Contains(box(d), want) { |
| + t.Fatalf("missing %q in:\n%s", want, box(d)) |
| + } |
| + d.Builds.Backlog, d.Builds.BacklogSince = 4, now.Add(-2*time.Hour) |
| + if got := box(d); !strings.Contains(got, " demo builds over the limit: 4 since 2026-11-30T10:00:00Z\n") || strings.Contains(got, "tries again") { |
| + t.Fatalf("a held app's backlog:\n%s", got) |
| + } |
| + d.Builds.Held = nil |
| + // Only what was read. |
| + if got := box(&status.DemoDisk{Run: d.Run}); !strings.Contains(got, " free: /run 180.0MB and 230000 inodes\n") || strings.Contains(got, "demo builds") { |
| + t.Fatalf("partial reading:\n%s", got) |
| + } |
| +} |