Repository navigation
fix(core): give core_var_decl/design_* naming-convention signatures real producers - #1151
Merged
Merged
Conversation
…eal producers (#1145) 7 SIGNAL_SCHEMA columns (struct_var_decl, struct_camel_case, struct_snake_case, struct_pascal_case, struct_upper_case, struct_short_vars, struct_long_vars) had zero producers anywhere in language_standards.py -- permanently 0 in every scan. core_var_decl is also a live consumer: signal_processor.py's encapsulation_ratio used it as a denominator term, which its permanent 0 silently floored to 0.0 for any file with a nonzero `globals` hit. Implemented as one universal (not per-language) mechanism in detector.py, the same "single regex for every language" precedent indent_tabs/indent_spaces already establish -- identifier casing is a lexical/formatting property, not a language-semantic one needing 59 hand-tuned regexes. A bounded var-decl pattern captures the identifier immediately before an unguarded `=`, tolerating an optional prefix so it reaches bare, keyword-led (let/const/var/val/mut), and C-style typed declarations alike; a small classifier buckets each captured name by casing and length. Adds a strict/adversarial test suite (tests/core_engine/test_naming_convention_signatures.py) in the spirit of the per-language test_<lang>_strict.py methodology: verified positive/negative cases, a ReDoS scaling sweep, ambiguity/mutual-exclusivity checks, and documented known limitations (chained assignment, no-space default params, the code_stream-already-comment-stripped precondition). Also adds regression coverage in test_signal_processor.py for the encapsulation_ratio fix. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
…signatures
Regenerated both tests/golden_master_audit.json (full-precision) and
tests/golden_master_zero_dep_audit.json (zero-dependency) via
tests/tools/update_golden_master.py against the pinned v1.0 language-crucible
corpus, per this repo's Differential Scan protocol for any PR touching parsing
logic.
Both fixtures showed identical drift (18947 diffs each), fully categorized and
explained before blessing -- none were off-target:
- 712 core_var_decl -- the new signal itself, direct and expected
- 1692 design_camel_case/snake_case/pascal_case/upper_case/short_vars/long_vars
-- same, direct and expected
- 13196 + 3347 archetype/ML-cluster/z-score/drift/fingerprint reshuffling --
indirect but expected: these 7 SIGNAL_SCHEMA columns feed
signal_processor.py's K-Means archetype-classification feature vector
(see analysis_lens.py's SIGNAL_SCHEMA-ordering comment). They were a
constant-0 dimension across the entire corpus before this fix, so
giving them real per-file variance necessarily reclassifies a
meaningful fraction of files' archetypes -- the same effect #1020
already documented for this feature vector, just from populating a
dead dimension instead of removing one.
Verified via `python tests/tools/crucible_check.py` (both modes PASS after the
update) rather than the raw pytest marker, since it rebuilds/refreshes the two
purpose-built venvs pinned to this exact checkout first (see that script's own
docstring for why: a stale editable-install pointer previously caused a false
"zero diff" pass, PR #579/#723).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
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
struct_var_decl/struct_camel_case/struct_snake_case/struct_pascal_case/struct_upper_case/struct_short_vars/struct_long_varshad zero producers anywhere inlanguage_standards.py— permanently 0 in every scan.core_var_declwas also a live consumer, not just an unused column:signal_processor.py'sencapsulation_ratioused it as a denominator term, so its permanent 0 silently floored that ratio to 0.0 for any file with a nonzeroglobalshit, regardless of how much state was actually locked inside functions.detector.py— the same "single regex for every language" precedentindent_tabs/indent_spacesalready establish, since identifier casing is a lexical/formatting property rather than a language-semantic one. A bounded var-decl regex captures the identifier immediately before an unguarded=(tolerating an optional prefix so it reaches bare, keyword-ledlet/const/var/val/mut, and C-style typed declarations alike), and a small pure-Python classifier buckets each captured name by casing/length. Confirmed via manual scaling sweep that this stays linear, not quadratic, under adversarial input.Golden Crucible re-bless
This PR touches
detector.pyparsing logic, sotests/golden_master_audit.jsonandtests/golden_master_zero_dep_audit.jsonneeded regenerating per the Differential Scan protocol. Verified against the pinned v1.0language-cruciblecorpus before blessing:core_var_decl+ 1,692design_*casing-bucket diffs — the new signal itself, direct and expected.SIGNAL_SCHEMAcolumns feedsignal_processor.py's K-Means archetype-classification feature vector. They were a constant-0 dimension across the entire corpus before this fix, so giving them real per-file variance necessarily reclassifies a meaningful fraction of files' archetypes — the same effect Remove AST-dependent Security & Vulnerability metrics (Injection, RCE, Memory) #1020 already documented for this feature vector, just from populating a previously-dead dimension instead of removing one.python tests/tools/update_golden_master.py(through thecrucible_check.py --update --yeswrapper, which rebuilds/refreshes the two purpose-built venvs pinned to this exact checkout first — see that script's docstring for why a stale editable-install pointer previously caused a false "zero diff" pass, PR Strict parsing tests:dockerfilestructural signatures #579/Fix #579: Strict parsing tests for dockerfile structural signatures #723).python tests/tools/crucible_check.py→ ✅ full_precision PASS, ✅ zero_dependency PASS.Test plan
tests/core_engine/test_naming_convention_signatures.py(74 tests) in the spirit of the per-languagetest_<lang>_strict.pymethodology: verified positive/negative cases (every case checked via a real.search()call, not reasoned from the pattern's shape), a ReDoS scaling sweep +assert_redos_immuneon adversarial payloads, casing-classifier ambiguity/mutual-exclusivity checks, end-to-endsplice()integration tests proving nonzero counts per bucket (the literal Dead naming-convention signature family: struct_camel_case/snake_case/pascal_case/upper_case/short_vars/long_vars/var_decl have zero producers #1145 acceptance criterion), and explicit tests for two documented known limitations (chained assignment only counts the first target; the regex trusts itscode_stream-already-comment-stripped precondition).tests/core_engine/test_signal_processor.pyprovingencapsulation_rationo longer floors to 0.0 given realcore_var_decldata, plus a companion test confirming the genuinely-all-global case still correctly scores 0.0.python -m pytest tests/— full suite green (6703+ passed pre-existing, +76 new).python tests/tools/audit_check.py— clean (ruff baseline regenerated for pure line-shifts only, mypy/dead-key untouched).ruff format --check— clean.python tests/tools/crucible_check.py— both full-precision and zero-dependency golden crucible modes PASS against the pinned v1.0 corpus.🤖 Generated with Claude Code