Skip to content

Python: arch_regex misses regex methods on compiled patterns (recall 0.53) #8858

Closed

Description

@squid-protocol

What is wrong

The Python regex_execution rule (arch_regex) only matches six module-level calls: re.compile|re.search|re.match|re.sub|re.findall|re.split. A function that runs a pattern it did not compile itself, or calls a method on a compiled pattern, scores 0. Against Python's ast, recall is 0.53 and precision 1.00 over 72,044 functions: it never over-counts, it misses half. Missed in the engine's own code (functions): finditer 5,153, fullmatch 3,390, match 3,186, search 2,777, findall 1,873.

Reproduce

import re
PAT = re.compile("a+")

def uses_module_pattern(s):
    return [m.group(0) for m in PAT.finditer(s)]

def uses_fullmatch(s):
    return PAT.fullmatch(s)

Both functions scan with arch_regex == 0.

Expected

arch_regex > 0 where the function executes a regular expression. Candidate additions: the re. forms finditer, fullmatch, subn, and method calls .finditer( .fullmatch( .match( .search( .findall( .subn( on a name. The method names collide with non-regex objects (str has none of them, but other classes do), so decide the precision/recall trade deliberately and report precision on the engine's own code.

Notes

Check the other languages' regex-execution rules for the same shape (module call list, no method-on-object form).

How this was found

A pilot that compares each function_data signal with what Python's own ast says the function does (72,044 functions of GitGalaxy's own code; see the pilot note, with corrections and one-function-per-case reproductions in temporal-crucible PR #188). This is part of the keyword-family validity epic (linked below once filed).

Rules for the fix

  • Any change to a keyword list adds or removes regex work, so time it: CPU seconds on keyword-rosetta and language-crucible before and after, and say the number in the PR.
  • If keyword-rosetta counts move, label the PR rosetta:rebless-owed and rebless as usual.
  • Add the case below as a test (one function per case, so a regression names itself).

Activity

  1. added
    bug
    python
    core-engine
    on Nov 21, 2026
  2. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Part of #8863 (keyword-family validity epic).

  3. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-22T16:11Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  4. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 8858-20261121T1656Z (host melek) ended without a PR. plan-held: python.py overlaps worker 8859, PRs #8902/#8914; requeued after those PRs

  5. added a commit that references this issue on Nov 27, 2026
    5112320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:melekcore-enginepriority: mediumpython

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions