carlos / platform Public

Merge origin/main into path-routes-across-boxes

One conflict: internal/provision/testdata/plan14-root-reads-chain.tsv.
Main appended the media-spike-values overlay; this branch appended
path-routes-across-boxes. Resolved with main's line first and this
branch's line last, its seal unchanged here; the census refresh on top
of main's chain follows in the next commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 735d90512c02faf9d505db9b66e5e8d51b5bd82e parent b7b2116parent 2b5b5b7
45 files changed, +1,352 −175
  • docs/site/media-conversion.md +7 −4
  • docs/site/plans.md +1 −1
  • docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6.md +30 −0
  • docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md +21 −0
  • docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6.md +11 −0
  • docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6b.md +7 −0
  • docs/superpowers/notes/census-claims-media-spike-values.tsv +0 −0
  • docs/superpowers/notes/census-proposal-media-spike-values.md +11 −0
  • docs/superpowers/notes/media-conversion-copy-deck.md +32 −6
  • docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md +6 −4
  • docs/superpowers/plans/2026-11-16-media-conversion-plan-3-engine.md +7 −3
  • docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md +21 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-spike-values.md +58 −0
  • docs/superpowers/specs/2026-11-16-video-conversion-design.md +81 −4
  • internal/console/apimedia_test.go +38 −0
  • internal/console/media_copy.go +25 −4
  • internal/console/mediawire.go +1 −1
  • internal/console/planmedia_test.go +31 −0
  • internal/console/store.go +3 −3
  • internal/media/limits.go +32 −14
  • internal/media/media.go +50 −15
  • internal/media/media_test.go +88 −19
  • internal/media/payload.go +18 −6
  • internal/media/result.go +3 −1
  • internal/mediahandler/ffmpeg.go +6 −3
  • internal/mediahandler/ffmpeg_test.go +1 −1
  • internal/mediahandler/fmp4_test.go +24 −1
  • internal/mediahandler/probe.go +17 −7
  • internal/mediahandler/probe_test.go +87 −1
  • internal/mediahandler/run.go +3 −3
  • internal/mediahandler/testdata/fmp4/provenance.txt +9 −0
  • internal/mediajobs/dispatch.go +11 −3
  • internal/mediajobs/jobs.go +3 −3
  • internal/mediajobs/jobs_test.go +188 −11
  • internal/mediajobs/metering.go +32 −10
  • internal/mediajobs/schema.go +14 −1
  • internal/mediajobs/track.go +39 −18
  • internal/plans/catalog.go +1 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-media-spike-values.tsv +3 −0
  • internal/sim/mediajobs/actions_test.go +10 −3
  • internal/sim/mediajobs/invariants_test.go +109 −13
  • internal/sim/mediajobs/sim_test.go +2 −0
  • internal/sim/mediajobs/witness_test.go +120 −0
  • internal/sim/mediajobs/world_test.go +90 −11

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-8xcESF
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/aws-sdk-go-v2/service/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/benbjohnson/litestream v0.5.14
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
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/config v1.32.6
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 golang.org/x/sys v0.49.0
go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1
go: downloading github.com/aws/aws-sdk-go-v2/credentials v1.19.6
go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.45.6
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/oschwald/maxminddb-golang v1.13.1
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/pion/randutil v0.1.0
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/aws/aws-sdk-go-v2/service/signin v1.0.4
go: downloading github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.40
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.23
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.31
go: downloading github.com/klauspost/compress v1.20.2
go: downloading golang.org/x/text v0.43.0
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0
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 google.golang.org/protobuf v1.36.10
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/google/uuid v1.6.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
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 (160 s, from +0 s)
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading google.golang.org/protobuf v1.36.10
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/mathutil v1.7.1
=== vet-tags (182 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/pierrec/lz4/v4 v4.1.22
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
=== gofmt (1 s, from +0 s)
gofmt -l .: clean
=== rest (376 s, from +15 s)
ok  	github.com/carlosframework/platform/cmd/carlos-media	120.760s
?   	github.com/carlosframework/platform/cmd/changelog	[no test files]
ok  	github.com/carlosframework/platform/cmd/console	198.384s
ok  	github.com/carlosframework/platform/cmd/mediaimage	41.243s
ok  	github.com/carlosframework/platform/cmd/moveprobe	14.554s
ok  	github.com/carlosframework/platform/cmd/pricebook-export	0.037s
ok  	github.com/carlosframework/platform/cmd/rootfswitness	0.167s
ok  	github.com/carlosframework/platform/cmd/runsc-assets	0.116s
ok  	github.com/carlosframework/platform/cmd/zddprobe	0.932s
ok  	github.com/carlosframework/platform/internal/agentsock	0.042s
ok  	github.com/carlosframework/platform/internal/alerting	0.020s
ok  	github.com/carlosframework/platform/internal/analytics	0.378s
ok  	github.com/carlosframework/platform/internal/appconfig	42.033s
ok  	github.com/carlosframework/platform/internal/apperr	0.241s
ok  	github.com/carlosframework/platform/internal/applog	0.559s
ok  	github.com/carlosframework/platform/internal/apppolicy	2.090s
ok  	github.com/carlosframework/platform/internal/assetcache	0.471s
ok  	github.com/carlosframework/platform/internal/awsinv	0.010s
ok  	github.com/carlosframework/platform/internal/awsmanaged	0.577s
ok  	github.com/carlosframework/platform/internal/awsregiongroup	0.331s
ok  	github.com/carlosframework/platform/internal/awsterminations	0.025s
ok  	github.com/carlosframework/platform/internal/backupswords	0.017s
ok  	github.com/carlosframework/platform/internal/billing	0.095s
ok  	github.com/carlosframework/platform/internal/billing/billingtest	0.032s
ok  	github.com/carlosframework/platform/internal/billingstripe	1.871s
ok  	github.com/carlosframework/platform/internal/boxchoice	0.023s
ok  	github.com/carlosframework/platform/internal/boxid	3.058s
?   	github.com/carlosframework/platform/internal/boxid/boxidtest	[no test files]
?   	github.com/carlosframework/platform/internal/boxid/internal/signtest	[no test files]
ok  	github.com/carlosframework/platform/internal/boxroles	0.017s
ok  	github.com/carlosframework/platform/internal/boxself	0.129s
ok  	github.com/carlosframework/platform/internal/boxvolumes	0.031s
ok  	github.com/carlosframework/platform/internal/caps	0.073s
ok  	github.com/carlosframework/platform/internal/certwarm	0.022s
ok  	github.com/carlosframework/platform/internal/cgroup	1.430s
ok  	github.com/carlosframework/platform/internal/changelog	4.053s
ok  	github.com/carlosframework/platform/internal/clamd	0.063s
?   	github.com/carlosframework/platform/internal/cliflag	[no test files]
ok  	github.com/carlosframework/platform/internal/clireg	0.013s
ok  	github.com/carlosframework/platform/internal/codehealth	16.370s
ok  	github.com/carlosframework/platform/internal/compute	0.030s
?   	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	9.984s
ok  	github.com/carlosframework/platform/internal/dbdoor/dbdoortest	0.035s
ok  	github.com/carlosframework/platform/internal/dbquery	0.018s
ok  	github.com/carlosframework/platform/internal/dbreads	3.203s
?   	github.com/carlosframework/platform/internal/dbreads/dbreadstest	[no test files]
ok  	github.com/carlosframework/platform/internal/dbverify	0.025s
ok  	github.com/carlosframework/platform/internal/demo	0.010s
ok  	github.com/carlosframework/platform/internal/demobuild	2.917s
ok  	github.com/carlosframework/platform/internal/democlaim	0.400s
ok  	github.com/carlosframework/platform/internal/devbox	16.269s
ok  	github.com/carlosframework/platform/internal/dnsrec	0.006s
ok  	github.com/carlosframework/platform/internal/docsite	0.068s
ok  	github.com/carlosframework/platform/internal/domainreg	0.010s
ok  	github.com/carlosframework/platform/internal/domains	65.719s
ok  	github.com/carlosframework/platform/internal/doorkey	0.012s
ok  	github.com/carlosframework/platform/internal/economics	0.006s
ok  	github.com/carlosframework/platform/internal/edgefence	0.091s
ok  	github.com/carlosframework/platform/internal/edgeguard	0.250s
?   	github.com/carlosframework/platform/internal/edgeproof	[no test files]
ok  	github.com/carlosframework/platform/internal/edgesfile	0.062s
ok  	github.com/carlosframework/platform/internal/egressaddr	0.004s
ok  	github.com/carlosframework/platform/internal/execsandbox	97.048s
ok  	github.com/carlosframework/platform/internal/fileacl	0.007s
ok  	github.com/carlosframework/platform/internal/fleetapi	1.833s
ok  	github.com/carlosframework/platform/internal/fleetstore	0.015s
ok  	github.com/carlosframework/platform/internal/fxrate	0.034s
ok  	github.com/carlosframework/platform/internal/gate	4.051s
ok  	github.com/carlosframework/platform/internal/genselect	0.067s
ok  	github.com/carlosframework/platform/internal/geo	0.045s
ok  	github.com/carlosframework/platform/internal/geoip	0.065s
ok  	github.com/carlosframework/platform/internal/groupadmission	0.012s
ok  	github.com/carlosframework/platform/internal/grouprollaws	17.792s
ok  	github.com/carlosframework/platform/internal/hadeparture	0.018s
ok  	github.com/carlosframework/platform/internal/hafresh	0.012s
ok  	github.com/carlosframework/platform/internal/hairpin	0.207s
ok  	github.com/carlosframework/platform/internal/historyreadback	1.149s
ok  	github.com/carlosframework/platform/internal/hostactors	23.502s
ok  	github.com/carlosframework/platform/internal/hostbox	22.262s
ok  	github.com/carlosframework/platform/internal/hostclaim	2.540s
ok  	github.com/carlosframework/platform/internal/hostenv	0.037s
ok  	github.com/carlosframework/platform/internal/hostevidence	0.018s
ok  	github.com/carlosframework/platform/internal/hostexec	24.117s
ok  	github.com/carlosframework/platform/internal/hostfence	0.153s
ok  	github.com/carlosframework/platform/internal/hostfiles	26.668s
ok  	github.com/carlosframework/platform/internal/hostfloor	0.100s
ok  	github.com/carlosframework/platform/internal/hostguard	1.520s
ok  	github.com/carlosframework/platform/internal/hostops	6.804s
?   	github.com/carlosframework/platform/internal/hostops/fencerelease	[no test files]
ok  	github.com/carlosframework/platform/internal/hostops/internal/fencerelease	0.013s
ok  	github.com/carlosframework/platform/internal/hostquarantine	0.012s
ok  	github.com/carlosframework/platform/internal/hostrelocate	1.983s
ok  	github.com/carlosframework/platform/internal/hostresolve	0.716s
ok  	github.com/carlosframework/platform/internal/hostwrite	0.013s
ok  	github.com/carlosframework/platform/internal/infraview	0.010s
ok  	github.com/carlosframework/platform/internal/ingresshealth	0.022s
ok  	github.com/carlosframework/platform/internal/ingresshealth/awstg	0.015s
ok  	github.com/carlosframework/platform/internal/instancectl	55.493s
ok  	github.com/carlosframework/platform/internal/instanceexec	7.838s
ok  	github.com/carlosframework/platform/internal/instancefs	0.020s
ok  	github.com/carlosframework/platform/internal/instancekey	0.005s
ok  	github.com/carlosframework/platform/internal/instanceupdates	0.021s
ok  	github.com/carlosframework/platform/internal/interactive	0.689s
ok  	github.com/carlosframework/platform/internal/launchd	0.009s
ok  	github.com/carlosframework/platform/internal/layout	20.002s
ok  	github.com/carlosframework/platform/internal/layout/pubclass	97.370s
ok  	github.com/carlosframework/platform/internal/lbhealth	0.020s
ok  	github.com/carlosframework/platform/internal/lease	143.155s
ok  	github.com/carlosframework/platform/internal/lease/leasetest	0.983s
ok  	github.com/carlosframework/platform/internal/lease/locktest	0.024s
ok  	github.com/carlosframework/platform/internal/ledger	0.056s
ok  	github.com/carlosframework/platform/internal/mail	0.822s
ok  	github.com/carlosframework/platform/internal/mailer	0.832s
ok  	github.com/carlosframework/platform/internal/mailsubmit	1.407s
ok  	github.com/carlosframework/platform/internal/mailwire	0.014s
ok  	github.com/carlosframework/platform/internal/maintenance	0.130s
ok  	github.com/carlosframework/platform/internal/maintenanceexec	8.236s
ok  	github.com/carlosframework/platform/internal/maintenanceguard	0.299s
ok  	github.com/carlosframework/platform/internal/media	1.740s
ok  	github.com/carlosframework/platform/internal/media/mediatest	0.010s
ok  	github.com/carlosframework/platform/internal/mediaaws	62.856s
ok  	github.com/carlosframework/platform/internal/mediahandler	42.117s
ok  	github.com/carlosframework/platform/internal/mediajobs	0.923s
ok  	github.com/carlosframework/platform/internal/medialocal	10.630s
ok  	github.com/carlosframework/platform/internal/metrics	0.157s
ok  	github.com/carlosframework/platform/internal/minorunits	0.007s
ok  	github.com/carlosframework/platform/internal/moves	56.521s
ok  	github.com/carlosframework/platform/internal/moves/archive	2.289s
ok  	github.com/carlosframework/platform/internal/moves/offlinerun	0.075s
ok  	github.com/carlosframework/platform/internal/namedunits	0.059s
ok  	github.com/carlosframework/platform/internal/objstore	0.732s
ok  	github.com/carlosframework/platform/internal/ops	14.545s
ok  	github.com/carlosframework/platform/internal/pageindex	3.915s
ok  	github.com/carlosframework/platform/internal/parity	0.103s
?   	github.com/carlosframework/platform/internal/parity/cmd/parity-doc	[no test files]
ok  	github.com/carlosframework/platform/internal/park	0.598s
ok  	github.com/carlosframework/platform/internal/perf	0.198s
ok  	github.com/carlosframework/platform/internal/plans	0.158s
ok  	github.com/carlosframework/platform/internal/privatefile	0.013s
ok  	github.com/carlosframework/platform/internal/provision	236.217s
ok  	github.com/carlosframework/platform/internal/proxyproto	0.935s
ok  	github.com/carlosframework/platform/internal/publicrelease	0.043s
ok  	github.com/carlosframework/platform/internal/ratelimit	0.226s
ok  	github.com/carlosframework/platform/internal/regionlabel	0.050s
ok  	github.com/carlosframework/platform/internal/regionname	0.066s
ok  	github.com/carlosframework/platform/internal/registrar	0.010s
ok  	github.com/carlosframework/platform/internal/registrar/openprovider	0.212s
?   	github.com/carlosframework/platform/internal/registrar/registrartest	[no test files]
ok  	github.com/carlosframework/platform/internal/registry	84.740s
ok  	github.com/carlosframework/platform/internal/relay	7.847s
ok  	github.com/carlosframework/platform/internal/release	89.592s
ok  	github.com/carlosframework/platform/internal/replicagen	0.089s
ok  	github.com/carlosframework/platform/internal/replicas	0.072s
ok  	github.com/carlosframework/platform/internal/reqrec	5.325s
ok  	github.com/carlosframework/platform/internal/rollout	12.576s
ok  	github.com/carlosframework/platform/internal/rolloutwords	0.024s
ok  	github.com/carlosframework/platform/internal/rootaws	100.382s
ok  	github.com/carlosframework/platform/internal/rootfsimage	0.827s
ok  	github.com/carlosframework/platform/internal/rootparticipation	0.094s
ok  	github.com/carlosframework/platform/internal/rootstate	0.059s
ok  	github.com/carlosframework/platform/internal/runs	1.221s
ok  	github.com/carlosframework/platform/internal/s3compat	0.018s
ok  	github.com/carlosframework/platform/internal/s3fake	1.868s
ok  	github.com/carlosframework/platform/internal/safefile	0.037s
ok  	github.com/carlosframework/platform/internal/schedule	25.429s
ok  	github.com/carlosframework/platform/internal/seeds	0.063s
ok  	github.com/carlosframework/platform/internal/sim/litestreamfacts	4.822s
ok  	github.com/carlosframework/platform/internal/sim/mediajobs	48.050s
ok  	github.com/carlosframework/platform/internal/sim/regionha	24.530s
ok  	github.com/carlosframework/platform/internal/status	0.614s
ok  	github.com/carlosframework/platform/internal/steering	0.337s
ok  	github.com/carlosframework/platform/internal/stopevidence	0.496s
ok  	github.com/carlosframework/platform/internal/storecfg	0.604s
ok  	github.com/carlosframework/platform/internal/svcrole	0.038s
ok  	github.com/carlosframework/platform/internal/systemd	5.270s
?   	github.com/carlosframework/platform/internal/systemdshow	[no test files]
ok  	github.com/carlosframework/platform/internal/team	4.085s
ok  	github.com/carlosframework/platform/internal/teamcontract	0.243s
ok  	github.com/carlosframework/platform/internal/telemetry	0.032s
ok  	github.com/carlosframework/platform/internal/termfence	2.632s
ok  	github.com/carlosframework/platform/internal/timerspec	0.038s
ok  	github.com/carlosframework/platform/internal/tsidentity	4.179s
ok  	github.com/carlosframework/platform/internal/tunnelclient	0.335s
ok  	github.com/carlosframework/platform/internal/unixdial	0.012s
ok  	github.com/carlosframework/platform/internal/updatewords	0.023s
ok  	github.com/carlosframework/platform/internal/upstreamguard	0.018s
?   	github.com/carlosframework/platform/internal/upstreamguard/guardtest	[no test files]
ok  	github.com/carlosframework/platform/internal/usage	0.027s
ok  	github.com/carlosframework/platform/internal/version	0.007s
ok  	github.com/carlosframework/platform/internal/vet	3.265s
ok  	github.com/carlosframework/platform/internal/zonehost	0.014s
ok  	github.com/carlosframework/platform/internal/zonehost/route53zones	0.100s
?   	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.027s
ok  	github.com/carlosframework/platform/scripts/pathmapcheck	0.089s
ok  	github.com/carlosframework/platform/scripts/region-ha-g2/fixture	5.238s
ok  	github.com/carlosframework/platform/scripts/stateless-replicas-drill	1.219s
ok  	github.com/carlosframework/platform/scripts/witness-pointer	0.015s
=== cutover-witness (152 s, from +15 s)
ok  	github.com/carlosframework/platform	3.533s
=== internal_grouproll@0 (270 s, from +74 s)
ok  	github.com/carlosframework/platform/internal/grouproll	268.703s
=== internal_grouproll@1 (275 s, from +74 s)
ok  	github.com/carlosframework/platform/internal/grouproll	273.169s
=== internal_activator@0 (142 s, from +138 s)
ok  	github.com/carlosframework/platform/internal/activator	138.677s
=== internal_activator@1 (132 s, from +138 s)
ok  	github.com/carlosframework/platform/internal/activator	128.097s
=== internal_activator@2 (133 s, from +138 s)
ok  	github.com/carlosframework/platform/internal/activator	128.354s
=== internal_activator@3 (187 s, from +138 s)
ok  	github.com/carlosframework/platform/internal/activator	182.605s
=== internal_edge@0 (191 s, from +160 s)
ok  	github.com/carlosframework/platform/internal/edge	179.387s
=== internal_edge@1 (139 s, from +160 s)
ok  	github.com/carlosframework/platform/internal/edge	127.234s
=== internal_edge@2 (214 s, from +160 s)
ok  	github.com/carlosframework/platform/internal/edge	203.174s
=== internal_edge@3 (171 s, from +160 s)
ok  	github.com/carlosframework/platform/internal/edge	158.893s
=== root@0 (121 s, from +169 s)
ok  	github.com/carlosframework/platform	113.611s
=== root@1 (112 s, from +169 s)
ok  	github.com/carlosframework/platform	103.929s
=== root@2 (121 s, from +169 s)
ok  	github.com/carlosframework/platform	112.427s
=== root@3 (112 s, from +169 s)
ok  	github.com/carlosframework/platform	104.004s
=== root@4 (102 s, from +169 s)
ok  	github.com/carlosframework/platform	93.067s
=== internal_host@0 (137 s, from +212 s)
ok  	github.com/carlosframework/platform/internal/host	132.572s
=== internal_host@1 (144 s, from +212 s)
ok  	github.com/carlosframework/platform/internal/host	139.680s
=== internal_host@2 (267 s, from +212 s)
ok  	github.com/carlosframework/platform/internal/host	262.898s
=== internal_host@3 (196 s, from +212 s)
ok  	github.com/carlosframework/platform/internal/host	191.126s
=== internal_host@4 (198 s, from +212 s)
ok  	github.com/carlosframework/platform/internal/host	193.565s
=== internal_host@5 (206 s, from +212 s)
ok  	github.com/carlosframework/platform/internal/host	201.840s
=== internal_console@0 (173 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	165.958s
=== internal_console@1 (159 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	153.670s
=== internal_console@2 (193 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	187.488s
=== internal_console@3 (228 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	222.858s
=== internal_console@4 (179 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	172.648s
=== internal_console@5 (193 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	186.816s
=== internal_console@6 (191 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	184.295s
=== internal_console@7 (192 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	185.205s
=== internal_console@8 (199 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	192.696s
=== internal_console@9 (208 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	200.329s
=== internal_console@10 (218 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	211.010s
=== internal_console@11 (202 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	195.859s
=== internal_console@12 (300 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	292.618s
=== internal_console@13 (197 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	191.307s
=== internal_console@14 (186 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	179.723s
=== internal_console@15 (207 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	201.590s
=== internal_console@16 (194 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	187.501s
=== internal_console@17 (218 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	212.425s
=== internal_console@18 (226 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	219.885s
=== internal_console@19 (228 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	221.601s
=== internal_console@20 (187 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	180.198s
=== internal_console@21 (208 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	201.653s
=== internal_console@22 (205 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	198.061s
=== internal_console@23 (205 s, from +217 s)
ok  	github.com/carlosframework/platform/internal/console	199.364s
=== lists: internal_console 215 s, internal_edge 159 s, internal_activator 137 s, internal_host 211 s, root 168 s, internal_grouproll 74 s
=== cpu: the gate used 12262 cpu-seconds in 517 s, about 23.7 of 32 cores; the machine as a whole was 79% busy
=== opentofu ===
opentofu: 35 test files in 11 suites, OpenTofu v1.13.9
  initialised in 15 s
  ok      16 s  infra/modules/box-fence-writer/tests/writer.tftest.hcl  Success! 1 passed, 0 failed.
  ok      28 s  infra/modules/deployment-buckets/tests/data_lifecycle.tftest.hcl  Success! 3 passed, 0 failed.
  ok      17 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      84 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      70 s  infra/modules/pdf-host/tests/pdf_host.tftest.hcl  Success! 24 passed, 0 failed.
  ok      46 s  infra/modules/region-group-operator-document/tests/document.tftest.hcl  Success! 12 passed, 0 failed.
  ok      24 s  infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl  Success! 2 passed, 0 failed.
  ok      69 s  infra/modules/region-host/ingress/tests/group_ingress.tftest.hcl  Success! 30 passed, 0 failed.
  ok      47 s  infra/modules/region-host/tests/alert_publish.tftest.hcl  Success! 18 passed, 0 failed.
  ok      43 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      17 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      66 s  infra/modules/region-host/tests/group.tftest.hcl  Success! 32 passed, 0 failed.
  ok      10 s  infra/modules/region-host/tests/group_alarms.tftest.hcl  Success! 4 passed, 0 failed.
  ok      10 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      34 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      27 s  infra/modules/region-host/tests/health_alarms.tftest.hcl  Success! 10 passed, 0 failed.
  ok      11 s  infra/modules/region-host/tests/ingress_drain_read.tftest.hcl  Success! 4 passed, 0 failed.
  ok       6 s  infra/modules/region-host/tests/instance_metadata.tftest.hcl  Success! 1 passed, 0 failed.
  ok      19 s  infra/modules/region-host/tests/mailer.tftest.hcl  Success! 6 passed, 0 failed.
  ok       8 s  infra/modules/region-host/tests/mailer_group.tftest.hcl  Success! 2 passed, 0 failed.
  ok      11 s  infra/modules/region-host/tests/managed_fleets/group_refusal.tftest.hcl  Success! 2 passed, 0 failed.
  ok     105 s  infra/modules/region-host/tests/managed_fleets/managed_fleets.tftest.hcl  Success! 46 passed, 0 failed.
  ok      68 s  infra/modules/region-host/tests/store_conversion.tftest.hcl  Success! 27 passed, 0 failed.
  ok      17 s  infra/modules/region-host/tests/store_scanning.tftest.hcl  Success! 4 passed, 0 failed.
  ok      19 s  infra/modules/region-host/tests/user_data_ignored.tftest.hcl  Success! 3 passed, 0 failed.
  ok      12 s  infra/modules/region-remote-host/tests/data_lifecycle.tftest.hcl  Success! 3 passed, 0 failed.
  ok      17 s  infra/modules/region-remote-host/tests/no_deployment_bucket.tftest.hcl  Success! 5 passed, 0 failed.
  ok      29 s  infra/modules/scanner-host/tests/scanner_host.tftest.hcl  Success! 14 passed, 0 failed.
opentofu: 35 files in 205 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: 65667234 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:31500
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/21 21:58:26 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18EA2E4C3E9ECA20, HostID: 3dd51527e749e52c66cec7e92aad306feeb4cd1098ffd4a93d65b99cdce59602, 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.046s
=== 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.039s
=== 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/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/21 21:58:32 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/11/21 21:58:32 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/11/21 21:58:32 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/21 21:58:32 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/21 21:58:32 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/21 21:58:32 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/11/21 21:58:32 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%3A40357: could not determine target mailbox
    agent.go:136: dbreads: dbr_fsbvds3ohdl2zdjqed6xoqextm: planned 3 files (1544 bytes) and restored to 3 in 13ms
    agent.go:136: dbreads: dbr_fsbvds3ohdl2zdjqed6xoqextm: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/21 21:58:33 console: db read dbr_fsbvds3ohdl2zdjqed6xoqextm: relayed 1 chunks (102 bytes) in 1.005s, ended done
    agent.go:136: dbreads: dbr_e7aoekqvbpur7vnv67pkawumda: planned 1 files (720 bytes) and restored to 1 in 11ms
    agent.go:136: dbreads: dbr_e7aoekqvbpur7vnv67pkawumda: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/21 21:58:34 console: db read dbr_e7aoekqvbpur7vnv67pkawumda: relayed 1 chunks (102 bytes) in 1.005s, ended done
    agent.go:136: dbreads: dbr_a6cdh3b6akqxttvuqc7chlhtiu: planned 3 files (1544 bytes) and held through 3 in 12ms
    agent.go:136: dbreads: dbr_a6cdh3b6akqxttvuqc7chlhtiu: output 1544 bytes in 1 confirmed chunks in 1ms
2026/11/21 21:58:35 console: db read dbr_a6cdh3b6akqxttvuqc7chlhtiu: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN   TestDBForwardMinio/by_disconnect
=== NAME  TestDBForwardMinio
    agent.go:136: dbreads: dbr_dewoelazryxxfcc6nbbybvqgmm: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/21 21:58:35 console: db read dbr_dewoelazryxxfcc6nbbybvqgmm: relayed 0 chunks (0 bytes) in 18ms, ended client gone
    agent.go:136: dbreads: dbr_dewoelazryxxfcc6nbbybvqgmm: output 5 bytes in 1 confirmed chunks in 104ms
=== RUN   TestDBForwardMinio/by_timeout
=== NAME  TestDBForwardMinio
    agent.go:136: dbreads: dbr_zulbpsy27opf6f6tk7dxmd3coe: planned 3 files (1544 bytes) and restored to 3 in 12ms
2026/11/21 21:58:55 console: db read dbr_zulbpsy27opf6f6tk7dxmd3coe: relayed 0 chunks (0 bytes) in 19.13s, ended no-result
    agent.go:136: dbreads: dbr_zulbpsy27opf6f6tk7dxmd3coe: output 5 bytes in 1 confirmed chunks in 19.103s
--- PASS: TestDBForwardMinio (22.78s)
    --- PASS: TestDBForwardMinio/by_disconnect (0.23s)
    --- PASS: TestDBForwardMinio/by_timeout (19.24s)
PASS
ok  	github.com/carlosframework/platform/internal/console	22.826s
Bucket created successfully `local/media-transfers`.
Bucket created successfully `local/media-transfer-results`.
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.06s)
PASS
ok  	github.com/carlosframework/platform/internal/mediaaws	0.061s
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.555s
=== RUN   TestHeldHandoverTwoBoxMinio
2026/11/21 21:58:59 edge: mesh key: minted
2026/11/21 21:59:00 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/21 21:59:00 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/21 21:59:00 tenant admission is open. accepting tenant work
2026/11/21 21:59:00 activator: HA placement host=shop-5f3f8742.example.test kind=Place ref=annie reason=roomiest generation=2026-11-21T21:59:00Z lock_generation=0
2026/11/21 21:59:00 lease: t8-5f3f8742/shop-5f3f8742.example.test: HA lease acquired in 4ms (first wake)
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: started carlos-instance@shop\x2d5f3f8742.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/21 21:59:00 activator: shop-5f3f8742.example.test: carlos-instance@shop\x2d5f3f8742.example.test.service launched in 7ms, healthy 0s later
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: woke in 20ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 8ms
2026/11/21 21:59:00 lease: t8-5f3f8742/plain-5f3f8742.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/21 21:59:00 activator: no replica for plain-5f3f8742.example.test in s3://contract-bucket/t8-5f3f8742/plain-5f3f8742.example.test — booting fresh
2026/11/21 21:59:00 activator: plain-5f3f8742.example.test: started carlos-instance@plain\x2d5f3f8742.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/21 21:59:00 activator: plain-5f3f8742.example.test: carlos-instance@plain\x2d5f3f8742.example.test.service launched in 6ms, healthy 0s later
2026/11/21 21:59:00 activator: plain-5f3f8742.example.test: woke in 45ms: checks 0s, lease 1ms, restore 17ms, identity 0s, protect 0s, spawn 7ms, replicate 20ms
2026/11/21 21:59:00 lease: t8-5f3f8742/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/11/21 21:59:00 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/21 21:59:00 activator: bot0.shop.bac.sidecar.internal: woke in 18ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, settle 0s, replicate 6ms
2026/11/21 21:59:00 activator: next-due probe plain-5f3f8742.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/21 21:59:00 activator: plain-5f3f8742.example.test hibernated
2026/11/21 21:59:00 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:b7384368cee9e8105a4b2252aed29a3c8f7c989eeb485cc44a3a06ea79470eb1) in 8ms: files 1ms, sync 4ms, record 1ms, marker 3ms
2026/11/21 21:59:00 activator: bot0.shop.bac.sidecar.internal hibernated
2026/11/21 21:59:00 activator: next-due probe shop-5f3f8742.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: released with a marker (clean true, txid 1, files 3:a74298bcc9d814103ef2047d5ec98cf33a9ae9b1a2967088559d2e1f63ce9c9c) in 6ms: files 1ms, sync 3ms, record 1ms, marker 2ms
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test hibernated
2026/11/21 21:59:00 lease: t8-5f3f8742/shop-5f3f8742.example.test: HA lease acquired in 3ms (clean marker)
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: restored (other-box)
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: started carlos-instance@shop\x2d5f3f8742.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 1ms, control socket 0s, key gate 0s, logs 0s) 1ms, launch file 0s, gate 0s, root start 1ms)
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: carlos-instance@shop\x2d5f3f8742.example.test.service launched in 2ms, healthy 0s later
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: woke in 86ms: checks 0s, lease 4ms, restore 25ms, identity 0s, protect 0s, spawn 2ms, replicate 54ms
2026/11/21 21:59:00 edge: ha-take shop-5f3f8742.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/11/21 21:59:00 edge: forward shop-5f3f8742.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:bc2d3108df2a29032b9a2e808ee2c964 Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-11-21 21:59:00.286347522 +0000 UTC FinishedAt:2026-11-21 21:59:00.433762647 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-5f3f8742.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:plain-5f3f8742.example.test Kind:other Marker:true Clean:true Reason:} {Host:bot0.shop.bac.sidecar.internal Kind:worker Marker:true Clean:true Reason:}] Unclean:[] Left:[] Holds:{LongestMS:125 Todays:0 RefusedAtOnce:1} Closed:0 Quiet:{DrainQuiet:{Waking:0 Stopping:0 Recovering:0 Owed:0} Held:[]}}
    hadrain_twobox_minio_linux_test.go:1239: driver calls: [begin shop-5f3f8742.example.test <nil> stop plain-5f3f8742.example.test marker=true clean=true <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> releasing shop-5f3f8742.example.test <nil> stop shop-5f3f8742.example.test marker=true clean=true <nil> taken shop-5f3f8742.example.test betty <nil> end-moves]
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/bot0.shop.bac.sidecar.internal/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/bot0.shop.bac.sidecar.internal/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/bot0.shop.bac.sidecar.internal/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-5f3f8742/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-5f3f8742/plain-5f3f8742.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-5f3f8742/bot0.shop.bac.sidecar.internal/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/head.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/generations/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0008/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0007/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0006/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0005/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0004/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0008/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0007/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0006/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0005/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0004/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/0009/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/files/0/manifest.json
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/files/0/objects/0000000000000001-da363a340021047bd87eea23de395ed8ed04ed69aff0cc5061841dc1bd364bf7
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/files/0/objects/0000000000000003-8a000c41900465a5db5736849f69faa0f2ec55c386a3cf180d97c27bfd14ec5d
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0009/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0001/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/0000/0000000000000001-0000000000000001.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0002/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0003/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-5f3f8742/shop-5f3f8742.example.test/0000/
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/0000/0000000000000002-0000000000000002.ltx
    hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-5f3f8742/shop-5f3f8742.example.test/lock.json
    hadrain_twobox_minio_linux_test.go:1243: drain took 195ms; S3 calls 46 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=30 PUT lock=3 PUT replica=3); deployment store calls 20 (GET edges=14 LIST edges=4 PUT edges=2)
    hadrain_twobox_minio_linux_test.go:1367: the fenced A's start gate answers 503 "This service is unavailable. Try again later.\n" (Retry-After "10")
2026/11/21 21:59:00 lease: t8-5f3f8742/plain-5f3f8742.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/21 21:59:00 activator: plain-5f3f8742.example.test: started carlos-instance@plain\x2d5f3f8742.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/21 21:59:00 activator: plain-5f3f8742.example.test: carlos-instance@plain\x2d5f3f8742.example.test.service launched in 1ms, healthy 0s later
2026/11/21 21:59:00 lease: /tmp/carlos-minio-contract-ntAYoC/g/dw2994099786/data/instances/plain-5f3f8742.example.test/plain-5f3f8742.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/11/21 21:59:00 activator: plain-5f3f8742.example.test: woke in 10ms: checks 0s, lease 2ms, restore 0s, identity 0s, protect 0s, spawn 1ms, replicate 6ms
2026/11/21 21:59:00 activator: next-due probe shop-5f3f8742.example.test: decode /api/next-due: invalid character 'b' looking for beginning of value — recording none (it sleeps until a request)
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test: released with a marker (clean true, txid 2, files 3:a74298bcc9d814103ef2047d5ec98cf33a9ae9b1a2967088559d2e1f63ce9c9c) in 4ms: files 1ms, sync 0s, record 1ms, marker 2ms
2026/11/21 21:59:00 activator: shop-5f3f8742.example.test hibernated
2026/11/21 21:59:00 tenant admission is closed for shutdown
2026/11/21 21:59:00 activator: next-due probe plain-5f3f8742.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/21 21:59:00 activator: plain-5f3f8742.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.52s)
=== RUN   TestHeldHandoverLostLeaseMinio
2026/11/21 21:59:00 edge: mesh key: minted
2026/11/21 21:59:00 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/21 21:59:00 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/21 21:59:00 tenant admission is open. accepting tenant work
2026/11/21 21:59:00 activator: HA placement host=shop-f915081d.example.test kind=Place ref=annie reason=roomiest generation=2026-11-21T21:59:00Z lock_generation=0
2026/11/21 21:59:00 lease: t8-f915081d/shop-f915081d.example.test: HA lease acquired in 3ms (first wake)
2026/11/21 21:59:00 activator: shop-f915081d.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/21 21:59:00 activator: shop-f915081d.example.test: started carlos-instance@shop\x2df915081d.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/21 21:59:00 activator: shop-f915081d.example.test: carlos-instance@shop\x2df915081d.example.test.service launched in 7ms, healthy 0s later
2026/11/21 21:59:00 activator: shop-f915081d.example.test: woke in 18ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 7ms
2026/11/21 21:59:00 activator: next-due probe shop-f915081d.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/21 21:59:00 activator: final checkpoint shop-f915081d.example.test: lease: release marker owed for s3://contract-bucket/t8-f915081d/shop-f915081d.example.test/lock.json (If-Match "0afb38061da45c254130c2d49132ef0c"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/11/21 21:59:00 activator: shop-f915081d.example.test hibernated
2026/11/21 21:59:00 activator: handover of shop-f915081d.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-f915081d.example.test client 4 "
    hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-f915081d.example.test <nil> releasing shop-f915081d.example.test <nil> stop shop-f915081d.example.test marker=false clean=false <nil> left shop-f915081d.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/21 21:59:00 tenant admission is closed for shutdown
2026/11/21 21:59:00 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.27s)
PASS
ok  	github.com/carlosframework/platform/internal/host	0.829s
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/21 21:59:01 lease: instances/gen-1795298341960429884.shop.example.com: HA lease acquired in 5ms (first wake)
2026/11/21 21:59:01 lease: instances/gen-1795298341960429884.shop.example.com: HA lease acquired in 3ms (holder terminated)
    gentake_minio_test.go:308: a second create-only copy onto instances/gen-1795298341960429884.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/11/21 21:59:02 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/21 21:59:02 http: proxy error: context canceled
2026/11/21 21:59:02 http: proxy error: context canceled
2026/11/21 21:59:02 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/21 21:59:02 lease: instances/gen-1795298342131656133.shop.example.com: HA lease acquired in 4ms (first wake)
2026/11/21 21:59:02 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/21 21:59:02 lease: instances/gen-1795298342131656133.shop.example.com: HA lease acquired in 3ms (clean marker)
=== RUN   TestGenerationTakeMinio/copy-version
=== RUN   TestGenerationTakeMinio/store-time
2026/11/21 21:59:02 lease: instances/gen-1795298342227664819.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/21 21:59:02 http: proxy error: context canceled
2026/11/21 21:59:02 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/21 21:59:02 lease: instances/gen-1795298342227664819.shop.example.com: HA lease acquired in 2ms (clean marker)
2026/11/21 21:59:02 lease: instances/gen-1795298342227664819.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/21 21:59:02 lease: instances/gen-1795298342227664819.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/21 21:59:02 lease: instances/gen-1795298342227664819.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/21 21:59:02 lease: instances/gen-1795298342227664819.shop.example.com: HA lease acquired in 2ms (unclean marker)
=== RUN   TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.38s)
    --- PASS: TestGenerationTakeMinio/take (0.17s)
    --- 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.392s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading golang.org/x/sync v0.23.0
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
staticcheck: clean
=== govulncheck ===
go version go1.26.10 linux/arm64
go: downloading golang.org/x/vuln v1.8.0
go: downloading golang.org/x/telemetry v0.0.0-20260908163034-4bcc4b2ee518
go: downloading golang.org/x/tools v0.50.0
govulncheck: scanned github.com/carlosframework/platform, amadan.net/carlos/platform.git/launchctx
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.615s
    codehealth_test.go:107: line metrics (code lines, then physical):
          file-lines  5471  7324  internal/activator activator_test.go
          file-lines  4219  7040  internal/console server.go
          file-lines  4184  6365  . apimode.go
          file-lines  3782  7198  internal/activator activator.go
          file-lines  3530  4459  . apimode_test.go
          file-lines  3261  3864  internal/registry registry_test.go
          file-lines  3211  6356  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   688  1232  internal/host runAgent
          func-lines   570   903  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   400   868  internal/provision rootReadArchivedChain
          func-lines   399   732  internal/release PassFilter
          func-lines   390   398  internal/host runFilesSeedPreparationWithLive
          func-lines   384   905  internal/edge (*Edge).ServeHTTP
          func-lines   383   406  internal/console TestDemoSourceToLiveAndUpdate
          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   635  cmd/console serve
          func-lines   364   371  internal/host testRootMigrationBootstrap
          func-lines   360   362  internal/edge TestDemoAPIAliasBoundary
          func-lines   358   362  internal/registry (*Registry).haJournal
          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 (203 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/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
          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/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/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/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/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         18578 at   45 sites  functions over 300 code lines (blank and comment-only lines not counted)
    codehealth_test.go:115: file-lines         30752 at    8 sites  files over 3,000 code lines, counted the same way
    codehealth_test.go:115: release-importers     66 at    1 sites  packages whose production files import internal/release
    codehealth_test.go:119: below the record: file-lines internal/activator activator.go -: 3782 in the code, the record allows 3783 (make code-health-record lowers it)
    codehealth_test.go:119: below the record: file-lines internal/host agent.go -: 3211 in the code, the record allows 3214 (make code-health-record lowers it)
--- PASS: TestCodeHealth (109.62s)
PASS
ok  	github.com/carlosframework/platform/internal/codehealth	110.597s
=== code-health-record ===
go version go1.26.10 linux/arm64
code-health record: comparing with the merge base 2b5b5b776d7e8425bd411feb4ef12ebca0f9eb24 (main is 2b5b5b776d7e8425bd411feb4ef12ebca0f9eb24)
=== RUN   TestRecordAgainstBase
    codehealth_test.go:186: accepted: release-importers internal/release - -: 66, up from 65: # raised: scripts/pathmapcheck reads claims and edges files from the store (#186 pre-roll check)
--- PASS: TestRecordAgainstBase (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/codehealth	0.008s
code-health record: no line went up without a reason
=== race ===
go version go1.26.10 linux/arm64
GATE_RACE=1 .amadan/test-gate.sh
=== internal_systemd@0 (14 s, from +14 s)
ok  	github.com/carlosframework/platform/internal/systemd	13.515s
=== internal_rootaws@0 (25 s, from +34 s)
ok  	github.com/carlosframework/platform/internal/rootaws	25.069s
=== internal_activator@0 (286 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	283.898s
=== internal_activator@1 (252 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	250.124s
=== internal_activator@2 (303 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	300.313s
=== internal_activator@3 (366 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	363.768s
=== internal_activator@4 (287 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	284.455s
=== internal_activator@5 (287 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	284.242s
=== internal_activator@6 (313 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	310.725s
=== internal_activator@7 (423 s, from +110 s)
ok  	github.com/carlosframework/platform/internal/activator	420.684s
=== internal_edge@0 (83 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	80.710s
=== internal_edge@1 (66 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	63.782s
=== internal_edge@2 (210 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	207.125s
=== internal_edge@3 (149 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	146.526s
=== internal_edge@4 (160 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	157.135s
=== internal_edge@5 (233 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	229.862s
=== internal_edge@6 (200 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	196.983s
=== internal_edge@7 (275 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	272.648s
=== internal_edge@8 (202 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	199.829s
=== internal_edge@9 (268 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	265.497s
=== internal_edge@10 (264 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	261.383s
=== internal_edge@11 (221 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	217.802s
=== internal_edge@12 (245 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	242.750s
=== internal_edge@13 (256 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	253.179s
=== internal_edge@14 (173 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	169.902s
=== internal_edge@15 (238 s, from +131 s)
ok  	github.com/carlosframework/platform/internal/edge	234.803s
=== internal_host@0 (15 s, from +189 s)
ok  	github.com/carlosframework/platform/internal/host	11.011s
=== internal_host@1 (9 s, from +189 s)
ok  	github.com/carlosframework/platform/internal/host	5.256s
=== lists: internal_edge 129 s, internal_activator 109 s, internal_host 189 s, internal_rootaws 33 s, internal_systemd 13 s
=== cpu: the gate used 7507 cpu-seconds in 533 s, about 14.1 of 32 cores; the machine as a whole was 43% busy
=== gitleaks ===
go version go1.26.10 linux/arm64
go: downloading github.com/zricethezav/gitleaks/v8 v8.30.1
go: downloading golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
go: downloading github.com/rs/zerolog v1.33.0
go: downloading github.com/fatih/semgroup v1.2.0
go: downloading github.com/spf13/cobra v1.9.1
go: downloading github.com/spf13/viper v1.19.0
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/BobuSumisu/aho-corasick v1.0.3
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading github.com/charmbracelet/lipgloss v0.5.0
go: downloading github.com/gitleaks/go-gitdiff v0.9.1
go: downloading github.com/h2non/filetype v1.1.3
go: downloading github.com/mholt/archives v0.1.2
go: downloading golang.org/x/sync v0.11.0
go: downloading github.com/STARRY-S/zip v0.2.1
go: downloading golang.org/x/text v0.22.0
go: downloading github.com/klauspost/compress v1.17.11
go: downloading github.com/pierrec/lz4/v4 v4.1.21
go: downloading github.com/ulikunitz/xz v0.5.12
go: downloading github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3
go: downloading github.com/bodgit/sevenzip v1.6.0
go: downloading github.com/sorairolake/lzip-go v0.3.5
go: downloading github.com/nwaples/rardecode/v2 v2.1.0
go: downloading github.com/therootcompany/xz v1.0.1
go: downloading github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
go: downloading github.com/minio/minlz v1.0.0
go: downloading github.com/klauspost/pgzip v1.2.6
go: downloading github.com/spf13/pflag v1.0.6
go: downloading github.com/mattn/go-colorable v0.1.14
go: downloading github.com/muesli/termenv v0.15.1
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68
go: downloading github.com/fsnotify/fsnotify v1.8.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading github.com/spf13/cast v1.7.1
go: downloading dario.cat/mergo v1.0.1
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/Masterminds/semver/v3 v3.3.0
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.4.0
go: downloading golang.org/x/crypto v0.35.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/bodgit/plumbing v1.3.0
go: downloading github.com/bodgit/windows v1.0.1
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading go4.org v0.0.0-20230225012048-214862532bf5
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading golang.org/x/sys v0.30.0
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.7
go: downloading github.com/mitchellh/reflectwalk v1.0.2
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 94 near misses of the names notscanned.go lists
self-test: skipped  the 31 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, 126 tracked files judged, 3 broken setups refused
gitleaks: scanned 11228 tracked files; 31 not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)
gitleaks: clean
diff --git a/docs/site/media-conversion.md b/docs/site/media-conversion.md
index 9090c54bb..0bc82821f 100644
--- a/docs/site/media-conversion.md
+++ b/docs/site/media-conversion.md
@@ -132,7 +132,9 @@ A job is `queued` while it waits for a place, `running` while the engine works o
| `source_dimensions` | `the video is larger than %s` |
| `source_frame_rate` | `the video has more than %d frames a second` |
| `source_too_long` | `the file is longer than %s, the maximum for this preset` |
+| `source_too_long` | `the HDR video is longer than %s, the maximum for HDR video up to 1080p` |
| `needs_long_class` | `the file is longer than %s, the most the short class converts. submit it again in the long class` |
+| `needs_long_class` | `the video is above 1080p, which only the long class converts. submit the same request again with "class": "long"` |
| `allowance_exceeded` | `this account's media allowance for the month does not cover this file. buy a media pack or move to a larger plan to convert it` |
| `unreadable` | `the file could not be read. it may be damaged or cut short` |
| `output_too_large` | `a converted file would be over 5 GB, the maximum for one output` |
@@ -194,14 +196,15 @@ Each job runs in a class. By default the source's size picks it, and you can ask
| Preset | Short class is used for | Short class converts up to | Stops a short job after | Stops a long job after |
| --- | --- | --- | --- | --- |
-| `video-720p` | sources up to 1 GiB | 10 minutes | 15 minutes | 50 minutes |
+| `video-720p` | sources up to 1 GiB | 10 minutes at or below 1080p | 15 minutes | 50 minutes |
| `audio-aac` | sources up to 256 MiB | 2 hours | 10 minutes | 50 minutes |
-A long job converts up to the preset's maximum. These maximums are provisional and may change:
+A video above 1080p converts only in the long class. The short class refuses it with `needs_long_class`, however short it is. A long job converts up to the preset's maximum:
| | `video-720p` | `audio-aac` |
| --- | --- | --- |
| Length, sources up to 1080p | 2 hours | 8 hours |
+| Length, HDR sources up to 1080p | 75 minutes | |
| Length, sources above 1080p | 30 minutes | |
| Source size | 40 GiB | 10 GiB |
| Largest picture, frame rate | 3840x2160, 60 | |
@@ -212,9 +215,9 @@ Fair use applies on every deployment. By default an account can have 20 conversi
### The allowance
-Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video counts as 1 media minute and a minute of audio as 0.1, so 10 minutes of audio is 1 media minute.
+Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video up to 1080p counts as 1 media minute, a minute of video above 1080p counts as 2, and a minute of audio counts as 0.1, so 10 minutes of audio is 1 media minute.
-A done job is charged for the length of its source. A failed job is charged for the engine time it used, or the full reserved time if the engine loses the task record. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance.
+A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used: 1 media minute per minute for video, or 0.1 for audio. A failed long video job whose result says the video is above 1080p is charged at 2 media minutes per minute. If the engine loses the task record, the job is charged the full time it was allowed to run, at 1 media minute per minute for video or 0.1 for audio. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file.
As with other monthly limits, the account's owners get a warning at 80% of the limit. At twice the monthly limit, new conversions are refused with `402` until the 1st of the UTC month, or until the account buys a media pack or moves to a larger plan. A job can also fail `allowance_exceeded` when what's left of the allowance won't cover the file. See [Plans](/docs/plans).
diff --git a/docs/site/plans.md b/docs/site/plans.md
index 657af6a76..381605158 100644
--- a/docs/site/plans.md
+++ b/docs/site/plans.md
@@ -36,7 +36,7 @@ Every account without a plan of its own is on `default_plan`. Packs may only rai
Set `pdf_renders_month` in a plan's limits to give your account a monthly PDF allowance shared by its apps. A value of 0 means no monthly limit. The PDF service's fair-use limits still apply.
-Set `media_minutes_month` to give your account a monthly allowance of media minutes for [media conversion](/docs/media-conversion), shared by its apps. A minute of video counts as 1 and a minute of audio as 0.1. A value of 0 means no monthly limit. As a starting point: 30 on a free plan, 600 on a personal plan, 1,200 on a community plan and 12,000 on a business plan, with a pack that adds 1,000. With no catalog, `account_minutes` in `CARLOS_MEDIA_LIMITS` sets one allowance for every account.
+Set `media_minutes_month` to give your account a monthly allowance of media minutes for [media conversion](/docs/media-conversion), shared by its apps. A minute of video up to 1080p counts as 1, a minute of video above 1080p as 2, and a minute of audio as 0.1. A value of 0 means no monthly limit. As a starting point: 30 on a free plan, 600 on a personal plan, 1,200 on a community plan and 12,000 on a business plan, with a pack that adds 1,000. With no catalog, `account_minutes` in `CARLOS_MEDIA_LIMITS` sets one allowance for every account.
Set `email_per_hour` to cap how many emails an account can send in one UTC hour. 0 means no hourly limit. There's no grace: once the hour's sends reach the limit, every sender of every app is held back until the next UTC hour.
diff --git a/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6.md b/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6.md
new file mode 100644
index 000000000..d4bec2185
--- /dev/null
+++ b/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6.md
@@ -0,0 +1,30 @@
+# Copy pass 6: media conversion, the spike's values (spec §11 A7)
+
+You are the copy-review gate itself for this set. Paul delegated copy review of platform UI, CLI, email and docs copy inside a plan to you on 2026-10-25; your verdicts ARE the review. Do NOT run the copy-review skill or start any server. You are writing a review report.
+
+Same feature, house rules and rulings as `docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion.md` (read it). What changed is spec amendment A7 in `docs/superpowers/specs/2026-11-16-video-conversion-design.md` §11 (read it): the dev spike's measured values and Paul's ruling that a minute of video above 1080p counts twice against the allowance. The code is in the tree and you may read it (`internal/console/media_copy.go`, `internal/media/`, `internal/mediajobs/`, `internal/mediahandler/probe.go`).
+
+In `docs/superpowers/notes/media-conversion-copy-deck.md`, review ONLY the rows marked "(pending Luna pass 6)". There are eight:
+
+1. **Two job error messages** (section "Job errors"): `media.job.source_too_long_hdr` and `media.job.needs_long_class_hi`. Readers are app developers reading a failed job's `error.message` from the API; their code may show it to their own users. `source_too_long_hdr` is the `source_too_long` message for an HDR video up to 1080p over its own maximum, 75 minutes by default; its `%s` is that maximum as `mediaDuration` writes it (`75 minutes`, `1 hour`). `needs_long_class_hi` is the `needs_long_class` message when the short class refuses a video above 1080p, whatever its length; it has no placeholder. Each sits beside its approved sibling (`media.job.source_too_long`, `media.job.needs_long_class`) and should read as one family with it. The fix for both `needs_long_class` messages is the same: send the same request again with `"class": "long"`.
+2. **Six docs rows** (section "Luna docs pass (Task 11)"): `docs.media.limits.4`, `docs.media.limits.6`, `docs.media.limits.8a` (a new table line), `docs.media.allowance.2`, `docs.media.allowance.3` on the media page (`docs/site/media-conversion.md`, "Limits" and "The allowance"), and `docs.plans.media.allowance` on the plans page (`docs/site/plans.md`). Readers are app developers and account owners. Read each in its table or paragraph on the page. Table rows keep their column count and the `\|` escapes as the deck writes them.
+
+The facts these rows must state, all from A7:
+
+- A video above 1080p (longer side over 1920 or shorter side over 1080) converts only in the long class. The short class refuses it with `needs_long_class` however short it is.
+- The short video class converts up to 10 minutes, at or below 1080p.
+- Maximum length: 2 hours for video up to 1080p, 75 minutes for HDR video up to 1080p, 30 minutes above 1080p (HDR or not); 8 hours for audio. These are now the spike's measured values, no longer provisional, but each is a deployment setting an operator can change.
+- Allowance weights: a minute of video up to 1080p counts 1, above 1080p 2, audio 0.1.
+- A done job is charged its source's length at its weight. A failed job is charged the engine time it used, at 2 a minute if the probe found the video above 1080p, otherwise at 1 (0.1 for audio); or the full reserved time if the engine loses the task record. A job that never starts is uncharged.
+- While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 a minute, because nothing is known of the picture until the engine reads the file.
+
+## Rules for this set, on top of pass 1's house rules
+
+- Job error messages: lower case, no trailing full stop, as their siblings are. Keep `%s` in `source_too_long_hdr`, and add no placeholder to `needs_long_class_hi`.
+- Not copy, leave them: job codes (`source_too_long`, `needs_long_class`), the class names `short` and `long`, `"class": "long"`, preset names, setting names (`video_max_hdr`, `media_minutes_month`, `account_minutes`, `CARLOS_MEDIA_LIMITS`), and the figures above.
+- Say "1080p" as the deck already does; don't introduce "Full HD", "4K" or pixel counts the rows don't need.
+- Change a row only when the change helps the reader act or avoids a misreading: a sentence that misleads, can't be parsed, contradicts its sibling or a fact above, or doesn't say what to do when the reader can do something. Consistency with the approved rows around it matters more than polish on one line. Don't rewrite for taste.
+
+## What to return
+
+A table `key | new | why`, with only the rows you change, each with its full new text in the row's own form. Unchanged rows are approved as they are. Then `## Flags` with only what Paul must decide or a fact you could not verify against the spec or code, each with your recommendation, or "none".
diff --git a/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md b/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md
new file mode 100644
index 000000000..be5a45837
--- /dev/null
+++ b/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md
@@ -0,0 +1,21 @@
+# Copy pass 6b: media conversion, one allowance row after review
+
+You are the copy-review gate itself for this one row. Paul delegated copy review of platform UI, CLI, email and docs copy inside a plan to you on 2026-10-25; your verdict IS the review. Do NOT run the copy-review skill or start any server. You are writing a review report.
+
+Same feature, house rules and rulings as `docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion.md` and pass 6 (`LUNA-COPY-BRIEF-media-conversion-6.md` and its result `LUNA-COPY-RESULT-media-conversion-6.md`; read all three).
+
+Review ONLY the row marked "(pending Luna pass 6b)" in `docs/superpowers/notes/media-conversion-copy-deck.md`: `docs.media.allowance.3`, the second paragraph of "The allowance" on `docs/site/media-conversion.md`. Readers are app developers and account owners.
+
+Why it changed: the branch's billing review (Astra round 1, `docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md`, the second P2) found that pass 6's text, "A failed job is charged for the engine time it used at the same weights; a video the engine never got to read counts as up to 1080p", overstates the charge. The facts, from spec §11 A7 "Charge" and `chargeWeight` in `internal/mediajobs/track.go`:
+
+- A done job: its source's length at its weight (1 up to 1080p, 2 above, 0.1 audio).
+- A failed job: the engine time it used, at 1 for video and 0.1 for audio. The only failed job charged at 2 is a long-class video whose result the console read and which says the video is above 1080p. A short-class job is never charged at 2: the short class refuses a video above 1080p before converting it. A failed job with no result for the console to read (the engine stopped it, it ran past its time, it crashed) is charged at 1.
+- A job whose task record the engine lost: the full time it was allowed to run (its deadline plus a 30-second stop grace), at 1 for video and 0.1 for audio.
+- A job that never starts: nothing.
+- While a job runs, the most it could cost is held; a long video job is held at 2.
+
+Change the row only where it misleads, can't be parsed, or contradicts a fact above. Keep it a plain paragraph. Don't add the 30-second figure unless it helps the reader act.
+
+## What to return
+
+A table `key | new | why` with the row if you change it (its full new text), or the single line "approved as written". Then `## Flags` with anything you could not verify, or "none".
diff --git a/docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6.md b/docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6.md
new file mode 100644
index 000000000..31bf83ea5
--- /dev/null
+++ b/docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6.md
@@ -0,0 +1,11 @@
+| key | new | why |
+|---|---|---|
+| `media.job.needs_long_class_hi` | `the video is above 1080p, which only the long class converts. submit the same request again with "class": "long"` | “Larger” could describe file size. Gives the exact retry action. |
+| `docs.media.limits.4` | `\| \`video-720p\` \| sources up to 1 GiB \| 10 minutes at or below 1080p \| 15 minutes \| 50 minutes \|` | Matches the A7 condition precisely. |
+| `docs.media.allowance.2` | `Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video up to 1080p counts as 1 media minute, a minute of video above 1080p counts as 2, and a minute of audio counts as 0.1, so 10 minutes of audio is 1 media minute.` | Makes the 1-minute video weight's resolution boundary explicit. |
+| `docs.media.allowance.3` | `A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used at the same weights. If the engine loses the task record, it is charged the full reserved time. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file.` | Fixes the incomplete final sentence and states all charge weights and failure cases. |
+| `docs.plans.media.allowance` | `Set \`media_minutes_month\` to give your account a monthly allowance of media minutes for [media conversion](/docs/media-conversion), shared by its apps. A minute of video up to 1080p counts as 1, a minute of video above 1080p as 2, and a minute of audio as 0.1. A value of 0 means no monthly limit. As a starting point: 30 on a free plan, 600 on a personal plan, 1,200 on a community plan and 12,000 on a business plan, with a pack that adds 1,000. With no catalog, \`account_minutes\` in \`CARLOS_MEDIA_LIMITS\` sets one allowance for every account.` | Makes the resolution boundary explicit while preserving the operator-facing shorthand. |
+
+## Flags
+
+none
\ No newline at end of file
diff --git a/docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6b.md b/docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6b.md
new file mode 100644
index 000000000..4c698126f
--- /dev/null
+++ b/docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6b.md
@@ -0,0 +1,7 @@
+| key | new | why |
+|---|---|---|
+| `docs.media.allowance.3` | A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used: 1 media minute per minute for video, or 0.1 for audio. A failed long video job whose result says the video is above 1080p is charged at 2 media minutes per minute. If the engine loses the task record, the job is charged the full time it was allowed to run, at 1 media minute per minute for video or 0.1 for audio. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file. | Correctly distinguishes ordinary failed jobs, the above-1080p long-video exception, and lost-task-record charges. It also includes the audio weight for lost records. |
+
+## Flags
+
+none
\ No newline at end of file
diff --git a/docs/superpowers/notes/census-claims-media-spike-values.tsv b/docs/superpowers/notes/census-claims-media-spike-values.tsv
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/superpowers/notes/census-proposal-media-spike-values.md b/docs/superpowers/notes/census-proposal-media-spike-values.md
new file mode 100644
index 000000000..986f574d1
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-media-spike-values.md
@@ -0,0 +1,11 @@
+# Census approval: media-spike-values
+
+Ruling `census-ruling-media-spike-values`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+Envelopes re-pinned: `internal/plans`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Seal: `194e88ad9cd7413c93b1181c0ac1e962107039ad84525e065893a8c14cdb3138` → `194e88ad9cd7413c93b1181c0ac1e962107039ad84525e065893a8c14cdb3138`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-media-spike-values.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/media-conversion-copy-deck.md b/docs/superpowers/notes/media-conversion-copy-deck.md
index a05ffc701..bc995a872 100644
--- a/docs/superpowers/notes/media-conversion-copy-deck.md
+++ b/docs/superpowers/notes/media-conversion-copy-deck.md
@@ -81,6 +81,11 @@ object. Placeholders: `source_too_long` and `needs_long_class` take the
limit as `mediaDuration` writes it (`2 hours`, `30 minutes`, `10 minutes`);
`source_dimensions` takes the maximum as `3840x2160`; `source_frame_rate` takes the maximum frames a second. Codes
marked "door copy" reuse the door's message for the same code.
+`source_too_long_hdr` is `source_too_long`'s message when the result's
+source facts say HDR and not above 1080p; its placeholder is that
+maximum (`75 minutes` by default). `needs_long_class_hi` has no placeholder: it is `needs_long_class`'s
+message when the result's source facts are above 1080p, which the short
+video class refuses whatever the length (spec §11 A7).
| Key | Message |
|---|---|
@@ -92,7 +97,9 @@ marked "door copy" reuse the door's message for the same code.
| `media.job.source_dimensions` | `the video is larger than %s` |
| `media.job.source_frame_rate` | `the video has more than %d frames a second` |
| `media.job.source_too_long` | `the file is longer than %s, the maximum for this preset` |
+| `media.job.source_too_long_hdr` | `the HDR video is longer than %s, the maximum for HDR video up to 1080p` (approved, Luna pass 6) |
| `media.job.needs_long_class` | `the file is longer than %s, the most the short class converts. submit it again in the long class` |
+| `media.job.needs_long_class_hi` | `the video is above 1080p, which only the long class converts. submit the same request again with "class": "long"` (approved, Luna pass 6) |
| `media.job.allowance_exceeded` | `this account's media allowance for the month does not cover this file. buy a media pack or move to a larger plan to convert it` |
| `media.job.unreadable` | `the file could not be read. it may be damaged or cut short` |
| `media.job.output_too_large` | `a converted file would be over 5 GB, the maximum for one output` |
@@ -403,6 +410,24 @@ extra message.
## Luna docs pass (Task 11), approved
+**Pass 6, 2026-11-21** (spec §11 A7, the spike's values): brief
+`LUNA-COPY-BRIEF-media-conversion-6.md`, result
+`LUNA-COPY-RESULT-media-conversion-6.md`. Eight rows reviewed, here and
+in "Job errors": five changed and applied, three approved unchanged
+(`media.job.source_too_long_hdr`, `docs.media.limits.6`,
+`docs.media.limits.8a`), no flags. One controller override:
+`docs.media.allowance.3` keeps Luna's text and adds "a video the engine
+never got to read counts as up to 1080p" after "at the same weights",
+since a failed job with no probe facts is charged at weight 1 (A7,
+"Charge"), and "the same weights" alone would say 2 for it.
+
+**Pass 6b, 2026-11-21:** Astra round 1's second P2 found that row still
+overstated failed-job charges (only a long video whose result says above
+1080p is charged at 2). The row was redrafted and reviewed alone: brief
+`LUNA-COPY-BRIEF-media-conversion-6b.md`, result
+`LUNA-COPY-RESULT-media-conversion-6b.md`, one change applied verbatim,
+no flags. It replaces pass 6's text and its override.
+
**Approved 2026-11-17** by the Luna docs pass (brief
`LUNA-DOCS-BRIEF-media-conversion.md`, result
`LUNA-DOCS-RESULT-media-conversion.md`): nine rows changed and applied
@@ -461,7 +486,7 @@ row is applied to the page verbatim.
| `docs.media.door.9` | (table, columns Status / Code / Message: one row per code; every message is its approved deck row verbatim, door copy for job codes as that table says) |
| `docs.media.jobs.1` | ## Job states and errors |
| `docs.media.jobs.2` | A job is `queued` while it waits for a place, `running` while the engine works on it, then `done` or `failed`. A failed job's answer has an `error` with a `code` and a `message`: |
-| `docs.media.jobs.3` | (table, columns Code / Message: one row per code; every message is its approved deck row verbatim, door copy for job codes as that table says) |
+| `docs.media.jobs.3` | (table, columns Code / Message: one row per message; every message is its approved deck row verbatim, door copy for job codes as that table says. `source_too_long` and `needs_long_class` each have two rows, the second for `media.job.source_too_long_hdr` and `media.job.needs_long_class_hi`) |
| `docs.media.jobs.4` | Encrypted files fail as `unsupported_container`. For `needs_long_class`, send the same `POST` again with `"class": "long"`. That is a new job. |
| `docs.media.serving.1` | ## Serving |
| `docs.media.serving.2` | The playlist names the video by the relative URL `video.mp4`, and a player looks for it beside wherever the playlist came from. So serve the playlist from your app's own origin, next to a route for the MP4, for example `/media/<id>/video.m3u8` and `/media/<id>/video.mp4`. Never redirect the playlist. |
@@ -485,19 +510,20 @@ row is applied to the page verbatim.
| `docs.media.limits.1` | ## Limits |
| `docs.media.limits.2` | Each job runs in a class. By default the source's size picks it, and you can ask for `"class": "long"`: |
| `docs.media.limits.3` | \| Preset \| Short class is used for \| Short class converts up to \| Stops a short job after \| Stops a long job after \| |
-| `docs.media.limits.4` | \| `video-720p` \| sources up to 1 GiB \| 10 minutes \| 15 minutes \| 50 minutes \| |
+| `docs.media.limits.4` | \| `video-720p` \| sources up to 1 GiB \| 10 minutes at or below 1080p \| 15 minutes \| 50 minutes \| | (approved, Luna pass 6)
| `docs.media.limits.5` | \| `audio-aac` \| sources up to 256 MiB \| 2 hours \| 10 minutes \| 50 minutes \| |
-| `docs.media.limits.6` | A long job converts up to the preset's maximum. These maximums are provisional and may change: |
+| `docs.media.limits.6` | A video above 1080p converts only in the long class. The short class refuses it with `needs_long_class`, however short it is. A long job converts up to the preset's maximum: | (approved, Luna pass 6)
| `docs.media.limits.7` | \| \| `video-720p` \| `audio-aac` \| |
| `docs.media.limits.8` | \| Length, sources up to 1080p \| 2 hours \| 8 hours \| |
+| `docs.media.limits.8a` | \| Length, HDR sources up to 1080p \| 75 minutes \| \| | (approved, Luna pass 6)
| `docs.media.limits.9` | \| Length, sources above 1080p \| 30 minutes \| \| |
| `docs.media.limits.10` | \| Source size \| 40 GiB \| 10 GiB \| |
| `docs.media.limits.11` | \| Largest picture, frame rate \| 3840x2160, 60 \| \| |
| `docs.media.limits.12` | Each converted file is at most 5 GB. |
| `docs.media.limits.13` | Fair use applies on every deployment. By default an account can have 20 conversions waiting or running, and send 30 a minute with bursts of 10. An account runs up to 2 short jobs and 1 long job at once, and the rest wait their turn. The deployment holds at most 200 waiting jobs. Your operator can change these numbers. |
| `docs.media.allowance.1` | ### The allowance |
-| `docs.media.allowance.2` | Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video counts as 1 media minute and a minute of audio as 0.1, so 10 minutes of audio is 1 media minute. |
-| `docs.media.allowance.3` | A done job is charged for the length of its source. A failed job is charged for the engine time it used, or the full reserved time if the engine loses the task record. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. |
+| `docs.media.allowance.2` | Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video up to 1080p counts as 1 media minute, a minute of video above 1080p counts as 2, and a minute of audio counts as 0.1, so 10 minutes of audio is 1 media minute. | (approved, Luna pass 6)
+| `docs.media.allowance.3` | A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used: 1 media minute per minute for video, or 0.1 for audio. A failed long video job whose result says the video is above 1080p is charged at 2 media minutes per minute. If the engine loses the task record, the job is charged the full time it was allowed to run, at 1 media minute per minute for video or 0.1 for audio. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file. | (approved, Luna pass 6b)
| `docs.media.allowance.4` | As with other monthly limits, the account's owners get a warning at 80% of the limit. At twice the monthly limit, new conversions are refused with `402` until the 1st of the UTC month, or until the account buys a media pack or moves to a larger plan. A job can also fail `allowance_exceeded` when what's left of the allowance won't cover the file. See [Plans](/docs/plans). |
| `docs.media.residency.1` | ## Where conversion runs |
| `docs.media.residency.2` | Conversion runs in your store's region: the engine reads the source from your store and writes the outputs back to it there. A store in a region with no conversion engine is refused with `no_engine_in_region`. It is never converted somewhere else. |
@@ -513,7 +539,7 @@ carries them yet (plan 3 writes it); the pack's price is left out.
| Key | Text |
|---|---|
| `docs.plans.media.packs` | Every account without a plan of its own is on `default_plan`. Packs may only raise counts and sizes: apps and instances, disk, storage, email, bandwidth and media minutes. A ceiling is the most any plan with packs can reach. |
-| `docs.plans.media.allowance` | Set `media_minutes_month` to give your account a monthly allowance of media minutes for [media conversion](/docs/media-conversion), shared by its apps. A minute of video counts as 1 and a minute of audio as 0.1. A value of 0 means no monthly limit. As a starting point: 30 on a free plan, 600 on a personal plan, 1,200 on a community plan and 12,000 on a business plan, with a pack that adds 1,000. With no catalog, `account_minutes` in `CARLOS_MEDIA_LIMITS` sets one allowance for every account. |
+| `docs.plans.media.allowance` | Set `media_minutes_month` to give your account a monthly allowance of media minutes for [media conversion](/docs/media-conversion), shared by its apps. A minute of video up to 1080p counts as 1, a minute of video above 1080p as 2, and a minute of audio as 0.1. A value of 0 means no monthly limit. As a starting point: 30 on a free plan, 600 on a personal plan, 1,200 on a community plan and 12,000 on a business plan, with a pack that adds 1,000. With no catalog, `account_minutes` in `CARLOS_MEDIA_LIMITS` sets one allowance for every account. | (approved, Luna pass 6)
| `docs.plans.media.caps_intro` | Once an hour the console compares each account's usage with its limits, for seven caps: (was "six caps") |
| `docs.plans.media.caps_item` | - media minutes this month. (the item before it, "PDFs rendered this month", now ends with a semicolon) |
| `docs.plans.media.caps_source` | The figures come from what the console already records: its own app list, the monthly usage statements, the daily storage sweep, the mail counts, completed PDF requests and media conversions. A cap whose limit is 0 is skipped. |
diff --git a/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md b/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md
index 8653fb5b9..8bf0f97aa 100644
--- a/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md
+++ b/docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md
@@ -16,10 +16,10 @@
- Execution id: 32 hex characters from 16 bytes of `crypto/rand`. It is RunTask's `startedBy` and its idempotency token.
- Output keys: `derived/<key>/<etag>/<preset>/<execution>/` + `video.mp4`, `video.m3u8`, `poster.jpg` (video) or `audio.mp4`, `audio.m3u8`, `peaks.json` (audio). Result object: `media-results/<execution>.json` in the deployment bucket, read bounded to 64 KiB.
- Classes (§7.1): video short (picked up to 1 GiB): 4 vCPU, 8 GB, deadline 15 min, granted 10 min; video long: 16 vCPU, 32 GB, 50 min, the video maximum; audio short (up to 256 MiB): 1 vCPU, 2 GB, 10 min, 2 h; audio long: 2 vCPU, 4 GB, 50 min, the audio maximum. Ephemeral storage 20 GiB, or source size plus 8 GiB when more.
-- Provisional maximums (settings, `CARLOS_MEDIA_LIMITS`; plan 1's report may change them): video 2 h up to 1080p and 30 min above, 40 GiB; audio 8 h, 10 GiB; 3840x2160, 60 fps.
+- Maximums (settings, `CARLOS_MEDIA_LIMITS`; plan 1's values, spec §11 A7): video 2 h up to 1080p, 75 min for HDR up to 1080p (`video_max_hdr`), 30 min above 1080p, 40 GiB; audio 8 h, 10 GiB; 3840x2160, 60 fps. The short video class takes nothing above 1080p (A7).
- Fair use: 6 short and 2 long tasks in the deployment, 2 short and 1 long per account, counted as rows with a dispatched execution and `task_stopped` false; per account 20 queued or running (429) and 30 submissions a minute with a burst of 10 (429); deployment-wide 200 queued (503).
- Stop grace 30 s. Full bound = `deadline_s` + 30 s. Grant lifetime 1 h. Deadline at most 50 min. Under 3 min of deadline: wait while the account has another execution running, else fail `allowance_exceeded` uncharged.
-- Weights: `video-720p` 1, `audio-aac` 0.1, held as tenths (10 and 1) so every allowance figure is an integer: units = milliseconds × weight-tenths.
+- Weights: `video-720p` 1, video above 1080p 2 (spec §11 A7, Paul's option A), `audio-aac` 0.1, held as tenths (10, 20 and 1) so every allowance figure is an integer: units = milliseconds × weight-tenths. A settled row is charged at the weight its probe measured (`weight_tenths`); a running long video row is reserved at 2.
- Allowance: `media_minutes_month`, monthly, warning at the limit, 402 from `capMessage` at twice the limit, ops accounts exempt, 0 = no limit, `capID` `media`. No catalog: `account_minutes` from `CARLOS_MEDIA_LIMITS`.
- One SQLite connection (`internal/console/store.go:122`): every query inside a transaction goes through its `*sql.Tx`, and no network call (engine, grants, storecfg) is ever made inside a transaction.
- Lock order: the store walk lock (`storeWalks.lock(acct, app, "")`) before any transaction, never the reverse. `mediajobs.Retire` never takes the lock; its caller holds it.
@@ -111,12 +111,12 @@ The deck holds every string Tasks 3 to 11 write. Drafts below; implementers copy
- `type ClassKey struct{ Preset, Class string }`, `func (k ClassKey) String() string` (`"video-720p/short"`).
- `type ClassSpec struct{ Key ClassKey; PickUpTo int64; CPU, MemoryMiB int; Deadline, Granted time.Duration }` (`Granted` 0 = the preset maximum) and `func Class(k ClassKey) (ClassSpec, bool)` with the four rows of Global Constraints.
- `func PickClass(preset, requested string, bytes int64) string`: `requested == "long"`, or bytes over the short row's `PickUpTo`, gives `long`; otherwise `short` (an explicit `short` above the threshold becomes `long`).
- - `func WeightTenths(preset string) int64` (10, 1); `func OutputNames(preset string) []string`; `func ContentType(name string) string` (`video/mp4`, `application/vnd.apple.mpegurl`, `image/jpeg`, `audio/mp4`, `application/json`).
+ - `func WeightTenths(preset string, above1080p bool) int64` (10, 20 above 1080p, audio 1), `func ReserveWeightTenths(k ClassKey) int64` and `func ChargeWeightTenths(k ClassKey, above1080p bool) int64` (spec §11 A7); `func OutputNames(preset string) []string`; `func ContentType(name string) string` (`video/mp4`, `application/vnd.apple.mpegurl`, `image/jpeg`, `audio/mp4`, `application/json`).
- `func JobID(key, etag, preset, class string) string`; `func NewExecutionID() (string, error)`; `func OutputPrefix(key, etag, preset, execution string) string`; `func ResultKey(execution string) string`; `func ValidKey(key string) bool` (non-empty, at most 512 bytes, valid UTF-8, no byte below 0x20 or 0x7f, no `.` or `..` segment, not prefixed `derived/`).
- `const (StopGrace = 30*time.Second; GrantLifetime = time.Hour; GrantMintSlack = 5*time.Minute; EngineRecordRetention = time.Hour; MinDeadline = 3*time.Minute; MaxDeadline = 50*time.Minute; PassEvery = 5*time.Second; FailedRetention = 90*24*time.Hour; MaxResultBytes = 64 << 10; MaxOverrideBytes = 8192; MaxPutBytes = 5 << 30; ScratchFloorGiB = 20; ScratchHeadroom = 8 << 30)`. `EngineRecordRetention` and `MaxOverrideBytes` are plan 1 measurements.
- `func DeadlineSleep(start time.Time, deadline time.Duration, expiry time.Time) time.Duration`: the earlier of `start+deadline` and `expiry−StopGrace`, minus `start` (may be ≤ 0). Plan 3's deadline container and local runner both use it.
- `func EphemeralGiB(sourceBytes int64) int`: 0 when `ceil((bytes+8 GiB)/GiB) <= 20`, else that figure (at most 200).
- - `type Limits struct{ VideoMax, VideoMaxHi, AudioMax time.Duration; VideoBytes, AudioBytes int64; AccountMinutes int64; Short, Long, AccountShort, AccountLong, AccountActive, PerMinute, Burst, Queue int }` and `func ParseLimits(v string) (Limits, error)`: comma-separated `key=value`; keys `video_max`, `video_max_hi`, `video_bytes`, `audio_max`, `audio_bytes`, `account_minutes`, `short`, `long`, `account_short`, `account_long`, `account_active`, `per_minute`, `burst`, `queue`; durations in Go syntax, bytes as an integer or `<n>GiB`/`<n>MiB`; `""` gives `2h,30m,40GiB,8h,10GiB,0,6,2,2,1,20,30,10,200`; unknown, duplicate, negative or zero-count keys are errors; `account_minutes` may be 0.
+ - `type Limits struct{ VideoMax, VideoMaxHDR, VideoMaxHi, AudioMax time.Duration; VideoBytes, AudioBytes int64; AccountMinutes int64; Short, Long, AccountShort, AccountLong, AccountActive, PerMinute, Burst, Queue int }` and `func ParseLimits(v string) (Limits, error)`: comma-separated `key=value`; keys `video_max`, `video_max_hdr` (A7, default 75m), `video_max_hi`, `video_bytes`, `audio_max`, `audio_bytes`, `account_minutes`, `short`, `long`, `account_short`, `account_long`, `account_active`, `per_minute`, `burst`, `queue`; durations in Go syntax, bytes as an integer or `<n>GiB`/`<n>MiB`; `""` gives `2h,30m,40GiB,8h,10GiB,0,6,2,2,1,20,30,10,200`; unknown, duplicate, negative or zero-count keys are errors; `account_minutes` may be 0.
- `func (l Limits) MaxBytes(preset string) int64`, `func (l Limits) Granted(k ClassKey) time.Duration` (the class figure, or the preset maximum for long).
- Error codes as `const Code… = "…"` for every code in the deck's `media.job.*` rows plus `CodeRetired = "retired"`; `var HandlerCodes map[string]bool` (the codes a result object may carry: every `media.job.*` code except `grant_expired`, `deadline_exceeded`, `engine_unavailable`, `engine_lost`, `retired`, `store_changed`, `store_writes_denied`).
- Exit codes: `ExitDone = 0`, `ExitFailed = 1`, `ExitGrantExpired = 75`, `DeadlineExitReached = 0`, `DeadlineExitBadInput = 3`, `DeadlineExitStopped = 143`; container names `ContainerCodec = "codec"`, `ContainerDeadline = "deadline"`; env names `PayloadEnv = "CARLOS_MEDIA_JOB"`, `DeadlineEnv = "CARLOS_MEDIA_DEADLINE_S"`, `ExpiryEnv = "CARLOS_MEDIA_GRANT_EXPIRY"`.
@@ -150,8 +150,10 @@ The deck holds every string Tasks 3 to 11 write. Drafts below; implementers copy
GrantedMS int64 `json:"g"`
GrantedBy string `json:"gb"` // "class" | "allowance"
MaxMS int64 `json:"d"`
+ MaxHDRMS int64 `json:"dr,omitempty"` // HDR video up to 1080p, spec §11 A7; 0 is MaxMS
MaxHiMS int64 `json:"dh"` // video sources above 1080p; 0 for audio
OutputBytes int64 `json:"o"`
+ Above1080pNeedsLong bool `json:"hl,omitempty"` // the short video class, spec §11 A7
}
type Payload struct {
V int `json:"v"`
diff --git a/docs/superpowers/plans/2026-11-16-media-conversion-plan-3-engine.md b/docs/superpowers/plans/2026-11-16-media-conversion-plan-3-engine.md
index 3b9f569cc..994be6449 100644
--- a/docs/superpowers/plans/2026-11-16-media-conversion-plan-3-engine.md
+++ b/docs/superpowers/plans/2026-11-16-media-conversion-plan-3-engine.md
@@ -11,7 +11,7 @@
## Global Constraints
- Plan 2's Global Constraints apply. This plan consumes `internal/media` exactly as plan 2 Task 1 declares it: `Payload`, `Transfers`, `Transfer`, `JobLimits`, `Result`, `SourceFacts`, `OutputFact`, `ParseResult`, the exit codes, `ContainerCodec`/`ContainerDeadline`, `PayloadEnv`/`DeadlineEnv`/`ExpiryEnv`, `OutputNames`, `ContentType`, `HandlerCodes`, `StopGrace`, `MaxPutBytes`, `MaxResultBytes`, `MaxOverrideBytes`, `TaskDefinition`, `CheckTaskDefinition`, `Engine`, `Grants`, `RunRequest`, `Task`, `Rejected`, `Misconfigured`, `ImageInfo`. No new shared name is defined here.
-- Plan 1's report (`docs/superpowers/reviews/2026-11-16-media-conversion-spike.md`) must be committed and Paul must have confirmed it before Task 4 starts. Its figures replace the provisional constants named "spike" below; if a proof failed, the spec amendment it lists lands first.
+- Plan 1's report (`docs/superpowers/reviews/2026-11-16-media-conversion-spike.md`) must be committed and Paul must have confirmed it before Task 4 starts. Its figures replace the provisional constants named "spike" below; if a proof failed, the spec amendment it lists lands first. Done: the report's values and amendments 1 to 3 are spec §11 A7 (branch `media-spike-values`, 2026-11-21).
- The task: two containers from one arm64 image pinned by digest, both essential, `stopTimeout` 30 each, `codec` `dependsOn` `deadline` `START`, no task role, no `pidMode`, no volume shared between them, user `65534:65534`, read-only root, every capability dropped, `enableExecuteCommand` false. `codec` alone mounts the volume `scratch` at `/scratch`. The image holds `/scratch` owned by `65534:65534`, mode `0700`, and declares it a volume in its config, so the Fargate bind mount there is writable by the codec's user (ECS bind mounts are otherwise root-owned `0755`); plan 1 Task 4 Step 4 proves it.
- Every path the handler and its argument builders use is under `Config.Scratch` (`<scratch>/in/source`, `<scratch>/out/<name>`, `<scratch>/tmp`), from `CARLOS_MEDIA_SCRATCH`, default `/scratch`. `/scratch/…` below means that default.
- Deadline container: sleep until the earlier of its start plus `CARLOS_MEDIA_DEADLINE_S` and `CARLOS_MEDIA_GRANT_EXPIRY` less 30 s; exit `DeadlineExitReached` (0) at once if that has passed; `DeadlineExitStopped` (143) on SIGTERM; `DeadlineExitBadInput` (3) on bad input, at once.
@@ -83,7 +83,7 @@ Expected; `make census-card` decides. In scope: every new file under `infra/` (`
**Interfaces:**
- Produces: `func runChild(ctx context.Context, cfg Config, name string, args []string, dir string) (stderrTail []byte, err error)` (Linux: the handler sets `PR_SET_CHILD_SUBREAPER` at start; the child gets its own process group and `Pdeathsig: SIGKILL`; when it exits or the context ends, `kill(-pgid, SIGKILL)`, then repeatedly kill every process whose parent is the handler (from `/proc/*/stat`) and `wait4(-1, WNOHANG)` until `ECHILD`, at most 5 s, else `engine_failed`; nothing reads `/scratch/out` before it returns; a non-zero exit is `unreadable`; the last 64 KiB of stderr is kept for the task's log and never holds a transfer; `procs_other.go` returns an error, as the handler runs only on Linux); `func sniff(head []byte, preset string) (demuxer string, err error)`; `type probeFacts struct{ VideoIndex, AudioIndex int; Width, Height, Rotation int; FPS float64; HDR bool; DolbyVisionProfile int; VideoCodec, AudioCodec string; Channels int; DurationMS int64 }` (`-1` for an absent stream); `func probe(ctx context.Context, cfg Config, demuxer string) (probeFacts, error)`; `func parseProbe(b []byte) (probeFacts, error)`; `func check(f probeFacts, preset string, l media.JobLimits) error` (a `jobError` or nil).
-- Rules: streams with `disposition.attached_pic` 1 are skipped; the first remaining video and first audio stream are taken (`audio-aac`: audio only); rotation from the display matrix side data, else the `rotate` tag; FPS from `avg_frame_rate`, `r_frame_rate` only when the average is `0/0`; HDR when `color_transfer` is `smpte2084` or `arib-std-b67`, or Dolby Vision side data is present; duration from `format.duration`, else the longest stream duration, else a second ffprobe pass over the chosen stream's packets (`-show_entries packet=pts_time,duration_time -of csv=p=0`) taking the largest `pts+duration`, else `unreadable`. Checks in spec §6's order: `no_video`/`no_audio`; video codec not `h264`, `hevc`, `vp8`, `vp9`, `av1` → `unsupported_video_codec`; audio codec not `aac`, `opus`, `vorbis`, `mp3`, `flac` or `pcm_*` → `unsupported_audio_codec`; a side over 4096 or more than 3840·2160 pixels → `source_dimensions`; FPS over 60 → `source_frame_rate`; duration over `MaxHiMS` (video above 1080p: longer side over 1920 or shorter side over 1080) or `MaxMS` → `source_too_long`; over `GrantedMS` → `needs_long_class` when `GrantedBy` is `class`, else `allowance_exceeded`; Dolby Vision profile 5 → `unsupported_hdr` only when the spike report sets `refuseDolbyVision5 = true` (spike; default false: decoded as HEVC and tone-mapped); probe failure or timeout → `unreadable`.
+- Rules: streams with `disposition.attached_pic` 1 are skipped; the first remaining video and first audio stream are taken (`audio-aac`: audio only); rotation from the display matrix side data, else the `rotate` tag; FPS from `avg_frame_rate`, `r_frame_rate` only when the average is `0/0`; HDR when `color_transfer` is `smpte2084` or `arib-std-b67`, or Dolby Vision side data is present; duration from `format.duration`, else the longest stream duration, else a second ffprobe pass over the chosen stream's packets (`-show_entries packet=pts_time,duration_time -of csv=p=0`) taking the largest `pts+duration`, else `unreadable`. Checks in spec §6's order: `no_video`/`no_audio`; video codec not `h264`, `hevc`, `vp8`, `vp9`, `av1` → `unsupported_video_codec`; audio codec not `aac`, `opus`, `vorbis`, `mp3`, `flac` or `pcm_*` → `unsupported_audio_codec`; a side over 4096 or more than 3840·2160 pixels → `source_dimensions`; FPS over 60 → `source_frame_rate`; duration over `MaxHiMS` (video above 1080p: longer side over 1920 or shorter side over 1080), else `MaxHDRMS` (HDR video; 0 is `MaxMS`, held to it; spec §11 A7) or `MaxMS` → `source_too_long`; video above 1080p with `Above1080pNeedsLong` (the short video class, A7) → `needs_long_class`; over `GrantedMS` → `needs_long_class` when `GrantedBy` is `class`, else `allowance_exceeded`; Dolby Vision profile 5 → `unsupported_hdr` only when the spike report sets `refuseDolbyVision5 = true` (spike; default false: decoded as HEVC and tone-mapped); probe failure or timeout → `unreadable`.
- [ ] **Step 1: Write the failing tests:** `TestSniffTable` (each family for each preset; `#EXTM3U`, `<?xml`, a PDF, 0 bytes and an MP3 under `video-720p` → `unsupported_container`); `FuzzSniff` (never panics; never answers a family whose magic is absent); `TestParseProbeFixtures` (each fixture's facts); `TestFrameRateUsesTheAverage` (Review Focus 2); `TestDurationFromPacketsWhenTheHeaderHasNone` (Review Focus 3, the second pass driven by a fake ffprobe from Task 7's helper); `TestAttachedPictureIsNotVideo` (Review Focus 4); `TestCheckOrder` (a source failing two checks reports the earlier); `TestLyingDurationIsTooLong`; `TestBombIsDimensions`; `FuzzParseProbe` (arbitrary bytes never panic and never yield facts that pass `check` with a negative size or duration); `TestRunChildKillsEscapedDescendants` (Linux: a helper child that forks a grandchild which calls `setsid` and sleeps: after `runChild` returns, neither process exists); `TestProbeTimeoutIsUnreadable` (a fake ffprobe that sleeps past a 100 ms test timeout).
- [ ] **Step 2:** Run `go test ./internal/mediahandler/ -run 'TestSniff|TestParseProbe|TestFrameRate|TestDurationFromPackets|TestAttachedPicture|TestCheckOrder|TestLying|TestBomb|TestRunChild|TestProbeTimeout' -count=1`. Expected: FAIL.
@@ -95,6 +95,8 @@ Expected; `make census-card` decides. In scope: every new file under `infra/` (`
### Task 4: Handler: the encodes, the playlist and the child processes
+**No longer provisional** (spec §11 A7, 2026-11-21): the spike set `x264Preset` to `medium` and kept `x264CRF` 23; the muxer flags and box sequence held on arm64. The fixtures in `testdata/fmp4` were encoded at `veryfast` and kept; `TestMuxerArgsMatchTheFixtures` accepts that one recorded difference (`fixturePreset`). Only the HDR chain's colours wait on Paul's Safari check.
+
Depends on plan 1 Task 3 Step 4: the muxer rules and the parser's accepted box sequence are settled by the fixtures Debian 13's ffmpeg made there, and this task's parser tests run only against those.
**Files:**
@@ -102,7 +104,7 @@ Depends on plan 1 Task 3 Step 4: the muxer rules and the parser's accepted box s
**Interfaces:**
- Produces: `func targetSize(w, h, rotation int) (ow, oh int)` (swap for ±90/270; box `(bw, bh)` = 1280x720 when `w >= h`, else 720x1280; integer arithmetic only: inside the box unchanged; else when `w·bh > h·bw` (width-limited) `ow = bw, oh = h·bw/w`, otherwise `oh = bh, ow = w·bh/h`, with integer division; then each side rounded down to even, at least 2); `func videoArgs(cfg Config, f probeFacts, p media.Payload, demuxer string) []string`; `func posterArgs(cfg Config, f probeFacts, p media.Payload, demuxer string) []string`; `func audioArgs(cfg Config, f probeFacts, p media.Payload, demuxer string, gainDB float64) []string` (every path from `cfg.Scratch`); `type fragment struct{ Offset, Length int64; DurationS float64 }`; `func readFMP4(r io.ReaderAt, size int64) (initLen int64, frags []fragment, durationMS int64, err error)` (top-level `ftyp`, `moov` then `moof`/`mdat` pairs, which is what these arguments produce with `skip_trailer`; if plan 1's Debian-made fixtures show another top-level box (a `free`, an `mfra`), the parser accepts exactly the sequence plan 1's report records and no other; the timescale from the first video track's `mdhd`, else the first track's; each fragment's duration from consecutive `tfdt`, the last from its `trun` sample durations; any other box order, overlap, a size past the file or over 1,000,000 fragments is an error); `func writePlaylist(w io.Writer, name string, initLen int64, frags []fragment) error`. Every encode runs through Task 3's `runChild`.
-- `videoArgs` (in order): the Global Constraints input flags; `-map 0:<v>`, `-map 0:<a>` when there is audio; `-sn -dn -map_metadata -1 -map_chapters -1 -t <GrantedMS as seconds, 3 decimals>`; `-vf scale=<ow>:<oh>:flags=bicubic,format=yuv420p` for SDR, or `-vf scale=<ow>:<oh>:flags=bicubic,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p` for HDR (spike: the chain and operator plan 1 confirms); `-c:v libx264 -profile:v high -preset <x264Preset> -crf <x264CRF> -maxrate 2500k -bufsize 5000k -pix_fmt yuv420p -fpsmax 30 -force_key_frames expr:gte(t,n_forced*2) -sc_threshold 0`; audio `-c:a aac -b:a 128k -ac 2 -ar 48000` or `-an`; `-f mp4 -movflags +frag_keyframe+empty_moov+default_base_moof+skip_trailer -min_frag_duration 4000000 /scratch/out/video.mp4` (fragments start at the first keyframe at least 4 s on; `skip_trailer` drops the `mfra` trailer). `x264Preset = "veryfast"` and `x264CRF = 23` (spike).
+- `videoArgs` (in order): the Global Constraints input flags; `-map 0:<v>`, `-map 0:<a>` when there is audio; `-sn -dn -map_metadata -1 -map_chapters -1 -t <GrantedMS as seconds, 3 decimals>`; `-vf scale=<ow>:<oh>:flags=bicubic,format=yuv420p` for SDR, or `-vf scale=<ow>:<oh>:flags=bicubic,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p` for HDR (spike: the chain and operator plan 1 confirms); `-c:v libx264 -profile:v high -preset <x264Preset> -crf <x264CRF> -maxrate 2500k -bufsize 5000k -pix_fmt yuv420p -fpsmax 30 -force_key_frames expr:gte(t,n_forced*2) -sc_threshold 0`; audio `-c:a aac -b:a 128k -ac 2 -ar 48000` or `-an`; `-f mp4 -movflags +frag_keyframe+empty_moov+default_base_moof+skip_trailer -min_frag_duration 4000000 /scratch/out/video.mp4` (fragments start at the first keyframe at least 4 s on; `skip_trailer` drops the `mfra` trailer). `x264Preset = "medium"` and `x264CRF = 23` (the spike's values, spec §11 A7; `veryfast` before it).
- `posterArgs`: `-ss <1.000, or duration/2 when under 2 s>` before `-i`, the same input flags and video filter, `-frames:v 1 -q:v 3 /scratch/out/poster.jpg`.
- `audioArgs`: `-map 0:<a> -vn -sn -dn -map_metadata -1 -map_chapters -1 -t <granted>`, `-af aformat=channel_layouts=<mono|stereo>:sample_rates=48000,volume=<gain>dB`, `-c:a aac -b:a <64k|128k>`, then `-f mp4 -movflags +empty_moov+default_base_moof+skip_trailer -frag_duration 4000000 /scratch/out/audio.mp4` (audio has no video keyframe to cut at, so the fragment duration itself is the trigger).
- Playlist: `#EXTM3U`, `#EXT-X-VERSION:7`, `#EXT-X-TARGETDURATION:<ceil(max)>`, `#EXT-X-PLAYLIST-TYPE:VOD`, `#EXT-X-INDEPENDENT-SEGMENTS`, `#EXT-X-MAP:URI="<name>",BYTERANGE="<initLen>@0"`, per fragment `#EXTINF:<3 decimals>,`, `#EXT-X-BYTERANGE:<len>@<off>`, `<name>`, then `#EXT-X-ENDLIST`. Written by Go, never by ffmpeg. `SourceFacts.DurationMS` is `readFMP4`'s duration (what was converted).
@@ -132,6 +134,8 @@ Depends on plan 1 Task 3 Step 4: the muxer rules and the parser's accepted box s
### Task 6: Handler: collecting and uploading outputs, and the result **[Astra: security gate]**
+**No longer provisional** (spec §11 A7, 2026-11-21): the spike ran the result path on every class. The result's `SourceFacts` gain `hdr` (omitted when false), which the console reads to name the HDR maximum.
+
**Files:**
- Create: `internal/mediahandler/collect_linux.go`, `collect_other.go`, `upload.go`, `result.go`, `collect_test.go`, `upload_test.go`, `run_test.go`
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md b/docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md
new file mode 100644
index 000000000..b89371c5c
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md
@@ -0,0 +1,21 @@
+# Astra findings: media-spike-values, round 1 of 3
+
+Reviewer: gpt-6-astra, reasoning effort high, read-only. Brief: `CODEX-REVIEW-BRIEF-media-spike-values.md`. Reviewed tip 2d5eb9f5cfbf444ef7450434427d40181a276c8a. The report below is the reviewer's final message, unedited.
+
+---
+
+No P1 findings.
+
+- **P2 — Check 7: the simulation permits incorrect weights on retired settlements.** [invariants_test.go:382](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/sim/mediajobs/invariants_test.go:382) accepts weight 1 for every `retired` row, including one retired **after** its above-1080p result was read. That case must retain weight 2, as [track.go:248](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/mediajobs/track.go:248) currently does. A regression charging that fallback at weight 1 would pass this checker. The simulation records facts when the codec writes them ([world_test.go:480](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/sim/mediajobs/world_test.go:480)), so it cannot distinguish the two retirement cases. **Fix:** record successful result reads and add witnesses for retirement before and after reading a 4K result, requiring weights 1 and 2 respectively. **Fault family:** I3—settlement weight must reflect the source facts actually read.
+
+- **P2 — Check 9: the allowance copy overstates failed-job charges.** [media-conversion.md:220](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/docs/site/media-conversion.md:220), repeated in `docs.media.allowance.3`, says failed above-1080p video uses weight 2 unless the engine never read it. An honest short-class job probes a 4K source, refuses it with `needs_long_class`, and charges weight 1: [media.go:122](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/media/media.go:122) caps the weight by class. Likewise, the engine may read a source but leave no result for the console; that also charges weight 1. **Fix:** describe both exceptions explicitly: short-class failures use weight 1, and video settlements without source facts read by the console use weight 1. Update the page and deck together. **Fault family:** the published billing explanation must match settlement accounting.
+
+No P3 findings.
+
+Wire compatibility: mixed versions break video conversions. A new console sends `dr`/`hl`, which an old image’s strict decoder rejects; a new image can emit `hdr`, which an old console rejects. The new reader accepts older results without `hdr`. These mixed-version failures are not stated in A7; they are acceptable under the brief’s premise that no deployment runs the engine yet, provided initial activation pairs the console and image from this release.
+
+Validation: `git diff --check` passed. Targeted Go tests were blocked by the read-only filesystem before execution; the reported simulation runs were not independently reproduced. GOCACHE remained unset.
+
+Census verdict — **approve** `internal/plans`: [catalog.go:54](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/plans/catalog.go:54) changes only a comment, introducing no root reads or weakened checks. Independently recomputed the envelope hash; it matches [the overlay at line 3](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/provision/testdata/plan14-root-reads-media-spike-values.tsv:3).
+
+**READY AFTER FIXES**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-spike-values.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-spike-values.md
new file mode 100644
index 000000000..ca872829e
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-media-spike-values.md
@@ -0,0 +1,58 @@
+# Review brief: branch `media-spike-values` (the media spike's values and above-1080p minutes), round 1 of 3
+
+Repo carlos/platform, branch `media-spike-values`, commit named in the reviewer's prompt.
+Under review: the diff `origin/main..media-spike-values` (base bddf7b1e).
+Authorities: `docs/superpowers/specs/2026-11-16-video-conversion-design.md` (rev 8, merged; §5 to §7 and §11), and its new amendment A7 on this branch, which is the change under review. Plans `docs/superpowers/plans/2026-11-16-media-conversion-plan-2-console.md` and `-plan-3-engine.md` (merged). The measurements come from the spike report, `docs/superpowers/reviews/2026-11-16-media-conversion-spike.md` on branch `media-spike-report` (commit 8387e4be, being merged; a report of measurements, not a design): read it with `git show 8387e4be:docs/superpowers/reviews/2026-11-16-media-conversion-spike.md`, its "Values for plans 2 and 3" table and "Spec amendments". Do not review against any other unmerged branch.
+
+You are an independent reviewer. Read A7, then the code, and check every claim against the code. This change touches billing: the allowance's charge, reservation and refusal.
+
+## Fixed: do not re-argue
+
+- Paul's ruling, 2026-11-20 (spec §11 A7): option A, a minute of video above 1080p counts twice. Weights: video up to 1080p 1, above 1080p 2, audio 0.1. Report only mechanisms that fail to honour it.
+- The spike's values: x264 `medium`; HDR video up to 1080p at most 75 minutes; SDR up to 1080p 2 hours; above 1080p 30 minutes; the short video class takes nothing above 1080p.
+- Reserving a long video at weight 2 before the probe (nothing is known of the picture yet). The consequence, half the grant near twice the limit, is accepted in A7.
+- A row that settles with no source facts read (no result, retired before its result was read, `engine_lost`) is charged at weight 1. A tenant who compromises its own codec can under-report its picture, as A2 already accepts for duration.
+- Out of scope, known and pre-existing: ECS's `stoppedAt` lands 23 to 35 s after the last container dies, so `charged_ms` can pass a row's full bound by that much (A7 "Still open"). Do not raise it against this branch unless the weight makes it worse.
+- The fMP4 fixtures stay as the spike encoded them at `veryfast`; `TestMuxerArgsMatchTheFixtures` accepts that one recorded difference (`fixturePreset`). Check the exception is as narrow as it claims, not whether a re-encode would be nicer.
+
+## What to check
+
+1. **Charge never passes reservation (the money invariant).** `media.ReserveWeightTenths`, `media.ChargeWeightTenths` (`internal/media/media.go`), `chargeWeight` and every charged settlement in `internal/mediajobs/track.go` (`commitDone` and its retired fallback, `failStop`, `lostAfterRetention`), `usageSQL`, `chargeWeightSQL` and `reserveWeightSQL` (`internal/mediajobs/metering.go`), and `fit` (`internal/mediajobs/dispatch.go`). Can any path settle a row at a weight above the weight it was reserved at, or reserve less than the most the row can be charged? Is `weight_tenths` written in the same transaction as the charge (I2), and never on a row it should not touch?
+2. **One weighted figure everywhere.** The door's 402 at twice the limit (`mediaFairUse`, `internal/console/apimedia.go`), the hourly cap measure (`internal/console/planmeasure.go`), the billing page and notices, and dispatch's `R` all read `usage`. Is there any other reader of `media_jobs` charges that still assumes one video weight (grep `charged_ms`, `source_ms`, `media_jobs`)?
+3. **Schema migration.** `weight_tenths` in `mediajobs.Schema` and `mediajobs.Migrations`, applied in `internal/console/store.go`'s additive list. A console upgraded over an existing table: are rows settled before the column charged as they were? Is the fallback in `chargeWeightSQL` sound for a settled uncharged row (weight 0)?
+4. **The short class refuses above 1080p.** `ClassSpec.TakesAbove1080p`, `JobLimits.Above1080pNeedsLong` set in `launch`, and `check` in `internal/mediahandler/probe.go` (order: after `source_too_long`, before the granted duration). Can a short video job convert a source above 1080p with an honest codec? Is the refusal the spec's existing mechanism (`needs_long_class`) rather than a new one?
+5. **HDR maximum.** `Limits.VideoMaxHDR`/`MaxHDR`, `video_max_hdr` in `ParseLimits`, `JobLimits.MaxHDRMS` (0 from an older console means `MaxMS`), the probe's HDR test, `SourceFacts.HDR`, and `mediaJobMessage`'s choice of `source_too_long_hdr` and `needs_long_class_hi` (`internal/console/media_copy.go`). Does the refusal name the maximum the handler actually applied, in every case (HDR above 1080p, HDR with `video_max_hdr` above `video_max`, an older image's result without `hdr`)?
+6. **Wire compatibility.** The payload (`hl`, `dr`) and the result (`hdr`) gain fields; both sides decode strictly (`DisallowUnknownFields`). The image and the console roll together at release (plan 3, image rebuilt every release). Say whether any order of rolling a console and an image breaks conversions in a way that is not stated, and whether that is acceptable while no deployment runs the engine yet.
+7. **The simulation** (`internal/sim/mediajobs`). The weights are stated in the checker from the spec, not taken from the job table. Does I8 still check every money bound with the new weight, and does the new I3 (weight) check catch an undercharge? Are the new events' floors honest? Results: 200 seeds pass; 5,000 seeds pass (123 above-1080p charges, 148 capped short-class reports); two mutations (never charge weight 2; reserve a long video at 1) were caught by I3 and I8.
+8. **Census.** `make census-card` shows only the `internal/plans` envelope re-pinned, by a comment in `internal/plans/catalog.go`. The card is `docs/superpowers/notes/census-proposal-media-spike-values.md`. Give a verdict on that envelope by the rules in the card.
+9. **Docs and copy match the code.** `docs/site/media-conversion.md` (limits, error table, allowance), `docs/site/plans.md`, and the deck rows approved in Luna pass 6 (`docs/superpowers/notes/LUNA-COPY-RESULT-media-conversion-6.md`; one controller override recorded in the deck). Flag any sentence that says something the code does not do.
+
+## 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 a census verdict line for the `internal/plans` envelope:
+approve or reject, citing the lines you read. 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.
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 921be6468..6e8ffdbff 100644
--- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md
+++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md
@@ -617,6 +617,7 @@ checks, exiting before any encoding:
| a side over 4096, or more pixels than 3840x2160 | `source_dimensions` |
| over 60 frames a second | `source_frame_rate` |
| longer than the preset's maximum duration (§7.1) | `source_too_long` |
+| short video class: a source above 1080p, whatever its length (§11 A7) | `needs_long_class` |
| short class: longer than the class's granted duration (§7.1). The message says to resubmit with `"class": "long"` | `needs_long_class` |
| longer than the allowance granted to this job (§7.3) | `allowance_exceeded` |
| probe fails or exceeds 60 s | `unreadable` |
@@ -664,16 +665,18 @@ about the source but its size **(astra R6-4)**.
| `audio-aac` | short | source up to 256 MiB, class not given | 1 vCPU, 2 GB | 10 min | 2 hours |
| `audio-aac` | long | larger source, or `"class": "long"` | 2 vCPU, 4 GB | 50 min | the audio maximum |
-A short job whose source turns out longer than its granted duration exits at
+A short job whose source turns out longer than its granted duration, or a
+short video job whose source is above 1080p (§11 A7), exits at
the probe with `needs_long_class`, and the app submits it again with
`"class": "long"`: a new job, since requeue was cut. Ephemeral storage is 20
GiB, or the source size plus 8 GiB when that is more.
-**Provisional maximums (estimates; the spike sets the final values).**
+**Maximums (the spike's values, §11 A7; estimates before it).**
| | `video-720p` | `audio-aac` |
|---|---|---|
| Duration, sources up to 1080p | 2 hours | 8 hours |
+| Duration, HDR sources up to 1080p (A7) | 75 minutes | |
| Duration, sources above 1080p | 30 minutes | |
| Source size | 40 GiB | 10 GiB |
| Dimensions, frame rate | 3840x2160, 60 | |
@@ -710,7 +713,9 @@ uses one per-account figure from `CARLOS_MEDIA_LIMITS` in its place.
**What is charged.** Every figure is in allowance minutes and is a query over
`media_jobs`. `w` is the preset's weight: `video-720p` 1, `audio-aac` 0.1
-**(paul R-A, decision 7)**.
+**(paul R-A, decision 7)**. Since §11 A7, video above 1080p weighs 2: a
+settled row is charged at the weight its probe measured, and a running long
+video row is reserved at 2.
- A `done` job: `w` times its source duration.
- Any other settled execution: `w` times its engine time. `charged_ms` is
@@ -745,7 +750,8 @@ Outputs count as the tenant's storage (roadmap ruling 6).
### 7.4 Cost and the spike
-All figures here are **estimates** until the spike reports.
+All figures here are **estimates** from before the spike. Its measured
+values are in §11 A7 and the spike report.
- **Time.** A task takes 30 to 60 seconds to start. A three-minute 1080p30
phone clip then converts in 30 to 90 seconds on 4 vCPUs. On 16 vCPUs,
@@ -1000,6 +1006,77 @@ the outputs. Store destroy gains the refusal of §5.3.
tracked again without a restart. Settings errors still stop the boot. A
settings error found only on a retry, once the console is already up,
leaves conversion off and is logged once.
+- **A7, spike values and above-1080p minutes** (spike 2026-11-20; Paul
+ chose option A). The dev spike measured the engine on Fargate arm64:
+ `docs/superpowers/reviews/2026-11-16-media-conversion-spike.md`, its
+ "Values for plans 2 and 3" table and its "Spec amendments" 1 to 3.
+ Where these values differ from §6, §7.1, §7.3, §7.4 or decision 6, they
+ override them.
+ - **Preset.** x264 encodes at `medium`, the slowest preset that runs at
+ least 3 times real time on long-class 1080p (`veryfast` 10.35,
+ `faster` 5.65, `medium` 5.85). The CRF stays 23.
+ - **HDR maximum.** 1080p HDR converts at 2.71 times real time on the
+ long class, against 5.85 for SDR. The plan's rule (the class's 40
+ minutes less a 31.7 s start and a 40 GiB download at 95.3 MB/s, times
+ the speed) gives 86.6 minutes, so HDR video up to 1080p converts up to
+ 75 minutes (`video_max_hdr`, held to `video_max`). SDR up to 1080p
+ keeps 2 hours, and above 1080p keeps 30 minutes whatever the
+ transfer. The probe already tells HDR from `color_transfer` and Dolby
+ Vision side data. The result's source facts now carry `hdr`, so the
+ console's `source_too_long` message names the HDR maximum.
+ - **Short-class ceiling.** At 4 vCPU the short video class converts 4K
+ HDR at 0.27 times real time and 4K SDR at 0.71, so not even 5 minutes
+ of 4K HDR fits its budget. Only the long video class takes a source
+ above 1080p. On the short class the codec answers `needs_long_class`
+ for one, after `source_too_long` and before the granted duration,
+ through the payload's `Above1080pNeedsLong`, and the console's message
+ names the picture size rather than a length. Up to 1080p the short
+ class still converts 10 minutes.
+ - **Weights (Paul's option A, 2026-11-20).** A minute of video above
+ 1080p counts twice against the allowance: video up to 1080p 1, above
+ 1080p 2, audio 0.1 (in tenths 10, 20 and 1). One minute of 4K HDR costs
+ about 1 cent of engine time (0.98 cents on the long class at `medium`,
+ 1.07 on the short), against decision 6's 0.6. 1080p SDR costs about
+ 0.2 cents, 1080p HDR 0.27 to 0.43, 4K SDR 0.36 to 0.46. The weight
+ applies everywhere the allowance is read:
+ - **Charge.** A settled row is charged at the weight of the source
+ its probe measured, from the dimensions in a result the console
+ parsed, and stores it as `weight_tenths` in the transaction that
+ settles it. Above 1080p counts only on the long video class. A row
+ that settles with no source facts read (no result, retired before
+ its result was read, or `engine_lost`) is charged at the weight up
+ to 1080p.
+ - **Reservation.** Before the probe nothing is known of the picture,
+ so a long video row is reserved, and its grant and deadline fitted,
+ at weight 2; a short video row at 1, as it never converts a source
+ above 1080p; audio at 0.1. A charge weight is never above its
+ class's reservation weight, so §7.3's bound still holds: a row's
+ reservation is the most it can cost. Near twice its limit, an
+ account's long video job is therefore granted half the minutes it
+ would get at weight 1.
+ - **Door and metering.** The 402 at twice the limit, the hourly cap
+ measure, the billing page and the notices all read the same
+ weighted figure.
+ - **Residual, as A2.** A tenant who compromises the codec in its own
+ job can report its source as 1080p or less and pay weight 1 for that
+ job. It gains nothing else, and every other bound holds.
+ - **Mixed versions.** The payload gains `hl` and `dr` and the result
+ gains `hdr`, and both sides decode strictly, so an older image
+ refuses a newer console's video payloads and an older console
+ refuses a newer image's HDR results. No deployment runs the engine
+ yet; console and image are rolled together from the release that
+ carries A7 (plan 3: every release builds the image), and a newer
+ console reads an older image's results.
+ - **Unchanged by the spike:** `video_bytes` 40 GiB, `video_max_hi` 30
+ minutes, `audio_max` 8 hours, `audio_bytes` 10 GiB, the class rows,
+ `codecHeadroomDB` 0.5, `refuseDolbyVision5` false (no profile 5 sample
+ was supplied), `EngineRecordRetention` 1 hour, `MaxOverrideBytes`
+ 8,192.
+ - **Still open from the report:** the HDR colours and the playback
+ matrix wait on Paul's Safari checks. ECS records a task STOPPED 23 to
+ 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.
## 12. Decisions for Paul
diff --git a/internal/console/apimedia_test.go b/internal/console/apimedia_test.go
index f0ec2710e..be5ea48a4 100644
--- a/internal/console/apimedia_test.go
+++ b/internal/console/apimedia_test.go
@@ -3,6 +3,7 @@ package console
import (
"context"
"encoding/json"
+ "fmt"
"net/http"
"strings"
"sync"
@@ -644,6 +645,43 @@ func TestGetFailedMessageComesFromTheDeck(t *testing.T) {
r.job.Error.Message != "the file is longer than 10 minutes, the most the short class converts. submit it again in the long class" {
t.Fatalf("needs_long_class: %s", r.raw)
}
+ // An HDR source up to 1080p over its own maximum (spec §11 A7): the
+ // handler's failure result for an 80-minute HLG 1080p source, named
+ // with the HDR maximum, not the SDR one.
+ hdrProbe := []byte(`{"streams":[{"index":0,"codec_type":"video","codec_name":"hevc","width":1920,"height":1080,` +
+ `"avg_frame_rate":"30/1","r_frame_rate":"30/1","color_transfer":"arib-std-b67"}],"format":{"duration":"4800.000000"}}`)
+ hdrLong, refused := mediahandler.ProbeFailure("0123456789abcdef0123456789abcdef", media.PresetVideo720p, media.JobLimits{
+ SourceBytes: l.VideoBytes, GrantedMS: l.VideoMax.Milliseconds(), GrantedBy: "class",
+ MaxMS: l.VideoMax.Milliseconds(), MaxHDRMS: l.MaxHDR().Milliseconds(), MaxHiMS: l.VideoMaxHi.Milliseconds(), OutputBytes: media.MaxPutBytes,
+ }, hdrProbe)
+ if !refused || hdrLong.Error != media.CodeSourceTooLong {
+ t.Fatalf("the handler's probe check answered %+v, refused %v", hdrLong, refused)
+ }
+ fail("source_too_long", hdrLong)
+ if tmpl := mediaCopy["media.job.source_too_long_hdr"]; tmpl == "" {
+ t.Fatal("the deck has no media.job.source_too_long_hdr row")
+ } else if r := f.get(sub.job.ID); r.job.Error == nil || r.job.Error.Message != fmt.Sprintf(tmpl, "75 minutes") {
+ t.Fatalf("source_too_long for HDR: %s", r.raw)
+ }
+ // A short-class job whose source is above 1080p (spec §11 A7): the
+ // handler's own failure result for a 30-second 2160p source, and the
+ // deck's row that names the picture size, not a length.
+ hiProbe := []byte(`{"streams":[{"index":0,"codec_type":"video","codec_name":"hevc","width":3840,"height":2160,` +
+ `"avg_frame_rate":"30/1","r_frame_rate":"30/1"}],"format":{"duration":"30.000000"}}`)
+ hi, refused := mediahandler.ProbeFailure("0123456789abcdef0123456789abcdef", media.PresetVideo720p, media.JobLimits{
+ SourceBytes: l.VideoBytes, GrantedMS: (10 * time.Minute).Milliseconds(), GrantedBy: "class",
+ MaxMS: l.VideoMax.Milliseconds(), MaxHiMS: l.VideoMaxHi.Milliseconds(), OutputBytes: media.MaxPutBytes,
+ Above1080pNeedsLong: true,
+ }, hiProbe)
+ if !refused || hi.Error != media.CodeNeedsLongClass {
+ t.Fatalf("the handler's probe check answered %+v, refused %v", hi, refused)
+ }
+ fail("needs_long_class", hi)
+ if want := mediaCopy["media.job.needs_long_class_hi"]; want == "" {
+ t.Fatal("the deck has no media.job.needs_long_class_hi row")
+ } else if r := f.get(sub.job.ID); r.job.Error == nil || r.job.Error.Message != want {
+ t.Fatalf("needs_long_class above 1080p: %s", r.raw)
+ }
}
// TestMediaDoorsRefuseOnHostClaim (spec §11 A1, pre-flight F22): both doors
diff --git a/internal/console/media_copy.go b/internal/console/media_copy.go
index 6597303c6..ee6c683fa 100644
--- a/internal/console/media_copy.go
+++ b/internal/console/media_copy.go
@@ -66,7 +66,9 @@ var mediaCopy = map[string]string{
"media.job.source_dimensions": "the video is larger than %s",
"media.job.source_frame_rate": "the video has more than %d frames a second",
"media.job.source_too_long": "the file is longer than %s, the maximum for this preset",
+ "media.job.source_too_long_hdr": "the HDR video is longer than %s, the maximum for HDR video up to 1080p",
"media.job.needs_long_class": "the file is longer than %s, the most the short class converts. submit it again in the long class",
+ "media.job.needs_long_class_hi": `the video is above 1080p, which only the long class converts. submit the same request again with "class": "long"`,
"media.job.allowance_exceeded": "this account's media allowance for the month does not cover this file. buy a media pack or move to a larger plan to convert it",
"media.job.unreadable": "the file could not be read. it may be damaged or cut short",
"media.job.output_too_large": "a converted file would be over 5 GB, the maximum for one output",
@@ -147,15 +149,34 @@ func mediaJobMessage(j mediajobs.Job, l media.Limits) string {
case media.CodeSourceFrameRate:
return mediaText(key, media.MaxFPS)
case media.CodeSourceTooLong:
- w, h := 0, 0
- if j.Result != nil && j.Result.Source != nil {
- w, h = j.Result.Source.Width, j.Result.Source.Height
+ w, h, hdr := 0, 0, false
+ if s := jobSource(j); s != nil {
+ w, h, hdr = s.Width, s.Height, s.HDR
}
- return mediaText(key, mediaDuration(l.MaxDuration(j.Preset, w, h)))
+ if j.Preset == media.PresetVideo720p && hdr && !media.Above1080p(w, h) {
+ // HDR up to 1080p has its own maximum (spec §11 A7).
+ key = "media.job.source_too_long_hdr"
+ }
+ return mediaText(key, mediaDuration(l.MaxDuration(j.Preset, w, h, hdr)))
case media.CodeNeedsLongClass:
+ // The short video class refuses a source above 1080p whatever
+ // its length (spec §11 A7); the result's facts say which.
+ if s := jobSource(j); j.Preset == media.PresetVideo720p && s != nil && media.Above1080p(s.Width, s.Height) {
+ return mediaText("media.job.needs_long_class_hi")
+ }
return mediaText(key, mediaDuration(l.Granted(media.ClassKey{Preset: j.Preset, Class: media.ClassShort})))
case media.CodeSourceTooLarge:
return mediaText(key, billingBytes(j.Bytes), j.Preset, billingBytes(l.MaxBytes(j.Preset)))
}
return mediaText(key)
}
+
+// jobSource is the source facts a job's stored result carries: the
+// probe's, on a done job or a failure the probe refused; nil when there
+// are none.
+func jobSource(j mediajobs.Job) *media.SourceFacts {
+ if j.Result == nil {
+ return nil
+ }
+ return j.Result.Source
+}
diff --git a/internal/console/mediawire.go b/internal/console/mediawire.go
index 175870053..1d7ad7ae7 100644
--- a/internal/console/mediawire.go
+++ b/internal/console/mediawire.go
@@ -212,7 +212,7 @@ func (s *Server) mediaAccountGone(ctx context.Context, account string) (bool, er
// limit). media.ParseLimits gives only such limits; this holds for a
// Config built any other way.
func validMediaLimits(l media.Limits) error {
- ok := l.VideoMax > 0 && l.VideoMaxHi > 0 && l.AudioMax > 0 && l.VideoBytes > 0 && l.AudioBytes > 0 &&
+ ok := l.VideoMax > 0 && l.VideoMaxHDR > 0 && l.VideoMaxHi > 0 && l.AudioMax > 0 && l.VideoBytes > 0 && l.AudioBytes > 0 &&
l.AccountMinutes >= 0 && l.Short > 0 && l.Long > 0 && l.AccountShort > 0 && l.AccountLong > 0 &&
l.AccountActive > 0 && l.PerMinute > 0 && l.Burst > 0 && l.Queue > 0
if !ok {
diff --git a/internal/console/planmedia_test.go b/internal/console/planmedia_test.go
index 69a199435..7b8d37bea 100644
--- a/internal/console/planmedia_test.go
+++ b/internal/console/planmedia_test.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "net/http"
"net/http/httptest"
"os"
"strings"
@@ -610,3 +611,33 @@ func TestLaunchCarriedKeysMatchTheirFields(t *testing.T) {
}
}
}
+
+// TestMediaCapsCountAbove1080pTwice (Paul's option A, 2026-11-20; spec
+// §11 A7): the cap measure and the door read one weighted figure, so 10
+// minutes of 4K count 20 media minutes, and an account with a limit of
+// 10 is refused at the door with plan_limit on the weighted figure.
+func TestMediaCapsCountAbove1080pTwice(t *testing.T) {
+ fx := newConsoleFixture(t)
+ acct := planAccount(t, fx, 501)
+ ctx := t.Context()
+ now := time.Now().UTC()
+ if _, err := fx.st.db.Exec(`INSERT INTO media_jobs
+ (account, app, incarnation, job_id, key, etag, bytes, preset, class, bucket, state, submitted_at,
+ execution_id, settled, source_ms, charged_ms, ended_at, weight_tenths)
+ VALUES (?, 'shop', 'inc', '4k', 'uploads/a.mov', 'e', 1, 'video-720p', 'long', 'b', 'done', ?, 'x', 1, ?, 1, ?, 20)`,
+ acct.Sqid, now.Add(-time.Hour).UnixMilli(), 10*videoMinute, now.Add(-time.Minute).UnixMilli()); err != nil {
+ t.Fatal(err)
+ }
+ got, errs := fx.srv.measureCaps(ctx, acct, &plans.Limits{MediaMinutesMonth: 10}, now)
+ if len(errs) != 0 || got[capMedia] != (capMeasure{Used: 20, Limit: 10}) {
+ t.Fatalf("measure = %v, %v", got, errs)
+ }
+ fx.srv.cfg.PlanCatalog = mediaLimitCatalog(t, 10)
+ ref, err := fx.srv.mediaFairUse(ctx, acct, now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if ref == nil || ref.Status != http.StatusPaymentRequired || ref.Code != "plan_limit" || ref.Msg != capMessage("cli.cap.media_minutes", 20, 10) {
+ t.Fatalf("door = %+v, want 402 plan_limit at 20 of 10", ref)
+ }
+}
diff --git a/internal/console/store.go b/internal/console/store.go
index 096e60261..27fcabb8b 100644
--- a/internal/console/store.go
+++ b/internal/console/store.go
@@ -557,8 +557,8 @@ func (s *Store) migrate() error {
}
}
// Additive column changes land here, forgiving "duplicate column" so
- // re-running is always safe.
- for _, stmt := range []string{
+ // re-running is always safe. The media job table's own come first.
+ for _, stmt := range append(append([]string{}, mediajobs.Migrations...), []string{
`ALTER TABLE users ADD COLUMN operator INTEGER NOT NULL DEFAULT 0;`,
// Pending lifetimes (lifetimes_store.go, merge review 5): the record
// key of a stale body under the replaced slot's previous owner, which
@@ -695,7 +695,7 @@ func (s *Store) migrate() error {
`ALTER TABLE invites ADD COLUMN seat_authorised_by TEXT NOT NULL DEFAULT '';`,
`ALTER TABLE invites ADD COLUMN seat_authorised_at INTEGER NOT NULL DEFAULT 0;`,
`ALTER TABLE invites ADD COLUMN seat_consumed_at INTEGER NOT NULL DEFAULT 0;`,
- } {
+ }...) {
if _, err := s.db.Exec(stmt); err != nil && !strings.Contains(err.Error(), "duplicate column") {
return err
}
diff --git a/internal/media/limits.go b/internal/media/limits.go
index 0e8891dce..57bcaa377 100644
--- a/internal/media/limits.go
+++ b/internal/media/limits.go
@@ -10,21 +10,27 @@ import (
// Limits are a deployment's media settings (CARLOS_MEDIA_LIMITS): the
// per-file maximums (spec §7.1), the per-account allowance used when there
// is no plan catalog (§7.3), and the fair-use figures (§7.2).
+//
+// VideoMaxHDR is the maximum for an HDR video source up to 1080p, held to
+// VideoMax (MaxHDR): the spike converted 1080p HDR at 2.71 times real
+// time on the long class, against 5.85 for SDR, so two hours of it do not
+// fit the class's 40-minute budget (spec §11 A7).
type Limits struct {
- VideoMax, VideoMaxHi, AudioMax time.Duration
- VideoBytes, AudioBytes int64
- AccountMinutes int64
- Short, Long int
- AccountShort, AccountLong int
- AccountActive int
- PerMinute, Burst int
- Queue int
+ VideoMax, VideoMaxHDR, VideoMaxHi, AudioMax time.Duration
+ VideoBytes, AudioBytes int64
+ AccountMinutes int64
+ Short, Long int
+ AccountShort, AccountLong int
+ AccountActive int
+ PerMinute, Burst int
+ Queue int
}
// DefaultLimits is what ParseLimits("") gives.
func DefaultLimits() Limits {
return Limits{
VideoMax: 2 * time.Hour,
+ VideoMaxHDR: 75 * time.Minute,
VideoMaxHi: 30 * time.Minute,
VideoBytes: 40 << 30,
AudioMax: 8 * time.Hour,
@@ -52,9 +58,10 @@ func ParseLimits(v string) (Limits, error) {
return l, nil
}
durations := map[string]*time.Duration{
- "video_max": &l.VideoMax,
- "video_max_hi": &l.VideoMaxHi,
- "audio_max": &l.AudioMax,
+ "video_max": &l.VideoMax,
+ "video_max_hdr": &l.VideoMaxHDR,
+ "video_max_hi": &l.VideoMaxHi,
+ "audio_max": &l.AudioMax,
}
sizes := map[string]*int64{
"video_bytes": &l.VideoBytes,
@@ -144,15 +151,26 @@ func (l Limits) MaxBytes(preset string) int64 {
return 0
}
+// MaxHDR is the maximum for an HDR video source up to 1080p: VideoMaxHDR,
+// held to VideoMax.
+func (l Limits) MaxHDR() time.Duration {
+ return min(l.VideoMaxHDR, l.VideoMax)
+}
+
// MaxDuration is the longest source the preset converts: for video,
-// VideoMaxHi when the source is above 1080p (Above1080p), else VideoMax;
-// for audio, AudioMax. It fills the deck's media.job.source_too_long.
-func (l Limits) MaxDuration(preset string, width, height int) time.Duration {
+// VideoMaxHi when the source is above 1080p (Above1080p), whatever its
+// transfer; else MaxHDR for an HDR source; else VideoMax. For audio,
+// AudioMax. It fills the deck's media.job.source_too_long and
+// source_too_long_hdr.
+func (l Limits) MaxDuration(preset string, width, height int, hdr bool) time.Duration {
switch preset {
case PresetVideo720p:
if Above1080p(width, height) {
return l.VideoMaxHi
}
+ if hdr {
+ return l.MaxHDR()
+ }
return l.VideoMax
case PresetAudioAAC:
return l.AudioMax
diff --git a/internal/media/media.go b/internal/media/media.go
index 07c5c421c..9f094e798 100644
--- a/internal/media/media.go
+++ b/internal/media/media.go
@@ -36,19 +36,24 @@ func (k ClassKey) String() string { return k.Preset + "/" + k.Class }
// PickUpTo is the largest source the short class takes when no class is
// asked for (0 on a long row: any size). CPU is in ECS CPU units (1024 per
// vCPU) and MemoryMiB in MiB, as RunTask's overrides take them. Granted 0
-// means the preset maximum (Limits.Granted).
+// means the preset maximum (Limits.Granted). TakesAbove1080p is whether
+// the class converts a video source above 1080p (Above1080p): only the
+// long video class does; on the short one the codec answers
+// needs_long_class (spec §11 A7: at 4 vCPU the spike converted 4K HDR at
+// 0.27 times real time). Audio rows never meet one and leave it false.
type ClassSpec struct {
- Key ClassKey
- PickUpTo int64
- CPU int
- MemoryMiB int
- Deadline time.Duration
- Granted time.Duration
+ Key ClassKey
+ PickUpTo int64
+ CPU int
+ MemoryMiB int
+ Deadline time.Duration
+ Granted time.Duration
+ TakesAbove1080p bool
}
var classes = map[ClassKey]ClassSpec{
{PresetVideo720p, ClassShort}: {Key: ClassKey{PresetVideo720p, ClassShort}, PickUpTo: 1 << 30, CPU: 4 * 1024, MemoryMiB: 8 * 1024, Deadline: 15 * time.Minute, Granted: 10 * time.Minute},
- {PresetVideo720p, ClassLong}: {Key: ClassKey{PresetVideo720p, ClassLong}, CPU: 16 * 1024, MemoryMiB: 32 * 1024, Deadline: 50 * time.Minute},
+ {PresetVideo720p, ClassLong}: {Key: ClassKey{PresetVideo720p, ClassLong}, CPU: 16 * 1024, MemoryMiB: 32 * 1024, Deadline: 50 * time.Minute, TakesAbove1080p: true},
{PresetAudioAAC, ClassShort}: {Key: ClassKey{PresetAudioAAC, ClassShort}, PickUpTo: 256 << 20, CPU: 1 * 1024, MemoryMiB: 2 * 1024, Deadline: 10 * time.Minute, Granted: 2 * time.Hour},
{PresetAudioAAC, ClassLong}: {Key: ClassKey{PresetAudioAAC, ClassLong}, CPU: 2 * 1024, MemoryMiB: 4 * 1024, Deadline: 50 * time.Minute},
}
@@ -74,12 +79,16 @@ func PickClass(preset, requested string, bytes int64) string {
return ClassShort
}
-// WeightTenths is the preset's allowance weight in tenths: video 10, audio
-// 1, so units = milliseconds × weight-tenths are always integers. An
-// unknown preset weighs 0.
-func WeightTenths(preset string) int64 {
+// WeightTenths is a source's allowance weight in tenths: video 10, video
+// above 1080p 20 (Paul's option A, 2026-11-20: such a minute counts
+// twice; spec §11 A7), audio 1, so units = milliseconds × weight-tenths
+// are always integers. An unknown preset weighs 0.
+func WeightTenths(preset string, above1080p bool) int64 {
switch preset {
case PresetVideo720p:
+ if above1080p {
+ return 20
+ }
return 10
case PresetAudioAAC:
return 1
@@ -87,6 +96,32 @@ func WeightTenths(preset string) int64 {
return 0
}
+// ReserveWeightTenths is the weight a dispatched row of the class is
+// reserved at: the most any source the class converts can weigh. Nothing
+// is known of the source's picture before the probe, so the long video
+// class reserves at the weight above 1080p; the short one never converts
+// such a source (TakesAbove1080p) and reserves at video's. 0 for an
+// unknown class.
+func ReserveWeightTenths(k ClassKey) int64 {
+ c, ok := classes[k]
+ if !ok {
+ return 0
+ }
+ return WeightTenths(k.Preset, c.TakesAbove1080p)
+}
+
+// ChargeWeightTenths is the weight a settled row of the class is charged
+// at, from the probe's dimensions: above1080p counts only on a class that
+// takes such a source, so the charge weight is never above
+// ReserveWeightTenths(k). 0 for an unknown class.
+func ChargeWeightTenths(k ClassKey, above1080p bool) int64 {
+ c, ok := classes[k]
+ if !ok {
+ return 0
+ }
+ return WeightTenths(k.Preset, above1080p && c.TakesAbove1080p)
+}
+
// OutputNames are the preset's three output files, in payload order; nil
// for an unknown preset.
func OutputNames(preset string) []string {
@@ -192,9 +227,9 @@ const (
ScratchHeadroom = 8 << 30
)
-// The source maximums the probe enforces (spec §7.1, provisional). The
-// deck's media.job.source_dimensions and source_frame_rate messages are
-// filled from MaxDimensions and MaxFPS.
+// The source maximums the probe enforces (spec §7.1; the spike kept them,
+// §11 A7). The deck's media.job.source_dimensions and source_frame_rate
+// messages are filled from MaxDimensions and MaxFPS.
const (
MaxDimensions = "3840x2160"
MaxSide = 4096
diff --git a/internal/media/media_test.go b/internal/media/media_test.go
index 245092289..19dc08c8b 100644
--- a/internal/media/media_test.go
+++ b/internal/media/media_test.go
@@ -115,14 +115,17 @@ func TestClassTable(t *testing.T) {
key ClassKey
cpu, mem int
deadline, granted time.Duration
+ hi bool
}{
- {ClassKey{PresetVideo720p, ClassShort}, 4096, 8192, 15 * time.Minute, 10 * time.Minute},
- {ClassKey{PresetVideo720p, ClassLong}, 16384, 32768, 50 * time.Minute, 2 * time.Hour},
- {ClassKey{PresetAudioAAC, ClassShort}, 1024, 2048, 10 * time.Minute, 2 * time.Hour},
- {ClassKey{PresetAudioAAC, ClassLong}, 2048, 4096, 50 * time.Minute, 8 * time.Hour},
+ // Above 1080p converts on the long video class only (spec §11 A7):
+ // at 4 vCPU 4K HDR ran at 0.27 times real time.
+ {ClassKey{PresetVideo720p, ClassShort}, 4096, 8192, 15 * time.Minute, 10 * time.Minute, false},
+ {ClassKey{PresetVideo720p, ClassLong}, 16384, 32768, 50 * time.Minute, 2 * time.Hour, true},
+ {ClassKey{PresetAudioAAC, ClassShort}, 1024, 2048, 10 * time.Minute, 2 * time.Hour, false},
+ {ClassKey{PresetAudioAAC, ClassLong}, 2048, 4096, 50 * time.Minute, 8 * time.Hour, false},
} {
s, ok := Class(c.key)
- if !ok || s.Key != c.key || s.CPU != c.cpu || s.MemoryMiB != c.mem || s.Deadline != c.deadline {
+ if !ok || s.Key != c.key || s.CPU != c.cpu || s.MemoryMiB != c.mem || s.Deadline != c.deadline || s.TakesAbove1080p != c.hi {
t.Errorf("Class(%s) = %+v, %v", c.key, s, ok)
}
if s.Deadline > MaxDeadline {
@@ -141,8 +144,20 @@ func TestClassTable(t *testing.T) {
}
func TestPresetFacts(t *testing.T) {
- if WeightTenths(PresetVideo720p) != 10 || WeightTenths(PresetAudioAAC) != 1 || WeightTenths("x") != 0 {
- t.Error("weights are not 10 and 1")
+ // Paul's option A, 2026-11-20 (spec §11 A7): a minute of video above
+ // 1080p counts twice.
+ for _, c := range []struct {
+ preset string
+ hi bool
+ want int64
+ }{
+ {PresetVideo720p, false, 10}, {PresetVideo720p, true, 20},
+ {PresetAudioAAC, false, 1}, {PresetAudioAAC, true, 1},
+ {"x", false, 0}, {"x", true, 0},
+ } {
+ if got := WeightTenths(c.preset, c.hi); got != c.want {
+ t.Errorf("WeightTenths(%s, above 1080p %v) = %d, want %d", c.preset, c.hi, got, c.want)
+ }
}
if got := OutputNames(PresetVideo720p); !reflect.DeepEqual(got, []string{"video.mp4", "video.m3u8", "poster.jpg"}) {
t.Errorf("video outputs %v", got)
@@ -167,7 +182,7 @@ func TestParseLimits(t *testing.T) {
t.Fatal(err)
}
want := Limits{
- VideoMax: 2 * time.Hour, VideoMaxHi: 30 * time.Minute, VideoBytes: 40 << 30,
+ VideoMax: 2 * time.Hour, VideoMaxHDR: 75 * time.Minute, VideoMaxHi: 30 * time.Minute, VideoBytes: 40 << 30,
AudioMax: 8 * time.Hour, AudioBytes: 10 << 30, AccountMinutes: 0,
Short: 6, Long: 2, AccountShort: 2, AccountLong: 1, AccountActive: 20,
PerMinute: 30, Burst: 10, Queue: 200,
@@ -184,15 +199,15 @@ func TestParseLimits(t *testing.T) {
if two != w2 {
t.Fatalf("overrides = %+v, want %+v", two, w2)
}
- all, err := ParseLimits("video_max=90m, video_max_hi=20m,video_bytes=512MiB,audio_max=4h,audio_bytes=1048576,account_minutes=600,short=4,long=1,account_short=3,account_long=2,account_active=5,per_minute=6,burst=2,queue=50")
+ all, err := ParseLimits("video_max=90m, video_max_hdr=45m, video_max_hi=20m,video_bytes=512MiB,audio_max=4h,audio_bytes=1048576,account_minutes=600,short=4,long=1,account_short=3,account_long=2,account_active=5,per_minute=6,burst=2,queue=50")
if err != nil {
t.Fatal(err)
}
- wAll := Limits{VideoMax: 90 * time.Minute, VideoMaxHi: 20 * time.Minute, VideoBytes: 512 << 20, AudioMax: 4 * time.Hour, AudioBytes: 1 << 20, AccountMinutes: 600, Short: 4, Long: 1, AccountShort: 3, AccountLong: 2, AccountActive: 5, PerMinute: 6, Burst: 2, Queue: 50}
+ wAll := Limits{VideoMax: 90 * time.Minute, VideoMaxHDR: 45 * time.Minute, VideoMaxHi: 20 * time.Minute, VideoBytes: 512 << 20, AudioMax: 4 * time.Hour, AudioBytes: 1 << 20, AccountMinutes: 600, Short: 4, Long: 1, AccountShort: 3, AccountLong: 2, AccountActive: 5, PerMinute: 6, Burst: 2, Queue: 50}
if all != wAll {
t.Fatalf("every key = %+v, want %+v", all, wAll)
}
- for _, bad := range []string{"bogus=1", "short=0", "video_max=1h,video_max=2h", "video_bytes=-1", "account_minutes=-1", "video_max=0s", "video_max", "queue=x", "audio_bytes=3TiB"} {
+ for _, bad := range []string{"bogus=1", "short=0", "video_max=1h,video_max=2h", "video_max_hdr=0s", "video_bytes=-1", "account_minutes=-1", "video_max=0s", "video_max", "queue=x", "audio_bytes=3TiB"} {
if _, err := ParseLimits(bad); err == nil {
t.Errorf("ParseLimits(%q) = nil error", bad)
}
@@ -205,24 +220,44 @@ func TestParseLimits(t *testing.T) {
}
}
+// TestMaxDuration: 2 hours for SDR up to 1080p, 75 minutes for HDR up to
+// 1080p (the spike's 1080p HDR ran at 2.71 times real time on the long
+// class, spec §11 A7), 30 minutes above 1080p whatever the transfer.
func TestMaxDuration(t *testing.T) {
l := DefaultLimits()
for _, c := range []struct {
preset string
w, h int
+ hdr bool
want time.Duration
}{
- {PresetVideo720p, 1920, 1080, 2 * time.Hour},
- {PresetVideo720p, 1080, 1920, 2 * time.Hour},
- {PresetVideo720p, 2560, 1440, 30 * time.Minute},
- {PresetVideo720p, 1440, 2560, 30 * time.Minute},
- {PresetVideo720p, 1921, 800, 30 * time.Minute},
- {PresetAudioAAC, 0, 0, 8 * time.Hour},
+ {PresetVideo720p, 1920, 1080, false, 2 * time.Hour},
+ {PresetVideo720p, 1080, 1920, false, 2 * time.Hour},
+ {PresetVideo720p, 1920, 1080, true, 75 * time.Minute},
+ {PresetVideo720p, 1080, 1920, true, 75 * time.Minute},
+ {PresetVideo720p, 2560, 1440, false, 30 * time.Minute},
+ {PresetVideo720p, 1440, 2560, false, 30 * time.Minute},
+ {PresetVideo720p, 3840, 2160, true, 30 * time.Minute},
+ {PresetVideo720p, 1921, 800, false, 30 * time.Minute},
+ {PresetAudioAAC, 0, 0, false, 8 * time.Hour},
+ {PresetAudioAAC, 0, 0, true, 8 * time.Hour},
} {
- if got := l.MaxDuration(c.preset, c.w, c.h); got != c.want {
- t.Errorf("MaxDuration(%s, %dx%d) = %s, want %s", c.preset, c.w, c.h, got, c.want)
+ if got := l.MaxDuration(c.preset, c.w, c.h, c.hdr); got != c.want {
+ t.Errorf("MaxDuration(%s, %dx%d, hdr %v) = %s, want %s", c.preset, c.w, c.h, c.hdr, got, c.want)
}
}
+ // An HDR maximum over the SDR one is held to it.
+ short := l
+ short.VideoMax = time.Hour
+ if got := short.MaxDuration(PresetVideo720p, 1920, 1080, true); got != time.Hour {
+ t.Errorf("HDR maximum with video_max=1h: %s, want 1h", got)
+ }
+ if got := short.MaxHDR(); got != time.Hour {
+ t.Errorf("MaxHDR with video_max=1h: %s, want 1h", got)
+ }
+ if got := l.MaxHDR(); got != 75*time.Minute {
+ t.Errorf("MaxHDR: %s, want 75m", got)
+ }
}
func TestEphemeralGiB(t *testing.T) {
@@ -459,3 +494,37 @@ func TestParseResult(t *testing.T) {
t.Errorf("a result of exactly %d bytes: %v", MaxResultBytes, err)
}
}
+
+// TestReserveAndChargeWeights: a class reserves at the most any source it
+// converts can weigh, which is the higher weight only on the long video
+// class (the short one refuses a source above 1080p before encoding); a
+// settled row is charged at its source's weight, never above its class's
+// reservation weight, so the charge never outgrows the reservation.
+func TestReserveAndChargeWeights(t *testing.T) {
+ for _, c := range []struct {
+ key ClassKey
+ reserve, charge, chargeHi int64
+ }{
+ {ClassKey{PresetVideo720p, ClassShort}, 10, 10, 10},
+ {ClassKey{PresetVideo720p, ClassLong}, 20, 10, 20},
+ {ClassKey{PresetAudioAAC, ClassShort}, 1, 1, 1},
+ {ClassKey{PresetAudioAAC, ClassLong}, 1, 1, 1},
+ {ClassKey{PresetVideo720p, "medium"}, 0, 0, 0},
+ {ClassKey{"x", ClassLong}, 0, 0, 0},
+ } {
+ if got := ReserveWeightTenths(c.key); got != c.reserve {
+ t.Errorf("ReserveWeightTenths(%s) = %d, want %d", c.key, got, c.reserve)
+ }
+ if got := ChargeWeightTenths(c.key, false); got != c.charge {
+ t.Errorf("ChargeWeightTenths(%s, 1080p) = %d, want %d", c.key, got, c.charge)
+ }
+ if got := ChargeWeightTenths(c.key, true); got != c.chargeHi {
+ t.Errorf("ChargeWeightTenths(%s, above 1080p) = %d, want %d", c.key, got, c.chargeHi)
+ }
+ for _, hi := range []bool{false, true} {
+ if ChargeWeightTenths(c.key, hi) > ReserveWeightTenths(c.key) {
+ t.Errorf("%s charges above its reservation weight (above 1080p %v)", c.key, hi)
+ }
+ }
+ }
+}
diff --git a/internal/media/payload.go b/internal/media/payload.go
index e97124aef..ee1bbf3b8 100644
--- a/internal/media/payload.go
+++ b/internal/media/payload.go
@@ -98,13 +98,25 @@ func SplitPresigned(raw string) (base, shared, rest string, err error) {
}
// JobLimits are the limits the codec enforces on one execution.
+//
+// MaxHDRMS is the maximum for an HDR video source up to 1080p
+// (Limits.MaxHDR); 0, as an older console sends it, means MaxMS. The codec
+// holds it to MaxMS either way.
+//
+// Above1080pNeedsLong is set on a video class that does not take a source
+// above 1080p (ClassSpec.TakesAbove1080p false: the short video class).
+// The codec then answers needs_long_class for such a source, after the
+// duration maximum and before the granted duration (spec §11 A7). It is
+// omitted when false, so a payload without it reads as before.
type JobLimits struct {
- SourceBytes int64 `json:"b"`
- GrantedMS int64 `json:"g"`
- GrantedBy string `json:"gb"` // "class" | "allowance"
- MaxMS int64 `json:"d"`
- MaxHiMS int64 `json:"dh"` // video sources above 1080p; 0 for audio
- OutputBytes int64 `json:"o"`
+ SourceBytes int64 `json:"b"`
+ GrantedMS int64 `json:"g"`
+ GrantedBy string `json:"gb"` // "class" | "allowance"
+ MaxMS int64 `json:"d"`
+ MaxHDRMS int64 `json:"dr,omitempty"` // HDR video sources up to 1080p; 0 for audio
+ MaxHiMS int64 `json:"dh"` // video sources above 1080p; 0 for audio
+ OutputBytes int64 `json:"o"`
+ Above1080pNeedsLong bool `json:"hl,omitempty"`
}
// Payload is the codec's whole input, one environment variable
diff --git a/internal/media/result.go b/internal/media/result.go
index ddf1db0d0..9bc7742bc 100644
--- a/internal/media/result.go
+++ b/internal/media/result.go
@@ -12,13 +12,15 @@ import (
// ResultVersion is the result object's schema version.
const ResultVersion = 1
-// SourceFacts are what the codec's probe found.
+// SourceFacts are what the codec's probe found. HDR is set for an HDR
+// video source (spec §11 A7: the console names its maximum from it).
type SourceFacts struct {
DurationMS int64 `json:"duration_ms"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
VideoCodec string `json:"video_codec,omitempty"`
AudioCodec string `json:"audio_codec,omitempty"`
+ HDR bool `json:"hdr,omitempty"`
}
// OutputFact is one uploaded output.
diff --git a/internal/mediahandler/ffmpeg.go b/internal/mediahandler/ffmpeg.go
index c0e9171b7..1cd9375ca 100644
--- a/internal/mediahandler/ffmpeg.go
+++ b/internal/mediahandler/ffmpeg.go
@@ -13,10 +13,13 @@ import (
"github.com/carlosframework/platform/internal/media"
)
-// The encoder settings plan 1's spike settles (provisional until its
-// report: plan 3 Task 4).
+// The encoder settings. x264Preset is the slowest preset that runs at
+// least 3 times real time on long-class 1080p (plan 1 Task 5 Step 2):
+// the spike measured veryfast 10.35, faster 5.65 and medium 5.85 times
+// real time there, so medium (spike report, "Values for plans 2 and 3";
+// spec §11 A7). x264CRF is the spike's unchanged 23.
const (
- x264Preset = "veryfast"
+ x264Preset = "medium"
x264CRF = 23
)
diff --git a/internal/mediahandler/ffmpeg_test.go b/internal/mediahandler/ffmpeg_test.go
index 94b073a66..0578e2d3f 100644
--- a/internal/mediahandler/ffmpeg_test.go
+++ b/internal/mediahandler/ffmpeg_test.go
@@ -110,7 +110,7 @@ func TestVideoArgsSDRLandscape(t *testing.T) {
"-map", "0:0", "-map", "0:1",
"-sn", "-dn", "-map_metadata", "-1", "-map_chapters", "-1", "-t", "61.500",
"-vf", "scale=1280:720:flags=bicubic,setsar=1,format=yuv420p,tpad=stop_mode=clone:stop=-1,trim=end=60.000",
- "-c:v", "libx264", "-profile:v", "high", "-preset", "veryfast", "-crf", "23",
+ "-c:v", "libx264", "-profile:v", "high", "-preset", "medium", "-crf", "23",
"-maxrate", "2500k", "-bufsize", "5000k", "-pix_fmt", "yuv420p", "-fpsmax", "30",
"-force_key_frames", "expr:gte(t,n_forced*2)", "-sc_threshold", "0",
"-c:a", "aac", "-b:a", "128k", "-ac", "2", "-ar", "48000", "-af", "aresample=async=1:first_pts=0,apad=whole_dur=60.000",
diff --git a/internal/mediahandler/fmp4_test.go b/internal/mediahandler/fmp4_test.go
index d1d110682..015f4b123 100644
--- a/internal/mediahandler/fmp4_test.go
+++ b/internal/mediahandler/fmp4_test.go
@@ -246,7 +246,24 @@ func TestReadFMP4Fixtures(t *testing.T) {
// audio filter gained sample_fmts=fltp while args.txt still read the
// older filter, and a muxer-only check passed (media spike, 2026-11-20).
// A change to videoArgs or audioArgs fails here until the fixtures are
-// regenerated (TestRegenerateFMP4Fixtures).
+// regenerated (TestRegenerateFMP4Fixtures), with one stated exception:
+// fixturePreset.
+//
+// fixturePreset is the x264 preset the committed fixtures were encoded
+// at: the spike's arm64 regeneration ran before its Task 5 Step 2 set
+// x264Preset to medium (spike report, "Values for plans 2 and 3"). A
+// video fixture's -preset value may be fixturePreset or x264Preset, and
+// every other argument must match exactly. What readFMP4 is tested on
+// does not depend on the preset: the box sequence comes from the muxer
+// flags, the fragment and keyframe times from -min_frag_duration,
+// -force_key_frames and -sc_threshold 0, and the decoder delay from the
+// B-frame count, which veryfast and medium share (3); the preset changes
+// packet sizes, which the fixtures' own packets files carry. The spike
+// also ran the handler at medium on every video class, playlist (and so
+// readFMP4) included (report, Task 5). Drop this exception once the
+// fixtures are next regenerated, which needs an ffmpeg 7.1.5 run.
+const fixturePreset = "veryfast"
+
func TestMuxerArgsMatchTheFixtures(t *testing.T) {
cfg := Config{Scratch: "/scratch"}
// Each recipe's source as the real probe answers it, under the 9 s
@@ -302,6 +319,12 @@ func TestMuxerArgsMatchTheFixtures(t *testing.T) {
t.Fatalf("args.txt names %s", a.File)
}
seen++
+ if i := slices.Index(want, "-preset"); i >= 0 && i+1 < len(a.Args) && a.Args[i] == "-preset" && a.Args[i+1] == fixturePreset {
+ // The one stated difference: the fixture's preset, read as
+ // the code's, so every other argument still compares exactly.
+ a.Args = slices.Clone(a.Args)
+ a.Args[i+1] = want[i+1]
+ }
if !slices.Equal(a.Args, want) {
t.Errorf("%s was made with\n%q\nthe encode builds\n%q\nregenerate testdata/fmp4 (provenance.txt)", a.File, a.Args, want)
}
diff --git a/internal/mediahandler/probe.go b/internal/mediahandler/probe.go
index f76045e37..c2ccb1db2 100644
--- a/internal/mediahandler/probe.go
+++ b/internal/mediahandler/probe.go
@@ -77,8 +77,8 @@ const grantedByClass = "class"
// refuseDolbyVision5 is the spike's ruling (plan 1): true refuses Dolby
// Vision profile 5 as unsupported_hdr; false decodes it as HEVC and
-// tone-maps it. Provisional: false until the spike report says
-// otherwise. A variable so the test can set it.
+// tone-maps it. False: the spike had no profile 5 sample to test (its
+// report; spec §11 A7). A variable so the test can set it.
var refuseDolbyVision5 = false
// maxDurationMS is where a parsed duration saturates: far over every
@@ -537,11 +537,14 @@ func allDigits(s string) bool {
// media.MaxDimensions: source_dimensions (no positive size:
// unreadable);
// 5. (video-720p) over media.MaxFPS: source_frame_rate;
-// 6. longer than MaxHiMS (video above 1080p, media.Above1080p) or
-// MaxMS: source_too_long (no positive duration: unreadable);
-// 7. longer than GrantedMS: needs_long_class when the class granted
+// 6. longer than MaxHiMS (video above 1080p, media.Above1080p), else
+// MaxHDRMS (an HDR video; 0 is MaxMS, and it is held to MaxMS),
+// else MaxMS: source_too_long (no positive duration: unreadable);
+// 7. (video-720p) above 1080p when Above1080pNeedsLong (the short
+// class, spec §11 A7): needs_long_class;
+// 8. longer than GrantedMS: needs_long_class when the class granted
// it, else allowance_exceeded;
-// 8. Dolby Vision profile 5, only when refuseDolbyVision5:
+// 9. Dolby Vision profile 5, only when refuseDolbyVision5:
// unsupported_hdr.
//
// An unknown preset is engine_failed: the payload was validated.
@@ -574,13 +577,20 @@ func check(f probeFacts, preset string, l media.JobLimits) error {
if f.DurationMS <= 0 {
return jobError{media.CodeUnreadable}
}
+ hi := video && media.Above1080p(f.Width, f.Height)
maxMS := l.MaxMS
- if video && media.Above1080p(f.Width, f.Height) {
+ switch {
+ case hi:
maxMS = l.MaxHiMS
+ case video && f.HDR && l.MaxHDRMS > 0:
+ maxMS = min(l.MaxHDRMS, l.MaxMS)
}
if f.DurationMS > maxMS {
return jobError{media.CodeSourceTooLong}
}
+ if hi && l.Above1080pNeedsLong {
+ return jobError{media.CodeNeedsLongClass}
+ }
if f.DurationMS > l.GrantedMS {
if l.GrantedBy == grantedByClass {
return jobError{media.CodeNeedsLongClass}
diff --git a/internal/mediahandler/probe_test.go b/internal/mediahandler/probe_test.go
index 6b20eb4d9..7f95bd7bf 100644
--- a/internal/mediahandler/probe_test.go
+++ b/internal/mediahandler/probe_test.go
@@ -290,6 +290,61 @@ func TestCheckTable(t *testing.T) {
{"audio has no hi maximum", audio, func(f *probeFacts, l *media.JobLimits) {
f.Width, f.Height, f.DurationMS = 3840, 2160, l.MaxMS
}, ""},
+ // The short video class takes nothing above 1080p (spec §11 A7).
+ {"short class: above 1080p needs the long class", video, func(f *probeFacts, l *media.JobLimits) {
+ l.Above1080pNeedsLong = true
+ f.Width, f.Height = 3840, 2160
+ }, media.CodeNeedsLongClass},
+ {"short class: 1920x1081 needs the long class", video, func(f *probeFacts, l *media.JobLimits) {
+ l.Above1080pNeedsLong = true
+ f.Width, f.Height = 1920, 1081
+ }, media.CodeNeedsLongClass},
+ {"short class: 1080p converts", video, func(_ *probeFacts, l *media.JobLimits) { l.Above1080pNeedsLong = true }, ""},
+ {"short class: 1080p portrait converts", video, func(f *probeFacts, l *media.JobLimits) {
+ l.Above1080pNeedsLong = true
+ f.Width, f.Height = 1080, 1920
+ }, ""},
+ {"short class: over the hi maximum is too long first", video, func(f *probeFacts, l *media.JobLimits) {
+ l.Above1080pNeedsLong = true
+ f.Width, f.Height, f.DurationMS = 3840, 2160, l.MaxHiMS+1
+ }, media.CodeSourceTooLong},
+ {"long class: above 1080p converts", video, func(f *probeFacts, _ *media.JobLimits) { f.Width, f.Height = 3840, 2160 }, ""},
+ {"audio ignores the short-class rule", audio, func(f *probeFacts, l *media.JobLimits) {
+ l.Above1080pNeedsLong = true
+ f.Width, f.Height = 3840, 2160
+ }, ""},
+ // HDR up to 1080p has its own maximum (spec §11 A7).
+ {"hdr 1080p over the hdr maximum", video, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = 4500000
+ f.HDR, f.DurationMS = true, 4500001
+ }, media.CodeSourceTooLong},
+ {"hdr 1080p at the hdr maximum", video, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = 4500000
+ f.HDR, f.DurationMS = true, 4500000
+ }, ""},
+ {"sdr 1080p past the hdr maximum", video, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = 4500000
+ f.DurationMS = 4500001
+ }, ""},
+ {"hdr above 1080p uses the hi maximum", video, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = 4500000
+ f.HDR, f.Width, f.Height, f.DurationMS = true, 3840, 2160, l.MaxHiMS+1
+ }, media.CodeSourceTooLong},
+ {"hdr above 1080p at the hi maximum", video, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = 4500000
+ f.HDR, f.Width, f.Height, f.DurationMS = true, 3840, 2160, l.MaxHiMS
+ }, ""},
+ {"no hdr maximum in the payload is the maximum", video, func(f *probeFacts, l *media.JobLimits) {
+ f.HDR, f.DurationMS = true, l.MaxMS
+ }, ""},
+ {"hdr maximum over the maximum is held to it", video, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = l.MaxMS + 60000
+ f.HDR, f.DurationMS = true, l.MaxMS+1
+ }, media.CodeSourceTooLong},
+ {"audio has no hdr maximum", audio, func(f *probeFacts, l *media.JobLimits) {
+ l.MaxHDRMS = 60000
+ f.HDR, f.DurationMS = true, 60001
+ }, ""},
{"over the class grant", video, func(f *probeFacts, l *media.JobLimits) { l.GrantedMS = 600000; f.DurationMS = 600001 }, media.CodeNeedsLongClass},
{"at the class grant", video, func(f *probeFacts, l *media.JobLimits) { l.GrantedMS = 600000; f.DurationMS = 600000 }, ""},
{"over the allowance", audio, func(f *probeFacts, l *media.JobLimits) {
@@ -361,7 +416,7 @@ func TestCheckOrder(t *testing.T) {
// Every check fails: no audio stream, wrong codecs, too big,
// too fast, too long for everything, Dolby Vision 5.
return probeFacts{VideoIndex: -1, AudioIndex: 2, Width: 30000, Height: 30000, FPS: 240, VideoCodec: "mpeg4", AudioCodec: "ac3", DurationMS: 99999999, DolbyVisionProfile: 5, HDR: true},
- media.JobLimits{GrantedMS: 600000, GrantedBy: grantedByClass, MaxMS: 7200000, MaxHiMS: 1800000}
+ media.JobLimits{GrantedMS: 600000, GrantedBy: grantedByClass, MaxMS: 7200000, MaxHiMS: 1800000, Above1080pNeedsLong: true}
}
old := refuseDolbyVision5
refuseDolbyVision5 = true
@@ -376,6 +431,7 @@ func TestCheckOrder(t *testing.T) {
{media.CodeSourceDimensions, func(f *probeFacts, _ *media.JobLimits) { f.Width, f.Height = 3840, 2160 }},
{media.CodeSourceFrameRate, func(f *probeFacts, _ *media.JobLimits) { f.FPS = 30 }},
{media.CodeSourceTooLong, func(f *probeFacts, _ *media.JobLimits) { f.DurationMS = 1800000 }},
+ {media.CodeNeedsLongClass, func(_ *probeFacts, l *media.JobLimits) { l.Above1080pNeedsLong = false }},
{media.CodeNeedsLongClass, func(f *probeFacts, _ *media.JobLimits) { f.DurationMS = 600000 }},
{media.CodeUnsupportedHDR, func(f *probeFacts, _ *media.JobLimits) { f.DolbyVisionProfile = 8 }},
{"", nil},
@@ -819,3 +875,33 @@ func TestCodecWhitelistMatchesTheChecks(t *testing.T) {
t.Errorf("the fixtures' provenance is not recorded: %v", err)
}
}
+
+// TestSourceFactsNameHDR (spec §11 A7): the result's source facts say
+// whether the video is HDR, on a refusal and on a success, so the console
+// can name the HDR maximum; an SDR video and an audio job say nothing.
+func TestSourceFactsNameHDR(t *testing.T) {
+ hdr := goodVideo()
+ hdr.HDR, hdr.VideoCodec = true, "hevc"
+ if s := errorFacts(hdr, media.PresetVideo720p); s == nil || !s.HDR {
+ t.Errorf("errorFacts of an HDR video: %+v", s)
+ }
+ if s := sourceFacts(hdr, media.PresetVideo720p, 1000); !s.HDR {
+ t.Errorf("sourceFacts of an HDR video: %+v", s)
+ }
+ if s := sourceFacts(goodVideo(), media.PresetVideo720p, 1000); s.HDR {
+ t.Errorf("sourceFacts of an SDR video: %+v", s)
+ }
+ if s := sourceFacts(hdr, media.PresetAudioAAC, 1000); s.HDR {
+ t.Errorf("sourceFacts of an audio job: %+v", s)
+ }
+ // The probe JSON of an HLG 1080p source over the HDR maximum, through
+ // the handler's own failure construction.
+ probe := []byte(`{"streams":[{"index":0,"codec_type":"video","codec_name":"hevc","width":1920,"height":1080,` +
+ `"avg_frame_rate":"30/1","r_frame_rate":"30/1","color_transfer":"arib-std-b67"}],"format":{"duration":"4800.000000"}}`)
+ l := limitsFor(media.PresetVideo720p)
+ l.MaxHDRMS = 4500000
+ r, refused := ProbeFailure(testExec, media.PresetVideo720p, l, probe)
+ if !refused || r.Error != media.CodeSourceTooLong || r.Source == nil || !r.Source.HDR {
+ t.Fatalf("ProbeFailure = %+v, %v", r, refused)
+ }
+}
diff --git a/internal/mediahandler/run.go b/internal/mediahandler/run.go
index ed81b496a..b6e605e15 100644
--- a/internal/mediahandler/run.go
+++ b/internal/mediahandler/run.go
@@ -233,12 +233,12 @@ func failureResult(execution, code string, facts *media.SourceFacts) media.Resul
// sourceFacts are the result's source facts: the converted duration
// (spec A2: what the job is charged for, at most the grant), the
-// source's stored dimensions and video codec (video-720p), and its
-// audio codec when it has audio.
+// source's stored dimensions, video codec and whether it is HDR
+// (video-720p), and its audio codec when it has audio.
func sourceFacts(f probeFacts, preset string, durationMS int64) *media.SourceFacts {
s := &media.SourceFacts{DurationMS: durationMS}
if preset == media.PresetVideo720p && f.VideoIndex >= 0 {
- s.Width, s.Height, s.VideoCodec = f.Width, f.Height, f.VideoCodec
+ s.Width, s.Height, s.VideoCodec, s.HDR = f.Width, f.Height, f.VideoCodec, f.HDR
}
if f.AudioIndex >= 0 {
s.AudioCodec = f.AudioCodec
diff --git a/internal/mediahandler/testdata/fmp4/provenance.txt b/internal/mediahandler/testdata/fmp4/provenance.txt
index febbd1755..0c3fff120 100644
--- a/internal/mediahandler/testdata/fmp4/provenance.txt
+++ b/internal/mediahandler/testdata/fmp4/provenance.txt
@@ -30,6 +30,15 @@ audio.mp4 recipe fixture-audio: 10 s 44.1 kHz stereo
-of csv=p=0 (the file's end, its latest track's)
args.txt the exact ffmpeg arguments of each
+These files were encoded at x264's veryfast preset, the code's preset
+when the spike made them. The spike then set x264Preset to medium (its
+Task 5 Step 2; spec §11 A7). They were not made again for that: no
+ffmpeg 7.1.5 run was at hand, and nothing readFMP4 reads depends on the
+preset (TestMuxerArgsMatchTheFixtures' fixturePreset says why). That
+test accepts veryfast as the fixtures' -preset and compares every other
+argument exactly. The next regeneration writes medium and the exception
+can go.
+
Each file is ftyp, moov, then three moof/mdat pairs (4 s, 4 s, 1 s), no
free and no mfra box.
diff --git a/internal/mediajobs/dispatch.go b/internal/mediajobs/dispatch.go
index 55761eb16..00fefdce3 100644
--- a/internal/mediajobs/dispatch.go
+++ b/internal/mediajobs/dispatch.go
@@ -182,7 +182,10 @@ func (j *Jobs) fit(k media.ClassKey, u Usage, limit int64) (grantedS, deadlineS
deadlineMS := deadline.Milliseconds()
by = grantedByClass
if limit > 0 && limit <= math.MaxInt64/(4*unitsPerMinute) {
- w := media.WeightTenths(k.Preset)
+ // The reservation's weight (spec §11 A7): the long video class's
+ // source may be above 1080p, so its grant and deadline fit the
+ // allowance at weight 2.
+ w := media.ReserveWeightTenths(k)
if w <= 0 {
return 0, 0, "", fmt.Errorf("mediajobs: preset %s has no weight", k.Preset)
}
@@ -361,9 +364,11 @@ func (j *Jobs) launch(ctx context.Context, l *Launch, now time.Time) (started bo
}
return false, ErrLaunchStale
}
- maxMS, maxHiMS := j.d.Limits.AudioMax.Milliseconds(), int64(0)
+ maxMS, maxHDRMS, maxHiMS, hiNeedsLong := j.d.Limits.AudioMax.Milliseconds(), int64(0), int64(0), false
if job.Preset == media.PresetVideo720p {
- maxMS, maxHiMS = j.d.Limits.VideoMax.Milliseconds(), j.d.Limits.VideoMaxHi.Milliseconds()
+ maxMS, maxHDRMS, maxHiMS = j.d.Limits.VideoMax.Milliseconds(), j.d.Limits.MaxHDR().Milliseconds(), j.d.Limits.VideoMaxHi.Milliseconds()
+ spec, _ := media.Class(media.ClassKey{Preset: job.Preset, Class: job.Class})
+ hiNeedsLong = !spec.TakesAbove1080p
}
p := media.Payload{
V: media.PayloadVersion, Execution: job.Execution, Preset: job.Preset,
@@ -372,8 +377,11 @@ func (j *Jobs) launch(ctx context.Context, l *Launch, now time.Time) (started bo
GrantedMS: job.GrantedS * 1000,
GrantedBy: l.grantedBy,
MaxMS: maxMS,
+ MaxHDRMS: maxHDRMS,
MaxHiMS: maxHiMS,
OutputBytes: media.MaxPutBytes,
+ // The short video class takes nothing above 1080p (A7).
+ Above1080pNeedsLong: hiNeedsLong,
},
Expiry: expiry.Unix(),
Transfers: transfers,
diff --git a/internal/mediajobs/jobs.go b/internal/mediajobs/jobs.go
index 0a80db59a..468b46dca 100644
--- a/internal/mediajobs/jobs.go
+++ b/internal/mediajobs/jobs.go
@@ -115,7 +115,7 @@ type SubmitRequest struct {
// Job is one row of media_jobs.
type Job struct {
Account, App, Incarnation, ID, Key, ETag, Preset, Class, Bucket, State, Execution, TaskARN, ErrorCode string
- Bytes, GrantedS, DeadlineS, ChargedMS, SourceMS int64
+ Bytes, GrantedS, DeadlineS, ChargedMS, SourceMS, WeightTenths int64
StartFailures int
TaskStopped, Settled bool
Result *media.Result
@@ -155,7 +155,7 @@ const (
// jobColumns is every column, in scanJob's order.
const jobColumns = `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`
+ settled, source_ms, result, error, cleanup_due, retired_at, ended_at, weight_tenths`
// rowOrder is the stable order of every scan: the primary key. Never the
// execution id (random) and never a map's iteration.
@@ -177,7 +177,7 @@ func scanJob(s scanner) (Job, error) {
var result string
if err := s.Scan(&j.Account, &j.App, &j.Incarnation, &j.ID, &j.Key, &j.ETag, &j.Bytes, &j.Preset, &j.Class, &j.Bucket, &j.State, &submitted,
&j.Execution, &j.TaskARN, &dispatched, &j.GrantedS, &j.DeadlineS, &stopped, &j.StartFailures, &j.ChargedMS,
- &settled, &j.SourceMS, &result, &j.ErrorCode, &cleanup, &retired, &ended); err != nil {
+ &settled, &j.SourceMS, &result, &j.ErrorCode, &cleanup, &retired, &ended, &j.WeightTenths); err != nil {
return Job{}, err
}
j.TaskStopped, j.Settled = stopped != 0, settled != 0
diff --git a/internal/mediajobs/jobs_test.go b/internal/mediajobs/jobs_test.go
index 64d96317c..38714743f 100644
--- a/internal/mediajobs/jobs_test.go
+++ b/internal/mediajobs/jobs_test.go
@@ -196,8 +196,13 @@ func (h *harness) run(job Job) (Job, media.Task) {
// codecSucceeds writes the three outputs and a success result.
func (h *harness) codecSucceeds(r Job, durationMS int64) {
+ h.codecSucceedsAt(r, durationMS, 0, 0)
+}
+
+// codecSucceedsAt is codecSucceeds for a source of width x height.
+func (h *harness) codecSucceedsAt(r Job, durationMS int64, width, height int) {
prefix := media.OutputPrefix(r.Key, r.ETag, r.Preset, r.Execution)
- res := media.Result{V: media.ResultVersion, Execution: r.Execution, Source: &media.SourceFacts{DurationMS: durationMS}, FFmpeg: "7.1.1"}
+ res := media.Result{V: media.ResultVersion, Execution: r.Execution, Source: &media.SourceFacts{DurationMS: durationMS, Width: width, Height: height}, FFmpeg: "7.1.1"}
for i, n := range media.OutputNames(r.Preset) {
size, etag := int64(1000+i), fmt.Sprintf("%032x", i+1)
h.gr.Objects[r.Bucket+"/"+prefix+n] = mediatest.Object{Size: size, ETag: etag}
@@ -268,10 +273,10 @@ func (h *harness) insert(j Job) {
}
return 0
}
- if _, err := h.db.Exec(`INSERT INTO media_jobs (`+jobColumns+`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
+ if _, err := h.db.Exec(`INSERT INTO media_jobs (`+jobColumns+`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
j.Account, j.App, j.Incarnation, j.ID, j.Key, j.ETag, j.Bytes, j.Preset, j.Class, j.Bucket, j.State, ms(j.SubmittedAt),
j.Execution, j.TaskARN, ms(j.DispatchedAt), j.GrantedS, j.DeadlineS, b(j.TaskStopped), j.StartFailures, j.ChargedMS,
- b(j.Settled), j.SourceMS, "", j.ErrorCode, ms(j.CleanupDue), ms(j.RetiredAt), ms(j.EndedAt)); err != nil {
+ b(j.Settled), j.SourceMS, "", j.ErrorCode, ms(j.CleanupDue), ms(j.RetiredAt), ms(j.EndedAt), j.WeightTenths); err != nil {
h.t.Fatal(err)
}
}
@@ -582,11 +587,13 @@ func TestDispatchFitsTheReservation(t *testing.T) {
h := newHarness(t, "account_long=2,long=2", map[string]int64{"acct1": 30})
a := h.submit("acct1", "shop", "uploads/a.mov", video, media.ClassLong, 2<<30)
b := h.submit("acct1", "shop", "uploads/b.mov", video, media.ClassLong, 2<<30)
+ // A long video reserves at the weight above 1080p, 2 (spec §11 A7):
+ // R = 60 minutes covers 30 of it.
l := h.mustDispatch(media.ClassLong)
- if l.job.ID != a.ID || l.job.GrantedS != 3600 || l.job.DeadlineS != 3000 || l.grantedBy != grantedByAllowance {
+ if l.job.ID != a.ID || l.job.GrantedS != 1800 || l.job.DeadlineS != 1770 || l.grantedBy != grantedByAllowance {
t.Fatalf("first: granted %d deadline %d by %s", l.job.GrantedS, l.job.DeadlineS, l.grantedBy)
}
- if u := h.usage("acct1", h.now); u.Reserved != 10*3600*1000 || u.Charged != 0 {
+ if u := h.usage("acct1", h.now); u.Reserved != 20*1800*1000 || u.Charged != 0 {
t.Fatalf("usage %+v, want 60 minutes reserved", u)
}
h.launch(l)
@@ -605,17 +612,20 @@ func TestDispatchFitsTheReservation(t *testing.T) {
if u := h.usage("acct1", h.now); u.Charged != 10*300*1000 || u.Reserved != 0 {
t.Fatalf("usage %+v", u)
}
+ // The failure had no source facts, so it was charged at weight 1: 5
+ // minutes, leaving R = 55 minutes, 27.5 at weight 2.
l = h.mustDispatch(media.ClassLong)
- if l.job.ID != b.ID || l.job.GrantedS != 3300 || l.job.DeadlineS != 3000 {
+ if l.job.ID != b.ID || l.job.GrantedS != 1650 || l.job.DeadlineS != 1620 {
t.Fatalf("second: granted %d deadline %d", l.job.GrantedS, l.job.DeadlineS)
}
h.launch(l)
req := h.eng.Requests(h.row(b).Execution)
var p media.Payload
- if len(req) != 1 || json.Unmarshal(req[0].Payload, &p) != nil || p.Limits.GrantedMS != 3300000 || p.Limits.GrantedBy != grantedByAllowance || req[0].DeadlineS != 3000 {
+ if len(req) != 1 || json.Unmarshal(req[0].Payload, &p) != nil || p.Limits.GrantedMS != 1650000 || p.Limits.GrantedBy != grantedByAllowance || req[0].DeadlineS != 1620 {
t.Fatalf("payload limits %+v", p.Limits)
}
- if p.Limits.MaxMS != h.limits.VideoMax.Milliseconds() || p.Limits.MaxHiMS != h.limits.VideoMaxHi.Milliseconds() || p.Limits.SourceBytes != h.limits.VideoBytes || p.Limits.OutputBytes != media.MaxPutBytes {
+ if p.Limits.MaxMS != h.limits.VideoMax.Milliseconds() || p.Limits.MaxHiMS != h.limits.VideoMaxHi.Milliseconds() || p.Limits.SourceBytes != h.limits.VideoBytes || p.Limits.OutputBytes != media.MaxPutBytes ||
+ p.Limits.MaxHDRMS != (75*time.Minute).Milliseconds() {
t.Fatalf("payload limits %+v", p.Limits)
}
if err := p.Validate(); err != nil {
@@ -648,7 +658,7 @@ func TestDispatchUnderThreeMinutes(t *testing.T) {
h.history("acct1", "h1", video, media.ClassShort, (50 * time.Minute).Milliseconds())
s := h.store("acct1", "blog")
h.insert(Job{Account: "acct1", App: "blog", Incarnation: s.Incarnation, ID: "r1", Key: "uploads/r1", ETag: "e", Bytes: 1, Preset: video, Class: media.ClassLong,
- Bucket: s.Bucket, State: stateRunning, SubmittedAt: h.now, Execution: strings.Repeat("a", 32), DispatchedAt: h.now, GrantedS: 480, DeadlineS: 450}) // 8 min reserved
+ Bucket: s.Bucket, State: stateRunning, SubmittedAt: h.now, Execution: strings.Repeat("a", 32), DispatchedAt: h.now, GrantedS: 240, DeadlineS: 210}) // 8 min reserved at weight 2
if u := h.usage("acct1", h.now); 2*30*unitsPerMinute-u.Charged-u.Reserved != 2*unitsPerMinute {
t.Fatalf("usage %+v, want R = 2 minutes", u)
}
@@ -1113,10 +1123,10 @@ func TestResultForAnotherExecutionDropped(t *testing.T) {
cur := h.row(b)
old := keyOf(cur)
old.execution = strings.Repeat("1", 32)
- if err := h.jobs.commitDone(tctx, old, 1000, 1000, "{}", stamp(h.now), h.now); err != nil {
+ if err := h.jobs.commitDone(tctx, old, 1000, 1000, "{}", 10, stamp(h.now), h.now); err != nil {
t.Fatal(err)
}
- if err := h.jobs.failStop(tctx, old, media.CodeEngineFailed, 1000, "", stamp(h.now), h.now); err != nil {
+ if err := h.jobs.failStop(tctx, old, media.CodeEngineFailed, 1000, "", 10, stamp(h.now), h.now); err != nil {
t.Fatal(err)
}
if got := h.row(b); got.State != stateRunning || got.Settled || got.Execution != cur.Execution {
@@ -1801,3 +1811,170 @@ func TestPassStopsTheClassAfterAFailedLaunch(t *testing.T) {
t.Fatalf("%d Runs in one pass, want 1", n)
}
}
+
+// TestShortVideoRefusesAbove1080p (spec §11 A7): the short video class's
+// payload asks the codec to refuse a source above 1080p with
+// needs_long_class; the long video class and both audio classes do not.
+func TestShortVideoRefusesAbove1080p(t *testing.T) {
+ h := newHarness(t, "account_short=4,account_long=4,long=4", nil)
+ for _, c := range []struct {
+ key, preset, class string
+ size int64
+ want bool
+ }{
+ {"uploads/short.mov", video, "", 10 << 20, true},
+ {"uploads/long.mov", video, media.ClassLong, 10 << 20, false},
+ {"uploads/short.m4a", audio, "", 10 << 20, false},
+ {"uploads/long.m4a", audio, media.ClassLong, 10 << 20, false},
+ } {
+ j := h.submit("acct1", "shop", c.key, c.preset, c.class, c.size)
+ r, _ := h.run(j)
+ req := h.eng.Requests(r.Execution)
+ var p media.Payload
+ if len(req) != 1 || json.Unmarshal(req[0].Payload, &p) != nil {
+ t.Fatalf("%s: no payload", c.key)
+ }
+ if c.preset == audio && p.Limits.MaxHDRMS != 0 {
+ t.Errorf("%s: an audio payload carries an HDR maximum %d", c.key, p.Limits.MaxHDRMS)
+ }
+ if p.Limits.Above1080pNeedsLong != c.want {
+ t.Errorf("%s (%s): Above1080pNeedsLong %v, want %v", c.key, r.Class, p.Limits.Above1080pNeedsLong, c.want)
+ }
+ }
+}
+
+// TestAbove1080pCountsTwice (Paul's option A, 2026-11-20; spec §11 A7):
+// a settled row is charged at its source's weight from the probe's
+// dimensions, stored on the row; above 1080p counts twice on the long
+// video class, at most the class's reservation weight elsewhere, and a
+// row with no source facts is charged at weight 1.
+func TestAbove1080pCountsTwice(t *testing.T) {
+ h := newHarness(t, "account_short=4,account_long=4,long=4", nil)
+ minute := time.Minute.Milliseconds()
+ type step struct {
+ key, class string
+ w, hgt int
+ durationMS int64
+ exit int
+ state, code string
+ weight int64
+ chargedUnits int64
+ }
+ runtime := 5 * minute
+ for _, c := range []step{
+ // Done: w x source duration.
+ {"uploads/4k.mov", media.ClassLong, 3840, 2160, 20 * minute, media.ExitDone, stateDone, "", 20, 20 * 20 * minute},
+ {"uploads/portrait-4k.mov", media.ClassLong, 2160, 3840, 3 * minute, media.ExitDone, stateDone, "", 20, 20 * 3 * minute},
+ {"uploads/1080p-long.mov", media.ClassLong, 1920, 1080, 20 * minute, media.ExitDone, stateDone, "", 10, 10 * 20 * minute},
+ // A short row reports a source above 1080p only from a codec that
+ // ignored its payload: still weight 1, its reservation's.
+ {"uploads/short-4k.mov", "", 3840, 2160, 2 * minute, media.ExitDone, stateDone, "", 10, 10 * 2 * minute},
+ // Failed with no result: no facts, weight 1 x engine time.
+ {"uploads/lost-facts.mov", media.ClassLong, 0, 0, 0, media.ExitFailed, stateFailed, media.CodeEngineFailed, 10, 10 * runtime},
+ } {
+ j := h.submit("acct1", "shop", c.key, video, c.class, 10<<20)
+ r, task := h.run(j)
+ h.now = h.now.Add(time.Duration(runtime) * time.Millisecond)
+ if c.exit == media.ExitDone {
+ h.codecSucceedsAt(r, c.durationMS, c.w, c.hgt)
+ }
+ h.finish(task, c.exit)
+ h.track()
+ got := h.row(j)
+ wantState(t, got, c.state, c.code, runtime)
+ if got.WeightTenths != c.weight {
+ t.Errorf("%s: weight %d, want %d", c.key, got.WeightTenths, c.weight)
+ }
+ }
+ // A failure whose result carries the probe's facts: a long 4K source
+ // refused at the probe is charged twice its engine time.
+ j := h.submit("acct1", "shop", "uploads/4k-refused.mov", video, media.ClassLong, 10<<20)
+ r, task := h.run(j)
+ h.now = h.now.Add(time.Duration(runtime) * time.Millisecond)
+ b, _ := json.Marshal(media.Result{V: media.ResultVersion, Execution: r.Execution, Error: media.CodeSourceTooLong,
+ Source: &media.SourceFacts{DurationMS: 40 * minute, Width: 3840, Height: 2160, VideoCodec: "hevc"}})
+ h.gr.Results[r.Execution] = b
+ h.finish(task, media.ExitFailed)
+ h.track()
+ got := h.row(j)
+ wantState(t, got, stateFailed, media.CodeSourceTooLong, runtime)
+ if got.WeightTenths != 20 {
+ t.Errorf("refused 4K: weight %d, want 20", got.WeightTenths)
+ }
+ // In allowance minutes: 2 x 20 + 2 x 3 + 20 + 2 + 5 + 2 x 5 = 83.
+ want := (20*20 + 20*3 + 10*20 + 10*2 + 10*5 + 20*5) * minute
+ if u := h.usage("acct1", h.now); u.Charged != want || u.Reserved != 0 {
+ t.Fatalf("usage %+v, want %d charged", u, want)
+ }
+ if m, err := h.jobs.ChargedMinutes(tctx, "acct1", h.now); err != nil || m != 83 {
+ t.Fatalf("charged %d minutes, want 83 (%v)", m, err)
+ }
+}
+
+// TestLongVideoReservesTwice: before the probe nothing says whether a
+// long video is above 1080p, so it reserves at weight 2; a short video,
+// which never converts one, and audio keep their weights.
+func TestLongVideoReservesTwice(t *testing.T) {
+ h := newHarness(t, "account_short=4,account_long=4,long=4", nil)
+ stop := media.StopGrace.Milliseconds()
+ for _, c := range []struct {
+ key, preset, class string
+ want int64
+ }{
+ {"uploads/long.mov", video, media.ClassLong, 20 * (2 * time.Hour).Milliseconds()},
+ {"uploads/short.mov", video, "", 10 * ((15 * time.Minute).Milliseconds() + stop)},
+ {"uploads/long.m4a", audio, media.ClassLong, 1 * (8 * time.Hour).Milliseconds()},
+ } {
+ before := h.usage("acct1", h.now).Reserved
+ j := h.submit("acct1", "shop", c.key, c.preset, c.class, 10<<20)
+ h.run(j)
+ if got := h.usage("acct1", h.now).Reserved - before; got != c.want {
+ t.Errorf("%s reserves %d units, want %d", c.key, got, c.want)
+ }
+ }
+}
+
+// TestLegacyRowsKeepTheirWeight: a table made before weight_tenths gains
+// it through Migrations, and a row settled before then (weight 0) is
+// charged at its preset's weight, as it was.
+func TestLegacyRowsKeepTheirWeight(t *testing.T) {
+ db, err := sql.Open("sqlite", fmt.Sprintf("file:mediajobs%d?mode=memory&cache=shared", dbSeq.Add(1)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ db.SetMaxOpenConns(1)
+ t.Cleanup(func() { db.Close() })
+ legacy := strings.Replace(Schema[0], "ended_at INTEGER NOT NULL DEFAULT 0,\n weight_tenths INTEGER NOT NULL DEFAULT 0,", "ended_at INTEGER NOT NULL DEFAULT 0,", 1)
+ if legacy == Schema[0] {
+ t.Fatal("the legacy table still has weight_tenths: the test no longer models the old schema")
+ }
+ if _, err := db.Exec(legacy); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := db.Exec(`INSERT INTO media_jobs (account, app, incarnation, job_id, key, etag, bytes, preset, class, bucket, state,
+ submitted_at, execution_id, settled, source_ms, charged_ms, ended_at, task_stopped) VALUES
+ ('acct1', 'shop', 'i', 'v', 'k', 'e', 1, ?, 'long', 'b', 'done', 1, 'x', 1, 60000, 1, ?, 1),
+ ('acct1', 'shop', 'i', 'a', 'k', 'e', 1, ?, 'long', 'b', 'failed', 1, 'y', 1, 0, 600000, ?, 1)`,
+ video, testStart.UnixMilli(), audio, testStart.UnixMilli()); err != nil {
+ t.Fatal(err)
+ }
+ for _, stmt := range append(append([]string{}, Schema...), Migrations...) {
+ if _, err := db.Exec(stmt); err != nil && !strings.Contains(err.Error(), "duplicate column") {
+ t.Fatalf("%s: %v", stmt, err)
+ }
+ }
+ // Again, as every console start runs them: a duplicate column only.
+ for _, stmt := range Migrations {
+ if _, err := db.Exec(stmt); err == nil || !strings.Contains(err.Error(), "duplicate column") {
+ t.Fatalf("a second run of %s: %v", stmt, err)
+ }
+ }
+ j := New(db, Deps{})
+ u, err := j.Usage(tctx, "acct1", testStart)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if want := int64(10*60000 + 1*600000); u.Charged != want {
+ t.Fatalf("legacy rows charged %d units, want %d", u.Charged, want)
+ }
+}
diff --git a/internal/mediajobs/metering.go b/internal/mediajobs/metering.go
index 715e50995..5a399ff10 100644
--- a/internal/mediajobs/metering.go
+++ b/internal/mediajobs/metering.go
@@ -3,6 +3,7 @@ package mediajobs
import (
"context"
"fmt"
+ "strings"
"time"
"github.com/carlosframework/platform/internal/media"
@@ -12,26 +13,47 @@ import (
// 60,000 ms at weight 10 tenths.
const unitsPerMinute = 600000
-// weightSQL is the preset's weight in tenths (media.WeightTenths) as an
-// SQL expression over the row.
-var weightSQL = fmt.Sprintf(`(CASE preset WHEN '%s' THEN %d WHEN '%s' THEN %d ELSE 0 END)`,
- media.PresetVideo720p, media.WeightTenths(media.PresetVideo720p),
- media.PresetAudioAAC, media.WeightTenths(media.PresetAudioAAC))
+// chargeWeightSQL is a settled row's weight in tenths: the weight_tenths
+// its settlement wrote (media.ChargeWeightTenths), or, on a row settled
+// before that column existed (0), its preset's weight then, at or below
+// 1080p.
+var chargeWeightSQL = fmt.Sprintf(`(CASE WHEN weight_tenths > 0 THEN weight_tenths
+ ELSE (CASE preset WHEN '%s' THEN %d WHEN '%s' THEN %d ELSE 0 END) END)`,
+ media.PresetVideo720p, media.WeightTenths(media.PresetVideo720p, false),
+ media.PresetAudioAAC, media.WeightTenths(media.PresetAudioAAC, false))
+
+// reserveWeightSQL is a running row's weight in tenths, by its class
+// (media.ReserveWeightTenths): the long video class at the weight above
+// 1080p, since nothing is known of the picture before the probe.
+var reserveWeightSQL = func() string {
+ b := strings.Builder{}
+ b.WriteString(`(CASE`)
+ for _, p := range []string{media.PresetVideo720p, media.PresetAudioAAC} {
+ for _, c := range []string{media.ClassShort, media.ClassLong} {
+ fmt.Fprintf(&b, ` WHEN preset = '%s' AND class = '%s' THEN %d`, p, c, media.ReserveWeightTenths(media.ClassKey{Preset: p, Class: c}))
+ }
+ }
+ b.WriteString(` ELSE 0 END)`)
+ return b.String()
+}()
// stopGraceS is the stop grace in whole seconds.
const stopGraceS = int64(media.StopGrace / time.Second)
// usageSQL is an account's units in the month [?, ?): charged is every
// settled row that ended in it, a done row by w × source_ms and any other
-// by w × charged_ms; reserved is every running unsettled row's
-// w × max(granted_s, deadline_s + stop grace) in milliseconds, whatever
-// month it was dispatched in.
+// by w × charged_ms, w its charge weight; reserved is every running
+// unsettled row's w × max(granted_s, deadline_s + stop grace) in
+// milliseconds, w its class's reservation weight, whatever month it was
+// dispatched in. A charge weight is never above its class's reservation
+// weight (media.ChargeWeightTenths), so settling never adds to what a
+// running row held.
var usageSQL = fmt.Sprintf(`SELECT
COALESCE(SUM(CASE WHEN settled = 1 AND ended_at >= ? AND ended_at < ?
THEN %[1]s * (CASE WHEN state = 'done' THEN source_ms ELSE charged_ms END) ELSE 0 END), 0),
COALESCE(SUM(CASE WHEN settled = 0 AND state = 'running' AND execution_id != ''
- THEN %[1]s * MAX(granted_s, deadline_s + %[2]d) * 1000 ELSE 0 END), 0)
- FROM media_jobs WHERE account = ?`, weightSQL, stopGraceS)
+ THEN %[2]s * MAX(granted_s, deadline_s + %[3]d) * 1000 ELSE 0 END), 0)
+ FROM media_jobs WHERE account = ?`, chargeWeightSQL, reserveWeightSQL, stopGraceS)
// monthOf is the UTC month that holds t, as its first instant.
func monthOf(t time.Time) time.Time {
diff --git a/internal/mediajobs/schema.go b/internal/mediajobs/schema.go
index 8379902cd..98885ebd5 100644
--- a/internal/mediajobs/schema.go
+++ b/internal/mediajobs/schema.go
@@ -2,7 +2,12 @@ package mediajobs
// Schema creates the media_jobs table: one row per job, changed only in
// transactions (spec §5.3). Times are Unix milliseconds; task_stopped
-// starts 1 so a queued row never counts toward capacity.
+// starts 1 so a queued row never counts toward capacity. weight_tenths is
+// the weight a settled row was charged at (media.ChargeWeightTenths, spec
+// §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).
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,
@@ -16,8 +21,16 @@ var Schema = []string{
result TEXT NOT NULL DEFAULT '', error TEXT NOT NULL DEFAULT '',
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,
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)`,
`CREATE INDEX IF NOT EXISTS media_jobs_queue ON media_jobs (state, class, submitted_at)`,
}
+
+// Migrations bring a media_jobs table made by an earlier Schema up to
+// this one: additive columns, each failing with "duplicate column" once
+// 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`,
+}
diff --git a/internal/mediajobs/track.go b/internal/mediajobs/track.go
index 6a98ffefb..a4c0e8701 100644
--- a/internal/mediajobs/track.go
+++ b/internal/mediajobs/track.go
@@ -120,7 +120,7 @@ func (j *Jobs) trackOne(ctx context.Context, r Job, t media.Task, now time.Time)
}
ran := runtimeMS(r, t)
if retired {
- return j.failStop(ctx, k, media.CodeRetired, ran, "", ended, now)
+ return j.failStop(ctx, k, media.CodeRetired, ran, "", chargeWeight(r, nil), ended, now)
}
// The result object is read on every stop with a start time: a failed
// stop takes its error from it when there is one (pre-flight F17).
@@ -139,6 +139,14 @@ func (j *Jobs) trackOne(ctx context.Context, r Job, t media.Task, now time.Time)
parsed = true
}
}
+ // The charge weight comes from the probe's dimensions in a result
+ // that parsed, whatever the outcome; with none it is the class's
+ // weight at or below 1080p (spec §11 A7).
+ var facts *media.SourceFacts
+ if parsed {
+ facts = res.Source
+ }
+ weight := chargeWeight(r, facts)
exit0 := t.CodecExit != nil && *t.CodecExit == media.ExitDone
if exit0 && !(parsed && res.Error != "") {
code := ""
@@ -158,7 +166,7 @@ func (j *Jobs) trackOne(ctx context.Context, r Job, t media.Task, now time.Time)
}
}
if code != "" {
- return j.failStop(ctx, k, code, ran, "", ended, now)
+ return j.failStop(ctx, k, code, ran, "", weight, ended, now)
}
// The stored result is the validated one, re-encoded, not the
// bytes as read.
@@ -169,13 +177,23 @@ func (j *Jobs) trackOne(ctx context.Context, r Job, t media.Task, now time.Time)
if beforeSuccessCommit != nil {
beforeSuccessCommit()
}
- return j.commitDone(ctx, k, ran, res.Source.DurationMS, string(validated), ended, now)
+ return j.commitDone(ctx, k, ran, res.Source.DurationMS, string(validated), weight, ended, now)
}
resultErr, stored := "", ""
if parsed && res.Error != "" {
resultErr, stored = res.Error, string(raw)
}
- return j.failStop(ctx, k, media.ClassifyStop(resultErr, t.CodecExit, t.DeadlineExit), ran, stored, ended, now)
+ return j.failStop(ctx, k, media.ClassifyStop(resultErr, t.CodecExit, t.DeadlineExit), ran, stored, weight, ended, now)
+}
+
+// chargeWeight is the weight a settled row is charged at
+// (media.ChargeWeightTenths): above 1080p when the probe's facts say so,
+// on a class that takes such a source; otherwise, facts or none, the
+// weight at or below 1080p. It is never above the row's reservation
+// weight.
+func chargeWeight(r Job, s *media.SourceFacts) int64 {
+ hi := r.Preset == media.PresetVideo720p && s != nil && media.Above1080p(s.Width, s.Height)
+ return media.ChargeWeightTenths(media.ClassKey{Preset: r.Preset, Class: r.Class}, hi)
}
// checkOutputs HEADs each output the result reports: absent, a size other
@@ -214,19 +232,20 @@ 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.
-func (j *Jobs) commitDone(ctx context.Context, k key, chargedMS, sourceMS int64, result string, ended int64, now time.Time) error {
+// ended is endedAt's; cleanup is due at now, the observation. 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 = ?
- WHERE `+keyWhere+liveGuard+` AND retired_at = 0`, k.args(chargedMS, sourceMS, result, due, ended)...)
+ 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)...)
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 = ?
- WHERE `+keyWhere+liveGuard+` AND retired_at > 0`, k.args(media.CodeRetired, chargedMS, due, ended)...)
+ 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)...)
if err != nil {
return err
}
@@ -240,14 +259,15 @@ func (j *Jobs) commitDone(ctx context.Context, k key, chargedMS, sourceMS int64,
}
// failStop is "stopped, failure": failed with code, charged ECS's
-// runtime, settled, stopped, ended at ended (endedAt's), cleanup due now.
-// 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, ended int64, now time.Time) error {
+// 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 "".
+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 = ?
- WHERE `+keyWhere+liveGuard, k.args(code, chargedMS, result, due, ended)...)
+ settled = 1, task_stopped = 1, cleanup_due = ?, ended_at = ?, weight_tenths = ?
+ WHERE `+keyWhere+liveGuard, k.args(code, chargedMS, result, due, ended, weight)...)
if err == nil && !ok {
j.logf("failed %s %s: dropped, the row is no longer live", k, code)
}
@@ -269,7 +289,8 @@ func (j *Jobs) failStop(ctx context.Context, k key, code string, chargedMS int64
// is charged its full bound, as ECS can no longer say how long the task
// ran; with none it is charged nothing. The test is in the UPDATE itself,
// so it reads the row as it settles. ECS has no stop time to give, so
-// ended_at is endedAt's fallback, the observation time now.
+// ended_at is endedAt's fallback, the observation time now. No result is
+// read, so the weight is the class's at or below 1080p (chargeWeight).
func (j *Jobs) lostAfterRetention(ctx context.Context, r Job, now time.Time) error {
bound := r.DispatchedAt.Add(time.Duration(r.DeadlineS)*time.Second + media.StopGrace + media.EngineRecordRetention)
if !now.After(bound) {
@@ -280,8 +301,8 @@ func (j *Jobs) lostAfterRetention(ctx context.Context, r Job, now time.Time) err
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 = '',
- settled = 1, task_stopped = 1, cleanup_due = ?, ended_at = ?
- WHERE `+keyWhere+liveGuard, k.args(media.CodeEngineLost, (r.DeadlineS+stopGraceS)*1000, cleanup, stamp(now))...)
+ settled = 1, task_stopped = 1, cleanup_due = ?, ended_at = ?, weight_tenths = ?
+ WHERE `+keyWhere+liveGuard, k.args(media.CodeEngineLost, (r.DeadlineS+stopGraceS)*1000, cleanup, stamp(now), chargeWeight(r, nil))...)
if err == nil && !ok {
j.logf("lost %s: dropped, the row is no longer live", k)
}
diff --git a/internal/plans/catalog.go b/internal/plans/catalog.go
index 365e391d3..3f2ff1ebc 100644
--- a/internal/plans/catalog.go
+++ b/internal/plans/catalog.go
@@ -51,7 +51,7 @@ type Limits struct {
EmailPerHour int `json:"email_per_hour,omitempty"`
BandwidthBytesMonth int64 `json:"bandwidth_bytes_month,omitempty"`
PDFRendersMonth int `json:"pdf_renders_month,omitempty"`
- MediaMinutesMonth int `json:"media_minutes_month,omitempty"` // per UTC month: a video minute is 1, an audio minute 0.1 (internal/mediajobs); 0 is no limit
+ MediaMinutesMonth int `json:"media_minutes_month,omitempty"` // per UTC month: a video minute is 1, above 1080p 2, an audio minute 0.1 (internal/mediajobs); 0 is no limit
CustomDomains bool `json:"custom_domains,omitempty"`
Fleets bool `json:"fleets,omitempty"`
MinScheduleSeconds int `json:"min_schedule_seconds,omitempty"`
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index d3306c806..7891132dc 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -271,4 +271,5 @@ plan14-root-reads-fleet-seeded-create-3.tsv 8a0a9cca336d3e695b79990a9aeda17f5ee8
plan14-root-reads-fleet-restart-wake.tsv 2967f0ba9722910621cedcfafc270cea3268a6de55738667574a20e67fd7f4e5
plan14-root-reads-ci-opentofu-tests.tsv 57ba3cadaf39de336f9a077d59a80148012e6d202de9059c166ce4f7dfc51ee0
plan14-root-reads-media-spike-fixes.tsv 194e88ad9cd7413c93b1181c0ac1e962107039ad84525e065893a8c14cdb3138
+plan14-root-reads-media-spike-values.tsv 194e88ad9cd7413c93b1181c0ac1e962107039ad84525e065893a8c14cdb3138
plan14-root-reads-path-routes-across-boxes.tsv f959a3626e83650aaad1880eecc3feddebdbd78474937f4c619df658eb46a1d6
diff --git a/internal/provision/testdata/plan14-root-reads-media-spike-values.tsv b/internal/provision/testdata/plan14-root-reads-media-spike-values.tsv
new file mode 100644
index 000000000..11f945129
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-media-spike-values.tsv
@@ -0,0 +1,3 @@
+# Census overlay media-spike-values, written by census-propose (#369). census-ruling-media-spike-values, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-media-spike-values.md.
+# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@coverage internal/plans 9231d5b5fe94606375698ea9dffab8cc129d161f02677f976a827a689ff09268
diff --git a/internal/sim/mediajobs/actions_test.go b/internal/sim/mediajobs/actions_test.go
index 7a61251a1..752bd91a3 100644
--- a/internal/sim/mediajobs/actions_test.go
+++ b/internal/sim/mediajobs/actions_test.go
@@ -350,14 +350,15 @@ func actFinishDone(w *world) bool {
kind += "+oversized"
w.events["oversized-result"]++
}
- if !w.codecSucceeds(t.StartedBy, d, pad) {
+ pic := pictures[w.rng.Intn(len(pictures))]
+ if !w.codecSucceedsAs(t.StartedBy, d, pad, pic) {
return false
}
if err := w.engine.Finish(t.ARN, w.now, media.ExitDone); err != nil {
w.fail("MODEL", "finish %s: %v", t.ARN, err)
return false
}
- w.logf("engine finish %s exit 0, duration %d ms (%s)", t.ARN, d, kind)
+ w.logf("engine finish %s exit 0, duration %d ms, %dx%d (%s)", t.ARN, d, pic.Width, pic.Height, kind)
return true
}
@@ -373,7 +374,13 @@ func actFinishError(w *world) bool {
}
sort.Strings(codes)
code := codes[w.rng.Intn(len(codes))]
- w.codecFails(t.StartedBy, code)
+ // Half the failures carry the probe's facts, as a refusal after the
+ // probe does.
+ var pic *sourcePicture
+ if w.rng.Intn(2) == 0 {
+ pic = &pictures[w.rng.Intn(len(pictures))]
+ }
+ w.codecFails(t.StartedBy, code, pic)
if err := w.engine.Finish(t.ARN, w.now, media.ExitFailed); err != nil {
w.fail("MODEL", "finish %s: %v", t.ARN, err)
return false
diff --git a/internal/sim/mediajobs/invariants_test.go b/internal/sim/mediajobs/invariants_test.go
index 127a23d32..5b00fd4f3 100644
--- a/internal/sim/mediajobs/invariants_test.go
+++ b/internal/sim/mediajobs/invariants_test.go
@@ -22,7 +22,7 @@ import (
// transaction that writes charged_ms and the terminal state, and
// nothing writes charged_ms afterwards. Checked: settled exactly when
// terminal; no charge on an unsettled row; a settled row's state,
-// charged_ms, source_ms and error never change.
+// charged_ms, source_ms, error and weight_tenths never change.
// - I3. Never undercharged. charged_ms is at least the time ECS reports
// the task ran, or the row's full bound when ECS cannot say. Amended
// by A5: this holds for a row whose task was observed (it settled
@@ -52,6 +52,22 @@ import (
// with a done row charged w × source_ms. Every settled row's charge
// is at least 0 and at most its reservation, and no execution is
// dispatched or run on a revision the fake engine marks misconfigured.
+// The weights are spec §11 A7's (Paul's option A, 2026-11-20), stated
+// here from the spec and not from the job table: a running row is
+// reserved at its class's weight, 2 for a long video (its source may
+// be above 1080p), 1 for a short video (which never converts one) and
+// 0.1 for audio; a settled row is charged at the weight its row
+// stores, which is never above that reservation weight and is 2 only
+// on a long video whose codec reported a source above 1080p.
+// - I3 (weight). A charged row settles at weight 2 exactly when it is a
+// long video and the job table read, in the step it settled, a result
+// whose source facts its codec wrote above 1080p. Any other charged
+// row settles at its preset's weight at or below 1080p: one that
+// settled without reading a result (retired before the read,
+// engine_lost), one whose result had no facts or did not parse, and
+// every short video. The read is recorded by recGrants.ReadResult, so
+// a row retired after its result was read (commitDone's retired
+// fallback) is held to weight 2 and one retired before it to 1.
// - I9. No release while a task might exist (whole-branch review round
// 2, A5). A row frees its place (task_stopped false to true) only when
// ECS's record shows its task stopped, or no Run of its execution
@@ -89,11 +105,12 @@ type row struct {
SourceMS int64
Result, Error string
CleanupDue, RetiredAt, EndedAt int64
+ WeightTenths 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`
+ settled, source_ms, result, error, cleanup_due, retired_at, ended_at, weight_tenths`
func (r row) id() string {
return r.Account + "/" + r.App + "/" + r.Incarnation + "/" + r.JobID
@@ -116,7 +133,7 @@ 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); err != nil {
+ &r.Settled, &r.SourceMS, &r.Result, &r.Error, &r.CleanupDue, &r.RetiredAt, &r.EndedAt, &r.WeightTenths); err != nil {
w.fail("MODEL", "scan row: %v", err)
return nil
}
@@ -130,17 +147,47 @@ 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.Settled, r.SourceMS, r.Result, r.Error, r.CleanupDue, r.RetiredAt, r.EndedAt, r.WeightTenths)
if err != nil {
panic(fmt.Sprintf("insert row: %v", err))
}
}
+// The weights in tenths, from spec §7.3 and §11 A7, written out here so
+// the checker does not take them from the code it checks.
+const (
+ simVideoWeight = 10 // a video minute at or below 1080p
+ simVideoHiWeight = 20 // a video minute above 1080p (Paul's option A)
+ simAudioWeight = 1 // an audio minute
+)
+
+// baseWeight is a preset's weight at or below 1080p.
+func baseWeight(preset string) int64 {
+ switch preset {
+ case media.PresetVideo720p:
+ return simVideoWeight
+ case media.PresetAudioAAC:
+ return simAudioWeight
+ }
+ return 0
+}
+
+// reserveWeight is the weight a running row is reserved at: the most its
+// class can charge. Only the long video class converts a source above
+// 1080p.
+func reserveWeight(r row) int64 {
+ if r.Preset == media.PresetVideo720p && r.Class == media.ClassLong {
+ return simVideoHiWeight
+ }
+ return baseWeight(r.Preset)
+}
+
// reservation is what a dispatched row may cost at most, in units:
-// w × max(granted_s, deadline_s + stop grace), in milliseconds.
+// w × max(granted_s, deadline_s + stop grace), in milliseconds, w its
+// reservation weight.
func reservation(r row) int64 {
if r.Execution == "" {
return 0
@@ -149,20 +196,30 @@ func reservation(r row) int64 {
if b := (r.DeadlineS + int64(media.StopGrace/time.Second)) * 1000; b > ms {
ms = b
}
- return media.WeightTenths(r.Preset) * ms
+ return reserveWeight(r) * ms
+}
+
+// chargedWeight is the weight a settled row's charge is read at: the
+// weight it stores, or its preset's base weight for a row that stores
+// none (settled before the column, or charged nothing).
+func chargedWeight(r row) int64 {
+ if r.WeightTenths > 0 {
+ return r.WeightTenths
+ }
+ return baseWeight(r.Preset)
}
// charge is a settled row's charge in units: w × source_ms for done,
-// w × charged_ms otherwise.
+// w × charged_ms otherwise, w its charged weight.
func charge(r row) int64 {
ms := r.ChargedMS
if r.State == "done" {
ms = r.SourceMS
}
- if ms > math.MaxInt64/10 {
+ if ms > math.MaxInt64/simVideoHiWeight {
return math.MaxInt64 // never wraps to a small figure
}
- return media.WeightTenths(r.Preset) * ms
+ return chargedWeight(r) * ms
}
// satAdd adds without wrapping past math.MaxInt64.
@@ -225,9 +282,9 @@ func check(w *world) {
if !p.Settled {
continue
}
- if r, ok := cur[id]; ok && (!r.Settled || r.State != p.State || r.ChargedMS != p.ChargedMS || r.SourceMS != p.SourceMS || r.Error != p.Error) {
- w.fail("I2", "settled row %s changed: %s %d ms (source %d, %q) became %s %d ms (source %d, %q), settled %v",
- shortID(p.JobID), p.State, p.ChargedMS, p.SourceMS, p.Error, r.State, r.ChargedMS, r.SourceMS, r.Error, r.Settled)
+ if r, ok := cur[id]; ok && (!r.Settled || r.State != p.State || r.ChargedMS != p.ChargedMS || r.SourceMS != p.SourceMS || r.Error != p.Error || r.WeightTenths != p.WeightTenths) {
+ w.fail("I2", "settled row %s changed: %s %d ms (source %d, %q, weight %d) became %s %d ms (source %d, %q, weight %d), settled %v",
+ shortID(p.JobID), p.State, p.ChargedMS, p.SourceMS, p.Error, p.WeightTenths, r.State, r.ChargedMS, r.SourceMS, r.Error, r.WeightTenths, r.Settled)
}
}
@@ -308,6 +365,44 @@ func check(w *world) {
}
}
+ // I3 (weight) and I8 (weight): the weight a charged row settles at.
+ // A row first seen settled takes the reads of this step as the ones
+ // its settlement made.
+ for _, r := range rows {
+ if !r.Settled || r.Execution == "" {
+ continue
+ }
+ if p, had := w.prev[r.id()]; !had || !p.Settled {
+ w.readAtEnd[r.Execution] = w.readNow[r.Execution]
+ }
+ if r.State != "done" && r.ChargedMS == 0 {
+ continue
+ }
+ longVideo := r.Preset == media.PresetVideo720p && r.Class == media.ClassLong
+ reportedHi := w.reported[r.Execution] && w.hi[r.Execution]
+ want := baseWeight(r.Preset)
+ if longVideo && reportedHi && w.readAtEnd[r.Execution] {
+ want = simVideoHiWeight
+ }
+ got := chargedWeight(r)
+ switch {
+ case got > reserveWeight(r):
+ w.fail("I8", "row %s %s is charged at weight %d, over its class's reservation weight %d", shortID(r.JobID), r.State, got, reserveWeight(r))
+ case got == simVideoHiWeight && !(longVideo && reportedHi):
+ w.fail("I8", "row %s %s is charged at weight %d, and no long-class result reported a source above 1080p", shortID(r.JobID), r.State, got)
+ case got != want:
+ w.fail("I3", "row %s %s %q is charged at weight %d, want %d from the result its settlement read", shortID(r.JobID), r.State, r.Error, got, want)
+ }
+ if p, had := w.prev[r.id()]; had && !p.Settled {
+ switch {
+ case got == simVideoHiWeight:
+ w.events["charged-above-1080p"]++
+ case reportedHi && !longVideo:
+ w.events["above-1080p-on-short"]++
+ }
+ }
+ }
+
// I4.
for id, p := range w.prev {
if _, ok := cur[id]; ok {
@@ -456,6 +551,7 @@ func check(w *world) {
}
w.prev = cur
+ w.readNow = map[string]bool{}
}
// cleanupDue reports whether a row's cleanup is due at now (P1).
diff --git a/internal/sim/mediajobs/sim_test.go b/internal/sim/mediajobs/sim_test.go
index 4bbe74f3a..7e1ac9098 100644
--- a/internal/sim/mediajobs/sim_test.go
+++ b/internal/sim/mediajobs/sim_test.go
@@ -62,6 +62,8 @@ var eventFloors = map[string]int{
"destroy": 90,
"destroy-refused": 25,
"recreated": 100,
+ "charged-above-1080p": 1,
+ "above-1080p-on-short": 2,
}
// 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 9969ad309..2ce5c78c4 100644
--- a/internal/sim/mediajobs/witness_test.go
+++ b/internal/sim/mediajobs/witness_test.go
@@ -564,6 +564,97 @@ func TestWitnessTwentyMinutesLeft(t *testing.T) {
}
}
+// TestWitnessAbove1080pWeighsTwice (spec §11 A7, Paul's option A): an
+// account with a limit of 30 (R = 60 minutes) runs a long video, which
+// reserves at weight 2 and so is granted 30 minutes; its codec reports 30
+// minutes of 4K, charged 60, exactly twice the limit and never past it. A
+// short video whose codec ignores Above1080pNeedsLong and reports 4K is
+// charged at weight 1, its reservation's.
+func TestWitnessAbove1080pWeighsTwice(t *testing.T) {
+ w := newWitness(t, "", map[string]int64{"acct1": 30})
+ w.object(shop, "uploads/clip-1.mov", 2<<30)
+ job, task := w.runJob(t, shop, "uploads/clip-1.mov", video, "")
+ r := w.rowOf(t, shop, job.ID)
+ if r.Class != media.ClassLong || r.GrantedS != 1800 || r.DeadlineS != 1770 || reservation(r) != 60*600000 {
+ t.Fatalf("long video: class %s, granted %d s, deadline %d s, reserved %d", r.Class, r.GrantedS, r.DeadlineS, reservation(r))
+ }
+ _, p, _ := w.lastRequest(r.Execution)
+ if p.Limits.Above1080pNeedsLong || p.Limits.GrantedMS != 1800000 {
+ t.Fatalf("long payload limits %+v", p.Limits)
+ }
+ w.now = w.now.Add(25 * time.Minute)
+ w.codecSucceedsAs(r.Execution, (30 * time.Minute).Milliseconds(), 0, sourcePicture{3840, 2160, true})
+ w.finish(t, task, media.ExitDone)
+ w.track(t)
+ r = w.rowOf(t, shop, job.ID)
+ if r.State != "done" || r.WeightTenths != 20 || charge(r) != 60*600000 {
+ t.Fatalf("4K done: %s weight %d charge %d", r.State, r.WeightTenths, charge(r))
+ }
+ if m, err := w.jobs.ChargedMinutes(ctx, "acct1", w.now); err != nil || m != 60 {
+ t.Fatalf("charged %d minutes, want 60 (%v)", m, err)
+ }
+
+ other := appRef{"acct2", "shop"}
+ w.object(other, "uploads/clip-2.mov", 10<<20)
+ sj, st := w.runJob(t, other, "uploads/clip-2.mov", video, "")
+ sr := w.rowOf(t, other, sj.ID)
+ if _, p, _ := w.lastRequest(sr.Execution); sr.Class != media.ClassShort || !p.Limits.Above1080pNeedsLong {
+ t.Fatalf("short payload limits %+v (class %s)", p.Limits, sr.Class)
+ }
+ w.now = w.now.Add(5 * time.Minute)
+ w.codecSucceedsAs(sr.Execution, (4 * time.Minute).Milliseconds(), 0, sourcePicture{2160, 3840, false})
+ w.finish(t, st, media.ExitDone)
+ w.track(t)
+ if sr = w.rowOf(t, other, sj.ID); sr.State != "done" || sr.WeightTenths != 10 || charge(sr) > reservation(sr) {
+ t.Fatalf("short 4K: %s weight %d charge %d reservation %d", sr.State, sr.WeightTenths, charge(sr), reservation(sr))
+ }
+}
+
+// TestWitnessRetiredBeforeAndAfterTheRead (spec §11 A7; Astra round 1,
+// P2-1): a long 4K video whose app is retired after the job table read its
+// result settles failed retired at weight 2, the weight of the facts it
+// read (commitDone's retired fallback); one retired before the read
+// settles at weight 1, as no facts were read.
+func TestWitnessRetiredBeforeAndAfterTheRead(t *testing.T) {
+ w := newWitness(t, "", nil)
+ four := sourcePicture{3840, 2160, true}
+
+ w.object(shop, "uploads/clip-1.mov", 2<<30)
+ after, task := w.runJob(t, shop, "uploads/clip-1.mov", video, "")
+ ra := w.rowOf(t, shop, after.ID)
+ w.now = w.now.Add(5 * time.Minute)
+ w.codecSucceedsAs(ra.Execution, (5 * time.Minute).Milliseconds(), 0, four)
+ w.finish(t, task, media.ExitDone)
+ w.retireOnRead = ra.Execution
+ w.track(t)
+ if w.retireOnRead != "" {
+ t.Fatal("the result was never read")
+ }
+ ra = w.rowOf(t, shop, after.ID)
+ wantRow(t, ra, "failed", media.CodeRetired, (5 * time.Minute).Milliseconds())
+ if ra.WeightTenths != 20 {
+ t.Fatalf("retired after the read: weight %d, want 20", ra.WeightTenths)
+ }
+
+ blog := appRef{"acct1", "blog"}
+ w.object(blog, "uploads/clip-2.mov", 2<<30)
+ before, task2 := w.runJob(t, blog, "uploads/clip-2.mov", video, "")
+ rb := w.rowOf(t, blog, before.ID)
+ w.now = w.now.Add(5 * time.Minute)
+ w.codecSucceedsAs(rb.Execution, (5 * time.Minute).Milliseconds(), 0, four)
+ w.finish(t, task2, media.ExitDone)
+ if _, err := w.jobs.Retire(ctx, mj.Scope{Account: blog.Account, App: blog.App}, w.now); err != nil {
+ t.Fatal(err)
+ }
+ w.clean(t)
+ w.track(t)
+ rb = w.rowOf(t, blog, before.ID)
+ wantRow(t, rb, "failed", media.CodeRetired, (5 * time.Minute).Milliseconds())
+ if rb.WeightTenths != 10 {
+ t.Fatalf("retired before the read: weight %d, want 10", rb.WeightTenths)
+ }
+}
+
// TestWitnessHostileResults (spec §11 A2): durations outside 0 to the
// grant fail engine_failed charged ECS's runtime; 0 and 1 ms commit done,
// charged by duration, with charged_ms still ECS's 9-minute runtime.
@@ -841,6 +932,22 @@ func TestCheckerCatchesEachInvariant(t *testing.T) {
t.Fatal(err)
}
}},
+ {"I3", "a long video settled at weight 1 after reading a 4K result", func(t *testing.T, f fixture) {
+ x := settledFailed(f, media.ClassLong, 10)
+ f.w.reported[x.Execution], f.w.hi[x.Execution], f.w.readNow[x.Execution] = true, true, true
+ f.w.insertRow(x)
+ }},
+ {"I8", "a short video settled at weight 2", func(t *testing.T, f fixture) {
+ x := settledFailed(f, media.ClassShort, 20)
+ f.w.reported[x.Execution], f.w.hi[x.Execution], f.w.readNow[x.Execution] = true, true, true
+ f.w.insertRow(x)
+ }},
+ {"I8", "a long video settled at weight 2 with no report above 1080p", func(t *testing.T, f fixture) {
+ f.w.insertRow(settledFailed(f, media.ClassLong, 20))
+ }},
+ {"I2", "a settled row's stored weight rewritten, its charge the same", func(t *testing.T, f fixture) {
+ f.w.exec(t, `UPDATE media_jobs SET weight_tenths = 10 WHERE job_id = ?`, f.d.JobID)
+ }},
{"I8", "an execution run on a refused revision", func(t *testing.T, f fixture) {
k := media.ClassKey{Preset: audio, Class: media.ClassShort}
f.w.engine.Misconfigure(k, "depends_on")
@@ -866,6 +973,19 @@ func TestCheckerCatchesEachInvariant(t *testing.T) {
}
}
+// settledFailed is a video row of class that failed engine_failed and
+// settled at weight, charged 1 s, with no task ever observed (so I3's
+// charge checks pass and only the weight is in question).
+func settledFailed(f fixture, class string, weight int64) row {
+ x := f.q
+ x.Key, x.Class = "uploads/clip-5.mov", class
+ x.JobID = media.JobID(x.Key, x.ETag, video, class)
+ x.State, x.Error, x.Execution = "failed", media.CodeEngineFailed, strings.Repeat("6", 32)
+ x.GrantedS, x.DeadlineS, x.ChargedMS, x.Settled, x.TaskStopped = 600, 900, 1000, true, true
+ x.EndedAt, x.WeightTenths = f.w.now.UnixMilli(), weight
+ return x
+}
+
func (w *world) exec(t *testing.T, q string, args ...any) {
t.Helper()
res, err := w.db.Exec(q, args...)
diff --git a/internal/sim/mediajobs/world_test.go b/internal/sim/mediajobs/world_test.go
index 116c8023f..befcd02c6 100644
--- a/internal/sim/mediajobs/world_test.go
+++ b/internal/sim/mediajobs/world_test.go
@@ -205,6 +205,28 @@ func (g *recGrants) Grant(c context.Context, r media.GrantRequest) (media.Transf
return tr, exp, err
}
+// ReadResult notes each result the job table read whole (the settlement
+// that follows takes its weight from it, spec §11 A7) and, when the world
+// asks, retires the execution's app right after the read, before the
+// settlement commits.
+func (g *recGrants) ReadResult(c context.Context, execution string) ([]byte, error) {
+ b, err := g.FakeGrants.ReadResult(c, execution)
+ if err == nil {
+ g.w.readNow[execution] = true
+ }
+ if g.w.retireOnRead != "" && g.w.retireOnRead == execution {
+ g.w.retireOnRead = ""
+ for _, r := range g.w.readRows() {
+ if r.Execution == execution {
+ if _, rerr := g.w.jobs.Retire(c, mj.Scope{Account: r.Account, App: r.App}, g.w.now); rerr != nil {
+ g.w.fail("MODEL", "retire on read: %v", rerr)
+ }
+ }
+ }
+ }
+ return b, 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 {
@@ -239,11 +261,17 @@ type world struct {
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
- ecs map[string]media.Task // the last record ECS showed for each execution, kept after it expires
- prev map[string]row // the rows at the last check, by rowKey
- destroyed []destroyEvent
+ 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
+ prev map[string]row // the rows at the last check, by rowKey
+ destroyed []destroyEvent
trace []string
violations []string
@@ -268,7 +296,9 @@ func buildWorld(seed int64, rng *rand.Rand, verbose bool, limits media.Limits, a
seed: seed, rng: rng, verbose: verbose, now: simStart,
limits: limits, allowance: allow,
keys: map[appRef][]string{}, purging: map[appRef]bool{},
- mayExist: map[string]bool{}, observed: map[string]bool{}, ecs: map[string]media.Task{}, prev: map[string]row{},
+ 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{},
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))
@@ -421,8 +451,38 @@ func outputKeys(p media.Payload) (bucket, prefix string, err error) {
// codecSucceeds plays the codec's success: the three outputs uploaded
// under the payload's prefix and the result object written. pad makes the
-// result that many bytes longer (over 64 KiB is refused at ReadResult).
+// result that many bytes longer (over 64 KiB is refused at ReadResult). A
+// video source is 1920x1080 SDR.
func (w *world) codecSucceeds(execution string, durationMS int64, pad int) bool {
+ return w.codecSucceedsAs(execution, durationMS, pad, sourcePicture{1920, 1080, false})
+}
+
+// sourcePicture is a video source's stored size and transfer, as a
+// result's facts report them.
+type sourcePicture struct {
+ Width, Height int
+ HDR bool
+}
+
+// pictures are the video sources the sweep's codec reports: 1080p either
+// way up, HDR or not, and 4K either way up (spec §11 A7: above 1080p
+// counts twice). A short-class row reporting 4K is a codec that ignored
+// its payload's Above1080pNeedsLong: the charge must still not pass the
+// row's reservation.
+var pictures = []sourcePicture{
+ {1920, 1080, false}, {1080, 1920, true}, {1280, 720, false},
+ {3840, 2160, true}, {2160, 3840, false}, {2560, 1440, false},
+}
+
+// recordFacts notes what a result the job table will parse says of its
+// source: whether it has facts, and whether they are above 1080p.
+func (w *world) recordFacts(execution, preset string, pic *sourcePicture) {
+ w.reported[execution] = pic != nil
+ w.hi[execution] = pic != nil && preset == media.PresetVideo720p && media.Above1080p(pic.Width, pic.Height)
+}
+
+// codecSucceedsAs is codecSucceeds for a video source of pic.
+func (w *world) codecSucceedsAs(execution string, durationMS int64, pad int, pic sourcePicture) bool {
_, p, ok := w.lastRequest(execution)
if !ok {
return false
@@ -438,10 +498,16 @@ func (w *world) codecSucceeds(execution string, durationMS int64, pad int) bool
FFmpeg: "7.1.1" + strings.Repeat(" ", pad),
}
if p.Preset == media.PresetVideo720p {
- res.Source.Width, res.Source.Height, res.Source.VideoCodec, res.Source.AudioCodec = 1920, 1080, "h264", "aac"
+ res.Source.Width, res.Source.Height, res.Source.HDR = pic.Width, pic.Height, pic.HDR
+ res.Source.VideoCodec, res.Source.AudioCodec = "h264", "aac"
} else {
res.Source.AudioCodec = "opus"
}
+ if pad == 0 {
+ w.recordFacts(execution, p.Preset, &pic)
+ } else {
+ w.recordFacts(execution, p.Preset, nil) // refused at ReadResult or ParseResult
+ }
for _, name := range media.OutputNames(p.Preset) {
size := 1 + int64(w.rng.Intn(1<<20))
etag := w.randHex(32)
@@ -453,10 +519,23 @@ func (w *world) codecSucceeds(execution string, durationMS int64, pad int) bool
return true
}
-// codecFails writes a result object naming a handler error.
-func (w *world) codecFails(execution, code string) {
- b, _ := json.Marshal(media.Result{V: media.ResultVersion, Execution: execution, Error: code})
+// codecFails writes a result object naming a handler error, with the
+// probe's facts for a video of pic when pic is not nil (the probe ran).
+func (w *world) codecFails(execution, code string, pic *sourcePicture) {
+ res := media.Result{V: media.ResultVersion, Execution: execution, Error: code}
+ preset := ""
+ if _, p, ok := w.lastRequest(execution); ok {
+ preset = p.Preset
+ }
+ if pic != nil {
+ res.Source = &media.SourceFacts{DurationMS: 60000, Width: pic.Width, Height: pic.Height, HDR: pic.HDR, VideoCodec: "hevc"}
+ if preset != media.PresetVideo720p {
+ res.Source = &media.SourceFacts{DurationMS: 60000, AudioCodec: "opus"}
+ }
+ }
+ b, _ := json.Marshal(res)
w.grants.Results[execution] = b
+ w.recordFacts(execution, preset, pic)
}
// tasksBy sorts the fake's tasks into pending, running and stopped.