Expand description
Canonical event schema and normalization contract for conformance testing.
This module formally defines which fields in conformance events are semantic (must match across runtimes), transport (non-deterministic noise that must be normalized before comparison), or derived (computed from other fields and ignored during comparison).
§Schema version
The schema is versioned so that changes to normalization rules can be tracked. Fixtures and baselines record which schema version they were generated against.
§Usage
ⓘ
use pi::conformance::normalization::*;
let contract = NormalizationContract::default();
let ctx = NormalizationContext::from_cwd(std::path::Path::new("/tmp"));
let mut event: serde_json::Value = serde_json::from_str(raw_line)?;
contract.normalize(&mut event, &ctx);Structs§
- Field
Rule - Describes a single field’s normalization rule.
- Normalization
Context - Environment-specific values needed for path canonicalization.
- Normalization
Contract - The canonical normalization contract.
- String
Rewrite Rule - Describes a string-level rewrite applied to all string values.
Enums§
- Field
Classification - How a conformance event field is treated during comparison.
Constants§
- PLACEHOLDER_
ARTIFACT_ ID - PLACEHOLDER_
HOST - PLACEHOLDER_
PID - PLACEHOLDER_
PI_ MONO_ ROOT - PLACEHOLDER_
PORT - PLACEHOLDER_
PROJECT_ ROOT - PLACEHOLDER_
RUN_ ID - PLACEHOLDER_
SESSION_ ID - PLACEHOLDER_
SPAN_ ID - PLACEHOLDER_
TIMESTAMP - PLACEHOLDER_
TRACE_ ID - PLACEHOLDER_
UUID - SCHEMA_
VERSION - Current schema version. Bump when normalization rules change.
- UI_
OP_ ALIASES - Known UI operation aliases that map to a canonical name.
Functions§
- canonicalize_
json_ keys - Sort JSON object keys recursively for stable serialization.
- canonicalize_
op_ name - Resolve an operation name to its canonical form.
- is_
path_ key - Returns
trueifkeynames a JSON field whose values are filesystem paths (e.g.promptPaths,filePath,cwd). - normalize_
string - Normalize a string value: strip ANSI, rewrite paths, replace UUIDs/run-IDs/ports.
- normalize_
value - Normalize a JSON value in-place according to the canonical rules.
- path_
suffix_ match - Path-aware suffix match for conformance assertions.