Add pcf-debug: inspection and visualization tool for PCF files#7
Merged
Conversation
…gins Introduce a read-only debugging tool for PCF files that visualises the physical layout (header, table-block chain, entries, data regions, slack, gaps) and decodes partition contents into field trees via a static plugin registry. Ships built-in PFS-MS decoders (PFS_NODE, PFS_SESSION) and a raw fallback. - Add a root Cargo workspace tying the reference crate and the new tool. - tools/pcf-debug: defensive chain walk, layout model with gap/overlap diagnostics, text and self-contained HTML renderers, hexdump, and a PartitionDecoder plugin trait. - Tests: canonical 395-byte vector snapshot, HTML smoke, PFS decoder field trees, and diagnostics for corrupted files. - CI: scope reference coverage to the pcf package and add a pcf-debug build/clippy/test/fmt job. https://claude.ai/code/session_012g2y2iK7i18XEMYEdQugLK
kduma
pushed a commit
that referenced
this pull request
Jun 2, 2026
PR #7 added pcf-debug with a PFS-MS decoder plugin, but its DIRECT/DELTA content-section parsing predates the compression extension. Bring it in sync with the revised spec (Section 7.3 / 9.5): - Decode the new compression_algo_id byte (0=none, 1=DEFLATE, 2=zstd, 3=brotli) in both DIRECT (now 91 bytes) and DELTA (now 165 bytes) content sections, and shift all subsequent field offsets accordingly. - Update the test fixture (pfs_node_direct) to the new 91-byte DIRECT layout and assert the decoded compression_algo_id field and its byte range. Also add reference/PFS-MS-v1.0 to the workspace members introduced by PR #7, so the crate builds within the workspace (it otherwise errors as a non-member). Verified end to end: a real DEFLATE-compressed archive built with `pfs put` now shows `compression_algo_id = 1 (DEFLATE)` under `pcf-debug decode`. Whole workspace passes fmt, clippy -D warnings, and all tests (pcf, pfs-ms, pcf-debug).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces
pcf-debug, a comprehensive read-only inspection and visualization tool for Partitioned Container Format (PCF) files. The tool walks a file's physical structure defensively, renders layouts and partition tables as text or self-contained HTML, and decodes partition contents through a plugin system.Key Changes
New
pcf-debugbinary crate with minimal dependencies (no external argument parsing or rendering libraries)Core modules:
model/walk.rs: Defensive, read-only traversal of the table-block chain with per-block validationmodel/layout.rs: Physical region mapping (header, table blocks, entries, data, slack, gaps)model/diag.rs: Diagnostic types for structural anomalies (overlaps, truncation, hash mismatches, cycles)plugin/mod.rs: Object-safe decoder trait and registry systemplugin/pfs.rs: Decoders for PFS-MS records (PFS_NODE and PFS_SESSION partitions per spec v1.0)plugin/raw.rs: Fallback decoder for any partition typeRendering backends:
render/text.rs: CLI/ASCII output with byte-map strip, layout, partition table, block chain treerender/html.rs: Self-contained HTML report with inline CSS, collapsible sections, no JavaScriptrender/hexdump.rs: Classic 16-column hexdump with file offsetsrender/color.rs: Minimal ANSI coloring withNO_COLORand TTY detection supportCLI interface (
cli/mod.rs):inspect(default),layout,table,chain,hexdump,decode--html,--no-color,--verify/--no-verifyComprehensive test suite:
tests/decode_pfs.rs: PFS-MS decoder validation (fields, ranges, warnings)tests/diagnostics.rs: Structural anomaly detection (overlaps, truncation, cycles)tests/cli_snapshot.rs: Text renderer output validationtests/html_smoke.rs: HTML report structural integritytests/common/mod.rs: Shared test fixtures (canonical PCF, PFS records)Notable Implementation Details
pcf::Containerwould reject, capturing anomalies as diagnostics for debugging broken filesFileHeader::from_bytes, etc.) to stay in sync with the specFieldNode) consumed by both text and HTML renderers, ensuring consistencyCargo.tomlworkspace configuration linking the reference crate and new toolFiles Modified
.gitignore: Expanded with Rust/Cargo, editor, and OS-specific patterns.github/workflows/ci.yml: Updated coverage command formattingCargo.toml(new): Workspace root configurationtools/pcf-debug/Cargo.toml(new): Binary crate manifesthttps://claude.ai/code/session_012g2y2iK7i18XEMYEdQugLK