46 parser = argparse.ArgumentParser(description="Audit PETSc option ingress against manifest.")
47 parser.add_argument(
48 "--manifest",
49 default="scripts/audit_ingress_manifest.json",
50 help="Path to ingress manifest JSON.",
51 )
52 parser.add_argument(
53 "--show-scanned",
54 action="store_true",
55 help="Print scanned option list before comparison.",
56 )
57 args = parser.parse_args()
58
59 repo_root = pathlib.Path(__file__).resolve().parents[1]
60 manifest_path = (repo_root / args.manifest).resolve()
61 scan_paths = [repo_root / "src/setup.c", repo_root / "src/io.c"]
62
63 if not manifest_path.exists():
64 print(f"[ERROR] Manifest not found: {manifest_path}", file=sys.stderr)
65 return 2
66
67 scanned = scan_petsc_options(scan_paths)
68 expected = load_manifest(manifest_path)
69
70 missing_in_manifest = sorted(scanned - expected)
71 stale_in_manifest = sorted(expected - scanned)
72
73 if args.show_scanned:
74 print("[INFO] Scanned PETSc options:")
75 for flag in sorted(scanned):
76 print(flag)
77 print("")
78
79 print(f"[INFO] Scanned options: {len(scanned)}")
80 print(f"[INFO] Manifest options: {len(expected)}")
81
82 if missing_in_manifest:
83 print("[ERROR] New PETSc ingress options missing in manifest:")
84 for flag in missing_in_manifest:
85 print(f" - {flag}")
86
87 if stale_in_manifest:
88 print("[ERROR] Manifest options no longer present in setup/io scan:")
89 for flag in stale_in_manifest:
90 print(f" - {flag}")
91
92 if missing_in_manifest or stale_in_manifest:
93 print(
94 "[FAIL] Ingress drift detected. Update scripts/audit_ingress_manifest.json and docs mapping.",
95 file=sys.stderr,
96 )
97 return 1
98
99 print("[OK] Ingress manifest matches setup/io PETSc option scan.")
100 return 0
101
102
int main(int argc, char **argv)