Repository navigation
Description
Summary
_resolve_objc_member_calls' field-type table (#2591, shipped in 0.9.39) is keyed by class node id.
It is the only extractor bucket that carries node ids as dict keys, and it is missing from the
#1529 symbol-prefix remap — which rewrites node ids, edge endpoints, raw_calls[].caller_nid and
swift_extensions[].nid, but not that table. The keys are minted before the remap and go stale, so
field_types_by_class.get(cls) misses for every class and [self.<field> …] / [_ivar …]
message sends resolve to nothing.
The remap fires whenever the input paths carry a common absolute prefix to strip — i.e. always via
graphify update <dir>. So #2591 is inert through the CLI. It works only when no prefix is stripped
(calling extract() with already-relative paths), which is the shape the tests use.
graphifyy 0.9.51 (v8), also present in 0.9.50 / 0.9.39. Python 3.10, macOS 14.
Reproduction
Four files. Direct owns a @property of type Greeter and messages it — the exact shape #2591
added support for:
// src/Greeter.h
#import <Foundation/Foundation.h>
@interface Greeter : NSObject
- (void)greet;
@end
// src/Greeter.m
#import "Greeter.h"
@implementation Greeter
- (void)greet { NSLog(@"hi"); }
@end
// src/Direct.h
#import <Foundation/Foundation.h>
#import "Greeter.h"
@interface Direct : NSObject
@property (nonatomic, strong) Greeter *greeter;
- (void)run;
@end
// src/Direct.m
#import "Direct.h"
@implementation Direct
- (void)run { [self.greeter greet]; }
@endRun the same corpus two ways:
$ graphify update . --no-cluster
# calls edges in graphify-out/graph.json:
[] # <- expected: Direct.-run -> Greeter.-greet
$ python3 -c '
import glob, tempfile
from pathlib import Path
from graphify.extract import extract
files = sorted(glob.glob("src/*.h") + glob.glob("src/*.m"))
with tempfile.TemporaryDirectory() as t:
res = extract(files, cache_root=Path(t), parallel=False)
n = {x["id"]: x for x in res["nodes"]}
print([(n[e["source"]]["label"], n[e["target"]]["label"], e.get("confidence"))
for e in res["edges"] if e.get("relation") == "calls"])'
[('-run', '-greet', 'INFERRED')] # <- resolvesSame files, same version, opposite results. The cached shard shows why — the table key and the node
id it is supposed to match were minted in different id spaces:
field table : {"path": "$graphify-root$/src/Direct.h",
"tables": {"users_me_work_iss1_src_direct_direct": {"greeter": "Greeter"}}}
class nodes : src_direct_direct, src_greeter_greeter
Note the "path" value is anchored while the key next to it is not — see "not the cache" below.
Passing absolute paths straight to extract() also resolves (users_me_work_iss1_src_direct_direct
for both key and id). Key and id always agree within one extract() call; only the remap
separates them.
Root cause
extractors/objc.py:207 keys the bucket by cls_nid (minted at :286 via
_make_id(cls_stem, name)) and exports it at :565:
result["objc_field_types"] = {"path": str_path, "tables": field_tables}extract.py:6257-6278 (#1529) then canonicalizes symbol ids and rewrites every carrier it knows
about:
if sym_remap:
for n in all_nodes: ... # node ids
for e in all_edges: ... # source / target
# raw_calls carry caller_nid (a symbol id) consumed by the cross-file
# call pass below, after this remap — rewrite it too or those edges
# would dangle on their (stale) source.
for rc in all_raw_calls: ... # caller_nid
# Same for swift_extensions[].nid (see the id_remap pass above).
for result in per_file: ... # swift_extensions[].nidper_file[].objc_field_types["tables"] keys are not in that list. The consumer at
extract.py:3681-3697 keys field_types_by_class off those stale strings, and the receiver lookup
in the same pass never hits. The pass' own docstring states the contract it now silently fails
(extract.py:3669):
Must run after id-disambiguation so node ids and caller_nids are final.
_merge_decl_def_classes (extract.py:2749-2756) has the same shape — it explicitly rewrites
raw_calls[].caller_nid and not the field table — so a .h/.m pair folded into one node can
strand the table a second way.
Why tests are green: every path form that needs no prefix stripping keeps key and id in the same
space, and that includes a fixture list of relative paths handed to extract() directly.
Why only ObjC: java_field_types / csharp_field_types (engine.py:2977/:2983) are consumed
in-file at engine.py:4860 and stamped onto raw_calls as a plain receiver_type string, so
they never cross the remap boundary. ObjC is the one language that carries an nid-keyed table across
it.
What does NOT fix it
Anchoring the keys in the cache. The shard round-trip is not the cause — a cold run
(rm -rf graphify-out) reproduces it, and cache._rewrite_strings is values-only by explicit
design, with a docstring that asserts the invariant this bucket broke:
Values only, never dict keys: no extractor bucket is keyed by a node id or a
path (the*_type_tablemaps arename -> type), and rewriting keys
could silently collide two entries into one.
That reasoning is still right (colliding two keys into one would be worse). It just is no longer true
that no bucket is keyed by a node id, so cache.py:699's neighbourhood deserves a note either way.
Keying by file path instead. A class' entries come from two files (@property in the header,
ivars in the impl) and _merge_decl_def_classes deliberately folds them into one node; the merge at
extract.py:3687 depends on both landing under one key.
Suggested shape
- Add the bucket to the import edges silently dropped on Next.js codebase — short IDs vs full-path node IDs (regression of #256) #1529 rewrite block, next to
swift_extensions[].nid:
rebuildresult["objc_field_types"]["tables"]withsym_remap.get(k, k)for each key.
On a key collision, merge with the existing conflict rule atextract.py:3689-3697(drop the
entry rather than pick) so the folded-pair case stays consistent. - Same for
_merge_decl_def_classes' remap (extract.py:2749), which has the identical omission. - Consider making the invariant enforceable rather than documented — e.g. have extractors declare
nid-keyed buckets in one place that every remap iterates, so the next such table cannot be missed.
The two comments quoted above ("rewrite it too or those edges would dangle", "Same for
swift_extensions[].nid") read like this list has been grown by discovery three times now. - A regression test that asserts a non-empty
callsedge set for the fixture above through a path
form that triggers the remap (absolute input paths, orgraphify updateon a temp dir) would
have caught this and would catch the next one.
Happy to send a PR for (1) + (2) + the test if that is useful.
Note
Two sibling reports from the same investigation: field-type tables are never walked up the inherits
chain (so a field declared on a superclass types nothing in a subclass — Java and ObjC both), and the
receiver type computed at these resolvers is discarded on bail-out, which is what makes cross-repo
member-call edges impossible after merge-graphs. Filed separately since they are a gap and a
feature; this one is a plain bug and independent of both.
Activity
fix(objc): remap the field->type table keys with the ids they hold (#…
chore: bump to 0.9.52
safishamsi commentedon Aug 29, 2026
Fixed in v0.9.52: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.52. Closing as resolved.
feat(merge): finish member calls across a repo boundary (#3152)