Rust Build and Packaging
Source and package versions
One AIWAF repository.
Python: py/aiwaf/ · Node.js: js/ · Rust/WASM: rust/ · Java: java/.
Source and canonical README.
Versions shown describe the source checkout; package releases are independent.
Current Python/Node source targets are aiwaf 1.1.8 (Python) and
aiwaf 1.1.5 (npm), with Rust/Python 0.2.7 and
WASM 0.2.5 and Java 1.3.5. Sandbox guides retain their separately pinned builds.
How AIWAF works: system architecture
Native Python build
Run these commands in a virtual environment from the monorepo root. Stage the canonical README and LICENSE before changing directory:
cp README.md rust/README.md
cp LICENSE rust/LICENSE
cp NOTICE rust/NOTICE
cp -R licenses rust/
python -m pip install maturin
cd rust
maturin develop
cd ..
pytest -q rust/tests/test_python_api.py
PowerShell users can stage the assets with Copy-Item README.md rust/README.md, Copy-Item LICENSE rust/LICENSE, Copy-Item NOTICE rust/NOTICE, and Copy-Item -Recurse licenses rust/. These generated package-local assets are ignored by Git.
Rust core and WASM
cargo test --manifest-path rust/Cargo.toml --locked -p aiwaf_core
cd rust/crates/aiwaf_wasm
wasm-pack test --node
wasm-pack build --release --target bundler
cd ../..
python scripts/patch_wasm_pkg.py
cp ../LICENSE crates/aiwaf_wasm/pkg/LICENSE
cp ../NOTICE crates/aiwaf_wasm/pkg/NOTICE
cp -R ../licenses crates/aiwaf_wasm/pkg/
The metadata script also stages LICENSE, NOTICE, and licenses/. The explicit copy commands above produce the same assets. PowerShell can use Copy-Item for files and Copy-Item -Recurse for directories. Browser applications require a bundler that understands WebAssembly assets; initialize the WASM module before calling its exports.
Release manifests
The Rust/Python source candidate is 0.2.3; WASM remains 0.2.2. They use independent releases under ELv2. Source versions do not establish registry availability.
- PyPI:
rust/pyproject.tomlandrust/Cargo.toml,rust-v0.2.3,rust-publish.yml. - npm:
rust/crates/aiwaf_wasm/Cargo.toml,wasm-v0.2.2,wasm-publish.yml. - PyO3 uses ABI3 wheels for Python 3.8 and newer, exporting
aiwaf_rust.
Verification
Confirm import aiwaf_rust works in the interpreter used by the application. Validate model round trips through fit, to_json, from_json, and predict. Python selects available Rust capabilities automatically and falls back when unavailable. WASM performance depends on batch size and conversion cost.
CSV validation and performance
# From the monorepo root, with the matching installed extension:
python scripts/check_native_csv_runtime.py
python scripts/check_csv_release_concurrency.py
python scripts/benchmark_native_training_boundary.py
python scripts/benchmark_native_csv_training.py
python scripts/benchmark_native_csv_workloads.py
python scripts/benchmark_csv_request_reuse.py
python scripts/profile_csv_logging.py
The preflight checks module locations, enabled flags, required capabilities, and temporary-file round trips without touching application data. Native snapshot caching and cached log handles are bounded. Closing writers matters before Windows log-directory deletion.
Three alternating runs on 10,000 synthetic records measured Apache timestamp speedups of 4.57x on Windows and 3.65x on WSL. Retained features plus a 20-tree Rust fit/predict boundary measured 1.55x and 1.35x. Native ISO parsing was slower on both, so it remains optional. An offline Windows Flask IP/keyword + CSV logging workload measured 5.95 ms native versus 9.18 ms Python. These are scoped measurements, not deployed throughput or complete training speedups.
Release validation includes quoting/gzip, timestamp fallback, seeded model parity, chunk equivalence, concurrent mutations, no-op writes, rotation/truncation, and writer reopening. The Linux four-process smoke check retained 160 log rows and 80 blocklist entries. Production load and the full platform/framework matrix still require deployment-specific checks.
Publish the Rust dependency before Python releases requiring it. Python release CI can build the matching extension locally for tests; its publication job checks that a compatible dependency is available on PyPI. Local test wheels stay separate from Python release artifacts.
Native pipeline release and validation
Release candidate: this page documents Python 1.1.8 and Rust/Python 0.2.7 in the current source checkout. Source versions do not establish registry availability. Python 1.1.8 requires aiwaf-rust>=0.2.7; framework dependencies remain extras.
Build/test NativeCSVPipeline and NativePipelineRequest in the installed wheel, not just the source extension. Run rust/tests/test_python_api.py and rust/tests/test_csv_pipeline_api.py. Publish the native wheels before the Python package that requires them.
Full benchmark method, measurements and deployment tradeoffs.
