Building a USDZ validator that admits what it cannot check
I built a Swift USDZ validator and had to decide what success means when part of an asset remains uninspected. Five real models helped separate defects, coverage gaps, and CI policy.
I built a USDZ validator that can inspect an asset, find no errors, and still return a nonzero exit code.
This is intentional. Explaining it took rather more work than I expected (a recurring feature of projects I initially describe as “a small command-line tool”).
The project is USDZ Validation Kit, a local Swift library and CLI for checking USDZ packaging, package-local references, and delivery budgets. The interesting part of building it was deciding what a successful check actually means when some of the asset remains beyond the inspector’s reach.
A package can have a sound container, sensible sizes, and readable texture headers while its binary scene layer contains dependencies I have not inspected. Returning an unconditional success would collapse two different observations: I found no blocking defects, and I completed the relevant checks.
I needed the report to preserve both.
Starting with the bytes I could actually inspect
For this first version, I kept native inspection inside a deliberately narrow boundary. It reads one stable regular file. It does not extract the archive, decompress entries, decode image pixels, load a USD stage, resolve references against the host filesystem, or call the network.
USD describes scenes, including their geometry, materials, and references to other assets. A USDZ package collects a scene and its resources into an archive; its layers can be text USDA or binary USDC.
That leaves plenty of useful work at the package level.
USDZ packaging gives the validator concrete things to inspect: ZIP records, stored payloads, entry names, offsets, checksums, and alignment. My supported container layout is classic single-disk ZIP with stored regular files and optional empty directories. Payloads must meet the 64-byte alignment requirement.
I check that the central and local records agree, that ranges and sizes are consistent, and that the stored bytes match their CRC-32 checksums. I also build an in-memory package namespace so duplicate names, unsafe paths, and file/directory conflicts have somewhere to be noticed.
The namespace follows exact, case-sensitive UTF-8 names. It does not helpfully search the disk for a missing texture or decide that two differently normalized names probably mean the same thing. That sort of helpfulness would make the result depend on the machine running the check, which is an impressive way to make CI confusing before breakfast.
These checks establish facts about the package. They do not establish that the scene inside it makes sense.
A correct checksum says the stored bytes match the recorded checksum. It says nothing about whether those bytes describe a valid material, a usable mesh, or even a valid embedded file. Similarly, recognizing a PXR-USDC header identifies a binary layer; it does not mean I have parsed that layer.
Keeping those claims separate became the central design constraint.
Text layers allowed a little more inspection. The validator lexically scans recognized USDA layers for supported asset-reference forms, ignoring apparent references inside comments and ordinary strings. Supported relative references can then be checked against the package namespace.
But this is still lexical inspection, not a USD grammar parser or composition engine. It scans recognized layers even when they might be inactive or unreferenced in a composed scene. When it encounters an expression or resolver form outside its supported model, the result is partial coverage. Inventing a missing-file error would turn “I cannot resolve this” into “this target does not exist.”
I was trying to build a validator, so manufacturing evidence seemed like an unfortunate place to economize.
Three answers instead of one green light
I ended up treating findings, coverage, and the acceptance decision as separate parts of the result.
Findings record what the validator observed: a malformed archive record, an unsafe path, a budget warning, or a limitation. Coverage records which inspection work was complete and where gaps remain. The gate decides whether that result is acceptable under the selected policy.
That distinction matters most for binary USDC layers. Native reference inspection is incomplete for every such layer in this version. A package can pass the native container and budget checks while retaining that gap.
By default, an otherwise acceptable package with incomplete native coverage exits with code 2. That does not mean the model is broken. It means the default gate did not accept the uninspected portion.
There is an explicit --allow-incomplete option for workflows willing to accept native gaps. With it, the same otherwise acceptable asset can exit with code 0, while the report still says inspection is incomplete.
For example, these fields can coexist in the JSON report (this is a shortened projection, not a complete report):
{
"validationStatus": "incomplete",
"gateDecision": "pass",
"acceptedIncomplete": true
}
The option changes the acceptance policy. The missing inspection remains missing, and the report keeps that fact available to the next consumer. An unavailable or unsuccessful requested checker also remains blocking; the flag only accepts native gaps.
I wanted a CI job to be able to accept a known limitation without forcing every downstream reader to rediscover it from a footnote. Someone might accept that gap for a packaging check and require a different inspection step before delivery. The machine-readable result needs enough information for both decisions.
There is a similar distinction in the budget checks. Configurable warnings express delivery preferences, such as encoded texture sizes or dimensions. Fixed safety limits bound what the inspector itself will attempt.
Disabling a warning threshold does not disable those safety limits. And counting encoded texture bytes does not produce an estimate of decoded GPU memory. The dimension checks read supported image headers; they do not decode the pixels.
I kept having to resist the temptation to let a useful measurement acquire a more impressive job title.
The report also carries these distinctions into JSON and SARIF. Optional external findings remain separate from native findings and coverage. Default output omits absolute local paths and raw tool diagnostics, so a report can be shared without automatically including a small guided tour of my filesystem.
Five real assets and one useful disagreement
The documented local verification on October 21 made the coverage model much less abstract.
I tested five files supplied as Apple gallery downloads. Their exact download URLs and redistribution terms were not verified, so the assets and raw local diagnostics stayed out of the repository. The verification record describes the observations and their limits.
All five originals had no detected native errors or budget warnings. Container structure, entry safety, byte budgets, and texture dimensions were complete. Each still carried the binary-reference limitation.
The native default exit was 2 for all five. With --allow-incomplete, all five exited with 0.
That was the expected behavior, but it also exposed an obvious question: what happens if I ask a separate USD checker to examine the asset?
The optional adapter invokes the installed /usr/bin/usdchecker, pinned to the supported Apple USD Tools version, which reported 0.25.11 during those tests. It requires an explicit request. There is no PATH search, automatic download, or caller-selected executable.
This is a different inspection boundary. The external tool is not filesystem- or network-sandboxed by the adapter, so I restrict that path to trusted inputs. The native package-local constraints cannot be silently advertised as constraints on another program.
On four of the five assets, the checker reported no failure. Native coverage still remained incomplete.
On the Fender model, the checker reported a material-subset failure. A follow-up read-only diagnostic found 149,979 mesh faces, with 149,002 uniquely covered by the relevant material subsets. That left 977 uncovered faces in a family authored as a partition, which requires complete, nonoverlapping coverage.
There were no duplicate or out-of-range subset indices in that count. The uncovered faces supported the checker’s complaint.
This established an authored material-subset defect. It did not establish its visual impact, or whether a particular renderer would display the model acceptably. I had evidence for a specific structural problem, and no reason to promote it into a review of the rendered guitar.
The native validator had not detected that composition-level issue. It had reported its own limited inspection correctly. The external checker contributed a separate finding with its own provenance.
For the four assets without a checker-reported failure, requesting the checker still produced exit 2 under the default policy: native coverage remained incomplete. Adding --allow-incomplete permitted exit 0.
For the Fender asset, the checker failure produced exit 1 under both policies.
That last behavior was essential. An option accepting native coverage gaps must not become a general-purpose “please make the pipeline green” switch (I can already achieve that by removing the pipeline, at considerably lower maintenance cost).
The same verification used three deliberately damaged copies of another asset: one with the ZIP end record removed, one with a corrupted texture byte and unchanged checksum, and one with an unsafe entry path. All three remained blocking errors with or without --allow-incomplete. The originals stayed unchanged.
Those tests gave the flag a concrete boundary: accept a known gap, preserve actual failures.
Leaving the unfinished part visible
The optional checker was useful, but its success could not honestly complete my native USDC reference inspection. It ran a different implementation under a different boundary. Even a successful invocation could only contribute its own result.
That is why the reports retain native coverage and external provenance separately. A checker that reports no failure, a native inspector that cannot examine binary dependencies, and a gate that accepts the combination can all describe the same run without contradicting each other.
It also shaped the next work. Binary USDC dependency inspection remains outside this version; investigating it is not the same as having shipped it. I would rather add a real capability later than broaden the current claim because the roadmap looks promising.
The verification claims need the same restraint. The project records passing required checks on the verified current host, while the broader platform matrix remains unverified. Repeated runs and relocation checks establish determinism in that tested environment. They do not establish identical output on every machine I have not used.
For the current CLI, the practical contract is straightforward: exit 0 means the configured gate accepted the result. The report explains the findings, the remaining gaps, and any external contribution behind that decision.
I can put that into CI and choose a policy deliberately. If I accept incomplete native reference inspection today, it will still be written in the report tomorrow, when I have forgotten why I added that flag.