From db7b00d74eb1d71beea7de28a9d7e738f44d76d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 15:17:48 +0000 Subject: [PATCH] Mirror the withdrawn-claims register from ad-res-j7 (2026-10-27): 13 new claims Copies ad-res-j7's canonical register (28 claims; adds rst-is-the-manufacturer, slg-is-a-warehouse, strategic-logistics-group and the ten corrected figures of 2026-10-27) and its checker, which now also catches a claim hard-wrapped across the lines of one prose paragraph. Where the banner tool found files carrying a claim, they are bannered; zonent/ mirror copies are left to the zonent sync. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RDB1UaJwokY8cw2E1M2fvp --- ANALYSIS_REFINEMENTS.md | 1 + EXECUTIVE_SUMMARY.md | 1 + ...mA Worldwide Distribution (Pty) Ltd(2).txt | 5 + ...egimA Worldwide Distribution (Pty) Ltd.txt | 5 + data_models/DATA_ACQUISITION_STRATEGY.md | 1 + data_models/EXECUTIVE_SUMMARY.md | 1 + .../IMPROVEMENTS_AND_RECOMMENDATIONS.md | 1 + docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json | 110 +++++++++++++++++- scripts/check_withdrawn_claims.py | 93 +++++++++++++-- 9 files changed, 205 insertions(+), 13 deletions(-) diff --git a/ANALYSIS_REFINEMENTS.md b/ANALYSIS_REFINEMENTS.md index 7b1169e..5018cfd 100644 --- a/ANALYSIS_REFINEMENTS.md +++ b/ANALYSIS_REFINEMENTS.md @@ -1,6 +1,7 @@ > ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-10).** Do not reuse them; use the corrections: > - corrected (`stock-stolen`): The R5,241,372.98 SLG write-off is an accounting residue (no FY2025 manufacture journal; 96.62% reconciled, GL-confirmed). Do not plead it as stolen or missing goods. +> - corrected (`strategic-logistics-group`): 'Strategic Logistics Group' is not the entity's name; it is Strategic Logistics CC (SLG), the manufacturing principal. > Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). # Revenue Stream Data Model Analysis & Refinements diff --git a/EXECUTIVE_SUMMARY.md b/EXECUTIVE_SUMMARY.md index 77b429f..3dd771b 100644 --- a/EXECUTIVE_SUMMARY.md +++ b/EXECUTIVE_SUMMARY.md @@ -1,6 +1,7 @@ > ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-10).** Do not reuse them; use the corrections: > - corrected (`stock-stolen`): The R5,241,372.98 SLG write-off is an accounting residue (no FY2025 manufacture journal; 96.62% reconciled, GL-confirmed). Do not plead it as stolen or missing goods. +> - corrected (`strategic-logistics-group`): 'Strategic Logistics Group' is not the entity's name; it is Strategic Logistics CC (SLG), the manufacturing principal. > Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). # Revenue Stream Data Model Analysis: Executive Summary diff --git a/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd(2).txt b/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd(2).txt index 3d011dd..57801ee 100644 --- a/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd(2).txt +++ b/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd(2).txt @@ -1,3 +1,8 @@ +# withdrawn-claims-banner +# ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-28).** Do not reuse them; use the corrections: +# - corrected (`rst-is-the-manufacturer`): RST is not the manufacturer and never manufactured; SLG (Strategic Logistics CC) is the manufacturing principal and RST buys stock from it. Bank, customs and DR H's own books decide this, not the group's accounts (fincosys-core `reports/parties/SLG_RST_ATTRIBUTION.md`). +# Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). + From: "Daniel Faucitt" Sent: 14/10/2025 13:51:15 To: "Natan Back" ; "Doron Block" diff --git a/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd.txt b/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd.txt index ab13013..ce7fdee 100644 --- a/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd.txt +++ b/TODO-SEARCH/txt/regima.com/dan@regima.com/Re_ Evidence - Invoice Payments - RegimA Worldwide Distribution (Pty) Ltd.txt @@ -1,3 +1,8 @@ +# withdrawn-claims-banner +# ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-28).** Do not reuse them; use the corrections: +# - corrected (`rst-is-the-manufacturer`): RST is not the manufacturer and never manufactured; SLG (Strategic Logistics CC) is the manufacturing principal and RST buys stock from it. Bank, customs and DR H's own books decide this, not the group's accounts (fincosys-core `reports/parties/SLG_RST_ATTRIBUTION.md`). +# Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). + From: "Daniel Faucitt" Sent: 15/10/2025 16:35:22 To: "Natan Back" ; "Doron Block" diff --git a/data_models/DATA_ACQUISITION_STRATEGY.md b/data_models/DATA_ACQUISITION_STRATEGY.md index 4719e89..c21503c 100644 --- a/data_models/DATA_ACQUISITION_STRATEGY.md +++ b/data_models/DATA_ACQUISITION_STRATEGY.md @@ -1,6 +1,7 @@ > ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-10).** Do not reuse them; use the corrections: > - corrected (`stock-stolen`): The R5,241,372.98 SLG write-off is an accounting residue (no FY2025 manufacture journal; 96.62% reconciled, GL-confirmed). Do not plead it as stolen or missing goods. +> - corrected (`strategic-logistics-group`): 'Strategic Logistics Group' is not the entity's name; it is Strategic Logistics CC (SLG), the manufacturing principal. > Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). # Data Acquisition Strategy: Missing Entities and Events diff --git a/data_models/EXECUTIVE_SUMMARY.md b/data_models/EXECUTIVE_SUMMARY.md index 83d0cb6..a098194 100644 --- a/data_models/EXECUTIVE_SUMMARY.md +++ b/data_models/EXECUTIVE_SUMMARY.md @@ -1,6 +1,7 @@ > ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-10).** Do not reuse them; use the corrections: > - corrected (`stock-stolen`): The R5,241,372.98 SLG write-off is an accounting residue (no FY2025 manufacture journal; 96.62% reconciled, GL-confirmed). Do not plead it as stolen or missing goods. +> - corrected (`strategic-logistics-group`): 'Strategic Logistics Group' is not the entity's name; it is Strategic Logistics CC (SLG), the manufacturing principal. > Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). # Executive Summary: Data Model Analysis and Refinement diff --git a/data_models/IMPROVEMENTS_AND_RECOMMENDATIONS.md b/data_models/IMPROVEMENTS_AND_RECOMMENDATIONS.md index de384ec..abf4a7c 100644 --- a/data_models/IMPROVEMENTS_AND_RECOMMENDATIONS.md +++ b/data_models/IMPROVEMENTS_AND_RECOMMENDATIONS.md @@ -1,6 +1,7 @@ > ⛔ **This file contains claims since withdrawn or corrected (flagged 2026-10-10).** Do not reuse them; use the corrections: > - corrected (`stock-stolen`): The R5,241,372.98 SLG write-off is an accounting residue (no FY2025 manufacture journal; 96.62% reconciled, GL-confirmed). Do not plead it as stolen or missing goods. +> - corrected (`strategic-logistics-group`): 'Strategic Logistics Group' is not the entity's name; it is Strategic Logistics CC (SLG), the manufacturing principal. > Register and sources: `docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json` (cogpy/ad-res-j7). # Improvements and Recommendations for Revenue Stream Hijacking Case Data Models diff --git a/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json b/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json index 172badd..8037c29 100644 --- a/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json +++ b/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json @@ -1,6 +1,7 @@ { "description": "Claims that were withdrawn or refuted after verification. scripts/check_withdrawn_claims.py fails any pull request that adds a line repeating one of them. A line is allowed when it cites the claim as withdrawn or corrected (see allow_line_markers), or sits on a verbatim or archive path (see allow_paths). Add a claim here the day it is withdrawn.", - "updated": "2026-10-19", + "updated": "2026-10-27", + "mirror_of": "cogpy/ad-res-j7 docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json (2026-10-27). ad-res-j7 is canonical: add claims there first, then copy.", "allow_line_markers": "(?i)withdrawn|refuted|\\bfalse\\b|corrected|correction|superseded|do not plead|don.t plead|do not cite|do not repeat|not established|\\bnot a director|struck|~~|⛔|if .{0,20}does(n.t| not) use", "allow_paths": [ "archive/", @@ -149,7 +150,110 @@ "withdrawn": "2026-10-19", "source": "docs/strategic/CROSS_REPO_FINDINGS_SYNC_2026_10_19.md §4; caselex-sync 2025-137857/ledger_baseline/12_PPM_CONVERSION_EVENTS_REGISTER.md §5.6", "banner": "The June 2021 Prime stock-take report is held (caselex-sync; net variance R22,782.59). Only the email archive lacks count sheets." + }, + { + "id": "rst-is-the-manufacturer", + "pattern": "(?i)(\\bRST\\b|RegimA Skin Treatments( CC)?)(\\s*\\((RegimA Skin Treatments|RST)\\))?\\**\\s*([(\\[|:—–-]||\\bis the\\b|\\boperated as the\\b|,\\s*the\\b)\\s*\\**\\s*(product |profitable )?manufactur(er|ing)(?!\\s*(cost|recovery|bill|journal|account|module))|manufacturer\\s*\\((RST|RegimA Skin Treatments)|\\bmanufacturer:\\**\\s*RegimA Skin Treatments|\\bRST manufactur(es|ing (staff|employees|output|practices|hub|entity))\\b|(\\bRST\\b|RegimA Skin Treatments)[^.\\n]{0,40}\\bmanufacturing source\\b", + "correction": "RST (RegimA Skin Treatments CC) has never manufactured. Strategic Logistics CC (SLG) is the manufacturing principal: it orders from and pays the contract manufacturer Prime Product Manufacturing (the bank shows SLG R40.4m against RST R20.3m, RST's last PPM payment in 2018), buys R23.9m of the R27.0m of raw materials and packaging, claims the input VAT, is named consignor on every customs record, and DR H's own books name it supplier 2017-2020. RST buys finished stock from SLG. The label began as the heading 'RST (Manufacturing Hub)' over an October 2025 analysis of the group's own trial balances (rzonedevops/analysis 6195a97), whose tables put the manufacture-cost accounts under SLG.", + "withdrawn": "2026-10-21", + "source": "case owner, 2026-10-21; fincosys/fincosys-core reports/parties/SLG_RST_ATTRIBUTION.md (§2a lineage) and reports/parties/SLG_RST_ATTRIBUTION_TIMELINE.md", + "banner": "RST is not the manufacturer and never manufactured; SLG (Strategic Logistics CC) is the manufacturing principal and RST buys stock from it. Bank, customs and DR H's own books decide this, not the group's accounts (fincosys-core `reports/parties/SLG_RST_ATTRIBUTION.md`)." + }, + { + "id": "slg-is-a-warehouse", + "pattern": "(?i)(\\bSLG\\b|Strategic Logistics)[^\\n]{0,80}(warehouse\\s*/\\s*logistics|warehouse, stock holding|third-party warehousing)|\\bSLG\\s*\\(warehouse\\)|Strategic Logistics[^.\\n]{0,30}\\b(is|as) (a |the )?(warehouse|logistics (provider|arm|company))", + "correction": "SLG (Strategic Logistics CC) is not a warehouse or logistics provider holding stock for RST/RWD. It is the group's manufacturing principal: it contracts and pays the manufacturer, buys the inputs, claims the input VAT and exports (fincosys-core SLG_RST_ATTRIBUTION). The 'warehouse / logistics' role was written by an AI session on 2026-03-23 (ad-res-j7 6d58947) with a cited source file held in no branch.", + "withdrawn": "2026-10-21", + "source": "case owner, 2026-10-21; fincosys/fincosys-core reports/parties/SLG_RST_ATTRIBUTION.md", + "banner": "SLG is not a warehouse/logistics entity holding stock for RST; it is the manufacturing principal (fincosys-core `reports/parties/SLG_RST_ATTRIBUTION.md`)." + }, + { + "id": "strategic-logistics-group", + "pattern": "(?i)Strategic Logistics Group", + "correction": "The entity is Strategic Logistics CC (SLG), registered as a close corporation. 'Strategic Logistics Group' is a name first written in rzonedevops/analysis on 2025-10-09 (2a2b763) and no record carries it.", + "withdrawn": "2026-10-21", + "source": "fincosys/fincosys-core reports/parties/SLG_RST_ATTRIBUTION.md §2a", + "banner": "'Strategic Logistics Group' is not the entity's name; it is Strategic Logistics CC (SLG), the manufacturing principal." + }, + { + "id": "bantjes-paid-from-df-savings", + "pattern": "(?i)(62089474309|DF (FNB )?savings)(?:[^.\\n]|\\.(?=\\d)){0,120}Bantj|Bantj(?:[^.\\n]|\\.(?=\\d)){0,120}(62089474309|DF (FNB )?savings)", + "correction": "FNB advices 92226T2F and S2SFGX6F are RST's own R5,000 payments to D J Bantjes of 30 Sep and 30 Nov 2019 (RST FNB 55270035642, statements 211 and 213). The DF savings debits of 3 Oct and 2 Dec 2019 went to DF's own current account and to RZI.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "The 2019 R5,000 payments to D J Bantjes came from RST, not from Daniel Faucitt's savings account." + }, + { + "id": "addarory-literal-1700493", + "pattern": "1,700,493\\.86|294,572\\.86|5,695,001\\.61", + "correction": "Literal-name Addarory payments: 8, R1,664,060.81 (SLG R1,405,921.00; RST 6 payments, R258,139.81). With the alias payments the channel total is R5,658,568.56.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "Literal-name Addarory payments are 8, R1,664,060.81 (RST: 6, R258,139.81)." + }, + { + "id": "prime-2023-2026-11234012", + "pattern": "11,234,012\\.25|2,943,973\\.26", + "correction": "SLG paid Prime R11,112,748.09 in 2023–2026; 2025: 8 payments, R2,822,709.10.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "SLG's Prime payments 2023–2026 are R11,112,748.09 (2025: R2,822,709.10)." + }, + { + "id": "proficos-2023-2026-1425844", + "pattern": "1,425,844\\.96", + "correction": "SLG paid Proficos R1,907,852.46 in 2023–2026; R1,425,844.96 omits the 29 Aug 2025 R482,007.50.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "SLG's Proficos payments 2023–2026 are R1,907,852.46." + }, + { + "id": "slg-fy2022-afs-inventory-6474658", + "pattern": "(?i)inventor(?:(?!bank|cash)[^\\n]){0,60}?6,474,658|6,474,658[*\\s]{0,4}(?:\\(\\s*|as\\s+)?inventor|FY\\s?2022(?:(?!FY\\s?20)[^\\n]){0,60}retained loss (of )?R?14,604", + "correction": "SLG's signed FY2022 AFS show inventory R8,344,000 and a loss for the year of R6,978; R6,474,658 is bank and cash and R14,604 the FY2021 loss.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "SLG FY2022 AFS: inventory R8,344,000, loss R6,978 (not R6,474,658 / R14,604)." + }, + { + "id": "sars-prov-653827-unmatched", + "pattern": "653,827\\.28", + "correction": "One RST provisional-tax payment of R326,913.64 on 25 Feb 2021, held as two notification copies (trace FB8Y946G).", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "The SARS PROV total is one RST payment of R326,913.64, not R653,827.28 unmatched." + }, + { + "id": "rwd-7700-2887676-aje", + "pattern": "(?i)2,887,676\\.80[^\\n]{0,60}(written|to zero|to nil|→ ?0|to R0)|(written|nil)[^\\n]{0,60}2,887,676\\.80", + "correction": "RWD's FY2020 AJE wrote 7700/000 Finished Goods of R141,163.95 to nil; R2,887,676.80 is in the workbook's first column pair.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "RWD's FY2020 finished-goods AJE was R141,163.95, not R2,887,676.80." + }, + { + "id": "rwd-sav-fy2425-4288883", + "pattern": "4,288,883\\.75", + "correction": "RWD savings 62836164880 paid out R5,288,883.75 in FY2024/25 (five transfers incl. R1,000,000 on 18 Apr 2024).", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "RWD savings FY2024/25 outflows are R5,288,883.75." + }, + { + "id": "slg-absa-main-flows-2025-26", + "pattern": "11,938,963\\.47|11,943,947\\.36|2,509,948\\.87|1,131,268\\.29|3,641,217\\.16|9,305,513\\.04", + "correction": "SLG ABSA 4112315016, stmts 15–27: R12,460,649.26 in (WWD R10,152,000.00; Reg R1,747,000.00; Strat Inv R302,000.00; card R259,649.26) and R12,466,083.15 out, per the printed account summaries. Appendix E distributors in that account: R2,716,901.04; others R1,836,535.21.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "SLG's ABSA main account flows are R12,460,649.26 in / R12,466,083.15 out (Appendix E distributors R2,716,901.04)." + }, + { + "id": "core-inventory-exposure-15611759", + "pattern": "15,611,759\\.72", + "correction": "No core inventory-exposure total survives: the RWD row is R141,163.95, the FY2020 Boxes divergence was refuted on 2026-09-22, and R5,241,372.98 is an accounting residue, not a loss. State each row on its own.", + "withdrawn": "2026-10-27", + "source": "docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md", + "banner": "The R15,611,759.72 'core inventory-fraud exposure' is withdrawn; no total survives." } - ], - "mirror_of": "cogpy/ad-res-j7 docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json (2026-10-10). ad-res-j7 is canonical: add claims there first, then copy." + ] } diff --git a/scripts/check_withdrawn_claims.py b/scripts/check_withdrawn_claims.py index 7998cf1..0f5c596 100644 --- a/scripts/check_withdrawn_claims.py +++ b/scripts/check_withdrawn_claims.py @@ -7,6 +7,7 @@ - --diff BASE: fails if lines added since BASE repeat a withdrawn claim (CI mode) - --report: counts the copies still in tracked files, per claim and per directory - Lines citing a claim as withdrawn or corrected, and verbatim/archive paths, are allowed +- A claim hard-wrapped across the lines of one prose paragraph (.md/.txt/.html) is caught too - --root DIR / --register FILE: scan another repository against this (or another) register """ import argparse @@ -20,6 +21,7 @@ ROOT = Path(__file__).resolve().parent.parent REGISTER = ROOT / "docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json" +PROSE_SUFFIXES = {".md", ".txt", ".html"} # hard-wrapped prose; data formats keep one field per line def load_register(): @@ -57,6 +59,54 @@ def violations(path, lines, claims, allow): for c in claims: if c["rx"].search(text): yield path, no, c, text.strip() + if Path(path).suffix.lower() in PROSE_SUFFIXES: + yield from wrapped_violations(path, {no for no, _ in lines}, claims, allow, struck) + + +BLOCK_START = re.compile(r"\s*([-*+]|\d+[.)]|#+)\s") # a list item or heading starts a new unit + + +def joinable(text): + """A line that continues prose: not blank, not a table row, not a code fence.""" + t = text.strip() + return bool(t) and not t.startswith(("|", "```")) + + +def wrapped_violations(path, wanted, claims, allow, struck): + """Claims hard-wrapped across lines of one paragraph, which no single line matches. + + Each paragraph (a run of joinable lines outside code fences; a list item or heading + starts a new one) holding a line in `wanted` is joined with spaces and searched + once per claim; only a match that crosses a join is reported, at its first line. It is skipped when a line it touches carries an allow marker, + is struck through, or repeats the claim on its own (the per-line check already + reports that), and reported only when it touches a line in `wanted`. + """ + paragraphs, run, fenced = [], [], False + for no, text in read_lines(path): + if text.strip().startswith("```"): + fenced = not fenced + if fenced or not joinable(text) or BLOCK_START.match(text): + paragraphs.append(run) + run = [] + if not fenced and joinable(text): + run.append((no, text.strip())) + paragraphs.append(run) + for group in paragraphs: + if len(group) < 2 or not wanted.intersection(no for no, _ in group): + continue + spans, pos = [], 0 + for no, text in group: + spans.append((no, text, pos, pos + len(text))) + pos += len(text) + 1 + joined = " ".join(text for _, text in group) + for c in claims: + for m in c["rx"].finditer(joined): + touched = [(no, text) for no, text, a, b in spans if a < m.end() and m.start() < b] + if len(touched) < 2 or not wanted.intersection(no for no, _ in touched): + continue + if any(no in struck or allow.search(t) or c["rx"].search(t) for no, t in touched): + continue + yield path, touched[0][0], c, " / ".join(t for _, t in touched) def added_lines(base): @@ -80,24 +130,44 @@ def tracked_files(): return [p for p in out.decode().split("\0") if p] +def prefilter_pattern(pattern): + """Loosen a claim pattern so it also matches when hard-wrapped (a superset, for ripgrep -U only).""" + pattern = re.sub(r"\(\?<[!=][^)]*\)", "", pattern) # lookbehinds would no longer be fixed-width + # the checks strip indentation before joining lines, so allow for it in bounded gaps + pattern = re.sub(r"\{(\d+),(\d+)\}", lambda m: "{%s,%d}" % (m.group(1), int(m.group(2)) + 200), pattern) + return pattern.replace("(?i)", "").replace("[^.\\n]", "[^.]").replace("[^\\n]", "[\\s\\S]").replace(" ", "\\s*") + + def candidate_files(reg, claims): - """Tracked files that may carry a claim: ripgrep prefilter when available, else every tracked file.""" + """Map each tracked file that may carry a claim to the line numbers worth checking. + + ripgrep runs the loosened patterns multiline and reports every line a possible + match touches, so the checks below only read those lines and their paragraphs. + Without ripgrep (or if it fails) every tracked file is checked in full (None). + """ tracked = tracked_files() import shutil import tempfile if not shutil.which("rg"): - return tracked - combined = "|".join("(?:%s)" % c["pattern"].replace("(?i)", "") for c in claims) + print("⚠️ ripgrep not found: checking every tracked file in full (slow)") + return dict.fromkeys(tracked) + combined = "|".join("(?:%s)" % prefilter_pattern(c["pattern"]) for c in claims) with tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False) as f: f.write(combined) globs = sum([["-g", g] for g in reg["file_globs"]], []) - r = subprocess.run(["rg", "-l", "-i", "-P", "--no-messages", "-f", f.name, *globs, "."], - cwd=str(ROOT), capture_output=True, text=True) + r = subprocess.run(["rg", "-n", "-i", "-P", "-U", "--null", "--no-heading", "--no-messages", + "-f", f.name, *globs, "."], cwd=str(ROOT), capture_output=True, text=True) Path(f.name).unlink() if r.returncode not in (0, 1): - return tracked - hits = {p[2:] if p.startswith("./") else p for p in r.stdout.splitlines() if p} - return [p for p in tracked if p in hits] + print(f"⚠️ ripgrep prefilter failed, checking every tracked file in full (slow): {r.stderr.strip()[:200]}") + return dict.fromkeys(tracked) + hits = collections.defaultdict(set) + for line in r.stdout.splitlines(): + p, _, rest = line.partition("\0") + no = rest.split(":", 1)[0] + if no.isdigit(): + hits[p[2:] if p.startswith("./") else p].add(int(no)) + return {p: hits[p] for p in tracked if p in hits} def read_lines(path): @@ -126,10 +196,13 @@ def run_diff(base, reg, claims, allow): def run_report(reg, claims, allow, out_path): per_claim, per_dir, rows = collections.Counter(), collections.Counter(), [] - for path in candidate_files(reg, claims): + for path, nos in candidate_files(reg, claims).items(): if not path_checked(path, reg): continue - for p, no, c, text in violations(path, read_lines(path), claims, allow): + lines = read_lines(path) + if nos is not None: + lines = [(no, text) for no, text in lines if no in nos] + for p, no, c, text in violations(path, lines, claims, allow): per_claim[c["id"]] += 1 per_dir[path.split("/")[0]] += 1 rows.append((c["id"], p, no))