Repository navigation
Call graph: C#, Kotlin and PHP — gate lanes, overloads by argument type, PHP inheritance, library-type guard (Part of #8161) - #8202
Merged
Conversation
…acked ones; Kotlin had 0 defs (Part of #8161) scip-java 0.13's Kotlin indexer writes single_line_range / multi_line_range and the enclosing forms as messages instead of the packed fields 1 and 7, so read_index left every Kotlin occurrence without a position: 0 defs (and a crash in contract_from_index) on kotlinpoet. Now 1,880 defs and 4,569 edges before the Kotlin conventions. An occurrence with no range at all is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
… (Part of #8161) The language-admission survey (engine-tuning-study/lang-survey) admitted C#, Kotlin and PHP to the LAWS panel with a survey-local adapter. Its conventions are now the gate's (tests/tools/scip_lang.py): extents read from the source where scip-dotnet / scip-php write none, C# `.ctor` and explicit interface names, the first attribute line, PHP `__construct`, scip-java 0.13's Kotlin defs (KDoc, `constructor`, synthesized members) and its named-call rule, and the M3 scope (test, example, doc, vendored and generated code out on both sides; a reference's `indexed` files are the only ones scored, through RefGraph.is_vendored). References, pinned as the survey ran them and built on a copy of the corpus checkout: - csharp: scip-dotnet 0.2.16 (.NET SDK 10.0.403) on Newtonsoft.Json @52fa3ae, net10.0 only; - kotlin: scip-java v0.13.2 (release binary, by sha256; scip-kotlinc), JDK 21, on kotlinpoet @d438267; - php: scip-php 0.0.2 (fetched with composer) on composer @3a5137b (main @71a5b11 is sensitivity only). A corpus entry's `callgraph_build` carries the repo's project / Gradle arguments (in the cache key). Corpus: kotlinpoet 5707384 -> d438267 (its import-graph numbers are identical), composer added for the call gate only (`import_graph: false`), guzzle and xunit import-graph only. Each rebuilt reference equals the survey's ref-*.json (defs, edges, external), and the lanes score the PR 4 engine exactly as the survey scored its engine (confident precision / strict / recall): C# 81.8 / 80.6 / 59.1 (577 of 623 wrong are overloads), Kotlin 81.9 / 79.7 / 32.0, PHP 99.8 / 99.0 / 87.1. Those are the baselines. C# and Kotlin report the overload-blind view. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…art of #8161) - graph_accuracy_plan: call-csharp and call-kotlin are gates (a scip_callgraph.py or scip_lang.py change moves them; their language standards select them); kotlin needs the JDK switch, csharp a new `dotnet` switch. - graph-accuracy-audit.yml: actions/setup-dotnet v6.0.0 (SDK 10.0.403) and `dotnet tool install scip-dotnet --version 0.2.16`, only when planned; a restore/save cache (main only) for the scip-java binary, Gradle and NuGet; csharp joins the cpp/python/c lane (~35 s with its reference build) and kotlin the rust/go lane (~145 s with kotlinpoet's Gradle build). - scip_lang: the Kotlin adapter fetches scip-java v0.13.2's release binary itself and checks its sha256 (5248136592d1...), as the java adapter fetches its jars; a `scip-java` on PATH or GITGALAXY_SCIP_JAVA_BIN is used when it has that sha256. - session hook: the scip-java binary, scip-dotnet and scip-php, each when its toolchain is there. - docs/graph_accuracy.md: the three references, their conventions and limits. php stays local-only: the static PHP 8.4.23 build the survey used is rebuilt in place at its download site (its sha256 no longer matches), and the reference was not checked under the runner's PHP. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…aults and params/vararg widen the counts (Part of #8161) core/overload_types.py ports java_arg_types to C# and Kotlin: the detector records each call site's argument types (literals with their suffixes, typed locals / parameters / fields, `new T(..)`, casts, `nameof`, `typeof`; Kotlin `T(..)` constructions, `T::class`, `x as T`, `val x = <literal>`) and each unit's parameter types and accepted counts (C# defaults and `params`, Kotlin defaults and `vararg`; a C# extension method's `this` receiver is not an argument; a Kotlin trailing lambda is one). C# and Kotlin join call_resolver.OVERLOAD_LANGS: among the overloads a call's count fits, the one the language picks (C#: identity, implicit numeric conversions, Nullable<T>, boxing; Kotlin: no numeric widening, nullability) when certain; an unknown argument, a maybe-applicable candidate (a user-defined implicit operator, an int literal to a narrower integral, a Kotlin integer literal to Long) or a tie keeps the `overload` row. Because the detector now keeps a bare call to the unit's own name in these languages (#3772), an overload delegating to a same-named overload (`WriteValue` -> `WriteValue(..)`, Kotlin expression bodies `builder(..) = builder(..)`) is a call again, pruned as recursion only when the count picks the unit itself. The #5628 rule (a bare `f(` in `Scope::f` may reach a free `f`) is C++'s: in C# and Kotlin the member shadows the top-level function. Gates (vs the survey's references; confident precision / strict / recall, wrong-overload): - csharp (Newtonsoft.Json, scip-dotnet): 81.8 / 80.6 / 59.1, 577 -> 98.2 / 96.9 / 71.0, 9 - kotlin (kotlinpoet, scip-java): 81.9 / 79.7 / 32.0, 88 -> 97.0 / 93.7 / 32.4, 7 (Kotlin's arguments are mostly expressions whose type the scan does not read -- `x.asTypeName()` -- so most of its overload links became `overload` rows, not decided links; resolution recall 32.6 -> 31.2 because the delegating self-name calls are now extracted names.) Other lanes are language-gated (Java keeps java_arg_types). Tests: tests/core_engine/test_overload_types_csharp_kotlin_8161.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
… / `parent::m()` reach inherited methods (Part of #8161) PHP's class_start captures no parent, so every PHP class had `inheritance: []`: `$this->getIO()` in a BaseCommand subclass could not walk to BaseCommand::getIO and was only the ambiguous `receiver` guess (186 of composer's reference edges), and `parent::m()` / `parent::__construct()` had no parent to reach (111). The detector now reads the class's `extends B` (leaf name) and the traits its body `use`s at top level (`use A, B;`: their methods are the class's own; a closure's `use ($x)` is not one). Interfaces are not parents here (their methods are bodyless). Gate php (composer vs scip-php 0.0.2; confident precision / strict / recall / resolution recall): 99.8 / 99.0 / 87.1 / 87.2 -> 99.9 / 99.0 / 96.3 / 98.2 (2948 judged, was 2670). Ambiguous precision 93.9 -> 55.6: what remains ambiguous is now mostly the hard residue. Test: tests/core_engine/test_php_class_parents_8161.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…ss (Part of #8161) The call was to a callee named `self` / `static`, which no definition has (58 of composer's reference edges to a `__construct`). Inside a class method the detector now names the class itself, as `new C(..)` does, so the resolver reaches its constructor (`static` may be a subclass at run time; the class the text names is the static target, which scip-php records). Gate php (composer vs scip-php 0.0.2): confident precision 99.9 / strict 99.0 unchanged, recall 96.3 -> 97.9 (agree 2945 -> 2995). Test: tests/core_engine/test_php_class_parents_8161.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…e builtins); `static::` is `self::` (Part of #8161) A bare `count(..)` / `\count(..)` / `unlink(..)` inside a class with its own `count` / `unlink` method walked the class's lineage and linked that method; PHP reaches a method only through `$this->`, `self::`, `static::` or `parent::`, so the call is PHP's builtin (scip-php: resolved outside the repo). A bare PHP call now reaches free functions only. `static::m()` (late static binding) is resolved like `self::m()`, the class's own lineage. Gate php (composer vs scip-php 0.0.2): confident precision 99.9, strict 99.0 -> 99.6 (external 28 -> 9), recall 97.9 unchanged. Test: tests/core_engine/test_php_class_parents_8161.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…idently only as the one definition of its name (Part of #8161) A Kotlin extension function (`fun String.escapeIfKeyword()`) has no owning class, so a receiver call (`name.escapeIfNotJavaIdentifier().escapeIfKeyword()`, `decl.toClassName()`) could reach only methods: 399 of kotlinpoet's reference edges were named but never linked. Extension functions (and C# extension methods, `this` on the first parameter) now carry def_shape `extension`, and the resolver's receiver lookup includes Kotlin's. A receiver the scan cannot type picks among every same-named definition, so an extension is a confident link only when it is the one definition of the name (or the only file and owner defining it); beside an extension on another receiver type or a method (`x.asTypeName()` with `ParameterizedType.asTypeName` in the caller's file and `Type.asTypeName` elsewhere) it is the ambiguous `receiver` guess. Gates (confident precision / strict / recall): - kotlin (kotlinpoet vs scip-java): 97.0 / 93.7 / 32.4 -> 97.3 / 94.3 / 35.9 - csharp (Newtonsoft.Json vs scip-dotnet): 98.2 / 96.9 / 71.0 -> 98.4 / 97.3 / 70.8 (an extension method beside a same-named method elsewhere is now the receiver guess: 10 fewer agree, 6 fewer wrong) Test: tests/core_engine/test_kotlin_extension_receivers_8161.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…eaches its class's method (X3 for C#, Part of #8161) `writer.WriteStartArray()` with `JsonWriter writer` linked the same-named override in JTokenWriter or TraceJsonWriter (the import / file rung) instead of JsonWriter's own method, which the compiler binds statically (~45 of the remaining wrong links). overload_types.receiver_types reads a C# unit's declarations (`T x`, `var x = new T(..)`, `T? x` for a class, pattern variables) and the file's fields (bare or `this.x`), and C# now records calls_out_receiver_types, so the resolver's `typed` step answers with the class's method, or an ancestor's. A primitive, an array or an unknown binding types nothing. Kotlin is not switched on: on kotlinpoet it adds recall (35.9 -> 39.1) but costs confident precision (97.3 -> 97.0): its nested same-named classes (`FunSpec.Builder`, `CodeBlock.Builder`) make a leaf type name ambiguous, and a repo-wide "one class of that name" rule would also drop C#'s partial classes. Gate csharp (Newtonsoft.Json vs scip-dotnet; confident precision / strict / recall / resolution recall): 98.4 / 97.3 / 70.8 / 71.1 -> 99.7 / 98.4 / 79.0 / 79.4 (wrong 54 -> 13). Test: tests/core_engine/test_csharp_receiver_types_8161.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…method, only an extension (Part of #8161) `_reader.ReadByte()` on a `BinaryReader _reader` linked BsonReader.ReadByte; `p.GetValue(..)` on a PropertyInfo, `char.IsWhiteSpace(c)`, `s.trim()` on a Kotlin String linked repo functions of the same name, which the compiler resolves outside the repo (scip: `external`). When a C# or Kotlin call's receiver is declared with a type the repo does not define (or is a C# keyword type), only an extension method / function can answer it; any other link is dropped. Kotlin now records receiver types for this guard only: they do not yet answer the `typed` step (_GUARD_ONLY_RECEIVER_TYPES; its nested same-named Builder classes cost precision there). Gates (confident precision / strict / recall; external): - csharp (Newtonsoft.Json vs scip-dotnet): 99.7 / 98.4 / 79.0, 46 -> 99.7 / 99.0 / 79.0, 23 - kotlin (kotlinpoet vs scip-java): 97.3 / 94.3 / 35.9, 16 -> 97.3 / 95.2 / 35.9, 11 Tests: test_csharp_receiver_types_8161.py, test_kotlin_extension_receivers_8161.py (both fail without the guard). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
`tests/tools/crucible_check.py --update --yes` (both modes). Before it, the check failed only on the crucible's PHP files (symfony's Application.php / ContainerBuilder.php) and their aggregates: PHP classes now have parents (`extends`, trait `use`), so `$this->m()` / `parent::m()` reach inherited methods, and a bare builtin (`count()`, `unlink()`) no longer reaches a same-named method. Function fan-in / fan-out / PageRank, the confident call pairs that join the file graph (import_edges, blast radius, network macro, bottlenecks), the repository fingerprint and the LLM brief move with them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
… and pruned as recursion (Part of #8161) test_calls_out_scoped_same_name_5628 pinned that C#'s `Rec(n - 1)` inside `Rec` is dropped by the detector. Since C# joined OVERLOAD_LANGS (overload_types.py) the detector keeps a bare self-name call with its argument count, as for C++ (#3784): a same-named sibling overload is a call, and the resolver prunes the call as recursion when the count picks only the unit itself. The test now pins both. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
Contributor
| if suffix not in ("().", "."): | ||
| return None | ||
| if lang in _LANG_CONVENTIONS: | ||
| import scip_lang |
| except OSError: | ||
| sources[d.path] = [""] | ||
| if lang in _LANG_CONVENTIONS: | ||
| import scip_lang |
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import scip_callgraph as sc |
| packed_wins = _field(1, _packed([1, 2, 3])) + _field(2, "k g().") + multi | ||
| rangeless = _field(2, "k h().") | ||
| doc = _field(1, "a.kt") + _field(2, typed) + _field(2, packed_wins) + _field(2, rangeless) | ||
| _tool, (d,) = sc.read_index(_field(2, doc)) |
# Conflicts: # tests/golden_master_audit/12_scan_output_snapshots/gpu_json.json # tests/golden_master_zero_dep_audit/12_scan_output_snapshots/gpu_json.json
Main's copies were taken at the merge and regenerated on the merged tree: only the crucible's C# (roslyn) and PHP (symfony, laravel_core) files and their aggregates moved, on both legs. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhAwXV1YnZkSqahDsn
Contributor
|
No description provided. |
Contributor
|
No description provided. |
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.
Part of #8161. PR 5: C#, Kotlin and PHP, the three languages LAWS Amendment 2 admitted to the many-labs panel (temporal-crucible #106, #107). They now have call-graph gate lanes on the admission-survey repos, and their resolution is tuned.
What changes
tests/tools/scip_callgraph.pyreads SCIP typed ranges (Occurrence fields 8–11). Kotlin had 0 defs before.tests/tools/scip_lang.py. Each rebuilt reference matches the survey's exactly, and the baselines are the survey's numbers.graph-accuracy-audit.yml: setup-dotnet and scip-dotnet are cached, and Kotlin fetches its pinned binary. PHP is local-only for now (no pinned PHP runtime in CI yet).core/overload_types.py, ported from Java's J1). Defaults andparams/varargwiden the counts. A call to the same name with different arguments is no longer dropped as recursion.extendsand traitusemake a class's parents, so$this->m()andparent::m()reach inherited methods.new self()/new static()construct the method's own class. A bare call never reaches a method (count()andunlink()are builtins).static::is treated asself::.Gates (confident precision / strict / recall / wrong-overload)
Network statistics (ACC-H3 bars: ρ ≥ 0.80, J ≥ 0.50, κ ≥ 0.60; dev repos, descriptive):
import_graph_accuracy --ci(27 languages), DOOM-rosetta, the dead-key, ruff, mypy and doc-refs audits, and the unit suites (extraction, recorders, core_engine).Follow-ups
x.asTypeName(), C# method results). Most Kotlin overload sites wait on this.FunSpec.Builder/CodeBlock.Builder). It was tried: recall 35.9 → 39.1, but precision 97.3 → 97.0, so it is not switched on.super.m()through Kotlin interface default methods.🤖 Generated with Claude Code
https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF