Fix pcf-compact corrupting PFS-MS files; add PFS-aware compaction#23
Merged
Conversation
Generic PCF compaction (Container::compacted_image) repacks entries into
shared table blocks and rewrites every table_hash. On a PFS-MS file this
destroys the one-PFS_SESSION-per-HEAD invariant and the inter-session
commitments (member_blocks_digest, prev_session_hash), so the result no
longer scans or verifies as PFS-MS:
pfs: broken session chain: HEAD block must hold exactly one PFS_SESSION
Generic content-preserving compaction therefore cannot keep a multi-session
PFS-MS file valid. Two changes address this:
1. PFS-aware compaction (pfs-ms crate): new `compact` / `compact_archive`
resolve the live tree at the head and re-emit it as a single fresh
session (seq=1, prev_session_hash=0), discarding history per spec
Section 15 -- deleted nodes are dropped and delta chains collapse to the
newest full DIRECT content. Exposed as `pfs compact <file> [<out>]`.
Reuses FsReader/FsWriter/commit_changes; the synthesized root means a
single commit_changes on a fresh create() yields one valid session.
2. Guard in pcf-compact: refuses an input carrying a PFS_SESSION partition
(type 0xAAAA0002) and points the user to `pfs compact`. `--allow-pfs`
forces a plain-PCF compaction that intentionally discards PFS structure.
Specs (PFS-MS Section 15, PCF Section 11.5) and READMEs updated to document
that generic PCF compaction MUST NOT be applied to profile-structured files.
Adds tests: single-session round-trip, deleted/delta flattening, metadata
and hash-algo preservation, empty tree, idempotence, corrupt-source
rejection, in-place/separate-output archives, and the pcf-compact guard.
https://claude.ai/code/session_016Xc2k2U7vWCQQUjTPNSRjK
…pfs-session-chain-gM5hG # Conflicts: # reference/PFS-MS-v1.0/src/bin/pfs.rs
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.
Generic PCF compaction (Container::compacted_image) repacks entries into
shared table blocks and rewrites every table_hash. On a PFS-MS file this
destroys the one-PFS_SESSION-per-HEAD invariant and the inter-session
commitments (member_blocks_digest, prev_session_hash), so the result no
longer scans or verifies as PFS-MS:
Generic content-preserving compaction therefore cannot keep a multi-session
PFS-MS file valid. Two changes address this:
PFS-aware compaction (pfs-ms crate): new
compact/compact_archiveresolve the live tree at the head and re-emit it as a single fresh
session (seq=1, prev_session_hash=0), discarding history per spec
Section 15 -- deleted nodes are dropped and delta chains collapse to the
newest full DIRECT content. Exposed as
pfs compact <file> [<out>].Reuses FsReader/FsWriter/commit_changes; the synthesized root means a
single commit_changes on a fresh create() yields one valid session.
Guard in pcf-compact: refuses an input carrying a PFS_SESSION partition
(type 0xAAAA0002) and points the user to
pfs compact.--allow-pfsforces a plain-PCF compaction that intentionally discards PFS structure.
Specs (PFS-MS Section 15, PCF Section 11.5) and READMEs updated to document
that generic PCF compaction MUST NOT be applied to profile-structured files.
Adds tests: single-session round-trip, deleted/delta flattening, metadata
and hash-algo preservation, empty tree, idempotence, corrupt-source
rejection, in-place/separate-output archives, and the pcf-compact guard.
https://claude.ai/code/session_016Xc2k2U7vWCQQUjTPNSRjK