Repository navigation
Description
What
Found while chasing the remaining ~1.4% args_exact_match gap after #1524/#1525 fixed the
tree-sitter audit tool's own node-type undercounting (63.0% → 98.6%). A separate, smaller slice of
the remaining mismatches (all 12 in language-crucible/data/python/fastapi/tests/test_dependency_partial.py)
is a real limitation in GitGalaxy's own engine, not the audit tool.
Python's args rule in gitgalaxy/standards/language_standards.py:
re.compile(
r'(?:async[ \t]+)?def[ \t]+(\w+)(?:\[(?:[^\[\]]|\[[^\[\]]*\])*\])?[ \t]*(\((?:[^()]|\([^()]*\))*\))|\blambda\b[ \t]*([^:]*):',
re.MULTILINE,
)The parameter-list capture group \((?:[^()]|\([^()]*\))*\) balances exactly one level of
nested parens (outer paren + one inner non-nested paren group). A default value with two levels of
nested calls -- e.g. FastAPI's dependency-injection idiom:
async def get_partial_callable_gen_dependency(
value: Annotated[
str,
Depends(partial(callable_gen_dependency, "partial-callable-gen-dependency")),
],
) -> str:(Depends( is depth 1, partial( is depth 2) doesn't match at all -- the whole def statement is
skipped by the args regex (confirmed via direct finditer against the real file: zero matches
for this function). func_start's simpler anchor still finds the function name (so it shows up as
"found" against tree-sitter ground truth), but args_count silently defaults to 0 instead of the
real 1.
Scope / context
Verified this isn't unique to python -- JS/TS's own args rules use \([^)]*\), i.e. zero
levels of nesting, an even tighter bound. This looks like a deliberate ReDoS-safety tradeoff
(bounded nesting depth instead of unbounded recursive matching) rather than an oversight, so a fix
here is a real regex-engine change to weigh against that tradeoff, not a mechanical whitelist
addition.
Why this is its own issue, not part of #1524/#1525
#1524/#1525 fixed a bug in the audit tool's ground-truth measurement (a test-only file). This
one is in GitGalaxy's actual production parsing logic (language_standards.py), so per this repo's
"Differential Scan" PR protocol any fix here needs crucible_check.py verification and a
golden_master_audit.json/golden_master_zero_dep_audit.json re-bless before it can ship --
deliberately scoped out of the smaller, lower-risk audit-tool fix.
Suggested direction (not a full design, needs its own pass)
Extending the capture group to balance two levels while keeping it bounded (e.g.
\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\)) is the mechanical fix, but real-world signatures aren't
bounded to any fixed nesting depth in general (three+ levels would still break), so this only
narrows the gap rather than closing it outright -- worth deciding whether one more level is worth
the added regex complexity/backtracking cost before implementing, or whether this should be
documented as an accepted limitation the way PEP 695's whitespace gap already is in
docs/language_status/python.md §5.
Activity
fix(python): args regex only balanced one level of nested parens (#1547)
docs(skill): record pool-of-5 round-3 gotchas -- watch-exit vs merge-…