Skip to content

Fix #822: Extraction hardening for c - #884

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

squid-protocol merged 1 commit into
mainfrom
feature/822-extraction-hardening-c

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

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

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for c per tests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and fixed one real bug in class_start: the struct/union/enum tag name was mandatory, so anonymous typedef'd structs (typedef struct { ... } Name;, an extremely common real C idiom) never matched at all, undercounting this structural signature. Made the tag name optional.

A worked example of the verification discipline catching a mistake before it shipped: an interim, broader version of this fix additionally required a trailing { to reject bare variable declarations of an existing struct type (struct Foo instance;). This broke test_c_intentional_double_classification_sweep (test_language_standards_strict.py), which explicitly documents that exact match as deliberate — designed to co-fire with the dependency_injection rule's _ops-vtable-suffix heuristic (e.g. struct foo_ops ops;). The trailing-{ requirement was reverted, keeping only the uncontested, purely-additive optional-tag-name fix. Flagging this openly since it's a good demonstration of why the full test suite step matters — this repo has an entire test file dedicated to documenting intentional cross-rule ambiguity as tested behavior, and it did its job here.

Also documents a known, unfixed architectural limitation: func_start's Mode-B string-shielding gap reproduces via un-decorated block comments (not strings — C has no raw strings, and its per-line-quoted string layout is structurally immune to the string-literal variant already confirmed on 6 other languages, a genuine negative result worth recording).

Differential Scan

Ran python tests/tools/crucible_check.py: cpython's dictobject.c and micropython's objtype.c each gained a real anonymous/inline-struct detection. The diff also touched files in python/numpy, lua/redis, scheme/racket, cobol/gnucobol_internals, and cpp/godot's object.h — all confirmed genuine C-classified files (verified via each file's own Language field, not just extension or repo label) embedded in repos labeled under a different primary language, not a confinement violation. Golden masters re-blessed via crucible_check.py --update --yes.

Test plan

  • pytest tests/extraction/languages/test_c.py (37 new tests) — run via bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3634 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed — critically, test_c_intentional_double_classification_sweep passes
  • 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 after re-blessing
  • Migrated c's cases out of the four monolithic dict files into tests/extraction/languages/test_c.py (class_start had no prior c entry there at all)
  • 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 26-28)

🤖 Generated with Claude Code

Hardens all four extraction gauntlets for c. This was a fresh sweep (no
pre-flagged known finding) and fixed one real bug in class_start: the
struct/union/enum tag name was mandatory, so anonymous typedef'd structs
(`typedef struct { ... } Name;`, an extremely common real C idiom) never
matched at all, undercounting this structural signature. Made the tag
name optional.

A broader interim fix was tried and reverted: additionally requiring a
trailing `{` (to reject bare variable declarations of an existing struct
type, e.g. `struct Foo instance;`) broke
test_c_intentional_double_classification_sweep
(test_language_standards_strict.py), which explicitly documents that
exact match as deliberate -- it's designed to co-fire with the
dependency_injection rule's `_ops`-vtable-suffix heuristic. This is a
genuine demonstration of the verification discipline working: the full
test suite caught a real conflict between what looked like an obvious
bug and existing, tested, intentional cross-rule ambiguity documentation
before it ever reached a PR.

Verified via crucible_check.py (structural JSON diff, not textual grep):
cpython's dictobject.c and micropython's objtype.c each gained a real
anonymous/inline-struct detection. The diff also touched files in
python/numpy, lua/redis, scheme/racket, cobol/gnucobol_internals, and
cpp/godot's object.h -- all confirmed genuine C-classified files (via
each file's own "Language" field) embedded in repos labeled under a
different primary language, not a confinement violation.

Also documents a known, unfixed limitation: func_start's Mode-B
string-shielding gap reproduces via un-decorated block comments (not
strings -- C has no raw strings, and its per-line-quoted string layout
is structurally immune to the string-literal variant already confirmed
on 6 other languages, a genuine negative result).

Migrates c's test cases out of the four monolithic dict files into
tests/extraction/languages/test_c.py (class_start had no prior c entry
there at all), and updates the epic + methodology doc with the new
findings (recurring bug classes 26-28, including a new standing
reminder to check test_language_standards_strict.py for intentional
cross-rule behavior before treating a permissive match as a bug).

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 6bd7df8 into main Jul 31, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the feature/822-extraction-hardening-c branch July 31, 2026 04:50
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: c

1 participant