The INFERRED rubric is {0.55, 0.65, 0.75, 0.85, 0.95}; the guarded rungs were
emitting 0.70, which test_inferred_confidence_rubric rejects (and which the
rubric has no tier for). 0.75 is the intended one-step-below-0.85 score.
(cherry picked from commit 27c01196ab)
The A/B record imported a second copy of the deny-list, so the comparison could
silently stop describing the rule the fix applies. Use one source of truth.
(cherry picked from commit d49009e351)
Closes the last shape in the report: `v.ToString().Mask()`. The receiver of the
outer call is the result of an inner call, so it carries no type at all, and
typing it would need BCL return types the corpus does not know.
The untyped rung therefore applies the same two name proofs the out-of-corpus
rung uses — the name is not a BCL member, and no regular method in the corpus
spells it — with no type-compatibility filter, and requires a unique surviving
declaration. A capitalized untyped receiver is a type named in source
(`Convert.ToInt32(x)`), never a value an extension applies to, so it is skipped.
This is the weakest rung and it is scored accordingly: INFERRED 0.70. The cost is
pinned by a fixture where a regular method elsewhere shares the name: the call
stays unbound rather than risking a false edge.
With all three rungs the reporter's corpus now matches the expected output:
Connections (3):
<-- StringExtensions [method] [EXTRACTED] Ext.cs:L3
<-- .A() [calls] [INFERRED] Svc.cs:L3
<-- .B() [calls] [INFERRED] Svc.cs:L4
Refs #4828
(cherry picked from commit 99d2834910)
Stage 1 deliberately refused a receiver whose type the corpus never declares,
which left the issue's headline case unbound: `s.Mask()` on a `string`, and the
same shape for `int` and any third-party type.
An undeclared type cannot have its instance members enumerated, so the
instance-wins rule cannot be applied. Two conservative proofs replace it:
* the member name is not one a BCL type owns (`ToString`, `GetValue`, `Split`,
...), because those calls are instance calls on the real runtime type; and
* no regular (non-extension) method anywhere in the corpus spells that name, so
an in-corpus type cannot legitimately own it either.
A `this T` / `this object` declaration is subject to the same guard and still
applies only when no exact or base/interface match exists. These edges are
INFERRED 0.70, one discrete tier below a receiver typed by the extractor's
declaration table, so a query can tell the two proofs apart.
The reported false negative this cannot reach — `string.ToInt32()` when an
unrelated static class also declares `ToInt32` — is pinned as a documented miss
in the ground-truth fixtures rather than papered over.
Refs #4828
(cherry picked from commit f80468a01b)
`value.Mask()` to a classic `this`-parameter extension produced no `calls`
edge: `_resolve_csharp_member_calls` types the receiver and looks the method up
on the receiver's type, but an extension is declared on a static class, so the
lookup found nothing and the call was dropped. The helper looked dead.
New `csharp_extension_calls` resolver, registered after the nominal pass, joins
a call site to the declaration its `this` parameter names. This first stage
binds only provable calls:
* the receiver's declared type is declared in the corpus and its base chain is
fully resolved — an out-of-corpus base may declare an instance member of
that name, and an instance member always wins over an extension;
* the receiver type declares no instance member of that name;
* the declaring static class's namespace is visible at the call site, walked
innermost namespace declaration outward (`CsharpNameResolver
.visible_namespaces`), so a file-level using is only considered at the
compilation-unit level and an inner-namespace extension wins;
* the extended type is the receiver's type, a resolved base, or an implemented
interface; an open generic `this T` / `this object` declaration applies only
when no exact or base match exists;
* the declaration accepts the call's argument count, reusing the arity /
min_arity facts from #4584 (the receiver is one parameter short of the call);
* exactly one declaration survives; a tie binds nothing.
Edges are INFERRED 0.85 (the receiver type comes from the extractor's declaration
table), sourced at the call site.
The tests pair the implementation with an executable A/B record: 15 fixtures
whose ground truth is decidable from the C# spec, and 10 candidate strategies
measured on the nominal graph (production resolver disabled for extraction). The
matrix test pins the trades that were measured rather than assumed — no scope
check binds an unimported extension, no poison binds through an unknown base, no
deny-list binds `PropertyInfo.GetValue`, and the bare-name fallback reproduces
the #1609 god-node edge. The production pass is asserted against the same ground
truth in test_csharp_extension_resolution.py.
Refs #4828
(cherry picked from commit a83cc6c0e3)
A call to a classic `this`-parameter extension method produced no `calls`
edge: the member-call resolver looks the method up on the receiver's declared
type, while an extension is declared on a static class. Two facts were missing
before any resolver could join them.
The extractor now persists, on the extension method's node:
extension: true
extended_type: <simple name of the `this` parameter's type>
extended_type_arity: <generic arity of that type>
extended_is_type_param: true for `this T`
`_csharp_method_signature` already detected the `this` modifier, but only used
it to compute `min_arity`; the extended type is the join key a call site needs
and is recorded where the declaration is still at hand. The type is the same
simple name a receiver is stamped with (`_read_csharp_type_name` strips the
namespace qualifier and generic arguments), so qualified `this App.Widget` and
generic `this Box<int>` are comparable with `receiver_type`.
`_csharp_receiver_type_name` no longer drops every lowercase type: predefined
primitives are not declared in the corpus, but `this string` dispatches on
exactly that name, so filtering them made those calls untypeable before the
extension pass could ever see them. The parking path is guarded in exchange:
`_park_if_absent` does not park a well-known BCL receiver name as a cross-repo
candidate, so `x.ToString()` on an `int` no longer stamps an `unresolved_calls`
payload on the caller.
AST cache schema 29 -> 30: cached `.cs` extractions lack the new facts.
Refs #4828
(cherry picked from commit 6a15bfefab)
The cache stat index and active scan root are process globals; in the full
suite a prior test's root can be served to a later rebuild and drop the
resolver-minted reference edges. Running each rebuild scenario in a fresh
interpreter gives the test the clean slate it has in isolation.
(cherry picked from commit d559ea232d)
`resolve_markdown_mentions` linked bare code spans like `token` or `raw`
to unrelated free functions carrying the same label across languages.
Require section-scoped evidence for bare prose-like free function names:
- Keep a bare free-function mention only if the section cites the defining
file (via a code span, file link, or path qualification) or cites another
symbol from that file (#4804).
- Exempt distinct code identifiers (snake_case, camelCase, or PascalCase
in export-by-convention languages).
- Extract source-file links as file citations, scoped to enclosing headings
as evidence owners, minting doc->file references only for scanned files.
- Resolve inline Markdown links strictly against document-relative targets,
and reject mixed-form citations escaping the scan root.
- Reconcile doc->file citations in watch rebuilds and bump AST cache schema.
(cherry picked from commit 638ab3ec18)
The doc-bisect fix added .yaml/.yml to _SPLITTABLE_TEXT_SUFFIXES, but those are
code, not documents (reclassified document->code in #2214), and never reach the
semantic pass, so slicing them at prose boundaries is meaningless. Drop the two
suffixes and their test parametrization; the core truncation-bisect fix stands.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
claw, kiro and pi dispatch semantic subagents with a CHUNK_PATH and expect
each to write its chunk file there, but they shipped the compact extraction
spec, which never names CHUNK_PATH. A subagent following that prompt
verbatim returned its JSON inline, so Step B3 found no chunk file and
reported the chunk as missing.
Add a compact-disk spec variant (the compact prompt plus the CHUNK_PATH
substitution and write step) and switch claw, kiro and pi to it. Codex keeps
the plain compact spec: its workers return JSON inline and the orchestrator
writes the chunk files.
Add a regression test: every host whose dispatch passes CHUNK_PATH gets a
spec that writes to it, and the inline-JSON host (codex) does not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b26a79372d)
providers.json can already override request body fields with
`extra_body`, but not headers, and some OpenAI-compatible gateways
require one: OpenCode Go rejects any request without
`x-opencode-session` (400 MissingSessionID). The only workaround was
the SDK-global OPENAI_CUSTOM_HEADERS env var.
Accept an optional `extra_headers` object on a provider entry and pass
it to the OpenAI client as `default_headers` at both construction
sites, extraction (`_call_openai_compat`) and `_call_llm` (labeling and
the --dedup-llm tiebreaker). Only string-to-string entries are kept,
and an Authorization entry is dropped with a warning, so the API key
still always comes from the provider's env_key. Without the field, the
client is built exactly as before.
(cherry picked from commit 82b48065ac)
graphify extract kept several full copies of the graph alive after they
were consumed. Release each one as soon as it is used, without changing
call order or output (graph.json is byte-identical):
- extract(): new opt-in release_parse_memo clears the Python parse memo
once both resolution passes finish; the CLI sets it, watch/MCP/library
callers keep the warm memo as before.
- extract CLI: drop the parsed previous graph.json once the resolution
context is built, the context after AST extraction, and the raw
AST/semantic/merged lists once G is built.
- to_json: canonicalize node/link dicts in place, and free the shrink
guard copies and the previous-graph parse before writing.
- cluster._partition: drop the sorted edge rows once stable is built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ykSAxiohPs7ei9m9DasUD
(cherry picked from commit 3892aea30b)
to_json passed an empty deleted_sources to _lost_saved_semantic_nodes, so
the old ids of every doc build_merge re-extracted this run (LLM ids are not
stable) were reported as lost whenever the guard was armed, e.g. by an
omitted file. build_merge now stashes the saved sources it replaced
(semantic tier) or pruned on G.graph, and to_json pops it and excuses them.
Sources with an unverified shrink (#3203) and untouched files stay guarded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ec964ea137)
Report malformed enum values without hashing them, and use conservative builder fallbacks so one structured field cannot abort a usable extraction.
Refs #5086
Co-authored-by: OpenAI <noreply@openai.com>
(cherry picked from commit 00da7d0155)
Preserve lexical receiver types and access operators, resolve fields by their declaring class, and unwrap supported standard smart pointers without guessing ambiguous targets. Persist class metadata for incremental resolution and invalidate older AST caches. Add regression and negative coverage for split headers, shadowing, namespace collisions, forward declarations, and cached rebuilds.
(cherry picked from commit 287b78caca)
`graphify path` fell back to the top of the score ranking for any name that
matched no tier, so `zzqqxx_no_such_symbol_9137` resolved to
`no_such_symbol_helper()` (three shared `_`-split tokens) and printed its route
with exit 0, while `explain` on the same name said "No node matching".
Nothing that exists could have answered that request, and the route reads as
if it had.
The fallback now only runs when every word of the query appears in some
node's name or id. That keeps the partial names it is there for
(`draft-generator` -> `draft-generator.ts`, `Reject-everything judge` ->
`Degenerate Reject-Everything Judge`, a label the caller is still typing) and
turns a name made of unknown words into the miss `explain` already reports,
which the CLI surfaces as exit 4.
Fixes#5079
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit a084c3dd67)
`query sweep_widget_state` missed `public.sweep_widget_state()` even though
`explain` on the same name found it. The full-query tier only fires when the
joined query tokens equal or prefix the label, so a leading `public` defeated
it, and the per-token tiers handed the seed slots to unrelated nodes whose
whole label is one of the query's tokens (`SWEEP`, `WIDGET`, `State`).
Add a tier between exact and prefix for labels of the shape
`<qualifier><sep><rest>` where the query names exactly `<rest>`: dotted,
`::`, `/`, `:` and `@` segments, plus a CamelCase qualifier on the last
segment. It is scaled down by the qualifier's token count and capped at four
tokens, so `public.f()` is trusted more than `a.b.c.d.f()`. Trailing
file-extension and numeric segments are skipped, so `lib/foo/bar.py` is the
name `bar` rather than `py`.
Nothing changes for a query that already equals or prefixes a label, or for
plain snake_case identifiers: those never reach the new branch.
Fixes#5080
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 8d2e1caed8)
_mtime_may_hide_a_rewrite() bailed out with "the mtime check already fired"
whenever seen - mtime came out negative. The caller only reaches it after the
stored and current mtime compared equal, so that shortcut skipped the hash on
a row that was still written in the same tick as the file.
seen is time.time() and mtime is the filesystem's, so the two clocks can
disagree by a few hundred nanoseconds in either direction (#5036: ~240 ns on
NTFS). When they do, a same-length rewrite inside the tick goes undetected and
detect_incremental reports the file as unchanged.
Only the magnitude of the delta says anything about whether the row is current,
so compare -delta against the same window. A row stamped a full window before
the mtime is still from an earlier run and keeps the stat-only fastpath.
Tests: test_a_row_stamped_just_before_the_mtime_still_hashes reproduces the
signed-delta miss, and test_a_row_stamped_well_before_the_mtime_keeps_the_
fastpath pins that the fastpath is not widened to every row.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 376f333f72)
A destructured require that reaches a symbol through a barrel
(`const { SourceCode } = require('./index')`, where `index.js` re-exports
`SourceCode` from another module) left the symbol import edge on the
barrel. The barrel defines no node, so cross-file call resolution found no
import evidence and dropped the `calls` edge.
Keep the required target file and imported name on the structural require
edge, then follow the target's exports to the declaring symbol before
cross-file resolution runs. The keys are internal and removed from the
final graph.
Fixes#5034
(cherry picked from commit 689e18a87e)
An under-produced semantic extraction (e.g. a doc chunk that returns only
its file-level node) is saved to the unversioned content-hash cache
without a `partial` flag. The #3203 shrink guard then refuses the graph
write on every later run while the cache keeps serving the degraded chunk,
so no LLM call is ever made again and the corpus stays un-updatable until
the entry is deleted by hand.
`save_semantic_cache` cannot read graph.json (and should not), so the
shared shrink handler marks the entry the read path would serve `partial`
once the guard has measured the shrink. `load_cached` already treats
`partial` as a miss, so the next run re-dispatches the file and a complete
extraction overwrites the same content-hash key with a clean entry. This
covers both a fresh under-production and a run that replays an
already-poisoned entry written by an older version.
The guard's stderr now separates "fresh extraction is smaller" from "a
cached smaller chunk is being replayed", names the marked cache entry, and
stops recommending --allow-partial for the cached case: following that
advice would write the degraded replay over the larger graph and drop the
prior nodes.
Tests: cache-level marking (prompt-fingerprinted and legacy flat
fallback), plus two end-to-end CLI repros that fail on the old code. The
second demonstrates the reported loop: the next run hit the poisoned
cache and refused again without ever calling the model.
(cherry picked from commit fc7f700f9e)
_load_existing_graph backs build_merge (--update) and merge_raw_extraction (--update --no-cluster). It read hyperedges only from the top-level key, so a graph.json whose hyperedges live in the node-link slot (graph.hyperedges, the shape node_link_data-only writers emit) lost its whole hyperedge set on the next incremental merge. build_from_json already folds that slot (#2485); the loader now does too. A top-level list still wins (the canonical slot, and the CLI's source pruner edits only it); a missing, null, or malformed top-level value falls back to the nested list instead of dropping or raising on a readable set.
The deleted-source prune also removed nodes AFTER build() had revalidated hyperedge members, so a surviving cross-file hyperedge kept naming the deleted file's node. Re-run the same #1916 policy once the node set is final: drop members that no longer resolve, and drop the hyperedge only when no member remains.
Adds the reported #5081 flow end to end, nested-only coverage for both incremental paths, malformed top-level fallback, top-level precedence, and deleted-member pruning.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@deepseek.com>
(cherry picked from commit e71d14cfa0)
to_wiki allocated unique slugs with str.lower() while the orphan sweep
indexed produced filenames with str.casefold(). For labels whose lower()
spellings differ but whose case folds agree ("Straße" / "STRASSE",
"Σ" / "ς"), both slugs were allocated, the folded map kept one, and the
sweep unlinked the other freshly written article. The export reported
both and index.md linked to the deleted page.
Dedup slugs on casefold(), the same relation the sweep uses, keeping the
existing ASCII filename behavior. Also skip any file whose exact name is
in produced before consulting the folded map, so "never delete a file
this run wrote" holds even if the two rules drift again, and build the
map from sorted(produced) so the survivor is deterministic.
Regressions cover community/community, community/hub and hub/hub
collisions for German sharp-s and Greek sigma, verify every link and
article body, and require repeated exports to be a byte-identical
fixpoint. The relabel test guards against turning the cleanup into a
no-op.
Fixes#5087
(cherry picked from commit 914f70d3fa)
The pruned watch tree is Linux-only. macOS and Windows still use a
recursive schedule, so `watched` stays empty and the handler's parent
guard dropped every event. Apply the guard only when the manual tree is
active, and leave the recursive fallback alone when an ignore file
changes.
Add a darwin-simulated regression test and make the schedule contract
tests platform-aware.
(cherry picked from commit 2ee00533dd)
Add a fake-observer scheduling test and a Linux inotify watch-count
test. Update the three contract assertions from recursive=True to
recursive=False.
(cherry picked from commit 3215888c13)
The scan-path injection fix reads graphify-out/.graphify_root once per Python
block, so the lean claude core grew from ~795 to 807 lines. Raise the ceiling to
820 — still far under the ~1156-line pre-split monolith the guard exists to catch.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The generated /graphify runbook substituted the agent-supplied scan path straight
into Python string literals across every code block: detect(Path('INPUT_PATH')),
extract(cache_root=Path('INPUT_PATH'), root=Path('INPUT_PATH')), the semantic
cache check/save, build_from_json/generate/diagnose, the manifest write, and the
--update detect_incremental + merge. A scan root whose NAME carried a single
quote or a $(...) / backtick broke out of the literal and ran as arbitrary code
the moment the block ran (e.g. a cloned repo with a subdirectory named
$(...) ). The shell transport was already hardened (#3642/#3844 write the path
to graphify-out/.graphify_root through a quoted heredoc); this extends the same
trust boundary to the Python blocks.
Each block now reads the resolved root from graphify-out/.graphify_root (the file
Step 1 writes) into an INPUT_PATH variable and passes the value, so the path is
always inert data, never code. The prose no longer tells the agent to substitute
a path. Applied to the assembled hosts (core.md, references/shared/update.md) and
to the Aider and Devin monoliths; a new _is_input_path_sidecar_fix_line sanctions
the monolith diff and --monolith-roundtrip / --check / --audit-coverage stay
green. A fast regression guard asserts no generated skill body carries a quoted
'INPUT_PATH' code literal.
SPEC_PATH (the skill's own extraction-spec install path, not attacker-controlled)
is left substituted and tracked as a follow-up.
Reported and first proposed by @danikdanik in #4762.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The landed fix caught a non-numeric price but still accepted nan, inf and
negative values, which parse as floats and then flow into cost estimation as
NaN/inf/negative. Validate each --pricing-input/--pricing-output through
_valid_price (finite and >= 0) with the same clean error + exit(1), and test
that nan/inf/-inf/1e999/-5 are rejected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Follow-up to #5025. The landed guard raised on any non-dict repo value, so a
single malformed entry backed up the whole manifest and dropped every tracked
repo. Keep the whole-file backup only for an unrecoverable shape (non-dict root
or repos map); when repos is a dict, drop just the malformed entries, keep the
valid repos, and report which went. Matches the per-entry isolation of #5024.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`graphify update sub` run from sub's parent stores source_file relative
to the build cwd (sub/pkg/mod.py, #2603) while ids are minted relative
to the scan root (pkg_mod). graph_has_legacy_ids derived the expected
stem from the stored path (sub_pkg_mod), so the real id matched the old
one-parent form and every query/MCP load of a freshly built graph told
the user to rebuild with `graphify extract --force`, which changes
nothing.
Read the cwd->scan-root offset from the relative .graphify_root marker
(new legacy_id_source_prefix) and strip it before deriving the stem.
Absolute, ".", and parent-escaping markers mean no offset, so behavior
for root-anchored graphs is unchanged and genuine legacy ids are still
reported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGb7YtZeBXGNQMw6JjuqZu
(cherry picked from commit f5ee99de8f)
Covers a SAM style template using nested Equals and Ref tags
extracting its structural nodes instead of failing the whole file,
plus a control confirming a python object tag alongside an
intrinsic tag still raises rather than executing.
(cherry picked from commit 4e2b26b211)
`_suppress_ambiguous_python_imports` mints a node-less
`ambiguous_python_import_<sha1>` target for an import that more than one
scanned module could satisfy. The hash included the edge's `source_file`
and `source` id as they are at that point in the pipeline, which is
before relativization: `source_file` is still the absolute path and the
importer id is derived from it. The same commit built in two directories
therefore produced different placeholder ids, so `graph.json` was not
reproducible across checkouts and community detection could differ.
Hash the scan-root-relative `source_file` (POSIX form) with the module
name and source location, and drop the path-derived `source` id. These
already identify the import site uniquely, and the existing
`while target in node_ids` guard still prevents a collision with a real
node.
Adds a regression test that builds the same tree in two checkout
directories and asserts identical placeholder edges; it fails without
this change.
Fixes#5044
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit ff047dfea7)
A C# property's accessor bodies, an indexer and a user-defined operator
or conversion were never walked, so every call made inside them was lost.
On Dapper, AutoMapper and Newtonsoft.Json (Roslyn answer key) that is 144
call links made from property/indexer accessors and 186 from conversion
operators, none found.
- A property's `get`/`set` bodies and an expression body (`int P =>
F();`) are walked with the existing property node as the caller. An
auto-accessor has no body and an initializer runs in the constructor,
so neither adds calls. Only the declaration that owns the property
node is walked: when the id is already another member's (an explicit
`IFoo.Name` property spelled like a method `Name()`), its calls are
dropped instead of being credited to that member.
- An indexer is a `this[]` node beside the properties (`defines`,
context `field`), id `_make_id(type_id, "this")`, salted per
signature (including an explicit interface) and away from a member
spelled `This`.
- An operator or conversion is a `.operator +()` / `.operator int()`
node owned through `method`; its id always carries a hash of the
signature, since several conversions share one parameter list.
- A property/indexer counts as owned by its type for caller lookups
(in-file unqualified calls, `this.`/`base.` member calls, the
partial-type own-type preference), like a method. It is never a call
target by name, and `operator` is kept out of the member-call index.
- No existing node id moves (checked on all three projects).
- AST cache schema 40.
Calls TO properties, indexers and operators are not linked: in these
projects they are about 3,500 property get/set links (more than half
to auto-properties), 27 indexer and 60 conversion links, against 0
user-defined binary operator calls. Linking them needs member-access
typing and a decision on the relation, so it is left out.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 0e6806a93b)
A C# constructor had no node. Calls in its body were credited to the
type (#4246), calls in `: base(...)`/`: this(...)` arguments were never
walked, and `new X(a, b)` could only point at the type, never at the
overload it runs. On Dapper, AutoMapper and Newtonsoft.Json (Roslyn answer
key) 151 call links made from constructors were all lost and none of the
130 constructor initializers was linked.
- Each constructor (instance, static, and a type's primary constructor)
is a node owned by its type through a `method` edge, labeled
`.TypeName()` with metadata kind "constructor" plus arity/signature.
The id is `_make_id(type_id, TypeName)`, the one a method named after
the type would get; other signatures are salted like method overloads
(#4584), a static constructor is its own "static" signature, and if a
member spelled like the type in another case (`foo()` in `Foo`)
already owns that id the constructor takes a salted one. No existing
node id changes (checked on all three projects).
- Body and initializer calls belong to the constructor.
- `new X(...)` sites and initializers are recorded in raw_calls with no
callee (so every name-keyed consumer skips them and the id passes
remap their caller). A tail C# pass links the constructor whose
parameter count fits, next to the existing edge to the type.
`: this(...)` uses the own type, `: base(...)` the single resolvable
base. Two fitting overloads, an unresolved base, or a type the caller
did not bind give no edge.
- Constructors are left out of every name-keyed call index (in-file
label map, global label index, member-call index, overload index,
interface dispatch), so a constructor can never be picked for an
ordinary call or shadow its type.
- AST cache schema 40.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 10332b79f5)
`using SafeCast for uint256; x.toUint48()` and `using EnumerableSet for
EnumerableSet.AddressSet; _set.add(a)` call the library function with
the receiver as its first argument, but the extractor parked
`x.toUint48` as a qualified call on a type named `x`, which never
exists, so no such call got an edge. On OpenZeppelin v5.4.0, 0 of the
228 calls solc resolves through a `using` directive were linked.
Record the directives in scope: a contract's own (`using` is not
inherited since 0.7), the file-level ones, and the `global` ones on a
type's declaration, as `using` metadata on the contract and file nodes,
and give library and free functions their `first_param_type`. The
resolver binds `recv.f(args)`, when the receiver's declared type is
known (the receiver typing of the previous commit, a base contract's
state variable or the return type of `g` in `g().f()`), to a function
`f` that a directive whose target is `*` or that type attaches, with
args + 1 parameters and the receiver's type as its first. The type must
match exactly, including user-defined value types and library structs
(`Trace208` inside Checkpoints reads as `Checkpoints.Trace208`, as a
caller writes it). An operator binding (`using {eq as ==} for T`)
attaches no member.
Fail closed: no edge when the receiver's type is unknown, a directive's
library name is ambiguous, or more than one function fits.
OpenZeppelin v5.4.0 (solc 0.8.28 AST as the answer key): using-for calls
0/228 -> 180/228; solmate: 0/10 -> 6/10. No other kind changes. Most of
the rest are chained calls (`slot.asBoolean().tload()`), calls written
inside a `?:` that tree-sitter parses as the member's object, and 7
calls made inside `_name` functions that share a node with their
`name` counterpart (the `_name` / `name` id merge), which land on that
merged node until the id merge is fixed.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 7bd9be0bee)
`IERC20 token; token.transfer(to, v)`, `IERC20(a).transfer(..)` and
`Ownable(x).owner()` got no edge: the extractor parked `token.transfer`
as a qualified call on a type named `token`, which never exists, and a
call on a conversion as a bare member call the shared pass drops. On
OpenZeppelin v5.4.0, 0 of the 74 such calls solc resolves were linked.
Bind `recv.f(..)` by name and arity through the receiver's declared
contract or interface type and that type's C3 linearization, the lookup
the compiler does. The type comes from the receiver typing the previous
commit adds, or from a base contract's state variable (`hevm.prank()`)
or the return type of `g` in `g().f()`. An interface method links to the
interface's declaration; no implementer is guessed. A type may be
imported through a file that re-exports it (`import {IERC20} from
"../ERC20.sol"`, the usual OpenZeppelin form), searched only when the
file declares and directly imports no type of that name.
Fail closed: no edge when the receiver is untyped, its type is not
exactly one visible contract/interface, the name/arity matches two
overloads, or a public state variable of that name (a getter) is found
first.
OpenZeppelin v5.4.0 (solc 0.8.28 AST as the answer key): typed calls
0/74 -> 71/74; solmate: 0/725 -> 716/725. No other kind changes. The 3
calls left on OpenZeppelin are made inside `_installModule` and
`_uninstallModule`, which share a node with `installModule` /
`uninstallModule` (the `_name` / `name` id merge), so they land on that
merged node until the id merge is fixed.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 752eaaf5fa)
make_id strips a leading `_` (and folds case), so in one contract
`_grantRole(bytes32,address)` and `grantRole(bytes32,address)` minted
ONE id. add_node kept the first declaration and dropped the second: the
`_` function vanished from the graph, and every call it makes, and every
call to it, landed on its public twin. OpenZeppelin v5.4.0 has 38 such
pairs (`_grantRole`, `_transferOwnership`, `_safeTransferFrom`, ...),
which made 104 of graphify's `calls` edges ones the compiler does not
have.
Apply the rule C# got in #4415 (and Python in #3302): group the members
of a contract (functions, modifiers, events, errors, state variables,
structs, enums), the file's free functions and the file's types by the
id they would get, and run each through `_underscore_salted_nid`. The
one public name keeps the plain id and every other spelling of the
group is salted, so the outcome does not depend on declaration order. A
name without a colliding sibling keeps its id, so only the `_` spelling
of a clashing pair gets a new one.
OpenZeppelin v5.4.0 (solc 0.8.28 AST as the answer key): 3907 -> 3945
nodes, 38 new ids (all salted `_` functions), 0 existing ids changed;
wrong `calls` edges 104 -> 0; compiler-resolved calls found: same
803 -> 887, emit 119 -> 146, revert 403 -> 423, inherited 268 -> 279,
super 173 -> 185, library 205 -> 209. solmate has no such pair and is
unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 94a08d1d6d)
99b8da7 and ff8ddf5 (#4925, #4937) open files through os_long_path(), but
on Windows its \\?\ spelling also leaked into cache identity.
file_hash() and cached_word_count() bound the stat index to the prefixed
root, so the plain cache_root that extract() passes read as a second root.
Every Windows `graphify update` that re-extracts warned "stat index
switched" (#3989) and flushed mid-run, and since no key was relative to the
prefixed anchor, stat-index.json was written with absolute keys and a moved
checkout re-hashed every file (#2199). The walked-parent match compared a
plain path with the prefixed root and never matched, so under a junctioned
or symlinked scan root an in-root alias took its target's salt and digest
(#2832), and the out-of-root salt carried a //?/ prefix. _normalize_path()
also stripped only \\?\, so the UNC form \\?\UNC\server\share became a
relative key that the flush pruned, and a corpus on a network or WSL share
always wrote an empty stat index.
Bind the index to the normalized root as before #4925, normalize the
resolved path and root before they become keys, salts or comparisons, and
map \\?\UNC\ back to \\. File I/O still goes through os_long_path(). CI
runs on Linux, where both helpers are the identity, so this only showed on
Windows.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 49616eb09c)