zipora 2.1.2

High-performance Rust implementation providing advanced data structures and compression algorithms with memory safety guarantees. Features LRU page cache, sophisticated caching layer, fiber-based concurrency, real-time compression, secure memory pools, SIMD optimizations, and complete C FFI for migration from C++.
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# Zipora Project Makefile
# Comprehensive build and test automation for debug/release modes with feature management
#
# Features:
# - Stable features: simd, mmap, zstd, lz4, serde, ffi  
# - Nightly features: avx512
#
# Usage:
#   make         # Build and test everything (stable features only)
#   make all     # Same as default
#   make build   # Build debug + release (stable features)
#   make test    # Test debug + release (stable features) 
#   make build_nightly  # Build with all features including nightly
#   make test_nightly   # Test with all features including nightly

.PHONY: all build test build_nightly test_nightly clean help
.PHONY: build_debug build_release build_nightly_debug build_nightly_release
.PHONY: test_debug test_release test_nightly_debug test_nightly_release  
.PHONY: bench bench_fsa bench_serialization bench_io bench_all bench_all_nightly
.PHONY: bench_release bench_nightly test_simd_base64 test_simd_base64_nightly
.PHONY: safety_tests miri_tests miri_full format clippy doc

# =============================================================================
# CONFIGURATION
# =============================================================================

# Feature sets
STABLE_FEATURES := --features simd,mmap,zstd,lz4,serde,ffi
NIGHTLY_FEATURES := --features simd,mmap,zstd,lz4,serde,ffi,avx512
ALL_FEATURES := --all-features

# Cargo commands
CARGO := cargo
CARGO_NIGHTLY := cargo +nightly
CARGO_MIRI := cargo +nightly miri

# Test exclusions
EXCLUDE_BENCH_TESTS := --exclude-from-test '*bench*'

# =============================================================================
# DEFAULT TARGET
# =============================================================================

# Default: build and test everything with stable features
all: build test
	@echo ""
	@echo "๐ŸŽ‰ All build and test targets completed successfully!"
	@echo ""
	@echo "๐Ÿ“Š Summary:"
	@echo "  โœ… Debug build (stable features)"
	@echo "  โœ… Release build (stable features)"  
	@echo "  โœ… Debug tests (stable features, no benchmarks)"
	@echo "  โœ… Release tests (stable features, with SIMD Base64 tests and benchmarks)"
	@echo ""
	@echo "๐Ÿ’ก Available targets:"
	@echo "    make bench_all           # All stable benchmarks"
	@echo "    make bench_all_nightly   # All benchmarks with nightly features"
	@echo "    make test_simd_base64    # SIMD Base64 comprehensive tests"
	@echo "    make test_nightly        # Build and test with nightly features"

# =============================================================================
# BUILD TARGETS
# =============================================================================

# Build both debug and release with stable features
build: build_debug build_release
	@echo "โœ… All stable builds completed"

# Build both debug and release with nightly features  
build_nightly: build_nightly_debug build_nightly_release
	@echo "โœ… All nightly builds completed"

# Individual build targets - Debug mode (stable)
build_debug:
	@echo "๐Ÿ”จ Building debug mode with stable features..."
	$(CARGO) build $(STABLE_FEATURES)
	@echo "โœ… Debug build (stable) completed"

# Individual build targets - Release mode (stable)
build_release:
	@echo "๐Ÿ”จ Building release mode with stable features..."
	$(CARGO) build --release $(STABLE_FEATURES)
	@echo "โœ… Release build (stable) completed"

# Individual build targets - Debug mode (nightly)
build_nightly_debug:
	@echo "๐ŸŒ™ Building debug mode with nightly features..."
	$(CARGO_NIGHTLY) build $(NIGHTLY_FEATURES)
	@echo "โœ… Debug build (nightly) completed"

# Individual build targets - Release mode (nightly)
build_nightly_release:
	@echo "๐ŸŒ™ Building release mode with nightly features..."
	$(CARGO_NIGHTLY) build --release $(NIGHTLY_FEATURES)
	@echo "โœ… Release build (nightly) completed"

# =============================================================================
# TEST TARGETS
# =============================================================================

# Test both debug and release with stable features
test: test_debug test_release
	@echo "โœ… All stable tests completed"

# Test both debug and release with nightly features
test_nightly: test_nightly_debug test_nightly_release
	@echo "โœ… All nightly tests completed"

# Individual test targets - Debug mode (stable, no benchmarks)
test_debug:
	@echo "๐Ÿงช Running debug tests with stable features (excluding benchmarks)..."
	$(CARGO) test $(STABLE_FEATURES) --lib --bins --tests
	@echo "โœ… Debug tests (stable) completed"

# Individual test targets - Release mode (stable, with benchmarks)
test_release:
	@echo "๐Ÿงช Running release tests with stable features (including benchmarks)..."
	$(CARGO) test --release $(STABLE_FEATURES) --lib --bins --tests
	@echo "๐Ÿงช Running SIMD Base64 comprehensive tests..."
	$(CARGO) test --release $(STABLE_FEATURES) --test simd_base64_tests -- --nocapture || echo "โŒ SIMD Base64 tests failed - may require additional setup"
	@echo "๐Ÿงช Running I/O & Serialization performance tests..."
	$(CARGO) test --release $(STABLE_FEATURES) test_stream_performance_comparison -- --nocapture || echo "โŒ I/O performance tests failed - may require additional setup"
	$(CARGO) test --release $(STABLE_FEATURES) test_combined_stream_operations -- --nocapture || echo "โŒ I/O integration tests failed - may require additional setup"
	@echo "๐Ÿงช Running stable benchmarks (excluding avx512_bench and cpp_comparison)..."
	$(CARGO) test --release $(STABLE_FEATURES) --bench benchmark --bench benchmark_rank_select --bench simd_rank_select_bench --bench dictionary_optimization_bench --bench cache_bench --bench secure_memory_pool_bench --bench specialized_containers_bench --bench rank_select_bench --bench compressed_sparse_trie_bench --bench comprehensive_trie_benchmarks --bench double_array_trie_bench --bench nested_louds_trie_bench --bench sortable_str_vec_bench --bench fsa_infrastructure_bench --bench memory_performance --bench memory_pools_bench --bench adaptive_mmap_bench --bench simple_benchmark --bench sortable_str_vec_optimized || echo "โŒ Some benchmarks failed - may require additional setup"
	@echo "โœ… Release tests (stable) completed"

# Individual test targets - Debug mode (nightly, no benchmarks)  
test_nightly_debug:
	@echo "๐ŸŒ™ Running debug tests with nightly features (excluding benchmarks)..."
	$(CARGO_NIGHTLY) test $(NIGHTLY_FEATURES) --lib --bins --tests
	@echo "โœ… Debug tests (nightly) completed"

# Individual test targets - Release mode (nightly, with benchmarks)
test_nightly_release:
	@echo "๐ŸŒ™ Running release tests with nightly features (including benchmarks)..."
	$(CARGO_NIGHTLY) test --release $(NIGHTLY_FEATURES) --lib --bins --tests
	@echo "๐Ÿงช Running SIMD Base64 comprehensive tests with nightly features..."
	$(CARGO_NIGHTLY) test --release $(NIGHTLY_FEATURES) --test simd_base64_tests -- --nocapture || echo "โŒ SIMD Base64 tests failed - may require additional setup"
	@echo "๐Ÿงช Running I/O & Serialization performance tests..."
	$(CARGO_NIGHTLY) test --release $(NIGHTLY_FEATURES) test_stream_performance_comparison -- --nocapture || echo "โŒ I/O performance tests failed - may require additional setup"
	$(CARGO_NIGHTLY) test --release $(NIGHTLY_FEATURES) test_combined_stream_operations -- --nocapture || echo "โŒ I/O integration tests failed - may require additional setup"
	@echo "๐Ÿงช Running nightly benchmarks (including avx512_bench, excluding cpp_comparison)..."
	$(CARGO_NIGHTLY) test --release $(NIGHTLY_FEATURES) --bench benchmark --bench benchmark_rank_select --bench simd_rank_select_bench --bench dictionary_optimization_bench --bench cache_bench --bench avx512_bench --bench secure_memory_pool_bench --bench specialized_containers_bench --bench rank_select_bench --bench compressed_sparse_trie_bench --bench comprehensive_trie_benchmarks --bench double_array_trie_bench --bench nested_louds_trie_bench --bench sortable_str_vec_bench --bench fsa_infrastructure_bench --bench memory_performance --bench memory_pools_bench --bench adaptive_mmap_bench --bench simple_benchmark --bench sortable_str_vec_optimized || echo "โŒ Some benchmarks failed - may require additional setup"
	@echo "โœ… Release tests (nightly) completed"

# =============================================================================
# SPECIALIZED TEST TARGETS
# =============================================================================

# Run benchmarks only
bench:
	@echo "โšก Running benchmarks..."
	$(CARGO) bench $(STABLE_FEATURES)
	@echo "โœ… Benchmarks completed"

# Run FSA infrastructure benchmarks specifically
bench_fsa:
	@echo "โšก Running FSA infrastructure benchmarks..."
	$(CARGO) bench $(STABLE_FEATURES) --bench fsa_infrastructure_bench
	@echo "โœ… FSA benchmarks completed"

# Run I/O & Memory benchmarks specifically  
bench_serialization:
	@echo "โšก Running I/O & Memory benchmarks..."
	$(CARGO) bench --release $(STABLE_FEATURES) --bench memory_performance --bench memory_pools_bench --bench adaptive_mmap_bench
	@echo "โœ… I/O & Memory benchmarks completed"

# Run I/O & Memory performance tests specifically
bench_io:
	@echo "โšก Running I/O & Memory performance tests..."
	$(CARGO) test --release $(STABLE_FEATURES) test_stream_performance_comparison -- --nocapture || echo "โŒ I/O performance tests failed - may require additional setup"
	$(CARGO) test --release $(STABLE_FEATURES) test_combined_stream_operations -- --nocapture || echo "โŒ I/O integration tests failed - may require additional setup"
	$(CARGO) test --release $(STABLE_FEATURES) test_stress_operations -- --nocapture || echo "โŒ I/O stress tests failed - may require additional setup"
	@echo "โšก Running I/O & Memory benchmarks..."
	$(CARGO) bench --release $(STABLE_FEATURES) --bench memory_performance --bench memory_pools_bench --bench adaptive_mmap_bench
	@echo "โœ… I/O performance tests and benchmarks completed"

# Run all benchmarks in release mode
bench_release:
	@echo "โšก Running all benchmarks in release mode..."
	$(CARGO) bench --release $(STABLE_FEATURES)
	@echo "โœ… Release benchmarks completed"

# Run nightly benchmarks with AVX-512
bench_nightly:
	@echo "๐ŸŒ™ Running nightly benchmarks with AVX-512..."
	$(CARGO_NIGHTLY) bench --release $(NIGHTLY_FEATURES)
	@echo "โœ… Nightly benchmarks completed"

# Run all available benchmarks explicitly (comprehensive test)
bench_all:
	@echo "โšก Running all available benchmarks..."
	$(CARGO) bench --release $(STABLE_FEATURES) \
		--bench benchmark \
		--bench benchmark_rank_select \
		--bench simd_rank_select_bench \
		--bench dictionary_optimization_bench \
		--bench cache_bench \
		--bench secure_memory_pool_bench \
		--bench specialized_containers_bench \
		--bench rank_select_bench \
		--bench compressed_sparse_trie_bench \
		--bench comprehensive_trie_benchmarks \
		--bench double_array_trie_bench \
		--bench nested_louds_trie_bench \
		--bench sortable_str_vec_bench \
		--bench fsa_infrastructure_bench \
		--bench memory_performance \
		--bench memory_pools_bench \
		--bench adaptive_mmap_bench \
		--bench simple_benchmark \
		--bench sortable_str_vec_optimized
	@echo "โœ… All stable benchmarks completed"

# Run all available benchmarks including nightly-only ones
bench_all_nightly:
	@echo "๐ŸŒ™ Running all available benchmarks with nightly features..."
	$(CARGO_NIGHTLY) bench --release $(NIGHTLY_FEATURES) \
		--bench benchmark \
		--bench benchmark_rank_select \
		--bench simd_rank_select_bench \
		--bench dictionary_optimization_bench \
		--bench cache_bench \
		--bench avx512_bench \
		--bench secure_memory_pool_bench \
		--bench specialized_containers_bench \
		--bench rank_select_bench \
		--bench compressed_sparse_trie_bench \
		--bench comprehensive_trie_benchmarks \
		--bench double_array_trie_bench \
		--bench nested_louds_trie_bench \
		--bench sortable_str_vec_bench \
		--bench fsa_infrastructure_bench \
		--bench memory_performance \
		--bench memory_pools_bench \
		--bench adaptive_mmap_bench \
		--bench simple_benchmark \
		--bench sortable_str_vec_optimized
	@echo "โœ… All nightly benchmarks completed"

# Run SIMD Base64 tests specifically
test_simd_base64:
	@echo "๐Ÿงช Running SIMD Base64 comprehensive tests..."
	$(CARGO) test --release $(STABLE_FEATURES) --test simd_base64_tests -- --nocapture
	@echo "โœ… SIMD Base64 tests completed"

# Run SIMD Base64 tests with nightly features
test_simd_base64_nightly:
	@echo "๐ŸŒ™ Running SIMD Base64 tests with nightly features..."
	$(CARGO_NIGHTLY) test --release $(NIGHTLY_FEATURES) --test simd_base64_tests -- --nocapture
	@echo "โœ… SIMD Base64 nightly tests completed"

# Run enhanced safety tests
safety_tests:
	@echo "๐Ÿ›ก๏ธ  Running enhanced container safety tests..."
	$(CARGO) test container_safety_tests $(STABLE_FEATURES) -- --nocapture
	$(CARGO) test enhanced_memory_safety $(STABLE_FEATURES) -- --nocapture
	@echo "โœ… Safety tests completed"

# Run Miri memory safety tests
miri_tests:
	@echo "๐Ÿ” Running Miri memory safety tests..."
	@if command -v rustup >/dev/null 2>&1; then \
		if ! rustup toolchain list | grep -q nightly; then \
			echo "๐Ÿ“ฆ Installing nightly toolchain..."; \
			rustup install nightly; \
		fi; \
		if ! rustup component list --toolchain nightly | grep -q "miri.*installed"; then \
			echo "๐Ÿ“ฆ Installing Miri..."; \
			rustup +nightly component add miri; \
		fi; \
		echo "๐Ÿ”ฌ Running enhanced memory safety tests with Miri..."; \
		$(CARGO_MIRI) test enhanced_memory_safety --quiet || \
		$(CARGO_MIRI) test enhanced_memory_safety --verbose; \
		echo "โœ… Miri tests completed"; \
	else \
		echo "โŒ Error: rustup not found. Please install rustup first."; \
		exit 1; \
	fi

# Run full Miri test suite using the script
miri_full:
	@echo "๐Ÿ” Running full Miri test suite..."
	@if [ -x "./run_miri_tests.sh" ]; then \
		./run_miri_tests.sh full; \
	else \
		echo "โŒ Error: run_miri_tests.sh not found or not executable"; \
		exit 1; \
	fi

# =============================================================================
# CODE QUALITY TARGETS
# =============================================================================

# Format code
format:
	@echo "๐ŸŽจ Formatting code..."
	$(CARGO) fmt --all
	@echo "โœ… Code formatting completed"

# Run clippy lints
clippy:
	@echo "๐Ÿ“Ž Running clippy lints..."
	$(CARGO) clippy $(STABLE_FEATURES) --all-targets -- -D warnings
	@echo "โœ… Clippy lints completed"

# Run clippy with nightly features
clippy_nightly:
	@echo "๐ŸŒ™ Running clippy lints with nightly features..."
	$(CARGO_NIGHTLY) clippy $(NIGHTLY_FEATURES) --all-targets -- -D warnings
	@echo "โœ… Clippy lints (nightly) completed"

# Generate documentation
doc:
	@echo "๐Ÿ“š Generating documentation..."
	$(CARGO) doc $(STABLE_FEATURES) --no-deps --open
	@echo "โœ… Documentation generated"

# Generate documentation with nightly features
doc_nightly:
	@echo "๐ŸŒ™ Generating documentation with nightly features..."
	$(CARGO_NIGHTLY) doc $(NIGHTLY_FEATURES) --no-deps --open
	@echo "โœ… Documentation (nightly) generated"

# =============================================================================
# COMPREHENSIVE TARGETS
# =============================================================================

# Full development cycle (stable)
dev: format clippy build test safety_tests
	@echo "๐Ÿš€ Full development cycle completed (stable features)"

# Full development cycle (nightly)
dev_nightly: format clippy_nightly build_nightly test_nightly miri_tests
	@echo "๐Ÿš€ Full development cycle completed (nightly features)"

# Complete validation (everything)
validate: dev dev_nightly doc doc_nightly
	@echo "๐ŸŽฏ Complete validation completed"

# =============================================================================
# MAINTENANCE TARGETS
# =============================================================================

# Clean build artifacts
clean:
	@echo "๐Ÿงน Cleaning build artifacts..."
	$(CARGO) clean
	@echo "๐Ÿงน Cleaning benchmark result files..."
	@rm -f bench_results.txt benchmark_output.txt benchmark_results.txt
	@rm -f benchmark_summary.txt final_bench_results.txt cpp_impl_bench_results.txt
	@rm -f *_bench_results.txt *_benchmark_*.txt
	@echo "๐Ÿงน Cleaning criterion reports..."
	@rm -rf target/criterion
	@echo "โœ… Clean completed"

# Update dependencies
update:
	@echo "๐Ÿ“ฆ Updating dependencies..."
	$(CARGO) update
	@echo "โœ… Dependencies updated"

# Check for outdated dependencies
outdated:
	@echo "๐Ÿ“‹ Checking for outdated dependencies..."
	@if command -v cargo-outdated >/dev/null 2>&1; then \
		$(CARGO) outdated; \
	else \
		echo "๐Ÿ’ก Install cargo-outdated: cargo install cargo-outdated"; \
	fi

# Security audit
audit:
	@echo "๐Ÿ”’ Running security audit..."
	@if command -v cargo-audit >/dev/null 2>&1; then \
		$(CARGO) audit; \
	else \
		echo "๐Ÿ’ก Install cargo-audit: cargo install cargo-audit"; \
	fi

# =============================================================================
# CI/CD TARGETS
# =============================================================================

# CI pipeline (stable features only)
ci: format clippy build test safety_tests
	@echo "๐Ÿค– CI pipeline completed (stable)"

# CI pipeline (nightly features)
ci_nightly: format clippy_nightly build_nightly test_nightly miri_tests
	@echo "๐Ÿค– CI pipeline completed (nightly)"

# Pre-commit hook
pre_commit: format clippy test_debug safety_tests
	@echo "โœ… Pre-commit checks completed"

# Release preparation
release_prep: clean format clippy build_release test_release bench doc audit
	@echo "๐Ÿš€ Release preparation completed"

# pre-commit sanity check
sanity: test_debug test_release test_nightly_debug test_nightly_release 

# =============================================================================
# HELP TARGET
# =============================================================================

help:
	@echo "Zipora Project Makefile"
	@echo "======================="
	@echo ""
	@echo "Main Targets:"
	@echo "  all                    Build and test everything (stable features)"
	@echo "  build                  Build debug + release (stable features)"
	@echo "  test                   Test debug + release (stable features)"
	@echo "  build_nightly          Build debug + release (all features including nightly)"
	@echo "  test_nightly           Test debug + release (all features including nightly)"
	@echo ""
	@echo "Individual Build Targets:"
	@echo "  build_debug            Build debug mode (stable features)"
	@echo "  build_release          Build release mode (stable features)"
	@echo "  build_nightly_debug    Build debug mode (nightly features)"
	@echo "  build_nightly_release  Build release mode (nightly features)"
	@echo ""
	@echo "Individual Test Targets:"
	@echo "  test_debug             Test debug mode (stable, no benchmarks)"
	@echo "  test_release           Test release mode (stable, with stable benchmarks)"
	@echo "  test_nightly_debug     Test debug mode (nightly, no benchmarks)"
	@echo "  test_nightly_release   Test release mode (nightly, with all benchmarks including avx512)"
	@echo ""
	@echo "Specialized Targets:"
	@echo "  bench                  Run benchmarks"
	@echo "  bench_fsa              Run FSA infrastructure benchmarks specifically"
	@echo "  bench_serialization    Run I/O & Memory benchmarks specifically"
	@echo "  bench_io               Run I/O & Memory performance tests specifically"
	@echo "  bench_release          Run all benchmarks in release mode"
	@echo "  bench_nightly          Run nightly benchmarks with AVX-512"
	@echo "  bench_all              Run all available benchmarks explicitly (stable)"
	@echo "  bench_all_nightly      Run all available benchmarks with nightly features"
	@echo "  test_simd_base64       Run SIMD Base64 comprehensive tests (stable)"
	@echo "  test_simd_base64_nightly Run SIMD Base64 tests with nightly features"
	@echo "  safety_tests           Run enhanced container safety tests"
	@echo "  miri_tests             Run Miri memory safety tests"
	@echo "  miri_full              Run full Miri test suite (using script)"
	@echo ""
	@echo "Code Quality:"
	@echo "  format                 Format code with rustfmt"
	@echo "  clippy                 Run clippy lints (stable)"
	@echo "  clippy_nightly         Run clippy lints (nightly)"
	@echo "  doc                    Generate documentation (stable)"
	@echo "  doc_nightly            Generate documentation (nightly)"
	@echo ""
	@echo "Development Workflows:"
	@echo "  dev                    Full development cycle (stable)"
	@echo "  dev_nightly            Full development cycle (nightly)"
	@echo "  validate               Complete validation (everything)"
	@echo ""
	@echo "Maintenance:"
	@echo "  clean                  Clean build artifacts"
	@echo "  update                 Update dependencies"
	@echo "  outdated               Check outdated dependencies"
	@echo "  audit                  Security audit"
	@echo ""
	@echo "CI/CD:"
	@echo "  ci                     CI pipeline (stable)"
	@echo "  ci_nightly             CI pipeline (nightly)"
	@echo "  pre_commit             Pre-commit checks"
	@echo "  release_prep           Release preparation"
	@echo ""
	@echo "Features:"
	@echo "  Stable: simd, mmap, zstd, lz4, serde, ffi"
	@echo "  Nightly: avx512"