carlos / platform Public

Merge origin/main into sec-h3-m2-scoped-key; census chain re-proposed

The root-read chain conflicted only on its manifest tail: main's lines
first, this branch's overlay last. census-propose re-run with the same
claim (runChannelsResign body; envelopes ., internal/release), seal
now 76f69ece -> 4f307fb9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c20b4d060f8f9e631f977532179c22c140978ad1 parent 958aa2aparent 9d294ac
47 files changed, +2,289 −302
  • .amadan/code-health.tsv +1 −2
  • accounts.go +87 −64
  • accounts_sealed.go +205 −0
  • accounts_sealed_test.go +485 −0
  • appconfig_cli.go +6 −22
  • appconfig_cli_fleet_test.go +1 −2
  • cmd/console/main.go +10 −18
  • docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md +161 −0
  • docs/superpowers/notes/census-proposal-infra-floor-keys-deny.md +25 −0
  • docs/superpowers/notes/census-proposal-sec-h3-m2-scoped-key.md +1 −1
  • docs/superpowers/notes/census-proposal-sec-h3-m3-envelope.md +19 −0
  • infra/modules/deployment-buckets/main.tf +39 −0
  • infra/modules/deployment-buckets/tests/published_floors.tftest.hcl +82 −0
  • infra/modules/deployment-buckets/variables.tf +15 −1
  • internal/activator/swap_fixture_test.go +9 −0
  • internal/appconfig/crypto.go +56 −45
  • internal/appconfig/crypto_bind_test.go +13 −24
  • internal/appconfig/hunt_H3-M3_test.go +141 −0
  • internal/appconfig/owned.go +13 −0
  • internal/appconfig/owned_test.go +114 −4
  • internal/appconfig/sealer.go +4 −2
  • internal/appconfig/sealer_test.go +2 −6
  • internal/appconfig/store.go +40 −0
  • internal/appconfig/unboundsets_test.go +95 −0
  • internal/console/apiconfig.go +6 −8
  • internal/console/apiconfig_test.go +6 −18
  • internal/console/apisystemhold_test.go +12 −9
  • internal/console/apisystemupdate.go +119 −5
  • internal/console/apisystemupdate_latestboxes_test.go +314 −0
  • internal/console/configwrite.go +14 −2
  • internal/console/envform_test.go +5 −20
  • internal/console/envsave_test.go +0 −2
  • internal/console/fleetsecrets_mint_test.go +2 −5
  • internal/console/fleetsecrets_relay_test.go +0 −4
  • internal/console/hotreads.go +27 −0
  • internal/console/hunt_H3-M9_test.go +34 −0
  • internal/console/hunt_h3m3_test.go +78 −0
  • internal/console/sealkey.go +2 −2
  • internal/console/sealkey_test.go +19 −28
  • internal/host/replicahomekeys_test.go +1 −1
  • internal/mail/sealer_helper_test.go +1 −1
  • internal/moves/archive/seal.go +2 −3
  • internal/objstore/walk_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +3 −1
  • internal/provision/testdata/plan14-root-reads-infra-floor-keys-deny.tsv +11 −0
  • internal/provision/testdata/plan14-root-reads-sec-h3-m2-scoped-key.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-sec-h3-m3-envelope.tsv +7 −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-vWkrTy
.amadan/test-gate.sh
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/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 golang.org/x/crypto v0.58.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.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/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading golang.org/x/sys v0.49.0
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/prometheus/procfs v0.12.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pion/randutil v0.1.0
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 github.com/klauspost/compress v1.20.2
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
=== launchctx (4 s, from +0 s)
ok  	amadan.net/carlos/platform.git/launchctx	0.015s
?   	amadan.net/carlos/platform.git/launchctx/controlname	[no test files]
?   	amadan.net/carlos/platform.git/launchctx/wireid	[no test files]
=== vet (177 s, from +0 s)
go: downloading github.com/klauspost/compress v1.20.2
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
=== vet-tags (190 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/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 modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== gofmt (1 s, from +0 s)
gofmt -l .: clean
=== rest (385 s, from +14 s)
ok  	github.com/carlosframework/platform/cmd/carlos-media	118.835s
?   	github.com/carlosframework/platform/cmd/changelog	[no test files]
ok  	github.com/carlosframework/platform/cmd/console	216.338s
ok  	github.com/carlosframework/platform/cmd/mediaimage	43.672s
ok  	github.com/carlosframework/platform/cmd/moveprobe	15.529s
ok  	github.com/carlosframework/platform/cmd/pricebook-export	0.037s
ok  	github.com/carlosframework/platform/cmd/rootfswitness	0.184s
ok  	github.com/carlosframework/platform/cmd/runsc-assets	0.107s
ok  	github.com/carlosframework/platform/cmd/zddprobe	0.975s
ok  	github.com/carlosframework/platform/internal/agentsock	0.069s
ok  	github.com/carlosframework/platform/internal/alerting	0.028s
ok  	github.com/carlosframework/platform/internal/analytics	0.196s
ok  	github.com/carlosframework/platform/internal/appconfig	43.843s
ok  	github.com/carlosframework/platform/internal/apperr	0.331s
ok  	github.com/carlosframework/platform/internal/applog	4.107s
ok  	github.com/carlosframework/platform/internal/apppolicy	2.400s
ok  	github.com/carlosframework/platform/internal/assetcache	0.479s
ok  	github.com/carlosframework/platform/internal/awsinv	0.034s
ok  	github.com/carlosframework/platform/internal/awsmanaged	9.266s
ok  	github.com/carlosframework/platform/internal/awsregiongroup	0.139s
ok  	github.com/carlosframework/platform/internal/awsterminations	0.020s
ok  	github.com/carlosframework/platform/internal/backupswords	0.015s
ok  	github.com/carlosframework/platform/internal/billing	0.055s
ok  	github.com/carlosframework/platform/internal/billing/billingtest	0.068s
ok  	github.com/carlosframework/platform/internal/billingstripe	2.015s
ok  	github.com/carlosframework/platform/internal/boxchoice	0.027s
ok  	github.com/carlosframework/platform/internal/boxid	2.367s
?   	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.009s
ok  	github.com/carlosframework/platform/internal/boxself	0.143s
ok  	github.com/carlosframework/platform/internal/boxvolumes	0.047s
ok  	github.com/carlosframework/platform/internal/caps	4.840s
ok  	github.com/carlosframework/platform/internal/certwarm	0.012s
ok  	github.com/carlosframework/platform/internal/cgroup	1.403s
ok  	github.com/carlosframework/platform/internal/changelog	3.870s
ok  	github.com/carlosframework/platform/internal/clamd	0.086s
?   	github.com/carlosframework/platform/internal/cliflag	[no test files]
ok  	github.com/carlosframework/platform/internal/clireg	0.008s
ok  	github.com/carlosframework/platform/internal/codehealth	17.894s
ok  	github.com/carlosframework/platform/internal/compute	0.021s
ok  	github.com/carlosframework/platform/internal/consolefleet	0.007s
?   	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	10.356s
ok  	github.com/carlosframework/platform/internal/dbdoor/dbdoortest	0.050s
ok  	github.com/carlosframework/platform/internal/dbquery	0.027s
ok  	github.com/carlosframework/platform/internal/dbreads	3.184s
?   	github.com/carlosframework/platform/internal/dbreads/dbreadstest	[no test files]
ok  	github.com/carlosframework/platform/internal/dbverify	0.044s
ok  	github.com/carlosframework/platform/internal/demo	0.008s
ok  	github.com/carlosframework/platform/internal/demobuild	5.184s
ok  	github.com/carlosframework/platform/internal/democlaim	0.452s
ok  	github.com/carlosframework/platform/internal/devbox	16.801s
ok  	github.com/carlosframework/platform/internal/dnsrec	0.010s
ok  	github.com/carlosframework/platform/internal/docsite	0.096s
ok  	github.com/carlosframework/platform/internal/domainreg	0.012s
ok  	github.com/carlosframework/platform/internal/domains	72.211s
ok  	github.com/carlosframework/platform/internal/doorkey	0.056s
ok  	github.com/carlosframework/platform/internal/economics	0.005s
ok  	github.com/carlosframework/platform/internal/edgefence	0.153s
ok  	github.com/carlosframework/platform/internal/edgeguard	0.335s
?   	github.com/carlosframework/platform/internal/edgeproof	[no test files]
ok  	github.com/carlosframework/platform/internal/edgesfile	0.102s
ok  	github.com/carlosframework/platform/internal/egressaddr	0.008s
ok  	github.com/carlosframework/platform/internal/execsandbox	106.463s
ok  	github.com/carlosframework/platform/internal/fileacl	0.013s
ok  	github.com/carlosframework/platform/internal/fleetapi	2.113s
ok  	github.com/carlosframework/platform/internal/fleetstore	0.009s
ok  	github.com/carlosframework/platform/internal/fxrate	0.040s
ok  	github.com/carlosframework/platform/internal/gate	5.233s
ok  	github.com/carlosframework/platform/internal/genselect	0.117s
ok  	github.com/carlosframework/platform/internal/geo	0.052s
ok  	github.com/carlosframework/platform/internal/geoip	0.131s
ok  	github.com/carlosframework/platform/internal/groupadmission	0.008s
ok  	github.com/carlosframework/platform/internal/grouprollaws	16.624s
ok  	github.com/carlosframework/platform/internal/hadeparture	0.030s
ok  	github.com/carlosframework/platform/internal/hafresh	0.033s
ok  	github.com/carlosframework/platform/internal/hairpin	0.222s
ok  	github.com/carlosframework/platform/internal/historyreadback	0.922s
ok  	github.com/carlosframework/platform/internal/hostactors	23.823s
ok  	github.com/carlosframework/platform/internal/hostbox	22.387s
ok  	github.com/carlosframework/platform/internal/hostclaim	2.662s
ok  	github.com/carlosframework/platform/internal/hostenv	0.047s
ok  	github.com/carlosframework/platform/internal/hostevidence	0.042s
ok  	github.com/carlosframework/platform/internal/hostexec	25.083s
ok  	github.com/carlosframework/platform/internal/hostfence	0.175s
ok  	github.com/carlosframework/platform/internal/hostfiles	28.273s
ok  	github.com/carlosframework/platform/internal/hostfloor	0.833s
ok  	github.com/carlosframework/platform/internal/hostguard	1.458s
ok  	github.com/carlosframework/platform/internal/hostops	9.014s
?   	github.com/carlosframework/platform/internal/hostops/fencerelease	[no test files]
ok  	github.com/carlosframework/platform/internal/hostops/internal/fencerelease	0.012s
ok  	github.com/carlosframework/platform/internal/hostquarantine	0.016s
ok  	github.com/carlosframework/platform/internal/hostrelocate	2.235s
ok  	github.com/carlosframework/platform/internal/hostresolve	0.614s
ok  	github.com/carlosframework/platform/internal/hostwrite	0.014s
ok  	github.com/carlosframework/platform/internal/infraview	0.013s
ok  	github.com/carlosframework/platform/internal/ingresshealth	0.008s
ok  	github.com/carlosframework/platform/internal/ingresshealth/awstg	0.023s
ok  	github.com/carlosframework/platform/internal/instancectl	65.941s
ok  	github.com/carlosframework/platform/internal/instanceexec	9.835s
ok  	github.com/carlosframework/platform/internal/instancefs	19.497s
ok  	github.com/carlosframework/platform/internal/instancekey	0.025s
ok  	github.com/carlosframework/platform/internal/instanceupdates	0.045s
ok  	github.com/carlosframework/platform/internal/interactive	0.719s
ok  	github.com/carlosframework/platform/internal/launchd	0.015s
ok  	github.com/carlosframework/platform/internal/layout	26.526s
ok  	github.com/carlosframework/platform/internal/layout/pubclass	103.667s
ok  	github.com/carlosframework/platform/internal/lbhealth	0.010s
ok  	github.com/carlosframework/platform/internal/lease	147.900s
ok  	github.com/carlosframework/platform/internal/lease/leasetest	1.395s
ok  	github.com/carlosframework/platform/internal/lease/locktest	0.046s
ok  	github.com/carlosframework/platform/internal/ledger	0.101s
ok  	github.com/carlosframework/platform/internal/mail	1.181s
ok  	github.com/carlosframework/platform/internal/mailer	0.799s
ok  	github.com/carlosframework/platform/internal/mailsubmit	2.152s
ok  	github.com/carlosframework/platform/internal/mailwire	0.010s
ok  	github.com/carlosframework/platform/internal/maintenance	0.281s
ok  	github.com/carlosframework/platform/internal/maintenanceexec	8.246s
ok  	github.com/carlosframework/platform/internal/maintenanceguard	0.392s
ok  	github.com/carlosframework/platform/internal/managedboot	4.134s
?   	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	2.381s
ok  	github.com/carlosframework/platform/internal/media/mediatest	0.008s
ok  	github.com/carlosframework/platform/internal/mediaaws	63.473s
ok  	github.com/carlosframework/platform/internal/mediahandler	43.793s
ok  	github.com/carlosframework/platform/internal/mediajobs	1.090s
ok  	github.com/carlosframework/platform/internal/medialocal	10.488s
ok  	github.com/carlosframework/platform/internal/metrics	0.159s
ok  	github.com/carlosframework/platform/internal/minorunits	0.005s
ok  	github.com/carlosframework/platform/internal/moves	52.706s
ok  	github.com/carlosframework/platform/internal/moves/archive	2.878s
ok  	github.com/carlosframework/platform/internal/moves/offlinerun	0.104s
ok  	github.com/carlosframework/platform/internal/namedunits	0.052s
ok  	github.com/carlosframework/platform/internal/objstore	2.473s
ok  	github.com/carlosframework/platform/internal/ops	16.544s
ok  	github.com/carlosframework/platform/internal/pageindex	4.033s
ok  	github.com/carlosframework/platform/internal/parity	0.153s
?   	github.com/carlosframework/platform/internal/parity/cmd/parity-doc	[no test files]
ok  	github.com/carlosframework/platform/internal/park	1.084s
ok  	github.com/carlosframework/platform/internal/perf	0.202s
ok  	github.com/carlosframework/platform/internal/plans	0.107s
ok  	github.com/carlosframework/platform/internal/privatefile	0.017s
ok  	github.com/carlosframework/platform/internal/provision	236.928s
ok  	github.com/carlosframework/platform/internal/proxyproto	0.973s
ok  	github.com/carlosframework/platform/internal/publicrelease	0.049s
ok  	github.com/carlosframework/platform/internal/ratelimit	0.195s
ok  	github.com/carlosframework/platform/internal/regionlabel	0.074s
ok  	github.com/carlosframework/platform/internal/regionname	0.019s
ok  	github.com/carlosframework/platform/internal/registrar	0.008s
ok  	github.com/carlosframework/platform/internal/registrar/openprovider	0.703s
?   	github.com/carlosframework/platform/internal/registrar/registrartest	[no test files]
ok  	github.com/carlosframework/platform/internal/registry	83.581s
ok  	github.com/carlosframework/platform/internal/relay	7.728s
ok  	github.com/carlosframework/platform/internal/release	131.033s
?   	github.com/carlosframework/platform/internal/release/requestwitness	[no test files]
ok  	github.com/carlosframework/platform/internal/replicagen	0.034s
ok  	github.com/carlosframework/platform/internal/replicas	0.131s
ok  	github.com/carlosframework/platform/internal/reqrec	7.180s
ok  	github.com/carlosframework/platform/internal/rollout	12.054s
ok  	github.com/carlosframework/platform/internal/rolloutwords	0.066s
ok  	github.com/carlosframework/platform/internal/rootaws	102.226s
ok  	github.com/carlosframework/platform/internal/rootfsimage	0.940s
ok  	github.com/carlosframework/platform/internal/rootparticipation	0.103s
ok  	github.com/carlosframework/platform/internal/rootstate	0.051s
ok  	github.com/carlosframework/platform/internal/runs	0.771s
ok  	github.com/carlosframework/platform/internal/s3compat	0.046s
ok  	github.com/carlosframework/platform/internal/s3fake	1.616s
ok  	github.com/carlosframework/platform/internal/s3meter	0.629s
ok  	github.com/carlosframework/platform/internal/safefile	0.070s
ok  	github.com/carlosframework/platform/internal/schedule	22.831s
ok  	github.com/carlosframework/platform/internal/seeds	0.082s
ok  	github.com/carlosframework/platform/internal/share	0.055s
ok  	github.com/carlosframework/platform/internal/sim/litestreamfacts	5.128s
ok  	github.com/carlosframework/platform/internal/sim/mediajobs	52.640s
ok  	github.com/carlosframework/platform/internal/sim/regionha	23.666s
ok  	github.com/carlosframework/platform/internal/status	0.384s
ok  	github.com/carlosframework/platform/internal/steering	0.219s
ok  	github.com/carlosframework/platform/internal/stopevidence	0.462s
ok  	github.com/carlosframework/platform/internal/storecfg	0.464s
ok  	github.com/carlosframework/platform/internal/svcrole	0.044s
ok  	github.com/carlosframework/platform/internal/systemd	6.137s
?   	github.com/carlosframework/platform/internal/systemdshow	[no test files]
ok  	github.com/carlosframework/platform/internal/team	4.040s
ok  	github.com/carlosframework/platform/internal/teamcontract	0.135s
ok  	github.com/carlosframework/platform/internal/telemetry	0.054s
ok  	github.com/carlosframework/platform/internal/termfence	3.406s
ok  	github.com/carlosframework/platform/internal/timerspec	0.014s
ok  	github.com/carlosframework/platform/internal/tsidentity	4.204s
ok  	github.com/carlosframework/platform/internal/tunnelclient	0.352s
ok  	github.com/carlosframework/platform/internal/unixdial	0.010s
ok  	github.com/carlosframework/platform/internal/updatewords	0.034s
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.209s
ok  	github.com/carlosframework/platform/internal/version	0.008s
ok  	github.com/carlosframework/platform/internal/vet	3.425s
ok  	github.com/carlosframework/platform/internal/zonehost	0.026s
ok  	github.com/carlosframework/platform/internal/zonehost/route53zones	0.085s
?   	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.023s
ok  	github.com/carlosframework/platform/scripts/pathmapcheck	0.128s
ok  	github.com/carlosframework/platform/scripts/region-ha-g2/fixture	5.193s
ok  	github.com/carlosframework/platform/scripts/stateless-replicas-drill	1.168s
ok  	github.com/carlosframework/platform/scripts/witness-pointer	0.028s
=== cutover-witness (164 s, from +14 s)
ok  	github.com/carlosframework/platform	2.450s
=== internal_grouproll@0 (276 s, from +73 s)
ok  	github.com/carlosframework/platform/internal/grouproll	274.698s
=== internal_grouproll@1 (282 s, from +73 s)
ok  	github.com/carlosframework/platform/internal/grouproll	281.177s
=== internal_activator@0 (155 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	150.246s
=== internal_activator@1 (134 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	128.615s
=== internal_activator@2 (139 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	134.524s
=== internal_activator@3 (170 s, from +146 s)
ok  	github.com/carlosframework/platform/internal/activator	165.242s
=== internal_edge@0 (197 s, from +175 s)
ok  	github.com/carlosframework/platform/internal/edge	188.977s
=== internal_edge@1 (143 s, from +175 s)
ok  	github.com/carlosframework/platform/internal/edge	134.925s
=== internal_edge@2 (149 s, from +175 s)
ok  	github.com/carlosframework/platform/internal/edge	141.003s
=== internal_edge@3 (215 s, from +175 s)
ok  	github.com/carlosframework/platform/internal/edge	208.277s
=== root@0 (117 s, from +181 s)
ok  	github.com/carlosframework/platform	106.547s
=== root@1 (107 s, from +181 s)
ok  	github.com/carlosframework/platform	98.394s
=== root@2 (126 s, from +181 s)
ok  	github.com/carlosframework/platform	116.604s
=== root@3 (109 s, from +181 s)
ok  	github.com/carlosframework/platform	100.467s
=== root@4 (102 s, from +181 s)
ok  	github.com/carlosframework/platform	91.177s
=== internal_host@0 (174 s, from +219 s)
ok  	github.com/carlosframework/platform/internal/host	168.868s
=== internal_host@1 (152 s, from +219 s)
ok  	github.com/carlosframework/platform/internal/host	146.872s
=== internal_host@2 (173 s, from +219 s)
ok  	github.com/carlosframework/platform/internal/host	168.056s
=== internal_host@3 (188 s, from +219 s)
ok  	github.com/carlosframework/platform/internal/host	183.172s
=== internal_host@4 (225 s, from +219 s)
ok  	github.com/carlosframework/platform/internal/host	219.873s
=== internal_host@5 (258 s, from +219 s)
ok  	github.com/carlosframework/platform/internal/host	253.320s
=== internal_console@0 (178 s, from +227 s)
ok  	github.com/carlosframework/platform/internal/console	171.522s
=== internal_console@1 (174 s, from +227 s)
ok  	github.com/carlosframework/platform/internal/console	166.977s
=== internal_console@2 (208 s, from +227 s)
ok  	github.com/carlosframework/platform/internal/console	200.816s
=== internal_console@3 (253 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	247.489s
=== internal_console@4 (204 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	199.068s
=== internal_console@5 (261 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	255.084s
=== internal_console@6 (221 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	215.085s
=== internal_console@7 (229 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	223.165s
=== internal_console@8 (233 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	227.678s
=== internal_console@9 (244 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	237.342s
=== internal_console@10 (271 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	264.254s
=== internal_console@11 (247 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	240.067s
=== internal_console@12 (347 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	341.136s
=== internal_console@13 (216 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	209.726s
=== internal_console@14 (223 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	216.353s
=== internal_console@15 (236 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	230.076s
=== internal_console@16 (216 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	209.935s
=== internal_console@17 (251 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	245.446s
=== internal_console@18 (260 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	252.865s
=== internal_console@19 (239 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	233.262s
=== internal_console@20 (206 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	198.577s
=== internal_console@21 (232 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	226.395s
=== internal_console@22 (236 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	229.536s
=== internal_console@23 (246 s, from +228 s)
ok  	github.com/carlosframework/platform/internal/console	239.641s
=== lists: internal_console 226 s, internal_edge 174 s, internal_activator 145 s, internal_host 217 s, root 179 s, internal_grouproll 72 s
=== cpu: the gate used 13063 cpu-seconds in 576 s, about 22.7 of 32 cores; the machine as a whole was 76% busy
=== opentofu ===
opentofu: 40 test files in 11 suites, OpenTofu v1.13.9
  initialised in 15 s
  ok      20 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      32 s  infra/modules/deployment-buckets/tests/fence_writers.tftest.hcl  Success! 3 passed, 0 failed.
  ok      29 s  infra/modules/deployment-buckets/tests/media_results.tftest.hcl  Success! 2 passed, 0 failed.
  ok      28 s  infra/modules/deployment-buckets/tests/published_floors.tftest.hcl  Success! 3 passed, 0 failed.
  ok      74 s  infra/modules/media-engine/tests/media_engine.tftest.hcl  Success! 24 passed, 0 failed.
  ok      23 s  infra/modules/pdf-host/tests/computed.tftest.hcl  Success! 2 passed, 0 failed.
  ok      54 s  infra/modules/pdf-host/tests/pdf_host.tftest.hcl  Success! 24 passed, 0 failed.
  ok      39 s  infra/modules/region-group-operator-document/tests/document.tftest.hcl  Success! 12 passed, 0 failed.
  ok      13 s  infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl  Success! 2 passed, 0 failed.
  ok      57 s  infra/modules/region-host/ingress/tests/group_ingress.tftest.hcl  Success! 30 passed, 0 failed.
  ok      43 s  infra/modules/region-host/tests/alert_publish.tftest.hcl  Success! 18 passed, 0 failed.
  ok      39 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      15 s  infra/modules/region-host/tests/console_mail.tftest.hcl  Success! 4 passed, 0 failed.
  ok       6 s  infra/modules/region-host/tests/fixed_state_unchanged.tftest.hcl  Success! 1 passed, 0 failed.
  ok      70 s  infra/modules/region-host/tests/group.tftest.hcl  Success! 32 passed, 0 failed.
  ok      10 s  infra/modules/region-host/tests/group_alarms.tftest.hcl  Success! 4 passed, 0 failed.
  ok      11 s  infra/modules/region-host/tests/group_iam.tftest.hcl  Success! 4 passed, 0 failed.
  ok       6 s  infra/modules/region-host/tests/group_isolation.tftest.hcl  Success! 1 passed, 0 failed.
  ok      36 s  infra/modules/region-host/tests/group_operator.tftest.hcl  Success! 13 passed, 0 failed.
  ok       8 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      10 s  infra/modules/region-host/tests/ingress_drain_read.tftest.hcl  Success! 4 passed, 0 failed.
  ok       5 s  infra/modules/region-host/tests/instance_metadata.tftest.hcl  Success! 1 passed, 0 failed.
  ok      24 s  infra/modules/region-host/tests/mailer.tftest.hcl  Success! 6 passed, 0 failed.
  ok      10 s  infra/modules/region-host/tests/mailer_group.tftest.hcl  Success! 2 passed, 0 failed.
  ok      16 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      74 s  infra/modules/region-host/tests/store_conversion.tftest.hcl  Success! 27 passed, 0 failed.
  ok      17 s  infra/modules/region-host/tests/store_scanning.tftest.hcl  Success! 4 passed, 0 failed.
  ok      30 s  infra/modules/region-host/tests/store_versioning.tftest.hcl  Success! 11 passed, 0 failed.
  ok      15 s  infra/modules/region-host/tests/store_write_credentials.tftest.hcl  Success! 4 passed, 0 failed.
  ok      16 s  infra/modules/region-host/tests/user_data_ignored.tftest.hcl  Success! 3 passed, 0 failed.
  ok      11 s  infra/modules/region-remote-host/tests/data_lifecycle.tftest.hcl  Success! 3 passed, 0 failed.
  ok      16 s  infra/modules/region-remote-host/tests/no_deployment_bucket.tftest.hcl  Success! 5 passed, 0 failed.
  ok      29 s  infra/modules/scanner-host/tests/scanner_host.tftest.hcl  Success! 14 passed, 0 failed.
opentofu: 40 files in 210 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: 66781346 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:37676
Added `local` successfully.
Bucket created successfully `local/contract-bucket`.
Bucket created successfully `local/denied-bucket`.
Created policy `contract-only` successfully.
Added user `scopeduser` successfully.
Attached Policies: [contract-only]
To User: scopeduser
  buckets and scoped user ready
=== RUN   TestDeliveredContractMinio
=== RUN   TestDeliveredContractMinio/put
=== RUN   TestDeliveredContractMinio/get_round-trips_the_body
=== RUN   TestDeliveredContractMinio/list_shows_the_key
=== RUN   TestDeliveredContractMinio/head_and_list_agree_on_the_version
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed
=== RUN   TestDeliveredContractMinio/delete_removes_it
=== RUN   TestDeliveredContractMinio/cross-bucket_denial
--- PASS: TestDeliveredContractMinio (0.03s)
    --- PASS: TestDeliveredContractMinio/put (0.00s)
    --- PASS: TestDeliveredContractMinio/get_round-trips_the_body (0.00s)
    --- PASS: TestDeliveredContractMinio/list_shows_the_key (0.00s)
    --- PASS: TestDeliveredContractMinio/head_and_list_agree_on_the_version (0.00s)
    --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload (0.00s)
    --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route (0.01s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed (0.00s)
    --- PASS: TestDeliveredContractMinio/delete_removes_it (0.00s)
    --- PASS: TestDeliveredContractMinio/cross-bucket_denial (0.00s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.038s
=== RUN   TestT4StorageProbeMinio
2026/11/30 21:29:36 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18ECEFF2A4610C4B, HostID: 74bcd588ce089b122557dcb93655c5e046d1bc1a71e6deb95392f0fbefd9a01d, 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.047s
=== RUN   TestS3StoreMinioContract
=== RUN   TestS3StoreMinioContract/conditional_get_and_etag_listing
=== RUN   TestS3StoreMinioContract/bump_through_every_mutation_path
--- PASS: TestS3StoreMinioContract (0.03s)
    --- PASS: TestS3StoreMinioContract/conditional_get_and_etag_listing (0.01s)
    --- PASS: TestS3StoreMinioContract/bump_through_every_mutation_path (0.02s)
PASS
ok  	github.com/carlosframework/platform/internal/release	0.041s
Bucket created successfully `local/analytics-versions`.
local/analytics-versions versioning is enabled
Created policy `analytics-versions` successfully.
Added user `analyticsversions` successfully.
Attached Policies: [analytics-versions]
To User: analyticsversions
=== RUN   TestS3StoreMinioVersions
--- PASS: TestS3StoreMinioVersions (0.03s)
PASS
ok  	github.com/carlosframework/platform/internal/release	0.040s
Bucket created successfully `local/store-versioned`.
local/store-versioned versioning is enabled
Created policy `store-versioned` successfully.
Added user `storeversioned` successfully.
Attached Policies: [store-versioned]
To User: storeversioned
=== RUN   TestVersionedContractMinio
--- PASS: TestVersionedContractMinio (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.020s
Bucket created successfully `local/wc-bucket`.
Created policy `writer` successfully.
Added user `wcwriter` successfully.
Attached Policies: [writer]
To User: wcwriter
=== RUN   TestWriteCredentialContractMinio
=== RUN   TestWriteCredentialContractMinio/put_under_the_prefix
=== RUN   TestWriteCredentialContractMinio/multipart_under_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_copy_from_the_store
=== RUN   TestWriteCredentialContractMinio/refused:_read_under_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_list
=== RUN   TestWriteCredentialContractMinio/refused:_list_uploads
=== RUN   TestWriteCredentialContractMinio/refused:_delete
=== RUN   TestWriteCredentialContractMinio/refused:_tag
=== RUN   TestWriteCredentialContractMinio/refused:_put_tagged
=== RUN   TestWriteCredentialContractMinio/refused:_put_beside_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_bucket_settings
=== RUN   TestWriteCredentialContractMinio/refused:_read_elsewhere
=== RUN   TestWriteCredentialContractMinio/refused:_head
=== RUN   TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag
=== RUN   TestWriteCredentialContractMinio/refused:_put_outside_the_prefix
=== RUN   TestWriteCredentialContractMinio/refused:_put_to_another_bucket
--- PASS: TestWriteCredentialContractMinio (0.04s)
    --- PASS: TestWriteCredentialContractMinio/put_under_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/multipart_under_the_prefix (0.01s)
    --- PASS: TestWriteCredentialContractMinio/refused:_copy_from_the_store (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_read_under_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_list (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_list_uploads (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_delete (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_tag (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_tagged (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_beside_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_bucket_settings (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_read_elsewhere (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_head (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_outside_the_prefix (0.00s)
    --- PASS: TestWriteCredentialContractMinio/refused:_put_to_another_bucket (0.00s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.048s
=== RUN   TestEndToEndMinio
=== RUN   TestEndToEndMinio/plan
=== RUN   TestEndToEndMinio/roll
=== RUN   TestEndToEndMinio/replace
=== RUN   TestEndToEndMinio/remove
--- PASS: TestEndToEndMinio (0.47s)
    --- PASS: TestEndToEndMinio/plan (0.01s)
    --- PASS: TestEndToEndMinio/roll (0.13s)
    --- PASS: TestEndToEndMinio/replace (0.15s)
    --- PASS: TestEndToEndMinio/remove (0.16s)
PASS
ok  	github.com/carlosframework/platform/internal/grouproll	0.482s
Bucket created successfully `local/dbf-deploy`.
Bucket created successfully `local/dbf-data-ie`.
Bucket created successfully `local/dbf-data-uk`.
local/dbf-deploy versioning is enabled
Created policy `dbf-console` successfully.
Created policy `dbf-ukbox` successfully.
Added user `dbfconsole` successfully.
Added user `dbfukbox` successfully.
Attached Policies: [dbf-console]
To User: dbfconsole
Attached Policies: [dbf-ukbox]
To User: dbfukbox
=== RUN   TestDBForwardMinio
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/30 21:29:45 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/11/30 21:29:45 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/11/30 21:29:45 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/30 21:29:45 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/30 21:29:45 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/30 21:29:45 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/11/30 21:29:45 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%3A35287: could not determine target mailbox
    agent.go:136: dbreads: dbr_5izh5wt6kvlvhzezk7rbu2jpkq: planned 3 files (1544 bytes) and restored to 3 in 13ms
    agent.go:136: dbreads: dbr_5izh5wt6kvlvhzezk7rbu2jpkq: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/30 21:29:46 console: db read dbr_5izh5wt6kvlvhzezk7rbu2jpkq: relayed 1 chunks (102 bytes) in 1.005s, ended done
    agent.go:136: dbreads: dbr_vg4ps6kk7uqi7cao25agq7pdii: planned 1 files (720 bytes) and restored to 1 in 11ms
    agent.go:136: dbreads: dbr_vg4ps6kk7uqi7cao25agq7pdii: output 5 bytes in 1 confirmed chunks in 1ms
2026/11/30 21:29:47 console: db read dbr_vg4ps6kk7uqi7cao25agq7pdii: relayed 1 chunks (102 bytes) in 1.005s, ended done
    agent.go:136: dbreads: dbr_kjzechvwkw4wpbgwqvxlrz5kli: planned 3 files (1544 bytes) and held through 3 in 13ms
    agent.go:136: dbreads: dbr_kjzechvwkw4wpbgwqvxlrz5kli: output 1544 bytes in 1 confirmed chunks in 1ms
2026/11/30 21:29:48 console: db read dbr_kjzechvwkw4wpbgwqvxlrz5kli: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN   TestDBForwardMinio/by_disconnect
=== NAME  TestDBForwardMinio
    agent.go:136: dbreads: dbr_g4snugfbmiiqbn5wfjeigxsq34: planned 3 files (1544 bytes) and restored to 3 in 14ms
2026/11/30 21:29:48 console: db read dbr_g4snugfbmiiqbn5wfjeigxsq34: relayed 0 chunks (0 bytes) in 22ms, ended client gone
    agent.go:136: dbreads: dbr_g4snugfbmiiqbn5wfjeigxsq34: output 5 bytes in 1 confirmed chunks in 104ms
=== RUN   TestDBForwardMinio/by_timeout
=== NAME  TestDBForwardMinio
    agent.go:136: dbreads: dbr_edvbt62mu723spfly7ejfc3fwq: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/30 21:30:08 console: db read dbr_edvbt62mu723spfly7ejfc3fwq: relayed 0 chunks (0 bytes) in 19.001s, ended no-result
    agent.go:136: dbreads: dbr_edvbt62mu723spfly7ejfc3fwq: output 5 bytes in 1 confirmed chunks in 18.976s
--- PASS: TestDBForwardMinio (22.68s)
    --- PASS: TestDBForwardMinio/by_disconnect (0.23s)
    --- PASS: TestDBForwardMinio/by_timeout (19.11s)
PASS
ok  	github.com/carlosframework/platform/internal/console	22.724s
Bucket created successfully `local/media-transfers`.
Bucket created successfully `local/media-transfer-results`.
local/media-transfer-results versioning is enabled
Created policy `media-transfers` successfully.
Added user `mediatransfers` successfully.
Attached Policies: [media-transfers]
To User: mediatransfers
=== RUN   TestMediaTransfersMinio
    upload.go:117: codec: the store already holds video.mp4
    upload.go:117: codec: the store already holds video.m3u8
    upload.go:117: codec: the store already holds poster.jpg
--- PASS: TestMediaTransfersMinio (0.07s)
PASS
ok  	github.com/carlosframework/platform/internal/mediaaws	0.075s
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.56s)
PASS
ok  	github.com/carlosframework/platform/internal/medialocal	0.565s
=== RUN   TestHeldHandoverTwoBoxMinio
2026/11/30 21:30:13 edge: mesh key: minted
2026/11/30 21:30:13 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:30:13 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:30:13 tenant admission is open. accepting tenant work
2026/11/30 21:30:13 activator: HA placement host=shop-00404be8.example.test kind=Place ref=annie reason=roomiest generation=2026-11-30T21:30:13Z lock_generation=0
2026/11/30 21:30:13 lease: t8-00404be8/shop-00404be8.example.test: HA lease acquired in 4ms (first wake)
2026/11/30 21:30:13 activator: shop-00404be8.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/30 21:30:13 activator: shop-00404be8.example.test: started carlos-instance@shop\x2d00404be8.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 6ms, control socket 0s, key gate 0s, logs 0s) 6ms, launch file 0s, gate 0s, root start 1ms)
2026/11/30 21:30:13 activator: shop-00404be8.example.test: carlos-instance@shop\x2d00404be8.example.test.service launched in 7ms, healthy 0s later
2026/11/30 21:30:13 activator: shop-00404be8.example.test: woke in 21ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 8ms
2026/11/30 21:30:13 lease: t8-00404be8/plain-00404be8.example.test: acquired in 3ms (client 0s, lock read and write 3ms)
2026/11/30 21:30:13 activator: no replica for plain-00404be8.example.test in s3://contract-bucket/t8-00404be8/plain-00404be8.example.test — booting fresh
2026/11/30 21:30:13 activator: plain-00404be8.example.test: started carlos-instance@plain\x2d00404be8.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 2ms, instance key 0s, env 5ms, control socket 0s, key gate 0s, logs 0s) 7ms, launch file 0s, gate 0s, root start 1ms)
2026/11/30 21:30:13 activator: plain-00404be8.example.test: carlos-instance@plain\x2d00404be8.example.test.service launched in 8ms, healthy 0s later
2026/11/30 21:30:13 activator: plain-00404be8.example.test: woke in 94ms: checks 0s, lease 3ms, restore 19ms, identity 0s, protect 0s, spawn 9ms, replicate 62ms
2026/11/30 21:30:13 lease: t8-00404be8/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/11/30 21:30:13 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/30 21:30:13 activator: bot0.shop.bac.sidecar.internal: woke in 70ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, settle 0s, replicate 58ms
2026/11/30 21:30:13 activator: next-due probe plain-00404be8.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/30 21:30:13 activator: plain-00404be8.example.test hibernated
2026/11/30 21:30:13 activator: next-due probe shop-00404be8.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/30 21:30:13 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:5d8c9ab6a39b759746b52b488fbb04f449c2697ebbdcfbb917b71ad1e1bb8bae) in 6ms: files 1ms, sync 3ms, record 1ms, marker 2ms
2026/11/30 21:30:13 activator: bot0.shop.bac.sidecar.internal hibernated
2026/11/30 21:30:13 activator: shop-00404be8.example.test: released with a marker (clean true, txid 1, files 3:73e3a96e14954a060a452de9835e95a532810ff06bf3a024b672167a654f7d2f) in 5ms: files 1ms, sync 2ms, record 1ms, marker 2ms
2026/11/30 21:30:13 activator: shop-00404be8.example.test hibernated
2026/11/30 21:30:13 lease: t8-00404be8/shop-00404be8.example.test: HA lease acquired in 3ms (clean marker)
2026/11/30 21:30:13 activator: shop-00404be8.example.test: restored (other-box)
2026/11/30 21:30:13 activator: shop-00404be8.example.test: started carlos-instance@shop\x2d00404be8.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/11/30 21:30:13 activator: shop-00404be8.example.test: carlos-instance@shop\x2d00404be8.example.test.service launched in 2ms, healthy 0s later
2026/11/30 21:30:13 activator: shop-00404be8.example.test: woke in 85ms: checks 0s, lease 3ms, restore 24ms, identity 0s, protect 0s, spawn 2ms, replicate 55ms
2026/11/30 21:30:13 edge: ha-take shop-00404be8.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/11/30 21:30:13 edge: forward shop-00404be8.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:4f25ae7fe947020fb23a31caeed1dc23 Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-11-30 21:30:13.599410622 +0000 UTC FinishedAt:2026-11-30 21:30:13.747274514 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-00404be8.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:plain-00404be8.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-00404be8.example.test <nil> releasing shop-00404be8.example.test <nil> stop plain-00404be8.example.test marker=true clean=true <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> stop shop-00404be8.example.test marker=true clean=true <nil> taken shop-00404be8.example.test betty <nil> end-moves]
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-00404be8/plain-00404be8.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-00404be8/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-00404be8/bot0.shop.bac.sidecar.internal/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-00404be8/shop-00404be8.example.test/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-00404be8/shop-00404be8.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-00404be8/shop-00404be8.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/head.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/generations/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0008/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0007/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0006/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0005/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0004/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0008/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0007/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0006/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0005/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0004/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/files/0/manifest.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/files/0/objects/0000000000000001-920cf257ddc2daadedd8b21124bb11ce26aa57f093b71c2b8e807bb3daa845ab
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/files/0/objects/0000000000000003-65ee4a25769fb4503bdb70a1ac43c5c910e49dfa37cd6804964fe64ccacd8851
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/0000/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-00404be8/shop-00404be8.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-00404be8/shop-00404be8.example.test/0000/0000000000000002-0000000000000002.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-00404be8/shop-00404be8.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1243: drain took 193ms; S3 calls 44 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=28 PUT lock=3 PUT replica=3); deployment store calls 20 (GET edges=14 LIST edges=4 PUT edges=2)
    hadrain_twobox_minio_linux_test.go:1367: the fenced A's start gate answers 503 "This service is unavailable. Try again later.\n" (Retry-After "10")
2026/11/30 21:30:13 lease: t8-00404be8/plain-00404be8.example.test: acquired in 2ms (client 0s, lock read and write 2ms)
2026/11/30 21:30:13 activator: plain-00404be8.example.test: started carlos-instance@plain\x2d00404be8.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 0s, control socket 0s, key gate 0s, logs 0s) 0s, launch file 0s, gate 0s, root start 1ms)
2026/11/30 21:30:13 activator: plain-00404be8.example.test: carlos-instance@plain\x2d00404be8.example.test.service launched in 1ms, healthy 0s later
2026/11/30 21:30:13 lease: /tmp/carlos-minio-contract-mqptTo/g/dw769816513/data/instances/plain-00404be8.example.test/plain-00404be8.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/11/30 21:30:13 activator: plain-00404be8.example.test: woke in 8ms: checks 0s, lease 2ms, restore 0s, identity 0s, protect 1ms, spawn 2ms, replicate 4ms
2026/11/30 21:30:13 activator: next-due probe shop-00404be8.example.test: decode /api/next-due: invalid character 'b' looking for beginning of value — recording none (it sleeps until a request)
2026/11/30 21:30:13 activator: shop-00404be8.example.test: released with a marker (clean true, txid 2, files 3:73e3a96e14954a060a452de9835e95a532810ff06bf3a024b672167a654f7d2f) in 4ms: files 1ms, sync 0s, record 1ms, marker 2ms
2026/11/30 21:30:13 activator: shop-00404be8.example.test hibernated
2026/11/30 21:30:13 tenant admission is closed for shutdown
2026/11/30 21:30:13 activator: next-due probe plain-00404be8.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/30 21:30:13 activator: plain-00404be8.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.60s)
=== RUN   TestHeldHandoverLostLeaseMinio
2026/11/30 21:30:13 edge: mesh key: minted
2026/11/30 21:30:13 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:30:13 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:30:13 tenant admission is open. accepting tenant work
2026/11/30 21:30:13 activator: HA placement host=shop-81e5c10d.example.test kind=Place ref=annie reason=roomiest generation=2026-11-30T21:30:13Z lock_generation=0
2026/11/30 21:30:13 lease: t8-81e5c10d/shop-81e5c10d.example.test: HA lease acquired in 3ms (first wake)
2026/11/30 21:30:13 activator: shop-81e5c10d.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/30 21:30:13 activator: shop-81e5c10d.example.test: started carlos-instance@shop\x2d81e5c10d.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 6ms, control socket 0s, key gate 0s, logs 0s) 6ms, launch file 0s, gate 0s, root start 1ms)
2026/11/30 21:30:13 activator: shop-81e5c10d.example.test: carlos-instance@shop\x2d81e5c10d.example.test.service launched in 7ms, healthy 0s later
2026/11/30 21:30:14 activator: shop-81e5c10d.example.test: woke in 67ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 55ms
2026/11/30 21:30:14 activator: next-due probe shop-81e5c10d.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/30 21:30:14 activator: final checkpoint shop-81e5c10d.example.test: lease: release marker owed for s3://contract-bucket/t8-81e5c10d/shop-81e5c10d.example.test/lock.json (If-Match "af8f12192610e865e4ca016a6a935ec3"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/11/30 21:30:14 activator: shop-81e5c10d.example.test hibernated
2026/11/30 21:30:14 activator: handover of shop-81e5c10d.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-81e5c10d.example.test client 4 "
    hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-81e5c10d.example.test <nil> releasing shop-81e5c10d.example.test <nil> stop shop-81e5c10d.example.test marker=false clean=false <nil> left shop-81e5c10d.example.test released without a marker]
    hadrain_twobox_minio_linux_test.go:1487: a request after the loss: 503 "This instance cannot wake right now. Please try again shortly.\n" (Retry-After "10", holder "none", 0s, err <nil>)
2026/11/30 21:30:14 tenant admission is closed for shutdown
2026/11/30 21:30:14 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.32s)
PASS
ok  	github.com/carlosframework/platform/internal/host	0.970s
Bucket created successfully `local/gen-take`.
local/gen-take versioning is enabled
Created policy `gen-take` successfully.
Added user `gentake` successfully.
Attached Policies: [gen-take]
To User: gentake
=== RUN   TestGenerationTakeMinio
=== RUN   TestGenerationTakeMinio/take
2026/11/30 21:30:15 lease: instances/gen-1796074215336878632.shop.example.com: HA lease acquired in 5ms (first wake)
2026/11/30 21:30:15 lease: instances/gen-1796074215336878632.shop.example.com: HA lease acquired in 3ms (holder terminated)
    gentake_minio_test.go:308: a second create-only copy onto instances/gen-1796074215336878632.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/11/30 21:30: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/11/30 21:30:15 ERROR enforce L0 time retention system=store db=w.example.com.db error="fetch l1 files: lease: a write has waited too long to reach storage (write fence)"
2026/11/30 21:30:15 ERROR retention enforcement failed system=store db=w.example.com.db error="enforce snapshot retention: remove ltx files: lease: a write has waited too long to reach storage (write fence)"
2026/11/30 21:30:15 http: proxy error: context canceled
=== RUN   TestGenerationTakeMinio/switch-412
2026/11/30 21:30:15 lease: instances/gen-1796074215461811288.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/30 21:30:15 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/30 21:30:15 lease: instances/gen-1796074215461811288.shop.example.com: HA lease acquired in 3ms (clean marker)
=== RUN   TestGenerationTakeMinio/copy-version
=== RUN   TestGenerationTakeMinio/store-time
2026/11/30 21:30:15 lease: instances/gen-1796074215558188716.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/30 21:30:15 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/30 21:30:15 lease: instances/gen-1796074215558188716.shop.example.com: HA lease acquired in 2ms (clean marker)
2026/11/30 21:30:15 lease: instances/gen-1796074215558188716.shop.example.com: HA lease acquired in 3ms (unclean marker)
2026/11/30 21:30:15 lease: instances/gen-1796074215558188716.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/30 21:30:15 lease: instances/gen-1796074215558188716.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/30 21:30:15 lease: instances/gen-1796074215558188716.shop.example.com: HA lease acquired in 2ms (unclean marker)
=== RUN   TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.38s)
    --- PASS: TestGenerationTakeMinio/take (0.12s)
    --- PASS: TestGenerationTakeMinio/switch-412 (0.09s)
    --- PASS: TestGenerationTakeMinio/copy-version (0.01s)
    --- PASS: TestGenerationTakeMinio/store-time (0.15s)
    --- PASS: TestGenerationTakeMinio/skew (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/lease	0.395s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading golang.org/x/sync v0.23.0
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
staticcheck: clean
=== govulncheck ===
go version go1.26.10 linux/arm64
go: downloading golang.org/x/vuln v1.8.0
go: downloading golang.org/x/telemetry v0.0.0-20260908163034-4bcc4b2ee518
go: downloading golang.org/x/tools v0.50.0
govulncheck: scanned github.com/carlosframework/platform, amadan.net/carlos/platform.git/launchctx, carlos-vulnscan
GO-2026-6859  called  stdlib@v1.26.10, fixed in v1.26.11
    HTTP/1 server crash due to MaxBytesReader header race in net/http
    excepted until 2027-01-31 (.amadan/govulncheck-exceptions.tsv:9): net/http MaxBytesReader header race, fixed in go1.26.11. CI and releases stay on go1.26.10 because 1.26.11 deadlocks the edge's Expect: 100-continue path (#897, .amadan/go-toolchain.sh); #904 checked every production MaxBytesReader site and found it unreachable.
GO-2026-5932  required  golang.org/x/crypto@v0.58.0, fixed in v0.58.1-0.20261009181718-2f1f834330b2
    The golang.org/x/crypto/openpgp package is unmaintained, unsafe by design, and has known security issues
    not fatal: no call path to the vulnerable code
govulncheck: clean (2 finding(s), none called outside .amadan/govulncheck-exceptions.tsv)
=== code-health ===
go version go1.26.10 linux/arm64
    codehealth_test.go:42: scanned in 1m54.656s
    codehealth_test.go:107: line metrics (code lines, then physical):
          file-lines  5471  7324  internal/activator activator_test.go
          file-lines  4179  7018  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  6342  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 (216 files):
          cmd/carlos-media/drill_other.go: built only for other systems or tags
          cmd/carlos-media/harden_other.go: built only for other systems or tags
          cmd/console/fleetsocket_other.go: built only for other systems or tags
          cmd/console/servelock_windows.go: built only for other systems or tags
          cmd/moveprobe/detach_windows.go: built only for other systems or tags
          cmd/rootfswitness/mmap_other.go: built only for other systems or tags
          devbox_acl_other.go: built only for other systems or tags
          devbox_envfile_darwin_test.go: built only for other systems or tags
          devbox_envfile_other.go: built only for other systems or tags
          domains_transfer_signals_other.go: built only for other systems or tags
          interactive_term_darwin.go: built only for other systems or tags
          interactive_term_other.go: built only for other systems or tags
          internal/activator/claimprocess_root_other.go: built only for other systems or tags
          internal/activator/escrow_stamp_other.go: built only for other systems or tags
          internal/activator/fleetreserve_other.go: built only for other systems or tags
          internal/activator/harecord_other.go: built only for other systems or tags
          internal/activator/ownenv_other.go: built only for other systems or tags
          internal/activator/pty_other.go: built only for other systems or tags
          internal/activator/race_on_test.go: built only for other systems or tags
          internal/activator/rolelaunch_other.go: built only for other systems or tags
          internal/assetcache/statfs_other.go: built only for other systems or tags
          internal/boxself/io_other.go: built only for other systems or tags
          internal/cgroup/cleanup_other.go: built only for other systems or tags
          internal/cgroup/cleanup_other_test.go: built only for other systems or tags
          internal/cgroup/hostprocs_other.go: built only for other systems or tags
          internal/cgroup/recreate_other.go: built only for other systems or tags
          internal/cgroup/role_other.go: built only for other systems or tags
          internal/cgroup/shim_other.go: built only for other systems or tags
          internal/cgroup/strict_other.go: built only for other systems or tags
          internal/cgroup/verify_other.go: built only for other systems or tags
          internal/console/claim_sql_identity_other.go: built only for other systems or tags
          internal/console/geoipverify_other.go: built only for other systems or tags
          internal/console/hostreports_process_other.go: built only for other systems or tags
          internal/console/replicaview_other.go: built only for other systems or tags
          internal/console/restore_sim_nice_other_test.go: built only for other systems or tags
          internal/console/scalecost_other_test.go: built only for other systems or tags
          internal/console/seedscratch_windows.go: built only for other systems or tags
          internal/dbreads/worker_other.go: built only for other systems or tags
          internal/demobuild/security_other.go: built only for other systems or tags
          internal/democlaim/source_other.go: built only for other systems or tags
          internal/devbox/peer_darwin.go: built only for other systems or tags
          internal/devbox/peer_darwin_test.go: built only for other systems or tags
          internal/devbox/peer_other.go: built only for other systems or tags
          internal/devbox/socketcheck_other.go: built only for other systems or tags
          internal/domains/certimport_read_portable.go: built only for other systems or tags
          internal/edge/devboxpeer_other.go: built only for other systems or tags
          internal/edge/hairpin_other.go: built only for other systems or tags
          internal/edge/heldbudget_other.go: built only for other systems or tags
          internal/edge/purge_listen_unix.go: built only for other systems or tags
          internal/edge/purge_listen_windows.go: built only for other systems or tags
          internal/edge/race_on_test.go: built only for other systems or tags
          internal/edge/replicaconsole_owner_other.go: built only for other systems or tags
          internal/edge/replicaconsole_peer_other.go: built only for other systems or tags
          internal/edge/replicaconsole_socket_other_test.go: built only for other systems or tags
          internal/edge/static_artifact_other.go: built only for other systems or tags
          internal/edge/static_recordlock_other.go: built only for other systems or tags
          internal/edge/static_sweep_other.go: built only for other systems or tags
          internal/execsandbox/cleanup_other.go: built only for other systems or tags
          internal/execsandbox/file_other.go: built only for other systems or tags
          internal/execsandbox/oci_other.go: built only for other systems or tags
          internal/fileacl/fileacl_darwin.go: built only for other systems or tags
          internal/fileacl/fileacl_darwin_amd64.s: built only for other systems or tags
          internal/fileacl/fileacl_darwin_arm64.s: built only for other systems or tags
          internal/fileacl/fileacl_darwin_test.go: built only for other systems or tags
          internal/grouproll/state_other.go: built only for other systems or tags
          internal/grouprollaws/pty_darwin.go: built only for other systems or tags
          internal/grouprollaws/pty_other.go: built only for other systems or tags
          internal/hairpin/native_other.go: built only for other systems or tags
          internal/host/applylock_other_test.go: built only for other systems or tags
          internal/host/bootstrapfs_other.go: built only for other systems or tags
          internal/host/boxroles_config_other.go: built only for other systems or tags
          internal/host/claimfilesseed_delegation_other.go: built only for other systems or tags
          internal/host/claimfilesseed_transport_other.go: built only for other systems or tags
          internal/host/claimjournal_containment_other.go: built only for other systems or tags
          internal/host/claimjournal_migration_other.go: built only for other systems or tags
          internal/host/claimlaunch_kernel_other.go: built only for other systems or tags
          internal/host/claimlaunch_rev2_other_test.go: built only for other systems or tags
          internal/host/claimproduction_other.go: built only for other systems or tags
          internal/host/claimready_other.go: built only for other systems or tags
          internal/host/claimroleassembly_other.go: built only for other systems or tags
          internal/host/claimservingartifact_other.go: built only for other systems or tags
          internal/host/claimservinghandover_reboot_other.go: built only for other systems or tags
          internal/host/claimservinghandover_reboot_other_test.go: built only for other systems or tags
          internal/host/claimservingpark_other.go: built only for other systems or tags
          internal/host/claimstate_other.go: built only for other systems or tags
          internal/host/claimstop_kernel_other.go: built only for other systems or tags
          internal/host/claimtoken_inventory_other.go: built only for other systems or tags
          internal/host/claimunit_dropin_other.go: built only for other systems or tags
          internal/host/claimunit_files_other.go: built only for other systems or tags
          internal/host/claimunit_migrate_other.go: built only for other systems or tags
          internal/host/claimunit_ready_other.go: built only for other systems or tags
          internal/host/claimunit_socket_migration_other.go: built only for other systems or tags
          internal/host/consolefleet_owner_other.go: built only for other systems or tags
          internal/host/dbreads_other.go: built only for other systems or tags
          internal/host/egress_rail_other.go: built only for other systems or tags
          internal/host/fileowner_other.go: built only for other systems or tags
          internal/host/flock_windows.go: built only for other systems or tags
          internal/host/group_config_other.go: built only for other systems or tags
          internal/host/group_maintenance_other.go: built only for other systems or tags
          internal/host/group_maintenance_verbs_other.go: built only for other systems or tags
          internal/host/group_receipt_other.go: built only for other systems or tags
          internal/host/hadrain_call_other.go: built only for other systems or tags
          internal/host/hadrain_socket_other.go: built only for other systems or tags
          internal/host/hadrainfence_other.go: built only for other systems or tags
          internal/host/headroom_other.go: built only for other systems or tags
          internal/host/installchannel_other.go: built only for other systems or tags
          internal/host/managedboot_other.go: built only for other systems or tags
          internal/host/metrics_nested_other.go: built only for other systems or tags
          internal/host/movesfloor_other.go: built only for other systems or tags
          internal/host/movesfloorgate_other.go: built only for other systems or tags
          internal/host/movesheldrelease_other.go: built only for other systems or tags
          internal/host/movesmeasure_other.go: built only for other systems or tags
          internal/host/offcloudcredentials_other.go: built only for other systems or tags
          internal/host/registrychild_exec_other.go: built only for other systems or tags
          internal/host/registrychild_other.go: built only for other systems or tags
          internal/host/registryowner_chown_other.go: built only for other systems or tags
          internal/host/registryowner_descriptor_unix.go: built only for other systems or tags
          internal/host/replicahealth_other.go: built only for other systems or tags
          internal/host/rootgeneration_census_other.go: built only for other systems or tags
          internal/host/rootgeneration_kernel_other.go: built only for other systems or tags
          internal/host/rootgeneration_payload_other.go: built only for other systems or tags
          internal/host/rootgeneration_retired_other.go: built only for other systems or tags
          internal/host/rootmigration_production_other.go: built only for other systems or tags
          internal/host/runscset_other.go: built only for other systems or tags
          internal/host/sandboxenv_other.go: built only for other systems or tags
          internal/host/statfs_windows.go: built only for other systems or tags
          internal/host/systemapply_other.go: built only for other systems or tags
          internal/hostbox/census_vendor_other.go: built only for other systems or tags
          internal/hostbox/inventory_identity_other.go: built only for other systems or tags
          internal/hostbox/journalmigration_other.go: built only for other systems or tags
          internal/hostbox/journalnamespace_other.go: built only for other systems or tags
          internal/hostbox/journaltrust_other.go: built only for other systems or tags
          internal/hostbox/migration_census_other.go: built only for other systems or tags
          internal/hostbox/typedpark_other.go: built only for other systems or tags
          internal/hostenv/group_other.go: built only for other systems or tags
          internal/hostenv/write_other.go: built only for other systems or tags
          internal/hostenv/write_other_test.go: built only for other systems or tags
          internal/hostexec/clock_other.go: built only for other systems or tags
          internal/hostexec/clock_other_test.go: built only for other systems or tags
          internal/hostexec/local_other.go: built only for other systems or tags
          internal/hostexec/pending_other.go: built only for other systems or tags
          internal/hostexec/probe_other.go: built only for other systems or tags
          internal/hostexec/rootprocess_other.go: built only for other systems or tags
          internal/hostfiles/dir_other.go: built only for other systems or tags
          internal/hostfiles/refuse_other.go: built only for other systems or tags
          internal/hostfiles/watch_other.go: built only for other systems or tags
          internal/hostfloor/controllers_other.go: built only for other systems or tags
          internal/hostfloor/image_other.go: built only for other systems or tags
          internal/hostguard/flock_other.go: built only for other systems or tags
          internal/hostguard/flock_other_test.go: built only for other systems or tags
          internal/hostguard/record_other.go: built only for other systems or tags
          internal/instancectl/claimexec_other.go: built only for other systems or tags
          internal/instancectl/claimexec_socket_other.go: built only for other systems or tags
          internal/instancectl/claimlaunch_snapshot_other.go: built only for other systems or tags
          internal/instancectl/claimnetwork_other.go: built only for other systems or tags
          internal/instancectl/demo_snapshot_other.go: built only for other systems or tags
          internal/instancectl/egress_cgroup_other.go: built only for other systems or tags
          internal/instancectl/egress_dropin_other.go: built only for other systems or tags
          internal/instancectl/fleetsize_other.go: built only for other systems or tags
          internal/instancectl/gvisorprobe_other.go: built only for other systems or tags
          internal/instancectl/peer_other.go: built only for other systems or tags
          internal/instancectl/peer_tuple_other.go: built only for other systems or tags
          internal/instancectl/rootfs_identity_other.go: built only for other systems or tags
          internal/instanceexec/claimexec_other.go: built only for other systems or tags
          internal/instanceexec/exec_rootfs_other.go: built only for other systems or tags
          internal/instanceexec/netlink_route_other.go: built only for other systems or tags
          internal/instanceexec/probe_gvisor_other.go: built only for other systems or tags
          internal/instanceexec/probe_hardening_other.go: built only for other systems or tags
          internal/instanceexec/probe_other.go: built only for other systems or tags
          internal/instanceexec/probe_rootfs_other.go: built only for other systems or tags
          internal/instanceexec/sandbox_other.go: built only for other systems or tags
          internal/instanceexec/scope_other.go: built only for other systems or tags
          internal/instanceexec/stop_other.go: built only for other systems or tags
          internal/instanceexec/tty_other.go: built only for other systems or tags
          internal/instancefs/instancefs_other.go: built only for other systems or tags
          internal/launchd/activate_darwin.go: built only for other systems or tags
          internal/launchd/activate_darwin_amd64.s: built only for other systems or tags
          internal/launchd/activate_darwin_arm64.s: built only for other systems or tags
          internal/launchd/activate_darwin_test.go: built only for other systems or tags
          internal/layout/journal_other.go: built only for other systems or tags
          internal/layout/links_other.go: built only for other systems or tags
          internal/mailer/keys_other.go: built only for other systems or tags
          internal/maintenanceexec/run_other.go: built only for other systems or tags
          internal/managedboot/admission_other.go: built only for other systems or tags
          internal/managedboot/identity_other.go: built only for other systems or tags
          internal/mediahandler/collect_other.go: built only for other systems or tags
          internal/mediahandler/procs_other.go: built only for other systems or tags
          internal/medialocal/runner_other.go: built only for other systems or tags
          internal/moves/archive/open_other.go: built only for other systems or tags
          internal/moves/archive/sync_other.go: built only for other systems or tags
          internal/ops/flock_windows.go: built only for other systems or tags
          internal/park/local_other.go: built only for other systems or tags
          internal/privatefile/io_other.go: built only for other systems or tags
          internal/proxyproto/peek_other.go: built only for other systems or tags
          internal/relay/race_on_test.go: built only for other systems or tags
          internal/release/consumedfence_other.go: built only for other systems or tags
          internal/release/digestcache_other.go: built only for other systems or tags
          internal/rootaws/credentials_other.go: built only for other systems or tags
          internal/rootaws/open_darwin.go: built only for other systems or tags
          internal/rootfsimage/dir_other.go: built only for other systems or tags
          internal/rootstate/authoritydir_other.go: built only for other systems or tags
          internal/rootstate/authorityfile_other.go: built only for other systems or tags
          internal/rootstate/file_other.go: built only for other systems or tags
          internal/rootstate/link_other.go: built only for other systems or tags
          internal/rootstate/persistent_other.go: built only for other systems or tags
          internal/rootstate/state_other.go: built only for other systems or tags
          internal/safefile/file_other.go: built only for other systems or tags
          internal/safefile/reap_other.go: built only for other systems or tags
          internal/stopevidence/fds_other.go: built only for other systems or tags
          internal/stopevidence/fds_other_test.go: built only for other systems or tags
          internal/stopevidence/holders_other.go: built only for other systems or tags
          internal/stopevidence/reconstruct_other.go: built only for other systems or tags
          internal/team/storelock_other.go: built only for other systems or tags
          internal/team/storelock_windows.go: built only for other systems or tags
          move_offline_run_other.go: built only for other systems or tags
          system_group_other.go: built only for other systems or tags
        
    codehealth_test.go:115: fatal               1090 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         30615 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 -: 4179 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 (114.66s)
PASS
ok  	github.com/carlosframework/platform/internal/codehealth	115.656s
=== code-health-record ===
go version go1.26.10 linux/arm64
code-health record: comparing with the merge base 9d294ace6fab2e2be5546a26025259b96827e04c (main is 9d294ace6fab2e2be5546a26025259b96827e04c)
=== RUN   TestRecordAgainstBase
--- PASS: TestRecordAgainstBase (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/codehealth	0.008s
code-health record: no line went up without a reason
=== race ===
go version go1.26.10 linux/arm64
GATE_RACE=1 .amadan/test-gate.sh
=== internal_systemd@0 (14 s, from +14 s)
ok  	github.com/carlosframework/platform/internal/systemd	13.653s
=== internal_rootaws@0 (26 s, from +35 s)
ok  	github.com/carlosframework/platform/internal/rootaws	25.416s
=== internal_activator@0 (272 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	269.348s
=== internal_activator@1 (250 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	247.748s
=== internal_activator@2 (289 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	286.195s
=== internal_activator@3 (428 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	426.028s
=== internal_activator@4 (285 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	282.920s
=== internal_activator@5 (313 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	310.709s
=== internal_activator@6 (294 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	292.138s
=== internal_activator@7 (423 s, from +112 s)
ok  	github.com/carlosframework/platform/internal/activator	420.947s
=== internal_edge@0 (84 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	81.613s
=== internal_edge@1 (101 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	98.548s
=== internal_edge@2 (211 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	207.686s
=== internal_edge@3 (164 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	161.135s
=== internal_edge@4 (191 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	187.974s
=== internal_edge@5 (227 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	224.423s
=== internal_edge@6 (204 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	201.283s
=== internal_edge@7 (215 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	211.621s
=== internal_edge@8 (265 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	262.073s
=== internal_edge@9 (286 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	282.591s
=== internal_edge@10 (226 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	223.559s
=== internal_edge@11 (222 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	219.553s
=== internal_edge@12 (253 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	250.088s
=== internal_edge@13 (256 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	253.066s
=== internal_edge@14 (176 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	172.586s
=== internal_edge@15 (256 s, from +136 s)
ok  	github.com/carlosframework/platform/internal/edge	252.977s
=== internal_host@0 (16 s, from +197 s)
ok  	github.com/carlosframework/platform/internal/host	12.038s
=== internal_host@1 (9 s, from +197 s)
ok  	github.com/carlosframework/platform/internal/host	5.413s
=== lists: internal_edge 135 s, internal_activator 112 s, internal_host 196 s, internal_rootaws 34 s, internal_systemd 13 s
=== cpu: the gate used 7715 cpu-seconds in 541 s, about 14.3 of 32 cores; the machine as a whole was 44% 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/viper v1.19.0
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/BobuSumisu/aho-corasick v1.0.3
go: downloading golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
go: downloading github.com/spf13/cobra v1.9.1
go: downloading github.com/fatih/semgroup v1.2.0
go: downloading github.com/gitleaks/go-gitdiff v0.9.1
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading github.com/h2non/filetype v1.1.3
go: downloading github.com/charmbracelet/lipgloss v0.5.0
go: downloading github.com/mholt/archives v0.1.2
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/muesli/termenv v0.15.1
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68
go: downloading github.com/sorairolake/lzip-go v0.3.5
go: downloading github.com/klauspost/compress v1.17.11
go: downloading github.com/bodgit/sevenzip v1.6.0
go: downloading github.com/therootcompany/xz v1.0.1
go: downloading github.com/pierrec/lz4/v4 v4.1.21
go: downloading github.com/nwaples/rardecode/v2 v2.1.0
go: downloading github.com/klauspost/pgzip v1.2.6
go: downloading github.com/STARRY-S/zip v0.2.1
go: downloading github.com/ulikunitz/xz v0.5.12
go: downloading github.com/minio/minlz v1.0.0
go: downloading github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
go: downloading golang.org/x/text v0.22.0
go: downloading github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading github.com/spf13/cast v1.7.1
go: downloading github.com/spf13/pflag v1.0.6
go: downloading github.com/mattn/go-colorable v0.1.14
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/magiconair/properties v1.8.9
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading golang.org/x/sys v0.30.0
go: downloading github.com/bodgit/plumbing v1.3.0
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/bodgit/windows v1.0.1
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/errwrap v1.1.0
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading dario.cat/mergo v1.0.1
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/Masterminds/semver/v3 v3.3.0
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/mitchellh/reflectwalk v1.0.2
go: downloading golang.org/x/sync v0.11.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 100 near misses of the names notscanned.go lists
self-test: skipped  the 33 files notscanned.go lists
self-test: refused  a notscanned.go entry git does not track
self-test: refused  a config that does not parse
self-test: refused  a config that does not exist
self-test: refused  a missing gitleaks binary
self-test: 6 planted keys reported, 134 tracked files judged, 3 broken setups refused
gitleaks: scanned 12120 tracked files; 33 not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)
gitleaks: clean
diff --git a/.amadan/code-health.tsv b/.amadan/code-health.tsv
index 41304e256..6fe3b2863 100644
--- a/.amadan/code-health.tsv
+++ b/.amadan/code-health.tsv
@@ -146,7 +146,7 @@ fatal . runAccountsCreate log.Fatalf 2
fatal . runAccountsList log.Fatal 1
fatal . runAccountsListRegistry log.Fatal 3
fatal . runAccountsMigrate log.Fatal 8
-fatal . runAccountsMigrate log.Fatalf 6
+fatal . runAccountsMigrate log.Fatalf 4
fatal . runAccountsPlan log.Fatalf 1
fatal . runAccountsSubdomain log.Fatalf 1
fatal . runAdd log.Fatal 4
@@ -492,7 +492,6 @@ fatal . runVersionTarget log.Fatal 7
fatal . scanTarget log.Fatalf 1
fatal . scheduleCommand log.Fatal 1
fatal . secretsCommand os.Exit 1
-fatal . secretsEnvelopeV2Env log.Fatalf 1
fatal . secretsPubKey log.Fatal 1
fatal . secretsPubKeyAPI log.Fatal 3
fatal . servicesCommand os.Exit 1
diff --git a/accounts.go b/accounts.go
index 1cd44306d..d7abaa661 100644
--- a/accounts.go
+++ b/accounts.go
@@ -391,7 +391,16 @@ func runAccountsMigrate(args []string) {
}
// No data-kind record is created (accounts_hostsused.go): a plan that
// would create one refuses before anything is written.
- if err := refuseDataRecords(ctx, store, plan); err != nil {
+ // Nor does a bound secret travel: it opens only as the account it was
+ // sealed to, and the copy is byte for byte. The config bundles are read
+ // once, here, into snap; the copy writes those validated bytes and
+ // never reads the source config again (accounts_sealed.go).
+ var snap configSnapshot
+ err = refuseDataRecords(ctx, store, plan)
+ if err == nil {
+ snap, err = snapshotConfig(ctx, store, *app, srcAcct, *to, plan)
+ }
+ if err != nil {
log.Fatal(err)
}
if len(plan) == 0 {
@@ -402,71 +411,14 @@ func runAccountsMigrate(args []string) {
// qualified pointer already exists; verification must not compare these
// against the legacy copy they deliberately did not take.
var keptPointers []string
- for _, c := range plan {
- if *dryRun {
+ if *dryRun {
+ for _, c := range plan {
warnf(os.Stdout, "would copy %s -> %s\n", c.from, c.to)
- continue
- }
- body, _, err := store.Get(ctx, c.from)
- if err != nil {
- log.Fatalf("accounts migrate: read %s: %v", c.from, err)
}
- if c.pointer {
- body = rebind(c.to, body)
- }
- // Channel pointers CONVERGE; everything else is immutable and is
- // claimed create-only. The split matters: a release manifest or
- // artifact at an existing path must never change meaning, so
- // different bytes there is a hard refusal. A channel pointer is the
- // one mutable object in the bucket — it moves on every promote — so a
- // destination pointer that disagrees is this migration's own
- // leftover, and the verb's whole job is to make the destination serve
- // what the source serves. Refusing there would strand the operator:
- // the pointer exists, so a re-run would hit exactly this branch
- // again, with no way forward that did not involve hand-deleting
- // objects mid-migration.
- if c.pointer {
- // EXCEPT when the source is the legacy key space. There, the
- // converge rationale inverts: an ordinary migration's destination
- // pointer can only be this migration's own leftover, but a
- // QUALIFIED pointer that already exists alongside legacy keys is
- // live state — promotes have been landing on it — and the legacy
- // copy is the stale one. Converging would move production
- // BACKWARDS, which is precisely what happened to the console on
- // 2026-08-03 (qualified canary/console at 3c7c7bc overwritten by a
- // day-old legacy 771c2f0; caught by the next adopt pass's
- // "updated" line reading like a rollback). Keep the qualified
- // pointer, say so, and count it — the operator is told the legacy
- // pointer was NOT taken rather than left to find out from adopt.
- if srcAcct == release.LegacySource {
- if cur, _, err := store.Get(ctx, c.to); err == nil && string(cur) != string(body) {
- fmt.Printf("%s %s — a qualified pointer already exists and differs from the legacy\n"+
- "copy; the qualified one is live state and wins. The legacy pointer was not taken.\n",
- colorFor(os.Stdout).warn("KEPT"), c.to)
- keptPointers = append(keptPointers, c.to)
- continue
- }
- }
- switch changed, err := putOverwrite(ctx, store, c.to, body); {
- case err != nil:
- log.Fatalf("accounts migrate: write %s: %v", c.to, err)
- case changed:
- fmt.Printf("%s %s -> %s (the destination pointer disagreed)\n",
- colorFor(os.Stdout).ok("converged"), c.from, c.to)
- default:
- mutedf(os.Stdout, "already copied %s -> %s\n", c.from, c.to)
- }
- continue
- }
- copied, err := copyMigrationRecord(ctx, store, c.to, body)
- if err != nil {
- log.Fatal(err)
- }
- if !copied {
- mutedf(os.Stdout, "already copied %s -> %s\n", c.from, c.to)
- continue
- }
- fmt.Printf("%s %s -> %s\n", colorFor(os.Stdout).ok("copied"), c.from, c.to)
+ } else if keptPointers, err = copyMigrationPlan(ctx, store, plan, snap, srcAcct, rebind); err != nil {
+ log.Fatal(err)
+ } else {
+ reportConfigChanged(ctx, os.Stdout, store, snap, *to)
}
// The one object that does not travel. Loud, because nothing downstream
// will notice: a destination with no flag simply defaults to "not
@@ -923,3 +875,74 @@ func resolveAccount(regPath, want, wantID string) string {
}
return sqid
}
+
+// copyMigrationPlan copies the plan's objects to the destination. A config
+// bundle is written from snap, the bytes refuseSealedSecrets' preflight
+// validated, and never read from the source again (snapshotConfig); every
+// other object is read as it is copied. kept lists the legacy-source
+// pointers it deliberately did not take.
+func copyMigrationPlan(ctx context.Context, store release.Store, plan []copyOp, snap configSnapshot, srcAcct string, rebind func(string, []byte) []byte) (kept []string, err error) {
+ for _, c := range plan {
+ body, err := snap.source(ctx, store, c.from)
+ if err != nil {
+ return kept, err
+ }
+ if c.pointer {
+ body = rebind(c.to, body)
+ }
+ // Channel pointers CONVERGE; everything else is immutable and is
+ // claimed create-only. The split matters: a release manifest or
+ // artifact at an existing path must never change meaning, so
+ // different bytes there is a hard refusal. A channel pointer is the
+ // one mutable object in the bucket — it moves on every promote — so a
+ // destination pointer that disagrees is this migration's own
+ // leftover, and the verb's whole job is to make the destination serve
+ // what the source serves. Refusing there would strand the operator:
+ // the pointer exists, so a re-run would hit exactly this branch
+ // again, with no way forward that did not involve hand-deleting
+ // objects mid-migration.
+ if c.pointer {
+ // EXCEPT when the source is the legacy key space. There, the
+ // converge rationale inverts: an ordinary migration's destination
+ // pointer can only be this migration's own leftover, but a
+ // QUALIFIED pointer that already exists alongside legacy keys is
+ // live state — promotes have been landing on it — and the legacy
+ // copy is the stale one. Converging would move production
+ // BACKWARDS, which is precisely what happened to the console on
+ // 2026-08-03 (qualified canary/console at 3c7c7bc overwritten by a
+ // day-old legacy 771c2f0; caught by the next adopt pass's
+ // "updated" line reading like a rollback). Keep the qualified
+ // pointer, say so, and count it — the operator is told the legacy
+ // pointer was NOT taken rather than left to find out from adopt.
+ if srcAcct == release.LegacySource {
+ if cur, _, err := store.Get(ctx, c.to); err == nil && string(cur) != string(body) {
+ fmt.Printf("%s %s — a qualified pointer already exists and differs from the legacy\n"+
+ "copy; the qualified one is live state and wins. The legacy pointer was not taken.\n",
+ colorFor(os.Stdout).warn("KEPT"), c.to)
+ kept = append(kept, c.to)
+ continue
+ }
+ }
+ switch changed, err := putOverwrite(ctx, store, c.to, body); {
+ case err != nil:
+ return kept, fmt.Errorf("accounts migrate: write %s: %v", c.to, err)
+ case changed:
+ fmt.Printf("%s %s -> %s (the destination pointer disagreed)\n",
+ colorFor(os.Stdout).ok("converged"), c.from, c.to)
+ default:
+ mutedf(os.Stdout, "already copied %s -> %s\n", c.from, c.to)
+ }
+ continue
+ }
+ copied, err := copyMigrationRecord(ctx, store, c.to, body)
+ if err != nil {
+ return kept, err
+ }
+ if !copied {
+ mutedf(os.Stdout, "already copied %s -> %s\n", c.from, c.to)
+ continue
+ }
+ fmt.Printf("%s %s -> %s\n", colorFor(os.Stdout).ok("copied"), c.from, c.to)
+ }
+ return kept, nil
+}
diff --git a/accounts_sealed.go b/accounts_sealed.go
new file mode 100644
index 000000000..a0df362af
--- /dev/null
+++ b/accounts_sealed.go
@@ -0,0 +1,205 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "sort"
+ "strings"
+
+ "github.com/carlosframework/platform/internal/appconfig"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// configSnapshot is the config bundles a migration copies, keyed by source
+// key: the bytes snapshotConfig read and validated, once, before anything
+// was written (hunt H3-M3, rounds 2 and 3).
+type configSnapshot map[string][]byte
+
+// source is the bytes the migration copies for the object at key: the
+// snapshot's for a config bundle, which is never read again, and the
+// store's for anything else.
+func (s configSnapshot) source(ctx context.Context, store release.Store, key string) ([]byte, error) {
+ if body, ok := s[key]; ok {
+ return body, nil
+ }
+ body, _, err := store.Get(ctx, key)
+ if err != nil {
+ return nil, fmt.Errorf("accounts migrate: read %s: %w", key, err)
+ }
+ return body, nil
+}
+
+// snapshotConfig reads every config bundle the plan copies (the default
+// bundle, every environment, every instance layer) once, and refuses the
+// plan if any of them holds a bound secret.
+//
+// A v2 envelope is sealed to the (account, app) whose config holds it, and
+// authenticates that pair (appconfig.Open). The migration copies config
+// byte for byte and then stamps the destination account on the app's
+// routes, so every box would render the copy as to/app and every bound
+// secret in it would fail to open: the app's whole config stalls.
+// Re-sealing needs the deployment's private key, which this verb does not
+// hold and must not, so it refuses instead, naming each such secret and
+// how to remove it, before anything is written.
+//
+// The returned snapshot is what the copy writes (copyMigrationPlan), so the
+// bytes validated are the bytes copied: a bound secret written to the
+// source after this read is not in the copy (reportConfigChanged says so).
+// A v1 envelope opens under any account and travels as before. A bundle
+// that does not parse holds nothing this can refuse and is copied as read.
+func snapshotConfig(ctx context.Context, store release.Store, app, from, to string, plan []copyOp) (configSnapshot, error) {
+ snap := configSnapshot{}
+ var refused []string
+ for _, c := range plan {
+ b, ok := configBundleAt(to, app, c.to)
+ if c.pointer || !ok {
+ continue
+ }
+ body, _, err := store.Get(ctx, c.from)
+ if err != nil {
+ return nil, fmt.Errorf("accounts migrate: read %s: %w", c.from, err)
+ }
+ snap[c.from] = body
+ if names := boundSecrets(body); len(names) > 0 {
+ refused = append(refused, " "+b.recovery(app, from, to, c.from, names))
+ }
+ }
+ if len(refused) == 0 {
+ return snap, nil
+ }
+ sort.Strings(refused)
+ return nil, fmt.Errorf("accounts migrate: %s holds secrets that open only for the account and app they\n"+
+ "were sealed to, so copies under %s would not open there. Nothing was copied.\n"+
+ "Remove them, run the migration, then set them again under %s:\n%s",
+ app, to, to, strings.Join(refused, "\n"))
+}
+
+// boundSecrets is the sorted names of body's secrets that are v2 (bound)
+// envelopes, read off the prefix with no key.
+func boundSecrets(body []byte) []string {
+ var m appconfig.Manifest
+ if json.Unmarshal(body, &m) != nil {
+ return nil
+ }
+ var names []string
+ for _, name := range m.SortedKeys() {
+ if v := m.Vars[name]; v.Kind == "secret" && appconfig.EnvelopeBound(v.Envelope) {
+ names = append(names, name)
+ }
+ }
+ return names
+}
+
+// configBundle is one of an app's config bundles: the default (env and
+// instance both empty), a named environment, or one instance's layer.
+type configBundle struct{ env, instance string }
+
+// configBundleAt reports whether key, a destination key of the plan, is one
+// of app's config bundles under to, and which.
+func configBundleAt(to, app, key string) (configBundle, bool) {
+ envs, insts := appconfig.EnvironmentsPrefix(to, app), appconfig.InstancesConfigPrefix(to, app)
+ switch {
+ case key == appconfig.Key(to, app):
+ return configBundle{}, true
+ case strings.HasPrefix(key, envs):
+ return configBundle{env: strings.TrimSuffix(strings.TrimPrefix(key, envs), ".json")}, true
+ case strings.HasPrefix(key, insts):
+ return configBundle{instance: strings.TrimSuffix(strings.TrimPrefix(key, insts), ".json")}, true
+ }
+ return configBundle{}, false
+}
+
+// recovery is the refusal's line for one bundle: where the secrets sit and
+// how to remove them from the object that holds them, key. It is derived
+// from key, not from the plan's account: a plan can take objects from the
+// legacy, account-less keys (apps/<app>/…), alone (--from legacy) or beside
+// the qualified ones (the default plan), and `carlos secrets unset` always
+// edits the qualified apps/<account>/<app>/ bundle, so for a legacy key it
+// would miss the blocker and could remove a same-named secret elsewhere.
+// It selects the default bundle or a named environment; nothing in the CLI
+// or the console removes or sets a var in one instance's layer
+// (appconfig.ApplyInstance has no door). For a legacy key or an instance
+// layer the line says so and names the object.
+func (b configBundle) recovery(app, from, to, key string, names []string) string {
+ list := strings.Join(names, " ")
+ qualified := from != release.LegacySource && strings.HasPrefix(key, release.AppPrefix(from, app))
+ switch {
+ case b.instance != "":
+ return fmt.Sprintf("instance %s (%s): no carlos command sets or removes an instance's own secrets, so an operator must remove them by hand from %s and restore them under %s after the migration",
+ b.instance, list, key, to)
+ case !qualified:
+ return fmt.Sprintf("%s (%s): %s is a legacy key, which carlos secrets unset cannot edit, so an operator must remove them by hand from it",
+ b.label(), list, key)
+ case b.env != "":
+ return fmt.Sprintf("environment %s (%s): carlos secrets unset --account %s --app %s --environment %s %s",
+ b.env, list, from, app, b.env, list)
+ }
+ return fmt.Sprintf("default config (%s): carlos secrets unset --account %s --app %s %s", list, from, app, list)
+}
+
+// label names a bundle in the refusal.
+func (b configBundle) label() string {
+ switch {
+ case b.instance != "":
+ return "instance " + b.instance
+ case b.env != "":
+ return "environment " + b.env
+ }
+ return "default config"
+}
+
+// configChangedSince compares each snapshotted source key with what it
+// holds now. changed is the keys whose bytes differ or that are gone;
+// unchecked is the keys whose current state could not be read, so whether
+// they changed is unknown. It sees only the snapshotted keys, at the moment
+// each is read here: a bundle created at the source during the migration,
+// or a write after this read, is not in either list.
+func configChangedSince(ctx context.Context, store release.Store, snap configSnapshot) (changed, unchecked []string) {
+ for key, body := range snap {
+ cur, _, err := store.Get(ctx, key)
+ switch {
+ case errors.Is(err, os.ErrNotExist):
+ changed = append(changed, key)
+ case err != nil:
+ unchecked = append(unchecked, key)
+ case !bytes.Equal(cur, body):
+ changed = append(changed, key)
+ }
+ }
+ sort.Strings(changed)
+ sort.Strings(unchecked)
+ return changed, unchecked
+}
+
+// reportConfigChanged names every config bundle written at the source while
+// the migration ran. The copy holds the bytes checked before it began, so
+// that change is not at the destination. It is reported, not undone: the
+// copy is already written, and a re-run would meet a destination object
+// that differs from its source.
+//
+// A bundle whose current state could not be read is reported apart: it may
+// not have changed at all, so it is not told to be redone.
+func reportConfigChanged(ctx context.Context, w io.Writer, store release.Store, snap configSnapshot, to string) {
+ changed, unchecked := configChangedSince(ctx, store, snap)
+ if len(changed) > 0 {
+ fmt.Fprintf(w, "\n%s\n", colorFor(w).warn("CHANGED DURING THE MIGRATION:"))
+ for _, k := range changed {
+ fmt.Fprintf(w, " %s\n", k)
+ }
+ fmt.Fprintf(w, "The copy under %s holds this config as it was before the migration began.\n"+
+ "Make those changes again under %s.\n", to, to)
+ }
+ if len(unchecked) > 0 {
+ fmt.Fprintf(w, "\n%s\n", colorFor(w).warn("COULD NOT CHECK:"))
+ for _, k := range unchecked {
+ fmt.Fprintf(w, " %s\n", k)
+ }
+ fmt.Fprintf(w, "These could not be read after the copy, so whether they changed during the\n"+
+ "migration is unknown. Compare each with its copy under %s by hand.\n", to)
+ }
+}
diff --git a/accounts_sealed_test.go b/accounts_sealed_test.go
new file mode 100644
index 000000000..1cde0687f
--- /dev/null
+++ b/accounts_sealed_test.go
@@ -0,0 +1,485 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "io/fs"
+ "maps"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/appconfig"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// sealerFor seals test secrets as v2 envelopes bound to acct/app.
+func sealerFor(t *testing.T, acct, app string) func(plain string) appconfig.Var {
+ t.Helper()
+ _, pubB64, err := appconfig.GenerateKey()
+ if err != nil {
+ t.Fatal(err)
+ }
+ pub, err := appconfig.ParsePublicKey(pubB64, "test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return func(plain string) appconfig.Var {
+ t.Helper()
+ env, err := appconfig.SealBound(pub, appconfig.Binding{Account: acct, App: app}, []byte(plain))
+ if err != nil {
+ t.Fatal(err)
+ }
+ return appconfig.Var{Kind: "secret", Envelope: env}
+ }
+}
+
+// sealedWorld is a store holding app demo under ops: a default bundle with
+// a plain var and a v2 secret sealed to ops/demo, an environment and an
+// instance layer each holding a v2 secret of their own.
+func sealedWorld(t *testing.T, store release.Store) {
+ t.Helper()
+ ctx := context.Background()
+ seal := sealerFor(t, release.OpsAccount, "demo")
+ if err := appconfig.SetEnv(ctx, store, release.OpsAccount, "demo", map[string]string{"PLAIN": "1"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := appconfig.SetSecret(ctx, store, release.OpsAccount, "demo", map[string]appconfig.Var{"STRIPE_KEY": seal("sk-live")}); err != nil {
+ t.Fatal(err)
+ }
+ if err := appconfig.SaveEnvironment(ctx, store, release.OpsAccount, "demo", "staging",
+ map[string]appconfig.Var{"SMTP_PASS": seal("smtp")}, nil); err != nil {
+ t.Fatal(err)
+ }
+ if _, _, err := appconfig.ApplyInstance(ctx, store, release.OpsAccount, "demo", "a.demo.example.com",
+ map[string]appconfig.Var{"NODE_TOKEN": seal("node")}, nil); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func migratePlanTo(t *testing.T, store release.Store, app, to string) ([]copyOp, string) {
+ t.Helper()
+ plan, src, _ := migrationPlan(context.Background(), store, app, release.OpsAccount, to, release.AppPrefix(to, app))
+ return plan, src
+}
+
+// TestMigrateRefusesBoundSecretsBeforeAnyWrite (H3-M3 rounds 2 and 3): a
+// v2 secret is sealed to its account and app, so a byte copy under another
+// account opens nowhere. The preflight names every such secret, by bundle,
+// with the command that removes it from that bundle (none exists for an
+// instance's layer, and the refusal says so), before anything is written.
+func TestMigrateRefusesBoundSecretsBeforeAnyWrite(t *testing.T) {
+ ctx := context.Background()
+ inner := release.NewDirStore(t.TempDir())
+ sealedWorld(t, inner)
+ if _, err := inner.Put(ctx, "apps/"+release.OpsAccount+"/demo/channels/stable.json", []byte(`{"v":1}`), ""); err != nil {
+ t.Fatal(err)
+ }
+ store := &orderStore{Store: inner}
+ plan, src := migratePlanTo(t, store, "demo", "cac")
+ snap, err := snapshotConfig(ctx, store, "demo", src, "cac", plan)
+ if err == nil || snap != nil {
+ t.Fatal("a plan carrying bound secrets passed the preflight")
+ }
+ for _, want := range []string{
+ "demo holds secrets that open only for the account and app they",
+ "copies under cac would not open there",
+ "Nothing was copied",
+ "default config (STRIPE_KEY): carlos secrets unset --account bab --app demo STRIPE_KEY",
+ "environment staging (SMTP_PASS): carlos secrets unset --account bab --app demo --environment staging SMTP_PASS",
+ "instance a.demo.example.com (NODE_TOKEN): no carlos command sets or removes an instance's own secrets, so an operator must remove them by hand from apps/bab/demo/instances-config/a.demo.example.com.json and restore them under cac after the migration",
+ } {
+ if !strings.Contains(err.Error(), want) {
+ t.Errorf("refusal %q does not say %q", err, want)
+ }
+ }
+ if len(store.puts) != 0 {
+ t.Fatalf("puts = %v, want none", store.puts)
+ }
+
+ // Without bound secrets the plan passes: plain vars, and a v1 envelope
+ // (which opens under any account) travel as before.
+ if _, err := appconfig.Unset(ctx, inner, release.OpsAccount, "demo", []string{"STRIPE_KEY"}); err != nil {
+ t.Fatal(err)
+ }
+ for _, k := range []string{appconfig.EnvironmentKey(release.OpsAccount, "demo", "staging"), appconfig.InstanceConfigKey(release.OpsAccount, "demo", "a.demo.example.com")} {
+ if err := inner.Delete(ctx, k); err != nil {
+ t.Fatal(err)
+ }
+ }
+ plan, src = migratePlanTo(t, store, "demo", "cac")
+ if _, err := snapshotConfig(ctx, store, "demo", src, "cac", plan); err != nil {
+ t.Fatalf("a plan without bound secrets = %v, want it to pass", err)
+ }
+}
+
+// TestMigrateRefusesAnInstanceOnlyBoundSecret: an app whose only config is
+// one instance's layer, holding a v2 secret, is refused too.
+func TestMigrateRefusesAnInstanceOnlyBoundSecret(t *testing.T) {
+ ctx := context.Background()
+ store := release.NewDirStore(t.TempDir())
+ seal := sealerFor(t, release.OpsAccount, "solo")
+ if _, _, err := appconfig.ApplyInstance(ctx, store, release.OpsAccount, "solo", "b.solo.example.com",
+ map[string]appconfig.Var{"ONLY_HERE": seal("x")}, nil); err != nil {
+ t.Fatal(err)
+ }
+ if _, _, err := store.Get(ctx, appconfig.Key(release.OpsAccount, "solo")); err == nil {
+ t.Fatal("fixture: the app has a default bundle")
+ }
+ plan, src := migratePlanTo(t, store, "solo", "cac")
+ _, err := snapshotConfig(ctx, store, "solo", src, "cac", plan)
+ if err == nil || !strings.Contains(err.Error(), "instance b.solo.example.com (ONLY_HERE): no carlos command sets or removes") {
+ t.Fatalf("instance-only bound secret = %v, want a refusal naming it", err)
+ }
+}
+
+// putManifest writes a config bundle's bytes at key as they are, the way
+// a legacy, account-less bundle sits in the bucket.
+func putManifest(t *testing.T, store release.Store, key string, vars map[string]appconfig.Var) {
+ t.Helper()
+ body, err := json.Marshal(appconfig.Manifest{Schema: 1, App: "demo", Vars: vars})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := store.Put(context.Background(), key, body, ""); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// TestMigrateLegacyRecoveryNamesTheObject (H3-M3 round 3 fixes, Astra P2):
+// a bound secret in a legacy, account-less bundle (apps/<app>/…) is named
+// by its object, with the plain statement that carlos secrets unset cannot
+// edit it: that command edits apps/<account>/<app>/ only. Both ways a plan
+// takes legacy objects: --from legacy, and the default plan's legacy-only
+// bundles beside the qualified ones.
+func TestMigrateLegacyRecoveryNamesTheObject(t *testing.T) {
+ ctx := context.Background()
+ seal := sealerFor(t, release.OpsAccount, "demo")
+ legacyLine := func(label, names, key string) string {
+ return label + " (" + names + "): " + key + " is a legacy key, which carlos secrets unset cannot edit, so an operator must remove them by hand from it"
+ }
+
+ t.Run("from legacy", func(t *testing.T) {
+ store := release.NewDirStore(t.TempDir())
+ putManifest(t, store, "apps/demo/config.json", map[string]appconfig.Var{"OLD_KEY": seal("x")})
+ plan, src, _ := migrationPlan(ctx, store, "demo", release.LegacySource, "cac", release.AppPrefix("cac", "demo"))
+ _, err := snapshotConfig(ctx, store, "demo", src, "cac", plan)
+ if err == nil || !strings.Contains(err.Error(), legacyLine("default config", "OLD_KEY", "apps/demo/config.json")) {
+ t.Fatalf("refusal = %v, want the legacy object named", err)
+ }
+ if strings.Contains(err.Error(), "--account") {
+ t.Fatalf("refusal %q offers a qualified unset for a legacy object", err)
+ }
+ })
+
+ t.Run("default plan, legacy-only bundle", func(t *testing.T) {
+ store := release.NewDirStore(t.TempDir())
+ if err := appconfig.SetSecret(ctx, store, release.OpsAccount, "demo", map[string]appconfig.Var{"STRIPE_KEY": seal("y")}); err != nil {
+ t.Fatal(err)
+ }
+ putManifest(t, store, "apps/demo/environments/staging.json", map[string]appconfig.Var{"SMTP_PASS": seal("z")})
+ plan, src, _ := migrationPlan(ctx, store, "demo", "", "cac", release.AppPrefix("cac", "demo"))
+ _, err := snapshotConfig(ctx, store, "demo", src, "cac", plan)
+ if err == nil {
+ t.Fatal("a mixed plan carrying bound secrets passed the preflight")
+ }
+ for _, want := range []string{
+ "default config (STRIPE_KEY): carlos secrets unset --account bab --app demo STRIPE_KEY",
+ legacyLine("environment staging", "SMTP_PASS", "apps/demo/environments/staging.json"),
+ } {
+ if !strings.Contains(err.Error(), want) {
+ t.Errorf("refusal %q does not say %q", err, want)
+ }
+ }
+ if strings.Contains(err.Error(), "--environment staging") {
+ t.Errorf("refusal %q offers a qualified unset for the legacy environment", err)
+ }
+ })
+}
+
+// failingStore fails every read of one key after the first, and serves the
+// rest as they are.
+type failingStore struct {
+ release.Store
+ key string
+ reads int
+}
+
+func (s *failingStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ if key == s.key {
+ s.reads++
+ if s.reads > 1 {
+ return nil, "", errors.New("store: connection reset")
+ }
+ }
+ return s.Store.Get(ctx, key)
+}
+
+// TestMigrateReportSeparatesUncheckedFromChanged (H3-M3 round 3 fixes,
+// Astra P2): after the copy, a bundle that is gone is reported as changed,
+// one whose read fails is reported as not checked, with advice to compare
+// it by hand and not to redo changes that may never have happened, and an
+// unchanged one is not reported at all.
+func TestMigrateReportSeparatesUncheckedFromChanged(t *testing.T) {
+ ctx := context.Background()
+ inner := release.NewDirStore(t.TempDir())
+ if err := appconfig.SetEnv(ctx, inner, release.OpsAccount, "demo", map[string]string{"PLAIN": "1"}); err != nil {
+ t.Fatal(err)
+ }
+ for _, env := range []string{"gone", "same"} {
+ if err := appconfig.SaveEnvironment(ctx, inner, release.OpsAccount, "demo", env, map[string]appconfig.Var{"PLAIN": {Kind: "env", Value: "1"}}, nil); err != nil {
+ t.Fatal(err)
+ }
+ }
+ unreadable := appconfig.Key(release.OpsAccount, "demo")
+ gone := appconfig.EnvironmentKey(release.OpsAccount, "demo", "gone")
+ store := &failingStore{Store: inner, key: unreadable}
+ plan, src := migratePlanTo(t, store, "demo", "cac")
+ snap, err := snapshotConfig(ctx, store, "demo", src, "cac", plan)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := inner.Delete(ctx, gone); err != nil {
+ t.Fatal(err)
+ }
+ changed, unchecked := configChangedSince(ctx, store, snap)
+ if len(changed) != 1 || changed[0] != gone || len(unchecked) != 1 || changed[0] == unreadable || unchecked[0] != unreadable {
+ t.Fatalf("changed %v, unchecked %v; want [%s] and [%s]", changed, unchecked, gone, unreadable)
+ }
+ var out bytes.Buffer
+ reportConfigChanged(ctx, &out, store, snap, "cac")
+ report := out.String()
+ changedPart, uncheckedPart, ok := strings.Cut(report, "COULD NOT CHECK:")
+ if !ok || !strings.Contains(changedPart, "CHANGED DURING THE MIGRATION:\n "+gone+"\n") || strings.Contains(changedPart, unreadable) {
+ t.Fatalf("report = %q", report)
+ }
+ if !strings.Contains(uncheckedPart, " "+unreadable+"\n") ||
+ !strings.Contains(uncheckedPart, "whether they changed during the\nmigration is unknown. Compare each with its copy under cac by hand.") {
+ t.Fatalf("report = %q", report)
+ }
+ if strings.Contains(report, "same.json") {
+ t.Fatalf("an unchanged bundle was reported: %q", report)
+ }
+}
+
+// turningStore turns one object into other bytes right after its first
+// read: a console or CLI write landing between the migration's preflight
+// and its copy. It counts every read of that key.
+type turningStore struct {
+ release.Store
+ key string
+ after []byte
+ reads int
+}
+
+func (s *turningStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ body, etag, err := s.Store.Get(ctx, key)
+ if key == s.key {
+ s.reads++
+ if s.reads == 1 {
+ if _, perr := s.Store.Put(ctx, key, s.after, etag); perr != nil {
+ return nil, "", perr
+ }
+ }
+ }
+ return body, etag, err
+}
+
+// TestMigrateCopiesTheValidatedConfigBytes (H3-M3 round 3, Astra P1): a
+// bundle that is plain when the preflight reads it and gains a v2 secret
+// before the copy reaches it is copied as validated, never as the newer
+// bytes, and the source is read once. The verb reports the bundle as
+// changed during the migration. Default, environment and instance-only.
+func TestMigrateCopiesTheValidatedConfigBytes(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ key string
+ write func(ctx context.Context, s release.Store) error
+ }{
+ {"default", appconfig.Key(release.OpsAccount, "demo"), func(ctx context.Context, s release.Store) error {
+ return appconfig.SetEnv(ctx, s, release.OpsAccount, "demo", map[string]string{"PLAIN": "1"})
+ }},
+ {"environment", appconfig.EnvironmentKey(release.OpsAccount, "demo", "staging"), func(ctx context.Context, s release.Store) error {
+ return appconfig.SaveEnvironment(ctx, s, release.OpsAccount, "demo", "staging", map[string]appconfig.Var{"PLAIN": {Kind: "env", Value: "1"}}, nil)
+ }},
+ {"instance-only", appconfig.InstanceConfigKey(release.OpsAccount, "demo", "a.demo.example.com"), func(ctx context.Context, s release.Store) error {
+ _, _, err := appconfig.ApplyInstance(ctx, s, release.OpsAccount, "demo", "a.demo.example.com", map[string]appconfig.Var{"PLAIN": {Kind: "env", Value: "1"}}, nil)
+ return err
+ }},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ ctx := context.Background()
+ inner := release.NewDirStore(t.TempDir())
+ if err := tc.write(ctx, inner); err != nil {
+ t.Fatal(err)
+ }
+ validated, _, err := inner.Get(ctx, tc.key)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // The newer bytes: the same bundle with a v2 secret added.
+ var m appconfig.Manifest
+ if err := json.Unmarshal(validated, &m); err != nil {
+ t.Fatal(err)
+ }
+ m.Vars["LATE_SECRET"] = sealerFor(t, release.OpsAccount, "demo")("late")
+ newer, err := json.Marshal(m)
+ if err != nil {
+ t.Fatal(err)
+ }
+ store := &turningStore{Store: inner, key: tc.key, after: newer}
+ plan, src := migratePlanTo(t, store, "demo", "cac")
+ snap, err := snapshotConfig(ctx, store, "demo", src, "cac", plan)
+ if err != nil {
+ t.Fatalf("preflight of a plain bundle = %v", err)
+ }
+ if _, err := copyMigrationPlan(ctx, store, plan, snap, src, pointerRebinder("demo", src, "cac")); err != nil {
+ t.Fatal(err)
+ }
+ dst := "apps/cac/demo/" + strings.TrimPrefix(tc.key, release.AppPrefix(release.OpsAccount, "demo"))
+ got, _, err := inner.Get(ctx, dst)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(got, validated) {
+ t.Fatalf("the copy at %s is not the validated bytes:\n got %s\nwant %s", dst, got, validated)
+ }
+ if store.reads != 1 {
+ t.Fatalf("the source bundle was read %d times by preflight and copy, want once", store.reads)
+ }
+ if changed, unchecked := configChangedSince(ctx, store, snap); len(changed) != 1 || changed[0] != tc.key || len(unchecked) != 0 {
+ t.Fatalf("changed during the migration = %v (unchecked %v), want [%s]", changed, unchecked, tc.key)
+ }
+ var out bytes.Buffer
+ reportConfigChanged(ctx, &out, store, snap, "cac")
+ if !strings.Contains(out.String(), tc.key) || !strings.Contains(out.String(), "Make those changes again under cac.") {
+ t.Fatalf("report = %q", out.String())
+ }
+ // A migration started now would see the bound secret and refuse.
+ plan, src = migratePlanTo(t, inner, "demo", "cac")
+ if _, err := snapshotConfig(ctx, inner, "demo", src, "cac", plan); err == nil || !strings.Contains(err.Error(), "LATE_SECRET") {
+ t.Fatalf("a fresh preflight over the newer bytes = %v, want a refusal", err)
+ }
+ })
+ }
+}
+
+// TestMigrateCommandWithBoundSecretsChangesNothing (H3-M3 round 2, Astra
+// P1): the built carlos, asked to move an app whose config holds a v2 secret,
+// refuses (dry run and real run alike) and leaves every object in the
+// bucket, source and destination, byte for byte as it was, and the route's
+// account column unstamped.
+func TestMigrateCommandWithBoundSecretsChangesNothing(t *testing.T) {
+ tmp := t.TempDir()
+ carlosBin := sharedCarlos(t)
+ storeDir := filepath.Join(tmp, "store")
+ regPath := filepath.Join(tmp, "registry.db")
+ store := release.NewDirStore(storeDir)
+ ctx := context.Background()
+ seed, pubB64, err := release.GenerateKey()
+ if err != nil {
+ t.Fatal(err)
+ }
+ priv, err := release.ParseSigningKey(seed, "e2e")
+ if err != nil {
+ t.Fatal(err)
+ }
+ m := release.Manifest{Schema: 1, App: "demo", Version: "v1", Kind: "binary",
+ Artifacts: map[string]release.Artifact{"linux-amd64": {File: "demo"}}}
+ if err := release.Ship(ctx, store, release.OpsAccount, m, map[string][]byte{"linux-amd64": []byte("v1 bytes")}); err != nil {
+ t.Fatal(err)
+ }
+ if err := release.Promote(ctx, store, priv, release.OpsAccount, "demo", "stable", "v1"); err != nil {
+ t.Fatal(err)
+ }
+ sealedWorld(t, store)
+ reg, err := registry.Open(regPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.Upsert(registry.Route{Host: "demo.example.com", Kind: "instance",
+ App: "demo", Status: "ready", Addr: "127.0.0.1:9000"}); err != nil {
+ t.Fatal(err)
+ }
+ reg.Close()
+
+ env := carlosTestEnv(t, "CARLOS_DEPLOYMENT_DIR="+storeDir, "CARLOS_RELEASE_PUBKEY="+pubB64,
+ "CARLOS_RELEASE_KEY="+seed, "HOME="+tmp, "CARLOS_CONSOLE=", "CARLOS_DESTINATION=")
+ run := func(args ...string) (string, error) {
+ t.Helper()
+ cmd := exec.Command(carlosBin, args...)
+ cmd.Env = env
+ cmd.Dir = tmp
+ out, err := cmd.CombinedOutput()
+ return string(out), err
+ }
+ out, err := run("accounts", "create", "-registry", regPath, "-name", "kass", "-owner", "paul@keymail.dev")
+ if err != nil {
+ t.Fatalf("accounts create: %v\n%s", err, out)
+ }
+ sqid := regexp.MustCompile(`(?m)^\s*sqid:\s*(\S+)`).FindStringSubmatch(out)[1]
+
+ before := bucketBytes(t, storeDir)
+ for _, dry := range []bool{true, false} {
+ args := []string{"accounts", "migrate", "-registry", regPath, "-app", "demo", "-to", sqid}
+ if dry {
+ args = append(args, "-dry-run")
+ }
+ out, err = run(args...)
+ if err == nil || !strings.Contains(out, "demo holds secrets that open only for the account and app they") ||
+ !strings.Contains(out, "Nothing was copied") {
+ t.Fatalf("migrate (dry run %v) of an app with bound secrets: %v\n%s", dry, err, out)
+ }
+ if after := bucketBytes(t, storeDir); !maps.EqualFunc(before, after, bytes.Equal) {
+ t.Fatalf("migrate (dry run %v) changed the bucket:\nbefore %v\nafter %v", dry, slicesOfKeys(before), slicesOfKeys(after))
+ }
+ }
+ reg, err = registry.Open(regPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer reg.Close()
+ rt, err := reg.Get("demo.example.com")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if rt == nil || rt.Account == sqid {
+ t.Fatalf("the route was stamped %s despite the refusal", sqid)
+ }
+}
+
+// bucketBytes is every object under a DirStore root, keyed by its path.
+func bucketBytes(t *testing.T, root string) map[string][]byte {
+ t.Helper()
+ out := map[string][]byte{}
+ err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error {
+ if err != nil || d.IsDir() {
+ return err
+ }
+ b, err := os.ReadFile(p)
+ if err != nil {
+ return err
+ }
+ rel, _ := filepath.Rel(root, p)
+ out[rel] = b
+ return nil
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ return out
+}
+
+func slicesOfKeys(m map[string][]byte) []string {
+ var keys []string
+ for k := range m {
+ keys = append(keys, k)
+ }
+ return keys
+}
diff --git a/appconfig_cli.go b/appconfig_cli.go
index 36960c9c4..9d8bdafc0 100644
--- a/appconfig_cli.go
+++ b/appconfig_cli.go
@@ -15,7 +15,6 @@ import (
"os"
"slices"
"sort"
- "strconv"
"strings"
"github.com/carlosframework/platform/internal/appconfig"
@@ -1320,25 +1319,11 @@ func secretsKeyFromConfig(cfg apiConfig, app string) (*ecdh.PublicKey, error) {
return appconfig.ParsePublicKey(cfg.SecretsPubkey, "console secrets_pubkey")
}
-// secretsEnvelopeV2Env reads CONSOLE_SECRETS_ENVELOPE_V2 for direct-bucket
-// `secrets set`, with the console's own rule: unset is false, and a value
-// that is not a boolean stops rather than guessing.
-func secretsEnvelopeV2Env() bool {
- v := strings.TrimSpace(os.Getenv("CONSOLE_SECRETS_ENVELOPE_V2"))
- if v == "" {
- return false
- }
- b, err := strconv.ParseBool(v)
- if err != nil {
- log.Fatalf("CONSOLE_SECRETS_ENVELOPE_V2 %q is not a boolean (use true or false)", v)
- }
- return b
-}
-
// sealSecretAPI seals one value for API-mode `secrets set`: bound to
-// (account, app) when the console named the account — which it does only
-// while its deployment writes v2 (CONSOLE_SECRETS_ENVELOPE_V2) — and v1
-// otherwise, which every box and every console door accepts.
+// (account, app) when the console named the account, which a current
+// console does for every app, and v1 otherwise. Only a console from before
+// hunt H3-M3 leaves the account out, and that console takes v1; a current
+// one refuses a new v1 envelope, because one opens in any tenant's config.
func sealSecretAPI(pub *ecdh.PublicKey, account, app string, v []byte) (string, error) {
if account == "" {
return appconfig.SealUnbound(pub, v)
@@ -1446,9 +1431,8 @@ func runSecretsSet(args []string) {
if err := directSealRefusal(context.Background(), store, acct, pub); err != nil {
log.Fatal(strings.ReplaceAll(err.Error(), "<app>", *app))
}
- // Direct-bucket mode has no console to ask, so the deployment's switch
- // comes from the operator's environment under the console's own name.
- sealer := appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: *app}, secretsEnvelopeV2Env())
+ // Bound, as every seal is: the config store refuses a new v1 envelope.
+ sealer := appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: *app}, true)
sealed := make(map[string]appconfig.Var, len(kv))
for k, v := range kv {
sv, err := sealer.Seal(appconfig.Binding{Account: acct, App: *app}, []byte(v))
diff --git a/appconfig_cli_fleet_test.go b/appconfig_cli_fleet_test.go
index 180b399a4..460f340ab 100644
--- a/appconfig_cli_fleet_test.go
+++ b/appconfig_cli_fleet_test.go
@@ -162,7 +162,6 @@ func directSetEnv(t *testing.T, dir, pubB64 string) {
clearDeploymentEnv(t)
t.Setenv("CARLOS_DEPLOYMENT_DIR", dir)
t.Setenv("CARLOS_SECRETS_PUBKEY", pubB64)
- t.Setenv("CONSOLE_SECRETS_ENVELOPE_V2", "1")
}
func TestDirectSecretsSetPlatformAppStillWorks(t *testing.T) {
@@ -192,7 +191,7 @@ func TestDirectSecretsSetPlatformAppStillWorks(t *testing.T) {
t.Fatalf("sealed_to = %q, want the terminal key's %s", v.SealedTo, fp)
}
if !appconfig.EnvelopeBound(v.Envelope) {
- t.Fatal("direct mode with the v2 switch on sealed v1")
+ t.Fatal("direct mode sealed v1")
}
priv, _ := appconfig.ParsePrivateKey(privB64, "test")
if got, err := appconfig.Open(priv, appconfig.Binding{Account: "bab", App: "shop"}, v.Envelope); err != nil || string(got) != "hunter2" {
diff --git a/cmd/console/main.go b/cmd/console/main.go
index 8f301ca44..aea7a949b 100644
--- a/cmd/console/main.go
+++ b/cmd/console/main.go
@@ -548,8 +548,7 @@ func serve() {
seedData = console.TimeS3Store(sd, rec)
}
}
- // Before the server exists: every door that seals reads this switch.
- appconfig.SetBoundSealing(secretsEnvelopeV2())
+ retiredSecretsEnvelopeV2()
// Every background loop the console runs, from the GeoIP reader's on,
// runs on work's context, so a stop cancels them together and waits for
// them (stop.go).
@@ -1799,23 +1798,16 @@ func redirectHosts() []string {
return out
}
-// secretsEnvelopeV2 parses CONSOLE_SECRETS_ENVELOPE_V2: whether secrets this
-// console seals (relay, mail, object storage) and the CLI seals through it
-// are bound v2 envelopes (appconfig.Binding, discussion #220). Off by
-// default, because a box on a binary that predates v2 cannot open one and
-// its whole config render for that app stalls. Turn it on once every box
-// runs a build that reads v2. A value strconv.ParseBool cannot read stops
-// the boot, as for the other boolean settings.
-func secretsEnvelopeV2() bool {
- v := strings.TrimSpace(os.Getenv("CONSOLE_SECRETS_ENVELOPE_V2"))
- if v == "" {
- return false
- }
- b, err := strconv.ParseBool(v)
- if err != nil {
- log.Fatalf("console: CONSOLE_SECRETS_ENVELOPE_V2 %q is not a boolean (use true or false)", v)
+// retiredSecretsEnvelopeV2 notes a CONSOLE_SECRETS_ENVELOPE_V2 left in the
+// environment. It used to choose whether secrets were sealed bound to their
+// account and app (v2) or not (v1), off by default. Every seal is v2 now
+// (hunt H3-M3: a v1 envelope opens in any tenant's config), so the setting
+// does nothing, whatever its value, and a leftover one does not stop the
+// boot.
+func retiredSecretsEnvelopeV2() {
+ if strings.TrimSpace(os.Getenv("CONSOLE_SECRETS_ENVELOPE_V2")) != "" {
+ log.Printf("console: CONSOLE_SECRETS_ENVELOPE_V2 is no longer read: every secret is sealed to its own account and app")
}
- return b
}
// dbForward parses CARLOS_DB_FORWARD: "1" turns on forwarding a carlos db
diff --git a/docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md b/docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md
new file mode 100644
index 000000000..85b73393c
--- /dev/null
+++ b/docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md
@@ -0,0 +1,161 @@
+# Secret envelopes: retiring v1 (hunt H3-M3)
+
+Branch `sec-h3-m3-envelope`, 2026-11-29 (round 2: 2026-11-30).
+
+## The problem
+
+A v1 secret envelope carries no binding, so a box opens it under any
+account's config. Anyone who can read the bucket and write their own app's
+config could copy another tenant's v1 envelope into their app, and the box
+would decrypt it into their environment. v2 (bound to account and app with
+GCM associated data) has existed since v0.23.0, but every deployment still
+wrote v1: the switch (`CONSOLE_SECRETS_ENVELOPE_V2`) was on nowhere.
+
+## What this branch does
+
+1. **Every seal is v2.** `appconfig.Seal` always binds. The console names the
+ account on every app (`secrets_account`), so the CLI and the settings page
+ seal v2 too. CLI direct-bucket mode seals v2. The console switch is
+ retired: a value left in the environment is logged and ignored.
+2. **The config store keeps a v1 envelope only where it already sits.** Every
+ manifest write through a door (`applyAtExpecting`,
+ `applyEnvironmentOwned`) refuses a secret whose envelope `Open` would read
+ as v1, unless it is byte for byte the value already stored under that
+ name in that bundle. A copy into another app, another bundle, another
+ name or an instance layer is refused, and so is a fresh v1 from an old
+ CLI. The console door answers with its existing `sealed-old` refusal.
+
+ **One exception: environment forks.** `ForkEnvironment` writes the new
+ bundle directly, so it copies a v1 secret from the source environment
+ into the new one unchanged. The copy stays in the same account and app,
+ under the same name (`TestForkStaysInItsOwnAccountAndApp`), so it crosses
+ no tenant boundary: the envelope already opened for that app. The sweep
+ below re-seals it with the rest.
+3. **Boxes still open stored v1 envelopes** for the config they sit in. No
+ secret is lost.
+4. **`carlos accounts migrate` refuses an app with v2 secrets.** The migration
+ copies config bundles byte for byte and then stamps the new account on
+ the app's routes. A v2 secret is sealed to the old account, so after the
+ move it would not open and the app's config would stall.
+ - Before writing anything, the verb reads every bundle it will copy
+ (default, environments, instance layers) once, and checks those bytes.
+ If any holds a v2 secret it names them and stops, with source and
+ destination untouched.
+ - The copy then writes exactly the bytes it checked and never reads the
+ source config again, so a v2 secret set while the migration runs cannot
+ slip into the copy.
+ - The refusal says how to remove each secret from the object that holds
+ it: `carlos secrets unset` (with `--environment` for an environment)
+ for a bundle under `apps/<account>/<app>/`. That command cannot edit
+ a legacy, account-less bundle (`apps/<app>/…`, taken with
+ `--from legacy` or beside the qualified keys), and no command sets or
+ removes a var in one instance's layer, so for those it names the
+ object and says an operator must edit it by hand. Then migrate, and
+ set the secrets again under the new account.
+ - **Migrate in a quiet window.** A config change made at the source while
+ the migration runs is not in the copy. After the copy the verb reads
+ each bundle it copied once more: one that changed or is gone is listed
+ with advice to make those changes again under the new account; one it
+ could not read is listed apart, to compare by hand. This sees only the
+ bundles it copied, at the moment it re-reads each: a bundle created
+ during the migration, or a write after that re-read, is not reported.
+ - Re-sealing during the move would need the deployment's private key,
+ which the CLI does not hold, so it is not built.
+
+This closes the finding's attacker: after the console rolls, no door accepts
+a v1 envelope it did not already hold.
+
+## Rollout gate
+
+v2 can only be opened by boxes on v0.23.0 or later. Both writers in this
+branch produce v2 unconditionally: the console, and the CLI in
+direct-bucket mode (which talks to no console and checks nothing).
+
+- **Before the console rolls, and before anyone uses this release's CLI in
+ direct-bucket mode,** every box that renders platform-app config must be
+ on v0.23.0 or later: dev, flagship, Tito, devboxes, every fleet, and any
+ offline or replacement box that may come back.
+- **No rollback below v0.23.0** on any of those boxes after that.
+
+Nothing in code enforces this. Suggested release-kit line:
+
+> H3-M3 reader floor: every box that renders app config (dev, flagship,
+> Tito, devboxes, every fleet, offline and replacement boxes) reports
+> v0.23.0 or later. Checked before rolling the console or handing out the
+> CLI; no box rolled back below it.
+
+## What is left
+
+- v1 envelopes already stored stay v1 until their owners set them again.
+- A v1 envelope copied into another app **before** the console rolls is
+ indistinguishable from that app's own.
+- Someone with direct bucket write can still plant a v1. They are past every
+ door anyway.
+
+Closing these needs boxes to refuse v1, which needs every stored v1 gone
+first.
+
+## Options for the sunset
+
+| Option | Data loss | Closes the residual | Cost |
+|---|---|---|---|
+| A. Refuse v1 on boxes now | Every v1 secret stops rendering, and each app's whole config stalls | Yes | Unacceptable |
+| B. Wait for owners to re-set secrets, then refuse v1 | None, if we wait until the count is zero | Eventually; may never reach zero | A keyless count of v1 envelopes per app |
+| C. One-time re-seal sweep, then refuse v1 | None | Yes | A tool run where the deployment private key already lives (a box) |
+| D. Pin each stored v1 with a MAC keyed from the private key | None | Yes | Same key handling as C plus a new format; no benefit over C |
+
+## Recommendation
+
+**C, after this branch has rolled.** A sweep, run once on a box that holds
+`CARLOS_SECRETS_KEY`, walks every bundle (default, environments, instance
+layers).
+
+- **Tenant-set secrets only.** It skips secrets the console issues itself:
+ the relay identity (`CARLOS_RELAY`), mail (`CARLOS_MAIL`), store and
+ scan-key secrets. The console checks those against the digest of the
+ envelope it last wrote (`relayenv.go:125`, `relayops.go:2397`), so a
+ re-sealed one would read as not current and be reissued anyway. Let the
+ console reissue them.
+- **Quietly, keeping `SealedTo`.** For each tenant-set v1 envelope sealed to
+ the deployment key, it opens the envelope and writes the v2 re-seal for
+ that same (account, app) at the bundle's etag. The rendered bytes are
+ identical, so no unit restarts. The bundle's version does change, so a
+ settings save or a `--if-version` write that was in flight at the time
+ will conflict and has to be retried. Run it when that is acceptable.
+
+### Duplicates are leads, not proof
+
+Before re-sealing, the sweep lists every v1 envelope found byte for byte in
+more than one (account, app). v1 envelopes come from fresh randomness, so a
+duplicate was copied from somewhere. That makes the list a set of
+candidates to investigate, not proof of an attack, and not a complete set:
+
+- **`accounts migrate` duplicates legitimately.** It copies an app's config
+ to the new account and leaves the source in place. Reconcile each
+ duplicate against the migration history before treating it as suspect.
+- **A planted copy can be a singleton.** If the victim has since rotated or
+ unset the secret, the attacker's copy is the only one left, appears on no
+ list, and the sweep re-seals it as the attacker's own v2.
+- **If bucket versioning is on,** also compare against noncurrent versions
+ of every bundle, which still hold rotated originals. If it is off, the
+ singleton case cannot be detected and has to be accepted.
+
+The sweep does not re-seal listed duplicates. Paul decides what happens to
+those secrets.
+
+### Box-side refusal
+
+Ship v1 refusal in `appconfig.Open` one release after a keyless count of v1
+envelopes reads zero on every deployment. The same release deletes
+`SealUnbound`, the CLI's v1 fallback for old consoles, and the `bound`
+parameter of `NewSealer`.
+
+Implemented now: steps 1 to 4 above (the safe part, which needs no
+decision). Not implemented: the sweep and the floor. Both need Paul to
+decide who runs a tool with the deployment private key, and when.
+
+## Not bound: the variable name (deferred)
+
+v2's associated data is (account, app), not the variable name. Deferred
+because a name swap stays inside one app and one tenant, while a v3 would
+cost another reader-first rollout for no tenant boundary gained.
diff --git a/docs/superpowers/notes/census-proposal-infra-floor-keys-deny.md b/docs/superpowers/notes/census-proposal-infra-floor-keys-deny.md
new file mode 100644
index 000000000..d8170108d
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-infra-floor-keys-deny.md
@@ -0,0 +1,25 @@
+# Census approval: infra-floor-keys-deny
+
+Ruling `census-ruling-infra-floor-keys-deny`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `infra/modules/deployment-buckets/main.tf` `external` | body | unchanged (1) | the deployment bucket policy gains OnlyOperatorsWriteMovesFloor (Deny s3:PutObject, s3:DeleteObject, s3:DeleteObjectVersion on control/moves-protocol.json and control/moves-protocol-auth.json, ArnNotLike operator_role_arns) and OnlyPublishersWriteSeedsFloor (the same actions on control/seeds-protocol.json, ArnNotLike operator_role_arns plus seeds_floor_writer_role_arns), Principal *, the nobody ARN when the list is empty, the same shape as OnlyOperatorsWriteBinds; a local joins the two lists; nothing wider is named and no other statement changes. Only narrows writers of objects root reads; tofu only, run on an operator machine; no read is added |
+| `infra/modules/deployment-buckets/variables.tf` `external` | body | unchanged (1) | adds variable seeds_floor_writer_role_arns (list of exact IAM role ARNs, default empty, wildcards refused by validation); operator_role_arns description names the floors; no read |
+
+Envelopes re-pinned: `infra/modules/deployment-buckets`, `infra/modules/deployment-buckets/tests`.
+
+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:
+
+- `infra/modules/deployment-buckets/main.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change;rev3=census-ruling-data-lifecycle-336;basis=adds aws_s3_bucket_lifecycle_configuration "data" on the data bucket: noncurrent versions expire after var.data_noncurrent_days, expired delete markers go, multipart aborts after 7 days; no read, no IAM change;rev3=census-ruling-media-results-cleanup;basis=two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change;rev3=census-ruling-store-write-credential;basis=the deployment bucket policy gains ConsoleFloorsAreCreateOnly (Deny s3:PutObject without If-None-Match) and ConsoleFloorsAreNeverDeleted (Deny s3:DeleteObject and s3:DeleteObjectVersion), both Principal * on control/console-floors/* only, the same shape as the box evidence statements; nothing wider is named. tofu only, run on an operator machine; no read is added and nothing on a box reads the file
+- `infra/modules/deployment-buckets/variables.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-data-lifecycle-336;basis=adds variable data_noncurrent_days (number, default 7, validated whole and >= 1); no read
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `infra/modules/deployment-buckets/tests/published_floors.tftest.hcl:external`: reads +file:external; written legacy, accepted-legacy, frozen
+
+Seal: `a6a19c800d55f99ed1c70068e38ffa66aef7af8f55199e97e986d9bbb0e0d80d` → `3d13ade9d1fce3bc1a7d7250d75f2cc5ea3563ca6426401f428ca3a86af19619`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-infra-floor-keys-deny.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/census-proposal-sec-h3-m2-scoped-key.md b/docs/superpowers/notes/census-proposal-sec-h3-m2-scoped-key.md
index 372974f86..5b7a9f224 100644
--- a/docs/superpowers/notes/census-proposal-sec-h3-m2-scoped-key.md
+++ b/docs/superpowers/notes/census-proposal-sec-h3-m2-scoped-key.md
@@ -14,6 +14,6 @@ Recorded dispositions, which each change must still satisfy:
- `channels_digests.go` `runChannelsResign`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
-Seal: `a6a19c800d55f99ed1c70068e38ffa66aef7af8f55199e97e986d9bbb0e0d80d` → `0a86ee3c77d0bf54a8c723bf5cd5eab440d556f7fc66d0eb2888063c85e42404`.
+Seal: `76f69ece310924c374511605d0f6c718464d6374292961ca6a53955ec36f6e21` → `4f307fb962a2aac71640ebc18058c02a29d6c7175b93ff1461317e37b94fca4b`.
Overlay: `internal/provision/testdata/plan14-root-reads-sec-h3-m2-scoped-key.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/census-proposal-sec-h3-m3-envelope.md b/docs/superpowers/notes/census-proposal-sec-h3-m3-envelope.md
new file mode 100644
index 000000000..4ec829292
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-sec-h3-m3-envelope.md
@@ -0,0 +1,19 @@
+# Census approval: sec-h3-m3-envelope
+
+Ruling `census-ruling-sec-h3-m3-envelope`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `accounts.go` `runAccountsMigrate` | body | unchanged (9) | H3-M3 r3: before any write or route stamp, after refuseDataRecords, snapshotConfig (accounts_sealed.go) GETs each planned config bundle (config.json, environments/*.json, instances-config/*.json under the plan's own source prefix, the same deployment store) ONCE into an in-memory snapshot and refuses the plan if any secret is a v2 envelope (appconfig.EnvelopeBound, a prefix check, no key). The copy loop moved verbatim into copyMigrationPlan, which returns errors instead of exiting and takes config bundle bytes from the snapshot (never re-reading the source config), other objects from store.Get as before; after the copy reportConfigChanged GETs each snapshotted key once more and only prints the keys whose bytes changed. Parsed config only decides a refusal or a printed key; nothing is opened, run or followed from it; adds a refusal, removes none |
+
+Envelopes re-pinned: `.`, `internal/appconfig`, `internal/moves/archive`.
+
+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:
+
+- `accounts.go` `runAccountsMigrate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-nearest-region-b;basis=reads the hostname history's floor before it opens the registry (checkMigrationFloorNow: GETs control/hosts-used/@floor from the deployment store, the one store the verb uses) and refuses below it; before any write it reads each planned record's source and destination keys and refuses a plan that would create a data-kind record (refuseDataRecords), and each record copy checks the same again (copyMigrationRecord) and never writes a data-kind record; no marks, no new kind of read, no path or input a tenant, app or box agent can name
+
+Seal: `3d13ade9d1fce3bc1a7d7250d75f2cc5ea3563ca6426401f428ca3a86af19619` → `76f69ece310924c374511605d0f6c718464d6374292961ca6a53955ec36f6e21`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-sec-h3-m3-envelope.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/infra/modules/deployment-buckets/main.tf b/infra/modules/deployment-buckets/main.tf
index 4fcbe3bbd..508991f57 100644
--- a/infra/modules/deployment-buckets/main.tf
+++ b/infra/modules/deployment-buckets/main.tf
@@ -209,6 +209,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "data" {
locals {
box_evidence_prefixes = ["control/boxes", "control/box-volumes", "control/box-enrollment", "control/box-fences"]
+ seeds_floor_writers = concat(var.operator_role_arns, var.seeds_floor_writer_role_arns)
}
resource "aws_s3_bucket_policy" "deployment_box_records" {
@@ -288,6 +289,44 @@ resource "aws_s3_bucket_policy" "deployment_box_records" {
}
}
},
+ # The published floors. Every box role may write this whole bucket,
+ # so tenant code that reaches one could publish a forged high floor
+ # or delete a real one. The moves floor and its root-signed
+ # authorization are an operator action (an operator shell, or
+ # hostfloor.Publish on a trusted host); nothing on a box and no
+ # console writes either. A deleted authorization tears the pair and
+ # the console refuses platform updates, so it is covered too. The
+ # seeds floor is published by a console (`carlos system seeds-floor
+ # publish`), so the consoles named in seeds_floor_writer_role_arns
+ # may write it as well. Exactly these three keys; with nobody named,
+ # the Deny covers everyone.
+ {
+ Sid = "OnlyOperatorsWriteMovesFloor"
+ Effect = "Deny"
+ Principal = "*"
+ Action = ["s3:PutObject", "s3:DeleteObject", "s3:DeleteObjectVersion"]
+ Resource = [
+ "${aws_s3_bucket.deployment.arn}/control/moves-protocol.json",
+ "${aws_s3_bucket.deployment.arn}/control/moves-protocol-auth.json",
+ ]
+ Condition = {
+ ArnNotLike = {
+ "aws:PrincipalArn" = length(var.operator_role_arns) > 0 ? var.operator_role_arns : ["arn:aws:iam::000000000000:role/nobody"]
+ }
+ }
+ },
+ {
+ Sid = "OnlyPublishersWriteSeedsFloor"
+ Effect = "Deny"
+ Principal = "*"
+ Action = ["s3:PutObject", "s3:DeleteObject", "s3:DeleteObjectVersion"]
+ Resource = "${aws_s3_bucket.deployment.arn}/control/seeds-protocol.json"
+ Condition = {
+ ArnNotLike = {
+ "aws:PrincipalArn" = length(local.seeds_floor_writers) > 0 ? local.seeds_floor_writers : ["arn:aws:iam::000000000000:role/nobody"]
+ }
+ }
+ },
]
})
}
diff --git a/infra/modules/deployment-buckets/tests/published_floors.tftest.hcl b/infra/modules/deployment-buckets/tests/published_floors.tftest.hcl
new file mode 100644
index 000000000..8fb16b2a1
--- /dev/null
+++ b/infra/modules/deployment-buckets/tests/published_floors.tftest.hcl
@@ -0,0 +1,82 @@
+# The two published floors (control/moves-protocol.json, with its
+# authorization control/moves-protocol-auth.json, and
+# control/seeds-protocol.json): every box role can write the whole
+# deployment bucket, so without these statements tenant code that reaches
+# a box role could publish a forged high floor or delete a real one (a
+# deleted authorization tears the pair, and the console then refuses
+# updates). Only operators write the moves floor pair; operators and the
+# named consoles write the seeds floor (`carlos system seeds-floor
+# publish` is a console door).
+# Each statement is checked whole, so a wider key, another action or
+# another exempt principal fails here.
+
+mock_provider "aws" {}
+
+override_resource {
+ target = aws_s3_bucket.deployment
+ values = { arn = "arn:aws:s3:::dep" }
+}
+
+variables {
+ deployment_bucket_name = "dep"
+ data_bucket_name = "data"
+}
+
+run "only_operators_write_the_moves_floor" {
+ command = plan
+ variables {
+ operator_role_arns = ["arn:aws:iam::123456789012:role/operator-*"]
+ seeds_floor_writer_role_arns = ["arn:aws:iam::123456789012:role/console"]
+ }
+ assert {
+ condition = jsonencode([
+ for s in jsondecode(aws_s3_bucket_policy.deployment_box_records.policy).Statement : s if s.Sid == "OnlyOperatorsWriteMovesFloor"
+ ]) == jsonencode([{
+ Action = ["s3:PutObject", "s3:DeleteObject", "s3:DeleteObjectVersion"]
+ Condition = { ArnNotLike = { "aws:PrincipalArn" = ["arn:aws:iam::123456789012:role/operator-*"] } }
+ Effect = "Deny"
+ Principal = "*"
+ Resource = [
+ "arn:aws:s3:::dep/control/moves-protocol.json",
+ "arn:aws:s3:::dep/control/moves-protocol-auth.json",
+ ]
+ Sid = "OnlyOperatorsWriteMovesFloor"
+ }])
+ error_message = "OnlyOperatorsWriteMovesFloor must Deny writes and deletes of the moves floor and its authorization (control/moves-protocol.json, control/moves-protocol-auth.json) alone to everyone but the operators; a console role is not exempt"
+ }
+ assert {
+ condition = jsonencode([
+ for s in jsondecode(aws_s3_bucket_policy.deployment_box_records.policy).Statement : s if s.Sid == "OnlyPublishersWriteSeedsFloor"
+ ]) == jsonencode([{
+ Action = ["s3:PutObject", "s3:DeleteObject", "s3:DeleteObjectVersion"]
+ Condition = { ArnNotLike = { "aws:PrincipalArn" = [
+ "arn:aws:iam::123456789012:role/operator-*",
+ "arn:aws:iam::123456789012:role/console",
+ ] } }
+ Effect = "Deny"
+ Principal = "*"
+ Resource = "arn:aws:s3:::dep/control/seeds-protocol.json"
+ Sid = "OnlyPublishersWriteSeedsFloor"
+ }])
+ error_message = "OnlyPublishersWriteSeedsFloor must Deny writes and deletes of control/seeds-protocol.json alone to everyone but the operators and the named consoles"
+ }
+}
+
+run "no_publishers_named_denies_everyone" {
+ command = plan
+ assert {
+ condition = jsonencode([
+ for s in jsondecode(aws_s3_bucket_policy.deployment_box_records.policy).Statement : s.Condition.ArnNotLike["aws:PrincipalArn"]
+ if contains(["OnlyOperatorsWriteMovesFloor", "OnlyPublishersWriteSeedsFloor"], s.Sid)
+ ]) == jsonencode([["arn:aws:iam::000000000000:role/nobody"], ["arn:aws:iam::000000000000:role/nobody"]])
+ error_message = "With no operators and no consoles named, both floor statements must exempt nobody."
+ }
+}
+
+run "wildcard_seeds_floor_writers_are_refused" {
+ command = plan
+ variables {
+ seeds_floor_writer_role_arns = ["arn:aws:iam::123456789012:role/*"]
+ }
+ expect_failures = [var.seeds_floor_writer_role_arns]
+}
diff --git a/infra/modules/deployment-buckets/variables.tf b/infra/modules/deployment-buckets/variables.tf
index e1af55cd3..f0fc32127 100644
--- a/infra/modules/deployment-buckets/variables.tf
+++ b/infra/modules/deployment-buckets/variables.tf
@@ -9,7 +9,7 @@ variable "data_bucket_name" {
}
variable "operator_role_arns" {
- description = "IAM role ARNs of human operators. Only these may write a box bind (control/boxes/*.bind.json). Empty means nobody can: the safe default until operators are named."
+ description = "IAM role ARNs of human operators. Only these may write a box bind (control/boxes/*.bind.json) or the moves floor and its authorization (control/moves-protocol.json, control/moves-protocol-auth.json), and they may write the seeds floor. Empty means nobody can: the safe default until operators are named."
type = list(string)
default = []
}
@@ -28,6 +28,20 @@ variable "box_fence_writer_role_arns" {
}
}
+variable "seeds_floor_writer_role_arns" {
+ description = "Exact IAM role ARNs of the consoles that publish the seeds floor (control/seeds-protocol.json, `carlos system seeds-floor publish`). Operators may write it too. Empty with no operators named means nobody can, and the publish door fails."
+ type = list(string)
+ default = []
+
+ validation {
+ condition = alltrue([
+ for arn in var.seeds_floor_writer_role_arns :
+ can(regex("^arn:[a-z0-9-]+:iam::[0-9]{12}:role/[^*?]+$", arn))
+ ])
+ error_message = "Seeds floor writers must be exact IAM role ARNs without wildcards."
+ }
+}
+
variable "data_noncurrent_days" {
description = "Days a replaced or deleted object in the data bucket is kept as a noncurrent version before it expires. Defaults to the 7-day restore window. Longer retention for a plan belongs in litestream's per-instance retention, not here."
type = number
diff --git a/internal/activator/swap_fixture_test.go b/internal/activator/swap_fixture_test.go
index 493dc94fb..5e5828381 100644
--- a/internal/activator/swap_fixture_test.go
+++ b/internal/activator/swap_fixture_test.go
@@ -283,6 +283,15 @@ func newSwapFixtureOn(t *testing.T, wrap func(*fakeSwapBackend) Backend) *swapFi
a.now = clk.now
a.genHealth = func(context.Context, Gen) error { return nil }
f := &swapFixture{a: a, b: b, clk: clk, reg: reg, host: "swap.example.com"}
+ // A run's settle (its proof's republication, after provenSettled is
+ // already true) and a sweep's sidecar restart (its recordBuild) write
+ // the generations file off the test's goroutine; both finish before
+ // the test's TempDirs go, which a cleanup registered here precedes
+ // (#897). Nothing sweeps after the test, so nothing starts another.
+ t.Cleanup(func() {
+ waitFor(t, "the sidecar restart in flight", func() bool { return a.sidecarSettled(f.host) })
+ waitBackground(t, a)
+ })
// The route's socket and database live in the test's own directory,
// never the shared /tmp.
rt := testRoute(f.host)
diff --git a/internal/appconfig/crypto.go b/internal/appconfig/crypto.go
index 93fabc53f..00aec625e 100644
--- a/internal/appconfig/crypto.go
+++ b/internal/appconfig/crypto.go
@@ -7,9 +7,11 @@
//
// v2 authenticates the (account, app) it was sealed for as GCM associated
// data, so a box opens it only while rendering that app's config — see
-// Binding. v1 is what every envelope written before v2 existed looks like,
-// and still opens anywhere; an uncompressed point always starts 0x04, so the
-// two can never be mistaken for each other. Mirrors the shape the framework's crypto core plans for its own
+// Binding. Every seal for a current console is v2. v1 is what envelopes
+// written before that look like: it still opens anywhere, so the config store
+// keeps one only where it already sits (checkUnboundSets) and a copied one is
+// refused at the write. An uncompressed point always starts 0x04, so the two
+// can never be mistaken for each other. Mirrors the shape the framework's crypto core plans for its own
// Seal/Open (docs/superpowers/specs/2026-08-01-carlos-framework-design.md
// §6), reimplemented natively here since platform cannot import the
// framework repo (platform is the substrate the framework builds on).
@@ -33,7 +35,6 @@ import (
"fmt"
"io"
"strings"
- "sync/atomic"
"golang.org/x/crypto/hkdf"
@@ -130,41 +131,21 @@ func ParsePublicKey(b64, src string) (*ecdh.PublicKey, error) {
return k, nil
}
-// boundSealing is whether Seal writes v2. Off by default, and that default is
-// the rollout guard: a box on a binary from before v2 cannot open one, and a
-// single unopenable secret stalls the app's whole config render on that box.
-// So reading v2 ships first and writing it is a separate, deliberate step —
-// the console turns it on from CONSOLE_SECRETS_ENVELOPE_V2 once every box
-// runs a build that reads v2 (cmd/console). Deployment-wide by nature, which
-// is why it is process state rather than a parameter threaded through every
-// door that seals.
-var boundSealing atomic.Bool
-
-// SetBoundSealing switches Seal between v1 (false, the default) and v2.
-func SetBoundSealing(on bool) { boundSealing.Store(on) }
-
-// BoundSealing reports whether Seal writes v2 in this process. The console
-// advertises it to the CLI (handleAPIConfigGet's secrets_account), so a
-// client-side seal follows the same switch.
-func BoundSealing() bool { return boundSealing.Load() }
-
// Seal encrypts plaintext for pub as the config of b: a v2 envelope bound to
-// b when bound sealing is on (SetBoundSealing), else a v1 envelope. b is
-// validated either way, so a caller passing the wrong binding fails now and
-// not on the day the switch flips.
+// b, which only a render of b's own config opens. It is SealBound; the name
+// stays for the callers that seal an app's config.
+//
+// Until hunt H3-M3 it wrote v1 unless a deployment switch
+// (CONSOLE_SECRETS_ENVELOPE_V2) said otherwise, and the switch was on in no
+// deployment, so every new secret could be copied into another tenant's
+// config and opened there. Every box has read v2 since v0.23.0, which is
+// why the switch could go.
func Seal(pub *ecdh.PublicKey, b Binding, plaintext []byte) (string, error) {
- if _, err := b.aad(); err != nil {
- return "", err
- }
- if !BoundSealing() {
- return SealUnbound(pub, plaintext)
- }
return SealBound(pub, b, plaintext)
}
-// SealBound writes a v2 envelope bound to b regardless of the switch: only a
-// render of b's own config opens it. For callers that already know every
-// reader takes v2 — the CLI once the console has said so.
+// SealBound writes a v2 envelope bound to b: only a render of b's own config
+// opens it.
func SealBound(pub *ecdh.PublicKey, b Binding, plaintext []byte) (string, error) {
aad, err := b.aad()
if err != nil {
@@ -178,9 +159,10 @@ func SealBound(pub *ecdh.PublicKey, b Binding, plaintext []byte) (string, error)
}
// SealUnbound writes the v1 envelope: no binding, opens under any account's
-// config. What Seal writes until bound sealing is on, and what the CLI writes
-// for a console that has not said it takes v2 (an older console's
-// CheckEnvelope reads the v2 prefix as a bad point and refuses it).
+// config. Only the CLI calls it, for a console from before v2 that does not
+// name the account (an older console's CheckEnvelope reads the v2 prefix as
+// a bad point and refuses it). A current console names the account on every
+// app, and its config store refuses a new v1 (UnboundEnvelopeError).
func SealUnbound(pub *ecdh.PublicKey, plaintext []byte) (string, error) {
eph, nonce, err := freshEphemeral()
if err != nil {
@@ -233,7 +215,8 @@ func splitVersion(raw []byte) (bool, []byte) {
// EnvelopeBound reports whether envelopeB64 is a v2 (bound) envelope, read
// off its prefix without any key. Bad base64 reads as false. The console's
// config door uses it to refuse a v1 envelope for an app on a fleet, whose
-// envelopes are always v2.
+// envelopes are always v2; the config store refuses one anywhere it is not
+// already stored (checkUnboundSets).
func EnvelopeBound(envelopeB64 string) bool {
raw, err := base64.StdEncoding.DecodeString(envelopeB64)
if err != nil {
@@ -243,18 +226,46 @@ func EnvelopeBound(envelopeB64 string) bool {
return bound
}
+// UnboundEnvelopeError is the config store's refusal of a v1 envelope that is
+// not already the value stored under Var in the bundle being written
+// (checkUnboundSets). A v1 envelope opens under any binding, so a new one is
+// either a copy of another config's secret or the work of a sealer from
+// before v2; both are refused. It names the var and never the envelope.
+type UnboundEnvelopeError struct{ Var string }
+
+func (e *UnboundEnvelopeError) Error() string {
+ return fmt.Sprintf("config: var %s: sealed in the old unbound format, which is accepted only where it is already stored; seal it again", e.Var)
+}
+
+// envelopeUnbound reports whether Open would read envelopeB64 as a v1
+// envelope: it decodes, with the same decoder Open uses, and carries no v2
+// prefix. Anything that does not decode Open refuses outright, so it opens
+// nowhere and is not this question.
+func envelopeUnbound(envelopeB64 string) bool {
+ raw, err := base64.StdEncoding.DecodeString(envelopeB64)
+ if err != nil {
+ return false
+ }
+ bound, _ := splitVersion(raw)
+ return !bound
+}
+
// Open decrypts an envelope with priv, for the config named by b. A v2
// envelope opens only if it was sealed for b. A v1 envelope opens regardless
// of b: those were written before the binding existed and are most of every
// production bucket today.
//
-// That v1 path is the residual the binding cannot close by itself. Anyone
-// who can write one tenant's config can copy another tenant's v1 envelope
-// into it and have a box decrypt it there. Stripping a v2 envelope down to
-// v1 does not get there (see boundInfo), so the exposure is the fixed set of
-// v1 envelopes already stored plus every one written while bound sealing is
-// off. Once it is on, each write re-seals as v2. Sunset: once no stored
-// envelope is v1, refuse v1 here.
+// That v1 path is the residual the binding cannot close by itself: a v1
+// envelope carries nothing that says whose it is. So the write side holds
+// it (hunt H3-M3). Nothing seals v1 for a current console (Seal), and the
+// config store accepts a v1 envelope only as the value already stored under
+// that name in that bundle (checkUnboundSets), so one copied from another
+// tenant's config is refused at every door. Stripping a v2 envelope down to
+// v1 does not get past this either (see boundInfo). What is left is the
+// fixed set of v1 envelopes already stored, which open here for the config
+// they sit in, and a writer with direct bucket access, who is past every
+// door. Sunset: re-seal those as v2, then refuse v1 here
+// (docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md).
func Open(priv *ecdh.PrivateKey, b Binding, envelopeB64 string) ([]byte, error) {
raw, err := base64.StdEncoding.DecodeString(envelopeB64)
if err != nil {
diff --git a/internal/appconfig/crypto_bind_test.go b/internal/appconfig/crypto_bind_test.go
index 2baaf10ca..c4819d840 100644
--- a/internal/appconfig/crypto_bind_test.go
+++ b/internal/appconfig/crypto_bind_test.go
@@ -162,43 +162,32 @@ func TestSyncRefusesAnEnvelopeSealedForAnotherAccount(t *testing.T) {
}
}
-// The rollout guard: until a deployment turns bound sealing on, Seal writes
-// v1, which every box can open — a box on a binary from before v2 would
-// stall the app's whole config render on a v2 envelope. It still validates
-// the binding, so a wrong caller fails before the switch ever flips.
+// Seal writes v2, bound to the config it is given, and validates that
+// binding (hunt H3-M3: it used to write v1 unless a deployment switch said
+// otherwise, and a v1 envelope opens in any tenant's config).
//
-// Mutation-mindedness: default boundSealing to true, or have Seal ignore it,
-// and the first assertion fails.
-func TestSealWritesV1UntilBoundSealingIsOn(t *testing.T) {
+// Mutation-mindedness: have Seal call SealUnbound again and the first
+// assertion fails.
+func TestSealWritesBoundEnvelopes(t *testing.T) {
priv, pub := bindKeys(t)
- t.Cleanup(func() { SetBoundSealing(false) })
b := Binding{Account: "aaa", App: "blog"}
-
- SetBoundSealing(false)
env, err := Seal(pub, b, []byte("shh"))
if err != nil {
t.Fatal(err)
}
raw, _ := base64.StdEncoding.DecodeString(env)
- if raw[0] != 0x04 {
- t.Fatalf("with bound sealing off Seal wrote a non-v1 envelope (first byte %#x)", raw[0])
- }
- if _, err := Seal(pub, Binding{}, []byte("shh")); err == nil {
- t.Fatal("Seal with bound sealing off accepted an empty binding")
- }
-
- SetBoundSealing(true)
- env, err = Seal(pub, b, []byte("shh"))
- if err != nil {
- t.Fatal(err)
- }
- raw, _ = base64.StdEncoding.DecodeString(env)
if !bytes.HasPrefix(raw, []byte(boundPrefix)) {
- t.Fatal("with bound sealing on Seal did not write v2")
+ t.Fatalf("Seal did not write v2 (first byte %#x)", raw[0])
+ }
+ if got, err := Open(priv, b, env); err != nil || string(got) != "shh" {
+ t.Fatalf("Open under its own binding = %q, %v", got, err)
}
if _, err := Open(priv, Binding{Account: "bbb", App: "blog"}, env); err == nil {
t.Fatal("v2 envelope from Seal opened under another account")
}
+ if _, err := Seal(pub, Binding{}, []byte("shh")); err == nil {
+ t.Fatal("Seal accepted an empty binding")
+ }
}
// EnvelopeBound reads the version off the prefix: v2 from SealBound, v1
diff --git a/internal/appconfig/hunt_H3-M3_test.go b/internal/appconfig/hunt_H3-M3_test.go
new file mode 100644
index 000000000..4ba61b41b
--- /dev/null
+++ b/internal/appconfig/hunt_H3-M3_test.go
@@ -0,0 +1,141 @@
+package appconfig
+
+import (
+ "context"
+ "crypto/ecdh"
+ "errors"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// hunt H3-M3 (Opus verifier). Tenant aaa's secret is sealed the way the
+// console and the CLI seal it. Someone who can READ the bucket copies that
+// envelope into an app they control (bbb/blog), either straight into the
+// bucket or through the config door, which can only run the keyless
+// CheckEnvelope (console/apiconfig.go). The box's real Sync renders bbb's
+// config under bbb's binding (sync.go). SECURE: aaa's plaintext never
+// reaches bbb's env file.
+//
+// When the hunt ran, Seal wrote v1 unless a deployment switch said
+// otherwise, and this test failed at its last line. Seal writes v2 now, so
+// the copy is stored and does not open under bbb's binding.
+func TestHunt_H3_M3_V1EnvelopeOpensInAnotherTenantsRender(t *testing.T) {
+ ctx := context.Background()
+ priv, pub := bindKeys(t)
+
+ s := release.NewDirStore(t.TempDir())
+ victim, err := Seal(pub, Binding{Account: "aaa", App: "shop"}, []byte("aaa-stripe-live-key"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := SetSecret(ctx, s, "aaa", "shop", map[string]Var{"STRIPE_KEY": {Envelope: victim}}); err != nil {
+ t.Fatal(err)
+ }
+ // The read: the envelope as it sits in aaa's config.
+ m, err := Get(ctx, s, "aaa", "shop")
+ if err != nil {
+ t.Fatal(err)
+ }
+ stolen := m.Vars["STRIPE_KEY"].Envelope
+ if err := CheckEnvelope(stolen); err != nil {
+ t.Fatalf("the config door would refuse it: %v", err)
+ }
+ // The write, into the attacker's own app.
+ if err := SetSecret(ctx, s, "bbb", "blog", map[string]Var{"LOOT": {Envelope: stolen}}); err != nil {
+ t.Fatal(err)
+ }
+ got := huntH3M3RenderBlog(t, s, priv)
+ if strings.Contains(got, "aaa-stripe-live-key") {
+ t.Fatalf("H3-M3: aaa/shop's secret rendered into bbb/blog's env file:\n%s", got)
+ }
+}
+
+// The same theft with an envelope written before every seal was v2: a v1
+// envelope already stored in aaa's config, which opens under any binding.
+// The config store accepts a v1 envelope only as the value already stored
+// in that slot, so the copy into bbb/blog is refused at the write, by name,
+// and nothing of it reaches bbb's env file. aaa's own render still opens
+// it: no stored secret is lost.
+//
+// Mutation-mindedness: drop checkUnboundSets from applyAtExpecting and the
+// copy is stored and rendered into bbb's env file.
+func TestHunt_H3_M3_LegacyV1EnvelopeCopyIsRefused(t *testing.T) {
+ ctx := context.Background()
+ priv, pub := bindKeys(t)
+ s := release.NewDirStore(t.TempDir())
+
+ legacy, err := SealUnbound(pub, []byte("aaa-stripe-live-key"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ // As the bucket holds it today: written before the store refused v1.
+ if _, _, err := putManifestAt(ctx, s, Key("aaa", "shop"), "shop",
+ &Manifest{Vars: map[string]Var{"STRIPE_KEY": {Kind: "secret", Envelope: legacy}}}, ""); err != nil {
+ t.Fatal(err)
+ }
+ m, err := Get(ctx, s, "aaa", "shop")
+ if err != nil {
+ t.Fatal(err)
+ }
+ stolen := m.Vars["STRIPE_KEY"].Envelope
+ if err := CheckEnvelope(stolen); err != nil {
+ t.Fatalf("the config door would refuse it: %v", err)
+ }
+
+ err = SetSecret(ctx, s, "bbb", "blog", map[string]Var{"LOOT": {Envelope: stolen}})
+ var unbound *UnboundEnvelopeError
+ if !errors.As(err, &unbound) || unbound.Var != "LOOT" {
+ t.Fatalf("copying aaa's v1 envelope into bbb/blog: err = %v, want UnboundEnvelopeError for LOOT", err)
+ }
+ if strings.Contains(err.Error(), stolen) {
+ t.Fatal("the refusal echoes the envelope")
+ }
+ // Every other bundle of bbb's refuses it too: a named environment and
+ // one an owner scope holds.
+ if _, err := ApplyEnvironment(ctx, s, "bbb", "blog", "staging", map[string]Var{"LOOT": {Kind: "secret", Envelope: stolen}}, nil); !errors.As(err, &unbound) {
+ t.Fatalf("copy into bbb/blog staging: err = %v, want UnboundEnvelopeError", err)
+ }
+ if _, err := ApplyEnvironmentOwned(ctx, s, "bbb", "blog", "preview", "team-1", map[string]Var{"LOOT": {Kind: "secret", Envelope: stolen}}, nil); !errors.As(err, &unbound) {
+ t.Fatalf("copy into bbb/blog's owned preview: err = %v, want UnboundEnvelopeError", err)
+ }
+ if got := huntH3M3RenderBlog(t, s, priv); strings.Contains(got, "aaa-stripe-live-key") {
+ t.Fatalf("H3-M3: aaa/shop's v1 secret rendered into bbb/blog's env file:\n%s", got)
+ }
+
+ // aaa's own route still renders its legacy secret.
+ reg := testRegistry(t)
+ if err := reg.Upsert(registry.Route{Host: "shop.example.com", Kind: "instance", App: "shop", Account: "aaa",
+ Status: "ready", Backing: registry.BackingUnit}); err != nil {
+ t.Fatal(err)
+ }
+ envDir := t.TempDir()
+ if err := Sync(ctx, reg, s, priv, envDir, func(string) error { return nil }, nil); err != nil {
+ t.Fatalf("Sync: %v", err)
+ }
+ own, _ := os.ReadFile(filepath.Join(envDir, "shop.example.com.env"))
+ if !strings.Contains(string(own), "STRIPE_KEY=aaa-stripe-live-key") {
+ t.Fatalf("aaa/shop lost its own legacy secret:\n%s", own)
+ }
+}
+
+// huntH3M3RenderBlog runs the box's real Sync for bbb/blog's route and
+// returns the env file it wrote ("" when it wrote none).
+func huntH3M3RenderBlog(t *testing.T, s release.Store, priv *ecdh.PrivateKey) string {
+ t.Helper()
+ reg := testRegistry(t)
+ if err := reg.Upsert(registry.Route{Host: "blog.example.com", Kind: "instance", App: "blog", Account: "bbb",
+ Status: "ready", Backing: registry.BackingUnit}); err != nil {
+ t.Fatal(err)
+ }
+ envDir := t.TempDir()
+ if err := Sync(context.Background(), reg, s, priv, envDir, func(string) error { return nil }, nil); err != nil {
+ t.Fatalf("Sync: %v", err)
+ }
+ got, _ := os.ReadFile(filepath.Join(envDir, "blog.example.com.env"))
+ return string(got)
+}
diff --git a/internal/appconfig/owned.go b/internal/appconfig/owned.go
index 8f0efa3a7..cb360b5b8 100644
--- a/internal/appconfig/owned.go
+++ b/internal/appconfig/owned.go
@@ -169,6 +169,9 @@ func applyEnvironmentOwned(ctx context.Context, s release.Store, acct, app, envN
if expect != "" && expect != before {
return Receipt{}, ErrVersionMismatch
}
+ if err := checkUnboundSets(&m, sets); err != nil {
+ return Receipt{}, err
+ }
r := applyToManifest(&m, sets, unsets)
raw, _, err := putManifestAt(ctx, s, key, app, &m, etag)
if err != nil {
@@ -232,6 +235,16 @@ func claimRawSetEnvironmentOwner(ctx context.Context, s release.Store, acct, app
// of it, and no key is needed here. exec_delivery is not copied: an owned
// bundle states its own, or none.
//
+// The one exception to the store's v1 rule (checkUnboundSets: a v1
+// envelope is accepted only where it already sits). A fork writes through
+// putManifestAt, not a door's apply, so a v1 secret in from is copied into
+// the new bundle as it is. That crosses no tenant boundary: acct and app
+// are one pair for both keys, so the copy stays in the same account and
+// app, and every var keeps its name (TestForkStaysInItsOwnAccountAndApp).
+// A v1 envelope already opened for this (account, app); the fork lets it
+// open for one more environment of it, which the sunset sweep re-seals
+// with the rest.
+//
// from must exist (ErrEnvironmentMissing) and must not be owned by another
// scope (ErrOwnedElsewhere; a source the same scope owns is fine, and so is
// an unowned one). The write is create-only: a `to` that exists, or that
diff --git a/internal/appconfig/owned_test.go b/internal/appconfig/owned_test.go
index 8c8797a76..ed6403162 100644
--- a/internal/appconfig/owned_test.go
+++ b/internal/appconfig/owned_test.go
@@ -358,13 +358,22 @@ func TestForkEnvironmentCopiesOwnKeysVerbatim(t *testing.T) {
}
smtp, _ := SealUnbound(pub, []byte("smtp-pass"))
if err := SaveEnvironment(ctx, s, "bab", "docs", "lagged", map[string]Var{
- "OWN": {Kind: "env", Value: "1"},
- "S1": {Kind: "secret", Envelope: v1},
- "S2": {Kind: "secret", Envelope: v2},
- "DOCS_SMTP_PASS": {Kind: "secret", Envelope: smtp},
+ "OWN": {Kind: "env", Value: "1"},
+ "S2": {Kind: "secret", Envelope: v2},
}, nil); err != nil {
t.Fatal(err)
}
+ // The v1 envelopes as a bundle holds them from before the store refused
+ // a new one (hunt H3-M3).
+ lagged, etag, _, err := getIfExistsAtETag(ctx, s, EnvironmentKey("bab", "docs", "lagged"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ lagged.Vars["S1"] = Var{Kind: "secret", Envelope: v1}
+ lagged.Vars["DOCS_SMTP_PASS"] = Var{Kind: "secret", Envelope: smtp}
+ if _, _, err := putManifestAt(ctx, s, EnvironmentKey("bab", "docs", "lagged"), "docs", lagged, etag); err != nil {
+ t.Fatal(err)
+ }
if err := ForkEnvironment(ctx, s, "bab", "docs", "lagged", "lagged-team", "alta", []string{"DOCS_SMTP_PASS"}); err != nil {
t.Fatal(err)
}
@@ -409,6 +418,107 @@ func TestForkEnvironmentCopiesOwnKeysVerbatim(t *testing.T) {
}
}
+// TestForkStaysInItsOwnAccountAndApp pins the fork's exception to the
+// store's v1 rule (H3-M3 round 2, Astra P2): a fork copies envelopes,
+// v1 included, but only into a new bundle of the same account and app,
+// under the same names. Every object the fork writes sits under the app's
+// own prefix, the new bundle names the same app, its vars are the source's
+// own names with the same envelopes, and the bound secret it carries still
+// opens for this (account, app) alone.
+func TestForkStaysInItsOwnAccountAndApp(t *testing.T) {
+ ctx, s, privB64 := ownedWorld(t)
+ priv, err := ParsePrivateKey(privB64, "test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ pub := priv.PublicKey()
+ v1, err := SealUnbound(pub, []byte("v1-plain"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ v2, err := SealBound(pub, Binding{Account: "bab", App: "docs"}, []byte("v2-plain"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := SaveEnvironment(ctx, s, "bab", "docs", "src", map[string]Var{"S2": {Kind: "secret", Envelope: v2}}, nil); err != nil {
+ t.Fatal(err)
+ }
+ src, etag, _, err := getIfExistsAtETag(ctx, s, EnvironmentKey("bab", "docs", "src"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ src.Vars["S1"] = Var{Kind: "secret", Envelope: v1}
+ if _, _, err := putManifestAt(ctx, s, EnvironmentKey("bab", "docs", "src"), "docs", src, etag); err != nil {
+ t.Fatal(err)
+ }
+ // Neighbours the fork must not touch: another app of the account, and
+ // the same app name in another account.
+ for _, n := range []struct{ acct, app string }{{"bab", "other"}, {"cac", "docs"}} {
+ if err := SetEnv(ctx, s, n.acct, n.app, map[string]string{"X": "1"}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ snapshot := func() map[string]string {
+ t.Helper()
+ keys, err := s.List(ctx, "apps/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ out := map[string]string{}
+ for _, k := range keys {
+ b, _, err := s.Get(ctx, k)
+ if err != nil {
+ t.Fatal(err)
+ }
+ out[k] = string(b)
+ }
+ return out
+ }
+ before := snapshot()
+ if err := ForkEnvironment(ctx, s, "bab", "docs", "src", "forked", "alta", nil); err != nil {
+ t.Fatal(err)
+ }
+ own := release.AppPrefix("bab", "docs")
+ wrote := false
+ for k, b := range snapshot() {
+ if before[k] == b {
+ continue
+ }
+ if !strings.HasPrefix(k, own) {
+ t.Errorf("the fork wrote %s, outside %s", k, own)
+ }
+ if k == EnvironmentKey("bab", "docs", "forked") {
+ wrote = true
+ }
+ }
+ if !wrote {
+ t.Fatal("the fork did not write its bundle")
+ }
+ m, _, found, err := GetEnvironment(ctx, s, "bab", "docs", "forked")
+ if err != nil || !found {
+ t.Fatalf("forked bundle: %v %v", found, err)
+ }
+ if m.App != "docs" {
+ t.Errorf("forked bundle names app %q, want docs", m.App)
+ }
+ if got, want := strings.Join(m.SortedKeys(), ","), strings.Join(src.SortedKeys(), ","); got != want {
+ t.Errorf("forked names = %s, want the source's %s", got, want)
+ }
+ for k, v := range src.Vars {
+ if m.Vars[k] != v {
+ t.Errorf("%s: forked %+v, source %+v", k, m.Vars[k], v)
+ }
+ }
+ if plain, err := Open(priv, Binding{Account: "bab", App: "docs"}, m.Vars["S2"].Envelope); err != nil || string(plain) != "v2-plain" {
+ t.Errorf("the forked bound secret does not open for its own app: %q %v", plain, err)
+ }
+ for _, b := range []Binding{{Account: "cac", App: "docs"}, {Account: "bab", App: "other"}} {
+ if _, err := Open(priv, b, m.Vars["S2"].Envelope); err == nil {
+ t.Errorf("the forked bound secret opened as %+v", b)
+ }
+ }
+}
+
// TestSyncKeepsRootsRefusalForAnOwnedBundle is the census review's witness
// (#280, P2): on the privileged unit-backed Sync path, an environment's
// owner mark is no authority for root to discard a hand-staged file. With
diff --git a/internal/appconfig/sealer.go b/internal/appconfig/sealer.go
index 9b6f68183..72ccab104 100644
--- a/internal/appconfig/sealer.go
+++ b/internal/appconfig/sealer.go
@@ -13,8 +13,10 @@ var ErrSealerBinding = errors.New("sealer: binding does not match the sealer's o
// Sealer seals secrets to one public key for one (account, app) binding, and
// records which key it used. Every seal in the platform goes through it, so a
// stored secret always names the key it was sealed to (Var.SealedTo). Whether
-// it writes a bound (v2) or unbound (v1) envelope is fixed at construction,
-// not read from the deployment-wide switch.
+// it writes a bound (v2) or unbound (v1) envelope is fixed at construction.
+// Every production caller builds a bound sealer; the unbound choice is left
+// for tests and goes, with SealUnbound, in the release that refuses v1
+// (docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md).
type Sealer struct {
pub *ecdh.PublicKey
fp string
diff --git a/internal/appconfig/sealer_test.go b/internal/appconfig/sealer_test.go
index 558f6445b..3c49f3551 100644
--- a/internal/appconfig/sealer_test.go
+++ b/internal/appconfig/sealer_test.go
@@ -55,14 +55,10 @@ func TestSealerRefusesAnotherBinding(t *testing.T) {
}
}
-// A sealer's bound flag is fixed at construction: the deployment-wide switch
-// (SetBoundSealing) does not change what it writes.
-func TestSealerBoundIgnoresTheDeploymentSwitch(t *testing.T) {
+// A sealer's bound flag is fixed at construction and decides what it writes.
+func TestSealerBoundDecidesTheFormat(t *testing.T) {
_, pub := bindKeys(t)
b := Binding{Account: "bab", App: "shop"}
- prev := BoundSealing()
- SetBoundSealing(false)
- t.Cleanup(func() { SetBoundSealing(prev) })
prefix := func(bound bool) string {
v, err := NewSealer(pub, b, bound).Seal(b, []byte("x"))
diff --git a/internal/appconfig/store.go b/internal/appconfig/store.go
index 90b0ea89c..54754d84b 100644
--- a/internal/appconfig/store.go
+++ b/internal/appconfig/store.go
@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"os"
+ "sort"
"github.com/carlosframework/platform/internal/release"
)
@@ -228,6 +229,9 @@ func applyAtExpecting(ctx context.Context, s release.Store, key, app, bundle str
if expect != "" && expect != before {
return Receipt{}, "", false, ErrVersionMismatch
}
+ if err := checkUnboundSets(&m, sets); err != nil {
+ return Receipt{}, "", false, err
+ }
r := applyToManifest(&m, sets, unsets)
if want != nil && len(sets) == 0 && len(r.Unset) == 0 {
r.VersionBefore, r.VersionAfter = before, before
@@ -245,6 +249,42 @@ func applyAtExpecting(ctx context.Context, s release.Store, key, app, bundle str
return r, newETag, true, nil
}
+// checkUnboundSets refuses a secret set whose envelope Open would read as v1
+// (unbound), unless it is byte for byte the envelope m already holds under
+// that name (hunt H3-M3). m is the bundle as read for this write, so the
+// check and the write rest on the same read. A value that is not base64 at
+// all opens nowhere and is left to the doors' CheckEnvelope, as before.
+//
+// A v1 envelope opens under any account's config (Open), so the only
+// evidence of where one belongs is where it already sits. One that sits in
+// this very slot may go on sitting there: rewriting it unchanged reveals
+// nothing it did not already. Anything else is refused: a v1 copied from
+// another tenant's config (the finding: anyone who can read the bucket and
+// write their own app's config), the same value moved to another name or
+// bundle, and a fresh v1 from a sealer that predates v2. Every current
+// client seals v2 (Seal), so none of them is refused.
+//
+// Names are checked sorted, so a write with several refused vars always
+// names the same one.
+func checkUnboundSets(m *Manifest, sets map[string]Var) error {
+ keys := make([]string, 0, len(sets))
+ for k := range sets {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+ for _, k := range keys {
+ v := sets[k]
+ if v.Kind != "secret" || !envelopeUnbound(v.Envelope) {
+ continue
+ }
+ if old, ok := m.Vars[k]; ok && old.Kind == "secret" && old.Envelope == v.Envelope {
+ continue
+ }
+ return &UnboundEnvelopeError{Var: k}
+ }
+ return nil
+}
+
// conditionalPutErr is a manifest write's error as a conditional caller
// must see it. The write was made at the etag of the read whose version
// matched expect, so a CAS conflict means another writer moved the layer in
diff --git a/internal/appconfig/unboundsets_test.go b/internal/appconfig/unboundsets_test.go
new file mode 100644
index 000000000..468e9ac25
--- /dev/null
+++ b/internal/appconfig/unboundsets_test.go
@@ -0,0 +1,95 @@
+package appconfig
+
+import (
+ "context"
+ "errors"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// The config store keeps a v1 (unbound) envelope only where it already sits
+// (checkUnboundSets, hunt H3-M3). Each case writes through the real store
+// doors over a bundle that already holds a legacy v1 under STRIPE_KEY.
+func TestStoreAcceptsV1OnlyWhereItAlreadySits(t *testing.T) {
+ ctx := context.Background()
+ _, pub := bindKeys(t)
+ legacy, err := SealUnbound(pub, []byte("old"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ fresh, err := SealUnbound(pub, []byte("new"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ bound, err := Seal(pub, Binding{Account: "aaa", App: "shop"}, []byte("new"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ world := func(t *testing.T) release.Store {
+ t.Helper()
+ s := release.NewDirStore(t.TempDir())
+ m := &Manifest{Vars: map[string]Var{"STRIPE_KEY": {Kind: "secret", Envelope: legacy}}}
+ if _, _, err := putManifestAt(ctx, s, Key("aaa", "shop"), "shop", m, ""); err != nil {
+ t.Fatal(err)
+ }
+ if _, _, err := putManifestAt(ctx, s, EnvironmentKey("aaa", "shop", "staging"), "shop", m, ""); err != nil {
+ t.Fatal(err)
+ }
+ return s
+ }
+ secret := func(env string) map[string]Var { return map[string]Var{"STRIPE_KEY": {Envelope: env}} }
+
+ for _, c := range []struct {
+ name string
+ write func(release.Store) error
+ refused string // the var named in the refusal, "" for accepted
+ }{
+ {"unchanged in its own slot", func(s release.Store) error { return SetSecret(ctx, s, "aaa", "shop", secret(legacy)) }, ""},
+ {"unchanged in its own environment slot", func(s release.Store) error {
+ _, err := ApplyEnvironment(ctx, s, "aaa", "shop", "staging", map[string]Var{"STRIPE_KEY": {Kind: "secret", Envelope: legacy}}, nil)
+ return err
+ }, ""},
+ {"replaced by v2", func(s release.Store) error { return SetSecret(ctx, s, "aaa", "shop", secret(bound)) }, ""},
+ {"replaced by a fresh v1", func(s release.Store) error { return SetSecret(ctx, s, "aaa", "shop", secret(fresh)) }, "STRIPE_KEY"},
+ {"moved to another name", func(s release.Store) error {
+ return SetSecret(ctx, s, "aaa", "shop", map[string]Var{"OTHER": {Envelope: legacy}})
+ }, "OTHER"},
+ {"copied to a bundle it is not in", func(s release.Store) error {
+ _, err := ApplyEnvironment(ctx, s, "aaa", "shop", "prod", map[string]Var{"STRIPE_KEY": {Kind: "secret", Envelope: legacy}}, nil)
+ return err
+ }, "STRIPE_KEY"},
+ {"as an instance layer", func(s release.Store) error {
+ _, _, err := ApplyInstance(ctx, s, "aaa", "shop", "shop-1.example.com", map[string]Var{"STRIPE_KEY": {Kind: "secret", Envelope: legacy}}, nil)
+ return err
+ }, "STRIPE_KEY"},
+ {"at a version", func(s release.Store) error {
+ m, etag, found, err := getIfExistsAtETag(ctx, s, Key("aaa", "shop"))
+ if err != nil || !found || m == nil {
+ t.Fatalf("read: %v %v", found, err)
+ }
+ _, err = ApplyAtVersion(ctx, s, "aaa", "shop", "", BundleVersion{Found: true, ETag: etag}, map[string]Var{"NEW": {Kind: "secret", Envelope: fresh}}, nil)
+ return err
+ }, "NEW"},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ s := world(t)
+ before, _ := Get(ctx, s, "aaa", "shop")
+ err := c.write(s)
+ if c.refused == "" {
+ if err != nil {
+ t.Fatalf("refused: %v", err)
+ }
+ return
+ }
+ var unbound *UnboundEnvelopeError
+ if !errors.As(err, &unbound) || unbound.Var != c.refused {
+ t.Fatalf("err = %v, want UnboundEnvelopeError for %s", err, c.refused)
+ }
+ after, _ := Get(ctx, s, "aaa", "shop")
+ if len(after.Vars) != len(before.Vars) || after.Vars["STRIPE_KEY"] != before.Vars["STRIPE_KEY"] {
+ t.Fatalf("a refused write changed the default bundle: %+v", after.Vars)
+ }
+ })
+ }
+}
diff --git a/internal/console/apiconfig.go b/internal/console/apiconfig.go
index c89f695f4..df30abf3e 100644
--- a/internal/console/apiconfig.go
+++ b/internal/console/apiconfig.go
@@ -247,10 +247,10 @@ func (s *Server) handleAPIConfigGet(w http.ResponseWriter, r *http.Request) {
// secrets_account is the account a secret for this app is bound to
// (appconfig.Binding), as the sqid this console resolved the request to;
// the CLI may only know the account by name. Its presence is how the CLI
- // learns to seal v2. For a fleet app it is always present, because a
- // fleet's envelopes are always v2. For a platform app it follows the
- // deployment switch (CONSOLE_SECRETS_ENVELOPE_V2): absent, the CLI seals
- // v1, which every box can open (discussion #220).
+ // learns to seal v2, and it is present for every app (hunt H3-M3: the
+ // config store refuses a new v1 envelope, which would open in any
+ // tenant's config). Only a console from before that omits it for a
+ // platform app, and the CLI then seals v1 (discussion #220).
//
// On a keyless fleet both are omitted and secrets_keyless_fleet names the
// caller's own fleet, so the CLI can name the fix (B8). Not a refusal:
@@ -275,13 +275,11 @@ func (s *Server) handleAPIConfigGet(w http.ResponseWriter, r *http.Request) {
case errors.Is(err, errNoDeploymentKey), errors.Is(err, errDeploymentKeyUnreadable):
// A platform app on a console without a usable key: the terminal's
// own CARLOS_SECRETS_PUBKEY is the only key, as before, and the
- // account still follows the switch.
+ // account is named all the same, so the CLI seals v2.
if errors.Is(err, errDeploymentKeyUnreadable) {
log.Printf("console: api config get %s/%s: %v", acct.Sqid, app, err)
}
- if appconfig.BoundSealing() {
- out["secrets_account"] = acct.Sqid
- }
+ out["secrets_account"] = acct.Sqid
default:
log.Printf("console: api config get %s/%s: seal key: %v", acct.Sqid, app, err)
jsonError(w, http.StatusBadGateway, "could not read the config — try again")
diff --git a/internal/console/apiconfig_test.go b/internal/console/apiconfig_test.go
index b9ccde7f0..aa26d58cf 100644
--- a/internal/console/apiconfig_test.go
+++ b/internal/console/apiconfig_test.go
@@ -269,29 +269,17 @@ func TestAPIConfigGetSecretsPubkey(t *testing.T) {
}
}
-// The GET names the account sqid a secret for this app is bound to — the
-// CLI may only know the account by name — and only while the deployment
-// writes bound (v2) envelopes: its presence is what makes the CLI seal v2,
-// so with CONSOLE_SECRETS_ENVELOPE_V2 off (the default) it must be absent
-// and the CLI keeps writing v1 that every box can open (discussion #220).
-func TestAPIConfigGetNamesTheSecretsAccountOnlyWhenV2IsOn(t *testing.T) {
+// The GET names the account sqid a secret for this app is bound to (the
+// CLI may only know the account by name), for every app: its presence is
+// what makes the CLI seal v2, and the config store refuses a new v1 envelope
+// (hunt H3-M3). It used to be absent unless CONSOLE_SECRETS_ENVELOPE_V2 was
+// on (discussion #220).
+func TestAPIConfigGetNamesTheSecretsAccount(t *testing.T) {
fx, token := configFixture(t, "code-config-secrets-account")
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
-
- appconfig.SetBoundSealing(false)
status, out := getJSON(t, configURL(fx, "titogo"), token)
if status != http.StatusOK {
t.Fatalf("GET = %d %v", status, out)
}
- if _, ok := out["secrets_account"]; ok {
- t.Fatalf("secrets_account served with bound sealing off: %v", out["secrets_account"])
- }
-
- appconfig.SetBoundSealing(true)
- status, out = getJSON(t, configURL(fx, "titogo"), token)
- if status != http.StatusOK {
- t.Fatalf("GET = %d %v", status, out)
- }
if got := str(t, out, "secrets_account"); got != release.OpsAccount {
t.Fatalf("secrets_account = %q, want %q", got, release.OpsAccount)
}
diff --git a/internal/console/apisystemhold_test.go b/internal/console/apisystemhold_test.go
index e6652763e..056bc1cae 100644
--- a/internal/console/apisystemhold_test.go
+++ b/internal/console/apisystemhold_test.go
@@ -157,12 +157,14 @@ func TestSystemHoldDoorWritesHoldsAndRefusesBadBoxes(t *testing.T) {
// holds into the promote's own pointer write, and refuses a bad box before
// any job starts.
//
-// The feed names a release at the holds floor: the fleet's boxes report no
-// layout and dark is stale, so a feed tag from before the instance layout
-// is refused as the resolved latest (hunt H6-M3) before any hold is judged.
+// The feed names the release the fleet's boxes run (SystemMovedAtFloor,
+// past the holds floor): the fleet's boxes report no layout and dark is
+// stale, so a feed tag from before the instance layout is refused as the
+// resolved latest (hunt H6-M3) before any hold is judged, and one below the
+// boxes' release is refused as a step back (hunt H3-M9).
func TestSystemUpdateWritesItsHoldsWithThePromote(t *testing.T) {
fx := newConsoleFixture(t)
- systemFeedTag(t, fx, release.SystemHoldsFloor, map[string][]byte{"carlos-linux-arm64": []byte("ELF arm64")})
+ systemFeedTag(t, fx, release.SystemMovedAtFloor, map[string][]byte{"carlos-linux-arm64": []byte("ELF arm64")})
owner := cliToken(t, fx, "paul@keymail.dev", "code-sys-update-hold")
updateHoldFleet(t, fx, release.SystemMovedAtFloor)
if st, out := postJSON(t, fx.ts.URL+"/api/cli/system/update", map[string]any{"channel": "stable", "holds": []string{"pi/dark"}}, owner); st != http.StatusConflict {
@@ -182,8 +184,8 @@ func TestSystemUpdateWritesItsHoldsWithThePromote(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if p.Current.Version != release.SystemHoldsFloor || len(p.Holds) != 2 {
- t.Fatalf("pointer %s holds %+v, want %s with pi/a and pi/b held", p.Current.Version, p.Holds, release.SystemHoldsFloor)
+ if p.Current.Version != release.SystemMovedAtFloor || len(p.Holds) != 2 {
+ t.Fatalf("pointer %s holds %+v, want %s with pi/a and pi/b held", p.Current.Version, p.Holds, release.SystemMovedAtFloor)
}
if h, _ := p.HoldFor("pi", "b"); h.Until.Sub(h.SetAt) != 90*time.Minute || h.SetBy != "paul@keymail.dev" {
t.Fatalf("pi/b hold = %+v", h)
@@ -439,9 +441,10 @@ func TestHoldWriteKeepsEveryHoldWhenTheCheckAfterCannotBeMade(t *testing.T) {
for _, door := range []string{"hold", "update"} {
t.Run(door, func(t *testing.T) {
fx := newConsoleFixture(t)
- // At the holds floor, not below the v0.44.0 the channel serves:
- // a resolved latest below it is refused (hunt H6-M3).
- systemFeedTag(t, fx, release.SystemHoldsFloor, map[string][]byte{"carlos-linux-arm64": []byte("ELF arm64")})
+ // The release the boxes run, not below the v0.44.0 the channel
+ // serves nor the boxes' v0.44.1: a resolved latest below either
+ // is refused (hunts H6-M3, H3-M9).
+ systemFeedTag(t, fx, release.SystemMovedAtFloor, map[string][]byte{"carlos-linux-arm64": []byte("ELF arm64")})
owner := cliToken(t, fx, "paul@keymail.dev", "code-sys-hold-keep-"+door)
updateHoldFleetWithPlat(t, fx, release.SystemMovedAtFloor, release.SystemMovedAtFloor)
ctx := context.Background()
diff --git a/internal/console/apisystemupdate.go b/internal/console/apisystemupdate.go
index 2cff9e1a5..9ce38a945 100644
--- a/internal/console/apisystemupdate.go
+++ b/internal/console/apisystemupdate.go
@@ -747,11 +747,30 @@ func (s *Server) runSystemUpdate(ctx context.Context, id string, job *systemJob,
// heartbeats, is the floor. A step back is still available, as the deliberate
// act it is: name the tag with --version, or run carlos system rollback.
//
-// A channel never promoted has no floor. A current version that does not
-// parse as a release (a local build promoted with --file) places nothing,
-// so a feed tag over it goes through: that is the dev-to-release move.
-// The layout floor is judged here too, for the tag the job resolved, since
-// the handler could judge only a named one.
+// The boxes on the channel are a floor too (hunt H3-M9): a channel never
+// promoted has no pointer, yet its boxes run a release, and a resolved tag
+// below the highest of them would move those boxes back. This holds even
+// for the tag the pointer already names: a re-promote stamps a new
+// PromotedAt, which a box reads as a fresh attempt, so after a typed step
+// back failed its gate on a box, an unsigned latest naming it again would
+// retry the downgrade (round 1). A tag equal to the highest box goes
+// through: it moves no box back, though lower boxes roll up to it.
+// Missing evidence never lowers the floor: an inventory that could not read
+// every report is refused, naming each prefix it could not read in full and
+// how many reports that prefix lists (highestChannelRelease).
+//
+// The box floor trades availability, never integrity. Box reports are not
+// signed by the console: an authenticated fleet box can write reports
+// anywhere under its fleet's prefix, naming any release and either channel,
+// and so can anyone who writes the deployment bucket. A false high report
+// can only refuse a resolved latest on that channel, never move one, and the
+// refusal names the box and the way past it, --version.
+//
+// A current version or a box release that does not parse as a release (a
+// local build promoted with --file) places nothing, so a feed tag over it
+// goes through: that is the dev-to-release move. The layout floor is judged
+// here too, for the tag the job resolved, since the handler could judge only
+// a named one.
func (s *Server) resolvedSystemLatestAllowed(ctx context.Context, component, channel, tag string) error {
cur, _, err := release.GetSystemPointer(ctx, s.cfg.Releases, s.cfg.ReleasePub, component, channel)
switch {
@@ -764,12 +783,107 @@ func (s *Server) resolvedSystemLatestAllowed(ctx context.Context, component, cha
tag, cur.Current.Version, component, channel)
}
}
+ box, running, incomplete, err := s.highestChannelRelease(ctx, channel)
+ if err != nil {
+ return fmt.Errorf("reading the boxes on %s before resolving the latest release: %w", channel, err)
+ }
+ if len(incomplete) > 0 {
+ return fmt.Errorf("could not read every box report (%s), so there is no telling whether %s would move a box on %s back; a resolved latest needs all of them. To promote it anyway name the release with --version",
+ strings.Join(incomplete, "; "), tag, channel)
+ }
+ if have, ok := release.ParseReleaseVersion(running); ok && release.BelowFloor(tag, have) {
+ return fmt.Errorf("the feed's latest.txt names %s, below the %s that box %s on %s already runs; a resolved latest never moves a box back. To step back on purpose name the release with --version",
+ tag, running, box, channel)
+ }
if reason := s.layoutDowngradeBlocked(ctx, tag); reason != "" {
return errors.New(reason)
}
return nil
}
+// highestChannelRelease is the box on channel running the highest release,
+// and that release; "" for both when no box on it reports one. incomplete
+// names each prefix whose reports could not all be read (a failed read, a
+// corrupt or oversize report, or a listing over status's key cap), with how
+// many reports it lists, for the operator to see which prefix and whether
+// it is the cap: the caller refuses on any, since the report it lost may be
+// the highest. A box that names no channel follows stable. Every report
+// counts, however old (loadBoxesUnaged, the same bounded read the pages
+// use, without the one-day listing horizon), until its box is
+// authoritatively gone: a fleet box its registry row holds detached, a
+// platform group member that has departed (activeStatusRows). A registry
+// whose fleets cannot be listed, or a fleet listing that fails, is an error.
+// A detached-row read that fails keeps every report, as
+// systemBoxesInventory does, which can only raise the floor.
+func (s *Server) highestChannelRelease(ctx context.Context, channel string) (box, running string, incomplete []string, err error) {
+ reg, fleets, err := s.systemFleets()
+ if err != nil {
+ return "", "", nil, fmt.Errorf("cannot list fleets: %w", err)
+ }
+ type read struct {
+ st release.Store
+ boxes []status.Box
+ complete bool
+ err error
+ }
+ reads := make([]read, 1+len(fleets))
+ forEachLimit(len(reads), readConcurrency, func(i int) {
+ st := s.cfg.Releases
+ if i > 0 {
+ st = release.NewPrefixStore(st, "fleets/"+fleets[i-1].Name+"/")
+ }
+ b, c, err := loadBoxesUnaged(ctx, st)
+ if err == nil && i > 0 {
+ detached, derr := detachedFleetBoxes(ctx, reg, fleets[i-1].Name)
+ if derr != nil {
+ log.Printf("console: latest floor: fleet %s registry boxes: %v; counting every report", fleets[i-1].Name, derr)
+ }
+ b = withoutDetached(b, detached)
+ }
+ reads[i] = read{st, b, c, err}
+ })
+ var top release.SemVer
+ for i, r := range reads {
+ fleet, where := "", "platform reports"
+ if i > 0 {
+ fleet = fleets[i-1].Name
+ where = "fleet " + fleet + " reports"
+ }
+ if r.err != nil {
+ if fleet == "" {
+ return "", "", nil, r.err
+ }
+ return "", "", nil, fmt.Errorf("fleet %s: %w", fleet, r.err)
+ }
+ if !r.complete {
+ // The refusal's diagnosis: one listing, on the refusal path only.
+ if keys, err := r.st.List(ctx, "status/boxes/"); err == nil {
+ where += fmt.Sprintf(": %d listed", len(keys))
+ }
+ incomplete = append(incomplete, where)
+ }
+ boxes := r.boxes
+ if i == 0 {
+ boxes = s.activeStatusRows(ctx, boxes)
+ }
+ for _, b := range boxes {
+ if b.Metrics == nil {
+ continue
+ }
+ follows := release.RungStable
+ if b.Metrics.SystemChannel != "" {
+ follows = b.Metrics.SystemChannel
+ }
+ v, ok := release.ParseReleaseVersion(b.Metrics.Release)
+ if follows != channel || !ok || (running != "" && v.Compare(top) <= 0) {
+ continue
+ }
+ top, running, box = v, b.Metrics.Release, release.SystemHoldBox(fleet, b.Label)
+ }
+ }
+ return box, running, incomplete, nil
+}
+
// systemPlatforms: the distinct platforms the fleet reports; linux-arm64
// when nothing has reported the field yet. STRICT — a fleet this console
// cannot enumerate stops the promote, because a platform silently left out
diff --git a/internal/console/apisystemupdate_latestboxes_test.go b/internal/console/apisystemupdate_latestboxes_test.go
new file mode 100644
index 000000000..29be1483f
--- /dev/null
+++ b/internal/console/apisystemupdate_latestboxes_test.go
@@ -0,0 +1,314 @@
+package console
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// The resolved-latest floor reads the boxes too (hunt H3-M9): a channel never
+// promoted has no pointer, but its boxes still run a release, and an unsigned
+// latest.txt below it must not move them back. Only boxes on the channel
+// count. The highest release the boxes run goes through (it moves no box
+// back; lower boxes still roll up to it); a newer one rolls; a typed
+// --version below them is still the operator's deliberate step back.
+func TestResolvedLatestFloorReadsTheChannelsBoxes(t *testing.T) {
+ fx := newConsoleFixture(t)
+ feed := newHuntFeed(t, fx)
+ for _, v := range []string{"v0.30.0", "v0.30.1", "v0.30.2"} {
+ feed.publish(v, map[string][]byte{"carlos-linux-arm64": []byte("ELF " + v + " arm64")})
+ }
+ seedFlatBox(t, fx, "ie", "linux-arm64", "canary", "v0.30.1")
+ seedFlatBox(t, fx, "us", "linux-arm64", "canary", "v0.30.0")
+ seedFlatBox(t, fx, "de", "linux-arm64", "stable", "v0.31.0") // another channel: no floor for canary
+ owner := cliToken(t, fx, "paul@keymail.dev", "code-hunt-m9b")
+ ctx := context.Background()
+ pointer := func() string {
+ p, _, err := release.GetSystemPointer(ctx, fx.rel, fx.pub, "router", "canary")
+ if err != nil {
+ return ""
+ }
+ return p.Current.Version
+ }
+
+ // Below the highest canary box, resolved by the console or confirmed by
+ // the CLI: refused, and nothing is written.
+ feed.setLatest("v0.30.0")
+ for _, body := range []map[string]any{
+ {"channel": "canary", "spread": "0s"},
+ {"channel": "canary", "version": "v0.30.0", "latest": true, "spread": "0s"},
+ } {
+ job := huntUpdate(t, fx, owner, body)
+ e, _ := job["error"].(string)
+ if !strings.Contains(e, "v0.30.0, below the v0.30.1 that box ie on canary already runs") || !strings.Contains(e, "--version") {
+ t.Fatalf("latest below the boxes (%v) = %q", body, e)
+ }
+ if v := pointer(); v != "" {
+ t.Fatalf("a refused latest wrote router/canary = %s", v)
+ }
+ }
+
+ // The release the highest box already runs: no box moves back, allowed.
+ feed.setLatest("v0.30.1")
+ if job := huntUpdate(t, fx, owner, map[string]any{"channel": "canary", "spread": "0s"}); job["error"] != "" {
+ t.Fatalf("latest equal to the boxes: %v", job)
+ }
+ if v := pointer(); v != "v0.30.1" {
+ t.Fatalf("pointer = %q, want v0.30.1", v)
+ }
+
+ // Typed, an older release is the operator's choice, boxes or not.
+ if job := huntUpdate(t, fx, owner, map[string]any{"channel": "canary", "version": "v0.30.0", "spread": "0s"}); job["error"] != "" {
+ t.Fatalf("a typed --version step back was refused: %v", job)
+ }
+ if v := pointer(); v != "v0.30.0" {
+ t.Fatalf("pointer after the typed step back = %q", v)
+ }
+
+ // The pointer's own release again, while box ie still runs v0.30.1 (its
+ // step back has not happened, or failed its gate and restored v0.30.1):
+ // a re-promote stamps a new PromotedAt, which a box reads as a fresh
+ // attempt, so an unsigned latest must not authorize it (H3-M9 round 1).
+ feed.setLatest("v0.30.0")
+ for _, body := range []map[string]any{
+ {"channel": "canary", "spread": "0s"},
+ {"channel": "canary", "version": "v0.30.0", "latest": true, "spread": "0s"},
+ } {
+ p0, _, _ := release.GetSystemPointer(ctx, fx.rel, fx.pub, "router", "canary")
+ job := huntUpdate(t, fx, owner, body)
+ if e, _ := job["error"].(string); !strings.Contains(e, "v0.30.0, below the v0.30.1 that box ie on canary already runs") {
+ t.Fatalf("latest equal to the pointer, a box still above it (%v) = %q", body, e)
+ }
+ if p1, _, _ := release.GetSystemPointer(ctx, fx.rel, fx.pub, "router", "canary"); !p1.PromotedAt.Equal(p0.PromotedAt) {
+ t.Fatalf("a refused re-promote restamped the pointer: %s -> %s", p0.PromotedAt, p1.PromotedAt)
+ }
+ }
+
+ // A newer latest rolls.
+ feed.setLatest("v0.30.2")
+ if job := huntUpdate(t, fx, owner, map[string]any{"channel": "canary", "spread": "0s"}); job["error"] != "" {
+ t.Fatalf("a newer latest: %v", job)
+ }
+ if v := pointer(); v != "v0.30.2" {
+ t.Fatalf("pointer = %q, want v0.30.2", v)
+ }
+}
+
+// incompleteWant is the refusal of a resolved latest when a box report on
+// the channel's inventory could not be read (H3-M9 round 1).
+const incompleteWant = "could not read every box report (%s), so there is no telling whether %s would move a box on %s back; a resolved latest needs all of them. To promote it anyway name the release with --version"
+
+// A box report the console cannot read is missing evidence, and missing
+// evidence never lowers the floor (H3-M9 round 1): the unreadable report
+// may be the box running the highest release. A platform report and a
+// fleet report, each under both request forms, are refused; nothing is
+// written. A typed --version still goes through.
+func TestResolvedLatestFloorRefusesAnIncompleteInventory(t *testing.T) {
+ fx := newConsoleFixture(t)
+ feed := newHuntFeed(t, fx)
+ feed.publish("v0.32.0", map[string][]byte{"carlos-linux-arm64": []byte("ELF v0.32.0 arm64")})
+ feed.setLatest("v0.32.0")
+ seedFlatBox(t, fx, "us", "linux-arm64", "canary", "v0.32.0")
+ seedFlatBox(t, fx, "ie", "linux-arm64", "canary", "v0.32.1")
+ reg := openTestReg(t, fx)
+ t.Cleanup(func() { reg.Close() })
+ if err := reg.UpsertFleet(registry.Fleet{Name: "pi", Account: fx.sqid, Bucket: "pi-bucket"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.AddFleetBox(registry.FleetBox{Fleet: "pi", Label: "a", TokenHash: strings.Repeat("a", 64)}); err != nil {
+ t.Fatal(err)
+ }
+ b := status.CollectBox(nil, status.Probes{Release: "v0.32.1", Platform: "linux-arm64", SystemChannel: "canary", Layout: &status.LayoutReport{Mode: "flat"}}, time.Now())
+ b.Label = "a"
+ if err := status.WriteBox(context.Background(), release.NewPrefixStore(fx.rel, "fleets/pi/"), b); err != nil {
+ t.Fatal(err)
+ }
+ ds := fx.rel.(*deletableStore)
+ owner := cliToken(t, fx, "paul@keymail.dev", "code-hunt-m9c")
+ for unreadable, where := range map[string]string{"status/boxes/ie.json": "platform reports: 2 listed", "fleets/pi/status/boxes/a.json": "fleet pi reports: 1 listed"} {
+ // The other v0.32.1 box is moved off canary, so the unreadable one
+ // is the only evidence above v0.32.0.
+ for _, k := range []string{"status/boxes/ie.json", "fleets/pi/status/boxes/a.json"} {
+ if k == unreadable {
+ continue
+ }
+ ds.setGetHook(nil)
+ raw, etag, err := fx.rel.Get(context.Background(), k)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.rel.Put(context.Background(), k, []byte(strings.Replace(string(raw), `"canary"`, `"stable"`, 1)), etag); err != nil {
+ t.Fatal(err)
+ }
+ }
+ ds.setGetHook(func(_ context.Context, key string) error {
+ if key == unreadable {
+ return errors.New("injected read failure")
+ }
+ return nil
+ })
+ for _, body := range []map[string]any{
+ {"channel": "canary", "spread": "0s"},
+ {"channel": "canary", "version": "v0.32.0", "latest": true, "spread": "0s"},
+ } {
+ job := huntUpdate(t, fx, owner, body)
+ if e, _ := job["error"].(string); e != fmt.Sprintf(incompleteWant, where, "v0.32.0", "canary") {
+ t.Fatalf("%s unreadable, %v = %q", unreadable, body, e)
+ }
+ if _, _, err := release.GetSystemPointer(context.Background(), fx.rel, fx.pub, "router", "canary"); err == nil {
+ t.Fatalf("%s unreadable: a refused latest wrote router/canary", unreadable)
+ }
+ }
+ // Put the moved box back on canary for the next round.
+ ds.setGetHook(nil)
+ for _, k := range []string{"status/boxes/ie.json", "fleets/pi/status/boxes/a.json"} {
+ raw, etag, err := fx.rel.Get(context.Background(), k)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.rel.Put(context.Background(), k, []byte(strings.Replace(string(raw), `"stable"`, `"canary"`, 1)), etag); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ // Typed, the operator's choice needs no inventory.
+ ds.setGetHook(func(_ context.Context, key string) error {
+ if key == "status/boxes/ie.json" {
+ return errors.New("injected read failure")
+ }
+ return nil
+ })
+ if job := huntUpdate(t, fx, owner, map[string]any{"channel": "canary", "version": "v0.32.0", "spread": "0s"}); job["error"] != "" {
+ t.Fatalf("a typed --version with a report unreadable: %v", job)
+ }
+}
+
+// A report not rewritten for more than a day still counts (H3-M9 round 1):
+// the status listing drops such objects as an optimisation, but a box still
+// enrolled may come back and read the channel, so its last release stays a
+// floor until it is detached or departs. The object's modification time is
+// aged past the horizon, not only its GeneratedAt.
+func TestResolvedLatestFloorCountsReportsOlderThanADay(t *testing.T) {
+ fx := newConsoleFixture(t)
+ feed := newHuntFeed(t, fx)
+ feed.publish("v0.30.0", map[string][]byte{"carlos-linux-arm64": []byte("ELF v0.30.0 arm64")})
+ feed.setLatest("v0.30.0")
+ seedFlatBox(t, fx, "us", "linux-arm64", "canary", "v0.30.0")
+ old := time.Now().Add(-3 * 24 * time.Hour)
+ b := status.CollectBox(nil, status.Probes{Release: "v0.30.1", Platform: "linux-arm64", SystemChannel: "canary", Layout: &status.LayoutReport{Mode: "flat"}}, old)
+ b.Label = "ie"
+ if err := status.WriteBox(context.Background(), fx.rel, b); err != nil {
+ t.Fatal(err)
+ }
+ ds := fx.rel.(*deletableStore)
+ if err := os.Chtimes(filepath.Join(ds.root, "status", "boxes", "ie.json"), old, old); err != nil {
+ t.Fatal(err)
+ }
+ owner := cliToken(t, fx, "paul@keymail.dev", "code-hunt-m9d")
+ for _, body := range []map[string]any{
+ {"channel": "canary", "spread": "0s"},
+ {"channel": "canary", "version": "v0.30.0", "latest": true, "spread": "0s"},
+ } {
+ job := huntUpdate(t, fx, owner, body)
+ if e, _ := job["error"].(string); !strings.Contains(e, "v0.30.0, below the v0.30.1 that box ie on canary already runs") {
+ t.Fatalf("a day-old v0.30.1 report, %v = %q", body, e)
+ }
+ if _, _, err := release.GetSystemPointer(context.Background(), fx.rel, fx.pub, "router", "canary"); err == nil {
+ t.Fatal("a refused latest wrote router/canary")
+ }
+ }
+}
+
+// readCountingStore records, per key, the most bytes any one read of it
+// consumed: a Get counts its whole body, an Open what was read through it.
+type readCountingStore struct {
+ release.Store
+ mu sync.Mutex
+ most map[string]int64
+}
+
+func (c *readCountingStore) note(key string, n int64) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ if n > c.most[key] {
+ c.most[key] = n
+ }
+}
+
+func (c *readCountingStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ b, etag, err := c.Store.Get(ctx, key)
+ c.note(key, int64(len(b)))
+ return b, etag, err
+}
+
+func (c *readCountingStore) Open(ctx context.Context, key string) (io.ReadCloser, string, error) {
+ rc, etag, err := release.OpenObject(ctx, c.Store, key)
+ if err != nil {
+ return nil, "", err
+ }
+ return &countingReadCloser{ReadCloser: rc, done: func(n int64) { c.note(key, n) }}, etag, nil
+}
+
+type countingReadCloser struct {
+ io.ReadCloser
+ n int64
+ done func(int64)
+}
+
+func (r *countingReadCloser) Read(p []byte) (int, error) {
+ n, err := r.ReadCloser.Read(p)
+ r.n += int64(n)
+ r.done(r.n)
+ return n, err
+}
+
+// An oversized box report refuses the resolved latest (an incomplete
+// inventory) without the floor ever reading it past the box-report cap and
+// one byte (H3-M9 round 2): a fleet box writes its own reports, and a read
+// that takes a whole object before judging its size is memory a box
+// chooses. A platform report and a fleet report, both oversized, are each
+// read no further than the cut; the refusal names each prefix and its count.
+func TestResolvedLatestFloorReadsOversizedReportsOnlyToTheCap(t *testing.T) {
+ fx := newConsoleFixture(t)
+ ds := fx.rel.(*deletableStore)
+ ds.streams.Store(true)
+ reg := openTestReg(t, fx)
+ t.Cleanup(func() { reg.Close() })
+ if err := reg.UpsertFleet(registry.Fleet{Name: "pi", Account: fx.sqid, Bucket: "pi-bucket"}); err != nil {
+ t.Fatal(err)
+ }
+ const huge = 8 * boxReportCap
+ keys := []string{"status/boxes/huge.json", "fleets/pi/status/boxes/huge.json"}
+ for _, k := range keys {
+ if _, err := fx.rel.Put(context.Background(), k, boxReportOfSize(t, "huge", huge), ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+ seedFlatBox(t, fx, "us", "linux-arm64", "canary", "v0.30.0")
+ counted := &readCountingStore{Store: fx.srv.cfg.Releases, most: map[string]int64{}}
+ fx.srv.cfg.Releases = counted
+ _, _, incomplete, err := fx.srv.highestChannelRelease(context.Background(), "canary")
+ if err != nil || len(incomplete) != 2 {
+ t.Fatalf("an oversized report: incomplete %q, err %v; want both prefixes incomplete", incomplete, err)
+ }
+ for _, k := range keys {
+ if got := counted.most[k]; got == 0 || got > boxReportCap+1 {
+ t.Errorf("%s: one read consumed %d bytes of a %d-byte report; want it cut at %d", k, got, huge, boxReportCap+1)
+ }
+ }
+ err = fx.srv.resolvedSystemLatestAllowed(context.Background(), "router", "canary", "v0.30.0")
+ if err == nil || !strings.Contains(err.Error(), "platform reports: 2 listed") || !strings.Contains(err.Error(), "fleet pi reports: 1 listed") {
+ t.Fatalf("refusal = %v, want each incomplete prefix named with its count", err)
+ }
+}
diff --git a/internal/console/configwrite.go b/internal/console/configwrite.go
index a942d111e..dc1695e03 100644
--- a/internal/console/configwrite.go
+++ b/internal/console/configwrite.go
@@ -9,8 +9,9 @@
// JSON door's exact status and sentence (byte-identical to what that door
// has always answered) and a closed code another door can render in its
// own words. Every refusal still comes back before the first store call;
-// the only store-shaped refusals (conflict, nothing-to-remove, store) are
-// the write's own outcome.
+// the only store-shaped refusals (conflict, nothing-to-remove, store, and
+// sealed-old for a v1 envelope the store will not take) are the write's own
+// outcome.
//
// NOTHING IN A REFUSAL OR A LOG LINE CARRIES CONTENT. Var names appear
// (the caller has to learn which var was refused, and names are not
@@ -274,6 +275,17 @@ func (s *Server) configWriteStore(ctx context.Context, unlock func(), acct *Acco
// environment gets (§3, §4), with no log line.
return 0, &configRefusal{Code: configRefusalNotFound, Status: http.StatusNotFound, Msg: notFoundBody}
}
+ var unbound *appconfig.UnboundEnvelopeError
+ if errors.As(err, &unbound) {
+ // The store's refusal of a v1 envelope that is not already the
+ // value in that slot (hunt H3-M3): one opens in any tenant's
+ // config, so it is either a copy or the work of a CLI from before
+ // every seal was v2. configCheckSealedTo words the same case for an app
+ // on a fleet. It is the config store that refuses, not the boxes:
+ // they still open the v1 envelopes already stored.
+ k := unbound.Var
+ return 0, badConfig(configRefusalSealedOld, k, fmt.Sprintf("%s was sealed in an older format that %s's config no longer accepts. upgrade the carlos CLI and set %s again", k, app, k))
+ }
var fromErr *envFromError
if errors.As(err, &fromErr) {
// The environment was written; a switched app's From was not
diff --git a/internal/console/envform_test.go b/internal/console/envform_test.go
index fa9345db2..34ca4e076 100644
--- a/internal/console/envform_test.go
+++ b/internal/console/envform_test.go
@@ -136,7 +136,8 @@ func (e *envFx) seal(t *testing.T, plaintext string) string {
if err != nil {
t.Fatal(err)
}
- env, err := appconfig.SealUnbound(pub, []byte(plaintext))
+ // v2, as the page's script seals it (data-seal-version="2").
+ env, err := appconfig.SealBound(pub, appconfig.Binding{Account: e.fx.sqid, App: "shop"}, []byte(plaintext))
if err != nil {
t.Fatal(err)
}
@@ -592,33 +593,19 @@ func TestEnvSealAttributes(t *testing.T) {
return envFields(t, body).Get("sealed_to")
}
- t.Run("platform app v1", func(t *testing.T) {
- appconfig.SetBoundSealing(false)
+ t.Run("platform app", func(t *testing.T) {
e := newEnvFx(t)
body := e.page(t)
a := formTag(t, body)
fp, _ := appconfig.PublicFingerprint(e.pub)
- if a["data-seal-pub"] != e.pub || a["data-seal-version"] != "1" || sealedTo(t, body) != fp {
- t.Fatalf("form = %v sealed_to %q, want v1 to the deployment key %s", a, sealedTo(t, body), fp)
- }
- if _, ok := a["data-account"]; ok {
- t.Fatalf("v1 form carries data-account: %v", a)
+ if a["data-seal-pub"] != e.pub || a["data-seal-version"] != "2" || a["data-account"] != e.fx.sqid || a["data-app"] != "shop" || sealedTo(t, body) != fp {
+ t.Fatalf("form = %v sealed_to %q, want v2 bound to %s/shop, to the deployment key %s", a, sealedTo(t, body), e.fx.sqid, fp)
}
if a["data-msg-chars"] != envCopyDraft.MsgChars || a["data-msg-changed"] != envCopyDraft.MsgChanged {
t.Fatalf("the script's refusals are not the copy's: %v", a)
}
})
- t.Run("platform app v2", func(t *testing.T) {
- appconfig.SetBoundSealing(true)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
- e := newEnvFx(t)
- a := formTag(t, e.page(t))
- if a["data-seal-version"] != "2" || a["data-account"] != e.fx.sqid || a["data-app"] != "shop" {
- t.Fatalf("form = %v, want v2 bound to %s/shop", a, e.fx.sqid)
- }
- })
t.Run("fleet app", func(t *testing.T) {
- appconfig.SetBoundSealing(false)
fx, _, k := skFleetShop(t, "code-env-fleet", true)
c := signInPaul(t, fx)
_, _, body := get(t, c, fx.u("/apps/shop/settings/environments"))
@@ -706,8 +693,6 @@ func TestEnvFormChromium(t *testing.T) {
t.Skip("no installed headless browser")
}
node := nodeOrSkip(t)
- appconfig.SetBoundSealing(true)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
e := newEnvFx(t)
if _, err := appconfig.ApplyEnvironment(context.Background(), e.fx.rel, e.fx.sqid, "shop", "staging",
map[string]appconfig.Var{"LOG_LEVEL": {Kind: "env", Value: "debug"}}, nil); err != nil {
diff --git a/internal/console/envsave_test.go b/internal/console/envsave_test.go
index 4b7bdb3a1..54a5d0270 100644
--- a/internal/console/envsave_test.go
+++ b/internal/console/envsave_test.go
@@ -261,7 +261,6 @@ func TestEnvSaveRefusalsPersonCopy(t *testing.T) {
// sealed bound; a keyless fleet takes none.
fleet := func(t *testing.T, code string, withKey bool, edit func(url.Values, skFleetKey, *consoleFixture)) (int, string, *consoleFixture) {
t.Helper()
- appconfig.SetBoundSealing(false)
fx, _, k := skFleetShop(t, code, withKey)
c := signInPaul(t, fx)
_, _, page := get(t, c, fx.u("/apps/shop/settings/environments"))
@@ -316,7 +315,6 @@ func TestEnvSaveRefusalsPersonCopy(t *testing.T) {
}
func TestEnvSaveSealedToChecked(t *testing.T) {
- appconfig.SetBoundSealing(false)
fx, _, k := skFleetShop(t, "code-envsave-sealedto", true)
c := signInPaul(t, fx)
_, _, page := get(t, c, fx.u("/apps/shop/settings/environments"))
diff --git a/internal/console/fleetsecrets_mint_test.go b/internal/console/fleetsecrets_mint_test.go
index f2917fafa..65e127a72 100644
--- a/internal/console/fleetsecrets_mint_test.go
+++ b/internal/console/fleetsecrets_mint_test.go
@@ -48,8 +48,6 @@ func fcmFleetShop(t *testing.T, code string, withKey bool) *fcmWorld {
skRegister(t, fx, token, "home", k)
}
fskPlaceShop(t, fx, token, "home")
- appconfig.SetBoundSealing(false)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
return &fcmWorld{fx: fx, token: token, fleet: k, depPriv: dep.priv}
}
@@ -378,8 +376,7 @@ func TestTeamEnvironmentCreateOnFleetDoesNotDeadlock(t *testing.T) {
}
// consoleTestSealer is the sealer a test hands a walk or a delivery helper
-// directly: pub for acct/app, bound as the deployment switch says, which
-// is what those took before they took a sealer.
+// directly: pub for acct/app, bound as every sealer is.
func consoleTestSealer(pub *ecdh.PublicKey, acct, app string) appconfig.Sealer {
- return appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: app}, appconfig.BoundSealing())
+ return appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: app}, true)
}
diff --git a/internal/console/fleetsecrets_relay_test.go b/internal/console/fleetsecrets_relay_test.go
index fbe67f6c1..287dc202f 100644
--- a/internal/console/fleetsecrets_relay_test.go
+++ b/internal/console/fleetsecrets_relay_test.go
@@ -303,8 +303,6 @@ func fsrLegacyShop(t *testing.T, code string, withKey bool) (*fcmWorld, *objstor
if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil {
t.Fatal(err)
}
- appconfig.SetBoundSealing(false)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
w := &fcmWorld{fx: fx, token: token, fleet: k, depPriv: dep.priv}
fake := w.armStore(t, "shop")
if status, out := postJSON(t, storeURL(fx, "shop")+"/grant", map[string]any{}, token); status != http.StatusOK {
@@ -606,8 +604,6 @@ func fsrRelayPlatformShop(t *testing.T, code string, withKey bool) *fcmWorld {
if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil {
t.Fatal(err)
}
- appconfig.SetBoundSealing(false)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
fx.srv.cfg.RelayRegions = []string{"eu-west-1"}
fx.srv.cfg.PlatformDomain = "oncarlos.com"
t.Setenv(relayMastersEnv("eu-west-1"), "k1:"+relayTestMaster(1))
diff --git a/internal/console/hotreads.go b/internal/console/hotreads.go
index 343969935..7546f3741 100644
--- a/internal/console/hotreads.go
+++ b/internal/console/hotreads.go
@@ -388,18 +388,45 @@ func boxReportKeyLimit(key string) int64 {
// skips and the same completeness. "{}" decodes to an empty report, which
// LoadBoxesComplete keeps without logging.
func loadBoxesConcurrently(ctx context.Context, st release.Store) ([]status.Box, bool, error) {
+ return loadBoxesBounded(ctx, st, false)
+}
+
+// loadBoxesUnaged is loadBoxesConcurrently without the status listing's
+// one-day horizon: every report listed is read, however long ago it was
+// written (the resolved-latest floor, hunt H3-M9). Only the listing changes.
+// unagedStore wraps the prefetch store inside the read, so the horizon's
+// ListMod is hidden from status alone, while every body is still read by
+// the prefetch through the real store's Open, cut at boxReportCap and one
+// byte (round 2: wrapping the real store instead would hide its Open too,
+// and OpenObject would fall back to a whole-object Get).
+func loadBoxesUnaged(ctx context.Context, st release.Store) ([]status.Box, bool, error) {
+ return loadBoxesBounded(ctx, st, true)
+}
+
+func loadBoxesBounded(ctx context.Context, st release.Store, unaged bool) ([]status.Box, bool, error) {
type out struct {
boxes []status.Box
complete bool
err error
}
o := readConcurrently(ctx, st, []byte("{}"), boxReportLimit, func(s release.Store) out {
+ if unaged {
+ s = unagedStore{s}
+ }
b, c, err := status.LoadBoxesComplete(ctx, s)
return out{b, c, err}
})
return o.boxes, o.complete, o.err
}
+// unagedStore hides a store's ListMod, so status.LoadBoxesComplete lists
+// every report rather than only those written in the last day (status's
+// statusListingHorizon, which lists whole a store that is not a
+// release.ModLister). It hides every other optional method too, Open among
+// them, so it wraps only the prefetch store, whose Get is the bounded read
+// (loadBoxesUnaged); never a store whose Get reads whole objects.
+type unagedStore struct{ release.Store }
+
// readEdgesSnapshotConcurrently is readEdgesSnapshot with the edges files
// read concurrently: the same listing, files and skips. The dry body is
// the smallest versioned edges file naming the box its key names, which
diff --git a/internal/console/hunt_H3-M9_test.go b/internal/console/hunt_H3-M9_test.go
new file mode 100644
index 000000000..e1445f420
--- /dev/null
+++ b/internal/console/hunt_H3-M9_test.go
@@ -0,0 +1,34 @@
+package console
+
+import (
+ "context"
+ "net/http"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// hunt H3-M9 (Opus verifier). The fleet already reports v0.19.0. Whoever
+// controls latest.txt (apt.carlosframework.com) serves "v0.18.0", a real,
+// correctly signed older release; Latest (publicrelease/feed.go:67) checks only
+// the tag's shape. The operator runs `carlos system update` with no version,
+// and runSystemUpdate (apisystemupdate.go:485) promotes whatever latest.txt
+// named: layoutDowngradeBlocked runs only for a NAMED version
+// (apisystemupdate.go:378). SECURE: "latest" never resolves to a release older
+// than the one the channel's boxes already run.
+func TestHunt_H3_M9_UnsignedLatestPushesADowngrade(t *testing.T) {
+ fx := newConsoleFixture(t)
+ systemFeed(t, fx, map[string][]byte{"carlos-linux-arm64": []byte("ELF arm64 v0.18.0")}) // latest.txt says v0.18.0
+ seedBox(t, fx, "ie", "linux-arm64", "canary", "v0.19.0")
+ owner := cliToken(t, fx, "paul@keymail.dev", "code-hunt-m9")
+ st, out := postJSON(t, fx.ts.URL+"/api/cli/system/update", map[string]any{"channel": "canary"}, owner)
+ if st != http.StatusOK {
+ t.Fatalf("update = %d %v", st, out)
+ }
+ job := waitJob(t, fx, owner, str(t, out, "job"))
+ p, _, err := release.GetSystemPointer(context.Background(), fx.rel, fx.pub, "router", "canary")
+ if err == nil && p.Current.Version == "v0.18.0" {
+ t.Fatalf("H3-M9: with every box on v0.19.0, an unsigned latest.txt made the console point router/canary at %s (job %v)",
+ p.Current.Version, job)
+ }
+}
diff --git a/internal/console/hunt_h3m3_test.go b/internal/console/hunt_h3m3_test.go
new file mode 100644
index 000000000..268b8ca91
--- /dev/null
+++ b/internal/console/hunt_h3m3_test.go
@@ -0,0 +1,78 @@
+package console
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/appconfig"
+)
+
+// hunt H3-M3 at the console's config doors. A v1 envelope already stored in
+// shop's config (written before every seal was v2) opens under any binding.
+// Someone who can read the bucket copies it into an app they can write
+// (blog): the JSON door the CLI uses, and writeConfig, the settings form's
+// door, both refuse it by name before anything is stored. Sent back
+// unchanged into its own slot it is accepted, so a client that round-trips
+// a stored value loses nothing.
+//
+// Mutation-mindedness: drop checkUnboundSets from appconfig's write and
+// both copies are stored (the JSON door answers 200).
+func TestHunt_H3_M3_ConfigDoorsRefuseACopiedV1Envelope(t *testing.T) {
+ fx, token, _ := fskFixture(t, "code-h3m3-door")
+ for _, app := range []string{"shop", "blog"} {
+ if _, err := fx.st.CreateAppIn(OpsAccountID, app, "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ depPub, depFP := mustTestSecretsKey()
+ pub, err := appconfig.ParsePublicKey(depPub, "test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ legacy, err := appconfig.SealUnbound(pub, []byte("shop-live-key"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ body, err := json.Marshal(appconfig.Manifest{Schema: 1, App: "shop", Vars: map[string]appconfig.Var{
+ "STRIPE_KEY": {Kind: "secret", Envelope: legacy, SealedTo: depFP},
+ }})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.rel.Put(context.Background(), appconfig.Key(fx.sqid, "shop"), body, ""); err != nil {
+ t.Fatal(err)
+ }
+
+ secret := map[string]string{"kind": "secret", "envelope": legacy, "sealed_to": depFP}
+ status, out := putJSON(t, configURL(fx, "blog"), map[string]any{"set": map[string]any{"LOOT": secret}}, token)
+ want := "LOOT was sealed in an older format that blog's config no longer accepts. upgrade the carlos CLI and set LOOT again"
+ if status != http.StatusBadRequest || out["error"] != want {
+ t.Fatalf("JSON door copy into blog = %d %v, want 400 %q", status, out, want)
+ }
+ acct, err := fx.st.AccountBySqid(fx.sqid)
+ if err != nil || acct == nil {
+ t.Fatalf("account: %v %v", acct, err)
+ }
+ _, ref := fx.srv.writeConfig(context.Background(), acct, "blog", "staging", nil,
+ map[string]configVarIn{"LOOT": {Kind: "secret", Envelope: legacy, SealedTo: depFP}}, nil)
+ if ref == nil || ref.Code != configRefusalSealedOld || ref.Var != "LOOT" {
+ t.Fatalf("form door copy into blog staging = %+v, want sealed-old for LOOT", ref)
+ }
+ if m, err := appconfig.Get(context.Background(), fx.rel, fx.sqid, "blog"); err != nil || len(m.Vars) != 0 {
+ t.Fatalf("blog's config after the refusals = %+v, %v; want nothing stored", m, err)
+ }
+ if _, _, found, err := appconfig.GetEnvironment(context.Background(), fx.rel, fx.sqid, "blog", "staging"); err != nil || found {
+ t.Fatalf("blog staging after the refusal: found %v, %v; want no bundle", found, err)
+ }
+
+ status, out = putJSON(t, configURL(fx, "shop"), map[string]any{"set": map[string]any{"STRIPE_KEY": secret}}, token)
+ if status != http.StatusOK {
+ t.Fatalf("unchanged in its own slot = %d %v, want 200", status, out)
+ }
+ if got := skStored(t, fx).Vars["STRIPE_KEY"].Envelope; got != legacy {
+ t.Fatal("shop's legacy envelope changed")
+ }
+}
diff --git a/internal/console/sealkey.go b/internal/console/sealkey.go
index e7ec9f29b..78b9d8f02 100644
--- a/internal/console/sealkey.go
+++ b/internal/console/sealkey.go
@@ -132,7 +132,7 @@ func (s *Server) chooseSealKey(ctx context.Context, acctSqid, app string) (sealC
if err != nil {
return sealChoice{}, err
}
- return sealChoice{sqid: acct.Sqid, pub: pub, bound: appconfig.BoundSealing()}, nil
+ return sealChoice{sqid: acct.Sqid, pub: pub, bound: true}, nil
}
if row.SecretsPub == "" {
return sealChoice{}, errFleetNoSecretsKey{Fleet: name}
@@ -146,7 +146,7 @@ func (s *Server) chooseSealKey(ctx context.Context, acctSqid, app string) (sealC
// not written by it, and its key is not the one registered.
return sealChoice{}, fmt.Errorf("console: seal key: fleet %s's key is %s but its row records %s", name, fp, row.SecretsKeyFP)
}
- // Fleet-key envelopes are always v2, whatever the deployment switch says.
+ // Envelopes are always v2, fleet key or deployment key (hunt H3-M3).
return sealChoice{sqid: acct.Sqid, pub: pub, bound: true, fleet: name}, nil
}
diff --git a/internal/console/sealkey_test.go b/internal/console/sealkey_test.go
index 4242a430d..5ba75840e 100644
--- a/internal/console/sealkey_test.go
+++ b/internal/console/sealkey_test.go
@@ -107,8 +107,6 @@ func skStored(t *testing.T, fx *consoleFixture) *appconfig.Manifest {
func TestSealKeyForFleetApp(t *testing.T) {
fx, _, k := skFleetShop(t, "code-sk-fleet", true)
- appconfig.SetBoundSealing(false)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
sl, err := fx.srv.sealKeyFor(context.Background(), fx.sqid, "shop")
if err != nil {
@@ -117,9 +115,8 @@ func TestSealKeyForFleetApp(t *testing.T) {
if sl.Fingerprint() != k.fp || sl.PublicKeyB64() != k.pub {
t.Fatalf("sealer key = %s, want home's %s", sl.Fingerprint(), k.fp)
}
- // Fleet-key envelopes are always v2, whatever the deployment switch says.
if !sl.Bound() {
- t.Fatal("a fleet sealer is unbound with the deployment switch off")
+ t.Fatal("a fleet sealer is unbound")
}
b := appconfig.Binding{Account: fx.sqid, App: "shop"}
if sl.Binding() != b {
@@ -144,19 +141,16 @@ func TestSealKeyForPlatformApp(t *testing.T) {
t.Fatal(err)
}
depPub, depFP := mustTestSecretsKey()
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
- for _, on := range []bool{false, true} {
- appconfig.SetBoundSealing(on)
- sl, err := fx.srv.sealKeyFor(context.Background(), fx.sqid, "shop")
- if err != nil {
- t.Fatalf("switch %v: sealKeyFor = %v", on, err)
- }
- if sl.Fingerprint() != depFP || sl.PublicKeyB64() != depPub {
- t.Fatalf("switch %v: sealer = %s, want the deployment key %s", on, sl.Fingerprint(), depFP)
- }
- if sl.Bound() != on {
- t.Fatalf("switch %v: Bound = %v, want the deployment switch", on, sl.Bound())
- }
+ sl, err := fx.srv.sealKeyFor(context.Background(), fx.sqid, "shop")
+ if err != nil {
+ t.Fatalf("sealKeyFor = %v", err)
+ }
+ if sl.Fingerprint() != depFP || sl.PublicKeyB64() != depPub {
+ t.Fatalf("sealer = %s, want the deployment key %s", sl.Fingerprint(), depFP)
+ }
+ // Bound, as every sealer is (hunt H3-M3).
+ if !sl.Bound() {
+ t.Fatal("the deployment sealer is unbound")
}
// Today's refusals: no deployment key, and one that does not parse.
@@ -249,8 +243,6 @@ func TestSealKeyForOtherAccountsFleetRefuses(t *testing.T) {
func TestConfigGetServesTheFleetKey(t *testing.T) {
fx, token, k := skFleetShop(t, "code-sk-get", true)
- appconfig.SetBoundSealing(false)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
status, out := getJSON(t, configURL(fx, "shop"), token)
if status != http.StatusOK {
@@ -261,7 +253,7 @@ func TestConfigGetServesTheFleetKey(t *testing.T) {
}
// Always for a fleet app: its envelopes are always v2.
if out["secrets_account"] != fx.sqid {
- t.Fatalf("secrets_account = %v, want %s with the switch off", out["secrets_account"], fx.sqid)
+ t.Fatalf("secrets_account = %v, want %s", out["secrets_account"], fx.sqid)
}
if _, ok := out["secrets_keyless_fleet"]; ok {
t.Fatalf("secrets_keyless_fleet = %v on a fleet with a key", out["secrets_keyless_fleet"])
@@ -273,15 +265,14 @@ func TestConfigGetServesTheFleetKey(t *testing.T) {
if status != http.StatusOK || out["secrets_pubkey"] != depPub {
t.Fatalf("platform GET = %d %v, want the deployment key", status, out)
}
- if _, ok := out["secrets_account"]; ok {
- t.Fatalf("platform secrets_account = %v with the switch off", out["secrets_account"])
+ // Named for a platform app too: every seal is v2 (hunt H3-M3).
+ if out["secrets_account"] != fx.sqid {
+ t.Fatalf("platform secrets_account = %v, want %s", out["secrets_account"], fx.sqid)
}
}
func TestConfigGetOmitsKeyOnKeylessFleet(t *testing.T) {
fx, token, _ := skFleetShop(t, "code-sk-get-keyless", false)
- appconfig.SetBoundSealing(true)
- t.Cleanup(func() { appconfig.SetBoundSealing(false) })
if err := appconfig.SetEnv(context.Background(), fx.rel, fx.sqid, "shop", map[string]string{"PORT": "8080"}); err != nil {
t.Fatal(err)
}
@@ -378,11 +369,11 @@ func TestConfigPutAcceptsOldCLIOnPlatformApp(t *testing.T) {
depPub, depFP := mustTestSecretsKey()
// An older CLI: no sealed_to. Accepted, and stored without one.
- if status, out := skPutSecret(t, fx, token, "OLD", skSeal(t, fx, depPub, false), ""); status != http.StatusOK {
+ if status, out := skPutSecret(t, fx, token, "OLD", skSeal(t, fx, depPub, true), ""); status != http.StatusOK {
t.Fatalf("old CLI PUT = %d %v", status, out)
}
// This CLI: sealed_to the deployment key. Accepted and kept.
- if status, out := skPutSecret(t, fx, token, "NEW", skSeal(t, fx, depPub, false), depFP); status != http.StatusOK {
+ if status, out := skPutSecret(t, fx, token, "NEW", skSeal(t, fx, depPub, true), depFP); status != http.StatusOK {
t.Fatalf("new CLI PUT = %d %v", status, out)
}
m := skStored(t, fx)
@@ -391,7 +382,7 @@ func TestConfigPutAcceptsOldCLIOnPlatformApp(t *testing.T) {
}
// Present and not the deployment key: refused.
other := skNewKey(t)
- status, out := skPutSecret(t, fx, token, "WRONG", skSeal(t, fx, other.pub, false), other.fp)
+ status, out := skPutSecret(t, fx, token, "WRONG", skSeal(t, fx, other.pub, true), other.fp)
want := "WRONG was sealed to a key that this app's boxes do not hold. unset CARLOS_SECRETS_PUBKEY in your terminal and set WRONG again"
if status != http.StatusBadRequest || out["error"] != want {
t.Fatalf("PUT = %d %v, want 400 %q", status, out, want)
@@ -403,7 +394,7 @@ func TestConfigPutAcceptsOldCLIOnPlatformApp(t *testing.T) {
// A console with no deployment key has nothing to compare: accepted, as
// today (the terminal's own key is the only one there is).
fx.srv.cfg.SecretsPub = ""
- if status, out := skPutSecret(t, fx, token, "TERMINAL", skSeal(t, fx, other.pub, false), other.fp); status != http.StatusOK {
+ if status, out := skPutSecret(t, fx, token, "TERMINAL", skSeal(t, fx, other.pub, true), other.fp); status != http.StatusOK {
t.Fatalf("no deployment key PUT = %d %v", status, out)
}
}
diff --git a/internal/host/replicahomekeys_test.go b/internal/host/replicahomekeys_test.go
index 68873fa21..5d24835e7 100644
--- a/internal/host/replicahomekeys_test.go
+++ b/internal/host/replicahomekeys_test.go
@@ -123,7 +123,7 @@ func TestConfiguredKeyReadsTheBucketNow(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- envelope, err := appconfig.SealUnbound(pub, []byte("x"))
+ envelope, err := appconfig.SealBound(pub, appconfig.Binding{Account: "acct", App: "shop"}, []byte("x"))
if err != nil {
t.Fatal(err)
}
diff --git a/internal/mail/sealer_helper_test.go b/internal/mail/sealer_helper_test.go
index 5b26b2099..3eef1e00c 100644
--- a/internal/mail/sealer_helper_test.go
+++ b/internal/mail/sealer_helper_test.go
@@ -10,5 +10,5 @@ import (
// 6): pub for acct/app, bound or not as the deployment switch says, which is
// what appconfig.Seal chose before the walks took a sealer.
func mailTestSealer(pub *ecdh.PublicKey, acct, app string) appconfig.Sealer {
- return appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: app}, appconfig.BoundSealing())
+ return appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: app}, true)
}
diff --git a/internal/moves/archive/seal.go b/internal/moves/archive/seal.go
index a4a2c5c92..e7f5372a3 100644
--- a/internal/moves/archive/seal.go
+++ b/internal/moves/archive/seal.go
@@ -47,9 +47,8 @@ func nonceFor(index uint64, last bool) ([]byte, []byte) {
// Seal encrypts plain into w under a fresh 256-bit data key and returns
// the data key sealed with appconfig.SealBound (a v2 envelope bound to b,
// with its own fresh ephemeral key and nonce) and the sha256 of what it
-// wrote. Never deterministic. SealBound, not appconfig.Seal: Seal writes
-// unbound v1 envelopes unless the process turned bound sealing on, and the
-// host agent never does (F4).
+// wrote. Never deterministic. SealBound by name (F4): when this was written
+// appconfig.Seal still wrote unbound v1 envelopes by default.
func Seal(plain io.Reader, pub *ecdh.PublicKey, b appconfig.Binding, w io.Writer) (sealedDataKey, sealedSHA string, err error) {
key := make([]byte, 32)
if _, err := rand.Read(key); err != nil {
diff --git a/internal/objstore/walk_test.go b/internal/objstore/walk_test.go
index f05c7265f..8a1a11a8a 100644
--- a/internal/objstore/walk_test.go
+++ b/internal/objstore/walk_test.go
@@ -38,7 +38,7 @@ func testSealKeypair(t *testing.T) (*ecdh.PrivateKey, *ecdh.PublicKey) {
// 6): pub for acct/app, bound or not as the deployment switch says, which is
// what appconfig.Seal chose before the walks took a sealer.
func storeTestSealer(pub *ecdh.PublicKey, acct, app string) appconfig.Sealer {
- return appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: app}, appconfig.BoundSealing())
+ return appconfig.NewSealer(pub, appconfig.Binding{Account: acct, App: app}, true)
}
// failingStore fails the FIRST Put to failKeyOnce, then behaves normally —
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 07e531ff2..98bf34d05 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -316,4 +316,6 @@ plan14-root-reads-catchall-stamp-now.tsv c9940b1b6fb0146a30a2fb2b557f898ac6d28ba
plan14-root-reads-gvisor-followups.tsv bf71949458c3c44c86b778a2a3e0d0b352268f5640c28b6b5d2f25bc2a5318b2
plan14-root-reads-instance-usage.tsv e3c8bc6a560e863ed44c7ab2f9367a4347ec767d8da2c3b1f1eafc90e45c89e8
plan14-root-reads-sec-h5-m8-fleet-hostnames.tsv a6a19c800d55f99ed1c70068e38ffa66aef7af8f55199e97e986d9bbb0e0d80d
-plan14-root-reads-sec-h3-m2-scoped-key.tsv 0a86ee3c77d0bf54a8c723bf5cd5eab440d556f7fc66d0eb2888063c85e42404
+plan14-root-reads-infra-floor-keys-deny.tsv 3d13ade9d1fce3bc1a7d7250d75f2cc5ea3563ca6426401f428ca3a86af19619
+plan14-root-reads-sec-h3-m3-envelope.tsv 76f69ece310924c374511605d0f6c718464d6374292961ca6a53955ec36f6e21
+plan14-root-reads-sec-h3-m2-scoped-key.tsv 4f307fb962a2aac71640ebc18058c02a29d6c7175b93ff1461317e37b94fca4b
diff --git a/internal/provision/testdata/plan14-root-reads-infra-floor-keys-deny.tsv b/internal/provision/testdata/plan14-root-reads-infra-floor-keys-deny.tsv
new file mode 100644
index 000000000..3e5b9b729
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-infra-floor-keys-deny.tsv
@@ -0,0 +1,11 @@
+# Census overlay infra-floor-keys-deny, written by census-propose (#369). census-ruling-infra-floor-keys-deny, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-infra-floor-keys-deny.md.
+# 2 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 975fa23004ac84f84aaa60c7f18ce88b2f1a87125dc8ff3b47dec6078b8b41d0 infra/modules/deployment-buckets/main.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change;rev3=census-ruling-data-lifecycle-336;basis=adds aws_s3_bucket_lifecycle_configuration "data" on the data bucket: noncurrent versions expire after var.data_noncurrent_days, expired delete markers go, multipart aborts after 7 days; no read, no IAM change;rev3=census-ruling-media-results-cleanup;basis=two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change;rev3=census-ruling-store-write-credential;basis=the deployment bucket policy gains ConsoleFloorsAreCreateOnly (Deny s3:PutObject without If-None-Match) and ConsoleFloorsAreNeverDeleted (Deny s3:DeleteObject and s3:DeleteObjectVersion), both Principal * on control/console-floors/* only, the same shape as the box evidence statements; nothing wider is named. tofu only, run on an operator machine; no read is added and nothing on a box reads the file;rev3=census-ruling-infra-floor-keys-deny;basis=the deployment bucket policy gains OnlyOperatorsWriteMovesFloor (Deny s3:PutObject, s3:DeleteObject, s3:DeleteObjectVersion on control/moves-protocol.json and control/moves-protocol-auth.json, ArnNotLike operator_role_arns) and OnlyPublishersWriteSeedsFloor (the same actions on control/seeds-protocol.json, ArnNotLike operator_role_arns plus seeds_floor_writer_role_arns), Principal *, the nobody ARN when the list is empty, the same shape as OnlyOperatorsWriteBinds; a local joins the two lists; nothing wider is named and no other statement changes. Only narrows writers of objects root reads; tofu only, run on an operator machine; no read is added file:external@0 473f7b112f8f3f8de83a71ecf7461aaf3435a75024a75b062623a7c8d8c274fe
+@legacy 50de54326d42fb20b0eaca4fddf0e13f518eb050aaf1ed1cf9bdc412671a1c12 infra/modules/deployment-buckets/variables.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-data-lifecycle-336;basis=adds variable data_noncurrent_days (number, default 7, validated whole and >= 1); no read;rev3=census-ruling-infra-floor-keys-deny;basis=adds variable seeds_floor_writer_role_arns (list of exact IAM role ARNs, default empty, wildcards refused by validation); operator_role_arns description names the floors; no read file:external@0 f3f80c2da50961544668e87430eed5dc7594e48f9abe9ac0a7cd781fba909f43
+@legacy cdc293d7df731c6d41277099d6165f276557da901d2b91ee8595c3a7b6324497 infra/modules/deployment-buckets/tests/published_floors.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-infra-floor-keys-deny;basis=new tftest (mock provider, plan only) asserting both floor statements whole, the nobody default, and the wildcard refusal; run only by tofu test, never on a box; no read file:external@0 db03e4f523fe2fea248faa82a5118c2384ca2775c3c06d414d953a0860d121f8
+infra/modules/deployment-buckets/main.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change;rev3=census-ruling-data-lifecycle-336;basis=adds aws_s3_bucket_lifecycle_configuration "data" on the data bucket: noncurrent versions expire after var.data_noncurrent_days, expired delete markers go, multipart aborts after 7 days; no read, no IAM change;rev3=census-ruling-media-results-cleanup;basis=two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change;rev3=census-ruling-store-write-credential;basis=the deployment bucket policy gains ConsoleFloorsAreCreateOnly (Deny s3:PutObject without If-None-Match) and ConsoleFloorsAreNeverDeleted (Deny s3:DeleteObject and s3:DeleteObjectVersion), both Principal * on control/console-floors/* only, the same shape as the box evidence statements; nothing wider is named. tofu only, run on an operator machine; no read is added and nothing on a box reads the file;rev3=census-ruling-infra-floor-keys-deny;basis=the deployment bucket policy gains OnlyOperatorsWriteMovesFloor (Deny s3:PutObject, s3:DeleteObject, s3:DeleteObjectVersion on control/moves-protocol.json and control/moves-protocol-auth.json, ArnNotLike operator_role_arns) and OnlyPublishersWriteSeedsFloor (the same actions on control/seeds-protocol.json, ArnNotLike operator_role_arns plus seeds_floor_writer_role_arns), Principal *, the nobody ARN when the list is empty, the same shape as OnlyOperatorsWriteBinds; a local joins the two lists; nothing wider is named and no other statement changes. Only narrows writers of objects root reads; tofu only, run on an operator machine; no read is added file:external@0 473f7b112f8f3f8de83a71ecf7461aaf3435a75024a75b062623a7c8d8c274fe
+infra/modules/deployment-buckets/variables.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-data-lifecycle-336;basis=adds variable data_noncurrent_days (number, default 7, validated whole and >= 1); no read;rev3=census-ruling-infra-floor-keys-deny;basis=adds variable seeds_floor_writer_role_arns (list of exact IAM role ARNs, default empty, wildcards refused by validation); operator_role_arns description names the floors; no read file:external@0 f3f80c2da50961544668e87430eed5dc7594e48f9abe9ac0a7cd781fba909f43
+infra/modules/deployment-buckets/tests/published_floors.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-infra-floor-keys-deny;basis=new tftest (mock provider, plan only) asserting both floor statements whole, the nobody default, and the wildcard refusal; run only by tofu test, never on a box; no read file:external@0 db03e4f523fe2fea248faa82a5118c2384ca2775c3c06d414d953a0860d121f8
+@coverage infra/modules/deployment-buckets 6fbd830a211ce2cd964425dda55cae4feada0dee657df76f47d2452c2c471839
+@coverage infra/modules/deployment-buckets/tests 01f7c35c54c468b5ff1d2a1c35474d2498c0c8548d8ab04f3e6d2ca369a96310
diff --git a/internal/provision/testdata/plan14-root-reads-sec-h3-m2-scoped-key.tsv b/internal/provision/testdata/plan14-root-reads-sec-h3-m2-scoped-key.tsv
index 4a1411f2a..07c44bc03 100644
--- a/internal/provision/testdata/plan14-root-reads-sec-h3-m2-scoped-key.tsv
+++ b/internal/provision/testdata/plan14-root-reads-sec-h3-m2-scoped-key.tsv
@@ -2,5 +2,5 @@
# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
@legacy 7ee23b3e31161d4564df522d0ebd3212493454373f256af24e036a298354d1cc channels_digests.go runChannelsResign legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-sec-h3-m2-scoped-key;basis=before asking, prints the plan's grant name and mint date when the head was signed under a key grant that names no account (fix round 2, Fable P2-a); same plan read and same Resign call, no new read; copy pass, literals only file:ReadString@1300 53f6cda6f4410e1cc46f432239460ddefbc5d355454fbca7e68de46dfbfbbb61
channels_digests.go runChannelsResign legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-sec-h3-m2-scoped-key;basis=before asking, prints the plan's grant name and mint date when the head was signed under a key grant that names no account (fix round 2, Fable P2-a); same plan read and same Resign call, no new read; copy pass, literals only file:ReadString@1300 53f6cda6f4410e1cc46f432239460ddefbc5d355454fbca7e68de46dfbfbbb61
-@coverage . 61fd134f903627223679345a1bd651d3e1cb8f583d604eac2f3c8aec0a937ba9
+@coverage . 46466c12842597caa7e3a0d0998d288a27688c84f770d309166a6b414a09ef0e
@coverage internal/release 9e4fa8578ce9848992c7cd81f2d31c046a2517d0963fb226bb4b6ca4aa101b0e
diff --git a/internal/provision/testdata/plan14-root-reads-sec-h3-m3-envelope.tsv b/internal/provision/testdata/plan14-root-reads-sec-h3-m3-envelope.tsv
new file mode 100644
index 000000000..26186a0fa
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-sec-h3-m3-envelope.tsv
@@ -0,0 +1,7 @@
+# Census overlay sec-h3-m3-envelope, written by census-propose (#369). census-ruling-sec-h3-m3-envelope, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-sec-h3-m3-envelope.md.
+# 1 body, 0 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy b903c729b9dbcbb0fd004a7ae5ac9c80a4935d6ae8ea17ceae68c0b942e4cc24 accounts.go runAccountsMigrate legacy accepted-legacy accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-nearest-region-b;basis=reads the hostname history's floor before it opens the registry (checkMigrationFloorNow: GETs control/hosts-used/@floor from the deployment store, the one store the verb uses) and refuses below it; before any write it reads each planned record's source and destination keys and refuses a plan that would create a data-kind record (refuseDataRecords), and each record copy checks the same again (copyMigrationRecord) and never writes a data-kind record; no marks, no new kind of read, no path or input a tenant, app or box agent can name;rev3=census-ruling-sec-h3-m3-envelope;basis=H3-M3 r3: before any write or route stamp, after refuseDataRecords, snapshotConfig (accounts_sealed.go) GETs each planned config bundle (config.json, environments/*.json, instances-config/*.json under the plan's own source prefix, the same deployment store) ONCE into an in-memory snapshot and refuses the plan if any secret is a v2 envelope (appconfig.EnvelopeBound, a prefix check, no key). The copy loop moved verbatim into copyMigrationPlan, which returns errors instead of exiting and takes config bundle bytes from the snapshot (never re-reading the source config), other objects from store.Get as before; after the copy reportConfigChanged GETs each snapshotted key once more and only prints the keys whose bytes changed. Parsed config only decides a refusal or a printed key; nothing is opened, run or followed from it; adds a refusal, removes none file:Open@1195,registry:Account@4142,registry:Account@4276,registry:App@4124,registry:Host@4267,registry:Host@4329,registry:Host@4405,registry:Host@4507,whole:Route@4110 baa1db8c3bbd22bf8767689ddcd7165d72eacd73c20edc20b0d5389c3c981f0a
+accounts.go runAccountsMigrate legacy accepted-legacy accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-nearest-region-b;basis=reads the hostname history's floor before it opens the registry (checkMigrationFloorNow: GETs control/hosts-used/@floor from the deployment store, the one store the verb uses) and refuses below it; before any write it reads each planned record's source and destination keys and refuses a plan that would create a data-kind record (refuseDataRecords), and each record copy checks the same again (copyMigrationRecord) and never writes a data-kind record; no marks, no new kind of read, no path or input a tenant, app or box agent can name;rev3=census-ruling-sec-h3-m3-envelope;basis=H3-M3 r3: before any write or route stamp, after refuseDataRecords, snapshotConfig (accounts_sealed.go) GETs each planned config bundle (config.json, environments/*.json, instances-config/*.json under the plan's own source prefix, the same deployment store) ONCE into an in-memory snapshot and refuses the plan if any secret is a v2 envelope (appconfig.EnvelopeBound, a prefix check, no key). The copy loop moved verbatim into copyMigrationPlan, which returns errors instead of exiting and takes config bundle bytes from the snapshot (never re-reading the source config), other objects from store.Get as before; after the copy reportConfigChanged GETs each snapshotted key once more and only prints the keys whose bytes changed. Parsed config only decides a refusal or a printed key; nothing is opened, run or followed from it; adds a refusal, removes none file:Open@1195,registry:Account@4142,registry:Account@4276,registry:App@4124,registry:Host@4267,registry:Host@4329,registry:Host@4405,registry:Host@4507,whole:Route@4110 baa1db8c3bbd22bf8767689ddcd7165d72eacd73c20edc20b0d5389c3c981f0a
+@coverage . 61b1d655ea7c729c58baf4a7ad42c22450c24b4af7ff55ada123a707d8024316
+@coverage internal/appconfig 2d4018700c44d5251cbac73db1a9ee7fc6be196ad85f11c45ec699e62af243c2
+@coverage internal/moves/archive e457ed3b644ef8d821e0ad3c739a52febe8cf1c504e1d56c2a186bec40c379ee