#!/usr/bin/env python3 """Job #4489 (route 141 step check): does any return on record answer the step? The step (set by #1822) has two halves: (a) map the 17 route-114 queue rows #1453 SKIPPED to served corpus paths by content ("preimage matching" of each hunk's context/'-' lines), then `git apply --check --include` each against the matched path and its /history versions; (b) for the 4 MOVED rows (#12, #30, #97, #132) do `git merge-file current ` and label each clean-merge or conflict with named hunks. This script does not run any of that. It reads the fetched return pages and reports, per return, which of the step's decisive phrases occur, with context, so the comparison is inspectable rather than asserted. """ import glob import os import re import sys HERE = os.path.dirname(os.path.abspath(__file__)) SRC = os.path.normpath(os.path.join(HERE, "..", "..", "sources")) RETURNS = [1453, 1822, 1455, 1460, 1987, 1982, 1891, 1837, 1828] # phrases that only the step's own work would produce PROBES = [ ("preimage", r"preimage"), ("git apply --check", r"git apply --check"), ("--include", r"--include"), ("merge-file", r"merge[- ]file"), ("3-way/thre-way", r"three[- ]way|3[- ]way"), ("recovered base", r"recovered base|recover(?:ed|y) (?:its|the) base"), ("skipped row", r"skipped\s+row|rows? (?:that )?#?1453 skipped|skipped\b"), ("17 rows", r"\b17\b"), ("route-114", r"route[- ]114"), ("patch_hash", r"patch_hash"), ("content-address", r"content[- ]address"), ("queue", r"queue"), ("#1453", r"#?1453"), ("served-listing", r"served-listing"), ("history endpoint", r"/history"), ] def page(r): hits = glob.glob(os.path.join(SRC, "ret%d" % r, "*.txt")) if not hits: return None return open(hits[0], encoding="utf-8").read() print("%-8s %s" % ("return", "probe hits (count)")) corpus = {} for r in RETURNS: t = page(r) if t is None: print("%-8d MISSING" % r) continue corpus[r] = t row = [] for name, rx in PROBES: n = len(re.findall(rx, t, re.I)) if n: row.append("%s:%d" % (name, n)) print("%-8d %s" % (r, ", ".join(row) if row else "(none)")) print() print("=== context for the decisive probes, per return ===") for r in RETURNS: t = corpus.get(r) if t is None: continue print("\n--- return #%d (%d chars) ---" % (r, len(t))) shown = set() for name, rx in PROBES: if name in ("queue", "#1453", "17 rows", "history endpoint", "route-114"): continue for m in re.finditer(rx, t, re.I): ctx = re.sub(r"\s+", " ", t[max(0, m.start() - 130):m.end() + 130]) key = ctx[:80] if key in shown: continue shown.add(key) print(" [%s] ...%s..." % (name, ctx)) if len(shown) > 26: break sys.exit(0)