Skip to content

Fix #824: Extraction hardening for swift - #888

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

squid-protocol merged 1 commit into
mainfrom
feature/824-extraction-hardening-swift

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

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

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for swift per tests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) 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 pass predating this epic; 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.

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 bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3688 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed — including all existing swift ambiguity-sweep tests
  • 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 swift's cases out of the four monolithic dict files into tests/extraction/languages/test_swift.py
  • Epic Epic: Harden the four extraction gauntlets (function/args/class/dependency) per language #813 and the methodology doc updated with the new findings (recurring bug classes 31-32)

🤖 Generated with Claude Code

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>
@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 428a8a3 into main Jul 31, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the feature/824-extraction-hardening-swift branch July 31, 2026 05:23
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: swift

1 participant