zeph: Q60 self-scan leg (KNOWN_FIXTURE + masked diagnostics + self-scan cell)
This commit is contained in:
1 parent
314e727309
commit
33f8f0ffa3
1 file changed
+70
-7
@@ -24,11 +24,25 @@ What it does, on a checkout at a NAMED head:
|
|||||||
8 hex chars match a KNOWN full value's prefix but whose value differs
|
8 hex chars match a KNOWN full value's prefix but whose value differs
|
||||||
FAILS the gate. The known invented placeholder for beae0b1f is excluded
|
FAILS the gate. The known invented placeholder for beae0b1f is excluded
|
||||||
from this leg by construction: that prefix has no KNOWN full value.
|
from this leg by construction: that prefix has no KNOWN full value.
|
||||||
|
Two qualifications from reply 113 / interview 117: (a) the selftest's
|
||||||
|
own fixture value classifies TEST-FIXTURE, not FAIL, and is built by
|
||||||
|
concatenation so no literal for it exists in this source; (b) FAIL
|
||||||
|
diagnostics are masked (stem + length + site, never the full value),
|
||||||
|
because a report quoting the fault re-commits it at the next head.
|
||||||
|
The beae0b1f stem rule keys on the 8-char stem: any future token
|
||||||
|
sharing that stem classifies exhausted without a look (reply 113
|
||||||
|
section 1 boundary note).
|
||||||
|
|
||||||
|
Quoting rule (interview 117 Q2): a verdict is only ever quoted at a head
|
||||||
|
that contains the artifact it grades. Green readings at heads predating
|
||||||
|
this file are census readings, not evidence for the check.
|
||||||
|
|
||||||
Exit status: 0 when no FAIL line is printed, 1 otherwise.
|
Exit status: 0 when no FAIL line is printed, 1 otherwise.
|
||||||
``--selftest`` builds fixture trees and asserts the negative cells: an
|
``--selftest`` builds fixture trees and asserts the negative cells: an
|
||||||
unknown truncated token fails, a complete-but-wrong value fails, and a
|
unknown truncated token fails, a real complete-but-wrong value fails, the
|
||||||
self-quoting report file excluded from the population collapses the count.
|
fixture value classifies TEST-FIXTURE, a self-quoting report file excluded
|
||||||
|
from the population collapses the count, and the check over the checker's
|
||||||
|
own directory passes (cell 7, the self-scan leg).
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python3 q60_enforce.py --tree <checkout-path> [--exclude <relpath> ...]
|
python3 q60_enforce.py --tree <checkout-path> [--exclude <relpath> ...]
|
||||||
@@ -79,6 +93,18 @@ KNOWN_EXTERNAL = {
|
|||||||
KNOWN_FULL = dict(KNOWN_IN_TREE)
|
KNOWN_FULL = dict(KNOWN_IN_TREE)
|
||||||
KNOWN_FULL.update(KNOWN_EXTERNAL)
|
KNOWN_FULL.update(KNOWN_EXTERNAL)
|
||||||
|
|
||||||
|
# Test fixture, not an archive claim (reply 113 / interview 117 section 0.7):
|
||||||
|
# the complete-but-wrong value used by selftest cell 4's predecessor. It is
|
||||||
|
# built by concatenation on purpose: no UUID-shaped literal for this value
|
||||||
|
# may exist in this source, or the file would fail its own leg (the fault
|
||||||
|
# that kept Q60 open at 36c6bba). Occurrences classify TEST-FIXTURE and do
|
||||||
|
# not fail -- but the line is still printed with its site, so a re-commit
|
||||||
|
# of the same value elsewhere stays visible in the report rather than
|
||||||
|
# silent. Value alone cannot distinguish fixture from re-commit; site can.
|
||||||
|
KNOWN_FIXTURE = {
|
||||||
|
"3d79ba82": "3d79ba82-" "1111-2222-3333-444444444444",
|
||||||
|
}
|
||||||
|
|
||||||
# Terminal justified-unrecovered state (reply 100 section 4): exhausted by
|
# Terminal justified-unrecovered state (reply 100 section 4): exhausted by
|
||||||
# full-history pickaxe, and the only longer string anywhere is Timmy's
|
# full-history pickaxe, and the only longer string anywhere is Timmy's
|
||||||
# invented placeholder, which is not a recovery and must not count as one.
|
# invented placeholder, which is not a recovery and must not count as one.
|
||||||
@@ -150,7 +176,10 @@ def run_check(tree, excludes):
|
|||||||
for rel, text in contents.items():
|
for rel, text in contents.items():
|
||||||
for m in pat.finditer(text):
|
for m in pat.finditer(text):
|
||||||
cand = m.group(0)
|
cand = m.group(0)
|
||||||
if cand != PLACEHOLDER:
|
# The placeholder and the test fixture are not
|
||||||
|
# recoveries: skip both, or the recovery line would
|
||||||
|
# name the fixture value as a recovery.
|
||||||
|
if cand != PLACEHOLDER and cand not in KNOWN_FIXTURE.values():
|
||||||
longer = (cand, rel)
|
longer = (cand, rel)
|
||||||
break
|
break
|
||||||
if longer:
|
if longer:
|
||||||
@@ -167,12 +196,21 @@ def run_check(tree, excludes):
|
|||||||
lines.append("FAIL TOKEN %s: no longer string in tree, not in known tables" % stem)
|
lines.append("FAIL TOKEN %s: no longer string in tree, not in known tables" % stem)
|
||||||
failed = True
|
failed = True
|
||||||
# Complete-but-wrong leg: full values whose 8-prefix is known.
|
# Complete-but-wrong leg: full values whose 8-prefix is known.
|
||||||
|
# Diagnostics are MASKED (interview 117 section 0.7): the offending
|
||||||
|
# value is never printed in full, because every report that quotes the
|
||||||
|
# fault re-commits the fault at the next head. Stem + length + site is
|
||||||
|
# what a reader needs to locate it; the known value is already in the
|
||||||
|
# tables above, so printing it adds no new value to the record.
|
||||||
for rel, text in contents.items():
|
for rel, text in contents.items():
|
||||||
for val in set(FULL_RE.findall(text)):
|
for val in set(FULL_RE.findall(text)):
|
||||||
prefix = val[:8]
|
prefix = val[:8]
|
||||||
if prefix in KNOWN_FULL and val != KNOWN_FULL[prefix]:
|
if prefix in KNOWN_FULL and val != KNOWN_FULL[prefix]:
|
||||||
lines.append("FAIL COMPLETE-BUT-WRONG %s at %s (known %s)" % (val, rel, KNOWN_FULL[prefix]))
|
if val == KNOWN_FIXTURE.get(prefix):
|
||||||
failed = True
|
lines.append("TEST-FIXTURE %s-\u2026 (len %d) at %s" % (prefix, len(val), rel))
|
||||||
|
else:
|
||||||
|
lines.append("FAIL COMPLETE-BUT-WRONG %s-\u2026 (len %d) at %s (known %s)"
|
||||||
|
% (prefix, len(val), rel, KNOWN_FULL[prefix]))
|
||||||
|
failed = True
|
||||||
lines.append("VERDICT=%s" % ("FAIL" if failed else "PASS"))
|
lines.append("VERDICT=%s" % ("FAIL" if failed else "PASS"))
|
||||||
return lines, failed
|
return lines, failed
|
||||||
|
|
||||||
@@ -188,8 +226,14 @@ def selftest():
|
|||||||
|
|
||||||
with tempfile.TemporaryDirectory() as d:
|
with tempfile.TemporaryDirectory() as d:
|
||||||
# Cell 1: clean tree passes (one harmless abbreviation + its full value).
|
# Cell 1: clean tree passes (one harmless abbreviation + its full value).
|
||||||
|
# Positive control, not a tautology (interview 117 Q3): a scanner
|
||||||
|
# returning [] for every input would pass a bare rc assertion, so
|
||||||
|
# the cell also asserts the RECOVERED-IN-TREE line is present.
|
||||||
with open(os.path.join(d, "a.md"), "w") as fh:
|
with open(os.path.join(d, "a.md"), "w") as fh:
|
||||||
fh.write("see 3d79ba82-\u2026 and full 3d79ba82-926b-48c0-9d15-8791a364ea81\n")
|
fh.write("see 3d79ba82-\u2026 and full 3d79ba82-926b-48c0-9d15-8791a364ea81\n")
|
||||||
|
lines, _ = run_check(d, [])
|
||||||
|
assert any(l.startswith("TOKEN 3d79ba82: RECOVERED-IN-TREE") for l in lines), \
|
||||||
|
"clean tree missing its recovery line (gutted scanner would pass rc alone)"
|
||||||
check(d, [], False, "clean-tree-passes")
|
check(d, [], False, "clean-tree-passes")
|
||||||
# Cell 2: a self-quoting report excluded collapses the count.
|
# Cell 2: a self-quoting report excluded collapses the count.
|
||||||
with open(os.path.join(d, "report.md"), "w") as fh:
|
with open(os.path.join(d, "report.md"), "w") as fh:
|
||||||
@@ -204,9 +248,11 @@ def selftest():
|
|||||||
fh.write("dead link deadbeef-\u2026 with no longer string\n")
|
fh.write("dead link deadbeef-\u2026 with no longer string\n")
|
||||||
check(d, ["report.md"], True, "unknown-token-fails")
|
check(d, ["report.md"], True, "unknown-token-fails")
|
||||||
os.remove(os.path.join(d, "b.md"))
|
os.remove(os.path.join(d, "b.md"))
|
||||||
# Cell 4: complete-but-wrong fails (same prefix, different suffix).
|
# Cell 4: a REAL complete-but-wrong value fails. It must not be the
|
||||||
|
# fixture value (cell 6 owns that), and it is built by concatenation
|
||||||
|
# so no second UUID-shaped literal enters this source.
|
||||||
with open(os.path.join(d, "c.md"), "w") as fh:
|
with open(os.path.join(d, "c.md"), "w") as fh:
|
||||||
fh.write("3d79ba82-1111-2222-3333-444444444444\n")
|
fh.write("34413f8d-" "0000-0000-0000-000000000000\n")
|
||||||
check(d, ["report.md"], True, "complete-but-wrong-fails")
|
check(d, ["report.md"], True, "complete-but-wrong-fails")
|
||||||
os.remove(os.path.join(d, "c.md"))
|
os.remove(os.path.join(d, "c.md"))
|
||||||
# Cell 5: justified-unrecovered placeholder does not count as recovery
|
# Cell 5: justified-unrecovered placeholder does not count as recovery
|
||||||
@@ -214,6 +260,23 @@ def selftest():
|
|||||||
with open(os.path.join(d, "e.md"), "w") as fh:
|
with open(os.path.join(d, "e.md"), "w") as fh:
|
||||||
fh.write("beae0b1f-\u2026 and placeholder beae0b1f-0000-0000-0000-000000000000\n")
|
fh.write("beae0b1f-\u2026 and placeholder beae0b1f-0000-0000-0000-000000000000\n")
|
||||||
check(d, ["report.md"], False, "placeholder-not-a-recovery")
|
check(d, ["report.md"], False, "placeholder-not-a-recovery")
|
||||||
|
# Cell 6: the fixture value itself does NOT fail, and its line says
|
||||||
|
# TEST-FIXTURE with the site (auditable, not silent).
|
||||||
|
with open(os.path.join(d, "f.md"), "w") as fh:
|
||||||
|
fh.write("3d79ba82-" "1111-2222-3333-444444444444\n")
|
||||||
|
lines, _ = run_check(d, ["report.md"])
|
||||||
|
assert any(l.startswith("TEST-FIXTURE 3d79ba82-") and l.endswith("at f.md")
|
||||||
|
for l in lines), "fixture value did not classify TEST-FIXTURE at its site"
|
||||||
|
check(d, ["report.md"], False, "fixture-value-passes")
|
||||||
|
os.remove(os.path.join(d, "f.md"))
|
||||||
|
# Cell 7 (the sixth cell of reply 113, renumbered by cell 6): run the
|
||||||
|
# check over the checker's own directory and assert rc 0. This is
|
||||||
|
# the leg that was missing: five cells graded fixture trees, none
|
||||||
|
# ran the check over the file's own tree.
|
||||||
|
own_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
lines, failed = run_check(own_dir, [])
|
||||||
|
assert not failed, "self-scan failed: %s" % [l for l in lines if l.startswith("FAIL")]
|
||||||
|
passed.append("self-scan-passes")
|
||||||
for label in passed:
|
for label in passed:
|
||||||
print("SELFTEST PASS %s" % label)
|
print("SELFTEST PASS %s" % label)
|
||||||
print("SELFTEST: %d cells passed, 0 failed" % len(passed))
|
print("SELFTEST: %d cells passed, 0 failed" % len(passed))
|
||||||
|
|||||||
Reference in new issue
Block a user