diff --git a/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json b/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json index 8037c29..4a80c37 100644 --- a/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json +++ b/docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json @@ -1,8 +1,14 @@ { - "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-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", + "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). Each claim carries must_match and must_not_match. The script refuses to run when a pattern misses a must_match form or matches a must_not_match correction. Add a claim here the day it is withdrawn, with both lists.", + "updated": "2026-11-03", + "mirror_of": "cogpy/ad-res-j7 docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json (2026-11-03). 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|not (?:shown to be )?an extraction", + "exemption_must_not_match": [ + "The R10.6M extraction was restated by counsel." + ], + "exemption_must_match": [ + "The R10,624,131.18 of 3 and 11 Sep 2025 is restated as transfers to savings, not an extraction." + ], "allow_paths": [ "archive/", "backups/", @@ -34,6 +40,12 @@ { "id": "commissioner-own-affidavit", "pattern": "(?i)(acted as|was|being) (the )?commissioner of oaths for (his )?own affidavit|commissioned his own affidavit", + "must_match": [ + "He acted as commissioner of oaths for his own affidavit." + ], + "must_not_match": [ + "Bantjies deposed while conflicted; Ms Hannelle Evert commissioned the affidavit." + ], "correction": "Bantjies' affidavit of 13 Aug 2025 was commissioned by Ms Hannelle Evert (SAIBA16721) at Pretoria. Allege that he deposed while irreconcilably conflicted.", "withdrawn": "2026-07-31", "source": "docs/strategic/REDTEAM_REVIEW_2026_07_31.md §2.2", @@ -42,6 +54,12 @@ { "id": "bantjies-ketoni-director", "pattern": "(?i)bantjies[^.\\n]{0,60}\\bdirector of ketoni|ketoni[^.\\n]{0,40}\\bdirector[^.\\n]{0,15}bantjies", + "must_match": [ + "Bantjies is a director of Ketoni." + ], + "must_not_match": [ + "Kevin Derrick is Ketoni's sole director. Bantjies is CFO of the George Group." + ], "correction": "Kevin Derrick is Ketoni's sole director. Bantjies is CFO of the George Group, where Derrick is also a director.", "withdrawn": "2026-08-01", "source": "docs/strategic/NEW_RECORDS_AND_CORRECTIONS_2026_08_01.md §7", @@ -50,6 +68,13 @@ { "id": "ketoni-debt", "pattern": "(?i)ketoni[^.\\n]{0,40}\\b(owes|owing)\\b|both ends of (the )?R18[.,]685|ketoni[^.\\n]{0,40}(?|\\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", + "must_match": [ + "RST was the manufacturing source for the group." + ], + "must_not_match": [ + "Prime Product Manufacturing is SLG's manufacturing source." + ], "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", @@ -162,6 +267,13 @@ { "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))", + "must_match": [ + "| SLG | Warehouse / logistics | R5.4M stock |" + ], + "must_not_match": [ + "Salco runs a warehouse/logistics operation in Cape Town.", + "SOLO provides third-party warehousing in the UK." + ], "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", @@ -170,6 +282,12 @@ { "id": "strategic-logistics-group", "pattern": "(?i)Strategic Logistics Group", + "must_match": [ + "Payments were booked to Strategic Logistics Group." + ], + "must_not_match": [ + "The entity is Strategic Logistics CC (SLG), a close corporation." + ], "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", @@ -178,6 +296,12 @@ { "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)", + "must_match": [ + "| ACC-BTN-2026-107796 | 2019-10-03 | **DF FNB Savings 62089474309** | −5,000.00 | 92226T2F | D J BANTJES |" + ], + "must_not_match": [ + "DF savings 62089474309 is held. Bantjes was paid by RST." + ], "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", @@ -186,6 +310,12 @@ { "id": "addarory-literal-1700493", "pattern": "1,700,493\\.86|294,572\\.86|5,695,001\\.61", + "must_match": [ + "Literal-name Addarory payments total R1,700,493.86." + ], + "must_not_match": [ + "Literal-name Addarory payments are R1,664,060.81." + ], "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", @@ -193,7 +323,15 @@ }, { "id": "prime-2023-2026-11234012", - "pattern": "11,234,012\\.25|2,943,973\\.26", + "pattern": "(?i)11,234,012\\.25|2,943,973\\.26|Prime[^.\\n]{0,40}\\bR11\\.23 ?M\\b|\\bR11\\.23 ?M\\b[^.\\n]{0,15}\\bPrime|\\bR11\\.23 ?M and R1\\.43 ?M\\b", + "must_match": [ + "SLG paid Prime R11.23M and Proficos R1.43M in 2023-2026.", + "The old total was R11,234,012.25.", + "refuted outright (R11.23M and R1.43M paid 2023-2026" + ], + "must_not_match": [ + "SLG paid Prime R11.11M and Proficos R1.91M." + ], "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", @@ -201,7 +339,14 @@ }, { "id": "proficos-2023-2026-1425844", - "pattern": "1,425,844\\.96", + "pattern": "(?i)1,425,844\\.96|Proficos[^.\\n]{0,40}\\bR1\\.43 ?M\\b|\\bR1\\.43 ?M\\b[^.\\n]{0,15}\\bProficos", + "must_match": [ + "R11.23M to Prime + R1.43M to Proficos.", + "The old Proficos total was R1,425,844.96." + ], + "must_not_match": [ + "SLG paid Prime R11.11M and Proficos R1.91M." + ], "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", @@ -210,6 +355,20 @@ { "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", + "must_match": [ + "SLG FY2022 AFS inventory R6,474,658.", + "inventory −642,704.68 vs 6,474,658", + "| Total inventory (7500–7750) | **−642,704.68** | **6,474,658** |", + "SLG FY2022 AFS: inventory **R6,474,658**.", + "SLG FY2022 AFS: retained loss R14,604." + ], + "must_not_match": [ + "SLG FY2022 AFS: inventory R8,344,000, bank and cash R6,474,658, loss for the year R6,978 (FY2021: R14,604).", + "SLG FY2022 AFS: inventory R8,344,000; bank and cash R6,474,658.", + "SLG FY2022 AFS: bank and cash R6,474,658; inventory R8,344,000.", + "SLG FY2022 AFS: bank and cash R6,474,658, inventory R8,344,000.", + "SLG FY2021 AFS: retained loss R14,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", @@ -218,6 +377,12 @@ { "id": "sars-prov-653827-unmatched", "pattern": "653,827\\.28", + "must_match": [ + "Unmatched SARS PROV of R653,827.28." + ], + "must_not_match": [ + "One RST provisional-tax payment of R326,913.64 on 25 Feb 2021." + ], "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", @@ -225,7 +390,15 @@ }, { "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", + "pattern": "(?i)2,887,676\\.80[^\\n]{0,60}(written|to zero|to nil|→ ?0|to R0)|\\bwritten (?:down )?to (?:zero|nil|R0)\\b(?:(?!\\d{1,3}(?:,\\d{3})+\\.\\d{2})[^\\n]){0,120}2,887,676\\.80", + "must_match": [ + "| RWD finished goods written to zero (FY2020 AJE — different year, genuinely additive) | R2,887,676.80 | Strong (this audit, Appendix C) |", + "RWD 7700/000 Finished Goods: R2,887,676.80 written down to R0" + ], + "must_not_match": [ + "The AJE wrote RWD finished goods of R141,163.95 to nil; R2,887,676.80 is in the first column pair.", + "written to zero: R141,163.95 (the R2,887,676.80 sits in the first column)" + ], "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", @@ -234,6 +407,12 @@ { "id": "rwd-sav-fy2425-4288883", "pattern": "4,288,883\\.75", + "must_match": [ + "RWD savings paid out R4,288,883.75 in FY2024/25." + ], + "must_not_match": [ + "RWD savings 62836164880 paid out R5,288,883.75 in FY2024/25." + ], "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", @@ -242,6 +421,12 @@ { "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", + "must_match": [ + "Totals across all 13 statements: R11,938,963.47 in." + ], + "must_not_match": [ + "SLG ABSA 4112315016: R12,460,649.26 in and R12,466,083.15 out." + ], "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", @@ -250,10 +435,37 @@ { "id": "core-inventory-exposure-15611759", "pattern": "15,611,759\\.72", + "must_match": [ + "Core inventory-fraud exposure R15,611,759.72." + ], + "must_not_match": [ + "No core inventory-exposure total survives. State each row on its own." + ], "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." + }, + { + "id": "r10-6m-extraction", + "pattern": "(?i)(?:extract\\w*|seiz\\w*|strip\\w*|stole|stolen|theft|loot\\w*|siphon\\w*|misappropriat\\w*|plunder\\w*|embezzl\\w*|divert\\w*|diversion)[^.\\n|]{0,80}R\\s?10(?:\\.6\\d*\\s?(?:M\\b|m\\b|million)|[ ,]624[ ,]131(?:\\.18)?)\\+?|R\\s?10(?:\\.6\\d*\\s?(?:M\\b|m\\b|million)|[ ,]624[ ,]131(?:\\.18)?)\\+?[^.\\n|]{0,80}(?:extract\\w*|seiz\\w*|strip\\w*|stole|stolen|theft|loot\\w*|siphon\\w*|misappropriat\\w*|plunder\\w*|embezzl\\w*|divert\\w*|diversion)", + "must_match": [ + "5. Use the court order to extract R10.6M+ from the company accounts", + "| 04 | Timeline of Financial Sabotage | March SARS request through September R10.6M extraction |", + " → Enabled R10.6M extraction (Sep 2025)", + "| **Proportionality** | R500K reimbursement used to justify R10.6M seizure | 0.95 |", + "used the resulting order to extract R10,624,131.18 from the companies", + "Within 8 days, R10.6 million was extracted from the company accounts." + ], + "must_not_match": [ + "On 3 and 11 Sep 2025, R10,624,131.18 was moved from four current accounts to savings accounts.", + "SLG sales of about R9-10.6M.", + "| R10.6M | transfers to savings |" + ], + "correction": "The four transfers of 3 and 11 Sep 2025 (R10,624,131.18) moved money from each company's FNB current account to savings: RST R3,090,000.00 to RST savings 62134839127, SLG R640,000.00 to SLG savings 62593375829, VVA R1,730,000.00 to VVA savings 62812835744 (FNB print of 11 Sep 2025), and RWD R5,164,131.18 out of RWD current 62323196362 'to savings' on 3 Sep (arrival not held). None is shown to have left its company. State them as transfers to savings, not as an extraction, seizure or theft.", + "withdrawn": "2026-10-28", + "source": "M-REF/04_FINANCIAL_SABOTAGE_TIMELINE.md Phase 7; docs/strategic/FACT_REGISTER_CONTRADICTIONS_RESOLVED_2026_10_27.md §7; evidence/2025-11-14-batch-3/CCE20250911_0001-0003", + "banner": "The R10.6M (R10,624,131.18) of 3-11 Sep 2025 was moved into the companies' savings accounts; it is not an extraction (RWD's R5.16M arrival not held)." } ] } diff --git a/scripts/check_withdrawn_claims.py b/scripts/check_withdrawn_claims.py index 0f5c596..1e79b51 100644 --- a/scripts/check_withdrawn_claims.py +++ b/scripts/check_withdrawn_claims.py @@ -3,11 +3,15 @@ Guard against withdrawn claims re-entering the repository Key features: -- Reads docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json (patterns, corrections, sources) +- Reads docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json (patterns, corrections, sources, + and the must_match / must_not_match examples each pattern has to satisfy) - --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 +- A claim hard-wrapped across the lines of one prose paragraph, or across the + lines of a fenced diagram, is caught too (.md/.txt/.html). A fence is a diagram + when it contains a box-drawing character (the form agents copy). Plain code + stays one statement per line. A diagram is not joined with the prose outside it - --root DIR / --register FILE: scan another repository against this (or another) register """ import argparse @@ -30,6 +34,85 @@ def load_register(): return reg, claims, re.compile(reg["allow_line_markers"]) +def example_errors(reg, claims): + """Each pattern must catch the forms it was written for and miss the correction. + + The examples live in the register, next to the pattern. A pattern edit that + misses a must_match form, or that matches a must_not_match correction, fails + here. exemption_must_not_match lines repeat a claim and must not be exempted + by allow_line_markers. exemption_must_match lines are real corrections and + must stay exempted. + """ + errors = [] + where = "docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json" + try: + allow = re.compile(reg["allow_line_markers"]) + except re.error as exc: + return [f"allow_line_markers in {where} does not compile: {exc}"] + + def require_lines(key, missing): + lines = reg.get(key) + if not lines: + errors.append(missing) + return [] + return lines + + still_fail = require_lines( + "exemption_must_not_match", + f"Add exemption_must_not_match to {where}: lines that repeat a withdrawn claim and " + "must not be exempted. 'The R10.6M extraction was restated by counsel.' is one.", + ) + still_allowed = require_lines( + "exemption_must_match", + f"Add exemption_must_match to {where}: corrections that repeat a withdrawn claim's " + "words and must stay exempted. The R10.6M line ending 'not an extraction' is one.", + ) + for text in still_fail: + if allow.search(text): + errors.append( + f"allow_line_markers in {where} exempts a line that repeats a withdrawn claim. " + f"A word like 'restated' is not a correction. Line: {text}" + ) + elif not any(c["rx"].search(text) for c in claims): + errors.append( + f"exemption_must_not_match in {where} does not repeat a registered claim, so it " + f"does not constrain the marker. Line: {text}" + ) + for text in still_allowed: + if not allow.search(text): + errors.append( + f"allow_line_markers in {where} no longer exempts a correction. Keep the specific " + f"marker (for example 'not an extraction'), not a broad word. Line: {text}" + ) + elif not any(c["rx"].search(text) for c in claims): + errors.append( + f"exemption_must_match in {where} does not repeat a registered claim. Line: {text}" + ) + for c in claims: + cid = f"{where} claim {c['id']}" + must = c.get("must_match") or [] + must_not = c.get("must_not_match") or [] + if not must or not must_not: + errors.append( + f"{cid}: add must_match (a form the pull request must reject) and must_not_match " + "(the correction, which the pattern must not catch)." + ) + continue + for text in must: + if not c["rx"].search(text): + errors.append( + f"{cid}: pattern does not match must_match. Widen the pattern, or fix the example. " + f"Form: {text}" + ) + for text in must_not: + if c["rx"].search(text): + errors.append( + f"{cid}: pattern matches a correction in must_not_match. Narrow the pattern and " + f"use the claim's correction field. Wording: {text}" + ) + return errors + + def path_checked(path, reg): if any(a in path for a in reg["allow_paths"]): return False @@ -64,33 +147,72 @@ def violations(path, lines, claims, allow): BLOCK_START = re.compile(r"\s*([-*+]|\d+[.)]|#+)\s") # a list item or heading starts a new unit +BOX_DRAWING = set("│┌┐└┘├┤┬┴┼▼▲►◄─") # a fenced diagram, as opposed to a code sample def joinable(text): - """A line that continues prose: not blank, not a table row, not a code fence.""" + """A line that continues a paragraph or a diagram: not blank, not a table row, not a fence marker.""" t = text.strip() return bool(t) and not t.startswith(("|", "```")) +def prose_runs(lines): + """Paragraphs of (line_no, stripped) from `lines`. + + A fenced region is included only when it is a diagram (some line contains a + box-drawing character). Those lines are not joined with the prose outside the + fence. Plain code is left out: joining it glues unrelated statements. + """ + paragraphs, run, fence, in_fence = [], [], [], False + + def flush(buf): + paragraphs.append(buf) + return [] + + def flush_fence(): + if any(any(ch in BOX_DRAWING for ch in text) for _, text in fence): + sub = [] + for no, text in fence: + if not joinable(text) or BLOCK_START.match(text): + paragraphs.append(sub) + sub = [] + if joinable(text): + sub.append((no, text.strip())) + paragraphs.append(sub) + + for no, text in lines: + if text.strip().startswith("```"): + if in_fence: + flush_fence() + fence = [] + in_fence = False + else: + run = flush(run) + in_fence = True + continue + if in_fence: + fence.append((no, text)) + continue + if not joinable(text) or BLOCK_START.match(text): + run = flush(run) + if joinable(text): + run.append((no, text.strip())) + if in_fence: + flush_fence() + paragraphs.append(run) + return paragraphs + + 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, + Each paragraph from `prose_runs` that holds 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) + paragraphs = prose_runs(read_lines(path)) for group in paragraphs: if len(group) < 2 or not wanted.intersection(no for no, _ in group): continue @@ -135,7 +257,7 @@ def prefilter_pattern(pattern): 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*") + return pattern.replace("(?i)", "").replace("[^.\\n|]", "[^.|]").replace("[^.\\n]", "[^.]").replace("[^\\n]", "[\\s\\S]").replace(" ", "\\s*") def candidate_files(reg, claims): @@ -151,22 +273,32 @@ def candidate_files(reg, claims): if not shutil.which("rg"): 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", "-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): - print(f"⚠️ ripgrep prefilter failed, checking every tracked file in full (slow): {r.stderr.strip()[:200]}") + + def run(patterns): + with tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False) as f: + f.write("|".join("(?:%s)" % prefilter_pattern(c) for c in patterns)) + 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() + return r + + patterns = [c["pattern"] for c in claims] + runs = [run(patterns)] + if runs[0].returncode not in (0, 1): + # the combined expression can exceed PCRE2's compile limit; one run per claim stays within it + runs = [run([p]) for p in patterns] + bad = [r for r in runs if r.returncode not in (0, 1)] + if bad: + print(f"⚠️ ripgrep prefilter failed, checking every tracked file in full (slow): {bad[0].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)) + for r in runs: + 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} @@ -239,6 +371,11 @@ def main(): elif (ROOT / "docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json").exists(): REGISTER = ROOT / "docs/strategic/WITHDRAWN_CLAIMS_REGISTER.json" reg, claims, allow = load_register() + errors = example_errors(reg, claims) + if errors: + for error in errors: + print(f"❌ {error}") + return 2 if a.diff: return run_diff(a.diff, reg, claims, allow) return run_report(reg, claims, allow, a.tsv)