edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB4c07cbcTahinli2 months ago3583 commits
| 1 | #!/usr/bin/env bash |
| 2 | # gen-fixture-library.sh — GENERATE scripts/fixture-library.tsv from source. |
| 3 | # |
| 4 | # The tsv is committed output, never hand-typed. Regenerate with: |
| 5 | # scripts/gen-fixture-library.sh && git diff --exit-code scripts/fixture-library.tsv |
| 6 | # so drift between "what the tests reach for" and "the manifest" is a |
| 7 | # one-command diff. `scripts/verify-fixture-library.sh` runs that same diff as |
| 8 | # part of its exit status. |
| 9 | # |
| 10 | # COLUMNS (tab separated) |
| 11 | # 1 path repo-relative; `fixtures/...` is relative to $EC_FIXTURES |
| 12 | # 2 required-by file:line of every reference (one row per reference) |
| 13 | # 3 provenance the script/recipe that reproduces the bytes, or |
| 14 | # `none (prose provenance only)` — a FINDING, not a |
| 15 | # placeholder: a pinned fixture claim must cite the |
| 16 | # originating encoder program and the artifact sha256, or the |
| 17 | # pin is unreproducible (the IVF-container drift incident is |
| 18 | # why that rule exists) |
| 19 | # 4 status ok | missing | empty-dir | absent-pin |
| 20 | # 5 sha256 of the artefact, when it is a regular file under 4 MiB |
| 21 | # |
| 22 | # ENUMERATION SHAPES the scan is derived from: |
| 23 | # CARGO_MANIFEST_DIR env!("CARGO_MANIFEST_DIR") / concat!(env!(...)) |
| 24 | # concat!(env!( a fixture root assembled from the manifest dir |
| 25 | # include_bytes! include_bytes!/include_str! argument literals |
| 26 | # "fixtures/ any string literal naming the fixture tree |
| 27 | # ../../fixtures crate-relative literals (CWD is the crate dir) |
| 28 | # Path::new( Path::new("...") argument literals |
| 29 | # fs::read fs::read / read_dir / File::open argument literals |
| 30 | # |
| 31 | # library_fixture:: a path passed to the ec-av1 library-fixture resolver |
| 32 | # (`library_fixture::require("video/…", …)`) is |
| 33 | # LIBRARY-RELATIVE, so it anchors at the fixture root |
| 34 | # the preflight validates (EC_FIXTURES first) rather |
| 35 | # than at any crate directory. Without this row shape |
| 36 | # the RESOLVE pass silently lost every clip row the |
| 37 | # moment a gate stopped naming `../../fixtures` |
| 38 | # literally -- the preflight would stop checking the |
| 39 | # exact paths whose absence this lane is about. |
| 40 | # TWO PASSES: |
| 41 | # 1. fixture-root / fixture-path literals -> the row is the literal itself. |
| 42 | # 2. bare media-file literals ("aac-adts-5.1-44100.aac", "entry-tx3g.mp4") |
| 43 | # joined onto each fixture directory literal seen in the SAME file, then |
| 44 | # onto the standard top-level library directories. Only joins that |
| 45 | # resolve are emitted; unresolved names are counted in the header as the |
| 46 | # declared blind spot. |
| 47 | # |
| 48 | # BLIND SPOT (honest: this is a preflight, not a proof). The scan is literal- |
| 49 | # and grep-derived, so it cannot see a path assembled at runtime from a value |
| 50 | # that is not a literal in the same file -- a vector name read from |
| 51 | # scripts/vectors.sha256, a row from fixtures/real-library-manifest.tsv, a |
| 52 | # format! interpolation, a name in a table. For those, the parent DIRECTORY is |
| 53 | # still enumerated, and the verifier requires every listed directory to exist |
| 54 | # AND be non-empty -- that is what catches the "three hosts whose fixture |
| 55 | # libraries differed" class. A single missing member of a runtime-named corpus |
| 56 | # shows up as a regeneration diff, not as a resolve failure. |
| 57 | |
| 58 | |
| 59 | |
| 60 | ROOT= |
| 61 | OUT= |
| 62 | FIXTURES= |
| 63 | |
| 64 | MEDIA_RE='\.(mp4|m4a|m4s|m4v|mkv|ivf|obu|flac|opus|ogg|oga|webm|265|264|h264|h265|hevc|y4m|yuv|wav|aac|ts|bin|ttml|srt|vtt|ass|json)' |
| 65 | |
| 66 | # Pins that are KNOWN ABSENT and must not vanish from the manifest. Each is |
| 67 | # recorded as an `absent-pin` row naming the gate that wants it, so the gap is |
| 68 | # visible instead of silently skipped. |
| 69 | # Provenance CLASS per row, kept separate from the GENERATOR script so a |
| 70 | # recovered witness is never confused with a re-encode: |
| 71 | # recovered-original the historical bytes, copied from a runner library; a |
| 72 | # re-encode is a DIFFERENT stream and would not hash the |
| 73 | # same, so column 7 is the self-validation |
| 74 | # captured committed bytes whose only provenance is a gate comment |
| 75 | # (a FINDING: no encoder recipe is recorded) |
| 76 | # regenerated a script in column 4 reproduces the bytes |
| 77 | # absent-pin referenced by code, not present; named so the gap is a row |
| 78 | # host-corpus a developer media file, not part of the library |
| 79 | RECOVERED_PINS="golden4-pin.obu golden6-mismatch.obu golden7-forwarding-mismatch.obu lr-sgr-r7.obu" |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | # --- 1. collect the source files that can name a fixture ----------------- |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | # lane-av1clipprobe: a literal that starts with one of the fixture library's |
| 121 | # own top-level directories is LIBRARY-RELATIVE, not crate-relative: it is what |
| 122 | # the ec-av1 library-fixture resolver takes (`require("video/…")`), and the |
| 123 | # other crates' `../../fixtures/<dir>` + `.join("video/…")` pairs resolve to the |
| 124 | # same manifest path. So it maps to `fixtures/<lit>` -- the same row, whether |
| 125 | # the consumer spells the root out or hands the relative part to the resolver. |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | # Provenance: which script reproduces these bytes. An empty answer is a |
| 135 | # finding -- committed pins whose only provenance is prose in a gate comment. |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | # Resolve a source literal to a manifest path. Cargo runs tests with the crate |
| 160 | # directory as CWD, so `../../fixtures` and `CARGO_MANIFEST_DIR` both anchor at |
| 161 | # the crate; a bare `fixtures/...` is accepted from either anchor. |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | tmp= |
| 237 | |
| 238 | unnamed=0 |
| 239 | seen_absent=() |
| 240 | |
| 241 | for; do |
| 242 | crate= |
| 243 | rel= |
| 244 | file_dirs=() |
| 245 | |
| 246 | # Pass 1 -- fixture-root / fixture-path literals. |
| 247 | while ; do |
| 248 | lineno= |
| 249 | lit= |
| 250 | lit= |
| 251 | lit= |
| 252 | || continue |
| 253 | path= |
| 254 | case in |
| 255 | absent-pin) |
| 256 | |
| 257 | continue ;; |
| 258 | esac |
| 259 | |
| 260 | [ && file_dirs+=("") |
| 261 | done |
| 262 | |
| 263 | # Pass 1b -- the ec-av1 library-fixture RESOLVER's literals (lane- |
| 264 | # av1clipprobe). `library_fixture::require("video/…", …)` takes a path |
| 265 | # RELATIVE TO THE FIXTURE ROOT, so it is not a crate-relative literal and |
| 266 | # Pass 1 cannot classify it -- and a clip gate that had stopped naming |
| 267 | # `../../fixtures` literally would have dropped its row from this manifest |
| 268 | # entirely, i.e. the preflight would have stopped RESOLVING the very paths |
| 269 | # whose silent absence this lane is about. Scoped to lines that actually |
| 270 | # call the resolver: a bare `audio/…` literal in another crate keeps |
| 271 | # whatever classification it had, so this adds no rows outside ec-av1. |
| 272 | while ; do |
| 273 | lineno= |
| 274 | while ; do |
| 275 | lit= |
| 276 | lit= |
| 277 | || continue |
| 278 | path="fixtures/" |
| 279 | case in |
| 280 | absent-pin) |
| 281 | |
| 282 | continue ;; |
| 283 | esac |
| 284 | |
| 285 | [ && file_dirs+=("") |
| 286 | done |
| 287 | done |
| 288 | # A resolver call names a FILE inside a library directory; the DIRECTORY row |
| 289 | # is what makes RESOLVE check the corpus is present AND non-empty, and it |
| 290 | # used to come from the `../../fixtures/video` literal this lane removed. |
| 291 | # One row per directory per file, so the manifest does not grow a |
| 292 | # duplicate per call site. |
| 293 | while ; do |
| 294 | d="" |
| 295 | while ; do |
| 296 | lit= |
| 297 | lit= |
| 298 | || continue |
| 299 | d="fixtures/" |
| 300 | done |
| 301 | [ || continue |
| 302 | case " " in *" "*) continue ;; esac |
| 303 | resolver_dirs=" " |
| 304 | case in |
| 305 | absent-pin) continue ;; |
| 306 | esac |
| 307 | |
| 308 | done |
| 309 | |
| 310 | # Pass 2 -- bare media names joined onto this file's fixture directories, |
| 311 | # then onto the standard top-level library directories (a file may name |
| 312 | # its corpus directory in a helper module rather than in this file). |
| 313 | for; do |
| 314 | [ && file_dirs+=("fixtures/") |
| 315 | done |
| 316 | || continue |
| 317 | while ; do |
| 318 | lineno= |
| 319 | name= |
| 320 | name= |
| 321 | name= |
| 322 | for; do |
| 323 | if [; then |
| 324 | |
| 325 | continue |
| 326 | fi |
| 327 | done |
| 328 | unnamed= |
| 329 | done |
| 330 | done |
| 331 | |
| 332 | # Pass 3 -- committed pins that NO source literal reaches. A committed |
| 333 | # fixture nothing references is either dead weight or a reference built at |
| 334 | # runtime from a name the grep cannot see; either way it must be a row, not a |
| 335 | # gap. Scanned over the crate-local committed pin directories. |
| 336 | orphans=0 |
| 337 | while ; do |
| 338 | [ || continue |
| 339 | if ! ; then |
| 340 | |
| 341 | orphans= |
| 342 | fi |
| 343 | done |
| 344 | |
| 345 | |
| 346 | # A known-absent pin is annotated where a source literal actually REACHES for |
| 347 | # it (pass 1, above: `absent_pin` supplies the provenance and the `absent-pin` |
| 348 | # status). Nothing is injected here: a pin no code references any more is not |
| 349 | # a gap in the library, it is a deleted reference, and inventing a row for it |
| 350 | # would keep a stale claim alive. A pin that IS referenced and IS absent still |
| 351 | # gets a row, because pass 1 emits one for every literal. |
| 352 | |
| 353 | # Which tests consume the fetched vector sets, and does anything need the |
| 354 | # .tar.gz blobs? The fleet sync excluded them deliberately, so a test that |
| 355 | # wanted a blob would be red on three hosts for a reason nobody wrote down. |
| 356 | vector_consumers= |
| 357 | blob_users= |
| 358 | |
| 359 | { |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | } |
| 392 | |
| 393 | rows= |
| 394 |