protocolith 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. protocolith/__init__.py +38 -0
  2. protocolith/baseline_groups.py +294 -0
  3. protocolith/baselines.py +288 -0
  4. protocolith/card_svg_render.py +281 -0
  5. protocolith/card_svg_styles.py +178 -0
  6. protocolith/cli.py +796 -0
  7. protocolith/core/__init__.py +63 -0
  8. protocolith/core/_lock_posix.py +29 -0
  9. protocolith/core/_lock_windows.py +29 -0
  10. protocolith/core/atlas.py +406 -0
  11. protocolith/core/atlas_assets/atlas.css +86 -0
  12. protocolith/core/atlas_assets/atlas.html +84 -0
  13. protocolith/core/atlas_assets/atlas.js +370 -0
  14. protocolith/core/atlas_i18n/en.json +61 -0
  15. protocolith/core/canonical.py +124 -0
  16. protocolith/core/capture.py +68 -0
  17. protocolith/core/clock.py +25 -0
  18. protocolith/core/commands.py +356 -0
  19. protocolith/core/errors.py +116 -0
  20. protocolith/core/issue.py +98 -0
  21. protocolith/core/ledger.py +75 -0
  22. protocolith/core/mcp.py +371 -0
  23. protocolith/core/ops.py +183 -0
  24. protocolith/core/rules.py +352 -0
  25. protocolith/core/schema.py +137 -0
  26. protocolith/core/store.py +101 -0
  27. protocolith/core/views.py +136 -0
  28. protocolith/doctor.py +135 -0
  29. protocolith/evidence_card.py +354 -0
  30. protocolith/family_ledger.py +489 -0
  31. protocolith/generic_ohlcv_batch_pre_registration_meta.py +123 -0
  32. protocolith/inspect.py +48 -0
  33. protocolith/nasa_power.py +266 -0
  34. protocolith/nasa_power_fetch.py +64 -0
  35. protocolith/nasa_power_parser.py +133 -0
  36. protocolith/nasa_power_prereg_runner.py +383 -0
  37. protocolith/noaa_coops_fetch.py +188 -0
  38. protocolith/noaa_coops_parser.py +120 -0
  39. protocolith/noaa_coops_prereg_runner.py +341 -0
  40. protocolith/public_ai_protocol.py +176 -0
  41. protocolith/py.typed +0 -0
  42. protocolith/registry.py +139 -0
  43. protocolith/registry_view.py +302 -0
  44. protocolith/rerun_report.py +111 -0
  45. protocolith/run_root.py +243 -0
  46. protocolith/scaffold.py +565 -0
  47. protocolith/source_probe.py +230 -0
  48. protocolith/svg_a11y.py +100 -0
  49. protocolith/tree_overlay.py +343 -0
  50. protocolith/verify_packs.py +251 -0
  51. protocolith/workflows.py +233 -0
  52. protocolith-0.6.0.dist-info/METADATA +283 -0
  53. protocolith-0.6.0.dist-info/RECORD +57 -0
  54. protocolith-0.6.0.dist-info/WHEEL +4 -0
  55. protocolith-0.6.0.dist-info/entry_points.txt +3 -0
  56. protocolith-0.6.0.dist-info/licenses/LICENSE +201 -0
  57. protocolith-0.6.0.dist-info/licenses/NOTICE +13 -0
@@ -0,0 +1,251 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """VERIFY pack shortcuts for cross-platform external operators."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from collections.abc import Callable
9
+
10
+ from protocolith.inspect import load_json, pick_fields
11
+
12
+
13
+ FORBIDDEN_AI_PHRASES = (
14
+ "deployment readiness",
15
+ "model safety",
16
+ "benchmark superiority",
17
+ "runtime behavior",
18
+ "generally safe",
19
+ )
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class VerifyCheck:
24
+ name: str
25
+ ok: bool
26
+ detail: str
27
+
28
+
29
+ def _ai_boundary_ok(card_path: Path) -> tuple[bool, str]:
30
+ data = load_json(card_path)
31
+ allowed = str(data.get("allowed_claim_sentence", "")).lower()
32
+ boundary = str(data.get("claim_boundary", "")).lower()
33
+ forbidden_in_allowed = [phrase for phrase in FORBIDDEN_AI_PHRASES if phrase in allowed]
34
+ if forbidden_in_allowed:
35
+ return False, f"forbidden phrases in allowed_claim_sentence: {', '.join(forbidden_in_allowed)}"
36
+ if "source" not in allowed and "audit" not in allowed:
37
+ return False, "allowed_claim_sentence should stay source-audit narrow"
38
+ if "does not" not in boundary and "not verify" not in boundary:
39
+ return False, "claim_boundary should state explicit non-claims"
40
+ return True, "ok"
41
+
42
+
43
+ def verify_source_probe_spec(repo_root: Path) -> list[VerifyCheck]:
44
+ doc = repo_root / "docs" / "SOURCE_PROBE_V1_ACCEPTANCE_CRITERIA.md"
45
+ script = repo_root / "scripts" / "protocolith_source_probe.py"
46
+ text = doc.read_text(encoding="utf-8") if doc.is_file() else ""
47
+ return [
48
+ VerifyCheck("doc_exists", doc.is_file(), str(doc)),
49
+ VerifyCheck(
50
+ "doc_marked_implemented",
51
+ "status: **implemented" in text.lower(),
52
+ "expects an 'implemented' status line",
53
+ ),
54
+ VerifyCheck(
55
+ "probe_script_present",
56
+ script.is_file(),
57
+ "scripts/protocolith_source_probe.py must exist",
58
+ ),
59
+ VerifyCheck(
60
+ "no_passed_by_itself",
61
+ "must not emit passed_under_protocol by itself" in text.lower(),
62
+ "spec must forbid PASSED_UNDER_PROTOCOL from probe alone",
63
+ ),
64
+ ]
65
+
66
+
67
+ def verify_static_registry_spec(repo_root: Path) -> list[VerifyCheck]:
68
+ doc = repo_root / "docs" / "STATIC_REGISTRY_MVP_ACCEPTANCE_CRITERIA.md"
69
+ script = repo_root / "scripts" / "protocolith_build_registry_view.py"
70
+ views = repo_root / "docs" / "registry" / "views"
71
+ text = doc.read_text(encoding="utf-8") if doc.is_file() else ""
72
+ return [
73
+ VerifyCheck("doc_exists", doc.is_file(), str(doc)),
74
+ VerifyCheck(
75
+ "doc_names_generator",
76
+ "protocolith_build_registry_view.py" in text,
77
+ "spec must name the generator script",
78
+ ),
79
+ VerifyCheck(
80
+ "registry_view_script_present",
81
+ script.is_file(),
82
+ "scripts/protocolith_build_registry_view.py must exist",
83
+ ),
84
+ VerifyCheck(
85
+ "registry_views_present",
86
+ (views / "index.html").is_file() and (views / "index.md").is_file(),
87
+ "docs/registry/views/index.{html,md} must exist",
88
+ ),
89
+ ]
90
+
91
+
92
+ def _cli_main(argv: list[str]) -> int:
93
+ from protocolith.cli import main as cli_main
94
+
95
+ return int(cli_main(argv))
96
+
97
+
98
+ def verify_api_parity(repo_root: Path) -> list[VerifyCheck]:
99
+ exit_code = _cli_main(["validate-all"])
100
+ checks = [VerifyCheck("validate_all", exit_code == 0, f"exit={exit_code}")]
101
+ registry = load_json(repo_root / "docs" / "registry" / "evidence_index.json")
102
+ card_count = registry.get("card_count")
103
+ cards = registry.get("cards")
104
+ checks.append(
105
+ VerifyCheck(
106
+ "card_count_consistent",
107
+ isinstance(cards, list) and card_count == len(cards),
108
+ f"card_count={card_count}, registry_entries={len(cards) if isinstance(cards, list) else 'n/a'}",
109
+ )
110
+ )
111
+ api_card = repo_root / "docs" / "evidence_cards" / "PLITH-API_PARITY_D001-2026-06-15.json"
112
+ if api_card.is_file():
113
+ fields = pick_fields(
114
+ load_json(api_card),
115
+ ("evidence_id", "result_status", "claim_boundary", "runner_command"),
116
+ )
117
+ checks.append(
118
+ VerifyCheck(
119
+ "api_card_present",
120
+ True,
121
+ f"evidence_id={fields['evidence_id']}",
122
+ )
123
+ )
124
+ else:
125
+ checks.append(VerifyCheck("api_card_present", False, "API parity card missing"))
126
+ return checks
127
+
128
+
129
+ def verify_ai_boundary(repo_root: Path) -> list[VerifyCheck]:
130
+ cards = (
131
+ "PLITH-ANTHROPIC_SYSTEM_CARDS_SOURCE_AUDIT_D001-2026-05-08",
132
+ "PLITH-OPENAI_GPT5_SYSTEM_CARD_SOURCE_AUDIT_D001-2026-05-08",
133
+ "PLITH-GOOGLE_DEEPMIND_MODEL_CARDS_SOURCE_AUDIT_D001-2026-05-08",
134
+ "PLITH-GROK_PROMPTS_SOURCE_AUDIT_D001-2026-05-07",
135
+ )
136
+ checks: list[VerifyCheck] = []
137
+ for card_id in cards:
138
+ path = repo_root / "docs" / "evidence_cards" / f"{card_id}.json"
139
+ if not path.is_file():
140
+ checks.append(VerifyCheck(card_id, False, "missing card"))
141
+ continue
142
+ ok, detail = _ai_boundary_ok(path)
143
+ checks.append(VerifyCheck(card_id, ok, detail))
144
+ return checks
145
+
146
+
147
+ def verify_eea_drift(repo_root: Path) -> list[VerifyCheck]:
148
+ from protocolith.workflows import drift_eea_source_audit
149
+
150
+ baseline = repo_root / "artifacts" / "source_audit_d001_summary.json"
151
+ checks = [
152
+ VerifyCheck("baseline_artifact", baseline.is_file(), str(baseline)),
153
+ ]
154
+ exit_code = drift_eea_source_audit(repo_root)
155
+ checks.append(VerifyCheck("eea_drift_probe", exit_code == 0, f"exit={exit_code}"))
156
+ return checks
157
+
158
+
159
+ def verify_nasa_rerun(repo_root: Path, *, operator: str = "verify-operator") -> list[VerifyCheck]:
160
+ from protocolith.workflows import rerun_nasa_d103
161
+
162
+ baseline = repo_root / "artifacts" / "nasa_power_d103_real_run_summary.json"
163
+ checks = [
164
+ VerifyCheck("baseline_artifact", baseline.is_file(), str(baseline)),
165
+ ]
166
+ exit_code = rerun_nasa_d103(repo_root, operator=operator)
167
+ checks.append(VerifyCheck("nasa_rerun_gate", exit_code == 0, f"exit={exit_code}"))
168
+ return checks
169
+
170
+
171
+ def verify_noaa_rerun(repo_root: Path, *, operator: str = "verify-operator") -> list[VerifyCheck]:
172
+ from protocolith.workflows import rerun_noaa_d131
173
+
174
+ baseline = repo_root / "artifacts" / "noaa_coops_d131_negative_result_summary.json"
175
+ checks = [
176
+ VerifyCheck("baseline_artifact", baseline.is_file(), str(baseline)),
177
+ ]
178
+ exit_code = rerun_noaa_d131(repo_root, operator=operator)
179
+ checks.append(VerifyCheck("noaa_rerun_gate", exit_code == 0, f"exit={exit_code}"))
180
+ return checks
181
+
182
+
183
+ def verify_starter_pack(repo_root: Path) -> list[VerifyCheck]:
184
+ checks: list[VerifyCheck] = []
185
+ for demo_name in ("eea-source-audit", "grok-source-audit"):
186
+ exit_code = _cli_main(["demo", demo_name])
187
+ checks.append(
188
+ VerifyCheck(f"demo_{demo_name}", exit_code == 0, f"exit={exit_code}")
189
+ )
190
+
191
+ flagship_cards = (
192
+ "PLITH-ANTHROPIC_SYSTEM_CARDS_SOURCE_AUDIT_D001-2026-05-08",
193
+ "PLITH-NASA-POWER-D103-2026-04-29",
194
+ "PLITH-NOAA-COOPS-D131-2026-04-30",
195
+ )
196
+ for card_id in flagship_cards:
197
+ path = repo_root / "docs" / "evidence_cards" / f"{card_id}.json"
198
+ fields = pick_fields(
199
+ load_json(path),
200
+ ("evidence_id", "result_status", "reproduction_level", "claim_boundary"),
201
+ )
202
+ if card_id.startswith("PLITH-NASA-POWER-D103"):
203
+ checks.append(
204
+ VerifyCheck(
205
+ "nasa_drift_in_reproduction_level",
206
+ fields["result_status"] == "PASSED_UNDER_PROTOCOL"
207
+ and "DRIFT" in str(fields["reproduction_level"]),
208
+ f"result_status={fields['result_status']} "
209
+ f"reproduction_level={fields['reproduction_level']}",
210
+ )
211
+ )
212
+ else:
213
+ checks.append(
214
+ VerifyCheck(
215
+ card_id,
216
+ path.is_file(),
217
+ f"result_status={fields['result_status']}",
218
+ )
219
+ )
220
+ return checks
221
+
222
+
223
+ VERIFY_PACKS: dict[str, Callable[..., list[VerifyCheck]]] = {
224
+ "starter-pack": verify_starter_pack,
225
+ "ai-boundary": verify_ai_boundary,
226
+ "api-parity": verify_api_parity,
227
+ "source-probe-spec": verify_source_probe_spec,
228
+ "static-registry-spec": verify_static_registry_spec,
229
+ "eea-drift": verify_eea_drift,
230
+ "nasa-rerun": verify_nasa_rerun,
231
+ "noaa-rerun": verify_noaa_rerun,
232
+ }
233
+
234
+ _NETWORK_PACKS = frozenset({"eea-drift", "nasa-rerun", "noaa-rerun"})
235
+
236
+
237
+ def run_verify_pack(repo_root: Path, pack_name: str, *, operator: str = "verify-operator") -> int:
238
+ handler = VERIFY_PACKS.get(pack_name)
239
+ if handler is None:
240
+ raise ValueError(f"unknown verify pack: {pack_name}")
241
+ if pack_name in ("nasa-rerun", "noaa-rerun"):
242
+ checks = handler(repo_root, operator=operator)
243
+ else:
244
+ checks = handler(repo_root)
245
+ ok = True
246
+ for check in checks:
247
+ status = "PASS" if check.ok else "FAIL"
248
+ print(f"[{status}] {check.name}: {check.detail}")
249
+ ok = ok and check.ok
250
+ print(f"verify_{pack_name}={'PASS' if ok else 'FAIL'}")
251
+ return 0 if ok else 1
@@ -0,0 +1,233 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Cross-platform operator workflow orchestration for reruns and drift checks."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import subprocess
8
+ import sys
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from protocolith.inspect import format_hash_lines, format_json_subset, hash_files, load_json, pick_fields
13
+ from protocolith.nasa_power_fetch import download_nasa_power_d103_points
14
+ from protocolith.nasa_power_prereg_runner import evaluate_nasa_power_prereg
15
+ from protocolith.noaa_coops_fetch import (
16
+ NOAA_COOPS_D131_STATIONS,
17
+ fetch_d131_station_payloads,
18
+ )
19
+ from protocolith.noaa_coops_prereg_runner import (
20
+ build_negative_result_summary,
21
+ evaluate_noaa_coops_prereg,
22
+ )
23
+ from protocolith.run_root import RunRootRequest, prepare_run_root
24
+
25
+
26
+ EEA_DRIFT_SUMMARY_KEYS = (
27
+ "http_status",
28
+ "final_url",
29
+ "page_sha256",
30
+ "rights_link_present",
31
+ "direct_link_presence",
32
+ "result_status",
33
+ )
34
+ EEA_DRIFT_COMPARE_KEYS = (
35
+ "http_status",
36
+ "final_url",
37
+ "content_type",
38
+ "page_sha256",
39
+ "page_byte_size",
40
+ "page_title",
41
+ "rights_link_present",
42
+ "direct_link_presence",
43
+ )
44
+
45
+
46
+ def _sha256_manifest(paths: list[Path]) -> str:
47
+ import hashlib
48
+
49
+ lines = []
50
+ for path in sorted(paths, key=lambda item: item.name):
51
+ digest = hashlib.sha256(path.read_bytes()).hexdigest()
52
+ lines.append(f"{digest} {path.name}")
53
+ payload = "\n".join(lines) + ("\n" if lines else "")
54
+ return hashlib.sha256(payload.encode("utf-8")).hexdigest()
55
+
56
+
57
+ def _gate_result_block(report: dict[str, Any]) -> dict[str, Any]:
58
+ if "result" in report and isinstance(report["result"], dict):
59
+ return report["result"]
60
+ keys = (
61
+ "source_audit_passed",
62
+ "eligible_point_count",
63
+ "eligible_windows",
64
+ "overall_go_no_go",
65
+ "result_status",
66
+ "allowed_narrow_claim",
67
+ )
68
+ return {key: report[key] for key in keys if key in report}
69
+
70
+
71
+ def _print_compare(title: str, baseline: dict[str, Any], current: dict[str, Any]) -> None:
72
+ print(f"=== {title} ===")
73
+ print(format_json_subset(_gate_result_block(baseline)), end="")
74
+ print("=== YOUR RUN ===")
75
+ print(format_json_subset(_gate_result_block(current)), end="")
76
+
77
+
78
+ def resolve_or_create_run_dir(
79
+ *,
80
+ protocol_id: str,
81
+ source_url: str,
82
+ operator: str,
83
+ root: Path,
84
+ run_dir: Path | None,
85
+ ) -> Path:
86
+ if run_dir is not None:
87
+ run_dir.mkdir(parents=True, exist_ok=True)
88
+ return run_dir.resolve()
89
+ paths = prepare_run_root(
90
+ RunRootRequest(
91
+ protocol_id=protocol_id,
92
+ operator=operator,
93
+ source_url=source_url,
94
+ root=root,
95
+ )
96
+ )
97
+ return paths[0].resolve()
98
+
99
+
100
+ def rerun_nasa_d103(
101
+ repo_root: Path,
102
+ *,
103
+ operator: str = "local operator",
104
+ root: Path | None = None,
105
+ run_dir: Path | None = None,
106
+ baseline_path: Path | None = None,
107
+ ) -> int:
108
+ runs_root = root or Path.home() / "protocolith_runs"
109
+ resolved_run_dir = resolve_or_create_run_dir(
110
+ protocol_id="NASA_POWER_D103",
111
+ source_url="https://power.larc.nasa.gov/docs/services/api/temporal/daily/",
112
+ operator=operator,
113
+ root=runs_root,
114
+ run_dir=run_dir,
115
+ )
116
+ raw_dir = resolved_run_dir / "raw"
117
+ reports_dir = resolved_run_dir / "reports"
118
+ hashes_dir = resolved_run_dir / "hashes"
119
+ raw_dir.mkdir(parents=True, exist_ok=True)
120
+ reports_dir.mkdir(parents=True, exist_ok=True)
121
+ hashes_dir.mkdir(parents=True, exist_ok=True)
122
+
123
+ print(f"run_dir={resolved_run_dir.as_posix()}")
124
+ downloaded = download_nasa_power_d103_points(raw_dir)
125
+ hash_path = hashes_dir / "nasa_raw_sha256.txt"
126
+ hash_path.write_text(format_hash_lines(hash_files(tuple(downloaded))), encoding="utf-8")
127
+ print(f"hash_file={hash_path.as_posix()}")
128
+
129
+ report_path = reports_dir / "nasa_power_d103_report.json"
130
+ evaluation = evaluate_nasa_power_prereg(
131
+ point_ids=["POWER_A", "POWER_B", "POWER_C"],
132
+ json_paths=downloaded,
133
+ pre_registration_doc_path=repo_root / "docs" / "protocols" / "NASA_POWER_D103_PREREG_CHARTER.md",
134
+ )
135
+ report_path.write_text(json.dumps(evaluation, indent=2, sort_keys=True), encoding="utf-8")
136
+ print(f"report={report_path.as_posix()}")
137
+
138
+ baseline = load_json(
139
+ baseline_path or repo_root / "artifacts" / "nasa_power_d103_real_run_summary.json"
140
+ )
141
+ _print_compare("BASELINE", baseline, evaluation)
142
+ return 0
143
+
144
+
145
+ def rerun_noaa_d131(
146
+ repo_root: Path,
147
+ *,
148
+ operator: str = "local operator",
149
+ root: Path | None = None,
150
+ run_dir: Path | None = None,
151
+ baseline_path: Path | None = None,
152
+ ) -> int:
153
+ runs_root = root or Path.home() / "protocolith_runs"
154
+ resolved_run_dir = resolve_or_create_run_dir(
155
+ protocol_id="NOAA_COOPS_D131",
156
+ source_url="https://api.tidesandcurrents.noaa.gov/api/prod/datagetter",
157
+ operator=operator,
158
+ root=runs_root,
159
+ run_dir=run_dir,
160
+ )
161
+ raw_dir = resolved_run_dir / "raw"
162
+ reports_dir = resolved_run_dir / "reports"
163
+ hashes_dir = resolved_run_dir / "hashes"
164
+ raw_dir.mkdir(parents=True, exist_ok=True)
165
+ reports_dir.mkdir(parents=True, exist_ok=True)
166
+ hashes_dir.mkdir(parents=True, exist_ok=True)
167
+
168
+ print(f"run_dir={resolved_run_dir.as_posix()}")
169
+ payload_paths: list[Path] = []
170
+ for station in NOAA_COOPS_D131_STATIONS:
171
+ payload_paths.extend(fetch_d131_station_payloads(station, raw_dir))
172
+ hash_path = hashes_dir / "raw_sha256.txt"
173
+ hash_path.write_text(format_hash_lines(hash_files(tuple(payload_paths))), encoding="utf-8")
174
+ print(f"hash_file={hash_path.as_posix()}")
175
+
176
+ observed = [raw_dir / f"{station}_observed.json" for station in NOAA_COOPS_D131_STATIONS]
177
+ predictions = [raw_dir / f"{station}_predictions.json" for station in NOAA_COOPS_D131_STATIONS]
178
+ manifest_sha = _sha256_manifest(observed + predictions)
179
+ evaluation = evaluate_noaa_coops_prereg(
180
+ station_ids=list(NOAA_COOPS_D131_STATIONS),
181
+ observed_paths=observed,
182
+ predictions_paths=predictions,
183
+ pre_registration_doc_path=repo_root / "docs" / "protocols" / "NOAA_COOPS_D131_PREREG_CHARTER.md",
184
+ external_payload_manifest_sha256=manifest_sha,
185
+ )
186
+ report_path = reports_dir / "noaa_coops_d131_report.json"
187
+ summary_path = reports_dir / "noaa_coops_d131_summary.json"
188
+ report_path.write_text(json.dumps(evaluation, indent=2, sort_keys=True), encoding="utf-8")
189
+ summary = build_negative_result_summary(evaluation, report_path=report_path)
190
+ summary_path.write_text(json.dumps(summary, indent=2, sort_keys=True), encoding="utf-8")
191
+ print(f"report={report_path.as_posix()}")
192
+ print(f"summary={summary_path.as_posix()}")
193
+
194
+ baseline = load_json(
195
+ baseline_path or repo_root / "artifacts" / "noaa_coops_d131_negative_result_summary.json"
196
+ )
197
+ _print_compare("BASELINE GATE", baseline, summary)
198
+ if "failed_gates" in summary:
199
+ print("=== YOUR FAILED GATES ===")
200
+ print(format_json_subset({"failed_gates": summary["failed_gates"]}), end="")
201
+ return 0
202
+
203
+
204
+ def drift_eea_source_audit(
205
+ repo_root: Path,
206
+ *,
207
+ baseline_path: Path | None = None,
208
+ report_path: Path | None = None,
209
+ ) -> int:
210
+ baseline = baseline_path or repo_root / "artifacts" / "source_audit_d001_summary.json"
211
+ report = report_path or repo_root / "artifacts" / "eea_source_audit_drift_check_summary.json"
212
+ script = repo_root / "scripts" / "protocolith_run_eea_source_audit.py"
213
+ report.parent.mkdir(parents=True, exist_ok=True)
214
+ result = subprocess.call([sys.executable, str(script), "--report", str(report)], cwd=repo_root)
215
+ if result != 0:
216
+ return result
217
+
218
+ baseline_data = load_json(baseline)
219
+ print("=== BASELINE ===")
220
+ print(format_json_subset(pick_fields(baseline_data, EEA_DRIFT_SUMMARY_KEYS)), end="")
221
+ print("=== FRESH PROBE ===")
222
+ fresh = load_json(report)
223
+ print(format_json_subset(pick_fields(fresh, EEA_DRIFT_SUMMARY_KEYS)), end="")
224
+
225
+ baseline_subset = pick_fields(load_json(baseline), EEA_DRIFT_COMPARE_KEYS)
226
+ fresh_subset = pick_fields(fresh, EEA_DRIFT_COMPARE_KEYS)
227
+ changed = [key for key in EEA_DRIFT_COMPARE_KEYS if baseline_subset.get(key) != fresh_subset.get(key)]
228
+ print(f"changed_fields={','.join(changed) if changed else 'none'}")
229
+ print(
230
+ "note=source drift does not automatically invalidate the original card; "
231
+ "record page_sha256 and marker fields in your issue comment."
232
+ )
233
+ return 0