import json

json_path = r'C:\Repos\Websites-Data\green-guides\docs\Sources\citations\bmp_crosswalk.json'
with open(json_path, 'r', encoding='utf-8') as f:
    data = json.load(f)

data['error_register'] = [
    {
        "id": "ERR-001",
        "bmp_id": "bioretention",
        "parameter": "typical_ponding_depth",
        "era": "2026",
        "severity": "value_incorrect",
        "claimed_value": "6 in",
        "finding": (
            "BMP 9.7 specifies a maximum ponding depth of 12 in for flat-bottom "
            "systems and 18 in for sloped-bottom systems. No typical or recommended "
            "value of 6 in appears anywhere in the source text. The design examples "
            "use depths up to 12 in."
        ),
        "evidence_source": "Sources/BMP_2026/Markdown/2026_BMP_9_7_Small_Scale_Bioretention_Systems.md",
        "evidence_quote": (
            "For the WQDS, the maximum depth of runoff is 12 inches in a "
            "flat-bottom bioretention system when designed in accordance with "
            "the other design criteria found in this chapter."
        ),
        "evidence_page": "p7",
        "suggested_correction": (
            'Replace "6 in" with "12 in max (flat-bottom); 18 in max (sloped-bottom)" '
            "or remove the parameter if no typical value is warranted."
        ),
        "status": "open",
        "logged_date": "2026-04-09"
    },
    {
        "id": "ERR-002",
        "bmp_id": "dry-well",
        "parameter": "foundation_setback",
        "era": "2026",
        "severity": "value_unsourced",
        "claimed_value": ">= 10 ft",
        "finding": (
            "BMP 9.2 states dry wells shall comply with all applicable setback laws "
            "but does not specify a numeric building setback. NJAC 7:9A-4.3 Table 4.3 "
            "shows a dash (no requirement) for dry well to occupied building. NJAC "
            "7:9D-2.7 requires wells (water supply wells, not dry wells) to be >= 5 ft "
            "from buildings. The claimed >= 10 ft value is not found in any 2026 BMP "
            "or NJAC source."
        ),
        "evidence_source": "Sources/NJAC_2026/Markdown/njac7_9a_OCR.md",
        "evidence_quote": "Table 4.3 - Dry Well row, Occupied Building column: dash (no minimum specified)",
        "evidence_page": "p36 (Table 4.3)",
        "suggested_correction": (
            'Replace ">= 10 ft" with "No specific setback in BMP Manual or NJAC 7:9A; '
            'defer to local ordinance" or remove the parameter.'
        ),
        "status": "open",
        "logged_date": "2026-04-09"
    },
    {
        "id": "ERR-003",
        "bmp_id": "dry-well",
        "parameter": "septic_setback",
        "era": "2026",
        "severity": "value_incorrect",
        "claimed_value": ">= 10 ft",
        "finding": (
            "BMP 9.2 defers to applicable laws. NJAC 7:9A-4.3 Table 4.3 specifies "
            "a dry well to disposal field separation of 50 ft (not 10 ft). The "
            "claimed >= 10 ft value contradicts the actual regulatory minimum of 50 ft."
        ),
        "evidence_source": "Sources/NJAC_2026/Markdown/njac7_9a_OCR.md",
        "evidence_quote": "Table 4.3 - Dry Well row, Disposal Field column: 50; Existing Seepage Pit or Cesspool column: 50",
        "evidence_page": "p36 (Table 4.3)",
        "suggested_correction": (
            'Replace ">= 10 ft" with ">= 50 ft per NJAC 7:9A-4.3 Table 4.3 '
            '(disposal field and seepage pit)".'
        ),
        "status": "open",
        "logged_date": "2026-04-09"
    }
]

data['meta']['error_register_count'] = 3

with open(json_path, 'w', encoding='utf-8') as f:
    json.dump(data, f, indent=2, ensure_ascii=False)

print("Added 3 error register entries.")
