Repository navigation
Fix #823: Extraction hardening for kotlin - #886
Merged
Merged
Conversation
Hardens all four extraction gauntlets for kotlin. This was a fresh sweep
(no pre-flagged known finding) and surfaced two real bugs:
- func_start/args shared a flat <[^>]{0,100}> Rule-11 generic-parameter
step-over, breaking any nested generic bound
(`fun <T, U : Comparable<U>> foo(x: T, y: U): T {`, a realistic
bounded generic function) -- the same bug class already fixed for
java/python/csharp/rust.
- class_start had no support for `companion object { ... }` at all
(almost always anonymous in real Kotlin -- a name is rare). The
tempting fix (making the general class/interface/object/enum-class
branch's name optional) would have opened a new false positive on
object EXPRESSIONS (`object : Base() {`, an anonymous object literal
used inline, a different construct from an object declaration).
Fixed instead with a dedicated alternative narrowly scoped to the
literal `companion object` shape with its own optional name, leaving
the general branch untouched.
Checked test_language_standards_strict.py for intentional kotlin
behavior before finalizing (per the lesson from c's #822 pass, where an
overly-broad fix broke a test documenting deliberate cross-rule
ambiguity) -- no conflicts found; the existing
test_kotlin_ambiguity_sweep_shared_literals_are_not_bugs test passes
unmodified.
crucible_check.py showed a zero diff -- confirmed expected: the corpus
has only 5 kotlin files (okhttp), with zero companion objects among
them (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 triple-quoted raw strings -- now
confirmed on a SEVENTH language.
Migrates kotlin's test cases out of the four monolithic dict files into
tests/extraction/languages/test_kotlin.py, and updates the epic +
methodology doc with the new findings (recurring bug classes 29-30).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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 #823.
Hardens all four extraction gauntlets (
func_start,args,class_start,_dependency_capture) for kotlin pertests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and surfaced two real bugs:func_start/argsshared a flat<[^>]{0,100}>Rule-11 generic-parameter step-over, breaking any nested generic bound (fun <T, U : Comparable<U>> foo(x: T, y: U): T {, a realistic bounded generic function) — the same bug class already fixed for java/python/csharp/rust.class_starthad no support forcompanion object { ... }at all (almost always anonymous in real Kotlin — a name is rare). The tempting fix (making the generalclass|interface|object|enum classbranch's name optional) would have opened a new false positive on object expressions (object : Base() {, an anonymous object literal used inline, a different construct from an object declaration). Fixed instead with a dedicated alternative narrowly scoped to the literalcompanion objectshape with its own optional name, leaving the general branch untouched.Checked
test_language_standards_strict.pyfor intentional kotlin behavior before finalizing (per the lesson from c's #822 pass, where an overly-broad fix broke a test documenting deliberate cross-rule ambiguity) — no conflicts found; the existingtest_kotlin_ambiguity_sweep_shared_literals_are_not_bugstest passes unmodified.Also documents a known, unfixed architectural limitation:
func_start's Mode-B string-shielding gap reproduces via triple-quoted raw strings — now confirmed on a seventh language.Differential Scan
Ran
python tests/tools/crucible_check.py: zero diff. Confirmed expected — the corpus has only 5 kotlin files (okhttp), with zero companion objects among them (confirmed by grep). Verification relied on regex-level empirical checks plus ReDoS scaling sweeps, consistent with recurring bug class 8 ("a zero diff can mean the corpus doesn't exercise the feature"). No golden master changes in this PR.Test plan
pytest tests/extraction/languages/test_kotlin.py(42 new tests) — run via barepytestfrom an unrelated CWD to reproduce CI's invocation stylepytest tests/core_engine/ tests/extraction/ -q— 3664 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed — including all existing kotlin ambiguity-sweep testspython 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 (zero diff, as expected — see above)tests/extraction/languages/test_kotlin.py🤖 Generated with Claude Code