Skip to main content

Module normalization

Module normalization 

Source
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§

FieldRule
Describes a single field’s normalization rule.
NormalizationContext
Environment-specific values needed for path canonicalization.
NormalizationContract
The canonical normalization contract.
StringRewriteRule
Describes a string-level rewrite applied to all string values.

Enums§

FieldClassification
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 true if key names 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.