Skip to main content

zeropx-corpus-scan

Byte-honest inventory of a document corpus.

Zero dependencies. Python 3.10+, standard library only. Read-only. Nothing is imported, executed, decoded past what the format demands, or sent anywhere.

Why

You've been handed a directory of documents — an M&A data room, a research participant's file dump, a legal discovery batch, a client's compliance archive — and before anyone opens anything you need a defensible inventory: what's in there, what's the same, what's malformed, what's the byte-level footprint of each file.

corpus-scan walks the directory, hashes every file, structurally parses the text formats (Markdown / JSON / JSONL / CSV), detects exact duplicates and multi-format representation groups (report.md, report.jsonl, report.json → one family), and writes a single JSON inventory suitable for downstream review or audit-trail storage.

Install

pip install zeropx-corpus-scan

(Python import module: corpus_scan | CLI command: corpus-scan)

Use

corpus-scan --root /path/to/corpus --out ./reports

By default only these extensions are scanned: .md .json .jsonl .csv .txt. Override with --extensions .md,.pdf,.docx — files with other extensions are counted in the directory but only get a byte-scan, no structural parse.

To descend into subdirectories, add --recursive (or -r):

corpus-scan --root /path/to/corpus --out ./reports --recursive

File symlinks whose resolved target lands outside --root are silently skipped — a symlink pointing to ~/, /, or a sibling mount is never followed into the inventory, so accidental corpus escape can't happen.

Detect format from magic bytes (v0.3+)

Add --detect-format to read each file's first bytes and record its actual format alongside the extension. Files whose extension implies one format but whose header shows a different one are flagged:

corpus-scan --root /path/to/corpus --out ./reports --recursive --detect-format

Each files[] entry gains a format_detected tag ("pdf", "png", "zip", "sqlite3", "elf", ...) and — if the extension disagrees — a format_disagreement note. The summary gets a format_disagreement_count. Useful for catching renamed executables, mislabelled attachments, and content-type spoofing without shelling out to libmagic.

With --detect-format on, the default extension list is automatically widened to include common binary formats (PDF, ZIP-family, images, archives, executables). Pass --extensions explicitly to override that widening.

Writes ./reports/INVENTORY.json — a single JSON document containing:

  • schema — versioned schema identifier
  • summary — file_count, total_bytes, strict_utf8_files, exact_duplicate_groups, representation_group_count
  • files[] — one record per file: index, name, stem, extension, relative_path, bytes, sha256, line_count_binary_lf, lf_count, max_line_bytes, nul_bytes, high_bytes, utf8_strict_valid, utf8_error, plus a format-specific structural block for text files
  • representation_groups[] — same-stem families with a chosen semantic representative
  • exact_duplicates[] — SHA-256-identical file groups

Use as a library

from pathlib import Path
from corpus_scan import scan_bytes, scan_markdown, audit_corpus, partition_pdf_pages

# Byte-level scan of one file
info = scan_bytes(Path("document.md"))
print(info["sha256"], info["utf8_strict_valid"])

# Full inventory of a tree
payload = audit_corpus(root=Path("/corpus"), out=Path("./reports"))
print(payload["summary"])

# Partition a 850-page PDF into 100-page jobs
jobs = partition_pdf_pages(850, chunk_size=100)  # -> [(1,100,100), (101,200,100), ..., (801,850,50)]

What it does not do

  • Recurse into subdirectories by default. (Recursion is opt-in via --recursive from v0.2 onward. Single-directory remains the default because it makes intent explicit; the toolkit is aimed at reviewers who pick a "level" of their corpus deliberately.)
  • Load PDFs, DOCXs, or any format needing a third-party parser. Those files get a byte-scan only. Extending to Poppler / python-docx is on the roadmap as an optional extra.
  • Decrypt, transcode, or normalize anything. What's on disk goes in the inventory as-is.
  • Send anything anywhere.

Tamper-evident inventory log (v0.4+, optional)

Install the sibling zeropx-receipt-chain package to unlock a cross-package feature: every inventory gets appended to an append-only hash-chained ledger, so you can prove months later exactly which corpus inventories were taken, when, at which root, and what SHA-256 the inventory file had.

pip install "zeropx-corpus-scan[ledger]"

CLI:

corpus-scan --root ./corpus --out ./reports --recursive --detect-format \
            --ledger ./inventories.jsonl --ledger-tag matter-2026-001

Library:

from pathlib import Path
from corpus_scan import audit_corpus
from corpus_scan.ledger_integration import append_inventory_to_ledger

audit_corpus(root=Path("./corpus"), out=Path("./reports"), recursive=True)
entry = append_inventory_to_ledger(
    Path("./reports"), Path("./inventories.jsonl"),
    tag="matter-2026-001",
    extras={"matter_id": "M-2026-001", "reviewer": "you"},
)

Re-running the same scan appends idempotently — no duplicate entries.

Suggested workflow: audit / e-discovery

  1. corpus-scan --root /discovery/batch1 --out ./ledger
  2. Store INVENTORY.json alongside the batch as tamper-evident manifest.
  3. Cite specific file SHA-256s in your review notes.
  4. Re-run at any time; diff two INVENTORY.json to detect what changed.

Standalone Windows binary

A precompiled Windows binary is built by:

py -3.14 -m pip install pyinstaller
py -3.14 -m PyInstaller --onefile --name corpus-scan --paths src packaging_entry.py

Result: single-file dist/corpus-scan.exe (~9 MB) that runs on any Windows machine without Python installed.

Author & Provenance

Sole Author: Dr. Vander Geraldo Rodrigues da Cunha Júnior (vgrcjr@gmail.com).

Technical & AI-Assisted Provenance Disclosure: Auxiliary computational/LLM tooling was used strictly for boilerplate and test-harness scaffolding under 1:1 human architectural design, code review, deterministic test verification, and sole human authorship. Zero runtime third-party or AI dependencies.

License

MIT.

Metadata

Release files for zeropx-corpus-scan 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zeropx-corpus-scan 0.4.0
File Size Uploaded Provenance Actions
zeropx_corpus_scan-0.4.0.tar.gz 130.0 kB Without provenance Details for zeropx_corpus_scan-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zeropx-corpus-scan 0.4.0
File Interpreter ABI Platform Actions
zeropx_corpus_scan-0.4.0-py3-none-any.whl Python 3 none any Details for zeropx_corpus_scan-0.4.0-py3-none-any.whl

Total release size: 149.6 kB

Release files / zeropx_corpus_scan-0.4.0.tar.gz

Download URL zeropx_corpus_scan-0.4.0.tar.gz
Size 130.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bbc9c5437f912a89f10e2f2e374cdd4c1638351bb1d9325e4bf6c4d9d32d0b2e
BLAKE2b-256 checksum
How to use checksums
4c55bffee451376420875ca55321def897f59f6885145ed191795353d0035486
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / zeropx_corpus_scan-0.4.0-py3-none-any.whl

Download URL zeropx_corpus_scan-0.4.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bafe2426a5bec3369daba07e5008dabfbd24d996cab08ee8ffd687be8b276d2
BLAKE2b-256 checksum
How to use checksums
9c30413b453330f3005a2df9b35e06f16d2c21019a3311c8386de124443f152e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for zeropx-corpus-scan 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page