Commit Graph

3 Commits

Author SHA1 Message Date
4f56b089d9 psocache_inspect: guard --entry bounds, zero-meta references, and header string slots 2026-11-25 01:31:22 +01:00
bb360f84d9 Add a reproducible cache extractor and decode the meta chunks
tools/psocache_extract.py walks an RPF9 archive's stream table in order,
inflates each stream to learn its extent and stops at the first stream whose
output starts with the cache magic. It joins the following contiguous streams
until the header's declared total is reached, writes the file inside the
temporary directory and validates it with psocache_inspect. A --budget and
--max-streams bound the search; a folder is scanned in sorted order and the
report carries the archive index and the archive-internal stream offset only.

psocache_inspect.py gains --meta (with --entry N and --limit N): it reports
the chunk-record order, the per-kind 0x41 fields, the 0x42 slot bytes and the
0x41-kind to 0x42-middle-byte correlation over the records whose counts match.
The 0x43 value is never printed.

docs/pso_cache.md records the decoded shape with a confidence per claim and
the remaining unknowns; docs/README.md names the new tool.

tests/test_psocache_extract.py builds synthetic RPF9 archives and covers the
contiguous split, folder scan, budget, stream limit, truncated chain and an
output path outside the temporary directory. The inspect test now covers the
meta decode, an entry listing and the CLI flags.
2026-11-23 04:26:54 +03:00
67a08540fe Add a PSO/shader cache inspector
tools/psocache_inspect.py reads a cache that starts with the PS\0\x09 magic and
checks it against the 0x80 header, 0x70 graphics record, 0x18 compute record and
8-byte index layout: it bounds every region, checks that the meta index covers
the meta blob and the shader index stays inside the code blob, parses the meta
chunk lists (0x41/0x42/0x43) and counts s_endpgm and s_code_end in the code
blob. A file that disagrees is printed region by region and the in-bounds checks
still run; the exit code is 0 for the model, 1 for a disagreement, 2 for input
that is not a cache.

tests/test_psocache_inspect.py builds a synthetic cache (a 0x80 header, two
graphics records, one compute record, two index entries, chunk records and two
programs) and covers the model, an out-of-range record reference, a truncated
file, a bad magic and a short file.
2026-11-23 03:56:55 +03:00