"""Reason codes owned by this bundle. Three groups, per SPECIFICATION.md section 9: session codes, preflight codes raised by the workspace admission check, and catalog codes raised by entry preconditions. Kernel codes are imported from the kernel when a kernel is present and are never restated here. """ from typing import Dict # Session and node codes. SESSION_CODES = ( "NODE_TIMEOUT", "NONSENSE_REPLAY", "CHECKER_ABSTAIN", "NOT_UNDERSTOOD", "AMBIGUOUS_TARGET", "ALREADY_APPLIED", "PROTECTED_PATH", "LINKED_PATH_IN_WORKSPACE", "NO_TEST_ANCHOR", "ASSERTION_REMOVED", "OUT_OF_CATALOG", "NO_MATCH", "NO_EDIT", "SEARCH_NOT_FOUND", ) # Preflight codes: workspace admission, checked before any node runs (section 1.1). PREFLIGHT_CODES = ( "NO_TEST_FILE", "TAB_INDENTED_TARGET", "CRLF_TARGET", "NOT_ASCII_TARGET", "DYNAMIC_REACH", "GENERATED_TARGET", ) # Lock codes raised by the gates. GATE_CODES = ( "PAIR_DISHONEST", "SHAPE_STILL_PRESENT", "SUITE_RED", "LEXICON_INCOMPLETE", "CATALOG_INTEGRITY", "CATALOG_CONFLICT", "CONFINEMENT", ) #: Every code this bundle may raise. ALL_CODES: Dict[str, str] = {} for _group, _name in ((SESSION_CODES, "session"), (PREFLIGHT_CODES, "preflight"), (GATE_CODES, "gate")): for _code in _group: ALL_CODES[_code] = _group and _name or "session" def group_of(code: str) -> str: return ALL_CODES.get(code, "unknown") def is_known(code: str) -> bool: return code in ALL_CODES