Repository navigation
Fix #824: Extraction hardening for swift - #888
Merged
Merged
Conversation
Hardens all four extraction gauntlets for swift. This was a fresh sweep
(no pre-flagged known finding) and fixed one real bug shared by
func_start/args: the generic-parameter step-over was the flat
<[^>]*>, truncating at the FIRST `>` and breaking any nested generic
bound via a Swift 5.7+ primary associated type constraint
(`func foo<T: Collection<Int>>(x: T) {`, mainstream modern Swift).
Widened to the established one-level-nesting idiom.
This is now the 7th of 9 generics-capable languages checked in this
epic (java, typescript, go, python, rust, csharp, kotlin, swift) to
have this exact Rule-11 bug class in at least one rule -- the two
exceptions (cpp, already immune except in args from a pre-epic pass;
c, no generics) prove the rule rather than break it.
Checked test_language_standards_strict.py for intentional swift
behavior before finalizing (per c's #822 lesson) -- no conflicts; the
existing test_swift_ambiguity_sweep_shared_literals_are_not_bugs test
passes unmodified.
crucible_check.py showed a zero diff -- confirmed expected: the corpus
has only 6 swift files, none using nested generic bounds (confirmed by
grep). Verification relied on regex-level empirical checks plus ReDoS
scaling sweeps, consistent with recurring bug class 8.
Also documents a known, unfixed limitation: func_start's Mode-B
string-shielding gap reproduces via BOTH triple-quoted multi-line
strings and #"..."# raw string literals -- now confirmed on an EIGHTH
language.
Migrates swift's test cases out of the four monolithic dict files into
tests/extraction/languages/test_swift.py, and updates the epic +
methodology doc with the new findings (recurring bug classes 31-32).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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 #824.
Hardens all four extraction gauntlets (
func_start,args,class_start,_dependency_capture) for swift pertests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and fixed one real bug shared byfunc_start/args: the generic-parameter step-over was the flat<[^>]*>, truncating at the first>and breaking any nested generic bound via a Swift 5.7+ primary associated type constraint (func foo<T: Collection<Int>>(x: T) {, mainstream modern Swift). Widened to the established one-level-nesting idiom.This is now the 7th of 9 generics-capable languages checked in this epic (java, typescript, go, python, rust, csharp, kotlin, swift) to have this exact Rule-11 bug class in at least one rule — the two exceptions (cpp, already immune except in
argsfrom a pass predating this epic; c, no generics) prove the rule rather than break it.Checked
test_language_standards_strict.pyfor intentional swift behavior before finalizing (per c's #822 lesson) — no conflicts; the existingtest_swift_ambiguity_sweep_shared_literals_are_not_bugstest passes unmodified.Also documents a known, unfixed architectural limitation:
func_start's Mode-B string-shielding gap reproduces via both triple-quoted multi-line strings and#"..."#raw string literals — now confirmed on an eighth language.Differential Scan
Ran
python tests/tools/crucible_check.py: zero diff. Confirmed expected — the corpus has only 6 swift files, none using nested generic bounds (confirmed by grep). Verification relied on regex-level empirical checks plus ReDoS scaling sweeps, consistent with recurring bug class 8. No golden master changes in this PR.Test plan
pytest tests/extraction/languages/test_swift.py(36 new tests) — run via barepytestfrom an unrelated CWD to reproduce CI's invocation stylepytest tests/core_engine/ tests/extraction/ -q— 3688 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed — including all existing swift ambiguity-sweep testspython 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_swift.py🤖 Generated with Claude Code