Skip to content

feat(artifacts): report declared DDS, GLB, KTX and KTX2 headers and regions - #14248

Merged
morluto merged 6 commits into
mainfrom
feat/gpu-asset-headers
Nov 24, 2026
Merged

morluto merged 6 commits into
mainfrom
feat/gpu-asset-headers

Conversation

@morluto

@morluto morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Part of #14155: DDS (including DX10), GLB, KTX and KTX2. Ogg Opus, RIFF/XMA2, Bink 2 and the Vulkan pipeline cache are not covered and remain open.

What changes

These four GPU asset containers were refused as file_format_rejected. They are now recognized by their header signatures, never by file name, and inventoried as containers (archive target kind, new format IDs dds, glb, ktx, ktx2).

  • One owner per format. src/artifacts/gpuAsset/GpuAssetLayouts.ts parses each header once with BinaryReader. It returns the declared metadata (src/domain/formatMetadata/gpuAssetMetadata.ts) and the byte regions the header names.
  • Regions are members. Each region is hashed, classified and extractable. Its format_metadata is kind: "gpu-asset-region" with a role and an index. The regions are:
    • DDS: payload.bin.
    • GLB: chunks/<n>.json|bin, plus images/<n>.<ext> for images stored in the BIN chunk through a bufferView.
    • KTX: key/value data and levels/<n>.bin.
    • KTX2: DFD, KVD and SGD extents, and levels/<n>.bin.
  • Header facts.
    • DDS: dimensions, mip count, FourCC, caps, and DX10 dxgi_format (with a name for common values), dimension, array size and misc flags. expected_payload_bytes is derived for BC1–BC7, DXT1–DXT5, ATI1/ATI2 and common uncompressed formats.
    • GLB: version, length, chunk table, asset.version/generator, top-level collection counts and extensionsUsed. The JSON is strict UTF-8, duplicate members are last-wins, and only up to 16 MiB is parsed for counts.
    • KTX: endianness, the GL fields, dimensions, faces, levels and key/value bytes.
    • KTX2: vkFormat, counts, the supercompression scheme and name, the DFD/KVD/SGD extents and the level index.
  • Nothing is decoded. No texture, mesh or image payload is decoded, decompressed or transcoded.

Malformed and truncated stay distinct

  • extent_check is consistent, truncated or trailing-bytes. A disagreement is a fact with unknown coverage, not a refusal:
    • A truncated DDS reports payload_bytes next to expected_payload_bytes, which is the issue's success criterion.
    • A region past the end of the file is dropped, never clipped, and a limitation names it.
  • Structural header faults refuse as malformed input (ParseFailure with format and offset). Examples:
    • DDS_PIXELFORMAT size is not 32;
    • the first GLB chunk is not JSON, or a chunk length is unaligned;
    • the KTX endianness marker is unknown;
    • more than 32 levels.
  • A DDS magic without a 124-byte header is not claimed.

#14239 note: TargetFailure has not landed, so the failures stay on the existing ParseFailure/artifactParseFailure path. #14239 migrates them.

Tests

  • src/artifacts/gpuAsset/GpuAssetArtifactReader.test.ts (17 tests):
    • recognition per format;
    • DDS header without a 124-byte size;
    • per-format facts and regions;
    • truncated DDS, GLB, KTX and KTX2;
    • malformed DDS, GLB and KTX;
    • GLB root inventory with the embedded image hashed.
  • tests/boundary/filesystem/binaryTarget.test.ts: all four resolve to archive targets under a .bin name.
  • tests/acceptance/gpuAssetHeadersCli.test.ts: compiled CLI inspect-artifact and extract-artifact for each format, comparing extracted bytes with source_location; a truncated DDS; a malformed GLB.
  • tests/boundary/mcp/gpuAssetHeadersMcp.test.ts: for each format, an MCP summary and an inspect_analysis_view page of one region.
  • Mutation checks:
    • dropping BC7 (98) from the block table fails the DDS size cases;
    • keeping regions past the end of the file fails three truncation cases.

Validation

  • npx vitest run over the gpu-asset, target, vocabulary, format-recognition, inventory and analysis-view tests: 119 files, 2427 passed.
  • Scoped tsc: clean. oxfmt, oxlint (no errors) and architecture-guards.mjs: pass.
  • The compiled CLI and MCP tests were not run locally (no build). CI covers them.

Real public files (scratch directory, never executed)

All four report extent_check: consistent and complete coverage through the source inventory:

Source File SHA-256 Facts
KhronosGroup/glTF-Sample-Assets e124e8d8 Models/Duck/glTF-Binary/Duck.glb 65bf938f…4ae54ab5 COLLADA2GLTF, 2 chunks, 1 mesh, 4 accessors, PNG image of 16,302 bytes
KhronosGroup/KTX-Software 983695c1 tests/resources/ktx/bc3_unorm_array_7.ktx 94c364ad…b6cc57 256x256, 7 array elements, one 458,752-byte level (7 × 65,536)
same external/basis_universal/test_files/kodim23.ktx2 0eb567d4…8390a8 768x512, BasisLZ, DFD/KVD/SGD and one level
WerWolv/ImHex-Patterns d2d3e7cc tests/patterns/test_data/dds.hexpat.dds eed49527…200968 DXT1 64x64; the expected 2,048 bytes equal the payload

Remaining

  • Ogg Opus, RIFF WAVE/XMA2, Bink 2 and the Vulkan pipeline cache.
  • DDS formats without a derived size report expected_payload_bytes: null, with a limitation.
  • compare-artifacts does not compare the root header facts yet. Like the other single-file formats, they are marked as covered by content comparison.

…egions

Recognize DDS (including the DX10 extension), GLB, KTX 1.1 and KTX 2.0
by their header signatures and inventory them as containers. The root
format metadata carries the declared header facts. Each declared byte
region is a member that is hashed, classified and extractable: the DDS
payload; GLB JSON and BIN chunks and BIN-stored images; KTX key/value
data and mip levels; and KTX2 DFD, KVD, SGD and levels.

Nothing is decoded. A DDS payload is checked against the size derived
from its dimensions, mips, faces, layers and block size. Disagreeing
extents are reported in extent_check with unknown coverage rather than
refused, and regions past the end of the file are dropped, not clipped.
Structural header faults refuse as malformed input with the format and
offset.

Part of #14155
@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-24T02:04:59.850574Z
We couldn’t complete this review. Comment @codex review to try again.
d7ad444 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

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] The change adds four file formats to artifact inspection and extraction workflows.

The uncertainty requirement must be satisfied before merging: an invalid GLB buffer URI can still produce complete coverage.

Summary

Adds signature-based recognition, header facts, and extractable byte regions for DDS, GLB, KTX, and KTX2 without decoding payloads.

  • DDS, GLB, KTX and KTX2 files are recognized as archive targets.
  • GPU asset inventory reports declared headers and exposes stored regions.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[File signature] --> B[GPU asset reader]
  B --> C[Header layout]
  C --> D[Root header facts]
  C --> E[Stored byte regions]
  E --> F[Hashes and extraction]
  C --> G[Extent and examined coverage]
  G --> H[Complete or unknown inventory]
Loading

Reviews (5) · Last reviewed commit: "fix(gpu-assets): count a GLB image as ex..." · Reviewed by Greptile

- Stop the GLB chunk walk at 1,024 chunks with unknown coverage.
- Refuse a GLB chunk that crosses the declared length, or a chunk table
  that stops short of a physically present declared end, as malformed.
- Report coverage unknown when GLB images were not all listed: past the
  image allowance, an unparsed JSON chunk, or an unresolved bufferView.
- Leave the DDS payload size unknown when rows are padded to a declared
  pitch or more than 32 mip levels are declared, instead of deriving it
  from different dimensions.
Only buffers[0] without a uri is the GLB BIN chunk. An image whose
bufferView sits in a buffer with a uri, or an image named by uri, is
stored outside the file; it was counted as an unresolved image and made
coverage unknown. Such images are now counted in external_images and
leave coverage complete; only views that resolve to no buffer stay
unknown.
The 64-bit level-index fields were read from a buffer that starts at file
offset 80, but an unsafe value reported its index-relative position.
The reader now takes the buffer's file base and reports base plus
position, so every failure offset is a file offset.
An image or buffer whose uri is present but not a string, and an image
with neither a uri nor a bufferView, were counted in external_images and
left coverage complete without an established source. Only a URI string
now marks a source external; other sources stay unresolved and keep
coverage unknown.
@morluto
morluto enabled auto-merge (squash) November 24, 2026 04:21
@morluto
morluto merged commit 78d2593 into main Nov 24, 2026
57 checks passed
@morluto
morluto deleted the feat/gpu-asset-headers branch November 24, 2026 04:28
vincentkoc added a commit that referenced this pull request Nov 24, 2026
…-20261124

* origin/main: (3854 commits)
  fix(ci): retry recorded crash dependency acquisition without stale index cache (#14076)
  chore(deps): bump rcssmin from 1.2.2 to 1.3.0 in /website (#14229)
  chore(deps): bump markdownify from 1.2.3 to 1.2.4 in /website (#14227)
  ci: compare frozen selections with observed test failures (#14301)
  ci: record affected-test predictions above the live cutoff (#14300)
  ci: wait for static checks before broad PR test shards (#14299)
  ci: validate workflow anchors with actionlint 1.7.12 (#14298)
  ci: measure portable runner time for recorded selection predictions (#14304)
  test(pe): distinguish unsupported DOS input from truncated input (#14302)
  test(go): check build information in a one-directory PE32 fixture (#14303)
  fix(tests): damage Deno PE resource framing the loader-equivalent reader reads
  test(go): expect loader-equivalent PE header facts in the MZ diagnostics (#14293)
  perf(resources): refuse non-ASAR Pickle prefixes without building errors
  perf(artifacts): reuse the streamed XML plist verdict when classifying
  perf(artifacts): decide the FAT header once per classified stream
  test: run repeated CLI formatting capacity pairings in process (#14279)
  fix(limits)!: make the IL2CPP pointer index adjustable and require owned refusal limits (#14243)
  fix(artifacts): report S-record data after the final count (#14260)
  feat(artifacts): report declared DDS, GLB, KTX and KTX2 headers and regions (#14248)
  fix(pe)!: share one loader-equivalent PE header owner across static readers (#14253)
  ...
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 26, 2026
BeqaKs added a commit to BeqaKs/rea that referenced this pull request 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.
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.

1 participant