Commit 7fed9b9
committed
feat(quasicryth-research): phase 5+6 — cross-variant integration + CLI
Phase 5 (integration tests) + Phase 6 (CLI binary), bundled.
Phase 5 — cross-variant integration tests
=========================================
New test file tests/round_trip.rs (7 tests):
- variants_agree_on_long_natural_text — 600-char Fibonacci-theory
paragraph round-trips under BOTH variants AND the decompressed
outputs are identical
- round_trip_at_5kb_scale — cyclic phrase to 5 KB, both variants
- round_trip_single_word
- round_trip_only_whitespace
- round_trip_mixed_punctuation_lines (parens, hyphens, semicolons,
quotes, tabs)
- round_trip_repeated_uppercase_word
- cross_variant_independence — compress with Flat, decompress;
compress with CowRadix, decompress; both equal original.
(Compressed bytes between variants MAY differ; decoded output
MUST match.)
This is the architectural property the codebook trait contract
guarantees and the workspace's substrate doctrine requires: the
COW radix trie variant is a drop-in alternative to the flat
storage variant at the compress/decompress boundary.
Phase 6 — CLI binary
====================
New src/bin/qresearch.rs (~170 LOC):
qresearch compress [-v flat|cow] <input> <output>
qresearch decompress <input> <output>
qresearch round-trip [-v flat|cow] <input>
qresearch --help / -h
Standard library only. Returns ExitCode::SUCCESS / ExitCode::FAILURE
with clean error messages on read/write/codec failures. The
`round-trip` subcommand reports compression ratio AND verifies
identity for quick validation on arbitrary text files.
Live test:
$ echo "The Fibonacci substitution..." > /tmp/sample.txt
$ qresearch round-trip /tmp/sample.txt
round-trip OK: 95 bytes → 329 compressed (346.32%) → identical, variant=Flat
$ qresearch round-trip -v cow /tmp/sample.txt
round-trip OK: 95 bytes → 329 compressed (346.32%) → identical, variant=CowRadix
(The >100% ratio on 95-byte inputs is expected: v1 simplifications
mean headers + per-token spans dominate at small sizes. The C
reference's per-byte overhead amortizes over much larger inputs
and uses multi-tier n-grams + LZMA escape + word-LZ77 to get
≤25% on enwik9. The Rust pipeline here demonstrates correctness,
not benchmark-competitive compression.)
README rewrite
==============
New README.md (180 lines) documents:
- the 7-phase transcode map (which C file → which Rust module)
- test counts per phase (total: 83)
- what's NOT byte-compatible with the upstream qm56 format
- CLI usage examples
- both codebook variants compared in a table
- the compressed stream format (v1 QRS1 magic) field by field
- relationships to bgz17 / helix / jc::weyl in the workspace
- paper-theorem verification list (Thm 2, Cor 4, Thm 9, Thm 13/Cor 15,
Sturmian minimality, PV property)
Final totals
============
Tests: 83 (was 76)
- 67 unit (no change)
- 9 paper-theorem integration
- 7 cross-variant integration (NEW)
Verification:
cargo test → 83 passed, 0 failed
cargo clippy --all-targets -- -D warnings clean
cargo fmt clean
cargo build --bin qresearch builds, CLI exercised
Zero dependencies. No unsafe. Stable Rust.
Full crate inventory
====================
Modules LOC Role
───── ─── ────
types 97 Tile, HLevel, ParentMap, Hierarchy, DeepPositions
constants 192 PHI, INV_PHI, MAX_HIER, HIER_WORD_LENS, 36 tilings
tiling 388 cut-and-project + 5 substitution-rule families
hierarchy 308 build_hierarchy, hier_context, detect_deep_positions
md5 196 RFC 1321 (~85 LOC C transcoded)
tok 377 tokenize, word_split, apply_case, TokenStream
codebook 744 Codebook trait + FlatCodebook + CowRadixCodebook +
CowArt (ART with Node4/Node16/Node256, path-copy)
arith_coder 640 Model256, VModel (Fenwick), Encoder, Decoder
pipeline 460 compress, decompress, Variant, PipelineError
bin/qresearch 170 CLI (compress/decompress/round-trip)
tests/... 310 paper_theorems + round_trip integration
lib + README 280
Total: ~4,160 LOC Rust (was ~1,300 after phase 0).1 parent de566f6 commit 7fed9b9
3 files changed
Lines changed: 396 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
19 | 59 | | |
20 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
21 | 63 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
27 | 67 | | |
28 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
29 | 96 | | |
30 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
31 | 100 | | |
32 | 101 | | |
33 | 102 | | |
34 | 103 | | |
35 | 104 | | |
36 | | - | |
37 | | - | |
| 105 | + | |
| 106 | + | |
38 | 107 | | |
39 | 108 | | |
40 | | - | |
41 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
42 | 137 | | |
43 | 138 | | |
44 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
45 | 151 | | |
46 | 152 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 153 | + | |
| 154 | + | |
52 | 155 | | |
53 | 156 | | |
54 | 157 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
64 | 168 | | |
65 | 169 | | |
66 | 170 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
0 commit comments