Skip to content

Fix #816: Extraction hardening for java - #868

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

squid-protocol merged 1 commit into
mainfrom
feature/816-extraction-hardening-java

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

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

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for java per tests/extraction/how_to_harden_extraction.md, and fixes three real bugs found during empirical verification:

  • func_start/args shared a flat <[^>]*> generic-bound modifier alternative (the "Rule 11" bug class) that truncated at the first >, breaking any single-line one-level-nested generic bound, e.g. public static <T, U extends Comparable<U>> T Foo(T a, U b) {. Widened to the established one-level-nesting idiom <(?:[^<>]|<[^<>]*>)*>.
  • class_start had no generic-parameter step-over at all between the class name and its extends/implements check (a worse variant of the same bug class than TypeScript's Extraction hardening: typescript #815 fix, which only needed widening an existing-but-flat step-over) — so any generic class declaration followed by extends/implements (class Foo<T> extends Base<T> {, common real Java) silently lost the entire inheritance capture even though the class name itself matched fine.

Also documents two known, unfixed architectural limitations (out of scope for a single-language pass, tracked in the epic for a future follow-up):

  • func_start's Mode-B string-shielding gap (_slice_by_braces, currently gated to js/ts only) reproduces on Java 15+ text blocks — confirms recurring bug class 3 is a genuine cross-language gap, not a js/ts quirk.
  • _dependency_capture is matched against fully unshielded raw file content for every language (broader than the Mode-B gap, since there's no gate at all there) — new recurring bug class, recorded in the epic.

Differential Scan

Ran python tests/tools/crucible_check.py: the only diff across the ~80-repo corpus is gradle's DefaultPluginManager.java, which now correctly detects findPluginIdForClass (public <P extends Plugin<?>> Optional<PluginId> findPluginIdForClass(...)) — exactly the nested-generic-bound shape this PR fixes, previously silently dropped from the function count (35 → 36 functions detected). Confirmed no other language/file is affected. Golden masters re-blessed for this on-target, expected change via crucible_check.py --update --yes.

Test plan

  • pytest tests/extraction/languages/test_java.py (67 new tests) — run via bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3381 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 java's cases out of the four monolithic dict files into tests/extraction/languages/test_java.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 9-12)

🤖 Generated with Claude Code

Hardens all four extraction gauntlets for java and fixes three real bugs
found during empirical verification:

- func_start/args shared a flat `<[^>]*>` generic-bound modifier
  alternative (Rule 11 bug class from how_to_add_a_language.md), breaking
  any single-line one-level-nested generic bound, e.g.
  `public static <T, U extends Comparable<U>> T Foo(T a, U b) {`. Widened
  to the established one-level-nesting idiom `<(?:[^<>]|<[^<>]*>)*>`.

- class_start had no generic-parameter step-over at all between the class
  name and its extends/implements check, so any generic class declaration
  followed by extends/implements (`class Foo<T> extends Base<T> {`,
  common real Java) silently lost the entire inheritance capture even
  though the class name itself matched fine.

Verified via crucible_check.py: the only diff across the ~80-repo corpus
is gradle's DefaultPluginManager.java, which now correctly detects
`findPluginIdForClass` (a real method with `<P extends Plugin<?>>`, the
exact nested-generic-bound shape this fixes) -- previously silently
dropped. Golden masters re-blessed for this on-target, expected change.

Also documents two known, unfixed architectural limitations (out of scope
for a single-language pass, tracked in the epic): func_start's Mode-B
string-shielding gap reproduces on Java 15+ text blocks (recurring bug
class 3, now confirmed on a second language), and _dependency_capture
runs against fully unshielded raw file content for every language (new
recurring bug class, broader than the Mode-B gap).

Migrates java's test cases out of the four monolithic dict files into
tests/extraction/languages/test_java.py per the epic's per-language file
layout, and updates the epic + methodology doc with the new findings.

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 e24e1a2 into main Jul 31, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the feature/816-extraction-hardening-java branch July 31, 2026 01:20
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: java

1 participant