agentleFS
MicrosoftKnown publishermicrosoft/preflate-rs/preflate/CLAUDE.md

preflate-rs / preflate

CLAUDE.md38 starsChanged 9 months agoApache-2.0View on GitHub

Core DEFLATE analysis and reconstruction. Analyzes a DEFLATE bitstream, extracts the uncompressed plaintext plus a compact set of reconstruction parameters, and later recreates the bit-exact original bitstream. PreflateConfig controls max_chain_length, plain_text_limit, and verify_compression. Reconstruction runs the same pipeline in reverse.

The file

Files
CLAUDE.md

preflate (core library)

Core DEFLATE analysis and reconstruction. Analyzes a DEFLATE bitstream, extracts the uncompressed plaintext plus a compact set of reconstruction parameters, and later recreates the bit-exact original bitstream.

Public API (lib.rs)

// Compress: analyze a DEFLATE stream and produce plaintext + correction data
PreflateStreamProcessor::new(config) -> Self
PreflateStreamProcessor::decompress(input: &[u8]) -> Result<PreflateStreamChunkResult>

// Recreate: given plaintext + correction data, reproduce the original DEFLATE stream
RecreateStreamProcessor::new() -> Self
RecreateStreamProcessor::recreate(chunk: PreflateStreamChunkResult) -> Result<Vec<u8>>

// One-shot helpers
preflate_whole_deflate_stream(input, config) -> Result<(Vec<u8>, Vec<u8>)>
recreate_whole_deflate_stream(plaintext, correction_data) -> Result<Vec<u8>>

PreflateConfig controls max_chain_length, plain_text_limit, and verify_compression.

Processing Pipeline

DEFLATE bytes
    └─ deflate/deflate_reader.rs  → tokens (literals + back-refs)
    └─ estimator/                 → TokenPredictorParameters (hash algo, nice_len, max_chain…)
    └─ token_predictor.rs         → predicted tokens (replaying the original compressor)
    └─ tree_predictor.rs          → predicted Huffman trees
    └─ cabac_codec.rs             → encode *differences* from prediction → correction bytes

Reconstruction runs the same pipeline in reverse.

Key Types

TypeWherePurpose
PlainTextpreflate_input.rsWraps uncompressed data
TokenPredictorParameterstoken_predictor.rsCompressor fingerprint
HashAlgorithmhash_algorithm.rsZlib / Miniz / Libdeflate / zlib-ng / …
PreflateError / ExitCodepreflate_error.rs29 error variants with context
DeflateTokendeflate/deflate_token.rsLiteral or length/distance match

Module Layout

src/
  lib.rs                      ← public API, PreflateConfig
  stream_processor.rs         ← PreflateStreamProcessor, RecreateStreamProcessor
  deflate/
    deflate_reader.rs         ← DEFLATE bitstream → tokens
    deflate_writer.rs         ← tokens → DEFLATE bitstream
    bit_reader.rs / bit_writer.rs
    huffman_calc.rs / huffman_encoding.rs
    deflate_token.rs / deflate_constants.rs
  estimator/
    preflate_parameter_estimator.rs  ← main estimator entry point
    complevel_estimator.rs
    depth_estimator.rs
    add_policy_estimator.rs
    preflate_parse_config.rs
    preflate_stream_info.rs
  token_predictor.rs
  tree_predictor.rs
  statistical_codec.rs
  cabac_codec.rs
  hash_algorithm.rs
  hash_chain.rs / hash_chain_holder.rs
  preflate_input.rs
  preflate_error.rs
  bit_helper.rs / utils.rs

Constraints

  • #![forbid(unsafe_code)] — strictly enforced.
  • Serialization: parameters via bitcode; correction data via CABAC (cabac crate).
  • The format is chunked to bound peak memory use.
  • #![deny(trivial_casts, non_ascii_idents)] also set.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.