tools(v4): mkpost --all -- v3's whole POST as a table, measured on v4: 849 of 1020 (#189)

v4/tools/mkpost.py --all --out FILE: every case of v3's whole POST (its 22 POST modules in test_runner.c's
order, Q48, stress, integration), v3 the reference, without touching system/post_cases.c or its document.
Run on Hera in the kernel's fabric after Phase 7 Task 4: 1020 cases, 849 pass, 171 fail -- by word and kind
in docs/v4.0.0/POST-PARITY.md section 5. Not pushed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-14 01:34:01 +00:00
parent c64c70bdb7
commit fa5a5c7096
2 changed files with 44 additions and 5 deletions
+22 -5
View File
@@ -55,6 +55,14 @@ MODULES = [
"system_words_test.c", "defining_words_tests.c", "control_words_test.c",
]
# v3's whole POST (Captain Bob, 2026-11-13: Phase 7 is accepted on "v3's whole POST"): test_modules[] in
# v3/src/test_runner/test_runner.c, in its order, then the modules it runs besides.
MODULES_ALL = MODULES + [
"starforth_words_test.c", "acl_words_test.c", "mama_forth_words_test.c",
"inference_words_test.c", "physics_freeze_words_test.c",
"q48_words_test.c", "stress_tests.c", "integration_tests.c",
]
# The FORTH-79 Standard's Required Word Set, by the standard's own groups.
# Written from the standard's word list; check it against the document
# before relying on it for a claim of compliance.
@@ -307,12 +315,19 @@ def main():
ap.add_argument("--v3", default=os.path.join(ROOT, "lfs", "amd64", "starforth"))
ap.add_argument("--report", default=None)
ap.add_argument("--dump", default=None, help="write what v3 did with every case")
ap.add_argument("--all", action="store_true",
help="every case of v3's whole POST, every module and word, not the Required set alone "
"(#189 Phase 7, Task 8: the measure of parity); with --out, and no document written")
ap.add_argument("--out", default=None, help="write the table here, not system/post_cases.c")
args = ap.parse_args()
global OUTPUT
if args.out:
OUTPUT = os.path.abspath(args.out)
required, left_out, cases, seen = set(REQUIRED), [], [], {}
for module in MODULES:
for module in (MODULES_ALL if args.all else MODULES):
for word, name, text, should_error in read_module(os.path.join(MODULE_DIR, module)):
if word not in required:
if word not in required and not args.all:
continue
label = ("%s.%s" % (word, name))[:31]
seen[label] = seen.get(label, 0) + 1
@@ -396,7 +411,7 @@ def main():
emit(rule["label"], lines, expectation(rule.get("error", False), rule.get("stack", []), rule.get("out", "")))
applied["extra"] += 1
unknown = [k for k in list(rules.STANDARD) + list(rules.ADDRESS) if k not in {c["label"] for c in cases}]
assert not unknown, "rules for cases that do not exist: %s" % unknown
assert args.all or not unknown, "rules for cases that do not exist: %s" % unknown
if args.dump:
open(args.dump, "w").write("\n".join(dump))
write_table(table)
@@ -405,7 +420,8 @@ def main():
untested = [w for w in REQUIRED if w not in set(tested)]
dropped = sum(1 for v in rules.STANDARD.values() if v is None)
total = len(cases) - dropped + len(rules.EXTRA)
assert total == len(table), (total, len(table))
assert args.all or total == len(table), (total, len(table))
total = len(table)
report = ["POST cases: %d, in %s" % (total, os.path.relpath(OUTPUT, ROOT)),
" from v3 unchanged: %d" % (len(cases) - applied["address"] - applied["standard"]),
" from v3, address-dependent (post79_rules.ADDRESS): %d" % applied["address"],
@@ -418,7 +434,8 @@ def main():
report += ["", "v3 did not do what its own table expects (%d):" % len(disagreements)]
report += [" %-32s %s" % item for item in disagreements]
text = "\n".join(report) + "\n"
write_doc(cases, results, left_out, disagreements, untested, total, applied, dropped)
if not args.all:
write_doc(cases, results, left_out, disagreements, untested, total, applied, dropped)
if args.report:
open(args.report, "w").write(text)
sys.stdout.write(text)