Commit Graph

3 Commits

Author SHA1 Message Date
cb395b7aa2 psocache_extract: stop at --max-streams, guard output path/overwrites, fix MAX_GAP & inside_tempdir, and write atomically 2026-11-25 05:51:58 +01:00
02b682db9c tests: psocache_extract pins the temporary directory it checks against
test_output_outside_the_temp_directory_is_refused expects the tool to
refuse an output path in the repository root, but the tool compares it
with the system temporary directory: a checkout under /tmp or %TEMP%
(the usual sandbox worktree) makes the repository itself 'inside', the
tool writes the cache there and the test fails with 0 != 2. Run the
tool with TMPDIR set to a fresh directory so the check holds wherever
the tree lives, and clean up the output path either way.

(cherry picked from commit 4c23e4f94d931725d26ab2381d0dbe8326e77a75)
2026-11-24 03:31:07 +02: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