Skip to content

Fix #814: Extraction hardening for javascript - #878

Merged
squid-protocol merged 1 commit into
mainfrom
feature/814-extraction-hardening-javascript
Jul 31, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feature/814-extraction-hardening-javascript

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Part of the extraction-hardening epic (#813). Closes #814.

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for javascript per tests/extraction/how_to_harden_extraction.md. The shared string-literal false positive (recurring bug class 3) was already fixed earlier via PR #860 (gated to js/ts); this issue closes the remaining javascript-specific case expansion and fixes one additional real bug:

  • func_start/args had no allowance for ES6 generator method shorthand (*foo() {}, async *foo() {}, static *foo() {}) — completely invisible before this fix. Generators are a common, legitimate ES6+ feature (custom iteration protocols, iterables).

A two-stage fix worth calling out explicitly: the first version used a whitespace-tolerant gap (\*?[ \t\n]*) between the star and the method name, matching the style of the other modifier gaps around it. This introduced a new false positive, caught via crucible_check.py against real corpus code — not by any hand-written test case, since it requires exactly the right prose shape to trigger: a JSDoc comment continuation line (* A (storage) buffer attribute..., where * is the comment's own marker and "A" is the first word of a plain-English sentence) got hallucinated as a generator method named A in threejs/BufferGeometry.js. Corrected by requiring the star to hug the name with zero intervening whitespace — every real formatter (Prettier included) emits *foo(), never * foo(), so this is strictly more accurate, not a flexibility regression. This is a concrete demonstration of why the methodology's crucible-check step matters even for "obviously safe" widenings.

Differential Scan

Ran python tests/tools/crucible_check.py: zero diff across the ~80-repo corpus, after the corrected (whitespace-tightened) fix. Confirmed expected — grep across the corpus's JS files shows zero real-world usage of generator method syntax anywhere. No golden master changes in this PR.

Test plan

  • pytest tests/extraction/languages/test_javascript.py (53 new tests) — run via bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3544 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed
  • python tests/tools/audit_check.py — clean (only the pre-existing, already-tracked guidestar_lens.py mypy findings, unrelated to this change)
  • python tests/tools/crucible_check.py — PASS on both venvs (zero diff, as expected — see above)
  • Migrated javascript's cases out of the four monolithic dict files into tests/extraction/languages/test_javascript.py
  • Epic Epic: Harden the four extraction gauntlets (function/args/class/dependency) per language #813 and the methodology doc updated with the new finding (recurring bug class 21)

🤖 Generated with Claude Code

Hardens all four extraction gauntlets for javascript. The shared
string-literal false positive (recurring bug class 3) was already fixed
earlier via PR #860 (gated to js/ts); this issue closes the remaining
javascript-specific case expansion work and fixes one additional real
bug:

- func_start/args had no allowance for ES6 generator method shorthand
  (`*foo() {}`, `async *foo() {}`, `static *foo() {}`) -- completely
  invisible before this fix. Generators are a common, legitimate ES6+
  feature (custom iteration protocols, iterables).

The first version of this fix used a whitespace-tolerant `\*?[ \t\n]*`
gap between the star and the method name, matching the style of the
other modifier gaps around it. This introduced a NEW false positive,
caught via crucible_check.py against real corpus code (not by any
hand-written test): a JSDoc comment continuation line
(`* A (storage) buffer attribute...`, where `*` is the comment's own
marker and "A" is the first word of a plain-English sentence) got
hallucinated as a generator method named "A" in threejs/BufferGeometry.js.
Corrected by requiring the star to hug the name with zero intervening
whitespace -- every real formatter (Prettier included) emits `*foo()`,
never `* foo()`, so this is strictly more accurate, not a flexibility
regression. crucible_check.py showed a zero diff after the corrected fix
(confirmed expected: zero generator-method usage anywhere in the
~80-repo JS corpus).

Migrates javascript's test cases out of the four monolithic dict files
into tests/extraction/languages/test_javascript.py, and updates the epic
+ methodology doc with the new finding (recurring bug class 21: a fix's
own whitespace tolerance can open a new false-positive path, caught only
by the real-corpus check).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 1845586 into main Jul 31, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the feature/814-extraction-hardening-javascript branch July 31, 2026 03:32
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.

Extraction hardening: javascript

1 participant