Skip to content

Kotlin family validity: closures count trailing and implicit-it lambdas, doc stays on the declaration directly below (Part of #8863) - #9358

Merged
squid-shepherd[bot] merged 4 commits into
mainfrom
churn/9330-20261126T0126Z
Nov 26, 2026
Merged

squid-shepherd[bot] merged 4 commits into
mainfrom
churn/9330-20261126T0126Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #8863. Phase 2 of #9330 (Kotlin keyword-family red cells).

Checklist: partial [c:3d9860c9] -- the two cells that are red on the pinned crucible (closures, doc) are fixed; the five okhttp-only cells (time_date_logic, io, panics_and_aborts, bitwise_ops, regex_execution) are unpinned and not measurable there, left as sibling gaps below

What changed

Pinned language-crucible v1.9.0, Kotlin (246 oracle functions), measured before and after:

Cell Before After Cause
closures recall 0.42, precision 0.97 (29 vs 67) recall 1.00, precision 0.97 (69 vs 67) The rule counted only explicit-arrow lambdas ({ x -> }). It now also counts trailing lambdas (runBlocking {, .also {, lazy {, synchronized(this) {) and implicit-it lambdas, line-anchored, and skips declaration and control-flow blocks (fun headers, class/object/supertype headers, if/else/try/finally/when/for/while, init, companion, when branches).
doc precision 0.75 (40 vs 30), recall 1.00 precision 1.00 (30 vs 30) The 5-line doc window above a unit is language-agnostic, so a class or property KDoc was credited to the first function after it. For Kotlin the doc must now sit directly on the unit (only blank lines, annotations, // comments, ) or import/package lines between).

Files: languages/kotlin.py (closures rule), core/detector.py (_DOC_ADJACENT_LANGS, _only_header_trivia_between), new test test_kotlin_family_validity_9330.py (25 tests: 10 positive lambda forms, 13 declaration/control negatives, doc adjacency). Regenerated, not hand-edited: both golden masters, tests/family_validity_baseline.json (Kotlin cells only), the two family-validity SVGs.

Family-validity checklist

  • Oracle checked against the contract before the rule: yes, the oracle counts lambda literals and doc comments on functions; the rules were wrong, not the oracle.
  • Whole Kotlin row re-read after the change: closures and doc moved; the other four pinned Kotlin cells are unchanged.
  • Precision misses left: 2 closures over-counts (serialize, line 50 of the two ...ContextualTest.kt / ...ContextualListTest.kt files; slice bleed-through).

Golden diff

Both fixtures re-blessed with golden-lock.sh crucible_check.py --update --yes; a second bless after merging origin/main reports no drift. The diff is confined to Kotlin: closure counts (closures_lambdas), documentation_exposure, and the archetype aggregates that follow from them. No other language moved.

Measurements

  • CPU, data/kotlin, 3 alternating runs, user seconds: base 1.85 / 1.58 / 1.60, branch 1.59 / 1.61 / 1.61 (no change).
  • keyword-rosetta verify_language.py kotlin with this engine: the same 2 mismatches as with main (calls_out_to for probeBranch and probeBypass, unrelated). A first draft of the doc change broke units_documented (the plant puts the KDoc above a // comment and an import); fixed by treating import/package lines as trivia, and pinned by a test. No rosetta:rebless-owed needed.
  • audit_check.py all clear, ruff format --check clean.

Cross-repo

None: no crucible pin change, no rosetta change.

Class sweep

Same mechanism (language-agnostic 5-line doc window crediting a class or property doc to the next function) exists for every other language; I gated the fix to Kotlin so goldens elsewhere do not move.

Sibling gaps

  • Other languages share the doc window leak (_DOC_ADJACENT_LANGS is the opt-in list).
  • Kotlin okhttp-only cells: on the pinned crucible they have under 10 oracle functions, so they are faded, not red: panics_and_aborts fires 38 vs 5 (precision 0.13), io 29 vs 0, regex_execution 2 vs 0, time_date_logic 0 vs 6, bitwise_ops 3 vs 0. They need a corpus with enough functions (an okhttp pin) before they can be fixed or quoted; panics_and_aborts may need a contract question.
  • Python io moved on a fresh sweep (precision 0.84 -> 0.797, 75 -> 79 family functions) with no Python change in the golden diff, so it is not from this PR. I kept its committed baseline cell; someone should re-measure it.

Remaining slices

The five Kotlin cells above, and the doc-window leak in other languages.

Lessons for agents

  • tests/family_validity_baseline.json regeneration (family_oracle_sweep.py --write) rewrites every language's cells; diff it per language and keep only the language you changed (another language's drift is not yours).
  • The keyword-rosetta control plants its KDoc above a // comment and an import: any tightening of the doc window must run verify_language.py <lang> against it.
  • crucible_check.py run in the background: the log stays empty while queued behind another agent's bless on golden.lock.

Facts checked: pinned crucible v1.9.0 Kotlin 246 functions; before/after cells from family_oracle_sweep.py and a per-function diff against the tree-sitter oracle; baseline diff Kotlin-only; post-merge bless shows no drift.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits November 25, 2026 20:44
…as, doc stays on the declaration directly below (Part of #8863)

Closures recall 0.42 -> 1.00 (precision 0.97); doc precision 0.75 -> 1.00 on the pinned crucible. Goldens, baseline and charts regenerated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 26, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review November 26, 2026 01:51
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) November 26, 2026 01:51
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol squid-protocol added shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md and removed shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md labels Nov 26, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd

Copy link
Copy Markdown
Contributor

This PR conflicts with main, so no checks ran. Merge origin/main into it and regenerate generated files with their tools (never hand-merge them), then push.

@squid-shepherd
squid-shepherd Bot disabled auto-merge November 26, 2026 02:03
@squid-shepherd squid-shepherd Bot added the shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md label Nov 26, 2026
Golden conflicts (gpu_json, function_archetype_distribution, both fixtures) taken from main and re-blessed; family-validity chart regenerated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-shepherd squid-shepherd Bot removed the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 26, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

CI shepherd: the head of this PR (5735c71) is not the one a maintainer labelled shepherd:merge on (new commits, or never approved), so the label was removed and nothing merges unreviewed code. Re-add the label when the new head is ready (shepherd:reapprove marks this PR until then). Until then it is a draft and runs the cheap audits only; re-adding the label marks it ready, which starts the full set on that head.

@squid-shepherd
squid-shepherd Bot marked this pull request as draft November 26, 2026 02:29
@squid-shepherd squid-shepherd Bot added shepherd:reapprove Bot: new commits dropped shepherd:merge; re-add it to merge this head. Guide: docs/ci.md and removed shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md labels Nov 26, 2026
Golden and chart conflicts taken from main and regenerated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md and removed shepherd:reapprove Bot: new commits dropped shepherd:merge; re-add it to merge this head. Guide: docs/ci.md labels Nov 26, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review November 26, 2026 03:19
@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) November 26, 2026 03:20
@squid-protocol squid-protocol added shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md and removed shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md labels Nov 26, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot merged commit 6787d6b into main Nov 26, 2026
133 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant