File size: 2,474 Bytes
48f2b75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba784dc
da61666
48f2b75
 
 
 
 
 
ba784dc
da61666
48f2b75
 
 
f628309
 
 
48f2b75
 
f628309
 
 
 
 
 
48f2b75
f628309
 
 
 
 
 
 
 
 
 
48f2b75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""One registry of every reason code this bundle can answer with.

A verdict is only useful when its reason can be looked up. Every REFUSED and
every UNKNOWN result names one of these codes: the pattern cases anchor their
negative rows on them, the card lists all of them, and the self_lint gate
checks that the registry and the card agree so the two can never drift apart.
"""

from __future__ import annotations

from typing import Tuple

from lingologos_python import rules

# Refusals the session raises itself, before or around the six-node run.
PATH_POLICY = "PATH_POLICY"
PATCH_NOT_APPLIED = "PATCH_NOT_APPLIED"
NODE_TIMEOUT = "NODE_TIMEOUT"
LINKED_PATH_IN_WORKSPACE = "LINKED_PATH_IN_WORKSPACE"
HARDLINKED_PATH_IN_WORKSPACE = "HARDLINKED_PATH_IN_WORKSPACE"
SESSION_LOCKED = "SESSION_LOCKED"

SESSION_REASONS: Tuple[str, ...] = (
    PATH_POLICY,
    PATCH_NOT_APPLIED,
    NODE_TIMEOUT,
    LINKED_PATH_IN_WORKSPACE,
    HARDLINKED_PATH_IN_WORKSPACE,
    SESSION_LOCKED,
)

# Verdicts the codex kernel brings back when the gates fail or decline to answer.
# The six-node run answers with the kernel's own vocabulary; the registry holds
# every word of it that can arrive on a REFUSED or UNKNOWN line, so the promise
# that every refusal names a registered code survives the pipeline too.
GATE_REJECTED = "GATE_REJECTED"
GATE_ABSTAIN = "GATE_ABSTAIN"
GATE_MISSING = "GATE_MISSING"
CHECKER_REJECTED = "CHECKER_REJECTED"
CHECKER_ABSTAIN = "CHECKER_ABSTAIN"
NOT_APPLIED = "NOT_APPLIED"
PROTECTED_PATH = "PROTECTED_PATH"
NO_INDEPENDENT_CONFIRMATION = "NO_INDEPENDENT_CONFIRMATION"

KERNEL_REASONS: Tuple[str, ...] = (
    GATE_REJECTED,
    GATE_ABSTAIN,
    GATE_MISSING,
    CHECKER_REJECTED,
    CHECKER_ABSTAIN,
    NOT_APPLIED,
    PROTECTED_PATH,
    NO_INDEPENDENT_CONFIRMATION,
)

# The refusal the catalog layer adds above the rules: a scan found the card fits
# more than one target and the caller named none.
AMBIGUOUS_TARGET = "AMBIGUOUS_TARGET"

PATTERN_REASONS: Tuple[str, ...] = (AMBIGUOUS_TARGET,)

# Preflight and shape refusals of the pattern rules, collected from the rules
# module so the registry cannot fall behind the rules that raise them.
RULE_REASONS: Tuple[str, ...] = tuple(
    value
    for name, value in vars(rules).items()
    if name.isupper() and isinstance(value, str) and value == name
)

REASON_CODES = (
    frozenset(SESSION_REASONS)
    | frozenset(KERNEL_REASONS)
    | frozenset(PATTERN_REASONS)
    | frozenset(RULE_REASONS)
)