#[non_exhaustive]pub enum ContrastiveDataError {
Show 36 variants
MalformedRow {
split: String,
index: usize,
reason: String,
},
InvalidUtf8 {
split: String,
index: usize,
},
EmptyInput {
split: String,
index: usize,
},
UnknownLabel {
split: String,
index: usize,
label: usize,
},
LabelTextMismatch {
split: String,
index: usize,
label: usize,
expected_text: String,
got_text: String,
},
InvalidClassCounts {
split: String,
expected: Vec<usize>,
got: Vec<usize>,
},
DeclaredLabelMapMismatch {
split: String,
shared: Vec<String>,
got: Vec<String>,
},
DuplicateId {
split: String,
id: String,
},
ConflictingSourceRole {
declared: String,
embedded: String,
},
SplitRoleMismatch {
expected_role: String,
embedded_role: String,
},
RowHashMismatch {
id: String,
expected: String,
got: String,
},
CrossSplitDuplicateUnderflow {
class_label: usize,
pool: usize,
shots: usize,
},
InvalidShots {
got: usize,
allowed: &'static str,
},
SemanticHashMismatch {
expected: String,
got: String,
},
SelectionReplayMismatch {
field: String,
},
EndpointNotInSelection {
id: String,
found_in: String,
},
ProfileMismatch {
expected: String,
got: String,
},
MissingSplit {
role: String,
},
SplitHashMismatch {
split: String,
expected: String,
got: String,
},
FingerprintMismatch {
expected: String,
got: String,
},
ExclusionRecordMismatch {
expected: String,
got: String,
},
SelfPair {
id: u64,
},
NoPairCapacity {
positive_capacity: u64,
negative_capacity: u64,
},
ZeroBudget,
ZeroHardCap,
BudgetExceedsHardCap {
budget: u64,
hard_cap: u64,
},
BudgetExceedsCapacity {
budget: u64,
capacity: u64,
},
OrdinalOutOfRange {
ordinal: u64,
budget: u64,
},
PairTargetMismatch {
lo: String,
hi: String,
declared_target: f32,
derived_target: f32,
},
UnsupportedSchemaVersion {
field: String,
got: u32,
supported: u32,
},
UnsupportedNormalizationVersion {
got: String,
supported: &'static str,
},
UnsupportedPolicyVersion {
policy: String,
got: u32,
supported: u32,
},
UnsupportedAlgorithmVersion {
got: u32,
supported: u32,
},
ArithmeticOverflow {
operation: String,
},
Serialization {
context: String,
detail: String,
},
Io {
context: String,
detail: String,
},
}Expand description
Every way the contrastive data protocol can refuse to proceed.
Grouped below by the boundary that raises them: split ingest, selection and manifest, dataset attestation, pair construction, and version/arithmetic/plumbing.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MalformedRow
A JSONL row did not parse, or parsed into something the schema rejects.
Fields
InvalidUtf8
A row’s bytes are not valid UTF-8, so they were never parsed.
Fields
EmptyInput
A row’s input field is empty or whitespace-only.
Fields
UnknownLabel
A row’s numeric label is outside the declared label map.
Fields
LabelTextMismatch
A row’s label_text disagrees with label_names[label].
This is a distinct failure from Self::UnknownLabel: the numeric label is in
range, but the human-readable text contradicts it, which is exactly what a
tampered or hand-edited mirror looks like.
Fields
InvalidClassCounts
The per-class row counts of a split do not match the declaration.
Fields
DeclaredLabelMapMismatch
A per-split label map disagrees with the declaration’s shared label map.
The declaration carries one label map per split AND a shared one. Rows are
validated against the per-split map, while the shared map is what reaches the
fingerprint, the stored map and SelectionPayload::label_names. If the two
disagree, every row validates and the manifest still commits a map that
contradicts them, so the disagreement must be refused before any row is read.
Fields
The shared label map the manifest would commit.
DuplicateId
The same row identifier appears twice inside one split.
Fields
ConflictingSourceRole
A dataset profile declared by the caller conflicts with the one in the bytes.
Fields
SplitRoleMismatch
A row’s embedded source_split is not the role being constructed.
The typestate makes leakage inexpressible for a library caller; this variant is
what stops honest-looking bytes from object storage becoming a Split<Train> the
compiler is perfectly happy with (D-16).
Fields
RowHashMismatch
A row’s recomputed content hash disagrees with the attested one.
Fields
CrossSplitDuplicateUnderflow
Cross-split duplicate exclusion shrank a class pool below shots_per_class.
Duplicate content is never fatal at prepare time (D-18, upheld verbatim by D-27) — it is excluded and recorded. This variant is the one real failure: after exclusion the pool can no longer supply the requested shots.
Fields
InvalidShots
shots_per_class is not one of the contracted values.
Checked BEFORE any RNG draw, so an invalid request never consumes an ordinal and never produces a partially built selection.
Fields
SemanticHashMismatch
A selection manifest’s recorded semantic_hash does not match its payload.
Fields
SelectionReplayMismatch
Replaying a selection from its manifest did not reproduce the manifest.
EndpointNotInSelection
A pair endpoint names an identifier that is not in the selection.
This is D-27’s fail-closed span check for untrusted, replayed pair bytes.
Fields
ProfileMismatch
The attested dataset profile is not the one the consumer asked for.
MissingSplit
The attestation names a split role for which no bytes were supplied.
SplitHashMismatch
A split’s recomputed JSONL digest disagrees with the attested one.
Fields
FingerprintMismatch
The recomputed dataset fingerprint disagrees with the attested one.
Fields
ExclusionRecordMismatch
The recomputed cross-split exclusion record disagrees with the attested one.
Fields
SelfPair
A pair was requested whose two endpoints are the same selected ordinal.
D-12: unreachable through the sampler, because CanonicalPair::new is the sole
constructor and it rejects equal endpoints. It IS reachable through the untrusted
pair-ingest boundary, which is why the variant exists.
NoPairCapacity
The layout admits no pairs of either kind.
Fields
ZeroBudget
An effective pair budget of zero was resolved or requested.
ZeroHardCap
A pair hard cap of zero was configured.
Distinct from Self::ZeroBudget: a zero cap means no budget can ever be
satisfied, which is a configuration defect rather than a request defect.
BudgetExceedsHardCap
An explicit budget above the configured hard cap.
This FAILS rather than silently clamping: the cap exists for DoS control, and a
user who typed a larger number deserves to be told it was refused, not to receive
a quietly different dataset (budget_resolution).
BudgetExceedsCapacity
A budget exceeding the available UNIQUE pair capacity (D-11).
Reserved for the unique-capacity check. The oversampling strategy draws with
replacement, so budget > capacity is not an error there.
Fields
OrdinalOutOfRange
A pair was requested at an ordinal at or beyond the resolved budget.
PairTargetMismatch
A replayed pair record’s target disagrees with its endpoints’ classes.
The 1.0/0.0 target is DERIVED from endpoint classes at emission and is never accepted from caller input; this variant is how that is enforced for bytes that claim otherwise.
Fields
UnsupportedSchemaVersion
A serialized artifact declares a schema version this build does not support.
Fields
UnsupportedNormalizationVersion
An artifact was produced under a content-normalization pipeline this build does not implement.
Distinct from Self::UnsupportedSchemaVersion because the normalization version
is a STRING tag rather than an integer, and because it changes what the exclusion
record MEANS rather than what the artifact’s fields are. Silently accepting a
foreign tag would let an exclusion record computed under different collapsing rules
be replayed as if it had been computed under these ones (D-17: the normalization is
contracted and versioned so it cannot drift).
UnsupportedPolicyVersion
A versioned policy enum value this build does not implement.
Fields
UnsupportedAlgorithmVersion
A sampling-algorithm version this build does not implement.
Separate from Self::UnsupportedPolicyVersion because changing the algorithm
changes pair IDENTITIES, whereas changing a policy changes which pairs are legal.
ArithmeticOverflow
A capacity or budget computation overflowed.
Every step of the closed-form capacity math uses checked arithmetic, so a large class layout produces this typed error instead of a wrapped, plausible-looking capacity that would then silently under-sample.
Serialization
Canonical serialization or deserialization of an artifact failed.
Fields
Io
A caller-supplied sink or source failed.
The crate performs NO filesystem or network access (D-04). This variant exists
only so dump_pairs<W: Write> can surface the caller’s own writer failure as a
typed error rather than swallowing it.
Trait Implementations§
Source§impl Clone for ContrastiveDataError
impl Clone for ContrastiveDataError
Source§impl Debug for ContrastiveDataError
impl Debug for ContrastiveDataError
Source§impl Display for ContrastiveDataError
impl Display for ContrastiveDataError
Source§impl Error for ContrastiveDataError
impl Error for ContrastiveDataError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()