import re
from IPython.display import Markdown
from spotregen.checks import CHECKS
MAPPING = [
("ARCH00", "package file does not parse", "COMPILE01"),
("ARCH01", "forbidden import", "COMPILE02"),
("ARCH02", "subpackage not in `[allowed]`", "COMPILE03"),
("ARCH03", "listed subpackage not found", "COMPACT01"),
("ARCH03", "allowed edge unused", "COMPACT02"),
("ARCH04", "new import cycle", "COMPILE04"),
("ARCH05", "known cycle gone", "COMPACT03"),
("UNIT01", "implementation does not exist", "COMPILE05"),
("UNIT01", "implementation does not parse", "`COMPILE01` (also from the unit check)"),
("UNIT02", "`path` is not the module", "removed: the path is derived"),
("UNIT03", "public name not defined", "COMPILE06"),
("UNIT04", "import not in `depends_on`", "COMPILE07"),
("UNIT05", "`depends_on` entry not imported", "COMPACT04"),
("UNIT06", "no intent item", "INTENT01"),
("EVAL01", "evaluation file does not exist", "EVAL01"),
("EVAL01", "evaluation file does not parse", "EVAL02"),
("EVAL01", "named evaluation not found", "EVAL03"),
("EVAL02", "file not marked `regen`", "EVAL04"),
("EVAL03", "evaluation imports a non-public name", "EVAL05"),
("EVAL04", "intent item names no evaluation", "INTENT02"),
("EVAL05", "evaluation not linked to intent", "COMPACT05"),
("PROV01", "intent item cites an unknown decision", "PROV01"),
("PROV01", "architecture cites an unknown decision", "PROV02"),
("PROV02", "`file:` evidence missing", "PROV03"),
("PROV02", "`commit:` evidence missing", "PROV04"),
("PROV02", "unknown evidence prefix", "PROV05"),
("PROV03", "review due", "PROV06"),
("PROV04", "rests on a non-active decision", "PROV07"),
("PROV05", "decision cited by nothing", "COMPACT06 (active decisions only)"),
("PROV06", "stale run: bundle", "PROV08"),
("PROV06", "stale run: module", "PROV09"),
("PROV06", "unparsable `run.toml` (reported per unit)", "PROV10 (once, at its own path)"),
("DEL01", "undeclared dependent", "DELETE01"),
("DEL02", "declared consumer missing", "DELETE02"),
("DEL03", "consumer no longer references the unit", "COMPACT07"),
]
known = {i for i, _, _ in CHECKS}
assert {i for _, _, new in MAPPING for i in re.findall(r"[A-Z]+\d\d", new)} <= known
rows = ["| 0.12 | condition | now |", "|:--|:--|:--|"]
rows += [f"| {old} | {what} | {new} |" for old, what, new in MAPPING]
Markdown("\n".join(rows))