Read explicitly selected local JSONL; skip and count invalid envelopes.
A collection identifier is lineage, not permission for training or sharing.
This operation sends nothing and does not consult or change current consent.
It never copies envelope prose or transport settings into the corpus.
Source code in src/marianne/corpus/ingest.py
| def ingest_spool(path: Path) -> list[TrainingExample]:
"""Read explicitly selected local JSONL; skip and count invalid envelopes.
A collection identifier is lineage, not permission for training or sharing.
This operation sends nothing and does not consult or change current consent.
It never copies envelope prose or transport settings into the corpus.
"""
records = []
skipped = 0
with path.open("rb") as stream:
for line in stream:
if not line.strip():
continue
try:
envelope = _Envelope.model_validate_json(line)
except ValidationError:
skipped += 1
continue
output = yaml.safe_dump(
sanitize_score(envelope.payload.score),
sort_keys=True,
allow_unicode=True,
)
records.append(
TrainingExample(
instruction=COMPOSITION_INSTRUCTION,
output=output,
provenance=CorpusProvenance(
source_path=str(path),
source_kind="telemetry",
source_schema_version=envelope.schema_version,
content_hash=hashlib.sha256(output.encode("utf-8")).hexdigest(),
consent_hash=hashlib.sha256(
envelope.consent_id.encode("utf-8")
).hexdigest(),
),
)
)
if skipped:
_logger.warning("Skipped %d invalid telemetry record(s).", skipped)
return records
|