from __future__ import annotations

import argparse
from pathlib import Path

import yaml


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--strict", action="store_true")
    args = parser.parse_args()
    canonical = yaml.safe_load(Path("spec/12_field_dictionary.yaml").read_text(encoding="utf-8"))
    mirror = yaml.safe_load(Path("spec/fields/field_dictionary.yaml").read_text(encoding="utf-8"))
    fields = canonical.get("field_dictionary", {}).get("fields", {})
    if not fields or mirror.get("source_of_truth") != "spec/12_field_dictionary.yaml":
        print("FAIL")
        return 1
    print("FIELD_DICTIONARY_OK")
    print(f"field_count={len(fields)}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

