media: result objects never outlive their job
Video conversion spec amendment A8 (dev drill R4, findings F1 and F2). The deployment bucket is versioned, so a plain delete of media-results/<execution>.json left a noncurrent version under a delete marker, and a create-only PUT through a still-valid transfer URL could recreate the result after cleanup. - Cleanup lists the key's versions and deletes every version and delete marker of exactly that key. - A stopped row is cleaned at the later of the observation and its grant bound (dispatched_at + 65 min), when every transfer has expired. - Every execution sent to RunTask keeps a cleanup duty, including given-up executions (new columns prior_execution, prior_cleanup_due). - deployment-buckets: lifecycle rules expire media-results/ objects and noncurrent versions after a day and remove expired delete markers. - media-engine: the console policy gains s3:ListBucketVersions (prefix media-results/*) and s3:DeleteObjectVersion on media-results/*. Rollout order: apply the media-engine console policy (s3:ListBucketVersions, s3:DeleteObjectVersion on media-results/) and the deployment-buckets lifecycle rules before any console runs this code. Until then every due cleanup is refused and retried each pass. Census: census-ruling-media-results-cleanup, Astra approved (#280); re-pinned onto main's chain at merge, seal 6921575b. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from media-results-cleanup into main.
35 files changed,
+2,054
−103
.amadan/ci.d/30-minio-contract+7 −1docs/superpowers/notes/census-claims-media-results-cleanup.tsv+7 −0docs/superpowers/notes/census-proposal-media-results-cleanup.md+27 −0docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup-R2.md+32 −0docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md+60 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md+129 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup.md+155 −0docs/superpowers/specs/2026-11-16-video-conversion-design.md+64 −0infra/modules/deployment-buckets/main.tf+44 −2infra/modules/deployment-buckets/tests/media_results.tftest.hcl+100 −0infra/modules/media-engine/iam.tf+19 −0infra/modules/media-engine/tests/media_engine.tftest.hcl+8 −0internal/console/mediapass_test.go+35 −9internal/console/mediaretire_test.go+8 −0internal/media/mediatest/grants.go+63 −13internal/mediaaws/config.go+2 −0internal/mediaaws/grants.go+73 −10internal/mediaaws/mediaaws_test.go+11 −5internal/mediaaws/minio_test.go+72 −0internal/mediaaws/versions_test.go+373 −0internal/mediajobs/dispatch.go+87 −20internal/mediajobs/jobs_test.go+295 −10internal/mediajobs/retire.go+62 −2internal/mediajobs/schema.go+7 −1internal/mediajobs/track.go+14 −11internal/medialocal/e2e_test.go+10 −2internal/provision/media_results_cleanup_census_test.go+22 −0internal/provision/plan9_b8_census_test.go+1 −1internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-media-results-cleanup.tsv+15 −0internal/sim/mediajobs/actions_test.go+54 −0internal/sim/mediajobs/invariants_test.go+88 −7internal/sim/mediajobs/sim_test.go+2 −0internal/sim/mediajobs/witness_test.go+63 −0internal/sim/mediajobs/world_test.go+44 −9
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-RwSpwj
.amadan/test-gate.sh
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 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading github.com/superfly/ltx v0.5.1
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 golang.org/x/crypto v0.58.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 golang.org/x/sys v0.49.0
go: downloading github.com/pion/logging v0.2.4
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading golang.org/x/sync v0.24.0
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.14
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.31
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading golang.org/x/text v0.43.0
go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0
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 golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
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 github.com/google/uuid v1.6.0
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 (169 s, from +0 s)
go: downloading modernc.org/sqlite v1.55.0
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
=== vet-tags (187 s, from +0 s)
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/google/uuid v1.6.0
=== gofmt (1 s, from +0 s)
gofmt -l .: clean
=== rest (381 s, from +14 s)
ok github.com/carlosframework/platform/cmd/carlos-media 120.855s
? github.com/carlosframework/platform/cmd/changelog [no test files]
ok github.com/carlosframework/platform/cmd/console 206.777s
ok github.com/carlosframework/platform/cmd/mediaimage 42.955s
ok github.com/carlosframework/platform/cmd/moveprobe 15.787s
ok github.com/carlosframework/platform/cmd/pricebook-export 0.049s
ok github.com/carlosframework/platform/cmd/rootfswitness 0.130s
ok github.com/carlosframework/platform/cmd/runsc-assets 0.122s
ok github.com/carlosframework/platform/cmd/zddprobe 0.947s
ok github.com/carlosframework/platform/internal/agentsock 0.094s
ok github.com/carlosframework/platform/internal/alerting 0.022s
ok github.com/carlosframework/platform/internal/analytics 0.209s
ok github.com/carlosframework/platform/internal/appconfig 44.189s
ok github.com/carlosframework/platform/internal/apperr 0.397s
ok github.com/carlosframework/platform/internal/applog 0.569s
ok github.com/carlosframework/platform/internal/apppolicy 1.751s
ok github.com/carlosframework/platform/internal/assetcache 0.344s
ok github.com/carlosframework/platform/internal/awsinv 0.026s
ok github.com/carlosframework/platform/internal/awsmanaged 0.584s
ok github.com/carlosframework/platform/internal/awsregiongroup 0.153s
ok github.com/carlosframework/platform/internal/awsterminations 0.021s
ok github.com/carlosframework/platform/internal/backupswords 0.016s
ok github.com/carlosframework/platform/internal/billing 0.110s
ok github.com/carlosframework/platform/internal/billing/billingtest 0.047s
ok github.com/carlosframework/platform/internal/billingstripe 1.955s
ok github.com/carlosframework/platform/internal/boxchoice 0.025s
ok github.com/carlosframework/platform/internal/boxid 2.252s
? 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.019s
ok github.com/carlosframework/platform/internal/boxself 0.129s
ok github.com/carlosframework/platform/internal/boxvolumes 0.033s
ok github.com/carlosframework/platform/internal/caps 2.998s
ok github.com/carlosframework/platform/internal/certwarm 0.009s
ok github.com/carlosframework/platform/internal/cgroup 1.282s
ok github.com/carlosframework/platform/internal/changelog 3.408s
ok github.com/carlosframework/platform/internal/clamd 0.086s
? github.com/carlosframework/platform/internal/cliflag [no test files]
ok github.com/carlosframework/platform/internal/clireg 0.015s
ok github.com/carlosframework/platform/internal/codehealth 16.339s
ok github.com/carlosframework/platform/internal/compute 0.028s
ok github.com/carlosframework/platform/internal/consolefleet 0.010s
? github.com/carlosframework/platform/internal/controlname [no test files]
? github.com/carlosframework/platform/internal/controlsock [no test files]
ok github.com/carlosframework/platform/internal/dbdoor 10.756s
ok github.com/carlosframework/platform/internal/dbdoor/dbdoortest 0.035s
ok github.com/carlosframework/platform/internal/dbquery 0.027s
ok github.com/carlosframework/platform/internal/dbreads 3.035s
? github.com/carlosframework/platform/internal/dbreads/dbreadstest [no test files]
ok github.com/carlosframework/platform/internal/dbverify 0.030s
ok github.com/carlosframework/platform/internal/demo 0.011s
ok github.com/carlosframework/platform/internal/demobuild 2.469s
ok github.com/carlosframework/platform/internal/democlaim 0.504s
ok github.com/carlosframework/platform/internal/devbox 15.833s
ok github.com/carlosframework/platform/internal/dnsrec 0.007s
ok github.com/carlosframework/platform/internal/docsite 0.083s
ok github.com/carlosframework/platform/internal/domainreg 0.012s
ok github.com/carlosframework/platform/internal/domains 66.799s
ok github.com/carlosframework/platform/internal/doorkey 0.028s
ok github.com/carlosframework/platform/internal/economics 0.015s
ok github.com/carlosframework/platform/internal/edgefence 0.100s
ok github.com/carlosframework/platform/internal/edgeguard 0.271s
? github.com/carlosframework/platform/internal/edgeproof [no test files]
ok github.com/carlosframework/platform/internal/edgesfile 0.102s
ok github.com/carlosframework/platform/internal/egressaddr 0.008s
ok github.com/carlosframework/platform/internal/execsandbox 98.380s
ok github.com/carlosframework/platform/internal/fileacl 0.007s
ok github.com/carlosframework/platform/internal/fleetapi 1.660s
ok github.com/carlosframework/platform/internal/fleetstore 0.009s
ok github.com/carlosframework/platform/internal/fxrate 0.018s
ok github.com/carlosframework/platform/internal/gate 4.877s
ok github.com/carlosframework/platform/internal/genselect 0.107s
ok github.com/carlosframework/platform/internal/geo 0.039s
ok github.com/carlosframework/platform/internal/geoip 0.108s
ok github.com/carlosframework/platform/internal/groupadmission 0.008s
ok github.com/carlosframework/platform/internal/grouprollaws 16.748s
ok github.com/carlosframework/platform/internal/hadeparture 0.026s
ok github.com/carlosframework/platform/internal/hafresh 0.007s
ok github.com/carlosframework/platform/internal/hairpin 0.163s
ok github.com/carlosframework/platform/internal/historyreadback 1.051s
ok github.com/carlosframework/platform/internal/hostactors 21.398s
ok github.com/carlosframework/platform/internal/hostbox 20.742s
ok github.com/carlosframework/platform/internal/hostclaim 2.031s
ok github.com/carlosframework/platform/internal/hostenv 0.032s
ok github.com/carlosframework/platform/internal/hostevidence 0.010s
ok github.com/carlosframework/platform/internal/hostexec 25.600s
ok github.com/carlosframework/platform/internal/hostfence 0.171s
ok github.com/carlosframework/platform/internal/hostfiles 27.193s
ok github.com/carlosframework/platform/internal/hostfloor 0.136s
ok github.com/carlosframework/platform/internal/hostguard 1.529s
ok github.com/carlosframework/platform/internal/hostops 7.098s
? github.com/carlosframework/platform/internal/hostops/fencerelease [no test files]
ok github.com/carlosframework/platform/internal/hostops/internal/fencerelease 0.009s
ok github.com/carlosframework/platform/internal/hostquarantine 0.016s
ok github.com/carlosframework/platform/internal/hostrelocate 1.532s
ok github.com/carlosframework/platform/internal/hostresolve 0.592s
ok github.com/carlosframework/platform/internal/hostwrite 0.009s
ok github.com/carlosframework/platform/internal/infraview 0.006s
ok github.com/carlosframework/platform/internal/ingresshealth 0.010s
ok github.com/carlosframework/platform/internal/ingresshealth/awstg 0.015s
ok github.com/carlosframework/platform/internal/instancectl 55.216s
ok github.com/carlosframework/platform/internal/instanceexec 8.447s
ok github.com/carlosframework/platform/internal/instancefs 0.029s
ok github.com/carlosframework/platform/internal/instancekey 0.008s
ok github.com/carlosframework/platform/internal/instanceupdates 0.035s
ok github.com/carlosframework/platform/internal/interactive 0.631s
ok github.com/carlosframework/platform/internal/launchd 0.010s
ok github.com/carlosframework/platform/internal/layout 22.055s
ok github.com/carlosframework/platform/internal/layout/pubclass 102.869s
ok github.com/carlosframework/platform/internal/lbhealth 0.010s
ok github.com/carlosframework/platform/internal/lease 141.067s
ok github.com/carlosframework/platform/internal/lease/leasetest 1.493s
ok github.com/carlosframework/platform/internal/lease/locktest 0.020s
ok github.com/carlosframework/platform/internal/ledger 0.113s
ok github.com/carlosframework/platform/internal/mail 0.723s
ok github.com/carlosframework/platform/internal/mailer 0.768s
ok github.com/carlosframework/platform/internal/mailsubmit 1.052s
ok github.com/carlosframework/platform/internal/mailwire 0.003s
ok github.com/carlosframework/platform/internal/maintenance 0.173s
ok github.com/carlosframework/platform/internal/maintenanceexec 8.367s
ok github.com/carlosframework/platform/internal/maintenanceguard 0.309s
ok github.com/carlosframework/platform/internal/media 2.029s
ok github.com/carlosframework/platform/internal/media/mediatest 0.009s
ok github.com/carlosframework/platform/internal/mediaaws 63.294s
ok github.com/carlosframework/platform/internal/mediahandler 43.234s
ok github.com/carlosframework/platform/internal/mediajobs 0.962s
ok github.com/carlosframework/platform/internal/medialocal 10.359s
ok github.com/carlosframework/platform/internal/metrics 0.107s
ok github.com/carlosframework/platform/internal/minorunits 0.007s
ok github.com/carlosframework/platform/internal/moves 56.121s
ok github.com/carlosframework/platform/internal/moves/archive 2.635s
ok github.com/carlosframework/platform/internal/moves/offlinerun 0.103s
ok github.com/carlosframework/platform/internal/namedunits 0.043s
ok github.com/carlosframework/platform/internal/objstore 1.915s
ok github.com/carlosframework/platform/internal/ops 15.790s
ok github.com/carlosframework/platform/internal/pageindex 3.967s
ok github.com/carlosframework/platform/internal/parity 0.124s
? github.com/carlosframework/platform/internal/parity/cmd/parity-doc [no test files]
ok github.com/carlosframework/platform/internal/park 0.629s
ok github.com/carlosframework/platform/internal/perf 0.217s
ok github.com/carlosframework/platform/internal/plans 0.115s
ok github.com/carlosframework/platform/internal/privatefile 0.014s
ok github.com/carlosframework/platform/internal/provision 241.462s
ok github.com/carlosframework/platform/internal/proxyproto 0.930s
ok github.com/carlosframework/platform/internal/publicrelease 0.097s
ok github.com/carlosframework/platform/internal/ratelimit 0.207s
ok github.com/carlosframework/platform/internal/regionlabel 0.083s
ok github.com/carlosframework/platform/internal/regionname 0.034s
ok github.com/carlosframework/platform/internal/registrar 0.012s
ok github.com/carlosframework/platform/internal/registrar/openprovider 0.652s
? github.com/carlosframework/platform/internal/registrar/registrartest [no test files]
ok github.com/carlosframework/platform/internal/registry 83.973s
ok github.com/carlosframework/platform/internal/relay 7.752s
ok github.com/carlosframework/platform/internal/release 92.195s
ok github.com/carlosframework/platform/internal/replicagen 0.020s
ok github.com/carlosframework/platform/internal/replicas 0.063s
ok github.com/carlosframework/platform/internal/reqrec 8.721s
ok github.com/carlosframework/platform/internal/rollout 12.583s
ok github.com/carlosframework/platform/internal/rolloutwords 0.031s
ok github.com/carlosframework/platform/internal/rootaws 105.644s
ok github.com/carlosframework/platform/internal/rootfsimage 1.047s
ok github.com/carlosframework/platform/internal/rootparticipation 0.171s
ok github.com/carlosframework/platform/internal/rootstate 0.043s
ok github.com/carlosframework/platform/internal/runs 1.875s
ok github.com/carlosframework/platform/internal/s3compat 0.064s
ok github.com/carlosframework/platform/internal/s3fake 1.898s
ok github.com/carlosframework/platform/internal/safefile 0.035s
ok github.com/carlosframework/platform/internal/schedule 26.665s
ok github.com/carlosframework/platform/internal/seeds 0.053s
ok github.com/carlosframework/platform/internal/sim/litestreamfacts 4.530s
ok github.com/carlosframework/platform/internal/sim/mediajobs 52.697s
ok github.com/carlosframework/platform/internal/sim/regionha 23.792s
ok github.com/carlosframework/platform/internal/status 0.336s
ok github.com/carlosframework/platform/internal/steering 0.345s
ok github.com/carlosframework/platform/internal/stopevidence 0.412s
ok github.com/carlosframework/platform/internal/storecfg 0.443s
ok github.com/carlosframework/platform/internal/svcrole 0.014s
ok github.com/carlosframework/platform/internal/systemd 6.538s
? github.com/carlosframework/platform/internal/systemdshow [no test files]
ok github.com/carlosframework/platform/internal/team 3.556s
ok github.com/carlosframework/platform/internal/teamcontract 0.272s
ok github.com/carlosframework/platform/internal/telemetry 0.097s
ok github.com/carlosframework/platform/internal/termfence 6.275s
ok github.com/carlosframework/platform/internal/timerspec 0.013s
ok github.com/carlosframework/platform/internal/tsidentity 4.174s
ok github.com/carlosframework/platform/internal/tunnelclient 0.435s
ok github.com/carlosframework/platform/internal/unixdial 0.017s
ok github.com/carlosframework/platform/internal/updatewords 0.041s
ok github.com/carlosframework/platform/internal/upstreamguard 0.013s
? github.com/carlosframework/platform/internal/upstreamguard/guardtest [no test files]
ok github.com/carlosframework/platform/internal/usage 0.040s
ok github.com/carlosframework/platform/internal/version 0.008s
ok github.com/carlosframework/platform/internal/vet 2.981s
ok github.com/carlosframework/platform/internal/zonehost 0.015s
ok github.com/carlosframework/platform/internal/zonehost/route53zones 0.089s
? 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.020s
ok github.com/carlosframework/platform/scripts/pathmapcheck 0.076s
ok github.com/carlosframework/platform/scripts/region-ha-g2/fixture 5.218s
ok github.com/carlosframework/platform/scripts/stateless-replicas-drill 1.227s
ok github.com/carlosframework/platform/scripts/witness-pointer 0.041s
=== cutover-witness (150 s, from +14 s)
ok github.com/carlosframework/platform 2.874s
=== internal_grouproll@0 (283 s, from +70 s)
ok github.com/carlosframework/platform/internal/grouproll 281.257s
=== internal_grouproll@1 (280 s, from +70 s)
ok github.com/carlosframework/platform/internal/grouproll 278.324s
=== internal_activator@0 (155 s, from +142 s)
ok github.com/carlosframework/platform/internal/activator 150.202s
=== internal_activator@1 (138 s, from +142 s)
ok github.com/carlosframework/platform/internal/activator 133.109s
=== internal_activator@2 (138 s, from +142 s)
ok github.com/carlosframework/platform/internal/activator 133.194s
=== internal_activator@3 (175 s, from +142 s)
ok github.com/carlosframework/platform/internal/activator 170.182s
=== internal_edge@0 (199 s, from +167 s)
ok github.com/carlosframework/platform/internal/edge 190.425s
=== internal_edge@1 (145 s, from +167 s)
ok github.com/carlosframework/platform/internal/edge 138.798s
=== internal_edge@2 (172 s, from +167 s)
ok github.com/carlosframework/platform/internal/edge 163.582s
=== internal_edge@3 (213 s, from +167 s)
ok github.com/carlosframework/platform/internal/edge 205.283s
=== root@0 (114 s, from +172 s)
ok github.com/carlosframework/platform 104.621s
=== root@1 (111 s, from +172 s)
ok github.com/carlosframework/platform 101.015s
=== root@2 (123 s, from +172 s)
ok github.com/carlosframework/platform 112.261s
=== root@3 (110 s, from +172 s)
ok github.com/carlosframework/platform 100.573s
=== root@4 (119 s, from +172 s)
ok github.com/carlosframework/platform 108.977s
=== internal_host@0 (145 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 140.601s
=== internal_host@1 (140 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 135.639s
=== internal_host@2 (213 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 207.787s
=== internal_host@3 (255 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 250.767s
=== internal_host@4 (136 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 131.693s
=== internal_host@5 (268 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 262.734s
=== internal_console@0 (150 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 143.323s
=== internal_console@1 (173 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 165.492s
=== internal_console@2 (208 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 200.814s
=== internal_console@3 (242 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 235.929s
=== internal_console@4 (197 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 189.836s
=== internal_console@5 (213 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 205.832s
=== internal_console@6 (211 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 202.801s
=== internal_console@7 (210 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 202.858s
=== internal_console@8 (212 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 204.832s
=== internal_console@9 (213 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 206.453s
=== internal_console@10 (226 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 218.666s
=== internal_console@11 (239 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 230.954s
=== internal_console@12 (283 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 275.226s
=== internal_console@13 (260 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 253.134s
=== internal_console@14 (239 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 230.997s
=== internal_console@15 (216 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 208.304s
=== internal_console@16 (237 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 229.537s
=== internal_console@17 (203 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 195.957s
=== internal_console@18 (213 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 204.601s
=== internal_console@19 (207 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 199.231s
=== internal_console@20 (207 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 199.713s
=== internal_console@21 (221 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 213.402s
=== internal_console@22 (214 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 206.773s
=== internal_console@23 (246 s, from +216 s)
ok github.com/carlosframework/platform/internal/console 239.295s
=== lists: internal_console 215 s, internal_edge 165 s, internal_activator 141 s, internal_host 211 s, root 170 s, internal_grouproll 70 s
=== cpu: the gate used 12611 cpu-seconds in 499 s, about 25.3 of 32 cores; the machine as a whole was 84% busy
=== opentofu ===
opentofu: 37 test files in 11 suites, OpenTofu v1.13.9
initialised in 14 s
ok 16 s infra/modules/box-fence-writer/tests/writer.tftest.hcl Success! 1 passed, 0 failed.
ok 30 s infra/modules/deployment-buckets/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 18 s infra/modules/deployment-buckets/tests/db_reads.tftest.hcl Success! 1 passed, 0 failed.
ok 14 s infra/modules/deployment-buckets/tests/evidence.tftest.hcl Success! 1 passed, 0 failed.
ok 27 s infra/modules/deployment-buckets/tests/fence_writers.tftest.hcl Success! 3 passed, 0 failed.
ok 23 s infra/modules/deployment-buckets/tests/media_results.tftest.hcl Success! 2 passed, 0 failed.
ok 86 s infra/modules/media-engine/tests/media_engine.tftest.hcl Success! 24 passed, 0 failed.
ok 33 s infra/modules/pdf-host/tests/computed.tftest.hcl Success! 2 passed, 0 failed.
ok 60 s infra/modules/pdf-host/tests/pdf_host.tftest.hcl Success! 24 passed, 0 failed.
ok 43 s infra/modules/region-group-operator-document/tests/document.tftest.hcl Success! 12 passed, 0 failed.
ok 21 s infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl Success! 2 passed, 0 failed.
ok 69 s infra/modules/region-host/ingress/tests/group_ingress.tftest.hcl Success! 30 passed, 0 failed.
ok 46 s infra/modules/region-host/tests/alert_publish.tftest.hcl Success! 18 passed, 0 failed.
ok 42 s infra/modules/region-host/tests/alerts_topic.tftest.hcl Success! 16 passed, 0 failed.
ok 15 s infra/modules/region-host/tests/analytics_prune.tftest.hcl Success! 2 passed, 0 failed.
ok 16 s infra/modules/region-host/tests/console_mail.tftest.hcl Success! 4 passed, 0 failed.
ok 8 s infra/modules/region-host/tests/fixed_state_unchanged.tftest.hcl Success! 1 passed, 0 failed.
ok 70 s infra/modules/region-host/tests/group.tftest.hcl Success! 32 passed, 0 failed.
ok 11 s infra/modules/region-host/tests/group_alarms.tftest.hcl Success! 4 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/group_iam.tftest.hcl Success! 4 passed, 0 failed.
ok 6 s infra/modules/region-host/tests/group_isolation.tftest.hcl Success! 1 passed, 0 failed.
ok 36 s infra/modules/region-host/tests/group_operator.tftest.hcl Success! 13 passed, 0 failed.
ok 9 s infra/modules/region-host/tests/group_user_data.tftest.hcl Success! 3 passed, 0 failed.
ok 28 s infra/modules/region-host/tests/health_alarms.tftest.hcl Success! 10 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/ingress_drain_read.tftest.hcl Success! 4 passed, 0 failed.
ok 5 s infra/modules/region-host/tests/instance_metadata.tftest.hcl Success! 1 passed, 0 failed.
ok 23 s infra/modules/region-host/tests/mailer.tftest.hcl Success! 6 passed, 0 failed.
ok 12 s infra/modules/region-host/tests/mailer_group.tftest.hcl Success! 2 passed, 0 failed.
ok 13 s infra/modules/region-host/tests/managed_fleets/group_refusal.tftest.hcl Success! 2 passed, 0 failed.
ok 104 s infra/modules/region-host/tests/managed_fleets/managed_fleets.tftest.hcl Success! 46 passed, 0 failed.
ok 75 s infra/modules/region-host/tests/store_conversion.tftest.hcl Success! 27 passed, 0 failed.
ok 18 s infra/modules/region-host/tests/store_scanning.tftest.hcl Success! 4 passed, 0 failed.
ok 29 s infra/modules/region-host/tests/store_versioning.tftest.hcl Success! 11 passed, 0 failed.
ok 18 s infra/modules/region-host/tests/user_data_ignored.tftest.hcl Success! 3 passed, 0 failed.
ok 13 s infra/modules/region-remote-host/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 16 s infra/modules/region-remote-host/tests/no_deployment_bucket.tftest.hcl Success! 5 passed, 0 failed.
ok 30 s infra/modules/scanner-host/tests/scanner_host.tftest.hcl Success! 14 passed, 0 failed.
opentofu: 37 files in 204 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: 65929378 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:35884
Added `local` successfully.
Bucket created successfully `local/contract-bucket`.
Bucket created successfully `local/denied-bucket`.
Created policy `contract-only` successfully.
Added user `scopeduser` successfully.
Attached Policies: [contract-only]
To User: scopeduser
buckets and scoped user ready
=== RUN TestDeliveredContractMinio
=== RUN TestDeliveredContractMinio/put
=== RUN TestDeliveredContractMinio/get_round-trips_the_body
=== RUN TestDeliveredContractMinio/list_shows_the_key
=== RUN TestDeliveredContractMinio/head_and_list_agree_on_the_version
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_its_own_object
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed
=== RUN TestDeliveredContractMinio/delete_removes_it
=== RUN TestDeliveredContractMinio/cross-bucket_denial
--- PASS: TestDeliveredContractMinio (0.03s)
--- PASS: TestDeliveredContractMinio/put (0.00s)
--- PASS: TestDeliveredContractMinio/get_round-trips_the_body (0.00s)
--- PASS: TestDeliveredContractMinio/list_shows_the_key (0.00s)
--- PASS: TestDeliveredContractMinio/head_and_list_agree_on_the_version (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route (0.02s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed (0.00s)
--- PASS: TestDeliveredContractMinio/delete_removes_it (0.00s)
--- PASS: TestDeliveredContractMinio/cross-bucket_denial (0.00s)
PASS
ok github.com/carlosframework/platform/internal/objstore 0.038s
=== RUN TestT4StorageProbeMinio
2026/11/25 02:21:22 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18EB28630E7AD3A7, HostID: aebfd07b0fd87be7eb71c0d5f3a25b4e544f662e99c0cfeba8d8741a07e26d48, api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
--- PASS: TestT4StorageProbeMinio (0.01s)
PASS
ok github.com/carlosframework/platform/internal/host 0.047s
=== RUN TestS3StoreMinioContract
=== RUN TestS3StoreMinioContract/conditional_get_and_etag_listing
=== RUN TestS3StoreMinioContract/bump_through_every_mutation_path
--- PASS: TestS3StoreMinioContract (0.03s)
--- PASS: TestS3StoreMinioContract/conditional_get_and_etag_listing (0.01s)
--- PASS: TestS3StoreMinioContract/bump_through_every_mutation_path (0.02s)
PASS
ok github.com/carlosframework/platform/internal/release 0.042s
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.019s
=== 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.15s)
PASS
ok github.com/carlosframework/platform/internal/grouproll 0.475s
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/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/25 02:21:29 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/11/25 02:21:29 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/11/25 02:21:29 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/25 02:21:29 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/25 02:21:29 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/25 02:21:29 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/11/25 02:21:29 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%3A42307: could not determine target mailbox
agent.go:136: dbreads: dbr_4sx2ix5trzomps6oiaxmq5m2ku: planned 3 files (1544 bytes) and restored to 3 in 13ms
agent.go:136: dbreads: dbr_4sx2ix5trzomps6oiaxmq5m2ku: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/25 02:21:30 console: db read dbr_4sx2ix5trzomps6oiaxmq5m2ku: relayed 1 chunks (102 bytes) in 1.005s, ended done
agent.go:136: dbreads: dbr_qtnbrzaapulnineidadinkvpci: planned 1 files (720 bytes) and restored to 1 in 12ms
agent.go:136: dbreads: dbr_qtnbrzaapulnineidadinkvpci: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/25 02:21:31 console: db read dbr_qtnbrzaapulnineidadinkvpci: relayed 1 chunks (102 bytes) in 1.005s, ended done
agent.go:136: dbreads: dbr_e2r5ohlfxx4qsgtkjqycek7oce: planned 3 files (1544 bytes) and held through 3 in 12ms
agent.go:136: dbreads: dbr_e2r5ohlfxx4qsgtkjqycek7oce: output 1544 bytes in 1 confirmed chunks in 1ms
2026/11/25 02:21:32 console: db read dbr_e2r5ohlfxx4qsgtkjqycek7oce: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN TestDBForwardMinio/by_disconnect
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_cvbjpjt3p5z6ernn5ilyyi62mm: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/25 02:21:32 console: db read dbr_cvbjpjt3p5z6ernn5ilyyi62mm: relayed 0 chunks (0 bytes) in 34ms, ended client gone
agent.go:136: dbreads: dbr_cvbjpjt3p5z6ernn5ilyyi62mm: output 5 bytes in 1 confirmed chunks in 105ms
=== RUN TestDBForwardMinio/by_timeout
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_iksgotad5jubbelxj7obvlb7gi: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/25 02:21:53 console: db read dbr_iksgotad5jubbelxj7obvlb7gi: relayed 0 chunks (0 bytes) in 19.909s, ended no-result
agent.go:136: dbreads: dbr_iksgotad5jubbelxj7obvlb7gi: output 5 bytes in 1 confirmed chunks in 19.881s
--- PASS: TestDBForwardMinio (23.59s)
--- PASS: TestDBForwardMinio/by_disconnect (0.25s)
--- PASS: TestDBForwardMinio/by_timeout (20.02s)
PASS
ok github.com/carlosframework/platform/internal/console 23.634s
Bucket created successfully `local/media-transfers`.
Bucket created successfully `local/media-transfer-results`.
local/media-transfer-results versioning is enabled
Created policy `media-transfers` successfully.
Added user `mediatransfers` successfully.
Attached Policies: [media-transfers]
To User: mediatransfers
=== RUN TestMediaTransfersMinio
upload.go:117: codec: the store already holds video.mp4
upload.go:117: codec: the store already holds video.m3u8
upload.go:117: codec: the store already holds poster.jpg
--- PASS: TestMediaTransfersMinio (0.07s)
PASS
ok github.com/carlosframework/platform/internal/mediaaws 0.074s
Bucket created successfully `local/media-local-store`.
Bucket created successfully `local/media-local-results`.
Created policy `media-local` successfully.
Added user `medialocal` successfully.
Attached Policies: [media-local]
To User: medialocal
=== RUN TestLocalEndToEndMinio
--- PASS: TestLocalEndToEndMinio (0.55s)
PASS
ok github.com/carlosframework/platform/internal/medialocal 0.559s
=== RUN TestHeldHandoverTwoBoxMinio
2026/11/25 02:21:58 edge: mesh key: minted
2026/11/25 02:21:58 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/25 02:21:58 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/25 02:21:58 tenant admission is open. accepting tenant work
2026/11/25 02:21:58 activator: HA placement host=shop-d3001d71.example.test kind=Place ref=annie reason=roomiest generation=2026-11-25T02:21:58Z lock_generation=0
2026/11/25 02:21:58 lease: t8-d3001d71/shop-d3001d71.example.test: HA lease acquired in 4ms (first wake)
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: started carlos-instance@shop\x2dd3001d71.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/25 02:21:58 activator: shop-d3001d71.example.test: carlos-instance@shop\x2dd3001d71.example.test.service launched in 7ms, healthy 0s later
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: woke in 20ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 8ms, replicate 7ms
2026/11/25 02:21:58 lease: t8-d3001d71/plain-d3001d71.example.test: acquired in 2ms (client 0s, lock read and write 1ms)
2026/11/25 02:21:58 activator: no replica for plain-d3001d71.example.test in s3://contract-bucket/t8-d3001d71/plain-d3001d71.example.test — booting fresh
2026/11/25 02:21:58 activator: plain-d3001d71.example.test: started carlos-instance@plain\x2dd3001d71.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 1ms, instance key 0s, env 4ms, control socket 0s, key gate 0s, logs 0s) 5ms, launch file 0s, gate 0s, root start 1ms)
2026/11/25 02:21:58 activator: plain-d3001d71.example.test: carlos-instance@plain\x2dd3001d71.example.test.service launched in 6ms, healthy 0s later
2026/11/25 02:21:58 activator: plain-d3001d71.example.test: woke in 46ms: checks 0s, lease 2ms, restore 19ms, identity 0s, protect 0s, spawn 7ms, replicate 19ms
2026/11/25 02:21:58 lease: t8-d3001d71/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/11/25 02:21:58 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/25 02:21:58 activator: bot0.shop.bac.sidecar.internal: woke in 19ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, settle 0s, replicate 7ms
2026/11/25 02:21:58 activator: next-due probe plain-d3001d71.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/25 02:21:58 activator: plain-d3001d71.example.test hibernated
2026/11/25 02:21:58 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:4d354a0b572254241d1b3f57f69b4c032032beb9fb4104cd73cc3de621c92086) in 8ms: files 1ms, sync 4ms, record 1ms, marker 2ms
2026/11/25 02:21:58 activator: bot0.shop.bac.sidecar.internal hibernated
2026/11/25 02:21:58 activator: next-due probe shop-d3001d71.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: released with a marker (clean true, txid 1, files 3:affb6af5a4a0d5f2b0f990b17e91115265496b6ed1d69a1eb84e14a988ec30c0) in 6ms: files 1ms, sync 3ms, record 1ms, marker 2ms
2026/11/25 02:21:58 activator: shop-d3001d71.example.test hibernated
2026/11/25 02:21:58 lease: t8-d3001d71/shop-d3001d71.example.test: HA lease acquired in 3ms (clean marker)
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: restored (other-box)
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: started carlos-instance@shop\x2dd3001d71.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/25 02:21:58 activator: shop-d3001d71.example.test: carlos-instance@shop\x2dd3001d71.example.test.service launched in 2ms, healthy 0s later
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: woke in 37ms: checks 0s, lease 3ms, restore 24ms, identity 0s, protect 0s, spawn 2ms, replicate 7ms
2026/11/25 02:21:58 edge: ha-take shop-d3001d71.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/11/25 02:21:58 edge: forward shop-d3001d71.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:afbb1da55d15a78532fc6d10e03c3f26 Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-11-25 02:21:58.355479835 +0000 UTC FinishedAt:2026-11-25 02:21:58.453519302 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-d3001d71.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:plain-d3001d71.example.test Kind:other Marker:true Clean:true Reason:} {Host:bot0.shop.bac.sidecar.internal Kind:worker Marker:true Clean:true Reason:}] Unclean:[] Left:[] Holds:{LongestMS:77 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-d3001d71.example.test <nil> stop plain-d3001d71.example.test marker=true clean=true <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> releasing shop-d3001d71.example.test <nil> stop shop-d3001d71.example.test marker=true clean=true <nil> taken shop-d3001d71.example.test betty <nil> end-moves]
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/bot0.shop.bac.sidecar.internal/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/bot0.shop.bac.sidecar.internal/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/bot0.shop.bac.sidecar.internal/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-d3001d71/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-d3001d71/plain-d3001d71.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-d3001d71/bot0.shop.bac.sidecar.internal/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/head.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/generations/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/files/0/manifest.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/files/0/objects/0000000000000001-af05765c3b24a4677f370b1032c0d55c89221aff2bacd703862556e557126a1f
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/files/0/objects/0000000000000003-be153e3ba08f3481989249343dfb8f1583aad739eb394f96477ebdf7258b021f
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/0000/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/0000/0000000000000002-0000000000000002.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-d3001d71/shop-d3001d71.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-d3001d71/shop-d3001d71.example.test/0003/
hadrain_twobox_minio_linux_test.go:1243: drain took 142ms; S3 calls 49 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=33 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/25 02:21:58 lease: t8-d3001d71/plain-d3001d71.example.test: acquired in 2ms (client 0s, lock read and write 2ms)
2026/11/25 02:21:58 activator: plain-d3001d71.example.test: started carlos-instance@plain\x2dd3001d71.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/25 02:21:58 activator: plain-d3001d71.example.test: carlos-instance@plain\x2dd3001d71.example.test.service launched in 1ms, healthy 0s later
2026/11/25 02:21:58 lease: /tmp/carlos-minio-contract-mBtuma/g/dw2396504286/data/instances/plain-d3001d71.example.test/plain-d3001d71.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/11/25 02:21:58 activator: plain-d3001d71.example.test: woke in 9ms: checks 0s, lease 2ms, restore 0s, identity 0s, protect 1ms, spawn 2ms, replicate 5ms
2026/11/25 02:21:58 activator: next-due probe shop-d3001d71.example.test: decode /api/next-due: invalid character 'b' looking for beginning of value — recording none (it sleeps until a request)
2026/11/25 02:21:58 activator: shop-d3001d71.example.test: released with a marker (clean true, txid 2, files 3:affb6af5a4a0d5f2b0f990b17e91115265496b6ed1d69a1eb84e14a988ec30c0) in 4ms: files 1ms, sync 0s, record 1ms, marker 2ms
2026/11/25 02:21:58 activator: shop-d3001d71.example.test hibernated
2026/11/25 02:21:58 tenant admission is closed for shutdown
2026/11/25 02:21:58 activator: next-due probe plain-d3001d71.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/25 02:21:58 activator: plain-d3001d71.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.47s)
=== RUN TestHeldHandoverLostLeaseMinio
2026/11/25 02:21:58 edge: mesh key: minted
2026/11/25 02:21:58 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/25 02:21:58 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/25 02:21:58 tenant admission is open. accepting tenant work
2026/11/25 02:21:58 activator: HA placement host=shop-b591e9e0.example.test kind=Place ref=annie reason=roomiest generation=2026-11-25T02:21:58Z lock_generation=0
2026/11/25 02:21:58 lease: t8-b591e9e0/shop-b591e9e0.example.test: HA lease acquired in 3ms (first wake)
2026/11/25 02:21:58 activator: shop-b591e9e0.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/25 02:21:58 activator: shop-b591e9e0.example.test: started carlos-instance@shop\x2db591e9e0.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/25 02:21:58 activator: shop-b591e9e0.example.test: carlos-instance@shop\x2db591e9e0.example.test.service launched in 7ms, healthy 0s later
2026/11/25 02:21:58 activator: shop-b591e9e0.example.test: woke in 18ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 6ms
2026/11/25 02:21:58 activator: next-due probe shop-b591e9e0.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/25 02:21:58 activator: final checkpoint shop-b591e9e0.example.test: lease: release marker owed for s3://contract-bucket/t8-b591e9e0/shop-b591e9e0.example.test/lock.json (If-Match "f20975dc37caf826031934f104f25964"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/11/25 02:21:58 activator: shop-b591e9e0.example.test hibernated
2026/11/25 02:21:58 activator: handover of shop-b591e9e0.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-b591e9e0.example.test client 4 "
hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-b591e9e0.example.test <nil> releasing shop-b591e9e0.example.test <nil> stop shop-b591e9e0.example.test marker=false clean=false <nil> left shop-b591e9e0.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/25 02:21:58 tenant admission is closed for shutdown
2026/11/25 02:21:58 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.27s)
PASS
ok github.com/carlosframework/platform/internal/host 0.787s
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/25 02:22:00 lease: instances/gen-1795573319996032125.shop.example.com: HA lease acquired in 5ms (first wake)
2026/11/25 02:22:00 lease: instances/gen-1795573319996032125.shop.example.com: HA lease acquired in 2ms (holder terminated)
gentake_minio_test.go:308: a second create-only copy onto instances/gen-1795573319996032125.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/11/25 02:22:00 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/25 02:22:00 http: proxy error: context canceled
2026/11/25 02:22:00 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/25 02:22:00 lease: instances/gen-1795573320121338563.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/25 02:22:00 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/25 02:22:00 lease: instances/gen-1795573320121338563.shop.example.com: HA lease acquired in 3ms (clean marker)
=== RUN TestGenerationTakeMinio/copy-version
=== RUN TestGenerationTakeMinio/store-time
2026/11/25 02:22:00 lease: instances/gen-1795573320224641691.shop.example.com: HA lease acquired in 4ms (first wake)
2026/11/25 02:22:00 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: fetch ltx files: lease: a write has waited too long to reach storage (write fence)"
2026/11/25 02:22:00 lease: instances/gen-1795573320224641691.shop.example.com: HA lease acquired in 3ms (clean marker)
2026/11/25 02:22:00 lease: instances/gen-1795573320224641691.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/25 02:22:00 lease: instances/gen-1795573320224641691.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/25 02:22:00 lease: instances/gen-1795573320224641691.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/25 02:22:00 lease: instances/gen-1795573320224641691.shop.example.com: HA lease acquired in 2ms (unclean marker)
=== RUN TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.34s)
--- PASS: TestGenerationTakeMinio/take (0.13s)
--- PASS: TestGenerationTakeMinio/switch-412 (0.09s)
--- PASS: TestGenerationTakeMinio/copy-version (0.01s)
--- PASS: TestGenerationTakeMinio/store-time (0.10s)
--- PASS: TestGenerationTakeMinio/skew (0.01s)
PASS
ok github.com/carlosframework/platform/internal/lease 0.354s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/sync v0.23.0
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
staticcheck: clean
=== govulncheck ===
go version go1.26.10 linux/arm64
go: downloading golang.org/x/vuln v1.8.0
go: downloading golang.org/x/tools v0.50.0
go: downloading golang.org/x/telemetry v0.0.0-20260908163034-4bcc4b2ee518
govulncheck: scanned github.com/carlosframework/platform, amadan.net/carlos/platform.git/launchctx
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 1m49.261s
codehealth_test.go:107: line metrics (code lines, then physical):
file-lines 5471 7324 internal/activator activator_test.go
file-lines 4223 7052 internal/console server.go
file-lines 4175 6358 . 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 3188 6348 internal/host agent.go
file-lines 3094 3992 internal/provision reconcile_test.go
func-lines 870 891 internal/host plan14InstalledClaimLaunch
func-lines 811 1275 internal/provision Reconcile
func-lines 769 1242 internal/console (*Server).handleAPIInstanceCreate
func-lines 689 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 809 internal/release adoptHost
func-lines 441 500 internal/host TestRootInstanceStopExecStop
func-lines 421 436 internal/host (*ClaimWakeAssembly).Build
func-lines 421 437 internal/team TestFixture
func-lines 412 414 internal/console TestDemoProtectionsSourceToLimitAndTakedown
func-lines 408 485 . TestFleetAppServesThroughTheHub
func-lines 402 406 internal/registry (*Registry).haJournal
func-lines 400 868 internal/provision rootReadArchivedChain
func-lines 399 732 internal/release PassFilter
func-lines 390 398 internal/host runFilesSeedPreparationWithLive
func-lines 383 406 internal/console TestDemoSourceToLiveAndUpdate
func-lines 379 898 internal/edge (*Edge).ServeHTTP
func-lines 378 600 internal/console (*Server).handleAPIShip
func-lines 374 377 internal/host plan14RequiredArtifactsRootRunner
func-lines 371 417 internal/host TestRootEgressKernelProof
func-lines 367 636 cmd/console serve
func-lines 364 371 internal/host testRootMigrationBootstrap
func-lines 360 362 internal/edge TestDemoAPIAliasBoundary
func-lines 357 358 internal/registry (*Registry).dispatchRemote
func-lines 355 372 internal/host TestRootSandboxUpdateFromOldBox
func-lines 343 354 internal/analytics Prune
func-lines 340 353 internal/host newColdRootHarness
func-lines 335 557 internal/console (*Store).migrate
func-lines 334 334 internal/host TestPlan12RecoveryRestoreSourceDatabase
func-lines 330 371 internal/edge TestRegionalNameNeverLeavesItsRegion
func-lines 329 471 . runDeploy
func-lines 329 329 internal/host TestPlan12RecoveryRestoreSourceDatabase.func1
func-lines 327 369 internal/edge TestTunnelWebSocketEndToEnd
func-lines 325 455 internal/objstore TestDeliveredContractMinio
func-lines 320 654 internal/appconfig SyncExecWithCallbacks
func-lines 315 318 internal/host plan14TimerIntention
func-lines 311 314 internal/host plan14TimerIntention.func1
func-lines 310 315 internal/hostbox ColdHandover.Run
func-lines 308 309 internal/host rootFilesSeedIsolatedWitness
func-lines 305 323 internal/host hairpinKernelWitness
func-lines 304 308 internal/console TestHAP2ProductionDoors
func-lines 302 329 internal/host TestRootG2PoolIngress
release-importers: . cmd/console internal/activator internal/analytics internal/appconfig internal/apperr internal/applog internal/apppolicy internal/boxid internal/boxvolumes internal/console internal/dbreads internal/dbreads/dbreadstest internal/dbverify internal/demobuild internal/domains internal/doorkey internal/edge internal/edgeproof internal/edgesfile internal/fleetapi internal/grouproll internal/grouprollaws internal/historyreadback internal/host internal/hostactors internal/hostbox internal/hostclaim internal/hostevidence internal/hostexec internal/hostfence internal/hostfiles internal/hostfloor internal/hostguard internal/hostops internal/hostrelocate internal/hostresolve internal/instancectl internal/instanceupdates internal/interactive internal/layout internal/lease internal/ledger internal/mail internal/mailer internal/mailsubmit internal/metrics internal/moves internal/objstore internal/ops internal/park internal/plans internal/provision internal/relay internal/rollout internal/rootfsimage internal/runs internal/s3fake internal/schedule internal/seeds internal/status internal/telemetry internal/usage internal/vet scripts/pathmapcheck scripts/witness-pointer
not scanned (211 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/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/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/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/mediahandler/collect_other.go: built only for other systems or tags
internal/mediahandler/procs_other.go: built only for other systems or tags
internal/medialocal/runner_other.go: built only for other systems or tags
internal/moves/archive/open_other.go: built only for other systems or tags
internal/moves/archive/sync_other.go: built only for other systems or tags
internal/ops/flock_windows.go: built only for other systems or tags
internal/park/local_other.go: built only for other systems or tags
internal/privatefile/io_other.go: built only for other systems or tags
internal/proxyproto/peek_other.go: built only for other systems or tags
internal/relay/race_on_test.go: built only for other systems or tags
internal/release/consumedfence_other.go: built only for other systems or tags
internal/release/digestcache_other.go: built only for other systems or tags
internal/rootaws/credentials_other.go: built only for other systems or tags
internal/rootaws/open_darwin.go: built only for other systems or tags
internal/rootfsimage/dir_other.go: built only for other systems or tags
internal/rootstate/authoritydir_other.go: built only for other systems or tags
internal/rootstate/authorityfile_other.go: built only for other systems or tags
internal/rootstate/file_other.go: built only for other systems or tags
internal/rootstate/link_other.go: built only for other systems or tags
internal/rootstate/persistent_other.go: built only for other systems or tags
internal/rootstate/state_other.go: built only for other systems or tags
internal/safefile/file_other.go: built only for other systems or tags
internal/safefile/reap_other.go: built only for other systems or tags
internal/stopevidence/fds_other.go: built only for other systems or tags
internal/stopevidence/fds_other_test.go: built only for other systems or tags
internal/stopevidence/holders_other.go: built only for other systems or tags
internal/stopevidence/reconstruct_other.go: built only for other systems or tags
internal/team/storelock_other.go: built only for other systems or tags
internal/team/storelock_windows.go: built only for other systems or tags
move_offline_run_other.go: built only for other systems or tags
system_group_other.go: built only for other systems or tags
codehealth_test.go:115: fatal 1094 at 474 sites log.Fatal*, (*log.Logger).Fatal* and os.Exit in the root package's production files
codehealth_test.go:115: sleep 1005 at 811 sites time.Sleep in test files
codehealth_test.go:115: db-no-context 885 at 703 sites database calls with no context (dbOpWithoutContext) in production files
codehealth_test.go:115: host-context 188 at 142 sites context.Background and context.TODO in internal/host production files
codehealth_test.go:115: func-lines 18619 at 45 sites functions over 300 code lines (blank and comment-only lines not counted)
codehealth_test.go:115: file-lines 30727 at 8 sites files over 3,000 code lines, counted the same way
codehealth_test.go:115: release-importers 66 at 1 sites packages whose production files import internal/release
codehealth_test.go:119: below the record: file-lines . apimode.go -: 4175 in the code, the record allows 4184 (make code-health-record lowers it)
codehealth_test.go:119: below the record: file-lines internal/host agent.go -: 3188 in the code, the record allows 3214 (make code-health-record lowers it)
--- PASS: TestCodeHealth (109.26s)
PASS
ok github.com/carlosframework/platform/internal/codehealth 110.549s
=== code-health-record ===
go version go1.26.10 linux/arm64
code-health record: HEAD is on main; comparing with its parent 33148c5bc52b0ba9de939ef76e200f6500bd9ab0
=== 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.816s
=== internal_rootaws@0 (25 s, from +34 s)
ok github.com/carlosframework/platform/internal/rootaws 25.105s
=== internal_activator@0 (268 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 265.629s
=== internal_activator@1 (270 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 267.210s
=== internal_activator@2 (275 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 272.588s
=== internal_activator@3 (417 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 414.450s
=== internal_activator@4 (276 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 273.531s
=== internal_activator@5 (312 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 309.508s
=== internal_activator@6 (317 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 314.454s
=== internal_activator@7 (410 s, from +110 s)
ok github.com/carlosframework/platform/internal/activator 407.257s
=== internal_edge@0 (84 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 81.049s
=== internal_edge@1 (144 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 141.716s
=== internal_edge@2 (198 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 195.064s
=== internal_edge@3 (169 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 166.156s
=== internal_edge@4 (155 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 151.923s
=== internal_edge@5 (233 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 230.381s
=== internal_edge@6 (236 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 233.427s
=== internal_edge@7 (232 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 229.439s
=== internal_edge@8 (225 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 221.976s
=== internal_edge@9 (250 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 247.094s
=== internal_edge@10 (219 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 216.097s
=== internal_edge@11 (211 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 208.035s
=== internal_edge@12 (232 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 229.451s
=== internal_edge@13 (265 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 262.019s
=== internal_edge@14 (173 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 169.976s
=== internal_edge@15 (244 s, from +132 s)
ok github.com/carlosframework/platform/internal/edge 240.970s
=== internal_host@0 (9 s, from +190 s)
ok github.com/carlosframework/platform/internal/host 5.066s
=== internal_host@1 (17 s, from +190 s)
ok github.com/carlosframework/platform/internal/host 13.235s
=== lists: internal_edge 131 s, internal_activator 109 s, internal_host 189 s, internal_rootaws 34 s, internal_systemd 14 s
=== cpu: the gate used 7606 cpu-seconds in 527 s, about 14.4 of 32 cores; the machine as a whole was 45% busy
=== gitleaks ===
go version go1.26.10 linux/arm64
go: downloading github.com/zricethezav/gitleaks/v8 v8.30.1
go: downloading github.com/rs/zerolog v1.33.0
go: downloading github.com/mholt/archives v0.1.2
go: downloading github.com/spf13/cobra v1.9.1
go: downloading github.com/spf13/viper v1.19.0
go: downloading github.com/h2non/filetype v1.1.3
go: downloading github.com/fatih/semgroup v1.2.0
go: downloading github.com/charmbracelet/lipgloss v0.5.0
go: downloading github.com/BobuSumisu/aho-corasick v1.0.3
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading github.com/gitleaks/go-gitdiff v0.9.1
go: downloading golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading golang.org/x/sync v0.11.0
go: downloading github.com/muesli/termenv v0.15.1
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading dario.cat/mergo v1.0.1
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading github.com/Masterminds/semver/v3 v3.3.0
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading golang.org/x/crypto v0.35.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 github.com/spf13/pflag v1.0.6
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.9
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/rivo/uniseg v0.2.0
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 golang.org/x/text v0.22.0
go: downloading github.com/mattn/go-colorable v0.1.14
go: downloading github.com/bodgit/sevenzip v1.6.0
go: downloading github.com/minio/minlz v1.0.0
go: downloading github.com/klauspost/pgzip v1.2.6
go: downloading github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3
go: downloading github.com/klauspost/compress v1.17.11
go: downloading github.com/ulikunitz/xz v0.5.12
go: downloading github.com/pierrec/lz4/v4 v4.1.21
go: downloading github.com/sorairolake/lzip-go v0.3.5
go: downloading github.com/therootcompany/xz v1.0.1
go: downloading github.com/STARRY-S/zip v0.2.1
go: downloading github.com/nwaples/rardecode/v2 v2.1.0
go: downloading github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
go: downloading github.com/bodgit/plumbing v1.3.0
go: downloading github.com/bodgit/windows v1.0.1
go: downloading go4.org v0.0.0-20230225012048-214862532bf5
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.7
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/hashicorp/errwrap v1.1.0
self-test: reported source file: a key
self-test: reported source file: a 64-hex key
self-test: reported source file: a census-shaped entry
self-test: reported source file: a key marked gitleaks:allow
self-test: reported source file: a test's fake value outside tests
self-test: reported allowed file: another key beside its allowed value
self-test: reported a tracked file named gitleaks-gate-sentinel.env
self-test: reported 97 near misses of the names notscanned.go lists
self-test: skipped the 32 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, 130 tracked files judged, 3 broken setups refused
gitleaks: scanned 11463 tracked files; 32 not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)
gitleaks: clean
diff --git a/.amadan/ci.d/30-minio-contract b/.amadan/ci.d/30-minio-contract| index 4112fbb0d..6288586a6 100755 |
| --- a/.amadan/ci.d/30-minio-contract |
| +++ b/.amadan/ci.d/30-minio-contract |
| @@ -596,6 +596,10 @@ fi |
| # it looks for the bucket, so the user is allowed that one delete and the |
| # test can see NoSuchBucket rather than a denial. |
| "$mc" --quiet mb local/media-transfers local/media-transfer-results |
| +# Versioned, as the deployment bucket the results live in is: the test |
| +# replays drills F1 and F2 (a delete leaves a marker, a create-only PUT |
| +# succeeds over it) and checks the cleanup removes every version. |
| +"$mc" --quiet version enable local/media-transfer-results |
| cat >"$rundir/media-transfers.json" <<'EOF' |
| {"Version": "2012-10-17", "Statement": [ |
| {"Effect": "Allow", "Action": ["s3:*"], "Resource": [ |
| @@ -645,9 +649,11 @@ cat >"$rundir/media-local.json" <<'EOF' |
| {"Effect": "Allow", "Action": ["s3:ListBucket"], "Resource": [ |
| "arn:aws:s3:::media-local-store", "arn:aws:s3:::media-local-results" |
| ]}, |
| + {"Effect": "Allow", "Action": ["s3:ListBucketVersions"], "Resource": ["arn:aws:s3:::media-local-results"]}, |
| {"Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"], "Resource": [ |
| "arn:aws:s3:::media-local-store/*", "arn:aws:s3:::media-local-results/*" |
| - ]} |
| + ]}, |
| + {"Effect": "Allow", "Action": ["s3:DeleteObjectVersion"], "Resource": ["arn:aws:s3:::media-local-results/media-results/*"]} |
| ]} |
| EOF |
| "$mc" --quiet admin policy create local media-local "$rundir/media-local.json" |
diff --git a/docs/superpowers/notes/census-claims-media-results-cleanup.tsv b/docs/superpowers/notes/census-claims-media-results-cleanup.tsv| new file mode 100644 |
| index 000000000..fca85adc6 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-claims-media-results-cleanup.tsv |
| @@ -0,0 +1,7 @@ |
| +# Census claims for media-results-cleanup (census-ruling-media-results-cleanup, video conversion spec §11 A8). <file>:<unit> TAB <what changed>. |
| +# Astra approved the card at the branch's earlier tip (#280). This file was not committed then; reconstructed 2026-11-25 from that card's rows and the overlay's basis for the new unit, word for word. |
| +# Merge re-pin 2026-11-25: merged origin/main 33148c5b; took main's chain and re-ran census-propose. Same four units and four envelopes as approved, overlay unchanged; only the seal moved (cdff7812 -> 6921575b, now chained after instance-ready-before-wake). |
| +infra/modules/deployment-buckets/main.tf:external two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change |
| +infra/modules/media-engine/iam.tf:external the console role customer-managed policy gains ListResultVersions (s3:ListBucketVersions on the deployment bucket, StringLike s3:prefix media-results/*) and DeleteResultVersions (s3:DeleteObjectVersion on <deployment bucket>/media-results/*); conversion role, execution role and every other statement unchanged; no read |
| +infra/modules/media-engine/tests/media_engine.tftest.hcl:external console_policy_exact expects the two new statements; mock provider only, no AWS access; no read is added |
| +infra/modules/deployment-buckets/tests/media_results.tftest.hcl:external new OpenTofu test (2 plan runs, mock_provider aws, no AWS access): asserts the two media-results/ rules and that the geoip, db-reads and data-bucket rules are unchanged; no read |
diff --git a/docs/superpowers/notes/census-proposal-media-results-cleanup.md b/docs/superpowers/notes/census-proposal-media-results-cleanup.md| new file mode 100644 |
| index 000000000..bcc85390c |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-media-results-cleanup.md |
| @@ -0,0 +1,27 @@ |
| +# Census approval: media-results-cleanup |
| + |
| +Ruling `census-ruling-media-results-cleanup`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `infra/modules/deployment-buckets/main.tf` `external` | body | unchanged (1) | two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change | |
| +| `infra/modules/media-engine/iam.tf` `external` | body | unchanged (1) | the console role customer-managed policy gains ListResultVersions (s3:ListBucketVersions on the deployment bucket, StringLike s3:prefix media-results/*) and DeleteResultVersions (s3:DeleteObjectVersion on <deployment bucket>/media-results/*); conversion role, execution role and every other statement unchanged; no read | |
| +| `infra/modules/media-engine/tests/media_engine.tftest.hcl` `external` | body | unchanged (1) | console_policy_exact expects the two new statements; mock provider only, no AWS access; no read is added | |
| + |
| +Envelopes re-pinned: `infra/modules/deployment-buckets`, `infra/modules/deployment-buckets/tests`, `infra/modules/media-engine`, `infra/modules/media-engine/tests`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `infra/modules/deployment-buckets/main.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change;rev3=census-ruling-data-lifecycle-336;basis=adds aws_s3_bucket_lifecycle_configuration "data" on the data bucket: noncurrent versions expire after var.data_noncurrent_days, expired delete markers go, multipart aborts after 7 days; no read, no IAM change |
| +- `infra/modules/media-engine/iam.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-media-conversion;basis=new: task execution role (ECR pull and the log group only); conversion role trusted only by the console role, Allow GetObject on store objects and PutObject on derived/ and media-results/, Deny GetObject on infected objects and any PutObject setting carlos-scan tags, 1 h sessions; the console role's customer-managed policy: AssumeRole on the conversion role, RunTask on this engine's task definitions in its cluster, Describe/Stop/List tasks in the cluster, DescribeTaskDefinition, PassRole of the execution role to ecs-tasks, ListBucket on the deployment bucket. |
| +- `infra/modules/media-engine/tests/media_engine.tftest.hcl` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-media-conversion;basis=new OpenTofu tests (24 runs: 9 plan and 15 apply, all against mock_provider aws, so no AWS access): task definitions pass the gate's shape, endpoint, role, console, reaper and DNS policies exact, no default route, drill states, output parses. The archive provider is real and writes the reaper's ZIP to a local path during the test.;rev3=census-ruling-media-spike-fixes;basis=assertions follow the module: capabilities must equal {add = [], drop = ["ALL"]}; deadline mountPoints and environment, and every volumesFrom, portMappings, systemControls must be empty (was: absent); new asserts that every list ECS fills in is written and that every DNS Firewall name is fully qualified; domain lists expected with trailing dots. Mock provider only, no AWS access; no read is added. |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `infra/modules/deployment-buckets/tests/media_results.tftest.hcl:external`: reads +file:external; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `aa953b1a43009c8208e44c67f5b8127ae1914b15d8b8822bcf16b19a6abdf121` → `6921575b59564ed947e30c02e314dd429016c6c11a85db9b8af50b2f31d5a5db`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-media-results-cleanup.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup-R2.md| new file mode 100644 |
| index 000000000..6ef521e04 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup-R2.md |
| @@ -0,0 +1,32 @@ |
| +- **R1 P1-1 — Resolved as a blocker by accepting A8’s narrower guarantee.** Late completion remains possible; this is an accepted residual, not a code fix. |
| +- **R1 P1-2 — Resolved.** Console tests now check retention before the grant bound and deletion afterward. |
| +- **R1 P2-3 — Resolved.** Abandoned executions retain durable cleanup duties through retry, retirement and pruning. |
| +- **R1 P2-4 — Resolved.** A8 distinguishes expiration eligibility from asynchronous deletion and removes the maximum-duration promise. |
| + |
| +Reviewed commit `8bc5035a00c2243cbf59344ebd76387611f520be`. No P1 findings. |
| + |
| +1. **P2 — Simulation loses abandoned executions immediately after cleanup.** |
| + |
| + `actLeakedPut` requires an execution to match a current row’s `execution_id` or `prior_execution` at [actions_test.go:669](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/sim/mediajobs/actions_test.go:669). Cleanup clears `prior_execution` at [retire.go:178](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/retire.go:178). R1 also skips output checks when that row association disappears at [invariants_test.go:604](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/sim/mediajobs/invariants_test.go:604). |
| + |
| + **Failure scenario:** a regression cleans an abandoned execution before its grant expires. After cleanup clears the prior identity, the simulation cannot attempt another leaked PUT for it. Even an independently recreated output escapes R1’s checks. The simulation therefore misses the resurrection it claims to detect. |
| + |
| + **Fix:** retain execution-to-object metadata independently of live rows, in deterministic grant order. Keep cleaned executions eligible for leaked PUT attempts and check their recorded output keys after cleanup and pruning. Add a witness demonstrating detection of premature prior cleanup. |
| + |
| + **Fault family:** cleanup verification must survive execution replacement and removal. |
| + |
| +2. **P2 — Cleanup guarantees still contradict A8’s accepted residual.** |
| + |
| + [dispatch.go:305](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/dispatch.go:305) says cleanup is final and nothing can recreate an object. [jobs_test.go:1210](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/jobs_test.go:1210) repeats that guarantee. Both contradict [A8:1135](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/docs/superpowers/specs/2026-11-16-video-conversion-design.md:1135). |
| + |
| + **Failure scenario:** an upload starts before expiry, cleanup clears the duty, and the upload completes afterward. The atomic fake does not exercise that interleaving, so passing tests do not establish finality. |
| + |
| + **Fix:** describe the bound as preventing **new requests**, qualify R1 as covering the model’s atomic PUTs, and explicitly reference the late-completion residual. Remove unconditional finality claims. |
| + |
| + **Fault family:** cleanup guarantees must distinguish request expiry from upload completion. |
| + |
| +I accept the residual because late results have lifecycle cleanup, while late outputs remain confined to their execution’s prefix in the tenant bucket, which the app already has permission to write ([aws.go:202](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/objstore/aws.go:202)). This does not establish bounded physical deletion: S3 expiration checks and lifecycle timing have the limitations documented at [https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html) and [https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-lifecycle.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-lifecycle.html). |
| + |
| +No P3 findings. Census and rollout rulings remain unchanged. `git diff --check` passed. No files changed, tests run, or AWS API calls made. Apply the P2 fixes without reopening review. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md b/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md| new file mode 100644 |
| index 000000000..5718fc3b1 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md |
| @@ -0,0 +1,60 @@ |
| +Reviewed `5daee236d90388072e2bf480932d48def9f3d1eb`, round 1. Two P1 findings and two P2 findings. No files changed, tests run, or AWS API calls made. `git diff --check` passed. |
| + |
| +1. **P1 — Cleanup timing: expiry does not stop uploads already in progress.** |
| + |
| + [dispatch.go:305](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/dispatch.go:305) treats grant expiry as proof that nothing can subsequently create an object. However, the authoritative [spec §5.4:371](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/docs/superpowers/specs/2026-11-16-video-conversion-design.md:371) explicitly allows a transfer begun before expiry to finish afterward. |
| + |
| + **Failure scenario:** a leaked PUT starts before expiry against an absent result or failed-job output, then uploads slowly. Cleanup reaches the bound, finds no completed object, and clears `cleanup_due` at [retire.go:120](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/retire.go:120). The upload completes afterward. No further job cleanup runs; an output remains indefinitely. |
| + |
| + **Fix:** establish and enforce an upload-completion bound before clearing cleanup duties, or introduce a storage-side mechanism that refuses late completion. Merely adding arbitrary slack does not prove this. Add a deterministic test that starts a PUT, pauses its body, runs cleanup, then completes it. The atomic fake at [grants.go:267](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/media/mediatest/grants.go:267) cannot exercise this interleaving. |
| + |
| + **Fault family:** cleanup finality across outstanding write authority. |
| + |
| +2. **P1 — Tests: the console lifecycle tests still require immediate cleanup.** |
| + |
| + [runToStopped:154](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/console/mediapass_test.go:154) finishes its third pass about 62 seconds after dispatch. `TestMediaPassRunsTheLifecycle` then requires the result to be deleted and `cleanup_due` to be zero at [mediapass_test.go:177](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/console/mediapass_test.go:177). `TestMediaPassFailedCleansOutputs` likewise requires deleted outputs at [mediapass_test.go:209](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/console/mediapass_test.go:209). |
| + |
| + **Failure scenario:** both tests reach those assertions while cleanup is deliberately deferred until dispatch plus 65 minutes. Their assertions therefore fail under the new behavior; this follows directly from the fixture and SQL, without executing them. |
| + |
| + **Fix:** assert settlement with objects retained before the bound, then advance the worker to the bound and assert cleanup. Preserve the successful-job output checks. |
| + |
| + **Fault family:** integration tests must follow the settlement/cleanup contract. |
| + |
| +3. **P2 — Cleanup coverage: retain duties for created-but-never-started tasks.** |
| + |
| + [track.go:113](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/track.go:113) sends a stopped task without `StartedAt` into `neverStarted`. That function either clears its execution identity for retry or settles it with `cleanup_due = 0` at [dispatch.go:501](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/mediajobs/dispatch.go:501). |
| + |
| + **Failure scenario:** an image-pull failure leaves live transfers in ECS overrides. A bearer writes through them after the row is requeued or failed. The old execution has no cleanup duty; outputs persist indefinitely. The simulation’s action selects only current, settled executions at [actions_test.go:654](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/internal/sim/mediajobs/actions_test.go:654), so it misses the discarded execution after retry. |
| + |
| + **Fix:** distinguish a definite non-launch from a created task that never started. Preserve a durable cleanup entry for the latter before replacing its execution identity, without charging engine time. Cover both retry and terminal cases. |
| + |
| + **Assessment:** this residual should close here; a result-only lifecycle rule does not clean its outputs. |
| + |
| + **Fault family:** cleanup obligations survive execution replacement and settlement. |
| + |
| +4. **P2 — A8: lifecycle does not guarantee deletion within two days.** |
| + |
| + [A8:1120](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/docs/superpowers/specs/2026-11-16-video-conversion-design.md:1120) promises “at most two days.” S3 rounds expiration eligibility to midnight UTC, performs deletion asynchronously, and starts noncurrent expiration after the version becomes noncurrent. Two one-day rules therefore provide no two-day physical-deletion maximum. See [https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-lifecycle.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/troubleshoot-lifecycle.html). |
| + |
| + **Failure scenario:** an operator treats two days as a retention guarantee while previous versions remain. |
| + |
| + **Fix:** describe current and noncurrent expiration eligibility separately, including asynchronous removal; remove the maximum-duration claim. |
| + |
| + **Fault family:** retention guarantees must match storage semantics. |
| + |
| +No P3 findings. For rollout, an explicit infrastructure-before-console instruction is sufficient: apply the lifecycle and IAM changes first. Retaining cleanup duties and retrying permission failures is appropriate; falling back to plain deletion would not complete cleanup. |
| + |
| +The census verdicts below concern the root-read boundary, independently of the blocking application findings: |
| + |
| +| Unit or envelope | Verdict and evidence | |
| +|---|---| |
| +| `deployment-buckets/main.tf:external` | **APPROVE.** [main.tf:101](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/main.tf:101): both added rules are confined to `media-results/`; existing rules and root-read protections remain intact. Existing `accepted-legacy` disposition remains appropriate. | |
| +| `media-engine/iam.tf:external` | **APPROVE.** [iam.tf:158](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/iam.tf:158): version listing and deletion are scoped to results. No conversion-role expansion or root-input validation weakening. Existing disposition remains appropriate. | |
| +| `media-engine/tests/media_engine.tftest.hcl:external` | **APPROVE.** [media_engine.tftest.hcl:550](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/tests/media_engine.tftest.hcl:550): mock-provider assertions include the exact new permissions and retain the policy-size check. | |
| +| New `deployment-buckets/tests/media_results.tftest.hcl:external` | **APPROVE** the proposed `legacy / accepted-legacy` disposition. [media_results.tftest.hcl:9](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/tests/media_results.tftest.hcl:9): mock-provider plan tests; no new runtime read authority. | |
| +| `infra/modules/deployment-buckets` envelope | **APPROVE.** Changed lifecycle blocks at [main.tf:101](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/main.tf:101) introduce no tenant-controlled root input. | |
| +| `infra/modules/deployment-buckets/tests` envelope | **APPROVE.** New assertions at [media_results.tftest.hcl:16](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/deployment-buckets/tests/media_results.tftest.hcl:16) are confined to mocked lifecycle plans. | |
| +| `infra/modules/media-engine` envelope | **APPROVE.** Changed policy statements at [iam.tf:158](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/iam.tf:158) preserve the root-read boundary. | |
| +| `infra/modules/media-engine/tests` envelope | **APPROVE.** Changed expected statements at [media_engine.tftest.hcl:592](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-results-cleanup/infra/modules/media-engine/tests/media_engine.tftest.hcl:592) match the scoped grants. | |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md| new file mode 100644 |
| index 000000000..2a3169d1d |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup-R2.md |
| @@ -0,0 +1,129 @@ |
| +# Review brief: branch `media-results-cleanup` (media result cleanup, drills F1 and F2), round 2 of 3 |
| + |
| +Repo carlos/platform, branch `media-results-cleanup`, the commit that adds |
| +this brief (its parent is the tip under review). Under review: the whole |
| +diff `origin/main...HEAD`, with attention on what changed since round 1, |
| +`5daee236..HEAD`. Read it from the worktree you are started in. |
| + |
| +Authorities, all on main: `docs/superpowers/specs/2026-11-16-video-conversion-design.md` |
| +§5.3, §5.4, §5.5 and §11 (A5 to A7); `AGENTS.md` ("Stopping rules", "The |
| +census"). Amendment A8, which this branch adds, is under review, not an |
| +authority. The round 1 brief, |
| +`docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup.md`, |
| +states the defect (drills F1, F2) and what the branch does; read it first. |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches |
| +and what that code reaches, and check every claim against the code. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- The census verdicts of round 1 (every unit and envelope approved). No |
| + file in census scope has changed since (`git diff 5daee236..HEAD -- |
| + infra .amadan` is empty), so the census is not part of this round. |
| +- The rollout ruling of round 1: infrastructure before console, stated in |
| + A8; no fallback to a plain delete. |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: round 1, `docs/superpowers/reviews/CODEX-FINDINGS-media-results-cleanup.md`. |
| +This is the second review of this change; one more round remains in the |
| +budget, and a fourth needs Paul. |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or not. |
| +Carry every unresolved or partly resolved finding forward at its current |
| +severity, then add new findings. The verdict covers everything |
| +outstanding, round 1 included. |
| + |
| +What the author did with each: |
| + |
| +- **P1-2 (console tests).** `internal/console/mediapass_test.go`: |
| + `runToStopped` returns the worker, `cleanAtGrantBound` checks that the |
| + settling pass deleted nothing and runs pass 4 at the grant bound. |
| + `internal/console/mediaretire_test.go` `TestAppPurgeRetiresQueuedAndRunning` |
| + checks nothing is cleaned at the stop and everything at `cleanup_due`. |
| +- **P2-3 (never-started duties).** `neverStarted` takes `sent` (RunTask |
| + was called: `track.go` for a task that never started, `launch` for a |
| + `*media.Rejected`; false for every path that never called RunTask). Sent |
| + and failing: the row keeps its execution with `cleanup_due` at the grant |
| + bound. Sent and back to queued: the execution's duty moves to two new |
| + additive columns, `prior_execution` and `prior_cleanup_due` |
| + (`schema.go`, `Migrations`), set in the same UPDATE that clears |
| + `execution_id`. `Cleanup` runs `cleanupPrior` (result and outputs) and |
| + `Prune` requires `prior_cleanup_due = 0`. A row requeues after a strike |
| + at most once; a second sent requeue with a duty still held is refused |
| + as an error rather than overwrite it. Tests: `TestGivenUpExecutionsAreCleaned`, |
| + `TestPruneKeepsAGivenUpDuty`, `TestNothingSentNoDuty`, and the two |
| + never-started tests updated. The simulation reads the new columns, and |
| + P1, P2 (prune) and I4 count the prior duty. A new invariant R2: every |
| + execution sent to RunTask that no row still runs is cleaned or holds a |
| + duty. `leaked-put` now also targets given-up executions. With `sent` |
| + forced false, R2 fails in 140 of 200 seeds. |
| +- **P2-4 (lifecycle wording).** A8 now says eligibility a day after |
| + writing or after becoming noncurrent, rounded to midnight UTC, removed |
| + asynchronously, and claims no maximum. |
| +- **P1-1 (an upload begun before the bound completes after cleanup).** Not |
| + changed in code. The author's position, now in A8 "What remains": S3 |
| + checks a presigned request's expiry when the request begins and offers |
| + no way to refuse a completion, so no bound on completion can be |
| + enforced. For a **result**, the lifecycle rules (`media-results/`, |
| + current objects expire) remove whatever such a PUT creates, which is |
| + the backstop the design asked for. For an **output** of a failed job, |
| + the object stays under that execution's prefix in the tenant's own |
| + bucket, under `derived/`, where the app's own credentials may already |
| + write (`internal/mediajobs/track.go`, `checkOutputs`' comment; the |
| + store user's policy). This case predates the branch, which narrows it |
| + from "any PUT inside the grant's hour after the stop" to "a PUT begun |
| + before the bound". Judge whether that is acceptable for this branch. |
| + If you hold it a P1, name the invariant and what fix would close it; |
| + under AGENTS.md stopping rule 2 a second round in the same fault family |
| + means the author stops and takes the choice to Paul. |
| + |
| +## What to check |
| + |
| +1. The P2-3 fix: every path that gives up or settles an execution after |
| + RunTask was called (`launch`, `release`, `neverStarted`, `Track`, |
| + `Recover`, `lostAfterRetention`, `Retire`), and that none leaves a sent |
| + execution without a duty, or records a duty for one never sent. The |
| + SQL: SQLite evaluates SET expressions against the old row, so |
| + `prior_execution = CASE WHEN ? THEN execution_id ...` takes the |
| + execution being cleared; the bool parameter binding; the guard |
| + against a second duty; the migration on an existing table. |
| +2. `cleanupPrior`: the guard on its UPDATE, a store bucket that is gone |
| + (`DeleteOutputs` treats `NoSuchBucket` as done), an app or account |
| + torn down while a duty is pending, and what `Retire`/teardown and |
| + `Prune` do with such a row. |
| +3. The simulation: R2's definition and its scan of `grantLog`; that R1, |
| + R2 and the widened `leaked-put` stay deterministic per seed and do not |
| + disturb I1 to I9; P1 and the prune rule with the prior duty. |
| +4. Anything round 1 found that the fixes did not reach, and anything the |
| + fixes broke. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. Leave GOCACHE unset; you need |
| +not run tests at all, and you must not call AWS. |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup.md| new file mode 100644 |
| index 000000000..b338ff497 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-results-cleanup.md |
| @@ -0,0 +1,155 @@ |
| +# Review brief: branch `media-results-cleanup` (media result cleanup, drills F1 and F2), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `media-results-cleanup`, the commit that adds |
| +this brief (its parent is the tip under review). Under review: the diff |
| +`origin/main...HEAD` (merge base d3266e8e). Read it from the worktree you |
| +are started in: `git diff origin/main...HEAD`. |
| + |
| +Authorities, all on main: `docs/superpowers/specs/2026-11-16-video-conversion-design.md` |
| +§5.3, §5.4, §5.5 and §11 (A5 to A7); `AGENTS.md` ("Stopping rules", "The |
| +census"). The branch adds amendment A8 to that spec; A8 is part of what |
| +you review, not an authority. The evidence below comes from a drills |
| +report on the unmerged branch `media-conversion-dev-drills`; it is quoted |
| +here so you need not read that branch, and it is evidence of a defect, |
| +not a design to review against. |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches |
| +and what that code reaches, and check every claim against the code. |
| + |
| +## The defect (drills R4 on dev, 2026-11-22) |
| + |
| +- **F1.** The deployment bucket is versioned, so the console's cleanup |
| + `DeleteObject` of `media-results/<execution>.json` only leaves a delete |
| + marker. A create-only PUT (`If-None-Match: *`) succeeds over a delete |
| + marker, so a result transfer read from a stopped task's ECS overrides |
| + (any principal with `ecs:DescribeTasks`), still inside the grant's hour, |
| + recreated the object after cleanup, at any size, and nothing removes it. |
| +- **F2.** Every result stays as a noncurrent version forever: the bucket's |
| + lifecycle has rules only for `control/geoip/` and `db-reads/`. |
| +- Invariant: a result object is gone after cleanup and never outlives its |
| + job (spec §5.3, §5.4). |
| + |
| +## What the branch does |
| + |
| +1. `infra/modules/deployment-buckets/main.tf`: two lifecycle rules on |
| + `media-results/` (`media-results-expire`: current objects after 1 day, |
| + noncurrent versions 1 day after they become noncurrent, multipart after |
| + 1 day; `media-results-delete-markers`: expired delete markers), inside |
| + the one existing `aws_s3_bucket_lifecycle_configuration.deployment`, |
| + always on (no variable). New `tests/media_results.tftest.hcl`. |
| +2. `infra/modules/media-engine/iam.tf`: the console's customer-managed |
| + policy gains `s3:ListBucketVersions` on the deployment bucket with |
| + `StringLike s3:prefix media-results/*`, and `s3:DeleteObjectVersion` on |
| + `<deployment bucket>/media-results/*`. |
| +3. `internal/mediaaws/grants.go` `DeleteResult`: lists versions with the |
| + exact result key as `Prefix` (URL encoding), deletes by version id every |
| + version and delete marker whose key equals it, relists, up to |
| + `resultDeleteRounds` (4). `S3API` gains `ListObjectVersions`; |
| + `NoSuchVersion` joins `knownAPICodes`. |
| +4. `internal/mediajobs`: a stopped row's `cleanup_due` is |
| + `MAX(observation, dispatched_at + GrantLifetime + GrantMintSlack)` |
| + (`cleanupDueSQL`, `grantBound`) in `commitDone` and `failStop`; before, |
| + it was the observation. `engine_lost` already used the bound. |
| +5. The result PUT's presign expiry is **not** shortened. Today every |
| + transfer is presigned with `X-Amz-Expires` = `GrantLifetime` (1 h) on a |
| + 1 h STS session, and `Launch` refuses a grant expiring after the bound. |
| + The author's reasons for not shortening: `X-Amz-Expires` is one of the |
| + payload's shared parameters (`internal/media/payload.go`, |
| + `sharedParams`; `presignAll` refuses differing ones), the codec and the |
| + `deadline` container read one expiry `e`, and `DeadlineSleep` counts the |
| + deadline from task start, so a shorter grant would eat a task's PENDING |
| + time; and a shorter expiry would not close the window anyway, because a |
| + task that ends early leaves its transfer live until that expiry while |
| + cleanup ran at the stop. Check that reasoning. |
| +6. Tests: a versioned fake bucket (`internal/mediaaws/versions_test.go`); |
| + `TestCleanupWaitsForTheGrant` (`internal/mediajobs/jobs_test.go`); a |
| + create-only `Put` through a presigned URL on `mediatest.FakeGrants`; the |
| + simulation (`internal/sim/mediajobs`) gains a `leaked-put` action and |
| + invariant R1 (it fails in 5 of 200 seeds with the old timing); the MinIO |
| + contract (`internal/mediaaws/minio_test.go`, `.amadan/ci.d/30-minio-contract`) |
| + versions the results bucket and replays F1, and grants the local |
| + runner's user the version calls. |
| +7. Census proposal: `docs/superpowers/notes/census-proposal-media-results-cleanup.md`. |
| + |
| +## What to check |
| + |
| +1. **DeleteResult.** Exact-key matching under URL encoding; the claim that |
| + the exact key sorts first among keys it prefixes, so a first page with |
| + none of its entries means none exist; termination and the round bound; |
| + a store that answers version id `null` or none; error mapping (a gone |
| + deployment bucket must stay an error; `NoSuchKey`/`NoSuchVersion` on a |
| + version delete are success); that nothing but that one key can ever be |
| + deleted; `ExpectedBucketOwner` on every call. |
| +2. **Cleanup timing.** Is `dispatched_at + GrantLifetime + GrantMintSlack` |
| + truly after every transfer of the execution expires (presign time vs |
| + assume time vs `Launch`'s check; STS session expiry vs `X-Amz-Expires`; |
| + console clock vs S3's)? Every path that sets `cleanup_due` or settles a |
| + row: does any still clean before the bound, or leave a minted grant |
| + with no cleanup? The author names one residual in A8: a task created |
| + and never started (`neverStarted`) settles with no cleanup while its |
| + overrides held live transfers; a result written through one lasts until |
| + the lifecycle removes it, and an output under that execution's prefix |
| + stays in the tenant's bucket. Say whether that residual is acceptable |
| + for this branch or must be closed here. |
| +3. **What a later cleanup changes.** Store destroy, app purge, account |
| + deletion, `Prune`, the `Summary`/status pages, the local runner, a |
| + destroyed-then-recreated bucket, S3 request counts. Anything that |
| + assumed cleanup happens in the pass that settles a row. |
| +4. **Nothing reads a result late.** The lifecycle expires results a day |
| + after they are written. Confirm no path reads a result object later than |
| + ECS's record retention after its task stops (only `Track` reads it). |
| +5. **IAM.** The two statements, their resources and the `s3:prefix` |
| + condition for an exact-key `ListObjectVersions` on AWS; how they combine |
| + with region-host's `AnalyticsDayVersionList` (`ListBucketVersions` on the |
| + same bucket, `s3:prefix` `apps/*`) on the same role; any Deny that would |
| + block them (deployment-buckets' bucket policy); the managed policy's |
| + 6,144-character limit. |
| +6. **Lifecycle.** S3's constraints (an expired-object-delete-marker |
| + expiration cannot sit beside `days` in one rule; two rules on one prefix |
| + are allowed, as `db-reads/` already does); the rules join the one |
| + resource and leave the existing rules byte for byte; on everywhere |
| + without a variable (the author's reason: only the media engine writes |
| + under the prefix, so where media is off the rules match nothing). |
| +7. **Rollout order.** The new console code calls `ListObjectVersions` and |
| + `DeleteObjectVersion`. If a console rolls before its root applies the |
| + module change, every due cleanup fails and is retried each pass |
| + (`PassEvery` 5 s) until the IAM lands. Is a release note enough, or must |
| + the code degrade? |
| +8. **Tests.** Does the versioned fake model S3 faithfully (create-only over |
| + a marker succeeds; a delete without a version id adds a marker)? Does R1 |
| + check what it claims, deterministically, without disturbing I1 to I9? |
| + Is the MinIO step correct (versioning enabled before the test, the |
| + local runner's policy, `versionId=null` on an unversioned bucket)? |
| +9. **Census.** Give a verdict for every unit and envelope in the card, |
| + under AGENTS.md "The census", citing the lines you read. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdicts, one per unit and envelope. End with |
| +exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. Leave GOCACHE unset; you need |
| +not run tests at all, and you must not call AWS. |
diff --git a/docs/superpowers/specs/2026-11-16-video-conversion-design.md b/docs/superpowers/specs/2026-11-16-video-conversion-design.md| index 6e8ffdbff..a50fc5831 100644 |
| --- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| +++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| @@ -1077,6 +1077,70 @@ the outputs. Store destroy gains the refusal of §5.3. |
| 35 s after its last container dies, so a charge read from `stoppedAt` |
| can pass a row's full bound by that much; that is plan 2's to settle, |
| not this amendment's. |
| +- **A8, cleanup outlasts the transfers** (dev drills R4, findings F1 and |
| + F2: `docs/superpowers/reviews/2026-11-16-media-conversion-dev-drills.md` |
| + on branch `media-conversion-dev-drills`). The deployment bucket is |
| + versioned. A plain delete of `media-results/<execution>.json` only puts |
| + a delete marker on top, so every result lived on as a noncurrent version |
| + (F2). A create-only PUT succeeds over a delete marker, so a result |
| + transfer read from a stopped task's overrides recreated the object after |
| + cleanup, at any size, and nothing removed it (F1). §5.3's "cleanup runs |
| + only after the task is confirmed stopped, so nothing is still writing" |
| + overlooked the transfers, which outlive the task. The invariant: once |
| + the grant bound has passed, no request can begin that creates an |
| + execution's result or outputs, and cleanup then deletes every version |
| + of them. Four rules override §5.3 and §5.4 where they differ. |
| + - **Cleanup waits for the grant.** A row whose task stopped is cleaned |
| + at the later of when the stop is seen and its grant bound, |
| + `dispatched_at` + `GrantLifetime` + `GrantMintSlack`. Launch already |
| + refuses a grant that expires after that bound, so from it every |
| + transfer of the execution is refused. `engine_lost` rows already used |
| + it. A result or a failed row's outputs therefore stay up to about |
| + 65 minutes after the job ends. The result PUT's own expiry is not |
| + shortened: all five transfers share one `X-Amz-Expires` in the |
| + payload, and the codec and the `deadline` container read one expiry, |
| + so a separate expiry needs a payload version. It would not close the |
| + gap either: a task that ends early would still leave its transfer |
| + live until that expiry. |
| + - **Every sent execution keeps a cleanup duty.** Once `RunTask` has been |
| + called for an execution, its transfers are out of the console: in the |
| + task's overrides when a task was created, and in the account's audit |
| + trail either way (§5.5). So "never started" and "launch rejected" |
| + after `RunTask` no longer mean "nothing to clean". A row that fails |
| + keeps its execution with `cleanup_due` at the grant bound. A row that |
| + goes back to queued, and so gives the execution up, keeps its duty in |
| + two columns, `prior_execution` and `prior_cleanup_due`, which cleanup |
| + carries out like a failed row's (the result and the three outputs) |
| + and which `Prune` waits for. A row goes back to queued after a strike |
| + at most once, so it never holds two such duties. A launch that never |
| + called `RunTask` sent nothing and keeps no duty. |
| + - **Cleanup deletes every version.** The console lists the result key's |
| + versions with the exact key as the prefix, and deletes by version id |
| + every version and delete marker whose key is exactly that key. Its |
| + role gains `s3:ListBucketVersions` on the deployment bucket, held to |
| + `s3:prefix` `media-results/*`, and `s3:DeleteObjectVersion` on |
| + `media-results/*` only (`infra/modules/media-engine`, the console's |
| + customer-managed policy). Apply that module change before a console |
| + with this amendment rolls; until then each due cleanup is refused and |
| + retried every pass. |
| + - **A lifecycle backstop for results.** The deployment bucket's |
| + lifecycle makes every object under `media-results/` eligible for |
| + expiration a day after it is written, each noncurrent version a day |
| + after it becomes noncurrent, and removes expired delete markers |
| + (`infra/modules/deployment-buckets`). S3 rounds eligibility up to the |
| + next midnight UTC and removes objects asynchronously after that, so |
| + the rules bound nothing to the hour; they make sure a result nothing |
| + else removes does not stay for good. The console reads a result only |
| + while ECS still has the stopped task's record, well under a day. |
| + - **What remains.** S3 checks a presigned request's expiry when the |
| + request begins, so a PUT begun just before the grant bound can |
| + complete after the cleanup, however long it takes to send. A result |
| + it creates is removed by the lifecycle rules. An output it creates |
| + stays in the tenant's bucket under that execution's prefix, under |
| + `derived/`, where the app's own credentials may write anyway (§5.3, |
| + `checkOutputs`), and no rule of ours reaches. S3 offers no way to |
| + refuse such a completion; closing it would need a platform rule on |
| + tenant buckets or a sweep of `derived/`, both outside this amendment. |
| ## 12. Decisions for Paul |
diff --git a/infra/modules/deployment-buckets/main.tf b/infra/modules/deployment-buckets/main.tf| index 625635b54..240166d7a 100644 |
| --- a/infra/modules/deployment-buckets/main.tf |
| +++ b/infra/modules/deployment-buckets/main.tf |
| @@ -29,8 +29,12 @@ resource "aws_s3_bucket_versioning" "deployment" { |
| # or superseded blob under control/geoip/ must not live on as a noncurrent |
| # version, because MaxMind's GeoLite EULA requires destroying superseded |
| # editions. Forwarded db reads (db region forward spec §5.7, J4): every |
| -# object under db-reads/ expires. Each rule is scoped to its own prefix; |
| -# nothing else in this bucket expires. |
| +# object under db-reads/ expires. Media conversion results (video conversion |
| +# spec §11 A8): every object under media-results/ expires. Each rule is |
| +# scoped to its own prefix; nothing else in this bucket expires. This is the |
| +# bucket's only lifecycle configuration: S3 replaces the whole configuration |
| +# on every write, so a rule for this bucket joins this resource and never |
| +# gets one of its own. |
| resource "aws_s3_bucket_lifecycle_configuration" "deployment" { |
| bucket = aws_s3_bucket.deployment.id |
| @@ -84,6 +88,44 @@ resource "aws_s3_bucket_lifecycle_configuration" "deployment" { |
| } |
| } |
| + # Media conversion results (video conversion spec §5.4, §11 A8): the |
| + # console reads media-results/<execution>.json once, within its job's |
| + # grant and ECS's record retention, and its cleanup deletes every version |
| + # of it. These rules are the backstop for anything cleanup missed: a |
| + # result written for an execution whose row was never cleaned, or one a |
| + # cleanup failed to reach. Each object expires a day after it is written, |
| + # each noncurrent version a day after it becomes noncurrent, and expired |
| + # delete markers go. On for every deployment: nothing but the media |
| + # engine writes under this prefix, so where media is off the rules match |
| + # nothing, and a switch would only be a way to run media without them. |
| + rule { |
| + id = "media-results-expire" |
| + status = "Enabled" |
| + filter { |
| + prefix = "media-results/" |
| + } |
| + expiration { |
| + days = 1 |
| + } |
| + noncurrent_version_expiration { |
| + noncurrent_days = 1 |
| + } |
| + abort_incomplete_multipart_upload { |
| + days_after_initiation = 1 |
| + } |
| + } |
| + |
| + rule { |
| + id = "media-results-delete-markers" |
| + status = "Enabled" |
| + filter { |
| + prefix = "media-results/" |
| + } |
| + expiration { |
| + expired_object_delete_marker = true |
| + } |
| + } |
| + |
| depends_on = [aws_s3_bucket_versioning.deployment] |
| } |
diff --git a/infra/modules/deployment-buckets/tests/media_results.tftest.hcl b/infra/modules/deployment-buckets/tests/media_results.tftest.hcl| new file mode 100644 |
| index 000000000..b911e088f |
| --- /dev/null |
| +++ b/infra/modules/deployment-buckets/tests/media_results.tftest.hcl |
| @@ -0,0 +1,100 @@ |
| +# Video conversion spec §11 A8 (drills F1, F2): the deployment bucket |
| +# expires everything under media-results/: current versions a day after |
| +# they are written, noncurrent versions a day after they become noncurrent, |
| +# and expired delete markers. The console's cleanup deletes every version; |
| +# these rules are the backstop. S3 replaces a bucket's whole lifecycle |
| +# configuration on every write, so the rules join the one resource and |
| +# every rule that was there stays exactly as it was. |
| + |
| +mock_provider "aws" {} |
| + |
| +variables { |
| + deployment_bucket_name = "dep" |
| + data_bucket_name = "data" |
| +} |
| + |
| +run "media_results_expire_with_their_versions_and_markers" { |
| + command = plan |
| + |
| + assert { |
| + condition = length([ |
| + for r in aws_s3_bucket_lifecycle_configuration.deployment.rule : r |
| + if r.id == "media-results-expire" && r.status == "Enabled" && |
| + one(r.filter).prefix == "media-results/" && |
| + one(r.expiration).days == 1 && |
| + one(r.noncurrent_version_expiration).noncurrent_days == 1 && |
| + one(r.abort_incomplete_multipart_upload).days_after_initiation == 1 |
| + ]) == 1 |
| + error_message = "media-results/ must expire current versions after 1 day and noncurrent versions 1 day after they become noncurrent" |
| + } |
| + |
| + assert { |
| + condition = length([ |
| + for r in aws_s3_bucket_lifecycle_configuration.deployment.rule : r |
| + if r.id == "media-results-delete-markers" && r.status == "Enabled" && |
| + one(r.filter).prefix == "media-results/" && |
| + one(r.expiration).expired_object_delete_marker == true && |
| + length(r.noncurrent_version_expiration) == 0 |
| + ]) == 1 |
| + error_message = "media-results/ must remove expired delete markers" |
| + } |
| +} |
| + |
| +run "the_existing_rules_are_unchanged" { |
| + command = plan |
| + |
| + assert { |
| + condition = ( |
| + length(aws_s3_bucket_lifecycle_configuration.deployment.rule) == 5 && |
| + toset([for r in aws_s3_bucket_lifecycle_configuration.deployment.rule : r.id]) == toset([ |
| + "geoip-noncurrent", "db-reads-expire", "db-reads-delete-markers", |
| + "media-results-expire", "media-results-delete-markers", |
| + ]) |
| + ) |
| + error_message = "the deployment bucket's lifecycle holds exactly the geoip, db-reads and media-results rules" |
| + } |
| + |
| + assert { |
| + condition = length([ |
| + for r in aws_s3_bucket_lifecycle_configuration.deployment.rule : r |
| + if r.id == "geoip-noncurrent" && r.status == "Enabled" && |
| + one(r.filter).prefix == "control/geoip/" && |
| + length(r.expiration) == 0 && |
| + one(r.noncurrent_version_expiration).noncurrent_days == 1 && |
| + one(r.abort_incomplete_multipart_upload).days_after_initiation == 1 |
| + ]) == 1 |
| + error_message = "the control/geoip/ rule must stay as it was" |
| + } |
| + |
| + assert { |
| + condition = length([ |
| + for r in aws_s3_bucket_lifecycle_configuration.deployment.rule : r |
| + if r.id == "db-reads-expire" && r.status == "Enabled" && |
| + one(r.filter).prefix == "db-reads/" && |
| + one(r.expiration).days == 1 && |
| + one(r.noncurrent_version_expiration).noncurrent_days == 1 && |
| + one(r.abort_incomplete_multipart_upload).days_after_initiation == 1 |
| + ]) == 1 |
| + error_message = "the db-reads/ expiry rule must stay as it was" |
| + } |
| + |
| + assert { |
| + condition = length([ |
| + for r in aws_s3_bucket_lifecycle_configuration.deployment.rule : r |
| + if r.id == "db-reads-delete-markers" && r.status == "Enabled" && |
| + one(r.filter).prefix == "db-reads/" && |
| + one(r.expiration).expired_object_delete_marker == true |
| + ]) == 1 |
| + error_message = "the db-reads/ delete-marker rule must stay as it was" |
| + } |
| + |
| + # The data bucket's configuration is its own resource and keeps its one |
| + # rule. |
| + assert { |
| + condition = ( |
| + length(aws_s3_bucket_lifecycle_configuration.data.rule) == 1 && |
| + one(aws_s3_bucket_lifecycle_configuration.data.rule).id == "expire-noncurrent" |
| + ) |
| + error_message = "the data bucket's lifecycle must stay as it was" |
| + } |
| +} |
diff --git a/infra/modules/media-engine/iam.tf b/infra/modules/media-engine/iam.tf| index eb63af0b3..c6bbef269 100644 |
| --- a/infra/modules/media-engine/iam.tf |
| +++ b/infra/modules/media-engine/iam.tf |
| @@ -155,6 +155,25 @@ resource "aws_iam_policy" "console" { |
| Action = "s3:ListBucket" |
| Resource = "arn:aws:s3:::${var.deployment_bucket_name}" |
| }, |
| + { |
| + # The deployment bucket is versioned, so a plain delete of a result |
| + # leaves it as a noncurrent version under a delete marker (drills |
| + # F1, F2). Cleanup lists the one key's versions, with the exact key |
| + # as the prefix, and deletes each by version id (spec §11 A8). The |
| + # listing is held to media-results/; S3 checks s3:prefix against |
| + # the request's prefix, which is the key itself. |
| + Sid = "ListResultVersions" |
| + Effect = "Allow" |
| + Action = "s3:ListBucketVersions" |
| + Resource = "arn:aws:s3:::${var.deployment_bucket_name}" |
| + Condition = { StringLike = { "s3:prefix" = "media-results/*" } } |
| + }, |
| + { |
| + Sid = "DeleteResultVersions" |
| + Effect = "Allow" |
| + Action = "s3:DeleteObjectVersion" |
| + Resource = local.results_objects |
| + }, |
| ] |
| }) |
| } |
diff --git a/infra/modules/media-engine/tests/media_engine.tftest.hcl b/infra/modules/media-engine/tests/media_engine.tftest.hcl| index 7a19f7ce0..7910311cd 100644 |
| --- a/infra/modules/media-engine/tests/media_engine.tftest.hcl |
| +++ b/infra/modules/media-engine/tests/media_engine.tftest.hcl |
| @@ -589,6 +589,14 @@ run "console_policy_exact" { |
| Sid = "PassExecutionRole" |
| }, |
| { Action = "s3:ListBucket", Effect = "Allow", Resource = "arn:aws:s3:::carlos-test-deployment", Sid = "ListResults" }, |
| + { |
| + Action = "s3:ListBucketVersions" |
| + Condition = { StringLike = { "s3:prefix" = "media-results/*" } } |
| + Effect = "Allow" |
| + Resource = "arn:aws:s3:::carlos-test-deployment" |
| + Sid = "ListResultVersions" |
| + }, |
| + { Action = "s3:DeleteObjectVersion", Effect = "Allow", Resource = "arn:aws:s3:::carlos-test-deployment/media-results/*", Sid = "DeleteResultVersions" }, |
| ]) |
| error_message = "the console's grants, exactly" |
| } |
diff --git a/internal/console/mediapass_test.go b/internal/console/mediapass_test.go| index 65f7b8c7b..528d12b3a 100644 |
| --- a/internal/console/mediapass_test.go |
| +++ b/internal/console/mediapass_test.go |
| @@ -128,8 +128,9 @@ func (f *mediaDoorFixture) codecWrites(r mediaPassRow, failed string) { |
| // runToStopped submits the test key, and runs the worker through dispatch |
| // (pass 1), the task's start (pass 2) and the codec writing what it does |
| -// and exiting with exit (pass 3). |
| -func runToStopped(t *testing.T, f *mediaDoorFixture, failed string, exit int) mediaPassRow { |
| +// and exiting with exit (pass 3), which settles the row. Its cleanup waits |
| +// for the grant (spec §11 A8): cleanAtGrantBound runs it. |
| +func runToStopped(t *testing.T, f *mediaDoorFixture, failed string, exit int) (mediaPassRow, *mediaPassWorker) { |
| t.Helper() |
| sub := f.submit(mediaTestKey) |
| if sub.status != http.StatusAccepted || sub.job.State != "queued" { |
| @@ -152,15 +153,39 @@ func runToStopped(t *testing.T, f *mediaDoorFixture, failed string, exit int) me |
| t.Fatal(err) |
| } |
| w.tick(3, time.Minute) |
| - return r |
| + return r, w |
| +} |
| + |
| +// cleanAtGrantBound checks that pass 3 settled the row and deleted |
| +// nothing, then runs pass 4 at the row's grant bound, dispatched_at + |
| +// GrantLifetime + GrantMintSlack, when every transfer of its execution has |
| +// expired. |
| +func cleanAtGrantBound(t *testing.T, f *mediaDoorFixture, w *mediaPassWorker, r mediaPassRow) { |
| + t.Helper() |
| + var dispatched, cleanup int64 |
| + if err := f.st.db.QueryRow(`SELECT dispatched_at, cleanup_due FROM media_jobs`).Scan(&dispatched, &cleanup); err != nil { |
| + t.Fatal(err) |
| + } |
| + bound := time.UnixMilli(dispatched).Add(media.GrantLifetime + media.GrantMintSlack) |
| + if cleanup != bound.UnixMilli() { |
| + t.Fatalf("cleanup_due %d, want the grant bound %d", cleanup, bound.UnixMilli()) |
| + } |
| + if len(f.grants.Deleted) != 0 { |
| + t.Fatalf("deleted %q before the grant bound", f.grants.Deleted) |
| + } |
| + if _, ok := f.grants.Results[r.execution]; !ok { |
| + t.Fatal("the result object was deleted before the grant bound") |
| + } |
| + w.tick(4, bound.Sub(f.clock)) |
| } |
| // TestMediaPassRunsTheLifecycle: the worker takes a job the door admitted |
| -// from queued to done over three passes, keeps the three outputs and |
| -// deletes the result object. |
| +// from queued to done over three passes, keeps the three outputs, and |
| +// deletes the result object in the first pass at the grant bound. |
| func TestMediaPassRunsTheLifecycle(t *testing.T) { |
| f := newMediaDoor(t, "code-media-pass-done") |
| - r := runToStopped(t, f, "", media.ExitDone) |
| + r, w := runToStopped(t, f, "", media.ExitDone) |
| + cleanAtGrantBound(t, f, w, r) |
| got := f.get(r.id) |
| if got.status != http.StatusOK || got.job.State != "done" || len(got.job.Outputs) != 3 { |
| @@ -195,11 +220,12 @@ func TestMediaPassRunsTheLifecycle(t *testing.T) { |
| } |
| // TestMediaPassFailedCleansOutputs: a job whose codec fails ends failed |
| -// with its code, and the cleanup deletes whatever outputs it uploaded as |
| -// well as the result object. |
| +// with its code, and the cleanup at the grant bound deletes whatever |
| +// outputs it uploaded as well as the result object. |
| func TestMediaPassFailedCleansOutputs(t *testing.T) { |
| f := newMediaDoor(t, "code-media-pass-failed") |
| - r := runToStopped(t, f, media.CodeNoVideo, media.ExitFailed) |
| + r, w := runToStopped(t, f, media.CodeNoVideo, media.ExitFailed) |
| + cleanAtGrantBound(t, f, w, r) |
| got := f.get(r.id) |
| if got.status != http.StatusOK || got.job.State != "failed" || got.job.Error == nil || |
diff --git a/internal/console/mediaretire_test.go b/internal/console/mediaretire_test.go| index ae94c9816..7ab81c917 100644 |
| --- a/internal/console/mediaretire_test.go |
| +++ b/internal/console/mediaretire_test.go |
| @@ -368,9 +368,17 @@ func TestAppPurgeRetiresQueuedAndRunning(t *testing.T) { |
| if r.cleanup == 0 { |
| t.Fatalf("no cleanup due on the stopped row: %+v", r) |
| } |
| + // Cleanup waits until every transfer of the execution has expired |
| + // (spec §11 A8): nothing at the stop, everything at cleanup_due. |
| if err := f.srv.media.Cleanup(ctx, f.clock); err != nil { |
| t.Fatal(err) |
| } |
| + if r := f.mediaRowOf(runID); r.cleanup == 0 { |
| + t.Fatalf("cleaned before the grant expired: %+v", r) |
| + } |
| + if err := f.srv.media.Cleanup(ctx, time.UnixMilli(r.cleanup)); err != nil { |
| + t.Fatal(err) |
| + } |
| if r := f.mediaRowOf(runID); r.cleanup != 0 { |
| t.Fatalf("cleanup did not run: %+v", r) |
| } |
diff --git a/internal/media/mediatest/grants.go b/internal/media/mediatest/grants.go| index b8d65cba2..8720f6e47 100644 |
| --- a/internal/media/mediatest/grants.go |
| +++ b/internal/media/mediatest/grants.go |
| @@ -207,11 +207,27 @@ func (g *FakeGrants) Fetch(rawURL string) (media.ObjectHead, error) { |
| g.mu.Lock() |
| defer g.mu.Unlock() |
| g.init() |
| + bucket, key, iss, err := g.resolve(rawURL) |
| + if err != nil { |
| + return media.ObjectHead{}, err |
| + } |
| + h, err := g.head(bucket, key) |
| + if err != nil { |
| + return h, err |
| + } |
| + if iss.etag != "" && h.ETag != iss.etag { |
| + return media.ObjectHead{}, errors.New("mediatest: precondition failed") |
| + } |
| + return h, nil |
| +} |
| + |
| +// resolve finds the transfer a URL built from Grant's transfers names, as |
| +// Fetch describes: ErrDenied for one never presigned, or expired. |
| +func (g *FakeGrants) resolve(rawURL string) (bucket, key string, iss issued, err error) { |
| base, query, ok := strings.Cut(rawURL, "?") |
| if !ok { |
| - return media.ObjectHead{}, media.ErrDenied |
| + return "", "", issued{}, media.ErrDenied |
| } |
| - var iss issued |
| found := false |
| for _, i := range g.issued[base] { |
| if sameQuery(query, i.query) && !g.now().After(i.expiry) { |
| @@ -220,28 +236,62 @@ func (g *FakeGrants) Fetch(rawURL string) (media.ObjectHead, error) { |
| } |
| } |
| if !found { |
| - return media.ObjectHead{}, media.ErrDenied |
| + return "", "", issued{}, media.ErrDenied |
| } |
| u, err := url.Parse(base) |
| if err != nil { |
| - return media.ObjectHead{}, err |
| + return "", "", issued{}, err |
| } |
| - bucket, ok := strings.CutSuffix(u.Host, ".s3.test") |
| + bucket, ok = strings.CutSuffix(u.Host, ".s3.test") |
| if !ok { |
| - return media.ObjectHead{}, media.ErrDenied |
| + return "", "", issued{}, media.ErrDenied |
| } |
| - key, err := url.PathUnescape(strings.TrimPrefix(u.EscapedPath(), "/")) |
| + key, err = url.PathUnescape(strings.TrimPrefix(u.EscapedPath(), "/")) |
| if err != nil { |
| - return media.ObjectHead{}, err |
| + return "", "", issued{}, err |
| } |
| - h, err := g.head(bucket, key) |
| + return bucket, key, iss, nil |
| +} |
| + |
| +// ErrPreconditionFailed is a create-only PUT over an object that exists. |
| +var ErrPreconditionFailed = errors.New("mediatest: precondition failed") |
| + |
| +// Put is a create-only PUT (If-None-Match: *) of body through a URL built |
| +// from Grant's transfers, as S3 answers it: ErrDenied for a URL never |
| +// presigned, or expired; ErrPreconditionFailed when the object exists; |
| +// otherwise the object is written, a result object into Results. An object |
| +// that was deleted is absent here, as it is in S3 once every version of |
| +// it is gone; in a versioned bucket a PUT also succeeds over a delete |
| +// marker, so it is absent to a create-only PUT either way. It is how a test |
| +// plays a leaked transfer (drills F1). |
| +func (g *FakeGrants) Put(rawURL string, body []byte) error { |
| + g.mu.Lock() |
| + defer g.mu.Unlock() |
| + g.init() |
| + bucket, key, iss, err := g.resolve(rawURL) |
| if err != nil { |
| - return h, err |
| + return err |
| } |
| - if iss.etag != "" && h.ETag != iss.etag { |
| - return media.ObjectHead{}, errors.New("mediatest: precondition failed") |
| + if iss.etag != "" { |
| + return media.ErrDenied // the source's GET: its signature is for GET |
| } |
| - return h, nil |
| + if bucket == g.deploymentBucket() { |
| + execution := strings.TrimSuffix(strings.TrimPrefix(key, "media-results/"), ".json") |
| + if media.ResultKey(execution) != key { |
| + return media.ErrDenied |
| + } |
| + if _, ok := g.Results[execution]; ok { |
| + return ErrPreconditionFailed |
| + } |
| + g.Results[execution] = append([]byte(nil), body...) |
| + return nil |
| + } |
| + if _, ok := g.Objects[bucket+"/"+key]; ok { |
| + return ErrPreconditionFailed |
| + } |
| + sum := sha256.Sum256(body) |
| + g.Objects[bucket+"/"+key] = Object{Size: int64(len(body)), ETag: hex.EncodeToString(sum[:16])} |
| + return nil |
| } |
| // sameQuery compares two raw queries as multisets of decoded pairs. |
diff --git a/internal/mediaaws/config.go b/internal/mediaaws/config.go| index 9d1d6926d..d23e98b60 100644 |
| --- a/internal/mediaaws/config.go |
| +++ b/internal/mediaaws/config.go |
| @@ -167,6 +167,7 @@ type S3API interface { |
| HeadObject(context.Context, *s3.HeadObjectInput, ...func(*s3.Options)) (*s3.HeadObjectOutput, error) |
| GetObject(context.Context, *s3.GetObjectInput, ...func(*s3.Options)) (*s3.GetObjectOutput, error) |
| DeleteObject(context.Context, *s3.DeleteObjectInput, ...func(*s3.Options)) (*s3.DeleteObjectOutput, error) |
| + ListObjectVersions(context.Context, *s3.ListObjectVersionsInput, ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error) |
| HeadBucket(context.Context, *s3.HeadBucketInput, ...func(*s3.Options)) (*s3.HeadBucketOutput, error) |
| GetBucketLocation(context.Context, *s3.GetBucketLocationInput, ...func(*s3.Options)) (*s3.GetBucketLocationOutput, error) |
| @@ -311,6 +312,7 @@ var knownAPICodes = map[string]bool{ |
| "NoSuchKey": true, |
| "NoSuchLifecycleConfiguration": true, |
| "NoSuchTagSet": true, |
| + "NoSuchVersion": true, |
| "ThrottlingException": true, |
| "TooManyRequestsException": true, |
| "ServerSideEncryptionConfigurationNotFoundError": true, |
diff --git a/internal/mediaaws/grants.go b/internal/mediaaws/grants.go| index 30f1c3b57..53ede04b1 100644 |
| --- a/internal/mediaaws/grants.go |
| +++ b/internal/mediaaws/grants.go |
| @@ -606,18 +606,81 @@ func (g *grants) ReadResult(ctx context.Context, execution string) ([]byte, erro |
| return b, nil |
| } |
| -// DeleteResult deletes the result object; absent is success. A deployment |
| -// bucket that is gone is not: that is a broken deployment, not a clean one. |
| +// resultDeleteRounds bounds DeleteResult's listings. A result has one |
| +// version, and a delete marker at most, so the first round deletes them |
| +// all and the second sees none. |
| +const resultDeleteRounds = 4 |
| + |
| +// DeleteResult deletes every version and every delete marker of the result |
| +// object (spec §5.4, §11 A8); absent is success. A deployment bucket that is |
| +// gone is not: that is a broken deployment, not a clean one. |
| +// |
| +// The deployment bucket is versioned, so a plain delete only puts a marker |
| +// over the result: the result lives on as a noncurrent version (drills F2), |
| +// and a create-only PUT succeeds over a marker as over nothing (F1). Each |
| +// round lists the versions whose key starts with the result's key, deletes |
| +// by version id those whose key is exactly it, and lists again, until a |
| +// listing holds none. A key the listing matches only by prefix is another |
| +// object and is never deleted. The exact key sorts before every longer key |
| +// it prefixes, so a listing whose first page holds none of its versions |
| +// means it has none, whatever follows. Keys come back URL encoded, as in |
| +// listed. |
| func (g *grants) DeleteResult(ctx context.Context, execution string) error { |
| - _, err := g.console.DeleteObject(ctx, &s3.DeleteObjectInput{ |
| - Bucket: aws.String(g.c.ResultsBucket), |
| - Key: aws.String(media.ResultKey(execution)), |
| - ExpectedBucketOwner: aws.String(g.c.AccountID), |
| - }) |
| - if err != nil && !isCode(err, "NoSuchKey") { |
| - return opError("s3 DeleteObject", err) |
| + if !validExecution(execution) { |
| + return &adapterError{op: "s3 DeleteObject", what: "the execution is not 32 hex characters"} |
| + } |
| + key := media.ResultKey(execution) |
| + for range resultDeleteRounds { |
| + out, err := g.console.ListObjectVersions(ctx, &s3.ListObjectVersionsInput{ |
| + Bucket: aws.String(g.c.ResultsBucket), |
| + Prefix: aws.String(key), |
| + EncodingType: s3types.EncodingTypeUrl, |
| + ExpectedBucketOwner: aws.String(g.c.AccountID), |
| + }) |
| + if err != nil { |
| + return opError("s3 ListObjectVersions", err) |
| + } |
| + var ids []*string |
| + match := func(k, id *string) error { |
| + name, err := url.QueryUnescape(aws.ToString(k)) |
| + if err != nil { |
| + return &adapterError{op: "s3 ListObjectVersions", what: "a listed key is not URL encoded"} |
| + } |
| + if name == key { |
| + ids = append(ids, id) |
| + } |
| + return nil |
| + } |
| + for _, v := range out.Versions { |
| + if err := match(v.Key, v.VersionId); err != nil { |
| + return err |
| + } |
| + } |
| + for _, m := range out.DeleteMarkers { |
| + if err := match(m.Key, m.VersionId); err != nil { |
| + return err |
| + } |
| + } |
| + if len(ids) == 0 { |
| + return nil |
| + } |
| + for _, id := range ids { |
| + in := &s3.DeleteObjectInput{ |
| + Bucket: aws.String(g.c.ResultsBucket), |
| + Key: aws.String(key), |
| + ExpectedBucketOwner: aws.String(g.c.AccountID), |
| + } |
| + // A store that names no version for an entry keeps one version |
| + // of each key: a plain delete removes it. |
| + if aws.ToString(id) != "" { |
| + in.VersionId = id |
| + } |
| + if _, err := g.console.DeleteObject(ctx, in); err != nil && !isCode(err, "NoSuchKey") && !isCode(err, "NoSuchVersion") { |
| + return opError("s3 DeleteObject", err) |
| + } |
| + } |
| } |
| - return nil |
| + return &adapterError{op: "s3 DeleteObject", what: "the result object still has versions after every round"} |
| } |
| // DeleteOutputs deletes outputs with the console's role. An absent key is |
diff --git a/internal/mediaaws/mediaaws_test.go b/internal/mediaaws/mediaaws_test.go| index 8088d495e..dc024bd2f 100644 |
| --- a/internal/mediaaws/mediaaws_test.go |
| +++ b/internal/mediaaws/mediaaws_test.go |
| @@ -154,6 +154,7 @@ type stubS3 struct { |
| headObject func(*s3.HeadObjectInput) (*s3.HeadObjectOutput, error) |
| getObject func(*s3.GetObjectInput) (*s3.GetObjectOutput, error) |
| deleteObject func(*s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error) |
| + listVersions func(*s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) |
| headBucket func(*s3.HeadBucketInput) (*s3.HeadBucketOutput, error) |
| location func(*s3.GetBucketLocationInput) (*s3.GetBucketLocationOutput, error) |
| @@ -201,6 +202,11 @@ func (s *stubS3) DeleteObject(_ context.Context, in *s3.DeleteObjectInput, _ ... |
| return s.deleteObject(in) |
| } |
| +func (s *stubS3) ListObjectVersions(_ context.Context, in *s3.ListObjectVersionsInput, _ ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error) { |
| + s.saw("ListObjectVersions", in.ExpectedBucketOwner) |
| + return s.listVersions(in) |
| +} |
| + |
| func (s *stubS3) HeadBucket(_ context.Context, in *s3.HeadBucketInput, _ ...func(*s3.Options)) (*s3.HeadBucketOutput, error) { |
| s.saw("HeadBucket", in.ExpectedBucketOwner) |
| return s.headBucket(in) |
| @@ -1903,14 +1909,11 @@ func TestDeletes(t *testing.T) { |
| } |
| api := &stubS3{deleteObject: ok} |
| g := NewGrants(testConfig(), staticAssume(time.Now()), api) |
| - if err := g.DeleteResult(context.Background(), testExec); err != nil { |
| - t.Fatal(err) |
| - } |
| keys := []string{"derived/a/video.mp4", "derived/a/video.m3u8"} |
| if err := g.DeleteOutputs(context.Background(), testBucket, keys); err != nil { |
| t.Fatal(err) |
| } |
| - want := []string{testResults + "/" + media.ResultKey(testExec), testBucket + "/derived/a/video.mp4", testBucket + "/derived/a/video.m3u8"} |
| + want := []string{testBucket + "/derived/a/video.mp4", testBucket + "/derived/a/video.m3u8"} |
| if !slices.Equal(deleted, want) { |
| t.Fatalf("deleted %v", deleted) |
| } |
| @@ -1938,7 +1941,9 @@ func TestDeletes(t *testing.T) { |
| }) |
| } |
| t.Run("a result bucket that is gone is not success", func(t *testing.T) { |
| - api := &stubS3{deleteObject: func(*s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error) { return nil, &s3types.NoSuchBucket{} }} |
| + api := &stubS3{listVersions: func(*s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) { |
| + return nil, &s3types.NoSuchBucket{} |
| + }} |
| if err := NewGrants(testConfig(), staticAssume(time.Now()), api).DeleteResult(context.Background(), testExec); err == nil { |
| t.Fatal("a missing deployment bucket passed as a deleted result") |
| } |
| @@ -2573,6 +2578,7 @@ func TestAdapterErrorsCarryNoSecrets(t *testing.T) { |
| listObjects: func(*s3.ListObjectsV2Input) (*s3.ListObjectsV2Output, error) { return nil, leaky }, |
| getObject: func(*s3.GetObjectInput) (*s3.GetObjectOutput, error) { return nil, leaky }, |
| deleteObject: func(*s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error) { return nil, leaky }, |
| + listVersions: func(*s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) { return nil, leaky }, |
| headBucket: func(*s3.HeadBucketInput) (*s3.HeadBucketOutput, error) { return nil, leaky }, |
| tagging: func(*s3.GetBucketTaggingInput) (*s3.GetBucketTaggingOutput, error) { return nil, leaky }, |
| putTagging: func(*s3.PutBucketTaggingInput) (*s3.PutBucketTaggingOutput, error) { return nil, leaky }, |
diff --git a/internal/mediaaws/minio_test.go b/internal/mediaaws/minio_test.go| index cd58892b0..5f8b3776e 100644 |
| --- a/internal/mediaaws/minio_test.go |
| +++ b/internal/mediaaws/minio_test.go |
| @@ -15,6 +15,7 @@ import ( |
| "github.com/aws/aws-sdk-go-v2/aws" |
| "github.com/aws/aws-sdk-go-v2/credentials" |
| "github.com/aws/aws-sdk-go-v2/service/s3" |
| + s3types "github.com/aws/aws-sdk-go-v2/service/s3/types" |
| "github.com/aws/aws-sdk-go-v2/service/sts" |
| "github.com/carlosframework/platform/internal/media" |
| @@ -190,14 +191,85 @@ func TestMediaTransfersMinio(t *testing.T) { |
| if err != nil || !bytes.Equal(b, result) { |
| t.Fatalf("ReadResult = %q, %v", b, err) |
| } |
| + |
| + // Drills F1 and F2 on a versioned results bucket, as the deployment |
| + // bucket is. The old cleanup, a plain delete, leaves the result as a |
| + // noncurrent version under a marker, and the same create-only transfer |
| + // then succeeds over the marker. |
| + results := c.ResultsBucket |
| + resultKey := media.ResultKey(execution) |
| + v, err := console.GetBucketVersioning(ctx, &s3.GetBucketVersioningInput{Bucket: aws.String(results)}) |
| + if err != nil || v.Status != s3types.BucketVersioningStatusEnabled { |
| + t.Fatalf("the results bucket must be versioned, as the deployment bucket is (30-minio-contract enables it): %v, %v", v, err) |
| + } |
| + sibling := resultKey + ".kept" |
| + if _, err := console.PutObject(ctx, &s3.PutObjectInput{Bucket: aws.String(results), Key: aws.String(sibling), Body: bytes.NewReader([]byte("x"))}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := console.DeleteObject(ctx, &s3.DeleteObjectInput{Bucket: aws.String(results), Key: aws.String(resultKey)}); err != nil { |
| + t.Fatalf("the old cleanup's delete: %v", err) |
| + } |
| + if _, err := g.ReadResult(ctx, execution); !errors.Is(err, media.ErrNotFound) { |
| + t.Fatalf("ReadResult under the delete marker: %v", err) |
| + } |
| + if status := sendTransfer(t, tr, tr.Result, []byte("leaked"), nil); status != http.StatusOK { |
| + t.Fatalf("a create-only result PUT over the delete marker = %d, want 200 (F1)", status) |
| + } |
| + versions := func(key string) (objects, markers int) { |
| + t.Helper() |
| + out, err := console.ListObjectVersions(ctx, &s3.ListObjectVersionsInput{Bucket: aws.String(results), Prefix: aws.String(key)}) |
| + if err != nil { |
| + t.Fatalf("ListObjectVersions: %v", err) |
| + } |
| + for _, o := range out.Versions { |
| + if aws.ToString(o.Key) == key { |
| + objects++ |
| + } |
| + } |
| + for _, m := range out.DeleteMarkers { |
| + if aws.ToString(m.Key) == key { |
| + markers++ |
| + } |
| + } |
| + return objects, markers |
| + } |
| + if o, m := versions(resultKey); o != 2 || m != 1 { |
| + t.Fatalf("after the old cleanup and a leaked PUT: %d versions, %d markers; want 2 and 1", o, m) |
| + } |
| + |
| + // DeleteResult removes every version and marker of the one key, and |
| + // leaves a key it only prefixes. Absent is success the second time. |
| for range 2 { |
| if err := g.DeleteResult(ctx, execution); err != nil { |
| t.Fatalf("DeleteResult: %v", err) |
| } |
| } |
| + if o, m := versions(resultKey); o != 0 || m != 0 { |
| + t.Fatalf("after DeleteResult: %d versions, %d markers", o, m) |
| + } |
| + if o, _ := versions(sibling); o != 1 { |
| + t.Fatalf("DeleteResult touched %s", sibling) |
| + } |
| if _, err := g.ReadResult(ctx, execution); !errors.Is(err, media.ErrNotFound) { |
| t.Fatalf("ReadResult after the delete: %v", err) |
| } |
| + // A transfer still in date can create the key again: that is why the |
| + // job table cleans only once the grant has expired (spec §11 A8). |
| + if status := sendTransfer(t, tr, tr.Result, []byte("leaked"), nil); status != http.StatusOK { |
| + t.Fatalf("a create-only result PUT after every version went = %d, want 200", status) |
| + } |
| + if err := g.DeleteResult(ctx, execution); err != nil { |
| + t.Fatalf("DeleteResult: %v", err) |
| + } |
| + out, err := console.ListObjectVersions(ctx, &s3.ListObjectVersionsInput{Bucket: aws.String(results), Prefix: aws.String(sibling)}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, o := range out.Versions { |
| + if _, err := console.DeleteObject(ctx, &s3.DeleteObjectInput{Bucket: aws.String(results), Key: o.Key, VersionId: o.VersionId}); err != nil { |
| + t.Fatalf("remove %s: %v", sibling, err) |
| + } |
| + } |
| // Cleanup through the adapter: absent keys are success the second time. |
| var keys []string |
diff --git a/internal/mediaaws/versions_test.go b/internal/mediaaws/versions_test.go| new file mode 100644 |
| index 000000000..bcbe57795 |
| --- /dev/null |
| +++ b/internal/mediaaws/versions_test.go |
| @@ -0,0 +1,373 @@ |
| +package mediaaws |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "net/http" |
| + "net/url" |
| + "slices" |
| + "strconv" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "github.com/aws/aws-sdk-go-v2/aws" |
| + "github.com/aws/aws-sdk-go-v2/service/s3" |
| + s3types "github.com/aws/aws-sdk-go-v2/service/s3/types" |
| + "github.com/aws/smithy-go" |
| + |
| + "github.com/carlosframework/platform/internal/media" |
| +) |
| + |
| +// versionedBucket is one bucket with versioning on, as S3 keeps it (drills |
| +// F1, F2): every write is a new version; a delete with no version id puts |
| +// a delete marker on top and removes nothing; a delete with a version id |
| +// removes that version or marker for good; and a create-only PUT |
| +// (If-None-Match: *) is refused only when the current version is an |
| +// object, so over a delete marker, as over nothing, it succeeds. |
| +// ListObjectVersions lists keys in order, each key's entries newest |
| +// first, pageSize at a time. Any other operation panics on the nil |
| +// embedded interface. |
| +type versionedBucket struct { |
| + S3API |
| + name string |
| + pageSize int // entries a listing answers; 0 is S3's 1000 |
| + |
| + mu sync.Mutex |
| + seq int |
| + keys map[string][]objectVersion // oldest first |
| + deletes []string // each DeleteObject: "key" or "key@id" |
| + owners []string // each call's ExpectedBucketOwner |
| + // deleteErr, when set, answers a delete by version id instead. |
| + deleteErr func(key, id string) error |
| + // keepVersions makes deletes by version id succeed and remove nothing. |
| + keepVersions bool |
| +} |
| + |
| +type objectVersion struct { |
| + id string |
| + marker bool |
| + body string |
| +} |
| + |
| +func newVersionedBucket(name string) *versionedBucket { |
| + return &versionedBucket{name: name, keys: map[string][]objectVersion{}} |
| +} |
| + |
| +// put is a PUT of key; createOnly adds If-None-Match: *. It answers the |
| +// HTTP status S3 would. |
| +func (b *versionedBucket) put(key, body string, createOnly bool) int { |
| + b.mu.Lock() |
| + defer b.mu.Unlock() |
| + vs := b.keys[key] |
| + if createOnly && len(vs) > 0 && !vs[len(vs)-1].marker { |
| + return http.StatusPreconditionFailed |
| + } |
| + b.seq++ |
| + b.keys[key] = append(vs, objectVersion{id: "v" + strconv.Itoa(b.seq), body: body}) |
| + return http.StatusOK |
| +} |
| + |
| +// current is key's current object: false when it has none or its current |
| +// version is a delete marker. |
| +func (b *versionedBucket) current(key string) (string, bool) { |
| + b.mu.Lock() |
| + defer b.mu.Unlock() |
| + vs := b.keys[key] |
| + if len(vs) == 0 || vs[len(vs)-1].marker { |
| + return "", false |
| + } |
| + return vs[len(vs)-1].body, true |
| +} |
| + |
| +// entries is how many versions and markers key has. |
| +func (b *versionedBucket) entries(key string) (versions, markers int) { |
| + b.mu.Lock() |
| + defer b.mu.Unlock() |
| + for _, v := range b.keys[key] { |
| + if v.marker { |
| + markers++ |
| + } else { |
| + versions++ |
| + } |
| + } |
| + return versions, markers |
| +} |
| + |
| +func (b *versionedBucket) ListObjectVersions(_ context.Context, in *s3.ListObjectVersionsInput, _ ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error) { |
| + b.mu.Lock() |
| + defer b.mu.Unlock() |
| + b.owners = append(b.owners, aws.ToString(in.ExpectedBucketOwner)) |
| + if aws.ToString(in.Bucket) != b.name { |
| + return nil, &s3types.NoSuchBucket{} |
| + } |
| + if in.KeyMarker != nil || in.VersionIdMarker != nil { |
| + return nil, errors.New("versionedBucket: DeleteResult relists from the start and never pages") |
| + } |
| + var names []string |
| + for k := range b.keys { |
| + if strings.HasPrefix(k, aws.ToString(in.Prefix)) { |
| + names = append(names, k) |
| + } |
| + } |
| + slices.Sort(names) |
| + size := b.pageSize |
| + if size == 0 { |
| + size = 1000 |
| + } |
| + out := &s3.ListObjectVersionsOutput{} |
| + n := 0 |
| + for _, k := range names { |
| + listed := k |
| + if in.EncodingType == s3types.EncodingTypeUrl { |
| + listed = url.QueryEscape(k) |
| + } |
| + vs := b.keys[k] |
| + for i := len(vs) - 1; i >= 0; i-- { |
| + if n == size { |
| + out.IsTruncated = aws.Bool(true) |
| + return out, nil |
| + } |
| + n++ |
| + latest := aws.Bool(i == len(vs)-1) |
| + if vs[i].marker { |
| + out.DeleteMarkers = append(out.DeleteMarkers, s3types.DeleteMarkerEntry{Key: aws.String(listed), VersionId: aws.String(vs[i].id), IsLatest: latest}) |
| + } else { |
| + out.Versions = append(out.Versions, s3types.ObjectVersion{Key: aws.String(listed), VersionId: aws.String(vs[i].id), IsLatest: latest}) |
| + } |
| + } |
| + } |
| + return out, nil |
| +} |
| + |
| +func (b *versionedBucket) DeleteObject(_ context.Context, in *s3.DeleteObjectInput, _ ...func(*s3.Options)) (*s3.DeleteObjectOutput, error) { |
| + b.mu.Lock() |
| + defer b.mu.Unlock() |
| + b.owners = append(b.owners, aws.ToString(in.ExpectedBucketOwner)) |
| + if aws.ToString(in.Bucket) != b.name { |
| + return nil, &s3types.NoSuchBucket{} |
| + } |
| + key := aws.ToString(in.Key) |
| + if in.VersionId == nil { |
| + b.deletes = append(b.deletes, key) |
| + b.seq++ |
| + b.keys[key] = append(b.keys[key], objectVersion{id: "m" + strconv.Itoa(b.seq), marker: true}) |
| + return &s3.DeleteObjectOutput{}, nil |
| + } |
| + id := aws.ToString(in.VersionId) |
| + b.deletes = append(b.deletes, key+"@"+id) |
| + if b.deleteErr != nil { |
| + if err := b.deleteErr(key, id); err != nil { |
| + return nil, err |
| + } |
| + } |
| + if b.keepVersions { |
| + return &s3.DeleteObjectOutput{}, nil |
| + } |
| + b.keys[key] = slices.DeleteFunc(b.keys[key], func(v objectVersion) bool { return v.id == id }) |
| + if len(b.keys[key]) == 0 { |
| + delete(b.keys, key) |
| + } |
| + return &s3.DeleteObjectOutput{}, nil |
| +} |
| + |
| +// TestResultCleanupOnAVersionedBucket is drills F1 and F2 against a model |
| +// of a versioned bucket. The old cleanup, a plain DeleteObject of the |
| +// result key, leaves the result as a noncurrent version under a marker, |
| +// and a create-only PUT then makes it current again. DeleteResult leaves |
| +// the key with no version and no marker. Whether a PUT can then recreate |
| +// it rests on its URL having expired, which is the job table's cleanup |
| +// timing (TestCleanupWaitsForTheGrant in internal/mediajobs). |
| +func TestResultCleanupOnAVersionedBucket(t *testing.T) { |
| + ctx := context.Background() |
| + key := media.ResultKey(testExec) |
| + |
| + t.Run("the old cleanup leaves the result recreatable", func(t *testing.T) { |
| + b := newVersionedBucket(testResults) |
| + if status := b.put(key, `{"v":1}`, true); status != http.StatusOK { |
| + t.Fatalf("the codec's result PUT = %d", status) |
| + } |
| + // What DeleteResult did before A8. |
| + if _, err := b.DeleteObject(ctx, &s3.DeleteObjectInput{Bucket: aws.String(testResults), Key: aws.String(key)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, ok := b.current(key); ok { |
| + t.Fatal("the result is still current after the delete") |
| + } |
| + if v, m := b.entries(key); v != 1 || m != 1 { |
| + t.Fatalf("after the old cleanup: %d versions, %d markers; want the result kept under a marker (F2)", v, m) |
| + } |
| + if status := b.put(key, "anything at all", true); status != http.StatusOK { |
| + t.Fatalf("a create-only PUT over the marker = %d, want 200 (F1)", status) |
| + } |
| + if body, ok := b.current(key); !ok || body != "anything at all" { |
| + t.Fatalf("after the leaked PUT the key holds %q, %v", body, ok) |
| + } |
| + }) |
| + |
| + t.Run("DeleteResult removes every version and marker of the one key", func(t *testing.T) { |
| + b := newVersionedBucket(testResults) |
| + other := media.ResultKey("fedcba9876543210fedcba9876543210") |
| + sibling := key + ".kept" |
| + b.put(key, `{"v":1}`, true) |
| + if _, err := b.DeleteObject(ctx, &s3.DeleteObjectInput{Bucket: aws.String(testResults), Key: aws.String(key)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.put(key, "recreated", true) |
| + b.put(sibling, "a key the prefix matches", false) |
| + b.put(other, "another execution's", true) |
| + g := NewGrants(testConfig(), staticAssume(time.Now()), b) |
| + if err := g.DeleteResult(ctx, testExec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if v, m := b.entries(key); v != 0 || m != 0 { |
| + t.Fatalf("after DeleteResult the key has %d versions and %d markers", v, m) |
| + } |
| + for _, k := range []string{sibling, other} { |
| + if _, ok := b.current(k); !ok { |
| + t.Fatalf("DeleteResult touched %s", k) |
| + } |
| + } |
| + for _, d := range b.deletes[1:] { // [0] is the old-style delete above |
| + if !strings.HasPrefix(d, key+"@") { |
| + t.Fatalf("DeleteResult made a delete without a version id, or of another key: %s", d) |
| + } |
| + } |
| + for _, o := range b.owners[1:] { // [0] is the old-style delete above |
| + if o != testAccount { |
| + t.Fatalf("a call sent expected owner %q", o) |
| + } |
| + } |
| + // Absent is success, and costs one listing. |
| + before := len(b.owners) |
| + if err := g.DeleteResult(ctx, testExec); err != nil { |
| + t.Fatalf("DeleteResult of an absent result: %v", err) |
| + } |
| + if len(b.owners) != before+1 { |
| + t.Fatalf("DeleteResult of an absent result made %d calls, want one listing", len(b.owners)-before) |
| + } |
| + }) |
| + |
| + t.Run("more versions than one listing answers", func(t *testing.T) { |
| + b := newVersionedBucket(testResults) |
| + b.pageSize = 2 |
| + b.put(key, "one", false) |
| + b.put(key, "two", false) |
| + b.put(key, "three", false) |
| + b.put(key+"x", "after it in order", false) |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), b).DeleteResult(ctx, testExec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if v, m := b.entries(key); v != 0 || m != 0 { |
| + t.Fatalf("left %d versions and %d markers", v, m) |
| + } |
| + if _, ok := b.current(key + "x"); !ok { |
| + t.Fatal("a longer key was deleted") |
| + } |
| + }) |
| + |
| + t.Run("a listing that only names longer keys is no version", func(t *testing.T) { |
| + b := newVersionedBucket(testResults) |
| + b.pageSize = 1 |
| + b.put(key+".a", "x", false) |
| + b.put(key+".b", "y", false) |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), b).DeleteResult(ctx, testExec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(b.deletes) != 0 { |
| + t.Fatalf("deleted %v", b.deletes) |
| + } |
| + }) |
| + |
| + t.Run("a version that never goes is an error", func(t *testing.T) { |
| + b := newVersionedBucket(testResults) |
| + b.keepVersions = true |
| + b.put(key, "stuck", false) |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), b).DeleteResult(ctx, testExec); err == nil { |
| + t.Fatal("DeleteResult passed with a version left") |
| + } |
| + if len(b.deletes) != resultDeleteRounds { |
| + t.Fatalf("made %d deletes, want one per round (%d)", len(b.deletes), resultDeleteRounds) |
| + } |
| + }) |
| + |
| + t.Run("a version deleted meanwhile is success", func(t *testing.T) { |
| + for _, code := range []string{"NoSuchVersion", "NoSuchKey"} { |
| + b := newVersionedBucket(testResults) |
| + b.put(key, "x", false) |
| + b.deleteErr = func(key, id string) error { |
| + b.keys[key] = nil |
| + delete(b.keys, key) |
| + return &smithy.GenericAPIError{Code: code} |
| + } |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), b).DeleteResult(ctx, testExec); err != nil { |
| + t.Fatalf("%s: %v", code, err) |
| + } |
| + } |
| + }) |
| + |
| + t.Run("a refused delete is an error", func(t *testing.T) { |
| + b := newVersionedBucket(testResults) |
| + b.put(key, "x", false) |
| + b.deleteErr = func(string, string) error { return &smithy.GenericAPIError{Code: "AccessDenied"} } |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), b).DeleteResult(ctx, testExec); err == nil { |
| + t.Fatal("a refused version delete passed") |
| + } |
| + }) |
| + |
| + t.Run("a refused listing is an error", func(t *testing.T) { |
| + api := &stubS3{listVersions: func(*s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) { |
| + return nil, &smithy.GenericAPIError{Code: "AccessDenied"} |
| + }} |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), api).DeleteResult(ctx, testExec); err == nil { |
| + t.Fatal("a refused listing passed") |
| + } |
| + }) |
| + |
| + t.Run("the listing asks for the exact key, URL encoded", func(t *testing.T) { |
| + var got *s3.ListObjectVersionsInput |
| + api := &stubS3{listVersions: func(in *s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) { |
| + got = in |
| + return &s3.ListObjectVersionsOutput{}, nil |
| + }} |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), api).DeleteResult(ctx, testExec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if aws.ToString(got.Bucket) != testResults || aws.ToString(got.Prefix) != key || got.EncodingType != s3types.EncodingTypeUrl || |
| + aws.ToString(got.ExpectedBucketOwner) != testAccount || got.Delimiter != nil || got.KeyMarker != nil { |
| + t.Fatalf("listed %+v", got) |
| + } |
| + }) |
| + |
| + t.Run("an unversioned store's null version is deleted by id", func(t *testing.T) { |
| + var deleted []string |
| + api := &stubS3{ |
| + listVersions: func(*s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) { |
| + if len(deleted) > 0 { |
| + return &s3.ListObjectVersionsOutput{}, nil |
| + } |
| + return &s3.ListObjectVersionsOutput{Versions: []s3types.ObjectVersion{{Key: aws.String(url.QueryEscape(key)), VersionId: aws.String("null")}}}, nil |
| + }, |
| + deleteObject: func(in *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error) { |
| + deleted = append(deleted, aws.ToString(in.Key)+"@"+aws.ToString(in.VersionId)) |
| + return &s3.DeleteObjectOutput{}, nil |
| + }, |
| + } |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), api).DeleteResult(ctx, testExec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !slices.Equal(deleted, []string{key + "@null"}) { |
| + t.Fatalf("deleted %v", deleted) |
| + } |
| + }) |
| + |
| + t.Run("an execution that is not one is refused before any call", func(t *testing.T) { |
| + api := &stubS3{} // any call panics |
| + for _, bad := range []string{"", "x", testExec + "/", "../" + testExec[3:], strings.ToUpper(testExec)} { |
| + if err := NewGrants(testConfig(), staticAssume(time.Now()), api).DeleteResult(ctx, bad); err == nil { |
| + t.Fatalf("DeleteResult(%q) passed", bad) |
| + } |
| + } |
| + }) |
| +} |
diff --git a/internal/mediajobs/dispatch.go b/internal/mediajobs/dispatch.go| index 00fefdce3..decaa3567 100644 |
| --- a/internal/mediajobs/dispatch.go |
| +++ b/internal/mediajobs/dispatch.go |
| @@ -302,6 +302,35 @@ func (j *Jobs) failQueued(ctx context.Context, tx *sql.Tx, k key, code string, n |
| return nil |
| } |
| +// grantBound is the moment every transfer of an execution dispatched at |
| +// dispatched has expired: Launch mints the grant at most |
| +// media.GrantMintSlack after dispatch and refuses one that expires more |
| +// than media.GrantLifetime after that. From then on S3 refuses every new |
| +// request through a transfer of the execution, the result's included, so |
| +// a cleanup at or after it cannot be undone by a request that begins |
| +// later (spec §11 A8, drills F1). Before it, a create-only PUT from a |
| +// leaked transfer succeeds over a deleted result, as over a delete |
| +// marker. S3 checks a presigned request's expiry when the request begins, |
| +// so a PUT begun before the bound can still complete after the cleanup: |
| +// A8's stated residual, which the lifecycle rules catch for a result. |
| +func grantBound(dispatched time.Time) time.Time { |
| + return dispatched.Add(media.GrantLifetime + media.GrantMintSlack) |
| +} |
| + |
| +// grantBoundMS is grantBound's offset from dispatched_at, in the |
| +// column's milliseconds. |
| +const grantBoundMS = int64((media.GrantLifetime + media.GrantMintSlack) / time.Millisecond) |
| + |
| +// cleanupDueSQL is the cleanup_due of a row whose task stopped: the |
| +// observation (its first parameter) or the row's grant bound (dispatched_at |
| +// plus its second, grantBoundMS), whichever is later. Cleanup runs after |
| +// the task stopped so that the task writes nothing more (spec §5.3), and |
| +// after the grant bound so that nothing holding its transfers can begin a |
| +// write afterwards (one begun before may still complete; grantBound): |
| +// a task's transfers are readable from ECS by any principal that may |
| +// describe it (spec §5.5), and the deployment bucket is versioned. |
| +const cleanupDueSQL = `MAX(?, dispatched_at + ?)` |
| + |
| // Launch mints the grant and starts the task of a dispatched row. It |
| // refuses a launch more than media.GrantMintSlack after the row's |
| // dispatched_at (a console that stalled between DispatchNext and Launch): |
| @@ -334,10 +363,10 @@ func (j *Jobs) launch(ctx context.Context, l *Launch, now time.Time) (started bo |
| } |
| job := l.job |
| k := keyOf(job) |
| - bound := job.DispatchedAt.Add(media.GrantLifetime + media.GrantMintSlack) |
| + bound := grantBound(job.DispatchedAt) |
| if now.Sub(job.DispatchedAt) > media.GrantMintSlack { |
| j.logf("launch %s: stale, dispatched %s ago", k, now.Sub(job.DispatchedAt)) |
| - if err := j.release(ctx, k, true, true, now); err != nil { |
| + if err := j.release(ctx, k, true, true, false, now); err != nil { |
| return false, err |
| } |
| return false, ErrLaunchStale |
| @@ -351,15 +380,15 @@ func (j *Jobs) launch(ctx context.Context, l *Launch, now time.Time) (started bo |
| if err != nil { |
| if ctx.Err() != nil { |
| j.logf("launch %s: grant: %v; the launch was cancelled, back to queued", k, err) |
| - return false, j.release(ctx, k, true, false, now) |
| + return false, j.release(ctx, k, true, false, false, now) |
| } |
| j.logf("launch %s: grant: %v; rejected, retryable", k, err) |
| - return false, j.release(ctx, k, true, true, now) |
| + return false, j.release(ctx, k, true, true, false, now) |
| } |
| if expiry.After(bound) { |
| // Run would let a PUT land after the row's cleanup. |
| j.logf("launch %s: the grant expires at %s, after the cleanup bound %s", k, expiry.UTC().Format(time.RFC3339), bound.UTC().Format(time.RFC3339)) |
| - if err := j.release(ctx, k, true, true, now); err != nil { |
| + if err := j.release(ctx, k, true, true, false, now); err != nil { |
| return false, err |
| } |
| return false, ErrLaunchStale |
| @@ -392,12 +421,12 @@ func (j *Jobs) launch(ctx context.Context, l *Launch, now time.Time) (started bo |
| } |
| if err != nil { |
| j.logf("launch %s: payload: %v; rejected", k, err) |
| - return false, j.release(ctx, k, false, true, now) |
| + return false, j.release(ctx, k, false, true, false, now) |
| } |
| if err := ctx.Err(); err != nil { |
| // Run is never called, so no task exists. |
| j.logf("launch %s: %v before RunTask; the launch was cancelled, back to queued", k, err) |
| - return false, j.release(ctx, k, true, false, now) |
| + return false, j.release(ctx, k, true, false, false, now) |
| } |
| arn, err := j.d.Engine.Run(ctx, media.RunRequest{ |
| Execution: job.Execution, |
| @@ -411,7 +440,9 @@ func (j *Jobs) launch(ctx context.Context, l *Launch, now time.Time) (started bo |
| switch { |
| case errors.As(err, &rej): |
| j.logf("launch %s: %v", k, rej) |
| - return false, j.release(ctx, k, rej.Retryable, true, now) |
| + // RunTask was called: its request, the transfers among its |
| + // overrides, is in the account's audit trail (spec §5.5). |
| + return false, j.release(ctx, k, rej.Retryable, true, true, now) |
| case err != nil: |
| return false, fmt.Errorf("mediajobs: launch %s: run, left for recovery: %w", k, err) |
| } |
| @@ -443,24 +474,39 @@ func (j *Jobs) recordARN(ctx context.Context, k key, arn string) error { |
| // running with no task, holding its place and blocking its store's |
| // teardown until its engine_lost bound (branch review round 1, P2-1). |
| // strike is false when the cause was ctx ending, not the row or the |
| -// engine. |
| -func (j *Jobs) release(ctx context.Context, k key, retryable, strike bool, now time.Time) error { |
| +// engine. sent is true when RunTask was called, so the execution's |
| +// transfers left the console (neverStarted). |
| +func (j *Jobs) release(ctx context.Context, k key, retryable, strike, sent bool, now time.Time) error { |
| rctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), ReleaseTimeout) |
| defer cancel() |
| - return j.neverStarted(rctx, k, retryable, strike, now) |
| + return j.neverStarted(rctx, k, retryable, strike, sent, now) |
| } |
| // neverStarted is "launch rejected" and "never started" in one |
| // transaction: task_stopped, start_failures + 1 when strike, then a |
| // retired row fails retired; with no strike, or a retryable cause on the |
| // first failure, the row goes back to queued; anything else fails |
| -// engine_unavailable. All uncharged, nothing to clean. |
| -func (j *Jobs) neverStarted(ctx context.Context, k key, retryable, strike bool, now time.Time) error { |
| +// engine_unavailable. All uncharged. |
| +// |
| +// sent is true when RunTask was called for the execution: a task was |
| +// created and never started, or RunTask refused the request. Either way |
| +// the transfers left the console, in the task's overrides, which any |
| +// principal that may describe it can read, and in the account's audit |
| +// trail (spec §5.5), and a create-only PUT through one succeeds until the |
| +// grant expires. So the execution keeps a cleanup duty at its grant bound |
| +// (spec §11 A8): a row that fails keeps its execution with cleanup_due at |
| +// the bound; a row that goes back to queued, and so gives its execution |
| +// up, keeps the duty in prior_execution and prior_cleanup_due, which |
| +// Cleanup reads. A row goes back to queued after a strike once at most |
| +// (its first failure), so it never holds two such duties; a requeue with |
| +// no strike is never sent. Not sent, nothing was written and nothing is |
| +// cleaned. |
| +func (j *Jobs) neverStarted(ctx context.Context, k key, retryable, strike, sent bool, now time.Time) error { |
| return j.inTx(ctx, func(tx *sql.Tx) error { |
| const guard = ` AND state = 'running' AND task_stopped = 0 AND settled = 0` |
| var failures int |
| - var retired int64 |
| - err := tx.QueryRowContext(ctx, `SELECT start_failures, retired_at FROM media_jobs WHERE `+keyWhere+guard, k.args()...).Scan(&failures, &retired) |
| + var retired, prior int64 |
| + err := tx.QueryRowContext(ctx, `SELECT start_failures, retired_at, prior_cleanup_due FROM media_jobs WHERE `+keyWhere+guard, k.args()...).Scan(&failures, &retired, &prior) |
| if errors.Is(err, sql.ErrNoRows) { |
| j.logf("never started %s: dropped, the row is no longer live", k) |
| return nil |
| @@ -471,20 +517,41 @@ func (j *Jobs) neverStarted(ctx context.Context, k key, retryable, strike bool, |
| if strike { |
| failures++ |
| } |
| + // cleanup is the failed row's cleanup_due: its grant bound when |
| + // sent, else none. |
| + cleanup, bound := `0`, int64(0) |
| + if sent { |
| + cleanup, bound = `dispatched_at + ?`, grantBoundMS |
| + } |
| + failArgs := func(code string) []any { |
| + if sent { |
| + return k.args(code, failures, bound, stamp(now)) |
| + } |
| + return k.args(code, failures, stamp(now)) |
| + } |
| var ok bool |
| switch { |
| case retired > 0: |
| ok, err = guarded(ctx, tx, `UPDATE media_jobs SET state = 'failed', error = ?, task_stopped = 1, start_failures = ?, |
| - settled = 1, charged_ms = 0, cleanup_due = 0, ended_at = ? |
| - WHERE `+keyWhere+guard, k.args(media.CodeRetired, failures, stamp(now))...) |
| + settled = 1, charged_ms = 0, cleanup_due = `+cleanup+`, ended_at = ? |
| + WHERE `+keyWhere+guard, failArgs(media.CodeRetired)...) |
| case !strike || (retryable && failures == 1): |
| + if sent && prior > 0 { |
| + // By the counting above this cannot happen; refuse rather |
| + // than lose the first duty. |
| + return fmt.Errorf("mediajobs: never started %s: a second execution to give up with a cleanup duty", k) |
| + } |
| + // SQLite evaluates every SET expression against the row as it |
| + // was, so prior_execution takes the execution being cleared. |
| ok, err = guarded(ctx, tx, `UPDATE media_jobs SET state = 'queued', task_stopped = 1, start_failures = ?, |
| + prior_execution = CASE WHEN ? THEN execution_id ELSE prior_execution END, |
| + prior_cleanup_due = CASE WHEN ? THEN dispatched_at + ? ELSE prior_cleanup_due END, |
| execution_id = '', task_arn = '', granted_s = 0, deadline_s = 0, error = '' |
| - WHERE `+keyWhere+guard, k.args(failures)...) |
| + WHERE `+keyWhere+guard, k.args(failures, sent, sent, grantBoundMS)...) |
| default: |
| ok, err = guarded(ctx, tx, `UPDATE media_jobs SET state = 'failed', error = ?, task_stopped = 1, start_failures = ?, |
| - settled = 1, charged_ms = 0, cleanup_due = 0, ended_at = ? |
| - WHERE `+keyWhere+guard, k.args(media.CodeEngineUnavailable, failures, stamp(now))...) |
| + settled = 1, charged_ms = 0, cleanup_due = `+cleanup+`, ended_at = ? |
| + WHERE `+keyWhere+guard, failArgs(media.CodeEngineUnavailable)...) |
| } |
| if err == nil && !ok { |
| j.logf("never started %s: dropped", k) |
diff --git a/internal/mediajobs/jobs_test.go b/internal/mediajobs/jobs_test.go| index 38714743f..c2ed70304 100644 |
| --- a/internal/mediajobs/jobs_test.go |
| +++ b/internal/mediajobs/jobs_test.go |
| @@ -158,6 +158,19 @@ func (h *harness) launch(l *Launch) { |
| } |
| } |
| +// prior is a row's duty for an execution it gave up (neverStarted): |
| +// the execution and when its cleanup is due, "" and zero for none. |
| +func (h *harness) prior(j Job) (string, time.Time) { |
| + h.t.Helper() |
| + var x string |
| + var due int64 |
| + if err := h.db.QueryRowContext(tctx, `SELECT prior_execution, prior_cleanup_due FROM media_jobs WHERE account = ? AND app = ? AND incarnation = ? AND job_id = ?`, |
| + j.Account, j.App, j.Incarnation, j.ID).Scan(&x, &due); err != nil { |
| + h.t.Fatal(err) |
| + } |
| + return x, msTime(due) |
| +} |
| + |
| // row reads a job's row, retired or not. |
| func (h *harness) row(j Job) Job { |
| h.t.Helper() |
| @@ -240,6 +253,15 @@ func (h *harness) cleanup() { |
| } |
| } |
| +// pastGrant moves the clock to r's grant bound, when every transfer of its |
| +// execution has expired and its cleanup is due (spec §11 A8), unless the |
| +// clock is already past it. |
| +func (h *harness) pastGrant(r Job) { |
| + if b := grantBound(r.DispatchedAt); h.now.Before(b) { |
| + h.now = b |
| + } |
| +} |
| + |
| func (h *harness) usage(account string, month time.Time) Usage { |
| h.t.Helper() |
| u, err := h.jobs.Usage(tctx, account, month) |
| @@ -745,17 +767,24 @@ func TestLaunchRejectedThenUnavailable(t *testing.T) { |
| h.launch(h.mustDispatch(media.ClassShort)) |
| r := h.row(a) |
| wantState(t, r, stateFailed, media.CodeEngineUnavailable, 0) |
| - if r.StartFailures != 1 || !r.CleanupDue.IsZero() { |
| + // RunTask was called, so the transfers left the console: cleaned at |
| + // the grant bound (spec §11 A8). |
| + if r.StartFailures != 1 || !r.CleanupDue.Equal(grantBound(r.DispatchedAt)) { |
| t.Fatalf("row %+v", r) |
| } |
| b := h.submit("acct1", "shop", "uploads/b.mov", video, "", 10<<20) |
| h.eng.Script(mediatest.RunRejectedRetryable, mediatest.RunRejectedRetryable) |
| - h.launch(h.mustDispatch(media.ClassShort)) |
| + l := h.mustDispatch(media.ClassShort) |
| + given := l.job.Execution |
| + h.launch(l) |
| r = h.row(b) |
| if r.State != stateQueued || r.StartFailures != 1 || !r.TaskStopped || r.Settled || r.ChargedMS != 0 || r.Execution != "" { |
| t.Fatalf("after one retryable rejection: %+v", r) |
| } |
| + if x, due := h.prior(b); x != given || due.IsZero() { |
| + t.Fatalf("the given-up execution's duty: %q at %s, want %q", x, due, given) |
| + } |
| if h.live(media.ClassShort) != 0 { |
| t.Fatal("the rejection kept its place") |
| } |
| @@ -792,9 +821,12 @@ func TestNeverStartedRetriesOnce(t *testing.T) { |
| h.track() |
| r = h.row(a) |
| wantState(t, r, stateFailed, media.CodeEngineUnavailable, 0) |
| - if r.StartFailures != 2 || !r.CleanupDue.IsZero() { |
| + if r.StartFailures != 2 || !r.CleanupDue.Equal(grantBound(r.DispatchedAt)) { |
| t.Fatalf("row %+v", r) |
| } |
| + if x, due := h.prior(a); x != first.Execution || !due.Equal(grantBound(first.DispatchedAt)) { |
| + t.Fatalf("the first execution's duty: %q at %s", x, due) |
| + } |
| } |
| func TestAmbiguousLaunchRecovers(t *testing.T) { |
| @@ -1090,6 +1122,7 @@ func TestRetiredRowNeverCommitsDone(t *testing.T) { |
| } |
| h.track() |
| wantState(t, h.row(a), stateFailed, media.CodeRetired, (4 * time.Minute).Milliseconds()) |
| + h.pastGrant(r) |
| h.cleanup() |
| prefix := media.OutputPrefix(r.Key, r.ETag, r.Preset, r.Execution) |
| for _, n := range media.OutputNames(video) { |
| @@ -1161,6 +1194,243 @@ func TestOutputSizeMismatchFails(t *testing.T) { |
| } |
| } |
| +// leakedTransfers are the transfers of r's execution as its task's |
| +// overrides carry them, which any principal allowed to describe the task |
| +// can read (spec §5.5, drills F1). |
| +func (h *harness) leakedTransfers(r Job) media.Transfers { |
| + h.t.Helper() |
| + req := h.eng.Requests(r.Execution) |
| + var p media.Payload |
| + if len(req) != 1 || json.Unmarshal(req[0].Payload, &p) != nil { |
| + h.t.Fatalf("no payload for %s", r.Execution) |
| + } |
| + return p.Transfers |
| +} |
| + |
| +// TestCleanupWaitsForTheGrant (spec §11 A8, drills F1): a row that stops |
| +// before its grant expires is cleaned at its grant bound, not when the |
| +// stop is seen. Before the bound a leaked create-only PUT succeeds over a |
| +// deleted result, as it does over a delete marker, so a cleanup then |
| +// would not be the end of it; from the bound every new request through a |
| +// transfer is refused. The fake's PUT is atomic, so this does not play a |
| +// PUT begun before the bound that completes after it, A8's stated |
| +// residual. A row seen after its bound is cleaned at once. |
| +func TestCleanupWaitsForTheGrant(t *testing.T) { |
| + for _, c := range []struct { |
| + name string |
| + exit int |
| + state string |
| + }{ |
| + {"done", media.ExitDone, stateDone}, |
| + {"failed", media.ExitFailed, stateFailed}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + h := newHarness(t, "", nil) |
| + a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| + r, task := h.run(a) |
| + tr := h.leakedTransfers(r) |
| + h.now = h.now.Add(3 * time.Minute) |
| + h.codecSucceeds(r, 60000) |
| + h.finish(task, c.exit) |
| + h.track() |
| + got := h.row(a) |
| + if got.State != c.state || !got.CleanupDue.Equal(grantBound(r.DispatchedAt)) { |
| + t.Fatalf("row %s, cleanup due %s; want %s at the grant bound %s", got.State, got.CleanupDue, c.state, grantBound(r.DispatchedAt)) |
| + } |
| + // At the observation nothing is deleted. |
| + h.cleanup() |
| + if _, ok := h.gr.Results[r.Execution]; !ok || len(h.gr.Deleted) != 0 { |
| + t.Fatalf("cleaned before the grant bound: deleted %v", h.gr.Deleted) |
| + } |
| + |
| + // Why: the result's transfer is live until the grant expires, |
| + // and a create-only PUT succeeds once the result is gone. Had |
| + // cleanup deleted it now, every version included, it would be |
| + // back. |
| + saved := h.gr.Results[r.Execution] |
| + delete(h.gr.Results, r.Execution) |
| + h.now = h.now.Add(10 * time.Minute) |
| + if err := h.gr.Put(tr.URL(tr.Result), []byte("leaked")); err != nil { |
| + t.Fatalf("a leaked result PUT inside the grant: %v, want it accepted", err) |
| + } |
| + if err := h.gr.Put(tr.URL(tr.Result), []byte("again")); !errors.Is(err, mediatest.ErrPreconditionFailed) { |
| + t.Fatalf("a second leaked result PUT: %v, want 412", err) |
| + } |
| + h.gr.Results[r.Execution] = saved |
| + |
| + h.now = grantBound(r.DispatchedAt).Add(-time.Millisecond) |
| + h.cleanup() |
| + if len(h.gr.Deleted) != 0 { |
| + t.Fatalf("cleaned before the grant bound: %v", h.gr.Deleted) |
| + } |
| + h.now = grantBound(r.DispatchedAt) |
| + h.cleanup() |
| + if !h.row(a).CleanupDue.IsZero() { |
| + t.Fatal("not cleaned at the grant bound") |
| + } |
| + if _, ok := h.gr.Results[r.Execution]; ok { |
| + t.Fatal("result kept") |
| + } |
| + // From the bound, every new request through a transfer is |
| + // refused, so none of them brings anything back. |
| + if err := h.gr.Put(tr.URL(tr.Result), []byte("leaked")); !errors.Is(err, media.ErrDenied) { |
| + t.Fatalf("a leaked result PUT at the grant bound: %v, want refused", err) |
| + } |
| + for _, o := range tr.Outputs { |
| + err := h.gr.Put(tr.URL(o), []byte("leaked")) |
| + if c.state == stateDone && !errors.Is(err, media.ErrDenied) && !errors.Is(err, mediatest.ErrPreconditionFailed) { |
| + t.Fatalf("a leaked PUT of done output %s: %v", o.Name, err) |
| + } |
| + if c.state != stateDone && !errors.Is(err, media.ErrDenied) { |
| + t.Fatalf("a leaked PUT of cleaned output %s: %v, want refused", o.Name, err) |
| + } |
| + } |
| + if _, err := h.gr.ReadResult(tctx, r.Execution); !errors.Is(err, media.ErrNotFound) { |
| + t.Fatalf("the result after cleanup: %v", err) |
| + } |
| + }) |
| + } |
| + |
| + t.Run("seen after the bound, cleaned at once", func(t *testing.T) { |
| + h := newHarness(t, "", nil) |
| + a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| + r, task := h.run(a) |
| + h.now = h.now.Add(3 * time.Minute) |
| + h.codecSucceeds(r, 60000) |
| + h.finish(task, media.ExitDone) |
| + seen := grantBound(r.DispatchedAt).Add(7 * time.Minute) |
| + h.now = seen |
| + h.track() |
| + if got := h.row(a); got.State != stateDone || !got.CleanupDue.Equal(seen) { |
| + t.Fatalf("row %s, cleanup due %s; want done at the observation %s", got.State, got.CleanupDue, seen) |
| + } |
| + h.cleanup() |
| + if _, ok := h.gr.Results[r.Execution]; ok { |
| + t.Fatal("result kept") |
| + } |
| + }) |
| +} |
| + |
| +// TestGivenUpExecutionsAreCleaned (spec §11 A8, Astra round 1 P2-3): a |
| +// task created and never started had its transfers in its overrides, so |
| +// the execution the row gives up when it goes back to queued keeps a |
| +// cleanup duty at its grant bound, whatever the row does next; and Prune |
| +// keeps a row until that duty is done. |
| +func TestGivenUpExecutionsAreCleaned(t *testing.T) { |
| + h := newHarness(t, "", nil) |
| + a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| + h.launch(h.mustDispatch(media.ClassShort)) |
| + first := h.row(a) |
| + tr := h.leakedTransfers(first) |
| + if err := h.eng.FailStart(h.task(first).ARN, h.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.track() |
| + if x, due := h.prior(a); x != first.Execution || !due.Equal(grantBound(first.DispatchedAt)) { |
| + t.Fatalf("after the start failure the duty is %q at %s", x, due) |
| + } |
| + // A leaked transfer writes while the grant is live. |
| + h.now = h.now.Add(10 * time.Minute) |
| + if err := h.gr.Put(tr.URL(tr.Result), []byte("leaked")); err != nil { |
| + t.Fatalf("a leaked result PUT: %v", err) |
| + } |
| + if err := h.gr.Put(tr.URL(tr.Outputs[0]), []byte("leaked")); err != nil { |
| + t.Fatalf("a leaked output PUT: %v", err) |
| + } |
| + // The row runs again under a new execution and ends done. |
| + second, task := h.run(a) |
| + h.now = h.now.Add(3 * time.Minute) |
| + h.codecSucceeds(second, 60000) |
| + h.finish(task, media.ExitDone) |
| + h.track() |
| + wantState(t, h.row(a), stateDone, "", (3 * time.Minute).Milliseconds()) |
| + |
| + h.now = grantBound(first.DispatchedAt).Add(-time.Millisecond) |
| + h.cleanup() |
| + if _, ok := h.gr.Results[first.Execution]; !ok { |
| + t.Fatal("the given-up execution was cleaned before its grant bound") |
| + } |
| + h.now = grantBound(first.DispatchedAt) |
| + h.cleanup() |
| + if x, due := h.prior(a); x != "" || !due.IsZero() { |
| + t.Fatalf("the duty is still %q at %s", x, due) |
| + } |
| + if _, ok := h.gr.Results[first.Execution]; ok { |
| + t.Fatal("the given-up execution's result was kept") |
| + } |
| + prefix := first.Bucket + "/" + media.OutputPrefix(first.Key, first.ETag, first.Preset, first.Execution) |
| + for _, n := range media.OutputNames(video) { |
| + if _, ok := h.gr.Objects[prefix+n]; ok { |
| + t.Fatalf("the given-up execution's %s was kept", n) |
| + } |
| + } |
| + if err := h.gr.Put(tr.URL(tr.Result), []byte("leaked")); !errors.Is(err, media.ErrDenied) { |
| + t.Fatalf("a leaked result PUT after the bound: %v, want refused", err) |
| + } |
| + // The second execution's own cleanup is its own, at its own bound. |
| + if _, ok := h.gr.Results[second.Execution]; !ok { |
| + t.Fatal("the second execution's result was deleted with the first's") |
| + } |
| +} |
| + |
| +// TestPruneKeepsAGivenUpDuty: a failed row is not pruned while the duty of |
| +// an execution it gave up is outstanding. |
| +func TestPruneKeepsAGivenUpDuty(t *testing.T) { |
| + h := newHarness(t, "", nil) |
| + a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| + for range 2 { |
| + h.launch(h.mustDispatch(media.ClassShort)) |
| + if err := h.eng.FailStart(h.task(h.row(a)).ARN, h.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.track() |
| + } |
| + r := h.row(a) |
| + wantState(t, r, stateFailed, media.CodeEngineUnavailable, 0) |
| + if x, _ := h.prior(a); x == "" || x == r.Execution { |
| + t.Fatalf("the first execution's duty is %q", x) |
| + } |
| + h.now = h.now.Add(media.FailedRetention + 2*time.Hour) |
| + // The row's own cleanup done by hand, the given-up duty left. |
| + if _, err := h.db.ExecContext(tctx, `UPDATE media_jobs SET cleanup_due = 0`); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := h.jobs.Prune(tctx, h.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.row(a) // still there |
| + h.cleanup() |
| + if err := h.jobs.Prune(tctx, h.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + var n int |
| + if err := h.db.QueryRowContext(tctx, `SELECT COUNT(*) FROM media_jobs`).Scan(&n); err != nil || n != 0 { |
| + t.Fatalf("%d rows after the duty was done, %v", n, err) |
| + } |
| +} |
| + |
| +// TestNothingSentNoDuty: a launch that never called RunTask sent no |
| +// transfer anywhere, so it leaves no cleanup duty. |
| +func TestNothingSentNoDuty(t *testing.T) { |
| + ctx, cancel := context.WithCancel(tctx) |
| + defer cancel() |
| + h := newHarness(t, "", nil) |
| + h.jobs = New(h.db, Deps{ |
| + Engine: h.eng, Grants: grantThenCancel{FakeGrants: h.gr, cancel: cancel}, Stores: h.stores, |
| + Allowance: func(_ context.Context, account string) (int64, error) { return h.allow[account], nil }, |
| + Limits: h.limits, |
| + Logf: t.Logf, |
| + }) |
| + a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| + if err := h.jobs.Launch(ctx, h.mustDispatch(media.ClassShort), h.now); err != nil { |
| + t.Fatalf("launch: %v", err) |
| + } |
| + r := h.row(a) |
| + if x, due := h.prior(a); r.State != stateQueued || x != "" || !due.IsZero() { |
| + t.Fatalf("row %s, duty %q at %s; want queued with none", r.State, x, due) |
| + } |
| +} |
| + |
| func TestCleanupSkipsDoneOutputs(t *testing.T) { |
| h := newHarness(t, "", nil) |
| a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| @@ -1174,6 +1444,7 @@ func TestCleanupSkipsDoneOutputs(t *testing.T) { |
| if done.Result == nil || done.Result.Execution != r.Execution || done.SourceMS != 60000 { |
| t.Fatalf("done row %+v", done) |
| } |
| + h.pastGrant(r) |
| h.cleanup() |
| if got := h.row(a); !got.CleanupDue.IsZero() { |
| t.Fatal("cleanup_due kept") |
| @@ -1212,10 +1483,12 @@ func TestCleanupOfSettledRows(t *testing.T) { |
| CleanupDue: h.now}) |
| h.insert(Job{Account: "acct1", App: "shop", Incarnation: s.Incarnation, ID: "later", Key: "k2", ETag: "e", Bytes: 1, Preset: video, Class: media.ClassShort, |
| Bucket: s.Bucket, State: stateFailed, ErrorCode: media.CodeEngineLost, SubmittedAt: h.now, Execution: strings.Repeat("d", 32), DispatchedAt: h.now, GrantedS: 600, DeadlineS: 900, |
| - TaskStopped: true, Settled: true, ChargedMS: 930000, EndedAt: h.now, CleanupDue: h.now.Add(time.Hour)}) |
| + TaskStopped: true, Settled: true, ChargedMS: 930000, EndedAt: h.now, CleanupDue: h.now.Add(2 * time.Hour)}) |
| h.track() |
| wantState(t, h.row(b), stateFailed, media.CodeEngineFailed, (2 * time.Minute).Milliseconds()) |
| h.gr.Deleted = nil |
| + h.pastGrant(ra) |
| + h.pastGrant(rb) |
| h.cleanup() |
| for _, j := range []Job{a, b} { |
| if r := h.row(j); !r.CleanupDue.IsZero() { |
| @@ -1463,6 +1736,7 @@ func TestOversizedResultSettles(t *testing.T) { |
| t.Fatal("capacity held") |
| } |
| delete(h.gr.ResultTooLarge, r.Execution) |
| + h.pastGrant(r) |
| h.cleanup() |
| if _, ok := h.gr.Results[r.Execution]; ok { |
| t.Fatal("result kept") |
| @@ -1556,7 +1830,7 @@ func TestSummary(t *testing.T) { |
| } |
| // TestPassRunsTheLifecycle: one Pass dispatches and launches, a later one |
| -// settles and cleans. |
| +// settles, and the first Pass at the grant bound cleans. |
| func TestPassRunsTheLifecycle(t *testing.T) { |
| h := newHarness(t, "", nil) |
| a := h.submit("acct1", "shop", "uploads/a.mov", video, "", 10<<20) |
| @@ -1579,8 +1853,15 @@ func TestPassRunsTheLifecycle(t *testing.T) { |
| } |
| got := h.row(a) |
| wantState(t, got, stateDone, "", (2 * time.Minute).Milliseconds()) |
| - if !got.CleanupDue.IsZero() { |
| - t.Fatal("not cleaned in the same pass") |
| + if !got.CleanupDue.Equal(grantBound(r.DispatchedAt)) { |
| + t.Fatalf("cleanup due %s, want the grant bound %s", got.CleanupDue, grantBound(r.DispatchedAt)) |
| + } |
| + h.pastGrant(r) |
| + if err := h.jobs.Pass(tctx, h.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !h.row(a).CleanupDue.IsZero() { |
| + t.Fatal("not cleaned in the pass at the grant bound") |
| } |
| if _, ok := h.gr.Results[r.Execution]; ok { |
| t.Fatal("result kept") |
| @@ -1590,7 +1871,7 @@ func TestPassRunsTheLifecycle(t *testing.T) { |
| // TestDelayedTrackingAcrossMonthEnd (Astra P2): a task that stopped on |
| // 30 November and is first tracked on 1 December, after a restart, is |
| // charged to November, the month ECS says it stopped in; its cleanup is |
| -// due from the observation. |
| +// due from the observation or the grant bound, whichever is later. |
| func TestDelayedTrackingAcrossMonthEnd(t *testing.T) { |
| nov, dec := time.Date(2026, 11, 1, 0, 0, 0, 0, time.UTC), time.Date(2026, 12, 1, 0, 0, 0, 0, time.UTC) |
| stop := time.Date(2026, 11, 30, 23, 57, 0, 0, time.UTC) |
| @@ -1620,8 +1901,12 @@ func TestDelayedTrackingAcrossMonthEnd(t *testing.T) { |
| h.track() |
| got := h.row(a) |
| wantState(t, got, c.state, c.code, (5 * time.Minute).Milliseconds()) |
| - if !got.EndedAt.Equal(stop) || !got.CleanupDue.Equal(seen) { |
| - t.Fatalf("ended_at %s, cleanup_due %s; want ECS's stop %s and the observation %s", got.EndedAt, got.CleanupDue, stop, seen) |
| + due := seen |
| + if b := grantBound(r.DispatchedAt); b.After(due) { |
| + due = b |
| + } |
| + if !got.EndedAt.Equal(stop) || !got.CleanupDue.Equal(due) { |
| + t.Fatalf("ended_at %s, cleanup_due %s; want ECS's stop %s and %s", got.EndedAt, got.CleanupDue, stop, due) |
| } |
| if u := h.usage("acct1", nov); u.Charged != c.charge || u.Reserved != 0 { |
| t.Fatalf("November: %+v, want %d units charged", u, c.charge) |
diff --git a/internal/mediajobs/retire.go b/internal/mediajobs/retire.go| index 99c0f6f5d..12e53dad0 100644 |
| --- a/internal/mediajobs/retire.go |
| +++ b/internal/mediajobs/retire.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "database/sql" |
| "errors" |
| + "fmt" |
| "time" |
| "github.com/carlosframework/platform/internal/media" |
| @@ -125,15 +126,74 @@ func (j *Jobs) Cleanup(ctx context.Context, now time.Time) error { |
| return err |
| })) |
| } |
| + errs = append(errs, j.cleanupPrior(ctx, ms)) |
| + return errors.Join(errs...) |
| +} |
| + |
| +// cleanupPrior carries out the due cleanup duties of executions rows gave |
| +// up when they went back to queued (neverStarted): the result object and |
| +// the three outputs, as for a row that did not end done. A duty whose |
| +// deletes fail is kept for the next pass. |
| +func (j *Jobs) cleanupPrior(ctx context.Context, ms int64) error { |
| + rs, err := j.db.QueryContext(ctx, `SELECT account, app, incarnation, job_id, bucket, key, etag, preset, prior_execution |
| + FROM media_jobs WHERE prior_cleanup_due > 0 AND prior_cleanup_due <= ? `+rowOrder, ms) |
| + if err != nil { |
| + return err |
| + } |
| + type duty struct{ account, app, incarnation, id, bucket, key, etag, preset, execution string } |
| + var duties []duty |
| + for rs.Next() { |
| + var d duty |
| + if err := rs.Scan(&d.account, &d.app, &d.incarnation, &d.id, &d.bucket, &d.key, &d.etag, &d.preset, &d.execution); err != nil { |
| + rs.Close() |
| + return err |
| + } |
| + duties = append(duties, d) |
| + } |
| + rs.Close() |
| + if err := rs.Err(); err != nil { |
| + return err |
| + } |
| + var errs []error |
| + for _, d := range duties { |
| + name := key{d.account, d.app, d.incarnation, d.id, d.execution} |
| + if d.execution == "" { |
| + errs = append(errs, fmt.Errorf("mediajobs: cleanup %s: a prior cleanup duty with no execution", name)) |
| + continue |
| + } |
| + if err := j.d.Grants.DeleteResult(ctx, d.execution); err != nil { |
| + j.logf("cleanup %s (given up): result: %v", name, err) |
| + continue |
| + } |
| + prefix := media.OutputPrefix(d.key, d.etag, d.preset, d.execution) |
| + var keys []string |
| + for _, n := range media.OutputNames(d.preset) { |
| + keys = append(keys, prefix+n) |
| + } |
| + if err := j.d.Grants.DeleteOutputs(ctx, d.bucket, keys); err != nil { |
| + j.logf("cleanup %s (given up): outputs: %v", name, err) |
| + continue |
| + } |
| + errs = append(errs, j.inTx(ctx, func(tx *sql.Tx) error { |
| + ok, err := guarded(ctx, tx, `UPDATE media_jobs SET prior_execution = '', prior_cleanup_due = 0 |
| + WHERE account = ? AND app = ? AND incarnation = ? AND job_id = ? AND prior_execution = ? |
| + AND prior_cleanup_due > 0 AND prior_cleanup_due <= ?`, d.account, d.app, d.incarnation, d.id, d.execution, ms) |
| + if err == nil && !ok { |
| + j.logf("cleanup %s (given up): dropped", name) |
| + } |
| + return err |
| + })) |
| + } |
| return errors.Join(errs...) |
| } |
| // Prune deletes settled, stopped, cleaned rows that are retired or failed, |
| -// FailedRetention after they ended. done rows of a live store are kept. |
| +// FailedRetention after they ended; cleaned includes any duty for an |
| +// execution the row gave up. done rows of a live store are kept. |
| func (j *Jobs) Prune(ctx context.Context, now time.Time) error { |
| return j.inTx(ctx, func(tx *sql.Tx) error { |
| res, err := tx.ExecContext(ctx, `DELETE FROM media_jobs |
| - WHERE settled = 1 AND task_stopped = 1 AND cleanup_due = 0 AND (retired_at > 0 OR state = 'failed') |
| + WHERE settled = 1 AND task_stopped = 1 AND cleanup_due = 0 AND prior_cleanup_due = 0 AND (retired_at > 0 OR state = 'failed') |
| AND ended_at < ?`, now.Add(-media.FailedRetention).UnixMilli()) |
| if err != nil { |
| return err |
diff --git a/internal/mediajobs/schema.go b/internal/mediajobs/schema.go| index 98885ebd5..e4479f153 100644 |
| --- a/internal/mediajobs/schema.go |
| +++ b/internal/mediajobs/schema.go |
| @@ -7,7 +7,10 @@ package mediajobs |
| // §11 A7), written in the transaction that settles a charged row; 0 on an |
| // unsettled row, on one settled with no charge, and on a row settled |
| // before the column existed, which is charged at its preset's weight |
| -// (metering.go). |
| +// (metering.go). prior_execution and prior_cleanup_due are the cleanup |
| +// duty of an execution the row gave up when it went back to queued after |
| +// its task was asked for and never started (spec §11 A8), empty and 0 |
| +// for none. They are read only by Cleanup and Prune, never by jobColumns. |
| var Schema = []string{ |
| `CREATE TABLE IF NOT EXISTS media_jobs ( |
| account TEXT NOT NULL, app TEXT NOT NULL, incarnation TEXT NOT NULL, job_id TEXT NOT NULL, |
| @@ -22,6 +25,7 @@ var Schema = []string{ |
| cleanup_due INTEGER NOT NULL DEFAULT 0, retired_at INTEGER NOT NULL DEFAULT 0, |
| ended_at INTEGER NOT NULL DEFAULT 0, |
| weight_tenths INTEGER NOT NULL DEFAULT 0, |
| + prior_execution TEXT NOT NULL DEFAULT '', prior_cleanup_due INTEGER NOT NULL DEFAULT 0, |
| PRIMARY KEY (account, app, incarnation, job_id))`, |
| `CREATE INDEX IF NOT EXISTS media_jobs_live ON media_jobs (task_stopped, state)`, |
| `CREATE INDEX IF NOT EXISTS media_jobs_by_account ON media_jobs (account, ended_at)`, |
| @@ -33,4 +37,6 @@ var Schema = []string{ |
| // it is there, which the caller ignores (the console's additive list). |
| var Migrations = []string{ |
| `ALTER TABLE media_jobs ADD COLUMN weight_tenths INTEGER NOT NULL DEFAULT 0`, |
| + `ALTER TABLE media_jobs ADD COLUMN prior_execution TEXT NOT NULL DEFAULT ''`, |
| + `ALTER TABLE media_jobs ADD COLUMN prior_cleanup_due INTEGER NOT NULL DEFAULT 0`, |
| } |
diff --git a/internal/mediajobs/track.go b/internal/mediajobs/track.go| index a4c0e8701..c5b6ac46d 100644 |
| --- a/internal/mediajobs/track.go |
| +++ b/internal/mediajobs/track.go |
| @@ -111,7 +111,8 @@ func (j *Jobs) trackOne(ctx context.Context, r Job, t media.Task, now time.Time) |
| } |
| k := keyOf(r) |
| if t.StartedAt.IsZero() { |
| - return j.neverStarted(ctx, k, true, true, now) |
| + // The task was created: its overrides held the transfers. |
| + return j.neverStarted(ctx, k, true, true, true, now) |
| } |
| ended, ok := endedAt(t, now) |
| if !ok { |
| @@ -232,20 +233,21 @@ func (j *Jobs) checkOutputs(ctx context.Context, r Job, res media.Result) (code |
| // commitDone is "stopped, success". When its guard matches nothing |
| // because the row was retired meanwhile, "stopped, failure" runs in the |
| // same transaction with retired: a retired row never commits done. |
| -// ended is endedAt's; cleanup is due at now, the observation. weight is |
| +// ended is endedAt's; cleanup is due at now, the observation, or at the |
| +// row's grant bound if that is later (cleanupDueSQL). weight is |
| // chargeWeight's, written with the charge. |
| func (j *Jobs) commitDone(ctx context.Context, k key, chargedMS, sourceMS int64, result string, weight, ended int64, now time.Time) error { |
| due := stamp(now) |
| return j.inTx(ctx, func(tx *sql.Tx) error { |
| ok, err := guarded(ctx, tx, `UPDATE media_jobs SET state = 'done', error = '', charged_ms = ?, source_ms = ?, result = ?, |
| - settled = 1, task_stopped = 1, cleanup_due = ?, ended_at = ?, weight_tenths = ? |
| - WHERE `+keyWhere+liveGuard+` AND retired_at = 0`, k.args(chargedMS, sourceMS, result, due, ended, weight)...) |
| + settled = 1, task_stopped = 1, cleanup_due = `+cleanupDueSQL+`, ended_at = ?, weight_tenths = ? |
| + WHERE `+keyWhere+liveGuard+` AND retired_at = 0`, k.args(chargedMS, sourceMS, result, due, grantBoundMS, ended, weight)...) |
| if err != nil || ok { |
| return err |
| } |
| ok, err = guarded(ctx, tx, `UPDATE media_jobs SET state = 'failed', error = ?, charged_ms = ?, source_ms = 0, result = '', |
| - settled = 1, task_stopped = 1, cleanup_due = ?, ended_at = ?, weight_tenths = ? |
| - WHERE `+keyWhere+liveGuard+` AND retired_at > 0`, k.args(media.CodeRetired, chargedMS, due, ended, weight)...) |
| + settled = 1, task_stopped = 1, cleanup_due = `+cleanupDueSQL+`, ended_at = ?, weight_tenths = ? |
| + WHERE `+keyWhere+liveGuard+` AND retired_at > 0`, k.args(media.CodeRetired, chargedMS, due, grantBoundMS, ended, weight)...) |
| if err != nil { |
| return err |
| } |
| @@ -260,14 +262,15 @@ func (j *Jobs) commitDone(ctx context.Context, k key, chargedMS, sourceMS int64, |
| // failStop is "stopped, failure": failed with code, charged ECS's |
| // runtime at weight (chargeWeight's), settled, stopped, ended at ended |
| -// (endedAt's), cleanup due now. result is the result object when the |
| -// code came from it, else "". |
| +// (endedAt's), cleanup due now or at the row's grant bound if that is |
| +// later (cleanupDueSQL). result is the result object when the code came |
| +// from it, else "". |
| func (j *Jobs) failStop(ctx context.Context, k key, code string, chargedMS int64, result string, weight, ended int64, now time.Time) error { |
| due := stamp(now) |
| return j.inTx(ctx, func(tx *sql.Tx) error { |
| ok, err := guarded(ctx, tx, `UPDATE media_jobs SET state = 'failed', error = ?, charged_ms = ?, source_ms = 0, result = ?, |
| - settled = 1, task_stopped = 1, cleanup_due = ?, ended_at = ?, weight_tenths = ? |
| - WHERE `+keyWhere+liveGuard, k.args(code, chargedMS, result, due, ended, weight)...) |
| + settled = 1, task_stopped = 1, cleanup_due = `+cleanupDueSQL+`, ended_at = ?, weight_tenths = ? |
| + WHERE `+keyWhere+liveGuard, k.args(code, chargedMS, result, due, grantBoundMS, ended, weight)...) |
| if err == nil && !ok { |
| j.logf("failed %s %s: dropped, the row is no longer live", k, code) |
| } |
| @@ -297,7 +300,7 @@ func (j *Jobs) lostAfterRetention(ctx context.Context, r Job, now time.Time) err |
| return nil |
| } |
| k := keyOf(r) |
| - cleanup := r.DispatchedAt.Add(media.GrantLifetime + media.GrantMintSlack).UnixMilli() |
| + cleanup := grantBound(r.DispatchedAt).UnixMilli() |
| return j.inTx(ctx, func(tx *sql.Tx) error { |
| ok, err := guarded(ctx, tx, `UPDATE media_jobs SET state = 'failed', error = ?, |
| charged_ms = CASE WHEN task_arn = '' THEN 0 ELSE ? END, source_ms = 0, result = '', |
diff --git a/internal/medialocal/e2e_test.go b/internal/medialocal/e2e_test.go| index 8a3cbae14..8c46f46db 100644 |
| --- a/internal/medialocal/e2e_test.go |
| +++ b/internal/medialocal/e2e_test.go |
| @@ -106,8 +106,8 @@ var e2eSeq atomic.Int64 |
| // runEndToEnd submits one video-720p job on s through mediajobs with this |
| // runner as its engine, the codec being the real carlos-media on the fake |
| // ffmpeg: the job goes to done, its three outputs are in the bucket under |
| -// its execution's prefix, the result object is deleted by the cleanup, |
| -// and the execution's scratch is gone. |
| +// its execution's prefix, the result object is deleted by the cleanup at |
| +// the grant bound, and the execution's scratch is gone. |
| func runEndToEnd(t *testing.T, s e2eStore) { |
| ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) |
| defer cancel() |
| @@ -192,6 +192,14 @@ func runEndToEnd(t *testing.T, s e2eStore) { |
| if got := s.list(t, prefix); !slices.Equal(got, want) { |
| t.Fatalf("under %s: %v, want %v", prefix, got, want) |
| } |
| + // The cleanup waits until every transfer of the execution has expired |
| + // (spec §11 A8): the first pass at that bound deletes the result. |
| + if _, err := s.grants.ReadResult(ctx, row.Execution); err != nil { |
| + t.Fatalf("the result object before the grant bound: %v", err) |
| + } |
| + if err := jobs.Pass(ctx, row.DispatchedAt.Add(media.GrantLifetime+media.GrantMintSlack)); err != nil { |
| + t.Fatalf("the cleaning pass: %v", err) |
| + } |
| if _, err := s.grants.ReadResult(ctx, row.Execution); !errors.Is(err, media.ErrNotFound) { |
| t.Fatalf("the result object after the cleanup: %v", err) |
| } |
diff --git a/internal/provision/media_results_cleanup_census_test.go b/internal/provision/media_results_cleanup_census_test.go| new file mode 100644 |
| index 000000000..d25484c59 |
| --- /dev/null |
| +++ b/internal/provision/media_results_cleanup_census_test.go |
| @@ -0,0 +1,22 @@ |
| +package provision |
| + |
| +// mediaResultsCleanupWriteCensusInventory is the record-write census for |
| +// branch media-results-cleanup (video conversion spec §11 A8), layered on |
| +// domainTransfersWriteCensusInventory (re-chained when main was merged in |
| +// on 2026-11-25; was fleetRestartWakeWriteCensusInventory). Reviewed by |
| +// the branch author against the source. One new unit, no class or site |
| +// kind changes: |
| +// |
| +// - FakeGrants.Put (internal/media/mediatest/grants.go): the in-memory |
| +// test fake's create-only PUT through a presigned transfer URL, which |
| +// tests use to play a leaked transfer. It writes the fake's own Results |
| +// and Objects maps; it reaches no store and builds no record key. |
| +func mediaResultsCleanupWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), domainTransfersWriteCensusInventory()...) |
| + for _, e := range entries { |
| + if e.File == "internal/media/mediatest/grants.go" && e.Unit == "FakeGrants.Put" { |
| + panic("media-results-cleanup census: FakeGrants.Put is already listed") |
| + } |
| + } |
| + return append(entries, censusEntry{"internal/media/mediatest/grants.go", "FakeGrants.Put", "nonrecord", "def:Put", "c9d1ef301f91185c7f0c52e7cc1dda7cb5ede4b0992a98b7489a455fdc1f11cc"}) |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index aefea718e..450b4aa55 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := domainTransfersWriteCensusInventory() |
| + inventory := mediaResultsCleanupWriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 90ce7d6d8..ccd44f8e7 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -289,3 +289,4 @@ plan14-root-reads-alias-publish-precert-1293.tsv c25a6eac6ece70098b052b6451deff6 |
| plan14-root-reads-domain-transfers.tsv c25a6eac6ece70098b052b6451deff684c29ff8cfcd24ba37625f01028dedf88 |
| plan14-root-reads-console-addr-from-install.tsv f273b5cb7bbf37b6dca4bb964a9293cbec15b14c1c0a19b9010c177f20789a86 |
| plan14-root-reads-instance-ready-before-wake.tsv aa953b1a43009c8208e44c67f5b8127ae1914b15d8b8822bcf16b19a6abdf121 |
| +plan14-root-reads-media-results-cleanup.tsv 6921575b59564ed947e30c02e314dd429016c6c11a85db9b8af50b2f31d5a5db |
diff --git a/internal/provision/testdata/plan14-root-reads-media-results-cleanup.tsv b/internal/provision/testdata/plan14-root-reads-media-results-cleanup.tsv| new file mode 100644 |
| index 000000000..f3766f8fa |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-media-results-cleanup.tsv |
| @@ -0,0 +1,15 @@ |
| +# Census overlay media-results-cleanup, written by census-propose (#369). census-ruling-media-results-cleanup, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-media-results-cleanup.md. |
| +# 3 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy 5bb338fdf3f8cce33a231065811133980046bd399f3fb9212a8eb29a3af9950b infra/modules/deployment-buckets/main.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change;rev3=census-ruling-data-lifecycle-336;basis=adds aws_s3_bucket_lifecycle_configuration "data" on the data bucket: noncurrent versions expire after var.data_noncurrent_days, expired delete markers go, multipart aborts after 7 days; no read, no IAM change;rev3=census-ruling-media-results-cleanup;basis=two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change file:external@0 1ba9fa127309d9d17900f7acb538c9ff77e7b7ca88675db61ff643147ef6a28d |
| +@legacy ec55d3c63d78859bba74f11cdd304ad9899a9e65f0398c7f9406a2deb2377173 infra/modules/media-engine/iam.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-media-conversion;basis=new: task execution role (ECR pull and the log group only); conversion role trusted only by the console role, Allow GetObject on store objects and PutObject on derived/ and media-results/, Deny GetObject on infected objects and any PutObject setting carlos-scan tags, 1 h sessions; the console role's customer-managed policy: AssumeRole on the conversion role, RunTask on this engine's task definitions in its cluster, Describe/Stop/List tasks in the cluster, DescribeTaskDefinition, PassRole of the execution role to ecs-tasks, ListBucket on the deployment bucket.;rev3=census-ruling-media-results-cleanup;basis=the console role customer-managed policy gains ListResultVersions (s3:ListBucketVersions on the deployment bucket, StringLike s3:prefix media-results/*) and DeleteResultVersions (s3:DeleteObjectVersion on <deployment bucket>/media-results/*); conversion role, execution role and every other statement unchanged; no read file:external@0 77895122f69cc48843656678049b0e606eacc669fefff85d30c4343becbdfdee |
| +@legacy 257d8c612bb5984c7de5700fe4bb8a78d8978d0420b0fd219474c65fb7ccaa02 infra/modules/media-engine/tests/media_engine.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-media-conversion;basis=new OpenTofu tests (24 runs: 9 plan and 15 apply, all against mock_provider aws, so no AWS access): task definitions pass the gate's shape, endpoint, role, console, reaper and DNS policies exact, no default route, drill states, output parses. The archive provider is real and writes the reaper's ZIP to a local path during the test.;rev3=census-ruling-media-spike-fixes;basis=assertions follow the module: capabilities must equal {add = [], drop = ["ALL"]}; deadline mountPoints and environment, and every volumesFrom, portMappings, systemControls must be empty (was: absent); new asserts that every list ECS fills in is written and that every DNS Firewall name is fully qualified; domain lists expected with trailing dots. Mock provider only, no AWS access; no read is added.;rev3=census-ruling-media-results-cleanup;basis=console_policy_exact expects the two new statements; mock provider only, no AWS access; no read is added file:external@0 ea0c744b68641b745682be8646a39d1caea6b395d995002c75b6de6e8f746ee6 |
| +@legacy 1ebb3fc78dc6f7cb9ec33c289f7285a42274d65f0b0159c54daf31acc993dee1 infra/modules/deployment-buckets/tests/media_results.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-media-results-cleanup;basis=new OpenTofu test (2 plan runs, mock_provider aws, no AWS access): asserts the two media-results/ rules and that the geoip, db-reads and data-bucket rules are unchanged; no read file:external@0 f1b8e9ae1f4f04b362f0773ddf28284e31c8b4d03f7cde5f7f62c7c586833a89 |
| +infra/modules/deployment-buckets/main.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change;rev3=census-ruling-data-lifecycle-336;basis=adds aws_s3_bucket_lifecycle_configuration "data" on the data bucket: noncurrent versions expire after var.data_noncurrent_days, expired delete markers go, multipart aborts after 7 days; no read, no IAM change;rev3=census-ruling-media-results-cleanup;basis=two lifecycle rules for media-results/ (media-results-expire: current objects after 1 day, noncurrent versions 1 day after they become noncurrent, multipart aborts after 1 day; media-results-delete-markers: expired delete markers) join the existing rules in aws_s3_bucket_lifecycle_configuration.deployment; comment only otherwise; existing rules unchanged; no read, no IAM change file:external@0 1ba9fa127309d9d17900f7acb538c9ff77e7b7ca88675db61ff643147ef6a28d |
| +infra/modules/media-engine/iam.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-media-conversion;basis=new: task execution role (ECR pull and the log group only); conversion role trusted only by the console role, Allow GetObject on store objects and PutObject on derived/ and media-results/, Deny GetObject on infected objects and any PutObject setting carlos-scan tags, 1 h sessions; the console role's customer-managed policy: AssumeRole on the conversion role, RunTask on this engine's task definitions in its cluster, Describe/Stop/List tasks in the cluster, DescribeTaskDefinition, PassRole of the execution role to ecs-tasks, ListBucket on the deployment bucket.;rev3=census-ruling-media-results-cleanup;basis=the console role customer-managed policy gains ListResultVersions (s3:ListBucketVersions on the deployment bucket, StringLike s3:prefix media-results/*) and DeleteResultVersions (s3:DeleteObjectVersion on <deployment bucket>/media-results/*); conversion role, execution role and every other statement unchanged; no read file:external@0 77895122f69cc48843656678049b0e606eacc669fefff85d30c4343becbdfdee |
| +infra/modules/media-engine/tests/media_engine.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-media-conversion;basis=new OpenTofu tests (24 runs: 9 plan and 15 apply, all against mock_provider aws, so no AWS access): task definitions pass the gate's shape, endpoint, role, console, reaper and DNS policies exact, no default route, drill states, output parses. The archive provider is real and writes the reaper's ZIP to a local path during the test.;rev3=census-ruling-media-spike-fixes;basis=assertions follow the module: capabilities must equal {add = [], drop = ["ALL"]}; deadline mountPoints and environment, and every volumesFrom, portMappings, systemControls must be empty (was: absent); new asserts that every list ECS fills in is written and that every DNS Firewall name is fully qualified; domain lists expected with trailing dots. Mock provider only, no AWS access; no read is added.;rev3=census-ruling-media-results-cleanup;basis=console_policy_exact expects the two new statements; mock provider only, no AWS access; no read is added file:external@0 ea0c744b68641b745682be8646a39d1caea6b395d995002c75b6de6e8f746ee6 |
| +infra/modules/deployment-buckets/tests/media_results.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-media-results-cleanup;basis=new OpenTofu test (2 plan runs, mock_provider aws, no AWS access): asserts the two media-results/ rules and that the geoip, db-reads and data-bucket rules are unchanged; no read file:external@0 f1b8e9ae1f4f04b362f0773ddf28284e31c8b4d03f7cde5f7f62c7c586833a89 |
| +@coverage infra/modules/deployment-buckets 6cbf34efe196a9e47feae78e94bd36968f57a40e11b1719cdefbb493d417b36b |
| +@coverage infra/modules/deployment-buckets/tests 28adb3f47aa32b5266825a2372acb9f90200e00c1401bd02a9b579db4596022c |
| +@coverage infra/modules/media-engine 2343511421fc0a4c27d7db1725f32bf7cb8bc02f55e239e7c7a725ea2543950d |
| +@coverage infra/modules/media-engine/tests 8c5507eeb9d15191608944fc455ac0bca7888b43d299d3d1ff30789af83ad93a |
diff --git a/internal/sim/mediajobs/actions_test.go b/internal/sim/mediajobs/actions_test.go| index 752bd91a3..841929997 100644 |
| --- a/internal/sim/mediajobs/actions_test.go |
| +++ b/internal/sim/mediajobs/actions_test.go |
| @@ -59,6 +59,9 @@ var actions = []action{ |
| {"recover-early", 3, actRecoverEarly}, |
| {"recover-at-bound", 2, actRecoverAtBound}, |
| {"cleanup", 4, actCleanup}, |
| + // Beyond the plan's list (spec §11 A8, drills F1): a transfer read |
| + // from a stopped task's overrides is used after its job settled. |
| + {"leaked-put", 3, actLeakedPut}, |
| {"prune", 2, actPrune}, |
| {"purge", 1, actPurge}, |
| {"destroy", 1, actDestroy}, |
| @@ -641,6 +644,57 @@ func actCleanup(w *world) bool { |
| return err == nil |
| } |
| +// actLeakedPut sends a create-only PUT, through a transfer of an execution |
| +// that was sent to RunTask and that no row still runs (a settled row's, or |
| +// one a row gave up when it went back to queued), of its result object or |
| +// one of its outputs: what anyone allowed to describe the stopped task, or |
| +// to read the audit trail, can do until the grant expires (drills F1). The deployment bucket is versioned and a |
| +// create-only PUT succeeds over a delete marker, which the fake grants |
| +// model as a deleted object being absent. R1 then holds that nothing the |
| +// job table's cleanup deleted ever comes back. |
| +func actLeakedPut(w *world) bool { |
| + // The candidates are kept by the grant log, not by the rows, so an |
| + // execution stays one after its cleanup has cleared every trace of it |
| + // from its row (Astra round 2, P2-1). |
| + rows := w.readRows() |
| + var sent []int // indexes into grantLog |
| + for i, g := range w.grantLog { |
| + if len(w.engine.Requests(g.Execution)) == 0 { |
| + continue |
| + } |
| + live := false |
| + for _, r := range rows { |
| + if r.Execution == g.Execution && !(r.Settled && r.TaskStopped) { |
| + live = true |
| + } |
| + } |
| + if !live { |
| + sent = append(sent, i) |
| + } |
| + } |
| + if len(sent) == 0 { |
| + return false |
| + } |
| + i := sent[w.rng.Intn(len(sent))] |
| + tr := w.transfers[w.grantLog[i].Execution] |
| + target, what := tr.Result, "result" |
| + if n := w.rng.Intn(len(tr.Outputs) + 1); n < len(tr.Outputs) { |
| + target, what = tr.Outputs[n], "output "+tr.Outputs[n].Name |
| + } |
| + err := w.grants.Put(tr.URL(target), []byte("leaked")) |
| + w.logf("leaked put of grant %d's %s: %v", i, what, err) |
| + switch { |
| + case err == nil: |
| + w.events["leaked-put-accepted"]++ |
| + case errors.Is(err, media.ErrDenied): |
| + w.events["leaked-put-expired"]++ |
| + case errors.Is(err, mediatest.ErrPreconditionFailed): |
| + default: |
| + w.fail("MODEL", "leaked put: %v", err) |
| + } |
| + return true |
| +} |
| + |
| func actPrune(w *world) bool { |
| err := w.checkPrune(func() error { return w.jobs.Prune(ctx, w.now) }) |
| w.logf("prune: %v", err) |
diff --git a/internal/sim/mediajobs/invariants_test.go b/internal/sim/mediajobs/invariants_test.go| index 5b00fd4f3..3bf080a2c 100644 |
| --- a/internal/sim/mediajobs/invariants_test.go |
| +++ b/internal/sim/mediajobs/invariants_test.go |
| @@ -4,6 +4,7 @@ import ( |
| "encoding/json" |
| "fmt" |
| "math" |
| + "strings" |
| "time" |
| "github.com/carlosframework/platform/internal/media" |
| @@ -75,6 +76,19 @@ import ( |
| // rejected), or it settles engine_lost past its bound; it goes back to |
| // queued only on the first two. Each execution is Run at most once. |
| // |
| +// - R1. Results never outlive their job (spec §5.3, §5.4, §11 A8; drills |
| +// F1). A result object or output the job table's cleanup deleted is |
| +// never there again, whatever a leaked transfer of its execution |
| +// sends afterwards (the leaked-put action). The fake's PUT is atomic, |
| +// checked for expiry and completed at once, so R1 covers requests |
| +// begun after cleanup; one begun before the grant bound and completing |
| +// after it is A8's stated residual, which this model cannot play. |
| +// - R2. Every sent execution keeps a cleanup duty (§11 A8; Astra round 1 |
| +// P2-3). An execution whose RunTask was called, rejected or not, and |
| +// that no row still runs, is either cleaned (its result deleted by the |
| +// job table's cleanup) or holds a duty: cleanup_due on the row that |
| +// holds it, or prior_cleanup_due on the row that gave it up. |
| +// |
| // Two progress checks run around each cleanup and prune action, since a |
| // nil error is not proof of work (a Cleanup whose UPDATE matched nothing |
| // passed every invariant above): |
| @@ -106,11 +120,14 @@ type row struct { |
| Result, Error string |
| CleanupDue, RetiredAt, EndedAt int64 |
| WeightTenths int64 |
| + PriorExecution string |
| + PriorCleanupDue int64 |
| } |
| const rowColumns = `account, app, incarnation, job_id, key, etag, bytes, preset, class, bucket, state, submitted_at, |
| execution_id, task_arn, dispatched_at, granted_s, deadline_s, task_stopped, start_failures, charged_ms, |
| - settled, source_ms, result, error, cleanup_due, retired_at, ended_at, weight_tenths` |
| + settled, source_ms, result, error, cleanup_due, retired_at, ended_at, weight_tenths, |
| + prior_execution, prior_cleanup_due` |
| func (r row) id() string { |
| return r.Account + "/" + r.App + "/" + r.Incarnation + "/" + r.JobID |
| @@ -133,7 +150,8 @@ func (w *world) readRows() []row { |
| var r row |
| if err := rs.Scan(&r.Account, &r.App, &r.Incarnation, &r.JobID, &r.Key, &r.ETag, &r.Bytes, &r.Preset, &r.Class, &r.Bucket, &r.State, &r.SubmittedAt, |
| &r.Execution, &r.TaskARN, &r.DispatchedAt, &r.GrantedS, &r.DeadlineS, &r.TaskStopped, &r.StartFailures, &r.ChargedMS, |
| - &r.Settled, &r.SourceMS, &r.Result, &r.Error, &r.CleanupDue, &r.RetiredAt, &r.EndedAt, &r.WeightTenths); err != nil { |
| + &r.Settled, &r.SourceMS, &r.Result, &r.Error, &r.CleanupDue, &r.RetiredAt, &r.EndedAt, &r.WeightTenths, |
| + &r.PriorExecution, &r.PriorCleanupDue); err != nil { |
| w.fail("MODEL", "scan row: %v", err) |
| return nil |
| } |
| @@ -147,10 +165,11 @@ func (w *world) readRows() []row { |
| // insertRow writes a row directly (the checker's witnesses and fixtures). |
| func (w *world) insertRow(r row) { |
| - _, err := w.db.Exec(`INSERT INTO media_jobs (`+rowColumns+`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, |
| + _, err := w.db.Exec(`INSERT INTO media_jobs (`+rowColumns+`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, |
| r.Account, r.App, r.Incarnation, r.JobID, r.Key, r.ETag, r.Bytes, r.Preset, r.Class, r.Bucket, r.State, r.SubmittedAt, |
| r.Execution, r.TaskARN, r.DispatchedAt, r.GrantedS, r.DeadlineS, r.TaskStopped, r.StartFailures, r.ChargedMS, |
| - r.Settled, r.SourceMS, r.Result, r.Error, r.CleanupDue, r.RetiredAt, r.EndedAt, r.WeightTenths) |
| + r.Settled, r.SourceMS, r.Result, r.Error, r.CleanupDue, r.RetiredAt, r.EndedAt, r.WeightTenths, |
| + r.PriorExecution, r.PriorCleanupDue) |
| if err != nil { |
| panic(fmt.Sprintf("insert row: %v", err)) |
| } |
| @@ -408,8 +427,8 @@ func check(w *world) { |
| if _, ok := cur[id]; ok { |
| continue |
| } |
| - if !p.Settled || p.CleanupDue != 0 || !p.TaskStopped { |
| - w.fail("I4", "row %s was deleted while settled %v, cleanup_due %d, task_stopped %v", shortID(p.JobID), p.Settled, p.CleanupDue, p.TaskStopped) |
| + if !p.Settled || p.CleanupDue != 0 || p.PriorCleanupDue != 0 || !p.TaskStopped { |
| + w.fail("I4", "row %s was deleted while settled %v, cleanup_due %d, prior_cleanup_due %d, task_stopped %v", shortID(p.JobID), p.Settled, p.CleanupDue, p.PriorCleanupDue, p.TaskStopped) |
| } |
| } |
| @@ -550,10 +569,54 @@ func check(w *world) { |
| } |
| } |
| + checkCleanupDuties(w, rows) |
| + |
| w.prev = cur |
| w.readNow = map[string]bool{} |
| } |
| +// checkCleanupDuties checks R2 and R1 (spec §11 A8). |
| +func checkCleanupDuties(w *world, rows []row) { |
| + // R2, in the order of the grant log: execution ids are random, so a |
| + // violation names the row, or the grant's place in the log. |
| + for i, g := range w.grantLog { |
| + x := g.Execution |
| + if len(w.engine.Requests(x)) == 0 || w.cleanedResults[x] { |
| + continue |
| + } |
| + held, duty, name := false, false, fmt.Sprintf("grant %d", i) |
| + for _, r := range rows { |
| + switch { |
| + case r.Execution == x: |
| + held, name = true, "row "+shortID(r.JobID) |
| + duty = !r.TaskStopped || r.CleanupDue > 0 |
| + case r.PriorExecution == x: |
| + held, name = true, "row "+shortID(r.JobID) |
| + duty = r.PriorCleanupDue > 0 |
| + } |
| + } |
| + if !held || !duty { |
| + w.fail("R2", "%s's execution was sent to RunTask and has no cleanup duty", name) |
| + } |
| + } |
| + |
| + // R1. Execution ids are random, so a violation names the row. |
| + // The objects are the grant's, recorded when it was minted, so the |
| + // check holds after a cleanup or a prune has removed every trace of |
| + // the execution from the rows. |
| + for i, g := range w.grantLog { |
| + x := g.Execution |
| + if _, ok := w.grants.Results[x]; ok && w.cleanedResults[x] { |
| + w.fail("R1", "grant %d's result object is back after its cleanup deleted it", i) |
| + } |
| + for _, k := range w.outputsOf[x] { |
| + if _, ok := w.grants.Objects[k]; ok && w.cleanedOutputs[k] { |
| + w.fail("R1", "grant %d's output %s is back after its cleanup deleted it", i, k[strings.LastIndex(k, "/")+1:]) |
| + } |
| + } |
| + } |
| +} |
| + |
| // cleanupDue reports whether a row's cleanup is due at now (P1). |
| func cleanupDue(r row, now time.Time) bool { |
| return r.CleanupDue > 0 && r.CleanupDue <= now.UnixMilli() && r.TaskStopped |
| @@ -562,7 +625,7 @@ func cleanupDue(r row, now time.Time) bool { |
| // pruneDue reports whether Prune may delete a row at now (P2), from the |
| // spec's rule, not the job table's query. |
| func pruneDue(r row, now time.Time) bool { |
| - return r.Settled && r.TaskStopped && r.CleanupDue == 0 && (r.RetiredAt > 0 || r.State == "failed") && |
| + return r.Settled && r.TaskStopped && r.CleanupDue == 0 && r.PriorCleanupDue == 0 && (r.RetiredAt > 0 || r.State == "failed") && |
| r.EndedAt < now.Add(-media.FailedRetention).UnixMilli() |
| } |
| @@ -606,6 +669,24 @@ func (w *world) checkCleanup(cleanup func() error) error { |
| } |
| } |
| } |
| + // A given-up execution's duty, due before, is done after. |
| + for _, b := range before { |
| + if b.PriorCleanupDue == 0 || b.PriorCleanupDue > w.now.UnixMilli() { |
| + continue |
| + } |
| + if a, ok := after[b.id()]; ok && (a.PriorCleanupDue != 0 || a.PriorExecution != "") { |
| + w.fail("P1", "row %s's given-up execution is still due after Cleanup", shortID(b.JobID)) |
| + } |
| + if _, ok := w.grants.Results[b.PriorExecution]; ok { |
| + w.fail("P1", "row %s's given-up execution's result survived its cleanup", shortID(b.JobID)) |
| + } |
| + prefix := b.Bucket + "/" + media.OutputPrefix(b.Key, b.ETag, b.Preset, b.PriorExecution) |
| + for _, n := range media.OutputNames(b.Preset) { |
| + if _, ok := w.grants.Objects[prefix+n]; ok { |
| + w.fail("P1", "row %s's given-up execution's output %s survived its cleanup", shortID(b.JobID), n) |
| + } |
| + } |
| + } |
| return nil |
| } |
diff --git a/internal/sim/mediajobs/sim_test.go b/internal/sim/mediajobs/sim_test.go| index 7e1ac9098..cef50fc1b 100644 |
| --- a/internal/sim/mediajobs/sim_test.go |
| +++ b/internal/sim/mediajobs/sim_test.go |
| @@ -64,6 +64,8 @@ var eventFloors = map[string]int{ |
| "recreated": 100, |
| "charged-above-1080p": 1, |
| "above-1080p-on-short": 2, |
| + "leaked-put-accepted": 12, |
| + "leaked-put-expired": 150, |
| } |
| // checkFloors fails the sweep of n seeds when a claimed event fell short |
diff --git a/internal/sim/mediajobs/witness_test.go b/internal/sim/mediajobs/witness_test.go| index 2ce5c78c4..142d0279b 100644 |
| --- a/internal/sim/mediajobs/witness_test.go |
| +++ b/internal/sim/mediajobs/witness_test.go |
| @@ -1086,3 +1086,66 @@ func TestProgressChecksCatchNoOps(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// TestWitnessGivenUpExecutionCleanedOnce (spec §11 A8; Astra round 2, |
| +// P2-1): a task that never starts sends its row back to queued with its |
| +// execution's cleanup duty in prior_execution. Cleaned at its grant bound, |
| +// a leaked PUT through its transfers is refused and R1 holds. A cleanup |
| +// run early, before the transfers expire, clears every trace of the |
| +// execution from the row, and a leaked PUT then recreates its objects: R1 |
| +// must still see them, from the grant alone. |
| +func TestWitnessGivenUpExecutionCleanedOnce(t *testing.T) { |
| + for _, early := range []bool{false, true} { |
| + name := "at the grant bound" |
| + if early { |
| + name = "too early" |
| + } |
| + t.Run(name, func(t *testing.T) { |
| + w := newWitness(t, "", nil) |
| + w.object(shop, "uploads/clip.mov", 10<<20) |
| + job := w.submit(t, shop, "uploads/clip.mov", video, "") |
| + w.launch(t, w.mustDispatch(t, job.Class)) |
| + first := w.rowOf(t, shop, job.ID) |
| + x := first.Execution |
| + if err := w.engine.FailStart(w.taskOf(t, x).ARN, w.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.track(t) |
| + r := w.rowOf(t, shop, job.ID) |
| + if r.State != "queued" || r.PriorExecution != x || r.PriorCleanupDue == 0 { |
| + t.Fatalf("after the start failure: %s, prior %q due %d", r.State, shortID(r.PriorExecution), r.PriorCleanupDue) |
| + } |
| + if early { |
| + // A cleanup that does not wait for the grant. |
| + w.exec(t, `UPDATE media_jobs SET prior_cleanup_due = ? WHERE job_id = ?`, w.now.UnixMilli(), job.ID) |
| + } else { |
| + w.now = time.UnixMilli(r.PriorCleanupDue) |
| + } |
| + if err := w.jobs.Cleanup(ctx, w.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if r := w.rowOf(t, shop, job.ID); r.PriorExecution != "" || r.PriorCleanupDue != 0 { |
| + t.Fatalf("the duty is still %q due %d", shortID(r.PriorExecution), r.PriorCleanupDue) |
| + } |
| + tr := w.transfers[x] |
| + errResult := w.grants.Put(tr.URL(tr.Result), []byte("leaked")) |
| + errOutput := w.grants.Put(tr.URL(tr.Outputs[0]), []byte("leaked")) |
| + check(w) |
| + if !early { |
| + if !errors.Is(errResult, media.ErrDenied) || !errors.Is(errOutput, media.ErrDenied) { |
| + t.Fatalf("leaked PUTs after the bound: %v, %v; want refused", errResult, errOutput) |
| + } |
| + if len(w.violations) != 0 { |
| + t.Fatalf("violations %v, want none", w.violations) |
| + } |
| + return |
| + } |
| + if errResult != nil || errOutput != nil { |
| + t.Fatalf("leaked PUTs inside the grant: %v, %v; want accepted", errResult, errOutput) |
| + } |
| + if len(w.violations) != 1 || invariantOf(w.violations[0]) != "R1" { |
| + t.Fatalf("violations %v, want exactly R1", w.violations) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/sim/mediajobs/world_test.go b/internal/sim/mediajobs/world_test.go| index befcd02c6..f98d7741a 100644 |
| --- a/internal/sim/mediajobs/world_test.go |
| +++ b/internal/sim/mediajobs/world_test.go |
| @@ -197,6 +197,12 @@ func (g *recGrants) Grant(c context.Context, r media.GrantRequest) (media.Transf |
| tr, exp, err := g.FakeGrants.Grant(c, r) |
| if err == nil { |
| g.w.grantLog = append(g.w.grantLog, grantRecord{Execution: r.Execution, At: g.w.now}) |
| + g.w.transfers[r.Execution] = tr |
| + var keys []string |
| + for _, o := range r.Outputs { |
| + keys = append(keys, r.Bucket+"/"+r.OutputPrefix+o.Name) |
| + } |
| + g.w.outputsOf[r.Execution] = keys |
| } |
| if cancel := g.w.cancelAfterGrant; cancel != nil { |
| g.w.cancelAfterGrant = nil |
| @@ -227,6 +233,27 @@ func (g *recGrants) ReadResult(c context.Context, execution string) ([]byte, err |
| return b, err |
| } |
| +// DeleteResult notes each result object the job table's cleanup deleted |
| +// (R1). |
| +func (g *recGrants) DeleteResult(c context.Context, execution string) error { |
| + err := g.FakeGrants.DeleteResult(c, execution) |
| + if err == nil { |
| + g.w.cleanedResults[execution] = true |
| + } |
| + return err |
| +} |
| + |
| +// DeleteOutputs notes each output the job table's cleanup deleted (R1). |
| +func (g *recGrants) DeleteOutputs(c context.Context, bucket string, keys []string) error { |
| + err := g.FakeGrants.DeleteOutputs(c, bucket, keys) |
| + if err == nil { |
| + for _, k := range keys { |
| + g.w.cleanedOutputs[bucket+"/"+k] = true |
| + } |
| + } |
| + return err |
| +} |
| + |
| // destroyEvent is a store destroy (or app purge) the world carried out: |
| // Live is the store's rows with task_stopped 0 at that moment. |
| type destroyEvent struct { |
| @@ -258,15 +285,22 @@ type world struct { |
| keys map[appRef][]string |
| purging map[appRef]bool |
| - runs []runRecord |
| - grantLog []grantRecord |
| - recGrants *recGrants |
| - mayExist map[string]bool // executions with a Run not definitively rejected: a task may exist, or appear later |
| - observed map[string]bool // executions whose task the job table was shown: an ARN from Run, or ListByStartedBy found it |
| - reported map[string]bool // executions whose codec wrote a result that parses, with source facts |
| - hi map[string]bool // of those, the ones whose facts are above 1080p (spec §11 A7) |
| - readNow map[string]bool // executions whose result the job table read since the last check |
| - readAtEnd map[string]bool // executions whose row settled in a check step whose reads included its result |
| + runs []runRecord |
| + grantLog []grantRecord |
| + // transfers are each granted execution's transfers, as its task's |
| + // overrides carry them: anyone who may describe the task can read |
| + // them, so the leaked-put action uses them (drills F1). |
| + transfers map[string]media.Transfers |
| + outputsOf map[string][]string // each granted execution's outputs, "bucket/key", kept whatever becomes of its row |
| + cleanedResults map[string]bool // executions whose result object the job table's cleanup deleted |
| + cleanedOutputs map[string]bool // "bucket/key" of each output the job table's cleanup deleted |
| + recGrants *recGrants |
| + mayExist map[string]bool // executions with a Run not definitively rejected: a task may exist, or appear later |
| + observed map[string]bool // executions whose task the job table was shown: an ARN from Run, or ListByStartedBy found it |
| + reported map[string]bool // executions whose codec wrote a result that parses, with source facts |
| + hi map[string]bool // of those, the ones whose facts are above 1080p (spec §11 A7) |
| + readNow map[string]bool // executions whose result the job table read since the last check |
| + readAtEnd map[string]bool // executions whose row settled in a check step whose reads included its result |
| retireOnRead string // recGrants retires this execution's app once its result has been read (a teardown racing the settlement) |
| ecs map[string]media.Task // the last record ECS showed for each execution, kept after it expires |
| @@ -299,6 +333,7 @@ func buildWorld(seed int64, rng *rand.Rand, verbose bool, limits media.Limits, a |
| mayExist: map[string]bool{}, observed: map[string]bool{}, reported: map[string]bool{}, hi: map[string]bool{}, |
| readNow: map[string]bool{}, readAtEnd: map[string]bool{}, |
| ecs: map[string]media.Task{}, prev: map[string]row{}, |
| + transfers: map[string]media.Transfers{}, outputsOf: map[string][]string{}, cleanedResults: map[string]bool{}, cleanedOutputs: map[string]bool{}, |
| stats: map[string]int{}, done: map[string]int{}, events: map[string]int{}, |
| } |
| db, err := sql.Open("sqlite", fmt.Sprintf("file:mediasim%d?mode=memory&cache=shared", seed)) |