Swarm: Testing & Quality
Test Files
This project uses separate integration test files in tests/. Run specific tests:
cargo test --test <test_file_name>
Workflow
- Check current test coverage in
tests/directory - Identify properties to test (invariants, roundtrips, bounds)
- Add
proptestdependency toCargo.toml - Create new test file in
tests/with property tests - Set up
fuzz/directory with cargo-fuzz targets - Add edge case tests to separate test files
- Run validation gates
Key Properties to Test
HVec10240
from_bytes(to_bytes(v)) == v(roundtrip)cosine_similarity(v, v) == 1.0(self-similarity)cosine_similarity(a, b) == cosine_similarity(b, a)(symmetry)cosine_similarity(a, b)in[-1.0, 1.0](bounds)
Reservoir
reset()clears state to zerosstep()with same input produces same output afterreset()to_hypervector()fails ifsize < 10240
Persistence
save_concept(c); load_concept(c.id) == Some(c)(roundtrip)delete_concept(id); load_concept(id) == None(deletion)- FK constraints reject invalid associations
Commands
# Run property tests
cargo test --test <test_name>
# Run fuzzer (requires cargo-fuzz)
cargo fuzz run fuzz_hvec_from_bytes
LOC Constraint
All files must remain ≤ 500 lines. Create new test files rather than inflating existing ones.