Repository navigation
Fix #814: Extraction hardening for javascript - #878
Merged
Merged
Conversation
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]>
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.
Summary
Part of the extraction-hardening epic (#813). Closes #814.
Hardens all four extraction gauntlets (
func_start,args,class_start,_dependency_capture) for javascript pertests/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/argshad 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 viacrucible_check.pyagainst 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 namedAinthreejs/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 barepytestfrom an unrelated CWD to reproduce CI's invocation stylepytest tests/core_engine/ tests/extraction/ -q— 3544 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailedpython tests/tools/audit_check.py— clean (only the pre-existing, already-trackedguidestar_lens.pymypy findings, unrelated to this change)python tests/tools/crucible_check.py— PASS on both venvs (zero diff, as expected — see above)tests/extraction/languages/test_javascript.py🤖 Generated with Claude Code