Phase 1 prototype · exact-text compression

LEXORA

Layered EXact-text Repository & Adaptive compression architecture. A text-cleaning and exact-compression system for document collections: canonicalize conservatively, then compress with guaranteed byte-exact recovery — decode(encode(C)) == C for every input.

CI status Tests: 192 passed locally Python 3.12 License MIT Version 0.0.1.dev1 round-trip byte-exact container .lxz v0 RAM budget ~4 GiB

No releases yet · no stable API · install from a source checkout · pytest -q is the local gate

What it is

Clean conservatively. Compress exactly.

LEXORA ingests text, canonicalizes it into deterministic UTF-8 bytes, and then compresses those bytes with a guarantee that holds for every input: the decompressed stream is byte-identical to the canonical stream. The core invariant is deliberate — canonicalization may lose information relative to the original source; compression after canonicalization must never lose a single byte.

Byte-exact losslessness

The round-trip is verified before anything is written: decode(encode(C)) == C. A failed comparison is a blocker, not a warning.

core invariant

Conservative canonicalization

Versioned, deterministic rule set (lexcan-0.1: CAN-R01/R02/R05) with golden test vectors and a whitelist contract — non-matching bytes pass through unchanged.

versioned rules

Cost-driven selection

Candidates compete against pinned baselines under a total-serialized-byte cost model — every byte of header, index and payload counts, not just the compressed stream.

measured, not assumed

.lxz v0 container

Frozen v0 layout per ADR-0007: 128-byte header, one complete zstd frame per block, per-block SHA-256, 40-byte trailer. Every block is decode-verified and the write is atomic.

experimental · major 0

A real CLI

Five tested subcommands — canon, zround, pipe, pack, unpack — with a stable exit-code contract (0, 2–7) exercised by the test suite.

canon/zround/pipe/pack/unpack

Built for low resources

Designed to run within a ~4 GiB RAM budget using bounded, streaming/block-based processing. Multilingual coverage (English, Hindi, Gujarati) is a design target.

bounded blocks
Interface

What the tool looks like

The experimental PySide6 GUI (milestones M1–M3, not released) shows a document collection, the cost-selected codec result and the round-trip verdict in one window. The figures below are the only published numbers — the Tier-1 smoke snapshot, baseline-vs-baseline.

Interface illustration — LEXORA is a Phase 1 prototype with no releases and no stable API; the figures shown are the project's published T1-gutenberg-p0 smoke snapshot (baseline-vs-baseline).

How it works

A pipeline with one hard boundary

Extraction and canonicalization are allowed to be lossy relative to the source. Everything after the canonical bytes exist must round-trip exactly. That boundary is where the guarantee lives.

01

Ingest

TXT/PDF files; OCR optional for scanned pages. (file ingestion planned)

02

Canonicalize

Versioned, deterministic UTF-8 bytes. may be lossy vs source

03

Compress

Cost-selected codec; candidate vs pinned baselines.

04

Verify

decode(encode(C)) == C enforced before writing.

05

Archive

.lxz v0 container now; .lxdb planned.

Quickstart

Install from a source checkout — no published package exists yet.

bash — install & verify
# editable install (Qt-free core)
pip install -e .
# + test suite, or + experimental PySide6 GUI
pip install -e ".[dev]"
pip install -e ".[gui]"

python3 -m pytest -q   # 192 passed locally
lexora --help          # lexora 0.0.1.dev1

Run the pipeline

canonicalize → compress → verify, then pack into a container.

bash — end-to-end
# raw → canonical → zstd frame → verify
lexora pipe --in raw.txt --out out.zst

# or step by step
lexora canon  --in raw.txt --out canon.txt
lexora zround --in canon.txt --out frame.zst

# wrap canonical bytes into .lxz v0
lexora pack   --in canon.txt --out archive.lxz
lexora unpack --in archive.lxz --out back.txt
Exit codes are part of the contract: 0 success · 2 usage · 3 I/O · 4 canonicalization · 5 codec · 6 round-trip failure · 7 container refusal. A round-trip mismatch (6) is a blocker severity.
Benchmarks

Measured results — reported honestly

There is no validated LEXORA-vs-baseline result yet. The figures below are the only published numbers: a Tier-1 smoke snapshot comparing frozen generic baselines against each other, not a gate verdict. Every number carries its mandatory tier label.

Corpus tier: T1-gutenberg-p0

7,124,095 B
Corpus input (6 English public-domain texts, 5 train / 1 held-out)
R1 · R2 · 2026-10-16
0.3004
Zstd-19 ratio — 2,139,962 B stored
baseline
0.2975
XZ-9 ratio — 2,119,756 B stored
baseline
FileSplitInput BZstd-19 B (ratio)XZ-9 B (ratio)
gutenberg-1184.txtheldout2,787,124782,892 (0.2809)776,472 (0.2786)
gutenberg-1342.txttrain772,386226,028 (0.2926)223,512 (0.2894)
gutenberg-1400.txttrain1,058,204324,526 (0.3067)321,664 (0.3040)
gutenberg-1661.txttrain607,606191,034 (0.3144)188,860 (0.3108)
gutenberg-2701.txttrain1,276,315422,220 (0.3308)418,184 (0.3276)
gutenberg-76.txttrain622,460193,262 (0.3105)191,064 (0.3069)

Acceptance gates (defined, not yet met)

A candidate codec does not exist yet, so no Pass/Partial/Fail row can be filled.

≥ 10%
Pass — smaller total stored size vs best frozen baseline
≥ 3%
Partial — smaller total stored size

Peak RSS (measured once, R3 artifact): zstd-19 ≈ 85,956 KiB · xz-9 ≈ 35,348 KiB. Budget target ≈ 4 GiB (REF-4G).

Known caveats, recorded honestly: 2 of 8 requested texts were discarded by the fetch size guard; held-out is a single lineage, so statistical strength is nil; the corpus (~7.1 MB) is far below the ≥1 GiB protocol target.

Get started

Clone it, install it, run the gate

LEXORA is an early Phase 1 prototype. Nothing here is a shipped or released feature — install from source and treat the test suite as the contract.

$ git clone

bash
git clone https://github.com/drsamonline/lexora.git
cd lexora
pip install -e ".[dev]"
python3 -m pytest -q

Python ≥3.12,<4.0 · dependency zstandard pinned to a tested range · GUI is an opt-in [gui] extra.

What you get

  • canonicalize.py — conservative v0 rule set with golden vectors
  • zstd_core.py — frame codec with round-trip verification
  • container.py — .lxz v0 pack/unpack (ADR-0007)
  • cli.py — the five-subcommand CLI with stable exit codes
  • benchmarks/ — harness + frozen corpus manifest

No releases, no download artifacts, and no coverage/release badges exist — those claims are not yet true.

FAQ

Straight answers

Q01Is LEXORA released or production-ready?
No. It is a Phase 1 prototype in development with no stable API and no releases. Early implementation code exists (canonicalization, a Zstd core baseline, the .lxz v0 container, a benchmark harness, a CLI, and experimental PySide6 GUI milestones).
Q02Does LEXORA beat Zstd, Brotli or XZ?
No validated evidence exists either way, and the project says so explicitly. The only published numbers are baseline-vs-baseline on a Tier-1 smoke corpus. Claiming any advantage before reproducible benchmark evidence would be out of scope by design.
Q03What exactly does "byte-exact" mean here?
For the canonical byte stream C, the guarantee is decode(encode(C)) == C for every input. It is enforced at build time — a mismatch is treated as a blocker (exit code 6), not a warning.
Q04Can canonicalization lose data?
Yes — by design, and conservatively. Canonicalization may be lossy relative to the original source (for example, encoding normalization and line-ending normalization). The hard rule is that compression after canonicalization must never lose a byte. Reconstructing original OCR output or PDF layout bit-for-bit is an explicit non-goal.
Q05Which languages and inputs are supported?
Design targets are .txt and .pdf (text layer first, OCR optional for scans) across Latin, Devanagari and Gujarati scripts. Current reality: byte-level canonicalization of raw text streams is implemented; TXT/PDF file ingestion is not implemented yet, and the build scope is English-only, with Hindi/Gujarati deferred (not blocking).
Q06What is the licence, and who maintains it?
MIT © 2026 Dr. Sohil Momin, who owns the project. CI runs are currently paused by owner decision (free-tier minutes exhausted); the verification gate is local — pytest -q plus a docs link check before every commit.