Skip to content

fix(core): wire lang_defs into StatisticalAuditor; drop the Low-Sample Guard (#2325) - #2331

Merged
squid-protocol merged 2 commits into
mainfrom
fix-statistical-auditor-langdefs-2325
Aug 27, 2026
Merged

fix(core): wire lang_defs into StatisticalAuditor; drop the Low-Sample Guard (#2325)#2331
squid-protocol merged 2 commits into
mainfrom
fix-statistical-auditor-langdefs-2325

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #2325.

The bug

Orchestrator.__init__ built StatisticalAuditor(parent_logger=logger)no lang_defs. So self.lang_defs == {} on every real scan, and in audit()'s per-language loop the Dynamic Auditability Check always took its else: is_inert = True branch ("Unknown/Undefined languages are inert by default"). The if is_inert: bypass then short-circuited every language group straight into verified_files.

Net effect: GATE C, GATE D (MAD baseline / Impossible Density Law / Zero-Density floor), and dead-code detection never executed in production — only the pre-loop Heuristic Extension Consensus triage did. test_statistical_auditor.py passes lang_defs explicitly, so the tests always exercised code the real pipeline never reached.

Fix

Per the decision on #2325 (wire it up, but drop GATE C):

file change
galaxyscope.py pass lang_defs to the constructor — GATE D's data-dump / packed-payload / MAD floors and dead-code detection now run
statistical_auditor.py delete GATE C (the "Low-Sample Threshold Guard"). It reverted any language with ≤ orphan_threshold files to plaintext unless every file had a Tier-0 lock — but a clean single-extension file (foo.css, foo.kt, foo.nix) locks at Tier 2 "Single Indicator (Ext)", never Tier 0. Verified: activating it would erase ~13 legitimately-classified languages (css, kotlin, nix, objective-c, scheme, proto, tcl, yacc, dockerfile, …) from GitGalaxy's own corpus. Small-sample hallucination is already handled upstream by the consensus triage + Tier-4/undeterminable pre-filters. Also removed the now-dead orphan_threshold / math import.
test_statistical_auditor.py replaced the GATE C test with one asserting a small weak-tier population is kept intact

Corpus impact — one file

GATE D, now active, relegates exactly one file across the whole ~80-repo corpus: javascript/threejs/Nodes.js — a 166-line pure re-export barrel (0 functions, ~140 export … from lines) tripping the Packed Payload Guard at 3.32 signal-hits/line. It's a borderline catch (a hand-written index file, not minified/obfuscated), but it carries no analyzable logic and it's the guard behaving as specified/tested.

Everything else in the golden-master rebless is downstream count / coordinate ripple from that single drop — no language reclassified, no other relegations (verified with a structural per-file diff). Both golden masters re-blessed; crucible_check PASS both modes.

Verification

  • test_statistical_auditor.py (9) + tests/security_auditing + tests/core_engine — 717 pass
  • ruff / mypy / dead-key / ast-accuracy — clean (ruff baseline: one PERF203 line-shift)
  • crucible_check.py — PASS both modes
  • tri_comparison_chart.py --all --ci — green (tree-sitter-accuracy-audit / tri-comparison-audit don't trigger on these file paths; crucible-audit + full-suite are the gates)

Note

Nodes.js being silently dropped is exactly the kind of thing #2326 (consensus engine silently deletes cleanly-extracted files) is about — if the Packed Payload Guard should distinguish hand-written barrel files from packed content (e.g. gate on is_minified or line length), that's a good follow-up there.

🤖 Generated with Claude Code

…e Guard (#2325)

`Orchestrator.__init__` constructed `StatisticalAuditor(parent_logger=logger)`
with no `lang_defs`, so `self.lang_defs == {}` on every real scan. In
`audit()`'s per-language loop the Dynamic Auditability Check then took its
`else: is_inert = True` branch for *every* language ("Unknown/Undefined
languages are inert by default"), and the `if is_inert` bypass short-circuited
each group straight into `verified_files`. Net effect: GATE C, GATE D (MAD
baseline / Impossible Density Law / Zero-Density floor), and dead-code
detection never executed in production -- only the pre-loop Heuristic
Extension Consensus triage did. The gate logic is covered by
test_statistical_auditor.py, which passes `lang_defs` explicitly, so the
tests always exercised code the real pipeline never reached.

- `galaxyscope.py` -- pass `lang_defs` to the constructor. GATE D's
  data-dump / packed-payload / MAD floors and dead-code detection now run.

- `statistical_auditor.py` -- DELETE GATE C (the "Low-Sample Threshold
  Guard"). It reverted any language with <= orphan_threshold files to
  plaintext unless every file carried a Tier-0 "Absolute Consensus" lock --
  but a clean single-extension file locks at Tier 2 "Single Indicator (Ext)",
  never Tier 0, so activating it would have erased ~13 legitimately-classified
  languages (css, kotlin, nix, objective-c, scheme, proto, tcl, yacc, ...)
  from any repo with a small footprint of them. Small-sample hallucination is
  already handled upstream by the consensus triage and the
  Tier-4/undeterminable pre-filters. Removed the now-dead `orphan_threshold`
  computation and `math` import.

- `test_statistical_auditor.py` -- replaced the GATE C test with one asserting
  a small weak-tier population is now kept intact.

Corpus impact (verified via crucible_check, both modes): GATE D now relegates
exactly ONE file across the whole ~80-repo corpus --
`javascript/threejs/Nodes.js`, a 166-line pure re-export barrel (0 functions,
~140 `export ... from` lines) tripping the Packed Payload Guard at 3.32
signal-hits/line. Every other diff in the golden-master rebless is downstream
count / coordinate ripple from that single drop. No language reclassified, no
other relegations.

Verification: test_statistical_auditor.py (9) + tests/security_auditing +
tests/core_engine (717) green; ruff/mypy/dead-key/ast-accuracy clean (ruff
baseline: one PERF203 line-shift); crucible_check both modes PASS;
tri_comparison_chart --all --ci green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

The docstring note added in the previous commit shifted the pre-existing
try/except from line 330 to 337. Pure line-shift, no new finding.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 7b0e165 into main Aug 27, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the fix-statistical-auditor-langdefs-2325 branch August 27, 2026 14:55
squid-protocol added a commit that referenced this pull request Aug 27, 2026
…#2309) (#2335)

`_count_top_level_args` unwraps a signature's outer `(...)` and counts
depth-0 commas in the remaining body. For a Dart parameter list whose
parameters live in a named group `({a, b, c})` or an optional-positional
group `([a, b])`, the group's own `{`/`[` was read as ordinary nesting --
so every comma inside sat at depth 1 and none counted. A Flutter widget
constructor like `EditableText({super.key, required this.controller, ...})`
measured **1** argument instead of 76; `_Editable`, `_UpdateTextSelectionAction`
and ~dozens more were similarly flattened. This is the args half of #2309
(the `func_start` existence half, and the bodyless `this.`/`super.`-forwarding
constructor case, were handled by #2071 / #2311).

Fix: in `_count_top_level_args`, for `primary_lang_id == "dart"`, when the
parameter-list body ends (ignoring trailing whitespace) in `}` or `]`,
locate that terminal group's matching opener at depth 0 and blank just those
two delimiter characters, so the group's members land at the top level and
their separating commas are counted. A `{...}` / `[...]` that is a
default-VALUE literal (`{int x = const [1, 2, 3]}`, `{Map m = const {'a': 1}}`)
is never flush against the body's end, so it stays nested and its internal
commas stay correctly ignored. Scoped to dart -- no other language's count
path is touched.

Result (name-matched `gather_language("dart")` args diff vs tree-sitter):
GitGalaxy under-counts by >=2 (excluding tree-sitter's own same-name
reconciliation inflation) drop from ~40 to 2, and those 2 are tree-sitter /
reconciler quirks, not GitGalaxy defects (`build` at editable_text.dart:6253
is genuinely 1 param; `copyWith` at theme_data.dart:140 is a bodyless
abstract method with 0). `EditableText` (1->76), `_Editable` (1->39),
`_UpdateTextSelectionAction` (4->6) now match tree-sitter exactly.

Regenerated:
- Both golden masters -- 328 diffs, all dart (arg counts + downstream
  structural-impact / spatial-coordinate ripple); 0 non-dart content change.
- `tree_sitter_accuracy_baseline_dart.json` -- `args_exact_match` 1519 -> 1633
  (+114); summary table in `language_standards.py` Dart row 99.4% -> 99.5%.
- `tree_sitter_accuracy_baseline_javascript.json` -- `files_scanned` 18 -> 17,
  a stale value left by #2331 (GATE D relegating `threejs/Nodes.js`); the
  tree-sitter-accuracy workflow doesn't trigger on statistical_auditor.py
  paths so it was never updated. Included here so this PR's own
  tree-sitter-accuracy-audit run (which `detector.py` does trigger) is green.

Verification: test_detector.py (+ new `_count_top_level_args` dart case) and
tests/extraction (6234) green; ruff/mypy/dead-key/ast-accuracy clean;
crucible_check both modes PASS; tree_sitter_accuracy_audit --all --ci and
tri_comparison_chart --all --ci both green.

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

StatisticalAuditor constructed without lang_defs -> GATE C/D density gates are dead code in production

1 participant