Skip to content

feat(artifacts): report declared Ogg Opus, RIFF/XMA2, Bink 2 and Vulkan pipeline-cache headers - #14700

Merged
morluto merged 18 commits into
morluto:mainfrom
BeqaKs:cursor/media-asset-headers-a7dc
Nov 27, 2026
Merged

morluto merged 18 commits into
morluto:mainfrom
BeqaKs:cursor/media-asset-headers-a7dc

Conversation

@BeqaKs

@BeqaKs BeqaKs commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #14155 by completing the remaining formats after merged #14248 (DDS/GLB/KTX/KTX2): Ogg Opus, RIFF WAVE fmt tag 0x166 (XMA2), Bink 2 (KB2 + revision), and Vulkan pipeline cache (VK_PIPELINE_CACHE_HEADER_VERSION_ONE).

inspect-artifact / extract-artifact previously returned file_format_rejected for these files. They are now recognized by header signatures (never by file name) and inventoried as archive containers with declared header facts and extractable byte regions. Payloads stay opaque.

Problem and expected behavior

Issue #14155 asks for header-only inventory of six GPU/media asset formats. #14248 landed DDS/GLB/KTX/KTX2. The four remaining formats were still refused. Success: each fixture reports header facts, region extents, and malformed vs unsupported/truncated when lengths disagree, without decoding audio/video/cache bodies.

Change and scope

Same pattern as src/artifacts/gpuAsset/: a mediaAsset owner parses each header once (MediaAssetLayouts.ts), exposes metadata (mediaAssetMetadata.ts), and lists declared regions as members.

  • Ogg Opus: page sequences/serials; OpusHead channel count, pre-skip, input rate; OpusTags vendor; page/audio regions.
  • RIFF XMA2: chunk list/extents; format tag, channels, rate, block align; declared XMA2 stream/loop fields when the fmt holds them.
  • Bink 2: revision, frame count, width/height, frame rate, frame-offset table extent; frames payload opaque. Other header words stay unnamed.
  • Vulkan pipeline cache: header size/version, vendorID, deviceID, pipelineCacheUUID; opaque remainder.

Intentionally not included: decode/decompress of audio, video, or pipeline-cache bodies; Bink field names beyond the issue's documented leading facts; generic Ogg/WAVE without OpusHead / tag 0x166.

Follow the contribution scope.
Contribution scope fit: ordinary artifact-format inventory within existing archive/evidence boundaries; not applicable for a new provider or execution capability.

Contract and boundary impact

  • Semantic owner and earliest changed stage: MediaAssetLayouts / MediaAssetArtifactReader produce format metadata and regions; inventory, inspect, extract, and target recognition consume them. Recognition is signature-based beside the existing GPU asset recognizers.
  • Contribution scope fit and linked maintainer decision: not applicable (header inventory only; no target execution, injection, mutation, or protection recovery).
  • CLI and MCP/tool-catalog contract: inspect-artifact / extract-artifact and binary open now admit the four formats as archives; no new tool names.
  • Provider, bridge, target-format, or platform compatibility: four new archive target formats (ogg-opus, riff-xma2, bink2, vulkan-pipeline-cache).
  • Evidence, artifact, provenance, or reconstruction contract: new root metadata kinds and media-asset-region members; comparison leaves root facts to content comparison (same as DDS/GLB).
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none authored here; CI regenerates catalogs.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run --maxWorkers=1 --no-file-parallelism src/artifacts/mediaAsset/MediaAssetArtifactReader.test.ts — 14 passed.
  • npx vitest run --maxWorkers=1 --no-file-parallelism src/artifacts/mediaAsset/MediaAssetArtifactReader.test.ts src/application/binary/TargetFormatVocabularies.test.ts src/domain/artifactFormatMetadata.test.ts — 75 passed.
  • npx vitest run --maxWorkers=1 --no-file-parallelism tests/boundary/filesystem/binaryTarget.test.ts -t "Ogg Opus|…|DDS, GLB" — 2 passed (media + existing GPU classification).
  • node scripts/run-typescript.mjs --noEmit --checkers 1 --maxMemory 2G — clean.
  • npx oxlint on new media-asset paths — warnings only (same class as GpuAssetLayouts).
  • npx oxfmt on new paths — clean.
  • node scripts/verify/architecture-guards.mjs — passed (3157 files).

Compatibility, safety, and release

  • Breaking changes or migration steps: none. New formats only; previously rejected files become inventoriable.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: read-only header/chunk inventory; no decode of media or vendor-private cache bodies.

Author readiness

Human owner: @BeqaKs

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP output (if applicable): deferred to CI; unit/boundary coverage only locally.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T11:38:17.801539Z
We couldn’t complete this review. Comment @codex review to try again.
2e1fad1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous packet-boundary issue is fixed and no new blocking issue was found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; the previous packet-boundary issue is fixed and no new blocking issue was found.

Summary

Adds header-only inventory and extraction for Ogg Opus, RIFF/XMA2, Bink 2 and Vulkan pipeline caches. Payloads remain opaque.

  • Four media and cache formats now expose their declared headers and byte regions.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["File bytes"] --> B["Signature recognition"]
  B --> C["MediaAssetArtifactReader"]
  C --> D["MediaAssetLayouts"]
  D --> E["Root header facts"]
  D --> F["Declared byte regions"]
  F --> G["Inventory and extraction"]
Loading

Reviews (13) · Last reviewed commit: "fix(artifacts): keep Ogg header reads in..." · Reviewed by Greptile

Comment thread src/artifacts/artifactFormats.ts Resolved
Comment thread docs/README.md Resolved
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 26, 2026
…an pipeline-cache headers

Recognize the four remaining morluto#14155 media/cache containers by their public
header signatures and inventory them as archives. Root format metadata
carries the declared header facts; each named byte region is a member that
is hashed and extractable. Payloads stay opaque: no audio, video or
pipeline-cache body decode.

Disagreeing extents stay in extent_check with unknown coverage rather than
a refusal. Structural header faults refuse as malformed input with format
and offset.

Completes the remaining formats from morluto#14155 after morluto#14248.
Stop RIFF inventory from buffering opaque chunks, keep chunk walks inside
the declared form, follow spanned OpusTags before audio, preserve first-page
truncation, ground the Bink fixture/table split, and document the formats.
Record incomplete RIFF/XMA2 chunk headers in metadata, treat cut-off fmt as
truncated rather than missing, and add media-asset-headers to the VitePress
sidebar registry.
Short RIFF, Bink 2, and Vulkan pipeline-cache headers that end before the
declared header size are truncated inputs, not malformed structure.
@BeqaKs
BeqaKs force-pushed the cursor/media-asset-headers-a7dc branch from 1ae1e72 to fa86ef2 Compare November 26, 2026 15:33
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Thanks for this. I reviewed the whole PR against reference readers and pushed fixes on top of your branch (no history rewritten): 5c95ce7d8b, a merge of main (51c60394b8), 5ae67d8988 and a3ec5e13b2.

Defects fixed

  • Bink 2 header fields were read 4 bytes off. FFmpeg's demuxer (libavformat/bink.c read_header, also its probe) and vgmstream (src/meta/bik.c) both put the frame count at 0x08, largest frame size at 0x0C, width at 0x14, height at 0x18 and fps at 0x1C/0x20, then video flags at 0x24 and the audio track count at 0x28. The PR read frame count from 0x0C and so on. The fixture wrote the same offsets the parser read, so the tests passed anyway.
  • Bink frame-offset table position ignored the audio tracks. The table follows one extra word for revisions i–k and 12 bytes per audio track (max decoded size, sample rate and flags, track ID). It now reports those track facts and places the table correctly. More than 256 tracks refuses as malformed, as both demuxers do.
  • Ogg OpusTags across multiplexed streams. Pages of another logical stream between OpusHead and OpusTags ended the walk, and the rest was classed as audio. Like opusfile, OpusTags is now read only from the OpusHead stream's serial, and the other pages are listed and named in a limitation.
  • Unbounded concat: all OpusTags pages were concatenated before the vendor was read, so a large picture comment was copied whole. Only the vendor prefix is assembled now.
  • Silent losses that are now limitations:
    • a non-UTF-8 vendor;
    • a vendor not fully examined;
    • a missing beginning-of-stream flag;
    • a second packet that is not OpusTags;
    • a missing continued-packet flag;
    • a 0x166 fmt chunk without the 52-byte XMA2WAVEFORMATEX.
  • fmt_extra_bytes reported 0 when a 16-byte fmt chunk has no cbSize; it is null now.
  • RIFF pad byte: an odd final chunk whose pad byte is omitted at the form end was reported as truncated. FFmpeg's wavdec tolerates this, and so does this PR now, with a limitation.
  • RIFF entry names: they used the raw FourCC, so a crafted ID could put /, dot segments or control characters into the entry path. Non-alphanumeric IDs are now named chunks/<index>.bin, and the exact ID stays in chunks[].id.
  • main added a PE overlay leading-format list that must name every recognized format. The four media formats are added, otherwise the merge did not compile.

Brittleness pass

  • Duplicated decision: recognition requires fmt as the first chunk while the layout searched find(id === "fmt "). The layout now takes the first chunk, which recognition guarantees, and notes any later fmt chunk, as wavdec does.
  • Named constants with their source:
    • BINK2_FIXED_HEADER_BYTES, the known and extra-word revision sets, BINK_MAX_AUDIO_TRACKS;
    • XMA2WAVEFORMATEX_EXTRA_BYTES (34) and WAVEFORMATEX_BYTES (18), from xma2defs.h;
    • the Ogg header_type bits.
  • Unknown, not guessed:
    • The references disagree after video flags 0x4 / 0x10000: vgmstream reads 6 or 12 more 16-bit values, FFmpeg reads none. For those flags, and for revisions FFmpeg does not read, the table offset is reported as null and coverage is unknown.
    • Revisions above k: FFmpeg doesn't read them, and vgmstream adds the extra word for every revision ≥ i. They are treated as unknown.
  • Implementation-mirroring test: a known-answer Bink header written at absolute offsets now checks the field positions independently of the fixture builder.
  • Removed dead code: the safe-integer checks on a u32 frame count.

Left as is, and why

  • Walk ceilings (64 Ogg pages, 256 RIFF chunks, 4096-byte vendor) still have no control. Details are in the review thread: the right control is artifact.member_count, but positional readers don't receive it yet, and the GPU asset reader shares the pattern. That needs one change across those readers.
  • The older XMA2 chunk form (no 0x166 fmt chunk), which FFmpeg also reads, is not recognized. That is out of scope.
  • Vulkan SC's 56-byte VERSION_SAFETY_CRITICAL_ONE header is not claimed.
  • No real encoder output was inspected; all fixtures are synthetic.

Sources

  • RFC 3533 and RFC 7845, plus opusfile through DeepWiki;
  • FFmpeg libavformat/bink.c, wavdec.c and riffdec.c;
  • vgmstream src/meta/bik.c;
  • the Vulkan specification (chapters/pipelines.adoc: VersionOne is 32 bytes, little-endian, headerSize must be 32).

Validation

  • MediaAssetArtifactReader.test.ts: 32 tests, 11 of them new.
  • Format recognition, vocabulary and PE overlay source tests: 180 passed.
  • 6 boundary files, including binaryTarget.test.ts: 143 passed.
  • check:fast, docs:check, oxfmt and the advertised-schema check all pass.

Comment thread src/domain/mediaAssetFormats.ts Resolved
Trailing bytes past the header size field are no longer claimed as
frame payload. Tables that do not fit the declared extent stay unlisted.
BeqaKs and others added 3 commits November 27, 2026 16:59
When header tables end past the declared file size, still measure the
frame-offset table against the file so extent_check reports truncated
instead of consistent while the tables remain unlisted.
Growing the read buffer with Buffer.concat left each saved page's packet
slice pinning the previous copy, so a long OpusTags continuation retained
O(n²) bytes before region_count refused the walk. Page records now store
packet offsets and read from the final buffer.
@morluto
morluto enabled auto-merge (squash) November 27, 2026 18:36
Keep media asset headers from this branch alongside Nintendo 64 ROMs
and YARA rule matches from main.
auto-merge was automatically disabled November 27, 2026 19:09

Head branch was pushed to by a user without write access

Refuse to decode track tables past declaredEnd so appended physical
bytes are not reported as audio_tracks.
Keep media_asset alongside android_dtbo in reader-limit schemas, CLI
descriptions, docs, and regenerated inspect/extract artifact summaries.
@morluto
morluto merged commit d74703f into morluto:main Nov 27, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Inventory declared headers of GPU and media asset files (DDS, GLB, Ogg Opus, RIFF/XMA2, Bink 2, Vulkan pipeline cache)

2 participants