|
| 1 | +"""Portable byte-lineage inputs, deliberately not scientific C6 evidence.""" |
| 2 | + |
| 3 | +import hashlib |
| 4 | +import json |
| 5 | +from copy import deepcopy |
| 6 | + |
| 7 | + |
| 8 | +def write_synthetic_c6_lineage(directory, count): |
| 9 | + """Write a minimal B26-style input DAG for CLI prevalidation only. |
| 10 | +
|
| 11 | + Records contain matching producer metadata and hashes, but no nodal states |
| 12 | + or admitted experiment manifest. Tests must stop at the analysis boundary; |
| 13 | + accepting these byte links does not admit a scientific report. |
| 14 | + """ |
| 15 | + if not 2 <= count <= 6: |
| 16 | + raise ValueError("the byte-lineage fixture supports two through six inputs") |
| 17 | + key_rows = ( |
| 18 | + (), |
| 19 | + ("input_evidence",), |
| 20 | + ("input_evidence", "source_input_evidence"), |
| 21 | + ("input_evidence", "parent_input_evidence", "source_input_evidence"), |
| 22 | + ( |
| 23 | + "input_evidence", |
| 24 | + "parent_input_evidence", |
| 25 | + "previous_input_evidence", |
| 26 | + "source_input_evidence", |
| 27 | + ), |
| 28 | + ( |
| 29 | + "input_evidence", |
| 30 | + "parent_input_evidence", |
| 31 | + "previous_input_evidence", |
| 32 | + "earlier_input_evidence", |
| 33 | + "source_input_evidence", |
| 34 | + ), |
| 35 | + ) |
| 36 | + paths = tuple(directory / f"source_{index}.json" for index in range(count)) |
| 37 | + records = [None] * count |
| 38 | + raw = [None] * count |
| 39 | + for index in reversed(range(count)): |
| 40 | + record = { |
| 41 | + "manifest": {"claim_id": f"synthetic-byte-source-{index}"}, |
| 42 | + "source_scope": ["synthetic/byte-prevalidation-only"], |
| 43 | + } |
| 44 | + for key, target in zip( |
| 45 | + key_rows[count - index - 1], range(index + 1, count), strict=True |
| 46 | + ): |
| 47 | + record[key] = { |
| 48 | + "sha256": hashlib.sha256(raw[target]).hexdigest(), |
| 49 | + "producer_manifest": deepcopy(records[target]["manifest"]), |
| 50 | + "producer_source_scope": list(records[target]["source_scope"]), |
| 51 | + } |
| 52 | + records[index] = record |
| 53 | + raw[index] = (json.dumps(record, sort_keys=True) + "\n").encode("utf-8") |
| 54 | + paths[index].write_bytes(raw[index]) |
| 55 | + return paths |
0 commit comments