accounts migrate refuses sealed v2 config secrets (H3-M3)
Fixes hunt finding H3-M3: carlos accounts migrate could copy config bundles holding v2 envelope secrets bound to the source account, leaving them unreadable. Before any write it snapshots each planned config bundle once, refuses the plan on a bound secret, copies from that snapshot, reports keys that changed meanwhile and gives per-key recovery advice (legacy keys included). Review: Astra R1-R3 + Fable R1, Astra R3 READY AFTER FIXES, fixes applied; census APPROVE (H3M3-R3-astra), chain re-proposed on merge with the same claim; copy pass no changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from sec-h3-m3-envelope into main.
34 files changed,
+1,598
−284
.amadan/code-health.tsv+1 −2accounts.go+87 −64accounts_sealed.go+205 −0accounts_sealed_test.go+485 −0appconfig_cli.go+6 −22appconfig_cli_fleet_test.go+1 −2cmd/console/main.go+10 −18docs/superpowers/notes/2026-11-29-secret-envelope-v1-sunset.md+161 −0docs/superpowers/notes/census-proposal-sec-h3-m3-envelope.md+19 −0internal/appconfig/crypto.go+56 −45internal/appconfig/crypto_bind_test.go+13 −24internal/appconfig/hunt_H3-M3_test.go+141 −0internal/appconfig/owned.go+13 −0internal/appconfig/owned_test.go+114 −4internal/appconfig/sealer.go+4 −2internal/appconfig/sealer_test.go+2 −6internal/appconfig/store.go+40 −0internal/appconfig/unboundsets_test.go+95 −0internal/console/apiconfig.go+6 −8internal/console/apiconfig_test.go+6 −18internal/console/configwrite.go+14 −2internal/console/envform_test.go+5 −20internal/console/envsave_test.go+0 −2internal/console/fleetsecrets_mint_test.go+2 −5internal/console/fleetsecrets_relay_test.go+0 −4internal/console/hunt_h3m3_test.go+78 −0internal/console/sealkey.go+2 −2internal/console/sealkey_test.go+19 −28internal/host/replicahomekeys_test.go+1 −1internal/mail/sealer_helper_test.go+1 −1internal/moves/archive/seal.go+2 −3internal/objstore/walk_test.go+1 −1internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/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-Ci08CU
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading golang.org/x/net v0.62.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/sns v1.43.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading golang.org/x/sys v0.49.0
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/aws/aws-sdk-go-v2/service/sesv2 v1.66.6
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/pion/randutil v0.1.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0
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 modernc.org/memory v1.11.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== launchctx (4 s, from +0 s)
ok amadan.net/carlos/platform.git/launchctx 0.015s
? amadan.net/carlos/platform.git/launchctx/controlname [no test files]
? amadan.net/carlos/platform.git/launchctx/wireid [no test files]
=== vet (181 s, from +0 s)
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 modernc.org/sqlite v1.55.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
=== vet-tags (193 s, from +0 s)
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/klauspost/compress v1.20.2
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/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 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 127.920s
? github.com/carlosframework/platform/cmd/changelog [no test files]
ok github.com/carlosframework/platform/cmd/console 212.336s
ok github.com/carlosframework/platform/cmd/mediaimage 43.948s
ok github.com/carlosframework/platform/cmd/moveprobe 15.759s
ok github.com/carlosframework/platform/cmd/pricebook-export 0.031s
ok github.com/carlosframework/platform/cmd/rootfswitness 0.144s
ok github.com/carlosframework/platform/cmd/runsc-assets 0.069s
ok github.com/carlosframework/platform/cmd/zddprobe 1.020s
ok github.com/carlosframework/platform/internal/agentsock 0.065s
ok github.com/carlosframework/platform/internal/alerting 0.029s
ok github.com/carlosframework/platform/internal/analytics 0.341s
ok github.com/carlosframework/platform/internal/appconfig 46.351s
ok github.com/carlosframework/platform/internal/apperr 0.469s
ok github.com/carlosframework/platform/internal/applog 4.176s
ok github.com/carlosframework/platform/internal/apppolicy 2.073s
ok github.com/carlosframework/platform/internal/assetcache 0.634s
ok github.com/carlosframework/platform/internal/awsinv 0.017s
ok github.com/carlosframework/platform/internal/awsmanaged 8.096s
ok github.com/carlosframework/platform/internal/awsregiongroup 0.151s
ok github.com/carlosframework/platform/internal/awsterminations 0.055s
ok github.com/carlosframework/platform/internal/backupswords 0.012s
ok github.com/carlosframework/platform/internal/billing 0.079s
ok github.com/carlosframework/platform/internal/billing/billingtest 0.073s
ok github.com/carlosframework/platform/internal/billingstripe 2.098s
ok github.com/carlosframework/platform/internal/boxchoice 0.022s
ok github.com/carlosframework/platform/internal/boxid 3.876s
? 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.020s
ok github.com/carlosframework/platform/internal/boxself 0.186s
ok github.com/carlosframework/platform/internal/boxvolumes 0.034s
ok github.com/carlosframework/platform/internal/caps 4.568s
ok github.com/carlosframework/platform/internal/certwarm 0.012s
ok github.com/carlosframework/platform/internal/cgroup 1.377s
ok github.com/carlosframework/platform/internal/changelog 6.021s
ok github.com/carlosframework/platform/internal/clamd 0.088s
? github.com/carlosframework/platform/internal/cliflag [no test files]
ok github.com/carlosframework/platform/internal/clireg 0.016s
ok github.com/carlosframework/platform/internal/codehealth 19.199s
ok github.com/carlosframework/platform/internal/compute 0.016s
ok github.com/carlosframework/platform/internal/consolefleet 0.018s
? github.com/carlosframework/platform/internal/controlname [no test files]
? github.com/carlosframework/platform/internal/controlsock [no test files]
ok github.com/carlosframework/platform/internal/dbdoor 11.891s
ok github.com/carlosframework/platform/internal/dbdoor/dbdoortest 0.048s
ok github.com/carlosframework/platform/internal/dbquery 0.018s
ok github.com/carlosframework/platform/internal/dbreads 3.276s
? github.com/carlosframework/platform/internal/dbreads/dbreadstest [no test files]
ok github.com/carlosframework/platform/internal/dbverify 0.034s
ok github.com/carlosframework/platform/internal/demo 0.010s
ok github.com/carlosframework/platform/internal/demobuild 6.075s
ok github.com/carlosframework/platform/internal/democlaim 0.540s
ok github.com/carlosframework/platform/internal/devbox 20.811s
ok github.com/carlosframework/platform/internal/dnsrec 0.010s
ok github.com/carlosframework/platform/internal/docsite 0.077s
ok github.com/carlosframework/platform/internal/domainreg 0.012s
ok github.com/carlosframework/platform/internal/domains 75.053s
ok github.com/carlosframework/platform/internal/doorkey 0.031s
ok github.com/carlosframework/platform/internal/economics 0.013s
ok github.com/carlosframework/platform/internal/edgefence 0.176s
ok github.com/carlosframework/platform/internal/edgeguard 0.401s
? github.com/carlosframework/platform/internal/edgeproof [no test files]
ok github.com/carlosframework/platform/internal/edgesfile 0.078s
ok github.com/carlosframework/platform/internal/egressaddr 0.005s
ok github.com/carlosframework/platform/internal/execsandbox 106.419s
ok github.com/carlosframework/platform/internal/fileacl 0.016s
ok github.com/carlosframework/platform/internal/fleetapi 2.317s
ok github.com/carlosframework/platform/internal/fleetstore 0.008s
ok github.com/carlosframework/platform/internal/fxrate 0.021s
ok github.com/carlosframework/platform/internal/gate 6.698s
ok github.com/carlosframework/platform/internal/genselect 0.130s
ok github.com/carlosframework/platform/internal/geo 0.081s
ok github.com/carlosframework/platform/internal/geoip 0.092s
ok github.com/carlosframework/platform/internal/groupadmission 0.008s
ok github.com/carlosframework/platform/internal/grouprollaws 17.521s
ok github.com/carlosframework/platform/internal/hadeparture 0.022s
ok github.com/carlosframework/platform/internal/hafresh 0.009s
ok github.com/carlosframework/platform/internal/hairpin 0.273s
ok github.com/carlosframework/platform/internal/historyreadback 1.142s
ok github.com/carlosframework/platform/internal/hostactors 25.986s
ok github.com/carlosframework/platform/internal/hostbox 25.820s
ok github.com/carlosframework/platform/internal/hostclaim 2.386s
ok github.com/carlosframework/platform/internal/hostenv 0.035s
ok github.com/carlosframework/platform/internal/hostevidence 0.026s
ok github.com/carlosframework/platform/internal/hostexec 27.040s
ok github.com/carlosframework/platform/internal/hostfence 0.218s
ok github.com/carlosframework/platform/internal/hostfiles 31.781s
ok github.com/carlosframework/platform/internal/hostfloor 0.333s
ok github.com/carlosframework/platform/internal/hostguard 1.491s
ok github.com/carlosframework/platform/internal/hostops 8.171s
? github.com/carlosframework/platform/internal/hostops/fencerelease [no test files]
ok github.com/carlosframework/platform/internal/hostops/internal/fencerelease 0.019s
ok github.com/carlosframework/platform/internal/hostquarantine 0.034s
ok github.com/carlosframework/platform/internal/hostrelocate 2.492s
ok github.com/carlosframework/platform/internal/hostresolve 0.572s
ok github.com/carlosframework/platform/internal/hostwrite 0.016s
ok github.com/carlosframework/platform/internal/infraview 0.012s
ok github.com/carlosframework/platform/internal/ingresshealth 0.026s
ok github.com/carlosframework/platform/internal/ingresshealth/awstg 0.014s
ok github.com/carlosframework/platform/internal/instancectl 67.032s
ok github.com/carlosframework/platform/internal/instanceexec 10.390s
ok github.com/carlosframework/platform/internal/instancefs 18.983s
ok github.com/carlosframework/platform/internal/instancekey 0.004s
ok github.com/carlosframework/platform/internal/instanceupdates 0.033s
ok github.com/carlosframework/platform/internal/interactive 0.650s
ok github.com/carlosframework/platform/internal/launchd 0.012s
ok github.com/carlosframework/platform/internal/layout 25.982s
ok github.com/carlosframework/platform/internal/layout/pubclass 101.198s
ok github.com/carlosframework/platform/internal/lbhealth 0.033s
ok github.com/carlosframework/platform/internal/lease 148.535s
ok github.com/carlosframework/platform/internal/lease/leasetest 1.311s
ok github.com/carlosframework/platform/internal/lease/locktest 0.022s
ok github.com/carlosframework/platform/internal/ledger 0.074s
ok github.com/carlosframework/platform/internal/mail 1.340s
ok github.com/carlosframework/platform/internal/mailer 0.928s
ok github.com/carlosframework/platform/internal/mailsubmit 1.701s
ok github.com/carlosframework/platform/internal/mailwire 0.010s
ok github.com/carlosframework/platform/internal/maintenance 0.129s
ok github.com/carlosframework/platform/internal/maintenanceexec 9.193s
ok github.com/carlosframework/platform/internal/maintenanceguard 0.344s
ok github.com/carlosframework/platform/internal/managedboot 4.371s
? 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.407s
ok github.com/carlosframework/platform/internal/media/mediatest 0.024s
ok github.com/carlosframework/platform/internal/mediaaws 65.069s
ok github.com/carlosframework/platform/internal/mediahandler 42.735s
ok github.com/carlosframework/platform/internal/mediajobs 1.320s
ok github.com/carlosframework/platform/internal/medialocal 10.488s
ok github.com/carlosframework/platform/internal/metrics 0.100s
ok github.com/carlosframework/platform/internal/minorunits 0.005s
ok github.com/carlosframework/platform/internal/moves 54.250s
ok github.com/carlosframework/platform/internal/moves/archive 4.066s
ok github.com/carlosframework/platform/internal/moves/offlinerun 0.124s
ok github.com/carlosframework/platform/internal/namedunits 0.039s
ok github.com/carlosframework/platform/internal/objstore 3.902s
ok github.com/carlosframework/platform/internal/ops 19.352s
ok github.com/carlosframework/platform/internal/pageindex 4.294s
ok github.com/carlosframework/platform/internal/parity 0.207s
? github.com/carlosframework/platform/internal/parity/cmd/parity-doc [no test files]
ok github.com/carlosframework/platform/internal/park 0.893s
ok github.com/carlosframework/platform/internal/perf 0.226s
ok github.com/carlosframework/platform/internal/plans 0.277s
ok github.com/carlosframework/platform/internal/privatefile 0.019s
ok github.com/carlosframework/platform/internal/provision 237.844s
ok github.com/carlosframework/platform/internal/proxyproto 0.974s
ok github.com/carlosframework/platform/internal/publicrelease 0.063s
ok github.com/carlosframework/platform/internal/ratelimit 0.257s
ok github.com/carlosframework/platform/internal/regionlabel 0.162s
ok github.com/carlosframework/platform/internal/regionname 0.090s
ok github.com/carlosframework/platform/internal/registrar 0.015s
ok github.com/carlosframework/platform/internal/registrar/openprovider 1.003s
? github.com/carlosframework/platform/internal/registrar/registrartest [no test files]
ok github.com/carlosframework/platform/internal/registry 83.045s
ok github.com/carlosframework/platform/internal/relay 7.506s
ok github.com/carlosframework/platform/internal/release 126.998s
? github.com/carlosframework/platform/internal/release/requestwitness [no test files]
ok github.com/carlosframework/platform/internal/replicagen 0.039s
ok github.com/carlosframework/platform/internal/replicas 0.074s
ok github.com/carlosframework/platform/internal/reqrec 6.147s
ok github.com/carlosframework/platform/internal/rollout 11.783s
ok github.com/carlosframework/platform/internal/rolloutwords 0.016s
ok github.com/carlosframework/platform/internal/rootaws 99.050s
ok github.com/carlosframework/platform/internal/rootfsimage 0.727s
ok github.com/carlosframework/platform/internal/rootparticipation 0.140s
ok github.com/carlosframework/platform/internal/rootstate 0.058s
ok github.com/carlosframework/platform/internal/runs 1.155s
ok github.com/carlosframework/platform/internal/s3compat 0.033s
ok github.com/carlosframework/platform/internal/s3fake 1.937s
ok github.com/carlosframework/platform/internal/s3meter 0.634s
ok github.com/carlosframework/platform/internal/safefile 0.046s
ok github.com/carlosframework/platform/internal/schedule 26.199s
ok github.com/carlosframework/platform/internal/seeds 0.123s
ok github.com/carlosframework/platform/internal/share 0.043s
ok github.com/carlosframework/platform/internal/sim/litestreamfacts 4.975s
ok github.com/carlosframework/platform/internal/sim/mediajobs 52.512s
ok github.com/carlosframework/platform/internal/sim/regionha 24.193s
ok github.com/carlosframework/platform/internal/status 0.479s
ok github.com/carlosframework/platform/internal/steering 0.310s
ok github.com/carlosframework/platform/internal/stopevidence 0.558s
ok github.com/carlosframework/platform/internal/storecfg 0.433s
ok github.com/carlosframework/platform/internal/svcrole 0.028s
ok github.com/carlosframework/platform/internal/systemd 5.827s
? github.com/carlosframework/platform/internal/systemdshow [no test files]
ok github.com/carlosframework/platform/internal/team 4.095s
ok github.com/carlosframework/platform/internal/teamcontract 0.263s
ok github.com/carlosframework/platform/internal/telemetry 0.022s
ok github.com/carlosframework/platform/internal/termfence 5.039s
ok github.com/carlosframework/platform/internal/timerspec 0.017s
ok github.com/carlosframework/platform/internal/tsidentity 4.182s
ok github.com/carlosframework/platform/internal/tunnelclient 0.392s
ok github.com/carlosframework/platform/internal/unixdial 0.012s
ok github.com/carlosframework/platform/internal/updatewords 0.039s
ok github.com/carlosframework/platform/internal/upstreamguard 0.018s
? github.com/carlosframework/platform/internal/upstreamguard/guardtest [no test files]
ok github.com/carlosframework/platform/internal/usage 0.147s
ok github.com/carlosframework/platform/internal/version 0.006s
ok github.com/carlosframework/platform/internal/vet 2.776s
ok github.com/carlosframework/platform/internal/zonehost 0.012s
ok github.com/carlosframework/platform/internal/zonehost/route53zones 0.088s
? 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.021s
ok github.com/carlosframework/platform/scripts/pathmapcheck 0.136s
ok github.com/carlosframework/platform/scripts/region-ha-g2/fixture 5.343s
ok github.com/carlosframework/platform/scripts/stateless-replicas-drill 1.239s
ok github.com/carlosframework/platform/scripts/witness-pointer 0.027s
=== cutover-witness (169 s, from +14 s)
ok github.com/carlosframework/platform 2.889s
=== internal_grouproll@0 (275 s, from +73 s)
ok github.com/carlosframework/platform/internal/grouproll 273.827s
=== internal_grouproll@1 (278 s, from +73 s)
ok github.com/carlosframework/platform/internal/grouproll 276.772s
=== internal_activator@0 (156 s, from +147 s)
ok github.com/carlosframework/platform/internal/activator 151.349s
=== internal_activator@1 (131 s, from +147 s)
ok github.com/carlosframework/platform/internal/activator 125.870s
=== internal_activator@2 (140 s, from +147 s)
ok github.com/carlosframework/platform/internal/activator 134.726s
=== internal_activator@3 (170 s, from +147 s)
ok github.com/carlosframework/platform/internal/activator 164.679s
=== root@0 (116 s, from +180 s)
ok github.com/carlosframework/platform 105.464s
=== root@1 (111 s, from +180 s)
ok github.com/carlosframework/platform 100.422s
=== root@2 (115 s, from +180 s)
ok github.com/carlosframework/platform 103.380s
=== root@3 (111 s, from +180 s)
ok github.com/carlosframework/platform 101.715s
=== root@4 (125 s, from +180 s)
ok github.com/carlosframework/platform 115.585s
=== internal_edge@0 (190 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 182.395s
=== internal_edge@1 (137 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 128.332s
=== internal_edge@2 (144 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 137.294s
=== internal_edge@3 (208 s, from +183 s)
ok github.com/carlosframework/platform/internal/edge 199.729s
=== internal_host@0 (173 s, from +221 s)
ok github.com/carlosframework/platform/internal/host 168.599s
=== internal_host@1 (155 s, from +221 s)
ok github.com/carlosframework/platform/internal/host 149.558s
=== internal_host@2 (158 s, from +221 s)
ok github.com/carlosframework/platform/internal/host 153.272s
=== internal_host@3 (191 s, from +221 s)
ok github.com/carlosframework/platform/internal/host 185.704s
=== internal_host@4 (240 s, from +221 s)
ok github.com/carlosframework/platform/internal/host 235.177s
=== internal_host@5 (253 s, from +221 s)
ok github.com/carlosframework/platform/internal/host 247.428s
=== internal_console@0 (169 s, from +230 s)
ok github.com/carlosframework/platform/internal/console 161.440s
=== internal_console@1 (178 s, from +230 s)
ok github.com/carlosframework/platform/internal/console 171.734s
=== internal_console@2 (215 s, from +230 s)
ok github.com/carlosframework/platform/internal/console 206.772s
=== internal_console@3 (241 s, from +230 s)
ok github.com/carlosframework/platform/internal/console 232.746s
=== internal_console@4 (204 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 198.038s
=== internal_console@5 (251 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 245.098s
=== internal_console@6 (231 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 224.343s
=== internal_console@7 (221 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 214.964s
=== internal_console@8 (232 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 224.501s
=== internal_console@9 (247 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 239.768s
=== internal_console@10 (305 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 297.716s
=== internal_console@11 (237 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 230.003s
=== internal_console@12 (347 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 338.583s
=== internal_console@13 (213 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 206.557s
=== internal_console@14 (216 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 208.973s
=== internal_console@15 (238 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 231.463s
=== internal_console@16 (217 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 209.644s
=== internal_console@17 (220 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 213.100s
=== internal_console@18 (251 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 243.230s
=== internal_console@19 (240 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 231.989s
=== internal_console@20 (217 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 209.227s
=== internal_console@21 (228 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 220.803s
=== internal_console@22 (232 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 224.954s
=== internal_console@23 (250 s, from +231 s)
ok github.com/carlosframework/platform/internal/console 241.169s
=== lists: internal_console 230 s, internal_edge 180 s, internal_activator 146 s, internal_host 220 s, root 179 s, internal_grouproll 72 s
=== cpu: the gate used 13119 cpu-seconds in 578 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 14 s
ok 19 s infra/modules/box-fence-writer/tests/writer.tftest.hcl Success! 1 passed, 0 failed.
ok 21 s infra/modules/deployment-buckets/tests/console_floors.tftest.hcl Success! 1 passed, 0 failed.
ok 31 s infra/modules/deployment-buckets/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 19 s infra/modules/deployment-buckets/tests/db_reads.tftest.hcl Success! 1 passed, 0 failed.
ok 21 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 24 s infra/modules/deployment-buckets/tests/media_results.tftest.hcl Success! 2 passed, 0 failed.
ok 29 s infra/modules/deployment-buckets/tests/published_floors.tftest.hcl Success! 3 passed, 0 failed.
ok 83 s infra/modules/media-engine/tests/media_engine.tftest.hcl Success! 24 passed, 0 failed.
ok 26 s infra/modules/pdf-host/tests/computed.tftest.hcl Success! 2 passed, 0 failed.
ok 56 s infra/modules/pdf-host/tests/pdf_host.tftest.hcl Success! 24 passed, 0 failed.
ok 41 s infra/modules/region-group-operator-document/tests/document.tftest.hcl Success! 12 passed, 0 failed.
ok 18 s infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl Success! 2 passed, 0 failed.
ok 66 s infra/modules/region-host/ingress/tests/group_ingress.tftest.hcl Success! 30 passed, 0 failed.
ok 44 s infra/modules/region-host/tests/alert_publish.tftest.hcl Success! 18 passed, 0 failed.
ok 41 s infra/modules/region-host/tests/alerts_topic.tftest.hcl Success! 16 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/analytics_prune.tftest.hcl Success! 2 passed, 0 failed.
ok 14 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 74 s infra/modules/region-host/tests/group.tftest.hcl Success! 32 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/group_alarms.tftest.hcl Success! 4 passed, 0 failed.
ok 11 s infra/modules/region-host/tests/group_iam.tftest.hcl Success! 4 passed, 0 failed.
ok 5 s infra/modules/region-host/tests/group_isolation.tftest.hcl Success! 1 passed, 0 failed.
ok 39 s infra/modules/region-host/tests/group_operator.tftest.hcl Success! 13 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/group_user_data.tftest.hcl Success! 3 passed, 0 failed.
ok 35 s infra/modules/region-host/tests/health_alarms.tftest.hcl Success! 10 passed, 0 failed.
ok 18 s infra/modules/region-host/tests/ingress_drain_read.tftest.hcl Success! 4 passed, 0 failed.
ok 8 s infra/modules/region-host/tests/instance_metadata.tftest.hcl Success! 1 passed, 0 failed.
ok 24 s infra/modules/region-host/tests/mailer.tftest.hcl Success! 6 passed, 0 failed.
ok 16 s infra/modules/region-host/tests/mailer_group.tftest.hcl Success! 2 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/managed_fleets/group_refusal.tftest.hcl Success! 2 passed, 0 failed.
ok 105 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 14 s infra/modules/region-host/tests/store_scanning.tftest.hcl Success! 4 passed, 0 failed.
ok 28 s infra/modules/region-host/tests/store_versioning.tftest.hcl Success! 11 passed, 0 failed.
ok 15 s infra/modules/region-host/tests/store_write_credentials.tftest.hcl Success! 4 passed, 0 failed.
ok 17 s infra/modules/region-host/tests/user_data_ignored.tftest.hcl Success! 3 passed, 0 failed.
ok 12 s infra/modules/region-remote-host/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 15 s infra/modules/region-remote-host/tests/no_deployment_bucket.tftest.hcl Success! 5 passed, 0 failed.
ok 37 s infra/modules/scanner-host/tests/scanner_host.tftest.hcl Success! 14 passed, 0 failed.
opentofu: 40 files in 214 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:39970
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.02s)
--- 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.036s
=== RUN TestT4StorageProbeMinio
2026/11/30 21:25:31 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18ECEFB9780108F2, HostID: e13951bee374ac468c67a3953d67e881b78227d887b5f2179a7b1cf57c06048c, 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.061s
=== 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.040s
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:_delete
=== RUN TestWriteCredentialContractMinio/refused:_tag
=== RUN TestWriteCredentialContractMinio/refused:_put_tagged
=== RUN TestWriteCredentialContractMinio/refused:_put_to_another_bucket
=== RUN TestWriteCredentialContractMinio/refused:_read_elsewhere
=== RUN TestWriteCredentialContractMinio/refused:_put_with_a_platform_tag
=== RUN TestWriteCredentialContractMinio/refused:_put_outside_the_prefix
=== RUN TestWriteCredentialContractMinio/refused:_put_beside_the_prefix
=== RUN TestWriteCredentialContractMinio/refused:_copy_from_the_store
=== RUN TestWriteCredentialContractMinio/refused:_bucket_settings
=== RUN TestWriteCredentialContractMinio/refused:_read_under_the_prefix
=== RUN TestWriteCredentialContractMinio/refused:_head
=== RUN TestWriteCredentialContractMinio/refused:_list
=== RUN TestWriteCredentialContractMinio/refused:_list_uploads
--- PASS: TestWriteCredentialContractMinio (0.04s)
--- PASS: TestWriteCredentialContractMinio/put_under_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/multipart_under_the_prefix (0.01s)
--- PASS: TestWriteCredentialContractMinio/refused:_delete (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_tag (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_tagged (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_put_to_another_bucket (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_read_elsewhere (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_beside_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_copy_from_the_store (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_bucket_settings (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_read_under_the_prefix (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_head (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_list (0.00s)
--- PASS: TestWriteCredentialContractMinio/refused:_list_uploads (0.00s)
PASS
ok github.com/carlosframework/platform/internal/objstore 0.047s
=== 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.12s)
--- PASS: TestEndToEndMinio/replace (0.15s)
--- PASS: TestEndToEndMinio/remove (0.16s)
PASS
ok github.com/carlosframework/platform/internal/grouproll 0.478s
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:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/30 21:25:39 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/11/30 21:25:39 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/11/30 21:25:39 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/30 21:25:39 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/30 21:25:39 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/30 21:25:40 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/11/30 21:25:40 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%3A36219: could not determine target mailbox
agent.go:136: dbreads: dbr_mapcbt2bheyts5so52ssqal2hu: planned 3 files (1544 bytes) and restored to 3 in 14ms
agent.go:136: dbreads: dbr_mapcbt2bheyts5so52ssqal2hu: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/30 21:25:41 console: db read dbr_mapcbt2bheyts5so52ssqal2hu: relayed 1 chunks (102 bytes) in 1.005s, ended done
agent.go:136: dbreads: dbr_v7x4hn6x4pyocxvy6dmpjqqnby: planned 1 files (720 bytes) and restored to 1 in 12ms
agent.go:136: dbreads: dbr_v7x4hn6x4pyocxvy6dmpjqqnby: output 5 bytes in 1 confirmed chunks in 1ms
2026/11/30 21:25:42 console: db read dbr_v7x4hn6x4pyocxvy6dmpjqqnby: relayed 1 chunks (102 bytes) in 1.017s, ended done
agent.go:136: dbreads: dbr_j72zgeisf7x67fev6haaiykbye: planned 3 files (1544 bytes) and held through 3 in 11ms
agent.go:136: dbreads: dbr_j72zgeisf7x67fev6haaiykbye: output 1544 bytes in 1 confirmed chunks in 1ms
2026/11/30 21:25:43 console: db read dbr_j72zgeisf7x67fev6haaiykbye: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN TestDBForwardMinio/by_disconnect
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_nhmhvokj4ao7d2kep6hyslzenq: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/30 21:25:43 console: db read dbr_nhmhvokj4ao7d2kep6hyslzenq: relayed 0 chunks (0 bytes) in 30ms, ended client gone
agent.go:136: dbreads: dbr_nhmhvokj4ao7d2kep6hyslzenq: output 5 bytes in 1 confirmed chunks in 104ms
=== RUN TestDBForwardMinio/by_timeout
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_eqbjxgf2lxih7mft4dpjng4hym: planned 3 files (1544 bytes) and restored to 3 in 15ms
2026/11/30 21:26:03 console: db read dbr_eqbjxgf2lxih7mft4dpjng4hym: relayed 0 chunks (0 bytes) in 19.681s, ended no-result
agent.go:136: dbreads: dbr_eqbjxgf2lxih7mft4dpjng4hym: output 5 bytes in 1 confirmed chunks in 19.653s
--- PASS: TestDBForwardMinio (23.38s)
--- PASS: TestDBForwardMinio/by_disconnect (0.24s)
--- PASS: TestDBForwardMinio/by_timeout (19.79s)
PASS
ok github.com/carlosframework/platform/internal/console 23.429s
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.55s)
PASS
ok github.com/carlosframework/platform/internal/medialocal 0.558s
=== RUN TestHeldHandoverTwoBoxMinio
2026/11/30 21:26:08 edge: mesh key: minted
2026/11/30 21:26:08 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:26:08 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:26:08 tenant admission is open. accepting tenant work
2026/11/30 21:26:08 activator: HA placement host=shop-7b8d6dd2.example.test kind=Place ref=annie reason=roomiest generation=2026-11-30T21:26:08Z lock_generation=0
2026/11/30 21:26:08 lease: t8-7b8d6dd2/shop-7b8d6dd2.example.test: HA lease acquired in 4ms (first wake)
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: started carlos-instance@shop\x2d7b8d6dd2.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:26:08 activator: shop-7b8d6dd2.example.test: carlos-instance@shop\x2d7b8d6dd2.example.test.service launched in 7ms, healthy 0s later
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: woke in 21ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 8ms, replicate 8ms
2026/11/30 21:26:08 lease: t8-7b8d6dd2/plain-7b8d6dd2.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/30 21:26:08 activator: no replica for plain-7b8d6dd2.example.test in s3://contract-bucket/t8-7b8d6dd2/plain-7b8d6dd2.example.test — booting fresh
2026/11/30 21:26:08 activator: plain-7b8d6dd2.example.test: started carlos-instance@plain\x2d7b8d6dd2.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 2ms, instance key 0s, env 4ms, control socket 0s, key gate 0s, logs 0s) 6ms, launch file 0s, gate 0s, root start 1ms)
2026/11/30 21:26:08 activator: plain-7b8d6dd2.example.test: carlos-instance@plain\x2d7b8d6dd2.example.test.service launched in 7ms, healthy 0s later
2026/11/30 21:26:08 activator: plain-7b8d6dd2.example.test: woke in 98ms: checks 0s, lease 1ms, restore 17ms, identity 0s, protect 0s, spawn 8ms, replicate 71ms
2026/11/30 21:26:08 lease: t8-7b8d6dd2/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/11/30 21:26:08 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/30 21:26:08 activator: bot0.shop.bac.sidecar.internal: woke in 68ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, settle 0s, replicate 57ms
2026/11/30 21:26:08 activator: next-due probe plain-7b8d6dd2.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:26:08 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:fdac08a260f579300e36ac66f5bc8a00a0f241acb1faebaf94657722b4c7cad5) in 7ms: files 1ms, sync 3ms, record 1ms, marker 2ms
2026/11/30 21:26:08 activator: bot0.shop.bac.sidecar.internal hibernated
2026/11/30 21:26:08 activator: plain-7b8d6dd2.example.test hibernated
2026/11/30 21:26:08 activator: next-due probe shop-7b8d6dd2.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:26:08 activator: shop-7b8d6dd2.example.test: released with a marker (clean true, txid 1, files 3:5146f7bec5983730bc8fdcc7ee1bac9b9ea40f2a258101f3b2e67f4547d5d23a) in 5ms: files 1ms, sync 2ms, record 1ms, marker 2ms
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test hibernated
2026/11/30 21:26:08 lease: t8-7b8d6dd2/shop-7b8d6dd2.example.test: HA lease acquired in 2ms (clean marker)
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: restored (other-box)
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: started carlos-instance@shop\x2d7b8d6dd2.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 0s, control socket 0s, key gate 0s, logs 0s) 1ms, launch file 0s, gate 0s, root start 1ms)
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: carlos-instance@shop\x2d7b8d6dd2.example.test.service launched in 2ms, healthy 0s later
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test: woke in 86ms: checks 0s, lease 3ms, restore 25ms, identity 0s, protect 0s, spawn 2ms, replicate 56ms
2026/11/30 21:26:08 edge: ha-take shop-7b8d6dd2.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/11/30 21:26:08 edge: forward shop-7b8d6dd2.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:6930cc1e8153b70c21d06c156a05d2df Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-11-30 21:26:08.552413738 +0000 UTC FinishedAt:2026-11-30 21:26:08.700394107 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-7b8d6dd2.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:bot0.shop.bac.sidecar.internal Kind:worker Marker:true Clean:true Reason:} {Host:plain-7b8d6dd2.example.test Kind:other Marker:true Clean:true Reason:}] Unclean:[] Left:[] Holds:{LongestMS:129 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-7b8d6dd2.example.test <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> stop plain-7b8d6dd2.example.test marker=true clean=true <nil> releasing shop-7b8d6dd2.example.test <nil> stop shop-7b8d6dd2.example.test marker=true clean=true <nil> taken shop-7b8d6dd2.example.test betty <nil> end-moves]
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-7b8d6dd2/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-7b8d6dd2/bot0.shop.bac.sidecar.internal/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-7b8d6dd2/plain-7b8d6dd2.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/head.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/generations/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/files/0/manifest.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/files/0/objects/0000000000000001-8b73d8c1cca9cc6944e197b3750137f71d29289e06d864c04ca18b831c7061b3
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/files/0/objects/0000000000000003-f91a62b554a4d8cb643f74c21eb6c54f3ae1c78f66ca0314b8f702c5cc0102c3
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/0000/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-7b8d6dd2/shop-7b8d6dd2.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/0000/0000000000000002-0000000000000002.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-7b8d6dd2/shop-7b8d6dd2.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1243: drain took 191ms; S3 calls 45 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=29 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:26:08 lease: t8-7b8d6dd2/plain-7b8d6dd2.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/30 21:26:08 activator: plain-7b8d6dd2.example.test: started carlos-instance@plain\x2d7b8d6dd2.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:26:08 activator: plain-7b8d6dd2.example.test: carlos-instance@plain\x2d7b8d6dd2.example.test.service launched in 1ms, healthy 0s later
2026/11/30 21:26:08 lease: /tmp/carlos-minio-contract-97Q19j/g/dw2548059458/data/instances/plain-7b8d6dd2.example.test/plain-7b8d6dd2.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/11/30 21:26:08 activator: plain-7b8d6dd2.example.test: woke in 8ms: checks 0s, lease 2ms, restore 0s, identity 0s, protect 0s, spawn 1ms, replicate 4ms
2026/11/30 21:26:08 activator: next-due probe shop-7b8d6dd2.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:26:08 activator: shop-7b8d6dd2.example.test: released with a marker (clean true, txid 2, files 3:5146f7bec5983730bc8fdcc7ee1bac9b9ea40f2a258101f3b2e67f4547d5d23a) in 4ms: files 1ms, sync 0s, record 1ms, marker 2ms
2026/11/30 21:26:08 activator: shop-7b8d6dd2.example.test hibernated
2026/11/30 21:26:08 tenant admission is closed for shutdown
2026/11/30 21:26:08 activator: next-due probe plain-7b8d6dd2.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:26:08 activator: plain-7b8d6dd2.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.62s)
=== RUN TestHeldHandoverLostLeaseMinio
2026/11/30 21:26:08 edge: mesh key: minted
2026/11/30 21:26:08 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:26:08 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/30 21:26:08 tenant admission is open. accepting tenant work
2026/11/30 21:26:08 activator: HA placement host=shop-11062e65.example.test kind=Place ref=annie reason=roomiest generation=2026-11-30T21:26:08Z lock_generation=0
2026/11/30 21:26:08 lease: t8-11062e65/shop-11062e65.example.test: HA lease acquired in 3ms (first wake)
2026/11/30 21:26:08 activator: shop-11062e65.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/30 21:26:08 activator: shop-11062e65.example.test: started carlos-instance@shop\x2d11062e65.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:26:08 activator: shop-11062e65.example.test: carlos-instance@shop\x2d11062e65.example.test.service launched in 7ms, healthy 0s later
2026/11/30 21:26:08 activator: shop-11062e65.example.test: woke in 66ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 55ms
2026/11/30 21:26:09 activator: next-due probe shop-11062e65.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:26:09 activator: final checkpoint shop-11062e65.example.test: lease: release marker owed for s3://contract-bucket/t8-11062e65/shop-11062e65.example.test/lock.json (If-Match "b642b0fc1a480c2abf9aa45d9b0b0e04"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/11/30 21:26:09 activator: shop-11062e65.example.test hibernated
2026/11/30 21:26:09 activator: handover of shop-11062e65.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-11062e65.example.test client 4 "
hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-11062e65.example.test <nil> releasing shop-11062e65.example.test <nil> stop shop-11062e65.example.test marker=false clean=false <nil> left shop-11062e65.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:26:09 tenant admission is closed for shutdown
2026/11/30 21:26:09 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.32s)
PASS
ok github.com/carlosframework/platform/internal/host 0.983s
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:26:10 lease: instances/gen-1796073970276042248.shop.example.com: HA lease acquired in 5ms (first wake)
2026/11/30 21:26:10 lease: instances/gen-1796073970276042248.shop.example.com: HA lease acquired in 3ms (holder terminated)
gentake_minio_test.go:308: a second create-only copy onto instances/gen-1796073970276042248.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/11/30 21:26:10 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:26:10 http: proxy error: context canceled
2026/11/30 21:26:10 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)"
=== RUN TestGenerationTakeMinio/switch-412
2026/11/30 21:26:10 lease: instances/gen-1796073970401751395.shop.example.com: HA lease acquired in 4ms (first wake)
2026/11/30 21:26:10 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:26:10 lease: instances/gen-1796073970401751395.shop.example.com: HA lease acquired in 3ms (clean marker)
=== RUN TestGenerationTakeMinio/copy-version
=== RUN TestGenerationTakeMinio/store-time
2026/11/30 21:26:10 lease: instances/gen-1796073970499524179.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/30 21:26:10 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:26:10 lease: instances/gen-1796073970499524179.shop.example.com: HA lease acquired in 3ms (clean marker)
2026/11/30 21:26:10 lease: instances/gen-1796073970499524179.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/30 21:26:10 lease: instances/gen-1796073970499524179.shop.example.com: HA lease acquired in 3ms (unclean marker)
2026/11/30 21:26:10 lease: instances/gen-1796073970499524179.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/30 21:26:10 lease: instances/gen-1796073970499524179.shop.example.com: HA lease acquired in 2ms (unclean marker)
=== RUN TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.39s)
--- PASS: TestGenerationTakeMinio/take (0.13s)
--- 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.399s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/sync v0.23.0
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
staticcheck: clean
=== govulncheck ===
go version go1.26.10 linux/arm64
go: downloading golang.org/x/vuln v1.8.0
go: downloading golang.org/x/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 1m55.71s
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 4128 6292 . 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 30623 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 -: 4128 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 (115.71s)
PASS
ok github.com/carlosframework/platform/internal/codehealth 116.791s
=== code-health-record ===
go version go1.26.10 linux/arm64
code-health record: HEAD is on main; comparing with its parent 46c0556ac8f9af53e0a658be7e5b9644f5dbb960
=== RUN TestRecordAgainstBase
--- PASS: TestRecordAgainstBase (0.01s)
PASS
ok github.com/carlosframework/platform/internal/codehealth 0.008s
code-health record: no line went up without a reason
=== race ===
go version go1.26.10 linux/arm64
GATE_RACE=1 .amadan/test-gate.sh
=== internal_systemd@0 (13 s, from +14 s)
ok github.com/carlosframework/platform/internal/systemd 12.591s
=== internal_rootaws@0 (26 s, from +34 s)
ok github.com/carlosframework/platform/internal/rootaws 25.594s
=== internal_activator@0 (271 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 268.330s
=== internal_activator@1 (250 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 247.499s
=== internal_activator@2 (289 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 286.441s
=== internal_activator@3 (423 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 420.815s
=== internal_activator@4 (287 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 284.862s
=== internal_activator@5 (312 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 309.279s
=== internal_activator@6 (296 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 293.785s
=== internal_activator@7 (422 s, from +112 s)
ok github.com/carlosframework/platform/internal/activator 419.951s
=== internal_edge@0 (83 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 80.591s
=== internal_edge@1 (101 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 98.607s
=== internal_edge@2 (210 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 207.183s
=== internal_edge@3 (164 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 161.434s
=== internal_edge@4 (191 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 187.617s
=== internal_edge@5 (230 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 226.586s
=== internal_edge@6 (204 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 201.179s
=== internal_edge@7 (215 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 211.686s
=== internal_edge@8 (265 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 262.328s
=== internal_edge@9 (286 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 282.921s
=== internal_edge@10 (226 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 223.101s
=== internal_edge@11 (223 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 220.020s
=== internal_edge@12 (253 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 250.015s
=== internal_edge@13 (256 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 253.404s
=== internal_edge@14 (176 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 173.004s
=== internal_edge@15 (257 s, from +136 s)
ok github.com/carlosframework/platform/internal/edge 253.779s
=== internal_host@0 (16 s, from +196 s)
ok github.com/carlosframework/platform/internal/host 12.203s
=== internal_host@1 (10 s, from +196 s)
ok github.com/carlosframework/platform/internal/host 5.632s
=== lists: internal_edge 135 s, internal_activator 112 s, internal_host 196 s, internal_rootaws 33 s, internal_systemd 13 s
=== cpu: the gate used 7711 cpu-seconds in 535 s, about 14.4 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/charmbracelet/lipgloss v0.5.0
go: downloading github.com/spf13/cobra v1.9.1
go: downloading github.com/BobuSumisu/aho-corasick v1.0.3
go: downloading github.com/spf13/viper v1.19.0
go: downloading golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
go: downloading github.com/h2non/filetype v1.1.3
go: downloading github.com/gitleaks/go-gitdiff v0.9.1
go: downloading github.com/mholt/archives v0.1.2
go: downloading github.com/fatih/semgroup v1.2.0
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading golang.org/x/text v0.22.0
go: downloading github.com/nwaples/rardecode/v2 v2.1.0
go: downloading github.com/klauspost/compress v1.17.11
go: downloading golang.org/x/sync v0.11.0
go: downloading github.com/sorairolake/lzip-go v0.3.5
go: downloading github.com/pierrec/lz4/v4 v4.1.21
go: downloading github.com/therootcompany/xz v1.0.1
go: downloading github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
go: downloading github.com/ulikunitz/xz v0.5.12
go: downloading github.com/minio/minlz v1.0.0
go: downloading github.com/bodgit/sevenzip v1.6.0
go: downloading github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3
go: downloading github.com/klauspost/pgzip v1.2.6
go: downloading github.com/STARRY-S/zip v0.2.1
go: downloading github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/muesli/termenv v0.15.1
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/huandu/xstrings v1.5.0
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.4.0
go: downloading github.com/spf13/cast v1.7.1
go: downloading golang.org/x/crypto v0.35.0
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/bodgit/plumbing v1.3.0
go: downloading github.com/bodgit/windows v1.0.1
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading go4.org v0.0.0-20230225012048-214862532bf5
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.7
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading golang.org/x/sys v0.30.0
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading github.com/magiconair/properties v1.8.9
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading gopkg.in/ini.v1 v1.67.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 12113 tracked files; 33 not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)
gitleaks: clean
landed from sec-h3-m3-envelope
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-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/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/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/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 a8e3d1999..ea1753789 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -317,3 +317,4 @@ plan14-root-reads-gvisor-followups.tsv bf71949458c3c44c86b778a2a3e0d0b352268f564 |
| plan14-root-reads-instance-usage.tsv e3c8bc6a560e863ed44c7ab2f9367a4347ec767d8da2c3b1f1eafc90e45c89e8 |
| plan14-root-reads-sec-h5-m8-fleet-hostnames.tsv a6a19c800d55f99ed1c70068e38ffa66aef7af8f55199e97e986d9bbb0e0d80d |
| plan14-root-reads-infra-floor-keys-deny.tsv 3d13ade9d1fce3bc1a7d7250d75f2cc5ea3563ca6426401f428ca3a86af19619 |
| +plan14-root-reads-sec-h3-m3-envelope.tsv 76f69ece310924c374511605d0f6c718464d6374292961ca6a53955ec36f6e21 |
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 |