Repository navigation
Fix #822: Extraction hardening for c - #884
Merged
Merged
Conversation
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]>
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 #822.
Hardens all four extraction gauntlets (
func_start,args,class_start,_dependency_capture) for c pertests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and fixed one real bug inclass_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 broketest_c_intentional_double_classification_sweep(test_language_standards_strict.py), which explicitly documents that exact match as deliberate — designed to co-fire with thedependency_injectionrule'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'sdictobject.cand micropython'sobjtype.ceach gained a real anonymous/inline-struct detection. The diff also touched files inpython/numpy,lua/redis,scheme/racket,cobol/gnucobol_internals, andcpp/godot'sobject.h— all confirmed genuine C-classified files (verified via each file's ownLanguagefield, not just extension or repo label) embedded in repos labeled under a different primary language, not a confinement violation. Golden masters re-blessed viacrucible_check.py --update --yes.Test plan
pytest tests/extraction/languages/test_c.py(37 new tests) — run via barepytestfrom an unrelated CWD to reproduce CI's invocation stylepytest tests/core_engine/ tests/extraction/ -q— 3634 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed — critically,test_c_intentional_double_classification_sweeppassespython 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 after re-blessingtests/extraction/languages/test_c.py(class_starthad no prior c entry there at all)🤖 Generated with Claude Code