Both change per-file extractor output (Markdown bare free-function mention
citation; C# extension-method facts + primitive receiver typing) and land in one
release window, so they share a single bump to 42 chained over prior (41).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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)
Picks up the pypdf 6.21.3/6.21.4 security fixes in both the pdf and all extras.
Regenerated uv.lock on current v8 so the graphifyy self-entry reads 0.9.104 and
the pypdf bump lands on a clean lock (the PR's lock carried a stale self-version
from its fork). pdf extraction tests pass on 6.21.4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pypdf 6.21.2 in uv.lock is affected by seven advisories (GHSA-42gh-23hr-vphw,
GHSA-4vqv-7265-gm2w, GHSA-5849-834g-hvw5, GHSA-62m5-6wh8-28x7,
GHSA-cggf-277g-3q54, GHSA-mfr5-77xh-9j7h, GHSA-x3rh-gjgm-fmqc), fixed in
6.21.3 and 6.21.4. Raise the floor in the pdf and all extras and refresh the lock
with uv lock --upgrade-package pypdf (6.21.2 to 6.21.4).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit 99aa336ab3)
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)
Fold the Markdown mention change (#5093) into #5098's AST schema-41 comment with a
chained prior (40), since both change per-file extractor output and share one
release window. Correct the _qualified_tail docstring example (a dotted tail is
one token, not CamelCase-split) and note the CamelCase fallback only fires on
cased input the lowercased-norm_label callers never pass (#5095 tweak).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
#5098's receiver-chain resolver dropped a single-element chain (`Greeter g;
g.greet()`) when the receiver's class is declared in no local file, where the
pre-chain path parked it by type name for the cross-repo merge to finish (#3152).
Restore that parking for a single-element chain with a known-but-local-absent
receiver type, so a typed local calling into another repo is parked, not lost.
Fixes test_cross_repo_member_calls[cpp-typed-local].
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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)
inotify_add_watch returns ENOSPC when max_user_watches is exhausted.
Log and skip that directory instead of killing the watcher.
(cherry picked from commit 3c4c84a017)
The ignored predicate is built at startup. Rebuild it and reschedule the
tree when .graphifyignore or .gitignore changes, so a newly ignored
directory stops being watched and a newly unignored one starts.
(cherry picked from commit 509df2b391)
A directory moved out of the root can still deliver an event after its
watch is removed. Drop events whose parent is not in the watched map,
and stale file paths whose parent no longer exists.
(cherry picked from commit cf36ca04d4)
On Linux, schedule non-recursive watches only for directories that
ignored_predicate() keeps. Recursive schedule installs a watch on every
directory, including .graphifyignore'd trees, and can exhaust
max_user_watches.
New and moved directories are scanned and their existing files are
synthesized as created events, so mkdir && write is not missed.
(cherry picked from commit 0c60a6ce10)
The @azizur100389 cluster fixes #5016/#5017/#5018/#5019/#5020 (one each), not a
shared #5020, and the fresh-subfolder query fix references #2603. Correct the
thanks/issue refs and add the PR numbers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
tree_html.build_tree folded aliases in a different order (src first) than
build._fold_node_aliases (src last), so a node carrying two conflicting file
aliases could key on different paths in the viewer vs the built graph. Use the
same order and pop the consumed alias, as the build-side fold does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>