Skip to content

fix(registry): refuse name-only member calls nothing ties to the receiver - #2977

Merged
DeusData merged 2 commits into
mainfrom
fix/registry-receiver-gate
Nov 14, 2026
Merged

DeusData merged 2 commits into
mainfrom
fix/registry-receiver-gate

Conversation

@DeusData

Copy link
Copy Markdown
Owner

Follows #2968 (merged).

Problem

#1897's receiver-chain gate judges only member calls whose chain starts with a
type (URLSession.shared.data). A chain rooted in a lower-case value
(tp.topic(), strings.Join()) passed through unjudged, and the two
suffix_match exits of resolve_multi_with_imports (every file with imports)
were never gated at all. So a member call that no LSP had typed bound whatever
project symbol shared its final name:

  • kafka: tp.topic() on a TopicPartition -> ConsumerRecord.topic
  • gardener: strings.Join(...) -> pkg/utils/net.Join
  • finagle: Future.exception(...) -> a thrift service's exception
  • koel: Song::query()->...->sort(...) -> AlbumBuilder.sort
  • plausible: site.domain (a struct field) -> a private domain/0 function

Fix

At the registry's name-only exits (unique_name, suffix_match, and the
import fallback), a CALLS resolve of a member call whose receiver is a value or
a new X(...) constructor now binds only on evidence that it means the chosen
candidate. Any one of these counts as evidence:

  • a chain segment names a segment of the candidate's ancestry, compared word by
    word, case- and underscore-blind: repo / Repo, cleanerManager /
    LogCleanerManager, otel_guard / OtelGuard, new RaftContext.Builder() /
    RaftContext.Builder, and the receiver handed to verify(x) / when(x);
  • the candidate lives in the caller's own module;
  • the candidate is reachable through the file's imports;
  • for a C/C++ call onto a struct member, the C member resolver decides it from
    the object's type;
  • in C/C++, the caller's own file declares the candidate's owner type (a class
    re-declared above Widget w(n); w.get_id()), which is all the C++ resolver
    had to type the receiver against.

If another candidate is the field-type hint's own pick, the call is left for
that re-pick.

Otherwise the guess is refused. It is a veto and never a re-pick: a refused
call stays unresolved, as with the cross-language veto. Self receivers (this,
self, cls, super, base, this_, _this) and :: namespace paths are
not judged. import_map, same_module, qualified_suffix and every lsp_*
strategy run before these exits and are untouched. The existing type-root check
now also covers the import fallback.

This is a language-agnostic suppressor inside the registry. The maintainers
accept that shape only as a recorded exception (exception 5 to the per-language
suppressor rule) and with the evidence #1897 met: upstream strategies
untouched, and a blast radius measured per language on real graphs and read by
hand. So the gate runs from an allowlist by measurement: a language is gated
only where its own measured precision cleared the bar, and every other
language, measured below it or not measured, keeps its name-only binds.

Scope and measurement

Each language was judged on hand-read seeded samples of the CALLS the gate
refuses on a real corpus, with fresh seeds per round. The precision column is
the share of refused edges that were wrong; the bar is about 85%. Where a
language's suffix_match picks cleared it and its unique_name binds did not,
only the suffix_match picks are judged and the unique_name binds are kept.

Language Gate CALLS refused (corpus) Wrong / judged Right edges lost (est.)
Go whole gardener: 339; opentelemetry-demo: 40 25/25; 25/25 0 seen
C++ (.cc, .h) whole opentelemetry-demo: 122 25/26 ~5
C# whole opentelemetry-demo: 5 5/5 0
Lua, Tcl whole redis: 14, 1 14/14, 1/1 0
Groovy (Gradle) whole kafka: 6; opentelemetry-demo: 1 7/7 0
Elixir whole plausible/analytics a39465fe: 1,885 suffix_match 30/30; unique_name 24/25 ~12
Scala suffix_match only kafka 4.0.0: 5,183; finagle ca472deb with #2360: 6,302 29/30; 28/30 ~600
Rust suffix_match only meilisearch 979167f: 4,503 53/60 (unique_name 20/25: kept) ~525
PHP suffix_match only koel 04ed8be: 938 30/30 (unique_name 15/25: kept) 0 seen
Java off (kafka: suffix_match only) 47/60 -
Kotlin off (JetBrains/Exposed c419caa: 8,730 if gated) 10/20 -
Swift off (swift-nio b440f7b: 18; flutter/packages 34b89b2: 60) 18/18; 20/42 -
Ruby off (rails 4b70e83: 54,106 if gated) 24/29; an earlier corpus 3/15 -
Objective-C off (flutter/packages: 64) 1/30 -
C off redis: 0 refused - -
Dart off flutter/packages: 0 refused - -
Python, JS/TS/TSX/ArkTS, Perl off 0 refused when gated own member guard after resolution -
Every other language off not measured - -

Notes on the languages left out or limited:

  • Scala, Rust and PHP keep their unique_name binds. A project's one
    method of a name is often what the untyped receiver means there: Rust's
    s.set_searchable_fields(...) inside update_settings(|s| ...), PHP's
    trait methods on parameter-typed receivers ($playlist->addCollaborator).
  • Java stays below the bar even with suffix_match only. Most of the right
    edges it would refuse sit behind a receiver that is a method's return value
    (groupByKey().count()), which only the Java LSP can type.
  • Kotlin: extension functions on value receivers (users.cityId.isNull(),
    tester1.insertAndGetId {}) bind right by name.
  • Swift: calls through a typed receiver's closure property and subscripts
    of its stored property (delegate?.completionHandler(...),
    cam.inProgressSavePhotoDelegates[id]) bind right by name.
  • Ruby: 24/29 on rails, 3/15 on the earlier corpus; below the bar on both.
  • Objective-C: protocol messages ([api waitForMapWithError:&error]) bind
    to the protocol's one implementation, which is what runs.
  • C and Dart: the gate refused nothing on redis and flutter/packages.
  • Python, the JS/TS family and Perl already drop these guesses with their
    own guards. Gating them before resolution changed no CALLS, but it skipped
    the URL-argument HTTP classification those guards keep.

Side effects

  • Fake edges removed: kafka loses 620 ASYNC_CALLS, all fake "kafka routes"
    minted from log.info(...)-style calls the name guess had bound. finagle loses
    13 HTTP_CALLS that came from path-shaped arguments (Dtab.read("/foo=>/bar")).
    TESTS edges derived from refused CALLS go with them (kafka -643, finagle -60,
    meilisearch -128, koel -2, plausible -1). koel loses one false CONFIGURES
    edge with an empty key, minted from (new $class())->getProperty() bound to
    one preference class.
  • Fallback false positives: a refused call still reaches the
    empty-resolution service fallbacks, as a cross-language-vetoed one does. On
    kafka that adds 2 false route registrations: props.put("log.dirs", "/tmp/a").

Tests

  • registry_receiver_gate_judges_value_receivers: every evidence rule, the
    self receivers, the C/C++ struct-member hand-off, the C++ owner type
    declared in the caller's file, and a language off the allowlist.
  • lsp_resolution_probe cpp/S3 (Widget w(n); w.get_id()) stays GREEN; it
    went RED with C++ gated before the owner-declared rule.
  • registry_receiver_gate_runs_by_measured_language: the allowlist. Go and
    Elixir judge unique_name binds; Scala, Rust and PHP keep them and judge
    only suffix_match picks; Java, Kotlin, Swift, Ruby, Objective-C, C, Dart
    and an unmeasured language (Zig) keep both.
  • registry_receiver_gate_judges_type_roots_at_import_fallback: the previously
    ungated exit.
  • pipeline_registry_receiver_gate_full_and_incremental: Scala, Go and C
    callers through the full index (sequential and parallel) and both incremental
    routes.

All four are RED on the base. Forcing the gate off turns them RED again.

The #2121 value-root controls now give their candidate a value receiver's
evidence (the caller's own module), which a type root would not admit.

Two indexes are identical (kafka; meilisearch 95,037 = 95,037 edges). The
languages off the allowlist index unchanged: rails, JetBrains/Exposed and
swift-nio give the same CALLS with the gate as without it. Incremental matches
the full index on plausible (Elixir) and on finagle with #2360. On
meilisearch, koel and gardener, incremental and full already differ without
the gate (meilisearch 49 edges, koel 49, gardener 159); with it they differ in
no more (meilisearch 31, koel 46).

…iver

#1897's receiver-chain gate judged only chains rooted in a type and let a
lower-case root through ("a value whose type the chain does not show"),
and the two suffix_match exits of resolve_multi_with_imports were never
gated. So a member call no LSP had typed bound whatever project symbol
shared its final name: kafka's `tp.topic()` on a TopicPartition bound
ConsumerRecord.topic, gardener's `strings.Join` bound pkg/utils/net.Join,
finagle's `Future.exception` a thrift service method.

At the same name-only exits (unique_name, suffix_match, and now the
import fallback) a CALLS resolve of a member call whose receiver is a
value or a `new X(...)` constructor binds only on evidence that it means
the chosen candidate: a chain segment names its ancestry word by word
(`repo` / Repo, `cleanerManager` / LogCleanerManager, `otel_guard` /
OtelGuard, the receiver of `verify(x)` / `when(x)`), it lives in the
caller's own module, it is import-reachable, or, for a C/C++ call onto a
struct member, the C member resolver decides it from the object's type.
When another candidate is the field-type hint's own pick the call is
left for that re-pick. Otherwise the guess is refused: a veto, never a
re-pick. Self receivers (this, self, cls, super, base, this_, _this) and
`::` paths are exempt; import_map, same_module, qualified_suffix and
lsp_* are untouched. A type root is checked at the import fallback too.

Scope by measured language (share of refused edges that were wrong, hand-
read seeded samples): whole for Go (50/50), C++ (25/26), C#, Lua, Tcl,
Groovy and C; suffix_match picks only for Scala (kafka 29/30, finagle on
#2360 28/30). Left out: Java (suffix_match-only still 47/60), Kotlin
(unmeasured), Ruby (3/15), and Python, the JS/TS family, Perl and PHP,
whose own guards run after resolution and keep their HTTP classification.

kafka 4.0.0 loses 5,189 CALLS (Scala 5,183) and 620 fake async routes,
finagle on #2360 6,302 Scala CALLS and 13 false HTTP_CALLS, gardener 339
Go CALLS, redis 15, otel 168. Deterministic; incremental matches full.

The #2121 controls for value roots now give their candidate a value
receiver's evidence (the caller's own module), which a type root would
not admit.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The receiver gate now runs from an explicit per-language allowlist set by
measurement instead of applying to every language not exempted:

- full gate: Go, C++, C#, Lua, Tcl, Groovy, Elixir;
- suffix_match-only: Scala, Rust, PHP;
- off: everything else (Java, Kotlin, Swift, Ruby, Objective-C, Dart, C,
  Python, the JS/TS family, Perl, and every unmeasured language).

Each language was measured on a pinned corpus with fresh seeds and hand-read
samples of the refused CALLS; a language is gated only where the share of
refused edges that were wrong is at least ~85% (Rust 88% for suffix_match,
80% for unique_name, so suffix-only; PHP 30/30 suffix, 60% unique; Elixir
30/30 and 24/25). Rust removes 4,503 false CALLS on meilisearch, PHP 938 on
koel, Elixir 1,885 on plausible; off languages are byte-identical.

Also new C/C++ evidence: a candidate whose owner type the caller's own module
declares binds (`Widget w(n); w.get_id()`), which fixes the cpp/S3
lsp_resolution_probe case the full C++ gate refused in the previous commit.

registry_receiver_gate_runs_by_measured_language replaces the JVM-only test
and pins full, suffix-only and off languages, including an unmeasured one.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData
DeusData merged commit b62a2ff into main Nov 14, 2026
27 of 28 checks passed
chidev added a commit to lev-os/codebase-memory-mcp that referenced this pull request Nov 14, 2026
…g ties to the receiver

Conflict in src/pipeline/registry.c resolve_name_candidates, kept both:
- lev narrows the import-reachable set and the fallback by the receiver
  chain (resolve_multi_with_imports takes callee_name and lang,
  closest_receiver_admitted). Kept.
- DeusData#2977 vetoes a fallback answer the imports do not reach when the
  receiver is blind (type_receiver_blind, value_receiver_blind), and the
  no-import closest pick when value_receiver_blind holds. Kept, applied
  after lev's narrowing. The gate is off for Java, Kotlin, Swift and the
  JS/TS family (gate_scope), so lev's work there is unchanged.

Signed-off-by: chidev <chicagowebdev@gmail.com>
chidev added a commit to lev-os/codebase-memory-mcp that referenced this pull request Nov 14, 2026
…ndidate names

DeusData#2977's registry_receiver_gate_judges_type_roots_at_import_fallback
expects the reference resolver to keep a name-only pick for
`Future.exception` at the import fallback. On lev the receiver-chain
guard narrows the import path's candidates on every resolve (cb1e370),
as upstream does on the unique-name and no-import paths, so that pick
is refused there too. The CALLS-path assertion of the test is unchanged.

Signed-off-by: chidev <chicagowebdev@gmail.com>
DeusData added a commit to ankitsusheel/codebase-memory-mcp that referenced this pull request Nov 14, 2026
Brings the branch up to main 08ab4a0 (DeusData#2966, DeusData#2969, DeusData#2970, DeusData#2977,
DeusData#2978, DeusData#2981).

scripts/vendored-checksums.txt: main (DeusData#2969) vendored the VB6/VBA
grammar while this branch edits MANIFEST.md. Regenerated with
scripts/security-vendored.sh --update (1101 files); only the
MANIFEST.md line differs from main.

Everything else merged without conflict and was checked by hand:
- MANIFEST.md keeps main's vba, sql and jsonnet text; only this
  branch's vbnet registration sentence and custom-handling row differ.
- The language count stays 164 (vendored grammar directories); the
  language-count contract passes. VB.NET adds a language name to the
  README list, not a grammar.
- DeusData#2977's receiver gate is an allowlist (gate_scope); VB.NET is not on
  it, so it stays GATE_OFF, and receiver_chain_admits is unchanged.
- The VB.NET case-insensitive retry still hooks
  cbm_registry_resolve_lang, cbm_registry_resolve_ref and
  resolve_call_lang; the Field-call USAGE policy and the enum-member
  gate are intact.
- DeusData#2981's linear-growth rewrites in extract_defs.c touch no VB.NET
  function; find_class_body still decides VB.NET first.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
DeusData added a commit that referenced this pull request Nov 14, 2026
Main brought in #2969 (vendored VB6/VBA grammar), #2981 (linear-growth
rewrites in extraction and eight LSP passes, a node for C# operators, C
increments recorded as writes), #2977 (receiver gate in the registry),
#2978 (possible override targets in trace_path), #2966 (CONTRIBUTING test
reference) and #2985 (freebsd-vm action bump).

Two files conflicted:

- internal/cbm/vendored/grammars/MANIFEST.md: the summary header. Took
  main's counts (164 grammars, 20 first-party, ABI 9x/78x/77x), which a
  recount of the merged tree confirms (164 grammar directories, LANGUAGE_VERSION
  13/14/15 = 9/78/77). Kept this branch's 2026-11-13 ObjectScript recount
  line above main's 2026-11-12 vba line; main had folded the 2026-11-11 sql
  line into its vba line, so that line goes. Main's vba prose and table rows
  and this branch's ObjectScript v1.11.0 rows are both present.
- scripts/vendored-checksums.txt: regenerated with
  scripts/security-vendored.sh --update. Only the MANIFEST.md hash moved;
  the result differs from this branch only by main's vba entries and from
  main only by the ObjectScript entries.

Every other file merged cleanly. For each file both sides changed
(THIRD_PARTY.md, extract_calls.c, extract_defs.c, extract_usages.c,
helpers.c, lang_specs.c, tests/test_parse_coverage.c) the merged file
differs from each parent by exactly the other parent's change.
#2981 rewrote objectscript_routine_preceding_tag onto a memoized sibling
search with the same probe; this branch does not touch that function.
ObjectScript stays outside #2977's receiver gate allowlist.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
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.

1 participant