# FIRST attempt: "each technique belongs to exactly one tactic". Kept for the write-up.
import json
chain = json.load(open("data/attack_chain.json"))["stages"]
seen, problems = {}, 0
for s in chain:
    for tid, name in s["techniques"]:
        base = tid.split(".")[0]
        if base in seen and seen[base] != s["tactic_id"]:
            print(f"[ERROR] {tid} {name}: stage {s['n']} says {s['tactic_id']} but earlier stage said {seen[base]}"); problems += 1
        seen.setdefault(base, s["tactic_id"])
print("problems:", problems)
