Expand description
Event format validation and hardening.
Three validation levels:
- Line syntax — TSJSON shape (8 tab-separated fields), valid UTF-8,
event_hashmatches recomputed BLAKE3 hash of fields 1–7. - Schema validation — Typed payload deserialization per event type. Unknown fields are preserved (forward compatible). Unknown event types produce warnings, not errors.
- Semantic validation — Enum constraint checks (kind, urgency, size, state values), item ID format, link target format.
§Shard-level checks
- Verifies Merkle hash chains against shard manifests.
- Detects truncated event files (incomplete trailing lines).
- Preserves valid events before a corrupt line in the report.
§Usage
use std::path::Path;
use bones_core::event::validate::{validate_shard, validate_all};
// Validate a single shard file
let report = validate_shard(Path::new(".bones/events/2026-01.events"), None);
println!("passed: {}, failed: {}", report.passed, report.failed);
for err in &report.errors {
println!(" line {}: {:?} — {}", err.line_num, err.kind, err.message);
}
// Validate all shards in a directory
let reports = validate_all(Path::new(".bones/events"));Structs§
- Validation
Error - Details about a single validation failure.
- Validation
Report - Summary report from validating an entire shard.
Enums§
- Validation
Error Kind - Category of validation failure.
Constants§
- MAX_
PAYLOAD_ BYTES - Maximum allowed size (in bytes) for the JSON data field of a single event.
Functions§
- validate_
all - Validate all shard files (
*.events) in an events directory. - validate_
event - Validate a single TSJSON event line.
- validate_
shard - Validate an entire shard file.