| |
| """Build the deterministic RC26 cross-repository migration ledger.""" |
|
|
| from __future__ import annotations |
|
|
| import csv |
| import hashlib |
| import json |
| from pathlib import Path |
|
|
|
|
| SOURCE_REPO = "https://github.com/sunshineluyao/aave-bns" |
| SOURCE_COMMIT = "932f6f4f62c3402adf38231ed83ea9ca17cc227c" |
|
|
| PROCESSED = { |
| "observed_protocol_action_counts": ("outputs/real_v2/ethereum/weekly_action_panel.csv", "real_v2", "DERIVED"), |
| "treatment_event_registry": ("data/metadata/treatment_registry.csv", "registry_v1", "OBSERVED"), |
| "participation_and_concentration_metrics": ("outputs/real_v5/descriptive/weekly_address_metrics.csv", "real_v5", "DERIVED"), |
| "cross_chain_overlap": ("outputs/real_v5/descriptive/cross_chain_overlap.csv", "real_v5", "DERIVED"), |
| "structural_metrics": ("outputs/real_v5/topology/address_role_topology_metrics.csv", "real_v5", "DERIVED"), |
| "actor_bounds_period": ("outputs/real_v4/ethereum/period_beneficiary_bounds.csv", "real_v4", "BOUNDED"), |
| "actor_bounds_change": ("outputs/real_v4/ethereum/period_change_bounds.csv", "real_v4", "BOUNDED"), |
| "simulation": ("outputs/simulation/scenario_results.csv", "simulation_v1", "SYNTHETIC"), |
| "failed_design_estimates": ("outputs/real_v6/arbitrum_gnosis_did_mvp/estimates.csv", "real_v6", "FAILED_DESIGN"), |
| "failed_design_event_study": ("outputs/real_v6/arbitrum_gnosis_did_mvp/event_study.csv", "real_v6", "FAILED_DESIGN"), |
| "failed_design_placebos": ("outputs/real_v6/arbitrum_gnosis_did_mvp/placebo_windows.csv", "real_v6", "FAILED_DESIGN"), |
| "failed_design_pretrends": ("outputs/real_v6/arbitrum_gnosis_did_mvp/pretrend_diagnostics.csv", "real_v6", "FAILED_DESIGN"), |
| "source_audit": ("data/metadata/event_source_audit.csv", "registry_v1", "OBSERVED"), |
| "metric_registry": ("data/metadata/network_measure_glossary.csv", "registry_v1", "OBSERVED"), |
| } |
|
|
| FIELDS = [ |
| "artifact_id", "source_repo", "source_commit", "source_path", |
| "source_locator", "target_path", "digest_kind", "sha256", "row_count", |
| "schema_version", "evidence_status", "release_class", "migration_status", |
| "notes", |
| ] |
|
|
|
|
| def digest(path: Path) -> str: |
| return hashlib.sha256(path.read_bytes()).hexdigest() |
|
|
|
|
| def csv_rows(path: Path) -> int: |
| with path.open(newline="", encoding="utf-8-sig") as handle: |
| return sum(1 for row in csv.reader(handle) if any(cell != "" for cell in row)) - 1 |
|
|
|
|
| def queried_source_path(path: Path) -> str: |
| """Resolve the preserved audit file to its exact monorepo location.""" |
| if path.parent.name == "real_v2_ethereum": |
| return f"outputs/real_v2/ethereum/{path.name}" |
| if path.name == "artifact_provenance.json": |
| return "data/metadata/real_v6_gnosis_artifact_provenance.json" |
| return f"outputs/real_v6/gnosis_donor/{path.name}" |
|
|
|
|
| def main() -> int: |
| root = Path(__file__).resolve().parents[1] |
| rows: list[dict[str, object]] = [] |
|
|
| for path in sorted((root / "data/queried").glob("*/*")): |
| if not path.is_file() or path.name == "README.md": |
| continue |
| rel = path.relative_to(root).as_posix() |
| version = path.parent.name |
| source_path = queried_source_path(path) |
| count = csv_rows(path) if path.suffix == ".csv" else "" |
| rows.append({ |
| "artifact_id": f"queried_{version}_{path.stem}", |
| "source_repo": SOURCE_REPO, |
| "source_commit": SOURCE_COMMIT, |
| "source_path": source_path, |
| "source_locator": f"git:{SOURCE_COMMIT}:{source_path}", |
| "target_path": rel, |
| "digest_kind": "target_file_sha256", |
| "sha256": digest(path), |
| "row_count": count, |
| "schema_version": version, |
| "evidence_status": "OBSERVED", |
| "release_class": "PUBLIC_DERIVED_AUDIT_EVIDENCE", |
| "migration_status": "VERIFIED_COPY", |
| "notes": "Completed acquisition audit evidence; no RC26 query executed.", |
| }) |
|
|
| for name, (source_path, version, evidence) in PROCESSED.items(): |
| path = root / "data/processed" / name / "data.csv" |
| rows.append({ |
| "artifact_id": f"processed_{name}", |
| "source_repo": SOURCE_REPO, |
| "source_commit": SOURCE_COMMIT, |
| "source_path": source_path, |
| "source_locator": f"git:{SOURCE_COMMIT}:{source_path}", |
| "target_path": path.relative_to(root).as_posix(), |
| "digest_kind": "target_file_sha256", |
| "sha256": digest(path), |
| "row_count": csv_rows(path), |
| "schema_version": version, |
| "evidence_status": evidence, |
| "release_class": "PUBLIC_AGGREGATE_OR_GOVERNED_TABLE", |
| "migration_status": "VERIFIED_COPY", |
| "notes": "Byte digest and governed row count verified in the target checkout.", |
| }) |
|
|
| rows.extend([ |
| { |
| "artifact_id": "raw_real_v2_ethereum_pool_events", |
| "source_repo": SOURCE_REPO, |
| "source_commit": SOURCE_COMMIT, |
| "source_path": "data/raw/real_v2/ethereum/pool_action_chunks/*.jsonl.gz", |
| "source_locator": "data/queried/real_v2_ethereum/manifest.json", |
| "target_path": "", |
| "digest_kind": "canonical_uncompressed_partition_stream_sha256", |
| "sha256": "594dbed52b82b6e01384ab473624f1e8e59e986b0d0c8164df9aad347351f309", |
| "row_count": 118806, |
| "schema_version": "real_v2", |
| "evidence_status": "RECOVERABLE", |
| "release_class": "ROW_LEVEL_PSEUDONYMOUS_ADDRESS_DATA", |
| "migration_status": "BLOCKED_SOURCE_PAYLOAD_NOT_IN_GIT", |
| "notes": "165 raw partitions; do not re-query or substitute a different chain snapshot.", |
| }, |
| { |
| "artifact_id": "processed_real_v2_ethereum_pool_events", |
| "source_repo": SOURCE_REPO, |
| "source_commit": SOURCE_COMMIT, |
| "source_path": "data/processed/real_v2/ethereum/aave_v3_pool_actions.csv.gz", |
| "source_locator": "data/queried/real_v2_ethereum/manifest.json", |
| "target_path": "", |
| "digest_kind": "gzip_artifact_sha256", |
| "sha256": "6746aeec58fe3fcf7ff2b42d92490ab5cf991f76831066732e49f4eeb334feb3", |
| "row_count": 118806, |
| "schema_version": "real_v2", |
| "evidence_status": "RECOVERABLE", |
| "release_class": "ROW_LEVEL_PSEUDONYMOUS_ADDRESS_DATA", |
| "migration_status": "NOT_MIGRATED_PRIVACY_MINIMIZATION_RECOVERABLE", |
| "notes": "Canonical uncompressed CSV SHA-256: 25063a...; full digest retained in the source manifest.", |
| }, |
| { |
| "artifact_id": "processed_real_v6_gnosis_pool_events", |
| "source_repo": SOURCE_REPO, |
| "source_commit": SOURCE_COMMIT, |
| "source_path": "data/processed/real_v6/gnosis_donor/aave_v3_pool_actions.csv.gz", |
| "source_locator": "github-actions://sunshineluyao/aave-bns/runs/31199679724/artifacts/9002776210", |
| "target_path": "", |
| "digest_kind": "github_actions_zip_sha256", |
| "sha256": "0b99ae20f62622c319a1abdeaf5a78ccf712b00f2d45f2d90a05d848cbd010f2", |
| "row_count": 81814, |
| "schema_version": "real_v6", |
| "evidence_status": "RESTRICTED", |
| "release_class": "ROW_LEVEL_PSEUDONYMOUS_ADDRESS_DATA", |
| "migration_status": "NOT_MIGRATED_PRIVACY_MINIMIZATION_RECOVERED", |
| "notes": "Artifact 9002776210 from workflow run 31199679724 was recovered and its outer ZIP digest verified.", |
| }, |
| { |
| "artifact_id": "address_level_real_v3_real_v4", |
| "source_repo": SOURCE_REPO, |
| "source_commit": SOURCE_COMMIT, |
| "source_path": "data/processed/real_v3;data/processed/real_v4", |
| "source_locator": f"git:{SOURCE_COMMIT}:data/metadata", |
| "target_path": "", |
| "digest_kind": "not_applicable_registry_only", |
| "sha256": "", |
| "row_count": "", |
| "schema_version": "real_v3-real_v4", |
| "evidence_status": "RESTRICTED", |
| "release_class": "ADDRESS_OR_ENTITY_LEVEL_INTERMEDIATE", |
| "migration_status": "NOT_MIGRATED_PRIVACY_MINIMIZATION", |
| "notes": "Only aggregate governed outputs required by RC26 are included.", |
| }, |
| ]) |
|
|
| output = root / "metadata/migration_manifest.csv" |
| with output.open("w", newline="", encoding="utf-8") as handle: |
| writer = csv.DictWriter(handle, fieldnames=FIELDS, lineterminator="\n") |
| writer.writeheader() |
| writer.writerows(rows) |
| print(f"wrote {len(rows)} migration records to {output}") |
| return 0 |
|
|
|
|
| if __name__ == "__main__": |
| raise SystemExit(main()) |
|
|