beam: Tarjan SCC iterative, brute-force verified
This commit is contained in:
1 parent
9a9061f71c
commit
7659e22493
9 files changed
+574
-38
No files matched your search
+59
-3
@@ -26,7 +26,7 @@ WHY THIS EXISTS
|
||||
|
||||
This tool grades the line so a fault is visible before it costs an iteration.
|
||||
|
||||
WHAT IT MEASURES -- SEVEN CLASSES, EACH WITH ITS RULE PRINTED
|
||||
WHAT IT MEASURES -- EIGHT CLASSES, EACH WITH ITS RULE PRINTED
|
||||
MISSING no line matches `^\\s*CHECK:`; the runner calls this RED at once.
|
||||
EMPTY a CHECK line with nothing after the colon.
|
||||
TAUTOLOGY the whole command is `true`, `:`, `exit 0`, `echo <literal>`,
|
||||
@@ -35,6 +35,12 @@ WHAT IT MEASURES -- SEVEN CLASSES, EACH WITH ITS RULE PRINTED
|
||||
true, `:`, `exit 0`, `echo`, `printf`, or a terminal statement
|
||||
`; true` / `; :` / `; exit 0` / `; echo ...`. Every path returns
|
||||
0, so the runner's GREEN carries no information.
|
||||
LABEL_PREFIX the command opens with a label, `word:` -- the line was written
|
||||
`CHECK: selftest: bash CHECK-x` or `CHECK: line: bash CHECK-x`.
|
||||
bash takes the whole first word as the command name, so the line
|
||||
dies with `word:: command not found` (rc 127) before anything is
|
||||
tested. Added 2026-11-02 after measuring the class on a live run:
|
||||
the same line shape RED'd one of this lane's own iterations.
|
||||
TRAILING_CR a literal carriage return survives at end of line; it reaches
|
||||
bash as part of the last word.
|
||||
PROSE_TAIL prose follows the command: an em dash, ` -- `, a trailing
|
||||
@@ -61,7 +67,7 @@ WHAT IT DOES NOT DO
|
||||
USAGE
|
||||
python3 check_lint.py --check "$CHECK"
|
||||
python3 check_lint.py --ralph-dir /root/.hermes/wizard-outputs/ralph
|
||||
python3 check_lint.py --selftest # 42 cells, one per class and edge
|
||||
python3 check_lint.py --selftest # 51 cells, one per class and edge
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -112,6 +118,22 @@ CATCH_ALL_RE = re.compile(
|
||||
r"|(?:(?<!&)(?<!\|)[;&]\s*(?:true|:|exit\s+0|echo\b|printf\b)(?:\s|$))"
|
||||
)
|
||||
|
||||
# A leading label: `selftest: python3 v.py`, `line: python3 v.py`, `Step-2: ...`.
|
||||
# bash takes the WHOLE first word as the command name, so a label makes the line
|
||||
# exit 127 with `word:: command not found` before a single test runs. Measured
|
||||
# 2026-11-02 rather than reasoned: a ralph iteration died on
|
||||
# `bash: line 1: selftest:: command not found` while this rubric read the line
|
||||
# SOUND, and the runner's own 2026-10-27 forge log carries the sibling shape
|
||||
# (`line: python3 ...`) one iteration before that CHECK was rewritten without it.
|
||||
#
|
||||
# The rule is anchored to the FIRST word and needs no space after the colon
|
||||
# (`ok:true` is the same defect), and it deliberately does not match:
|
||||
# `PATH=/a:/b python3 x.py` -- the `=` breaks the word class before the colon
|
||||
# `python3 x.py: --selftest` -- the colon is not in the first word
|
||||
# `'note: x' cmd` -- a quoted first token is not a bare word
|
||||
# The last two are pinned as SOUND cells so the boundary is measured, not assumed.
|
||||
LABEL_RE = re.compile(r"^(?P<label>[A-Za-z0-9][A-Za-z0-9_.+-]*):")
|
||||
|
||||
PROSE_MARKERS = [
|
||||
(re.compile(r"\s+[\u2014\u2013]\s+"), "em dash"),
|
||||
(re.compile(r"\s--\s+"), "spaced --"),
|
||||
@@ -128,7 +150,12 @@ PROSE_MARKERS = [
|
||||
# zero-exit constructs outrank the mechanical ones because they are the faults
|
||||
# that make a GREEN meaningless, while TRAILING_CR/PROSE_TAIL only make one
|
||||
# noisy (they break the run, loudly, and cost an iteration instead of lying).
|
||||
SEVERITY = ["EMPTY", "TAUTOLOGY", "CATCH_ALL", "TRAILING_CR", "PROSE_TAIL"]
|
||||
# LABEL_PREFIX sits with the zero-exit group in rank, not in kind: it cannot
|
||||
# return 0 either, but it fails the other way round -- the run REDs for a reason
|
||||
# that has nothing to do with what was tested, so it is the first thing a reader
|
||||
# should be told when a line carries both a label and a prose tail.
|
||||
SEVERITY = ["EMPTY", "TAUTOLOGY", "CATCH_ALL", "LABEL_PREFIX", "TRAILING_CR",
|
||||
"PROSE_TAIL"]
|
||||
|
||||
|
||||
def prose_tail(core: str):
|
||||
@@ -167,6 +194,14 @@ def classify(cmd: str | None):
|
||||
faults.append("CATCH_ALL")
|
||||
detail["catch_all_match"] = m_catch.group(0)
|
||||
|
||||
m_label = LABEL_RE.match(core.lstrip())
|
||||
if m_label:
|
||||
faults.append("LABEL_PREFIX")
|
||||
detail["label"] = m_label.group("label")
|
||||
# The cut point, printed the way PROSE_TAIL prints its own: what the
|
||||
# line would say with the label removed, which is what bash needs.
|
||||
detail["command_after_label"] = core.lstrip()[m_label.end():].strip()
|
||||
|
||||
pt = prose_tail(core)
|
||||
if pt:
|
||||
faults.append("PROSE_TAIL")
|
||||
@@ -302,6 +337,10 @@ def grade_run(run: dict) -> dict:
|
||||
cross = "GREEN_BY_CONSTRUCTION"
|
||||
elif final == "GREEN" and primary in ("PROSE_TAIL", "TRAILING_CR"):
|
||||
cross = "GREEN_DESPITE_FORMATTING"
|
||||
# LABEL_PREFIX is deliberately in neither arm: a labelled line exits 127 at
|
||||
# the shell, so a runner cannot have reported it GREEN. If one ever did, the
|
||||
# run is reported with cross="none" and the class printed, rather than being
|
||||
# folded into a bucket whose meaning it would dilute.
|
||||
|
||||
per_iteration = []
|
||||
for n in sorted(iters):
|
||||
@@ -393,6 +432,22 @@ FIXTURES = [
|
||||
("CHECK: python3 x.py\n\nA CHECK: line is required.\n", "SOUND"),
|
||||
("CHECK: python3 x.py\n\n CHECK: line \u2014 one shell command that verifies "
|
||||
"your work and exits 0\n", "PROSE_TAIL"),
|
||||
# LABEL_PREFIX cells (2026-11-02, volt). The first two are the measured
|
||||
# shapes: cell 1 is the line this lane's own ralph iteration died on
|
||||
# (`bash: line 1: selftest:: command not found`), cell 2 is the one the
|
||||
# runner's 2026-10-27 forge log carries, one iteration before that CHECK was
|
||||
# rewritten without the label. The four controls pin the boundary of the
|
||||
# rule: a colon that is not in the FIRST word, a colon inside an assignment,
|
||||
# and a quoted first token are all SOUND.
|
||||
("CHECK: selftest: python3 tools/check_lint.py --selftest\n", "LABEL_PREFIX"),
|
||||
("CHECK: line: python3 tools/check_lint.py --selftest\n", "LABEL_PREFIX"),
|
||||
("CHECK: Verdict: bash CHECK-x\n", "LABEL_PREFIX"), # capitalised
|
||||
("CHECK: step-2: python3 x.py\n", "LABEL_PREFIX"), # hyphenated
|
||||
("CHECK: 2026-11-02: python3 x.py\n", "LABEL_PREFIX"), # date label
|
||||
("CHECK: ok:true\n", "LABEL_PREFIX"), # no space after
|
||||
("CHECK: python3 x.py: --selftest\n", "SOUND"), # colon, word 2
|
||||
("CHECK: PATH=/a:/b python3 x.py\n", "SOUND"), # assignment
|
||||
("CHECK: 'note: x' cmd\n", "SOUND"), # quoted token
|
||||
]
|
||||
|
||||
EXTRACT_FIXTURES = [
|
||||
@@ -435,6 +490,7 @@ def print_rules():
|
||||
print(" EMPTY a CHECK line with nothing after the colon")
|
||||
print(" TAUTOLOGY whole command is true/: /exit 0/echo/printf/sleep")
|
||||
print(" CATCH_ALL a || arm or terminal ; statement that exits 0 regardless")
|
||||
print(" LABEL_PREFIX a leading `word:` label -- bash exits 127 on it")
|
||||
print(" TRAILING_CR a literal carriage return survives at end of line")
|
||||
print(" PROSE_TAIL prose follows the command (CANDIDATE, cut point printed)")
|
||||
print(" SOUND none of the above -- not a promise about its meaning")
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
append_only_audit.py 18 cells
|
||||
append_only_owners.py 15 cells
|
||||
census_row_delta.py 37 cells
|
||||
check_lint.py 42 cells
|
||||
check_lint.py 51 cells
|
||||
checkin_check.py 36 cells
|
||||
citation_hash_class.py 19 fixtures
|
||||
citation_resolve_check.py 14 fixtures
|
||||
|
||||
|
Reference in new issue
Block a user