Skip to content

Fix #821: Extraction hardening for cpp - #882

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

squid-protocol merged 1 commit into
mainfrom
feature/821-extraction-hardening-cpp

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

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

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for cpp per tests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and surfaced two real bugs:

  • func_start/args had zero allowance for a class-qualifier before the operator keyword, so out-of-line operator overload definitions (TargetClass::operator=(...), TargetClass::operator==(...), declared in a header and defined in a .cpp file, mainstream C++) were completely invisible — even though bare (non-qualified) operator=(...) already worked. This is a distinct failure mode from the Rule-11 nesting bug already fixed elsewhere in this epic: the operator alternative simply never had the qualifier-prefix group the plain-identifier alternative already had.
  • args also needed the established nested-template step-over for the method's own template arguments (Foo::Bar<Baz<int>>(...), an explicit template specialization), matching the Rule 11 idiom already proven in func_start.

Also documents a known, unfixed architectural limitation (out of scope for a single-language pass, tracked in the epic): func_start's Mode-B string-shielding gap reproduces on C++ raw string literals (R"(...)") — now confirmed on a sixth language. class_start's lack of a base-clause capture group was confirmed to be cpp's original, deliberate design (one capture group only, unlike java/python/csharp) — not a regression.

Differential Scan

Ran python tests/tools/crucible_check.py: 7 real files across 4 repos (mlir, NVDA, powertoys, godot) gained newly-detected operator functions and/or parameter counts. NVDA's storage.cpp function count jumped 10 → 13 for its 3 out-of-line comparison operators; powertoys' centralized_kb_hook.cpp already detected operator< but previously reported 0 parameters, now correctly reports 3.

Note on verifying confinement: a naive textual git diff | grep on the update produced dozens of false "other language" hits (.zig, .pm, unrelated .h paths) — these turned out to be pre-existing dependency-list values sitting inside other files' JSON entries, not actually-changed entries. Re-verified with a proper structural diff (loading pre/post JSON and comparing only the "6. Parsed Files (Scanned Artifacts)" -> "<repo>" -> "Files" keys), which correctly confirmed all 7 changed files are cpp. Documented as a new methodology lesson (recurring bug class 25) so this doesn't cost time again on a future language.

Test plan

  • pytest tests/extraction/languages/test_cpp.py (42 new tests) — run via bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3606 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed
  • 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 cpp's cases out of the four monolithic dict files into tests/extraction/languages/test_cpp.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 24-25)

🤖 Generated with Claude Code

Hardens all four extraction gauntlets for cpp. This was a fresh sweep
(no pre-flagged known finding) and surfaced two real bugs:

- func_start/args had zero allowance for a class-qualifier before the
  `operator` keyword, so out-of-line operator overload definitions
  (`TargetClass::operator=(...)`, `TargetClass::operator==(...)`,
  declared in a header and defined in a .cpp file, mainstream C++) were
  completely invisible -- even though bare (non-qualified) `operator=(...)`
  already worked. Distinct failure mode from the Rule-11 nesting bug
  already fixed elsewhere in this epic: the operator alternative simply
  never had the qualifier-prefix group the plain-identifier alternative
  already had.

- args also needed the established nested-template step-over for the
  method's own template arguments (`Foo::Bar<Baz<int>>(...)`, an
  explicit template specialization), matching the Rule 11 idiom already
  proven in func_start.

Verified via crucible_check.py: 7 real files across 4 repos (mlir, NVDA,
powertoys, godot) gained newly-detected operator functions and/or
parameter counts. NVDA's storage.cpp function count jumped 10 -> 13 for
its 3 out-of-line comparison operators; powertoys' centralized_kb_hook.cpp
already detected `operator<` but previously reported 0 parameters, now
correctly reports 3. A structural JSON diff (not a textual git-diff grep,
which produced false "other language" hits from unrelated dependency-list
values) was needed to correctly confirm confinement to cpp -- see the
epic for the full lesson.

Also documents a known, unfixed limitation: func_start's Mode-B
string-shielding gap reproduces on C++ raw string literals (R"(...)")
-- now confirmed on a SIXTH language. class_start's lack of a base-clause
capture group was confirmed to be cpp's original, deliberate design (one
capture group only), not a regression of the java/python/csharp bug.

Migrates cpp's test cases out of the four monolithic dict files into
tests/extraction/languages/test_cpp.py, and updates the epic +
methodology doc with the new findings (recurring bug classes 24-25).

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 93abae1 into main Jul 31, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the feature/821-extraction-hardening-cpp branch July 31, 2026 04:18
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: cpp

1 participant