pub struct PreparedDataset<P: DatasetProfile> { /* private fields */ }Expand description
A validated, fingerprinted dataset of exactly one profile.
Implementations§
Source§impl PreparedDataset<Canonical>
impl PreparedDataset<Canonical>
Sourcepub fn from_labeled_rows(
train: Vec<LabeledExample>,
validation: Vec<LabeledExample>,
test: Vec<LabeledExample>,
decls: &CanonicalDeclarations,
ledger: &mut AccessLedger,
) -> Result<Self, ContrastiveDataError>
pub fn from_labeled_rows( train: Vec<LabeledExample>, validation: Vec<LabeledExample>, test: Vec<LabeledExample>, decls: &CanonicalDeclarations, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>
Ingest three typed split row sets under the canonical profile.
The CLI has already decoded its dataset-specific source format into typed rows —
D-05 keeps paired *_text.txt / *_labels.txt decoding on the CLI side, so this
crate never sees a dataset-specific format and never touches a byte it was not
handed.
Ordering matters twice, and both orders are ascending by role name because that is
what DatasetFingerprint::compute debug-asserts: the fingerprint inputs and the
dedup inputs. The ledger, by contrast, records in INGEST order (train, validation,
test), because a log of what happened should read in the order it happened.
§Errors
Any gate-ladder variant from the split boundary. Nothing is recorded in the ledger on the failing path: a dataset that was rejected was never accessed.
Sourcepub fn label_names(&self) -> &[String]
pub fn label_names(&self) -> &[String]
The declared label map, in label order.
Sourcepub fn validation(&self) -> &Split<Validation>
pub fn validation(&self) -> &Split<Validation>
The validation split.
Sourcepub fn validation_witness(&self) -> ValidationWitness<'_>
pub fn validation_witness(&self) -> ValidationWitness<'_>
A proof that this dataset has a validation split.
This method exists only on the canonical type. Its absence on
PreparedDataset<Compatibility> is DATA-06’s compile-time gate:
use aprender_contrastive_data::prepared::{Compatibility, PreparedDataset};
fn take_witness(dataset: &PreparedDataset<Compatibility>) {
let _ = dataset.validation_witness();
}The same call on the canonical type compiles, which is what stops the block above from being green for an unrelated reason:
use aprender_contrastive_data::prepared::{Canonical, PreparedDataset};
fn take_witness(dataset: &PreparedDataset<Canonical>) {
let _ = dataset.validation_witness();
}Sourcepub fn exclusions(&self) -> &ExclusionRecord
pub fn exclusions(&self) -> &ExclusionRecord
What cross-split duplication removed from the training pool.
Sourcepub fn fingerprint(&self) -> &DatasetFingerprint
pub fn fingerprint(&self) -> &DatasetFingerprint
This dataset’s identity.
Sourcepub fn encode_jsonl(&self) -> Result<PreparedJsonl, ContrastiveDataError>
pub fn encode_jsonl(&self) -> Result<PreparedJsonl, ContrastiveDataError>
Canonical JSONL bytes per split.
§Errors
ContrastiveDataError::Serialization if a split cannot be re-encoded.
Source§impl PreparedDataset<Compatibility>
impl PreparedDataset<Compatibility>
Sourcepub fn from_labeled_rows(
train: Vec<LabeledExample>,
compatibility_test: Vec<LabeledExample>,
decls: &CompatibilityDeclarations,
ledger: &mut AccessLedger,
) -> Result<Self, ContrastiveDataError>
pub fn from_labeled_rows( train: Vec<LabeledExample>, compatibility_test: Vec<LabeledExample>, decls: &CompatibilityDeclarations, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>
Ingest the compatibility profile’s two split row sets.
Selection cannot consume the result:
use aprender_contrastive_data::prepared::{Canonical, Compatibility, PreparedDataset};
fn selection(_dataset: &PreparedDataset<Canonical>) {}
fn call(compatibility: &PreparedDataset<Compatibility>) {
selection(compatibility);
}The canonical control, which must compile:
use aprender_contrastive_data::prepared::{Canonical, PreparedDataset};
fn selection(_dataset: &PreparedDataset<Canonical>) {}
fn call(canonical: &PreparedDataset<Canonical>) {
selection(canonical);
}§Errors
Any gate-ladder variant from the split boundary.
Sourcepub fn label_names(&self) -> &[String]
pub fn label_names(&self) -> &[String]
The declared label map, in label order.
Sourcepub fn compatibility_test(&self) -> &Split<CompatibilityTest>
pub fn compatibility_test(&self) -> &Split<CompatibilityTest>
The merged compatibility test split.
Sourcepub fn exclusions(&self) -> &ExclusionRecord
pub fn exclusions(&self) -> &ExclusionRecord
What cross-split duplication removed from the training pool.
Sourcepub fn fingerprint(&self) -> &DatasetFingerprint
pub fn fingerprint(&self) -> &DatasetFingerprint
This dataset’s identity.
Sourcepub fn encode_jsonl(&self) -> Result<PreparedJsonl, ContrastiveDataError>
pub fn encode_jsonl(&self) -> Result<PreparedJsonl, ContrastiveDataError>
Canonical JSONL bytes per split.
§Errors
ContrastiveDataError::Serialization if a split cannot be re-encoded.
Source§impl PreparedDataset<Canonical>
impl PreparedDataset<Canonical>
Sourcepub fn from_attested_bytes(
attestation_bytes: &[u8],
splits: &BTreeMap<String, Vec<u8>>,
ledger: &mut AccessLedger,
) -> Result<Self, ContrastiveDataError>
pub fn from_attested_bytes( attestation_bytes: &[u8], splits: &BTreeMap<String, Vec<u8>>, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>
The canonical profile’s attested boundary.
splits is keyed by split role — exactly the shape
crate::prepared::PreparedJsonl::as_map hands back, so
from_labeled_rows -> encode_jsonl -> from_attested_bytes is a closed round trip
whose two ends must fingerprint identically.
§Errors
ContrastiveDataError::UnsupportedSchemaVersion,
ContrastiveDataError::UnsupportedNormalizationVersion,
ContrastiveDataError::ProfileMismatch,
ContrastiveDataError::ConflictingSourceRole,
ContrastiveDataError::MissingSplit,
ContrastiveDataError::SplitHashMismatch, any gate-ladder variant (including
ContrastiveDataError::InvalidClassCounts when the attested per-class counts
disagree with the split contents), ContrastiveDataError::ExclusionRecordMismatch,
or ContrastiveDataError::FingerprintMismatch.
Source§impl PreparedDataset<Compatibility>
impl PreparedDataset<Compatibility>
Sourcepub fn from_attested_bytes(
attestation_bytes: &[u8],
splits: &BTreeMap<String, Vec<u8>>,
ledger: &mut AccessLedger,
) -> Result<Self, ContrastiveDataError>
pub fn from_attested_bytes( attestation_bytes: &[u8], splits: &BTreeMap<String, Vec<u8>>, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>
The compatibility profile’s attested boundary.
A canonical attestation fed here is ContrastiveDataError::ProfileMismatch, and
so is a compatibility attestation fed to the canonical constructor. The profile is
a type parameter, so the two are separate functions the compiler keeps apart; this
check is what stops untrusted BYTES from crossing between them (D-19).
§Errors
The same set as the canonical constructor.