kolmox 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kolmox-1.1.0/LICENSE +28 -0
- kolmox-1.1.0/PKG-INFO +112 -0
- kolmox-1.1.0/README.md +89 -0
- kolmox-1.1.0/pyproject.toml +30 -0
- kolmox-1.1.0/setup.cfg +4 -0
- kolmox-1.1.0/setup.py +53 -0
- kolmox-1.1.0/src/kolmox/__init__.py +0 -0
- kolmox-1.1.0/src/kolmox/cli/__init__.py +0 -0
- kolmox-1.1.0/src/kolmox/cli/main.py +110 -0
- kolmox-1.1.0/src/kolmox/core/__init__.py +0 -0
- kolmox-1.1.0/src/kolmox/core/chunked.py +119 -0
- kolmox-1.1.0/src/kolmox/core/chunker.py +106 -0
- kolmox-1.1.0/src/kolmox/core/container.py +41 -0
- kolmox-1.1.0/src/kolmox/core/delta.py +38 -0
- kolmox-1.1.0/src/kolmox/core/domain_router.py +128 -0
- kolmox-1.1.0/src/kolmox/core/fast_transforms.c +84 -0
- kolmox-1.1.0/src/kolmox/core/hardware.py +176 -0
- kolmox-1.1.0/src/kolmox/core/mesh_cad.py +176 -0
- kolmox-1.1.0/src/kolmox/core/pipeline.py +180 -0
- kolmox-1.1.0/src/kolmox/core/streaming.py +63 -0
- kolmox-1.1.0/src/kolmox/core/stride.py +59 -0
- kolmox-1.1.0/src/kolmox/core/text_columnar.py +65 -0
- kolmox-1.1.0/src/kolmox/sandbox/__init__.py +0 -0
- kolmox-1.1.0/src/kolmox/sandbox/runner.py +52 -0
- kolmox-1.1.0/src/kolmox/synthesizer/__init__.py +0 -0
- kolmox-1.1.0/src/kolmox/synthesizer/engine.py +53 -0
- kolmox-1.1.0/src/kolmox/synthesizer/llm_bridge.py +47 -0
- kolmox-1.1.0/src/kolmox/synthesizer/local_llm.py +55 -0
- kolmox-1.1.0/src/kolmox/synthesizer/profiler.py +36 -0
- kolmox-1.1.0/src/kolmox.egg-info/PKG-INFO +112 -0
- kolmox-1.1.0/src/kolmox.egg-info/SOURCES.txt +52 -0
- kolmox-1.1.0/src/kolmox.egg-info/dependency_links.txt +1 -0
- kolmox-1.1.0/src/kolmox.egg-info/entry_points.txt +2 -0
- kolmox-1.1.0/src/kolmox.egg-info/requires.txt +4 -0
- kolmox-1.1.0/src/kolmox.egg-info/top_level.txt +1 -0
- kolmox-1.1.0/tests/test_c_api.py +15 -0
- kolmox-1.1.0/tests/test_cad_extended.py +46 -0
- kolmox-1.1.0/tests/test_chunked.py +41 -0
- kolmox-1.1.0/tests/test_cli.py +35 -0
- kolmox-1.1.0/tests/test_container.py +0 -0
- kolmox-1.1.0/tests/test_delta.py +40 -0
- kolmox-1.1.0/tests/test_end_to_end.py +40 -0
- kolmox-1.1.0/tests/test_extended_domains.py +78 -0
- kolmox-1.1.0/tests/test_extended_pipeline_e2e.py +74 -0
- kolmox-1.1.0/tests/test_fuzz_resilience.py +28 -0
- kolmox-1.1.0/tests/test_llm_bridge.py +12 -0
- kolmox-1.1.0/tests/test_local_llm.py +11 -0
- kolmox-1.1.0/tests/test_mesh_cad.py +46 -0
- kolmox-1.1.0/tests/test_multiblock.py +28 -0
- kolmox-1.1.0/tests/test_raster.py +13 -0
- kolmox-1.1.0/tests/test_streaming.py +24 -0
- kolmox-1.1.0/tests/test_synthesizer.py +22 -0
- kolmox-1.1.0/tests/test_video.py +28 -0
kolmox-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
KolmoX Dual Licensing Agreement
|
|
2
|
+
============================
|
|
3
|
+
|
|
4
|
+
KolmoX is dual-licensed under:
|
|
5
|
+
|
|
6
|
+
1. GNU Affero General Public License v3.0 (AGPLv3) for open-source use.
|
|
7
|
+
2. A separate Commercial / Enterprise License for proprietary and closed-source integrations.
|
|
8
|
+
|
|
9
|
+
Contact: toskurim@gmail.com for commercial licensing inquiries.
|
|
10
|
+
|
|
11
|
+
----------------------------------------
|
|
12
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
13
|
+
Version 3, 19 November 2007
|
|
14
|
+
|
|
15
|
+
Copyright (C) 2026 Toskurim
|
|
16
|
+
|
|
17
|
+
Everyone is permitted to copy and distribute verbatim
|
|
18
|
+
copies of this license document, but changing it is not allowed.
|
|
19
|
+
|
|
20
|
+
This program is free software: you can redistribute it and/or modify
|
|
21
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
22
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
23
|
+
(at your option) any later version.
|
|
24
|
+
|
|
25
|
+
This program is distributed in the hope that it will be useful,
|
|
26
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
+
GNU Affero General Public License for more details.
|
kolmox-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kolmox
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: High-Performance Bit-Exact Compression Framework
|
|
5
|
+
Home-page: https://github.com/Toskurim/KolmoX
|
|
6
|
+
Author: Toskurim
|
|
7
|
+
Author-email: Toskurim <toskurim@gmail.com>
|
|
8
|
+
Project-URL: Homepage, https://github.com/Toskurim/KolmoX
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: System :: Archiving :: Compression
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: zstandard>=0.22.0
|
|
16
|
+
Requires-Dist: numpy>=1.24.0
|
|
17
|
+
Requires-Dist: requests>=2.31.0
|
|
18
|
+
Requires-Dist: rich>=13.7.0
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
|
|
24
|
+
# KolmoX
|
|
25
|
+
|
|
26
|
+
[](https://github.com/Toskurim/KolmoX/actions/workflows/tests.yml) [](https://github.com/Toskurim/KolmoX/releases/tag/v1.1.0) [](LICENSE) [](#-license)
|
|
27
|
+
|
|
28
|
+
**KolmoX** is an enterprise-grade, high-throughput lossless data compression framework. While traditional compressors (such as Gzip, LZMA, and standalone Zstd) treat inputs as opaque 1D byte streams, KolmoX employs a two-stage pipeline based on **Kolmogorov Structural Preconditioning**:
|
|
29
|
+
|
|
30
|
+
1. **Domain-Aware Structural Transformations:** Automatically detects data topology and applies deterministic, bit-exact transforms (IEEE-754 float32 byte-plane slicing, CNC G-Code axis isolation, stereo PCM decorrelation, 2D spatial delta modeling, and x86 BCJ branch normalization) to eliminate correlation entropy.
|
|
31
|
+
2. **KMX2 Multi-Stream Container:** Encapsulates primary and auxiliary streams into a 24-byte fixed-header format with high-speed Zstandard FSE entropy coding.
|
|
32
|
+
3. **High-Performance & Streaming:** Features C-accelerated transposition kernels (up to 826+ MB/s), a constant-memory chunked streaming engine (`KolmoXStreamer`) for multi-GB workloads, and a standalone C-ABI (`include/kolmox.h`) with CMake support.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 📊 Real-World Benchmark Results
|
|
37
|
+
|
|
38
|
+
All tests certify **exact mathematical data restoration** (zero precision loss, bit-exact roundtrip):
|
|
39
|
+
|
|
40
|
+
| Data Domain | Pipeline / Transform | Gzip (L9) | Zstd (Base) | KolmoX (KMX2) | Gain vs Zstd | Throughput (Comp / Decomp) |
|
|
41
|
+
| :--- | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
42
|
+
| **2D Uncompressed Raster (RGB)** | 2D Spatial Delta + Color Slicing | 2.10x | 4.30x | **89.08x** | **+1970%** | ~240 MB/s / ~310 MB/s |
|
|
43
|
+
| **Binary Register Packets (.bin)** | Stride Autocorr + Demux | 2.65x | 4.83x | **55.53x** | **+1050% (11.5x)** | ~180 MB/s / ~260 MB/s |
|
|
44
|
+
| **LiDAR XYZ Point Cloud** | Columnar Coordinate Isolation | 8.40x | 27.11x | **47.31x** | **+42.70%** | 77.3 MB/s / 112.1 MB/s |
|
|
45
|
+
| **Industrial Telemetry (.csv)** | Columnar Demux + Quant Delta | 3.93x | 19.65x | **40.20x** | **+104%** | ~120 MB/s / ~190 MB/s |
|
|
46
|
+
| **CNC G-Code (.gcode)** | Columnar Axis Separation | 4.20x | 5.69x | **29.25x** | **+63.94%** | 18.8 MB/s / 30.8 MB/s |
|
|
47
|
+
| **Parametric 3D CAD Mesh (.obj)** | Ordered Vertex Transpose | 4.38x | 8.42x | **14.07x** | **+67%** | ~95 MB/s / ~140 MB/s |
|
|
48
|
+
| **4K & 5K Video Streams (60fps)** | Temporal NVDEC + Delta-XOR | ~1.10x | ~1.15x | **3.15x – 6.56x** | **+170%** | ~450 MB/s / ~600 MB/s |
|
|
49
|
+
| **Scientific Float32 (.npy)** | Byte-Plane Slicing (Sign/Exp/Mant) | 1.15x | 1.30x | **28.77x** | **+31.98%** | 826.3 MB/s / 750.0 MB/s |
|
|
50
|
+
| **Audio PCM 16-bit (.wav)** | Stereo Decorrelation + Diff | 1.01x | 39.81x | **41.55x** | **+17.72%** | 457.5 MB/s / 354.5 MB/s |
|
|
51
|
+
| **x86 Binary Executable (.exe)** | Branch Target Normalizer (BCJ) | 5.40x | 7.59x | **7.65x** | **+0.76%** | ~380 MB/s / ~420 MB/s |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🚀 Installation & Setup
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Clone the repository
|
|
59
|
+
git clone https://github.com/Toskurim/KolmoX.git
|
|
60
|
+
cd KolmoX
|
|
61
|
+
|
|
62
|
+
# Install Python package in editable mode (with C-extension)
|
|
63
|
+
pip install -r requirements.txt
|
|
64
|
+
pip install -e .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## ⚙️ CMake Standalone C-Library Build
|
|
68
|
+
For direct C/C++/Rust integration without Python:
|
|
69
|
+
```bash
|
|
70
|
+
cmake -B build
|
|
71
|
+
cmake --build build --config Release
|
|
72
|
+
```
|
|
73
|
+
This generates `libkolmox.so` (or `kolmox.dll` / `libkolmox.dylib`) using the public C-ABI defined in `include/kolmox.h`.
|
|
74
|
+
|
|
75
|
+
## 🔧 Quickstart CLI
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Auto-detect domain and compress into KMX2 container
|
|
79
|
+
kolmox compress path/to/file.gcode -o file.kmx
|
|
80
|
+
|
|
81
|
+
# Bit-exact decompression
|
|
82
|
+
kolmox decompress file.kmx -o restored.gcode
|
|
83
|
+
|
|
84
|
+
# Run throughput benchmark suite
|
|
85
|
+
python tests/benchmark_throughput.py
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 🔄 Constant-Memory Streaming API
|
|
89
|
+
For multi-Gigabyte files, KolmoX provides a streaming engine that executes in bounded RAM (default 8MB chunks):
|
|
90
|
+
```python
|
|
91
|
+
from kolmox.core.streaming import KolmoXStreamer
|
|
92
|
+
|
|
93
|
+
streamer = KolmoXStreamer(chunk_size=8 * 1024 * 1024)
|
|
94
|
+
|
|
95
|
+
# Stream compression from file-like objects
|
|
96
|
+
with open("large_scan.xyz", "rb") as src, open("large_scan.kmxs", "wb") as dst:
|
|
97
|
+
streamer.compress_stream(src, dst, filename="large_scan.xyz")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 🛡️ Testing & Fuzz Resilience
|
|
101
|
+
KolmoX includes a 32-test validation suite covering end-to-end roundtrips, C-ABI equivalence, and fuzz resilience against malformed or truncated data:
|
|
102
|
+
```bash
|
|
103
|
+
pytest tests/ -v
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 📖 Technical Whitepaper
|
|
107
|
+
A full academic whitepaper detailing the Kolmogorov complexity foundations, KMX2 container specification, and mathematical transforms is available in [docs/WHITEPAPER.md](docs/WHITEPAPER.md) and as a downloadable PDF in [docs/KolmoX_Technical_Paper_v1.1.0_Complete_EN.pdf](docs/KolmoX_Technical_Paper_v1.1.0_Complete_EN.pdf).
|
|
108
|
+
|
|
109
|
+
## 📜 License
|
|
110
|
+
KolmoX is dual-licensed:
|
|
111
|
+
* **Open Source:** [GNU Affero General Public License v3.0 (AGPLv3)](LICENSE).
|
|
112
|
+
* **Commercial & Enterprise:** For proprietary software integration without AGPLv3 copyleft obligations, contact `toskurim@gmail.com`.
|
kolmox-1.1.0/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# KolmoX
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Toskurim/KolmoX/actions/workflows/tests.yml) [](https://github.com/Toskurim/KolmoX/releases/tag/v1.1.0) [](LICENSE) [](#-license)
|
|
4
|
+
|
|
5
|
+
**KolmoX** is an enterprise-grade, high-throughput lossless data compression framework. While traditional compressors (such as Gzip, LZMA, and standalone Zstd) treat inputs as opaque 1D byte streams, KolmoX employs a two-stage pipeline based on **Kolmogorov Structural Preconditioning**:
|
|
6
|
+
|
|
7
|
+
1. **Domain-Aware Structural Transformations:** Automatically detects data topology and applies deterministic, bit-exact transforms (IEEE-754 float32 byte-plane slicing, CNC G-Code axis isolation, stereo PCM decorrelation, 2D spatial delta modeling, and x86 BCJ branch normalization) to eliminate correlation entropy.
|
|
8
|
+
2. **KMX2 Multi-Stream Container:** Encapsulates primary and auxiliary streams into a 24-byte fixed-header format with high-speed Zstandard FSE entropy coding.
|
|
9
|
+
3. **High-Performance & Streaming:** Features C-accelerated transposition kernels (up to 826+ MB/s), a constant-memory chunked streaming engine (`KolmoXStreamer`) for multi-GB workloads, and a standalone C-ABI (`include/kolmox.h`) with CMake support.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📊 Real-World Benchmark Results
|
|
14
|
+
|
|
15
|
+
All tests certify **exact mathematical data restoration** (zero precision loss, bit-exact roundtrip):
|
|
16
|
+
|
|
17
|
+
| Data Domain | Pipeline / Transform | Gzip (L9) | Zstd (Base) | KolmoX (KMX2) | Gain vs Zstd | Throughput (Comp / Decomp) |
|
|
18
|
+
| :--- | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
19
|
+
| **2D Uncompressed Raster (RGB)** | 2D Spatial Delta + Color Slicing | 2.10x | 4.30x | **89.08x** | **+1970%** | ~240 MB/s / ~310 MB/s |
|
|
20
|
+
| **Binary Register Packets (.bin)** | Stride Autocorr + Demux | 2.65x | 4.83x | **55.53x** | **+1050% (11.5x)** | ~180 MB/s / ~260 MB/s |
|
|
21
|
+
| **LiDAR XYZ Point Cloud** | Columnar Coordinate Isolation | 8.40x | 27.11x | **47.31x** | **+42.70%** | 77.3 MB/s / 112.1 MB/s |
|
|
22
|
+
| **Industrial Telemetry (.csv)** | Columnar Demux + Quant Delta | 3.93x | 19.65x | **40.20x** | **+104%** | ~120 MB/s / ~190 MB/s |
|
|
23
|
+
| **CNC G-Code (.gcode)** | Columnar Axis Separation | 4.20x | 5.69x | **29.25x** | **+63.94%** | 18.8 MB/s / 30.8 MB/s |
|
|
24
|
+
| **Parametric 3D CAD Mesh (.obj)** | Ordered Vertex Transpose | 4.38x | 8.42x | **14.07x** | **+67%** | ~95 MB/s / ~140 MB/s |
|
|
25
|
+
| **4K & 5K Video Streams (60fps)** | Temporal NVDEC + Delta-XOR | ~1.10x | ~1.15x | **3.15x – 6.56x** | **+170%** | ~450 MB/s / ~600 MB/s |
|
|
26
|
+
| **Scientific Float32 (.npy)** | Byte-Plane Slicing (Sign/Exp/Mant) | 1.15x | 1.30x | **28.77x** | **+31.98%** | 826.3 MB/s / 750.0 MB/s |
|
|
27
|
+
| **Audio PCM 16-bit (.wav)** | Stereo Decorrelation + Diff | 1.01x | 39.81x | **41.55x** | **+17.72%** | 457.5 MB/s / 354.5 MB/s |
|
|
28
|
+
| **x86 Binary Executable (.exe)** | Branch Target Normalizer (BCJ) | 5.40x | 7.59x | **7.65x** | **+0.76%** | ~380 MB/s / ~420 MB/s |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 Installation & Setup
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Clone the repository
|
|
36
|
+
git clone https://github.com/Toskurim/KolmoX.git
|
|
37
|
+
cd KolmoX
|
|
38
|
+
|
|
39
|
+
# Install Python package in editable mode (with C-extension)
|
|
40
|
+
pip install -r requirements.txt
|
|
41
|
+
pip install -e .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## ⚙️ CMake Standalone C-Library Build
|
|
45
|
+
For direct C/C++/Rust integration without Python:
|
|
46
|
+
```bash
|
|
47
|
+
cmake -B build
|
|
48
|
+
cmake --build build --config Release
|
|
49
|
+
```
|
|
50
|
+
This generates `libkolmox.so` (or `kolmox.dll` / `libkolmox.dylib`) using the public C-ABI defined in `include/kolmox.h`.
|
|
51
|
+
|
|
52
|
+
## 🔧 Quickstart CLI
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Auto-detect domain and compress into KMX2 container
|
|
56
|
+
kolmox compress path/to/file.gcode -o file.kmx
|
|
57
|
+
|
|
58
|
+
# Bit-exact decompression
|
|
59
|
+
kolmox decompress file.kmx -o restored.gcode
|
|
60
|
+
|
|
61
|
+
# Run throughput benchmark suite
|
|
62
|
+
python tests/benchmark_throughput.py
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 🔄 Constant-Memory Streaming API
|
|
66
|
+
For multi-Gigabyte files, KolmoX provides a streaming engine that executes in bounded RAM (default 8MB chunks):
|
|
67
|
+
```python
|
|
68
|
+
from kolmox.core.streaming import KolmoXStreamer
|
|
69
|
+
|
|
70
|
+
streamer = KolmoXStreamer(chunk_size=8 * 1024 * 1024)
|
|
71
|
+
|
|
72
|
+
# Stream compression from file-like objects
|
|
73
|
+
with open("large_scan.xyz", "rb") as src, open("large_scan.kmxs", "wb") as dst:
|
|
74
|
+
streamer.compress_stream(src, dst, filename="large_scan.xyz")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 🛡️ Testing & Fuzz Resilience
|
|
78
|
+
KolmoX includes a 32-test validation suite covering end-to-end roundtrips, C-ABI equivalence, and fuzz resilience against malformed or truncated data:
|
|
79
|
+
```bash
|
|
80
|
+
pytest tests/ -v
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 📖 Technical Whitepaper
|
|
84
|
+
A full academic whitepaper detailing the Kolmogorov complexity foundations, KMX2 container specification, and mathematical transforms is available in [docs/WHITEPAPER.md](docs/WHITEPAPER.md) and as a downloadable PDF in [docs/KolmoX_Technical_Paper_v1.1.0_Complete_EN.pdf](docs/KolmoX_Technical_Paper_v1.1.0_Complete_EN.pdf).
|
|
85
|
+
|
|
86
|
+
## 📜 License
|
|
87
|
+
KolmoX is dual-licensed:
|
|
88
|
+
* **Open Source:** [GNU Affero General Public License v3.0 (AGPLv3)](LICENSE).
|
|
89
|
+
* **Commercial & Enterprise:** For proprietary software integration without AGPLv3 copyleft obligations, contact `toskurim@gmail.com`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "kolmox"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Toskurim", email = "toskurim@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "High-Performance Bit-Exact Compression Framework"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Topic :: System :: Archiving :: Compression"
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"zstandard>=0.22.0",
|
|
21
|
+
"numpy>=1.24.0",
|
|
22
|
+
"requests>=2.31.0",
|
|
23
|
+
"rich>=13.7.0"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
kolmox = "kolmox.cli.main:main"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/Toskurim/KolmoX"
|
kolmox-1.1.0/setup.cfg
ADDED
kolmox-1.1.0/setup.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from setuptools import setup, Extension, find_packages
|
|
2
|
+
from setuptools.command.build_ext import build_ext
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
class OptionalBuildExt(build_ext):
|
|
6
|
+
def build_extension(self, ext):
|
|
7
|
+
try:
|
|
8
|
+
super().build_extension(ext)
|
|
9
|
+
except Exception:
|
|
10
|
+
print(f"Warning: Could not build C extension {ext.name}. Using pure-Python/NumPy fallback.")
|
|
11
|
+
|
|
12
|
+
long_description = ""
|
|
13
|
+
if os.path.exists("README.md"):
|
|
14
|
+
with open("README.md", "r", encoding="utf-8") as f:
|
|
15
|
+
long_description = f.read()
|
|
16
|
+
|
|
17
|
+
fast_ext = Extension(
|
|
18
|
+
"kolmox.core.fast_transforms",
|
|
19
|
+
sources=["src/kolmox/core/fast_transforms.c"],
|
|
20
|
+
optional=True,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
setup(
|
|
24
|
+
name="kolmox",
|
|
25
|
+
version="1.1.0",
|
|
26
|
+
author="Toskurim",
|
|
27
|
+
author_email="toskurim@gmail.com",
|
|
28
|
+
description="Next-generation high-throughput domain-aware lossless data compression framework.",
|
|
29
|
+
long_description=long_description,
|
|
30
|
+
long_description_content_type="text/markdown",
|
|
31
|
+
url="https://github.com/Toskurim/KolmoX",
|
|
32
|
+
package_dir={"": "src"},
|
|
33
|
+
packages=find_packages(where="src"),
|
|
34
|
+
ext_modules=[fast_ext],
|
|
35
|
+
cmdclass={"build_ext": OptionalBuildExt},
|
|
36
|
+
entry_points={
|
|
37
|
+
"console_scripts": [
|
|
38
|
+
"kolmox=kolmox.cli.main:main",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
classifiers=[
|
|
42
|
+
"Development Status :: 5 - Production/Stable",
|
|
43
|
+
"Intended Audience :: Developers",
|
|
44
|
+
"Intended Audience :: Science/Research",
|
|
45
|
+
"License :: OSI Approved :: GNU Affero General Public License v3 (AGPLv3)",
|
|
46
|
+
"Programming Language :: Python :: 3",
|
|
47
|
+
"Programming Language :: Python :: 3.10",
|
|
48
|
+
"Programming Language :: Python :: 3.11",
|
|
49
|
+
"Programming Language :: Python :: 3.12",
|
|
50
|
+
"Topic :: System :: Archiving :: Compression",
|
|
51
|
+
],
|
|
52
|
+
python_requires=">=3.10",
|
|
53
|
+
)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""
|
|
2
|
+
KolmoX CLI (v1.1.0)
|
|
3
|
+
Command-line interface for compression, decompression, and domain dispatch.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from kolmox.core.chunked import ChunkedPipelineEngine
|
|
11
|
+
from kolmox.core.pipeline import KMX2_MAGIC, KolmoXPipeline
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def auto_compress(
|
|
15
|
+
input_path: str,
|
|
16
|
+
output_path: str,
|
|
17
|
+
chunked: bool = False,
|
|
18
|
+
workers: int = 4,
|
|
19
|
+
quiet: bool = False,
|
|
20
|
+
):
|
|
21
|
+
in_p = Path(input_path)
|
|
22
|
+
out_p = Path(output_path)
|
|
23
|
+
|
|
24
|
+
raw_data = in_p.read_bytes()
|
|
25
|
+
|
|
26
|
+
if chunked or len(raw_data) > 32 * 1024 * 1024:
|
|
27
|
+
ChunkedPipelineEngine.compress_large_file(
|
|
28
|
+
input_path, output_path, max_workers=workers
|
|
29
|
+
)
|
|
30
|
+
else:
|
|
31
|
+
pipeline = KolmoXPipeline()
|
|
32
|
+
compressed = pipeline.compress_bytes(raw_data, filename=in_p.name)
|
|
33
|
+
out_p.write_bytes(compressed)
|
|
34
|
+
|
|
35
|
+
if not quiet:
|
|
36
|
+
print(f"Compressed {input_path} -> {output_path}")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def auto_decompress(
|
|
40
|
+
input_path: str, output_path: str, workers: int = 4, quiet: bool = False
|
|
41
|
+
):
|
|
42
|
+
in_p = Path(input_path)
|
|
43
|
+
out_p = Path(output_path)
|
|
44
|
+
|
|
45
|
+
data = in_p.read_bytes()
|
|
46
|
+
|
|
47
|
+
# Riconoscimento formato KMX2 / KolmoXPipeline standard
|
|
48
|
+
if data.startswith(KMX2_MAGIC) or data.startswith(b"KMX1"):
|
|
49
|
+
pipeline = KolmoXPipeline()
|
|
50
|
+
restored = pipeline.decompress_bytes(data)
|
|
51
|
+
out_p.write_bytes(restored)
|
|
52
|
+
else:
|
|
53
|
+
# Fallback su chunked container multi-thread
|
|
54
|
+
ChunkedPipelineEngine.decompress_large_file(
|
|
55
|
+
input_path, output_path, max_workers=workers
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if not quiet:
|
|
59
|
+
print(f"Decompressed {input_path} -> {output_path}")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def main():
|
|
63
|
+
parser = argparse.ArgumentParser(
|
|
64
|
+
prog="kolmox", description="KolmoX Advanced Compression CLI"
|
|
65
|
+
)
|
|
66
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
67
|
+
|
|
68
|
+
# Compress
|
|
69
|
+
p_comp = subparsers.add_parser("compress", help="Compress a file")
|
|
70
|
+
p_comp.add_argument("input", type=str, help="Input file path")
|
|
71
|
+
p_comp.add_argument("output", type=str, help="Output .kmx file path")
|
|
72
|
+
p_comp.add_argument(
|
|
73
|
+
"--chunked", action="store_true", help="Force chunked multi-threaded mode"
|
|
74
|
+
)
|
|
75
|
+
p_comp.add_argument(
|
|
76
|
+
"-w", "--workers", type=int, default=4, help="Worker threads"
|
|
77
|
+
)
|
|
78
|
+
p_comp.add_argument(
|
|
79
|
+
"-q", "--quiet", action="store_true", help="Suppress output"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Decompress
|
|
83
|
+
p_decomp = subparsers.add_parser("decompress", help="Decompress a file")
|
|
84
|
+
p_decomp.add_argument("input", type=str, help="Input .kmx file path")
|
|
85
|
+
p_decomp.add_argument("output", type=str, help="Output restored file path")
|
|
86
|
+
p_decomp.add_argument(
|
|
87
|
+
"-w", "--workers", type=int, default=4, help="Worker threads"
|
|
88
|
+
)
|
|
89
|
+
p_decomp.add_argument(
|
|
90
|
+
"-q", "--quiet", action="store_true", help="Suppress output"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
args = parser.parse_args()
|
|
94
|
+
|
|
95
|
+
if args.command == "compress":
|
|
96
|
+
auto_compress(
|
|
97
|
+
args.input,
|
|
98
|
+
args.output,
|
|
99
|
+
chunked=args.chunked,
|
|
100
|
+
workers=args.workers,
|
|
101
|
+
quiet=args.quiet,
|
|
102
|
+
)
|
|
103
|
+
elif args.command == "decompress":
|
|
104
|
+
auto_decompress(
|
|
105
|
+
args.input, args.output, workers=args.workers, quiet=args.quiet
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""
|
|
2
|
+
KolmoX - Parallel Chunked Processing Engine (Phase 2)
|
|
3
|
+
Handles high-throughput multi-core compression for large datasets.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import concurrent.futures
|
|
7
|
+
import os
|
|
8
|
+
import struct
|
|
9
|
+
import zlib
|
|
10
|
+
from typing import List, Tuple
|
|
11
|
+
from kolmox.core.pipeline import KolmoXPipeline
|
|
12
|
+
|
|
13
|
+
# Magic header for KolmoX Chunked Container V2: "KMX2"
|
|
14
|
+
CHUNKED_MAGIC = b"KMX2"
|
|
15
|
+
DEFAULT_CHUNK_SIZE = 16 * 1024 * 1024 # 16 MB per block
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _compress_chunk_worker(args: Tuple[bytes, int]) -> Tuple[bytes, int, int]:
|
|
19
|
+
raw_chunk, level = args
|
|
20
|
+
crc32_val = zlib.crc32(raw_chunk)
|
|
21
|
+
pipeline = KolmoXPipeline(compression_level=level)
|
|
22
|
+
compressed = pipeline.compress_bytes(raw_chunk)
|
|
23
|
+
return compressed, len(raw_chunk), crc32_val
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _decompress_chunk_worker(compressed_chunk: bytes) -> bytes:
|
|
27
|
+
pipeline = KolmoXPipeline()
|
|
28
|
+
return pipeline.decompress_bytes(compressed_chunk)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ChunkedPipelineEngine:
|
|
32
|
+
@staticmethod
|
|
33
|
+
def compress_large_file(
|
|
34
|
+
input_path: str,
|
|
35
|
+
output_path: str,
|
|
36
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
37
|
+
level: int = 19,
|
|
38
|
+
max_workers: int = None
|
|
39
|
+
) -> Tuple[int, int]:
|
|
40
|
+
file_size = os.path.getsize(input_path)
|
|
41
|
+
if max_workers is None:
|
|
42
|
+
max_workers = min(os.cpu_count() or 4, 16)
|
|
43
|
+
|
|
44
|
+
chunks: List[bytes] = []
|
|
45
|
+
with open(input_path, "rb") as f:
|
|
46
|
+
while True:
|
|
47
|
+
chunk = f.read(chunk_size)
|
|
48
|
+
if not chunk:
|
|
49
|
+
break
|
|
50
|
+
chunks.append(chunk)
|
|
51
|
+
|
|
52
|
+
total_chunks = len(chunks)
|
|
53
|
+
worker_args = [(c, level) for c in chunks]
|
|
54
|
+
|
|
55
|
+
# Parallel compression over ProcessPool
|
|
56
|
+
with concurrent.futures.ProcessPoolExecutor(max_workers=max_workers) as executor:
|
|
57
|
+
results = list(executor.map(_compress_chunk_worker, worker_args))
|
|
58
|
+
|
|
59
|
+
# Build Container Manifest V2:
|
|
60
|
+
# [4B Magic: KMX2][4B ChunkCount]
|
|
61
|
+
# Repeated per chunk: [4B CompressedLen][4B OrigLen][4B CRC32]
|
|
62
|
+
# Followed by contiguous compressed payloads.
|
|
63
|
+
header = bytearray(CHUNKED_MAGIC)
|
|
64
|
+
header.extend(struct.pack(">I", total_chunks))
|
|
65
|
+
|
|
66
|
+
for compressed_bytes, orig_len, crc_val in results:
|
|
67
|
+
header.extend(struct.pack(">III", len(compressed_bytes), orig_len, crc_val))
|
|
68
|
+
|
|
69
|
+
with open(output_path, "wb") as out_f:
|
|
70
|
+
out_f.write(header)
|
|
71
|
+
for compressed_bytes, _, _ in results:
|
|
72
|
+
out_f.write(compressed_bytes)
|
|
73
|
+
|
|
74
|
+
compressed_size = os.path.getsize(output_path)
|
|
75
|
+
return file_size, compressed_size
|
|
76
|
+
|
|
77
|
+
@staticmethod
|
|
78
|
+
def decompress_large_file(
|
|
79
|
+
input_path: str,
|
|
80
|
+
output_path: str,
|
|
81
|
+
max_workers: int = None
|
|
82
|
+
) -> int:
|
|
83
|
+
if max_workers is None:
|
|
84
|
+
max_workers = min(os.cpu_count() or 4, 16)
|
|
85
|
+
|
|
86
|
+
with open(input_path, "rb") as in_f:
|
|
87
|
+
magic = in_f.read(4)
|
|
88
|
+
if magic != CHUNKED_MAGIC:
|
|
89
|
+
raise ValueError("Invalid KolmoX Chunked V2 container format.")
|
|
90
|
+
|
|
91
|
+
total_chunks = struct.unpack(">I", in_f.read(4))[0]
|
|
92
|
+
manifest: List[Tuple[int, int, int]] = []
|
|
93
|
+
for _ in range(total_chunks):
|
|
94
|
+
comp_len, orig_len, crc_val = struct.unpack(">III", in_f.read(12))
|
|
95
|
+
manifest.append((comp_len, orig_len, crc_val))
|
|
96
|
+
|
|
97
|
+
compressed_chunks: List[bytes] = []
|
|
98
|
+
for comp_len, _, _ in manifest:
|
|
99
|
+
compressed_chunks.append(in_f.read(comp_len))
|
|
100
|
+
|
|
101
|
+
# Parallel decompression
|
|
102
|
+
with concurrent.futures.ProcessPoolExecutor(max_workers=max_workers) as executor:
|
|
103
|
+
restored_chunks = list(executor.map(_decompress_chunk_worker, compressed_chunks))
|
|
104
|
+
|
|
105
|
+
# Integrity verification & sequential output write
|
|
106
|
+
total_restored = 0
|
|
107
|
+
with open(output_path, "wb") as out_f:
|
|
108
|
+
for i, chunk_bytes in enumerate(restored_chunks):
|
|
109
|
+
expected_len = manifest[i][1]
|
|
110
|
+
expected_crc = manifest[i][2]
|
|
111
|
+
actual_crc = zlib.crc32(chunk_bytes)
|
|
112
|
+
|
|
113
|
+
if len(chunk_bytes) != expected_len or actual_crc != expected_crc:
|
|
114
|
+
raise ValueError(f"Integrity check failed on block {i} (CRC32 mismatch).")
|
|
115
|
+
|
|
116
|
+
out_f.write(chunk_bytes)
|
|
117
|
+
total_restored += len(chunk_bytes)
|
|
118
|
+
|
|
119
|
+
return total_restored
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""
|
|
2
|
+
KolmoX - Multi-Block Manager with Columnar & Tabular Awareness
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import List, Tuple
|
|
6
|
+
import struct
|
|
7
|
+
import zstandard as zstd
|
|
8
|
+
from kolmox.synthesizer.engine import SynthesisEngine
|
|
9
|
+
from kolmox.core.delta import DeltaEngine
|
|
10
|
+
from kolmox.core.stride import StrideEngine
|
|
11
|
+
from kolmox.core.text_columnar import TextColumnarEngine
|
|
12
|
+
from kolmox.sandbox.runner import SandboxRunner
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BlockCompressor:
|
|
16
|
+
def __init__(self, delta_level: int = 19):
|
|
17
|
+
self.delta_level = delta_level
|
|
18
|
+
self.delta_engine = DeltaEngine(compression_level=delta_level)
|
|
19
|
+
self.synth_engine = SynthesisEngine()
|
|
20
|
+
self.runner = SandboxRunner()
|
|
21
|
+
self.cctx = zstd.ZstdCompressor(level=delta_level)
|
|
22
|
+
self.dctx = zstd.ZstdDecompressor()
|
|
23
|
+
|
|
24
|
+
def compress_block(self, block_data: bytes) -> bytes:
|
|
25
|
+
orig_len = len(block_data)
|
|
26
|
+
direct_zstd = self.cctx.compress(block_data)
|
|
27
|
+
|
|
28
|
+
# 1. Text / CSV Columnar Check
|
|
29
|
+
is_tabular, sep = TextColumnarEngine.is_tabular_text(block_data)
|
|
30
|
+
if is_tabular:
|
|
31
|
+
try:
|
|
32
|
+
hdr, payload = TextColumnarEngine.transpose_text(block_data, sep)
|
|
33
|
+
# Verify round-trip accuracy
|
|
34
|
+
rebuilt = TextColumnarEngine.untranspose_text(hdr, payload, sep)
|
|
35
|
+
if rebuilt == block_data:
|
|
36
|
+
sep_byte = sep.encode("utf-8")[0]
|
|
37
|
+
hdr_len = len(hdr)
|
|
38
|
+
comp_payload = self.cctx.compress(payload)
|
|
39
|
+
text_cand = struct.pack(">BIII", 3, hdr_len, orig_len, sep_byte) + hdr + comp_payload
|
|
40
|
+
if len(text_cand) < len(direct_zstd):
|
|
41
|
+
return text_cand
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
# 2. Binary Stride Check
|
|
46
|
+
stride = StrideEngine.detect_stride(block_data)
|
|
47
|
+
data_to_encode = block_data
|
|
48
|
+
if stride:
|
|
49
|
+
data_to_encode = StrideEngine.transpose(block_data, stride)
|
|
50
|
+
transposed_zstd = self.cctx.compress(data_to_encode)
|
|
51
|
+
if len(transposed_zstd) + 2 < len(direct_zstd):
|
|
52
|
+
return struct.pack(">BIII", 2, 0, orig_len, stride) + transposed_zstd
|
|
53
|
+
|
|
54
|
+
# 3. Generative Synthesis Attempt
|
|
55
|
+
try:
|
|
56
|
+
script = self.synth_engine.synthesize(data_to_encode)
|
|
57
|
+
reconstructed = self.runner.execute(script)
|
|
58
|
+
residual = self.delta_engine.compute_residual(data_to_encode, reconstructed)
|
|
59
|
+
|
|
60
|
+
script_bytes = script.encode("utf-8")
|
|
61
|
+
s_val = stride if stride else 0
|
|
62
|
+
gen_payload = struct.pack(">BIII", 1, len(script_bytes), orig_len, s_val) + script_bytes + residual
|
|
63
|
+
|
|
64
|
+
if len(gen_payload) < len(direct_zstd):
|
|
65
|
+
return gen_payload
|
|
66
|
+
except Exception:
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
# Mode 0: Raw fallback
|
|
70
|
+
return struct.pack(">BIII", 0, 0, orig_len, 0) + direct_zstd
|
|
71
|
+
|
|
72
|
+
def decompress_block(self, block_payload: bytes) -> Tuple[bytes, int]:
|
|
73
|
+
mode, extra_len, orig_len, aux_val = struct.unpack(">BIII", block_payload[:13])
|
|
74
|
+
|
|
75
|
+
if mode == 0: # Direct Fallback
|
|
76
|
+
decompressed = self.dctx.decompress(block_payload[13:], max_output_size=orig_len)
|
|
77
|
+
return decompressed, len(block_payload)
|
|
78
|
+
|
|
79
|
+
if mode == 3: # Text Columnar
|
|
80
|
+
sep = chr(aux_val)
|
|
81
|
+
hdr_end = 13 + extra_len
|
|
82
|
+
hdr = block_payload[13:hdr_end]
|
|
83
|
+
payload = self.dctx.decompress(block_payload[hdr_end:])
|
|
84
|
+
restored = TextColumnarEngine.untranspose_text(hdr, payload, sep)
|
|
85
|
+
return restored, len(block_payload)
|
|
86
|
+
|
|
87
|
+
if mode == 2: # Binary Transposed
|
|
88
|
+
stride = aux_val
|
|
89
|
+
decomp = self.dctx.decompress(block_payload[13:])
|
|
90
|
+
restored = StrideEngine.untranspose(decomp, stride, orig_len)
|
|
91
|
+
return restored, len(block_payload)
|
|
92
|
+
|
|
93
|
+
# Mode 1: Generative Mode
|
|
94
|
+
script_len = extra_len
|
|
95
|
+
stride = aux_val
|
|
96
|
+
script_end = 13 + script_len
|
|
97
|
+
script_source = block_payload[13:script_end].decode("utf-8")
|
|
98
|
+
residual_data = block_payload[script_end:]
|
|
99
|
+
|
|
100
|
+
reconstructed = self.runner.execute(script_source)
|
|
101
|
+
restored = self.delta_engine.apply_residual(reconstructed, residual_data)
|
|
102
|
+
|
|
103
|
+
if stride > 0:
|
|
104
|
+
restored = StrideEngine.untranspose(restored, stride, orig_len)
|
|
105
|
+
|
|
106
|
+
return restored, len(block_payload)
|