Skip to content

fix(core): give core_var_decl/design_* naming-convention signatures real producers - #1151

Merged
squid-protocol merged 2 commits into
mainfrom
fix/1145-naming-convention-signatures
Aug 7, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/1145-naming-convention-signatures

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Aug 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes Dead naming-convention signature family: struct_camel_case/snake_case/pascal_case/upper_case/short_vars/long_vars/var_decl have zero producers #1145: 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 was also a live consumer, not just an unused column: signal_processor.py's encapsulation_ratio used it as a denominator term, so its permanent 0 silently floored that ratio to 0.0 for any file with a nonzero globals hit, regardless of how much state was actually locked inside functions.
  • 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, 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-led let/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.py parsing logic, so tests/golden_master_audit.json and tests/golden_master_zero_dep_audit.json needed regenerating per the Differential Scan protocol. Verified against the pinned v1.0 language-crucible corpus before blessing:

  • Both fixtures show identical drift (18,947 diffs each), and every single diff was categorized and explained before regenerating — none were off-target:
    • 712 core_var_decl + 1,692 design_* casing-bucket diffs — the new signal itself, direct and expected.
    • 13,196 + 3,347 archetype/ML-cluster/z-score/drift/fingerprint diffs — indirect but expected: these 7 SIGNAL_SCHEMA columns feed signal_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.
  • Regenerated via python tests/tools/update_golden_master.py (through the crucible_check.py --update --yes wrapper, 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: dockerfile structural signatures #579/Fix #579: Strict parsing tests for dockerfile structural signatures #723).
  • Re-verified clean after blessing: python tests/tools/crucible_check.py → ✅ full_precision PASS, ✅ zero_dependency PASS.

Test plan

  • New strict/adversarial suite tests/core_engine/test_naming_convention_signatures.py (74 tests) in the spirit of the per-language test_<lang>_strict.py methodology: 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_immune on adversarial payloads, casing-classifier ambiguity/mutual-exclusivity checks, end-to-end splice() 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 its code_stream-already-comment-stripped precondition).
  • New regression coverage in tests/core_engine/test_signal_processor.py proving encapsulation_ratio no longer floors to 0.0 given real core_var_decl data, 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

…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]>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

…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]>
@squid-protocol
squid-protocol merged commit 23e43bd into main Aug 7, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the fix/1145-naming-convention-signatures branch August 7, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead naming-convention signature family: struct_camel_case/snake_case/pascal_case/upper_case/short_vars/long_vars/var_decl have zero producers

1 participant