Repository navigation
Fix argument counting to ignore commas within nested brackets/types - #1036
Merged
Merged
Conversation
) The args_count heuristic ran .count(",") over the whole captured signature, so nested commas -- generic type hints (Map<A, B>, Dict[str, int]), default dict/list literals, and nested callback signatures -- each inflated the count as if they were separate top- level arguments. StructuralExtractor._count_top_level_args replaces this with a depth- and string-aware sweep that only counts commas at the argument list's own nesting level, tracking (), [], {}, <> and skipping commas inside string literals. This changes structural magnitude / 3D coordinates across the golden master corpus wherever real signatures carry nested brackets (e.g. FastAPI's heavily Annotated[...] parameters), so both tests/golden_master_audit.json and golden_master_zero_dep_audit.json are re-blessed via tests/tools/update_golden_master.py per the Differential Scan protocol. crucible_check.py passes clean against the new baselines in both full-precision and zero-dependency mode. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StructuralExtractor._calculate_block_metricscounted arguments by running.count(",")over the whole captured function signature, so any nested comma — generic type hints (Map<A, B>,Dict[str, int]), default dict/list literals, or nested callback signatures — inflated the count as if each were a separate top-level argument.StructuralExtractor._count_top_level_args(gitgalaxy/core/detector.py): a depth- and string-aware sweep that isolates the argument list's own bracket body (captured signatures include the wrapping(...), e.g."def foo(x, y)") and only counts commas at that top level, tracking(),[],{},<>nesting and skipping commas inside string literals.Why the golden masters changed
Both
tests/golden_master_audit.jsonandtests/golden_master_zero_dep_audit.jsonare re-blessed viatests/tools/update_golden_master.py, per the Differential Scan protocol in CLAUDE.md. Real corpus code with nested-bracket signatures now scores a correspondingly lower argument count, cascading into structural magnitude / 3D coordinates for those files (e.g. FastAPI'sHTTPException.__init__, whose params are wrapped in heavily-nestedAnnotated[..., Doc("""...""")]hints, previously way overcounted).crucible_check.pypasses clean against the new baselines in both full-precision and zero-dependency mode.Test plan
python -m pytest tests/core_engine/— 2904 passed, 1 xfailedpython -m pytest tests/core_engine/test_language_standards_strict.py -k perlandtests/extraction/languages/test_perl.py— unaffectedpython tests/tools/crucible_check.py— PASS (full_precision + zero_dependency)python tests/tools/audit_check.py— ruff/mypy/dead-key all cleandef foo(data: Dict[str, int])→ 1 arg,def foo(data: dict = {"x": 1, "y": 2}, z=5)→ 2 args,foo(Map<String, Integer> data, int y)→ 2 args, TS nested-callback param → 2 args🤖 Generated with Claude Code