fix(powershell): shield here-strings; close final 3 tri-comparison ledger shapes - #2451
Merged
Conversation
…apes tri-comparison-ledger-sweep remaining-shapes pass. Every reproducing discrepancy shape in docs/self_scan/tri_comparison_ledger.json is now `status: validated` (was 3 unvalidated, count 1 each). #2450 -- PowerShell here-string false positive (engine defect, fixed). `Write-Output @"namespace ... enum ProviderType { ... }"@` in PowerToys/generate-interface.ps1: PowerShell's `embedded_syntax` lexical family strips only `#` / `<# #>`, and prism.py had no here-string handling in the code_stream path, so `class_start` matched `enum ProviderType` inside the string. Added `_strip_powershell_herestrings` to `_strip_segment_comments` pre-processing (blanks `@"..."@` / `@'...'@` bodies, newline-count preserving, captures to the doc stream -- same idiom as `_strip_python_docstrings` / `_strip_php_string_mass`). powershell class precision 90.0% -> 100.0% (extra_classes 1 -> 0); baseline + both golden masters regenerated (the diff is .ps1 files reclassifying here-string mass from code LOC to doc LOC, plus ripple). #2451 -- tri_comparison_gatherer.py's tree-sitter walk now injects the css/javascript grammar for HTML `<style>`/`<script>` elements, reusing the accuracy audit's own `_html_embedded_ts_funcs` (#2421). layout.html:40's `@media only screen { ... }` -- which GitGalaxy's polyglot detector correctly reports as a function `media` -- was previously invisible to tree-sitter-html (opaque `raw_text`), making a correct find look like over-detection. `media` is now in GitGalaxy+tree-sitter consensus; ctags-html still can't see it (no CSS parser, documented). haskell/function/existence/agree[ctags,gitgalaxy]_vs[tree_sitter] (n=1): reconciler rank-pairing artifact from ctags-haskell tagging one function once per line (name line + `::` sig line + equations). pandoc/Shared.hs's `addPandocAttributes` -> 3 ctags tags vs 1 each from GitGalaxy/tree-sitter. Not a defect in any engine. Documented in ctags_reader.py. No credit/debit on any of the four shapes. An independent Gemini (agy) audit of the four languages where GitGalaxy's raw function count trails tree-sitter (perl -122, cpp -122, c -60, dart) confirmed all are tree-sitter over-detection (bodyless `sub` prototypes, `OPCODE(...)` dispatch macros, `#if 0` dead code) except dart, whose real recall gap is already tracked in #2072. Gemini's one dissent (cpp conversion operators) did not hold up on verification -- GitGalaxy finds all 60 `Variant::operator X()` definitions in godot/variant.cpp; the difference is a `() const` naming-suffix, not a miss. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S
The HTML embedded-grammar-injection issue was filed as #2452, not #2451 (#2451 is this PR). Corrects the code comments and the ledger verdict. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S
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.
Final pass of the tri-comparison-ledger-sweep. Every reproducing discrepancy shape in
docs/self_scan/tri_comparison_ledger.jsonis nowstatus: validated(was 3 unvalidated,count 1 each). GitGalaxy ties or beats tree-sitter and Universal Ctags on function/class
detection for every language in the corpus.
Engine fix — #2450 (PowerShell here-strings)
PowerToys/generate-interface.ps1generates a C#/IDL interface from aWrite-Output @"namespace ... enum ProviderType { ... }"@here-string. PowerShell'sembedded_syntaxlexical family strips only#/<# #>comments, andprism.pyhad nohere-string handling in the
code_streampath, so the here-string body leaked through andclass_startmatchedenum ProviderTypeas a real class.Fixed with
_strip_powershell_herestringsin_strip_segment_comments's pre-processing step(blanks
@"..."@/@'...'@bodies, newline-count preserving, captures to the doc stream —same idiom as
_strip_python_docstrings/_strip_php_string_mass).PowerShell class precision 90.0% → 100.0% (
extra_classes1 → 0).Tooling fix — #2451 (HTML embedded-grammar injection in the gatherer)
tri_comparison_gatherer.py's tree-sitter walk now injects the css/javascript grammar for HTML<style>/<script>elements, reusing the accuracy audit's own_html_embedded_ts_funcs(the exact mechanism #2421 added to
tree_sitter_accuracy_audit.py).layout.html:40's@media only screen { ... }— which GitGalaxy's polyglot detector correctly reports as afunction
media— was invisible to tree-sitter-html (opaqueraw_text), so a correct findlooked like over-detection.
mediais now in GitGalaxy+tree-sitter consensus.Ledger verdicts
@"..."@here-strings #2450).ctags-html has no CSS parser (documented).
function once per line (name line +
::signature line + equations), sopandoc/Shared.hs'saddPandocAttributesgets 3 ctags tags vs 1 each fromGitGalaxy/tree-sitter. Not a defect in any engine. Documented in
ctags_reader.py.No credit/debit on any shape.
Independent Gemini audit
An
agy(Gemini 3.1 Pro) read-only audit of the 4 languages where GitGalaxy's raw functioncount trails tree-sitter (perl −122, cpp −122, c −60, dart) confirmed all are tree-sitter
over-detection — bodyless
sub NAME($$$);prototypes (perl, per #1608),OPCODE(...)bytecode-dispatch macros and bare
bool/voidmembers (cpp), macro array-initializers and#if 0dead code (c) — except dart, whose real recall gap is already tracked in #2072.Gemini's one dissent (cpp conversion operators are "real code GitGalaxy misses") did not hold
up on verification: GitGalaxy finds all 60
Variant::operator X()definitions ingodot/variant.cpp; the difference is tree-sitter's() constnaming suffix, not a miss.Differential Scan
.ps1files reclassifying here-string mass from codeLOC to doc LOC, plus Global Ecosystem / directory-magnitude / topological ripple. No
function/class count changes anywhere.
crucible_check.py --mode bothPASS.tree_sitter_accuracy_audit.py --all --ci31/31 OK.tri_comparison_chart.py --all --ciOK.tests/core_engine+tests/extractionpass.audit_check.pyclean. Ledger / chart /points-of-interest regenerated (
--all).Closes #2450, closes #2451.
🤖 Generated with Claude Code
https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S