44 Commits
Author SHA1 Message Date
nothariharan cbc48a69ab fix(cache): stop a degraded semantic entry from pinning the corpus (#5083)
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)
2026-11-09 14:09:22 +00:00
nothariharan 0a14069d7f fix(build): keep hyperedges whole across an incremental merge (#5081)
_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)
2026-11-09 14:09:20 +00:00
nothariharan 1de3f09607 fix(wiki): fold slugs with casefold so the orphan sweep keeps current articles
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)
2026-11-09 14:09:19 +00:00
nothariharan 6be19949d6 feat(go): dispatch interface method calls to implicit implementers
A call through an interface-typed field lands on the interface's method
node, and nothing joins it to the concrete method, because Go types
satisfy interfaces implicitly and the shared interface_dispatch pass
only reads `implements` edges. So the concrete method loses every caller
that goes through the interface.

The Go extractor now stamps interface type nodes with
metadata {"language": "go", "kind": "interface"}, and a new
graphify.go_dispatch pass infers implementers from method sets (every
method name the interface requires, own and embedded) and feeds those
pairs to resolve_interface_dispatch. Empty interfaces, type-set
constraints, interfaces embedding an interface outside the corpus, and
interfaces with more than ten structural implementers are skipped; an
unexported requirement only matches types in the same package. The AST
cache schema is bumped so cached Go extractions pick up the stamp.

(cherry picked from commit 97ccefff72)
2026-11-03 19:46:14 +00:00
nothariharan d90f9f5342 fix(go): resolve member calls on receivers typed from another package (#3368)
1695efae resolves a Go member call through the receiver's declared type,
but only when that type is declared in the caller's own package:
_go_single_type_name drops a qualified_type (`pkg.T`) because no bare
local name can stand for it. A dependency held as a field is almost always
typed from another package (`*plugincontext.Provider`, `plugins.Client`),
so the common case of #3368 still produced no calls edge, including when
the struct is declared in a sibling file (fdd25f7b).

The file's import of `pkg` is exact evidence of which `T` is meant. The
type table now keeps `pkg.T` as written, and _resolve_go_member_calls binds
it only to a `T` whose node carries the import path the caller imports
`pkg` from. Each Go type node records that path (`_go_package_path`, from
go.mod), and the incremental resolution context forwards it, so an
unchanged declaring file still answers on an update.

A sibling file's struct field (`_go_fields`) is stored as
`<import path>.T`, settled by the declaring file's imports: the method
file reading it, like Grafana's datasources.go reading
`HTTPServer.pluginClient plugins.Client`, need not import `pkg` itself.

Stdlib and out-of-corpus types stay unresolved and are not parked. The
qualifier also settles two packages declaring the same `T`, which the
bare-name path must leave alone.

Bumps _AST_CACHE_SCHEMA to 34 so cached Go extractions re-run.

(cherry picked from commit 048685ada1)
2026-11-03 19:45:14 +00:00
nothariharan d3b314d92e fix(cpp): type receivers per function and keep untyped receivers bound in-file
Review follow-ups to the previous commit.

The receiver table is one dict for the whole file, filled first-write-wins,
so `void g() { Response r; }` retyped `r` in `void f(Request& r)` and f's
`r.send()` went looking on Response. Build each function's table on its
own (a local still shadows a parameter there), then drop any name the file
types two different ways, including a field declared with different types
in two classes. An ambiguous receiver gets no type rather than a guess.

Defer a member call only when its receiver is typed. `auto w = make();
w.paint()`, smart pointers and range-for variables have no table entry, and
deferring them dropped the in-file edge they had on v8.

(cherry picked from commit 539e96f821)
2026-11-02 19:05:45 +00:00
nothariharan ffbdae50c2 fix(cpp): bind x.m() by the receiver's type, not the file's same-named method
A C++ member call with a variable receiver fell through to the file-wide
bare-name map, so `void render(Base* b) { b->draw(); }` in a file that also
defines `Derived::draw` produced an EXTRACTED edge to Derived::draw, the one
the static type rules out, and no edge to Base::draw.

Defer `x.m()` / `x->m()` to _resolve_cpp_member_calls like JS/TS already
do (#4598). With the parameter and field typing from the previous commit,
`b` is typed as Base and the call reaches Base::draw (INFERRED). An untyped
receiver now gets no edge instead of a name guess. `this->m()` and
`Foo::m()` keep their existing in-file binding.

(cherry picked from commit 971f564076)
2026-11-02 19:05:45 +00:00
nothariharan bce0d5624e fix(rust): scan only expression macros, and let a parsed call win the dedupe
Review follow-ups to the previous commit.

Any `name(...)` inside any macro was taken as a call, so DSL macros
(diesel `table!`, `quote!` with `#name(...)`, `html!`) produced calls the
code never makes. Scan only the std and log macros whose arguments are
plain expressions, and skip a name after `#`.

The in-file macro edge took the (caller, target) pair first, so a real
`compute(2)` later in the same function was deduped behind the INFERRED
token-pattern edge. Macro edges are now added after the function bodies
are walked, only for pairs no parsed call produced.

(cherry picked from commit f92f62e16f)
2026-11-02 18:02:14 +00:00
nothariharan fdb288fd5b fix(rust): link calls written inside macro arguments
Tree-sitter keeps a macro's arguments as a flat token tree, so
`println!("{}", f(x))`, `assert_eq!(f(), 1)` and `vec![f()]` had no
call_expression and the call produced no edge: `explain f` showed no
callers for a function used only inside formatting or assert macros.

Scan each macro invocation's token tree for an identifier followed by a
`(` group and treat it as a bare call. A name after `.` or `::`, a name
followed by `!`, uppercase names (constructors and variants) and the
builtin/trait-method blocklists are skipped. An in-file match is INFERRED,
since a token pattern is weaker evidence than a parsed call; anything else
goes to the cross-file pass like any other bare call. macro_rules! bodies
are macro_definition nodes and are not scanned.

(cherry picked from commit 309f9b1341)
2026-11-02 18:02:14 +00:00
nothariharan afb177911f fix(rust): keep module-path calls inside the caller's crate and out of local names
Review follow-ups on the rebased #2135.

- `crate::util::f()` stopped matching at `crate` without checking which
  crate the candidate is in, so in a workspace it bound to another crate's
  util.rs. A candidate must now share the caller's crate root (nearest
  Cargo.toml, else the directory above `src`).
- `crate::b::helper()` in a.rs went through the in-file bare-name lookup
  first and bound to a.rs's own helper. A module-path call binds in-file only
  for `self::f()` or an inline `mod m { .. }` declared in that file.
- Module names starting with `_` were rejected (`'_'.islower()` is False);
  only an UpperCamelCase segment means a type.
- Methods are skipped as candidates: a module path names a free function.

(cherry picked from commit ef748fd9f0)
2026-11-02 18:02:13 +00:00
nothariharan f3cdf6b651 fix(llm): write a held sliced file in chunk order, not completion order
Review follow-up. With max_concurrency > 1, slices finish in any order, and
the held results were joined in that order, so the cached entry's node
order changed from run to run and a cache-served build churned graph.json
(the #1632 problem). Join them by chunk index.

(cherry picked from commit 299fc1a36f)
2026-11-02 18:02:01 +00:00
nothariharan f2ef7024fe fix(llm): cache a sliced file only once every slice has succeeded (#4943)
An oversized document is split into FileSlice units, and each slice's
checkpoint saved under the parent file with merge_existing=True. Nothing
recorded that sibling slices were still pending, so after the first slice
the parent had a complete-looking entry. A run interrupted at that point
served the head of the file as the whole file, and check_semantic_cache
reported nothing left to extract.

Hold a sliced parent's results in memory until its last slice returns, then
write them in one save. A whole file in the same chunk is still checkpointed
right away. A slice that raises leaves its parent unsaved, and the parent is
added to the result's _partial_files, so the caller's final save stamps it
partial instead of writing the other slices' nodes as the complete file.

Entries written by earlier interrupted runs still look complete; a semantic
cache prompt or schema bump would be needed to invalidate them.

(cherry picked from commit dad35d8143)
2026-11-02 18:02:01 +00:00
nothariharan 590c77d89c fix(go): reference the types a package-level var initialiser names (#2360)
#2360 walks a package-level `var` initialiser for calls owned by the file,
but the types named there were still dropped: `new(T)`, `new(*pkg.T)`, a
composite literal `pkg.T{}` / `&T{}`, and the declared `var x pkg.T`. A file
holding only a google/wire set, `wire.Bind(new(Iface), new(*Impl))`, then
referenced nothing and was reported as yielding no symbols.

The file now gets a `references` edge (context `variable_type`) to each such
type, collected with the same _go_collect_type_refs and ensure_named_node a
struct field uses, so `pkg.T` resolves through the import and an external
type is parked on its import path exactly as a field type is. A closure body
inside the initialiser is function code and is left alone.
2026-11-01 18:24:02 +05:30
nothariharan f3e50225ed fix(python): don't resolve a bare call in a method to a method
A bare `f()` in a Python method body reads locals, enclosing functions,
module globals, then builtins; methods are only reachable through
self/cls/the class. The call walk's bare-call fallback used the file-wide
label_to_nid map, which also holds method names, so a method calling an
imported or module-level function of its own name (`AsyncTemplate.get_build_status`
calling the imported `get_build_status`) got a false EXTRACTED self-loop.

When that fallback lands on a method and the call is not in the body of
that method's class, look the name up in a method-free map instead; with no in-file hit the call
goes to raw_calls and the cross-file resolver binds it through the import.
Module-function recursion and self/cls calls are unchanged.
2026-11-01 18:22:23 +05:30
nothariharan 6bb5913dac fix(go): link a method value reached through a receiver field (#1566)
61e864a7 records a method value passed as an argument (`routing.Wrap(s.Health)`)
as an indirect raw call, but only when its operand is a plain identifier. A
handler held as a field of the receiver, `m.UseMiddleware(hs.ContextHandler.Middleware)`,
has a selector operand, so it was skipped and the method got no edge.

The argument walk now also accepts `self.field.M` when `self` is the method's
own receiver, and records it the way the direct-call branch records
`self.field.M()`: the field as `member_receiver`, the receiver's type as
`field_owner`. _resolve_go_member_calls then types it through the caller's
table or the owner struct's fields in a sibling file (#3368) and emits the
INFERRED `indirect_call`. A field whose type is declared nowhere links and
parks nothing, as before.
2026-11-01 18:22:15 +05:30
nothariharan eaa4aba022 fix(python): resolve imports across PEP 420 namespace packages under src/
In a monorepo of namespace distributions (pkgsql/src/airflow/..., pkgpresto/src/airflow/...,
no __init__.py anywhere), the package-root pass skipped every file because it found no
initializer, so an absolute import across distributions dangled. The importing class lost
its base, its inherited self.method() calls were dropped, and imported functions fell back
to INFERRED name matches.

When no initializer is found, take the nearest src/ ancestor as the import root. Modules
directly under src/ and stdlib-named namespaces are left alone, and the existing guard still
leaves a module claimed by two src roots unresolved.
2026-11-01 17:15:08 +05:30
nothariharan 0581b222c0 docs(skill): resolve the 'do not skip steps' contradiction (#4061)
The fast path tells the agent to skip Steps 1-5 for an existing graph,
then the next paragraph said 'Follow these steps in order. Do not skip
steps.' Reword the latter to defer to the fast path in all three source
fragments (core.md, aider.md, devin.md), and add the reword to the
sanctioned monolith-diff predicates so --monolith-roundtrip accepts it.

Regenerated the 14 split-host skill artifacts and expected snapshots with
tools.skillgen; --check and --monolith-roundtrip both pass.

(cherry picked from commit 41141efaa8)
2026-10-30 23:27:52 +00:00
nothariharan 948938a647 fix(extract): resolve module.func values in Python dispatch tables (#1566)
A dict/list/set/tuple literal of bare function names already yields
`indirect_call` edges, but the same table written with the module
prefix, the usual shape of a plugin registry:

    from payments import card, cash
    PROVIDERS = {"card": card.card_charge, "cash": cash.cash_charge}

got no edge at all, because only bare identifiers counted as values.

Such a value now becomes an `indirect` member raw call, and the Python
member-call resolver binds it through its module arm only: the receiver
must be a module imported into the caller's own file, holding exactly
one callable of that name. It is emitted as the INFERRED
`indirect_call` (0.85, context `collection`) the bare-name path uses,
never to a class used as a value, and never when a parameter or local
shadows the module name. A module-level table resolves from the file
node. The AST cache schema goes to 26 so cached Python extractions
re-run.

(cherry picked from commit 28934b6316)
2026-10-30 23:27:41 +00:00
nothariharan fdd25f7b31 fix(go): type a receiver's field when its struct is declared in a sibling file (#3368)
1695efae types `s.field.M()` through the caller file's own go_type_table.
When the struct is declared in another file of the package, the usual Go
layout, that file has no binding for `field` and the call is dropped, even
for a same-package field type.

Each Go file node now carries the field types of the structs it declares
(`_go_fields`, keyed by struct id), and a self-rooted raw call names the
struct that owns the field (`field_owner`). When the caller's table has no
binding, the resolver reads the owner struct's fields, only when the owner
is a single type declared by a single file. The fields ride on the file
node, not the struct node: every method file emits the struct's id too,
and on an incremental rebuild that fresh copy shadows the declaring
file's. `_go_fields` is carried through the incremental resolution
context, and the AST cache schema goes to 30.

(cherry picked from commit f3b1e7d87a)
2026-10-30 23:26:30 +00:00
nothariharan 61e864a7b1 fix(go): link a method value passed as an argument as an indirect_call (#1566)
A Go handler or callback is registered by passing a method value:
`routing.Wrap(s.Health)`, `r.Get("/p", s.Health)`. The call walk looked
only at what a call expression invokes, so the method got no edge from
its registration and a handler reached only through its route had no
caller.

walk_calls now records each `x.M` argument (on a plain identifier, not an
imported package) as an `indirect` raw member call, typed the way a direct
`x.M()` is. _resolve_go_member_calls resolves it through the same receiver
type, single-declaration and single-method guards and emits an INFERRED
`indirect_call`, as Python and JS do. It is never parked for a merge: a
value argument is as often a field as a method. The AST cache schema goes
to 30.

(cherry picked from commit e724c0c44f)
2026-10-30 23:26:18 +00:00
nothariharan 1c4c3f2c63 fix(go): credit calls in a package-level var initialiser to the file (#2360)
extract_go walks only function and method bodies for calls. A package-level
`var` initialiser was recursed into and never registered as a body, so a
call there, most often inside a `var provider = func(...) {...}` closure
kept as a swappable hook, produced no edge and its callee lost the caller.

A package-level var_declaration is now walked by the existing walk_calls,
owned by the file node: the initialiser runs at package init and has no
enclosing function. A `var` inside a function is unchanged. The AST cache
schema goes to 30.

(cherry picked from commit a05773eb54)
2026-10-30 23:26:10 +00:00
nothariharan b4686ea4af fix(install): write the global OpenCode plugin to ~/.config/opencode (#3398)
A global `graphify install --platform opencode` passed Path(".") as the
plugin base and joined `.opencode/plugins/graphify.js` onto it, so the
"global" plugin landed in whatever directory the command ran from and
loaded only for that project. OpenCode's global plugin dir is
~/.config/opencode/plugins, with no `.opencode/` segment, so the base
path alone could not be swapped.

The plugin helpers now take the OpenCode config dir itself, chosen by
_opencode_dir(): <project>/.opencode for a project install and
~/.config/opencode for a global one. `graphify uninstall` removes the
global plugin as well, and the OpenCode 2 plugin refresh also checks the
global dir. The legacy `.opencode/plugins/graphify.js` entry that older
releases wrote into opencode.json is still matched by its old string.

The slash-command half of the issue no longer applies: v8 has no
_install_opencode_command.

(cherry picked from commit c5cb910b78)
2026-10-30 23:24:56 +00:00
nothariharan 2859f5b9b0 fix(install): give gemini its own global skill dir on Windows (#2800)
On Windows the gemini user-global skill went to ~/.agents/skills/graphify,
the same path the `agents` platform installs to. The two ship different
SKILL.md files, so installing either one overwrote the other, and
uninstalling either one deleted the other's skill, references/ and stamp.

The Windows branch came from #368 on the belief that Gemini CLI prefers
~/.agents/skills there. Gemini CLI reads both ~/.gemini/skills and the
~/.agents/skills alias on every OS (docs/cli/skills.md), with the alias
winning a name clash, so the branch bought nothing and caused the clash.
gemini now uses ~/.gemini/skills/graphify everywhere.

Because the alias wins, a copy an older Windows gemini install left in
~/.agents/skills would hide the new one. gemini install now prints a note
naming that folder instead of deleting it, since it may be a real
`agents` install.

(cherry picked from commit 037fc62cd9)
2026-10-30 23:24:56 +00:00
nothariharan 0d251fe577 fix(serve): a name spelled exactly wins a lookup tie that is only case
Since #2779 the Go extractor keeps `Run` and `run` apart, but node lookup
folds case: both land in the exact tier and every lookup is refused as a
same-file tie, even one spelled exactly like one of them. The get_node and
get_neighbors tools also lowercased the query before resolving it. A
case-only pair could be reached only by its opaque id.

When the exact tier holds names that are equal up to case and exactly one
label is written as queried, that node is the exact tier and the others
move to the front of prefix. A query in neither spelling, or one spelling
that two files share, is still refused. get_node and get_neighbors pass
the label as written; the tiers fold case on their own.

(cherry picked from commit 507c5f351a)
2026-10-30 22:43:06 +00:00
nothariharan 92741d162b docs(security): refresh the threat-surface table (#4643-#4645, #4657, #4566, #4329)
Document mitigations that landed after the last SECURITY.md update:
- URL validation now rejects embedded credentials, port 0, and missing hostnames.
- ingest writes via lstat and refuses to replace an existing entry (symlink escape).
- credential-shaped text is redacted before it reaches graph.json.
- uninstall --purge refuses the project, home directory, and filesystem roots.

(cherry picked from commit 61f9bc82c4)
2026-10-23 18:20:06 +01:00
nothariharan 85567c95af docs(readme): list the antigravity-windows platform (#4655)
install.py defines antigravity-windows (the Windows shell variant of the
Google Antigravity platform), and the CLI help already lists it, but the
README platform table only had 'Google Antigravity'.

(cherry picked from commit ab742a3058)
2026-10-23 18:20:06 +01:00
nothariharan aa8ca7370b docs: document GRAPHIFY_CLAUDE_CLI_MODEL (#2861)
The claude-cli backend defaults to Opus, so community naming can burn
Opus quota silently. Document the env var in the README environment
section and mention it in the label/cluster-only --model help.

(cherry picked from commit f6d8a9b6b0)
2026-10-23 18:20:05 +01:00
nothariharan e8b1bb571f docs(readme): list the optional [watch] extra (#1203)
graphify watch needs watchdog, but the README extras table omitted the
[watch] extra, so users following the install docs hit 'watchdog not
installed'. Add the row alongside the other extras.

(cherry picked from commit ff015b9a74)
2026-10-23 18:20:04 +01:00
nothariharan 7174d3b972 docs(readme): document labeling batch limits, --missing-only, and html node limit (#3859)
- README: add a compact 'Labeling and rendering limits' section covering
  --batch-size vs context window, --missing-only, .graphify_labels.json.sig,
  export html --node-limit / GRAPHIFY_VIZ_NODE_LIMIT, and the Leiden->Louvain
  fallback.
- CLI help: state the ~16k default sizing for --batch-size and the 5000
  default for export html --node-limit.

Docs/help strings only; no behavior change.

(cherry picked from commit 4bbb93789b)
2026-10-23 18:20:02 +01:00
nothariharan 7598c5dcee fix(build): resolve a raw graph's import endpoints through the alias index (#4670)
`extract --no-cluster` and the clustered path disagreed on where a
framework-style `#import <Kit/ToolEvent.h>` lands. The clustered path
re-pointed the edge at the header's real file node (`kit_event_toolevent`);
the raw path minted an external stub for the header's bare basename
(`toolevent`) and left the edge on it, so the two write paths of one
extractor produced different graphs for the same corpus.

The raw path only had a normalization map. Normalization cannot bridge
`toolevent` and `kit_event_toolevent` - they are not the same string
modulo case and punctuation - so re-pointing was impossible. The
clustered path resolves it through the pre-migration alias index, which
maps a file's old-stem spellings onto its canonical id (#1504/#1509).

Move that index into a shared `_alias_index` helper and use it in both
paths, so the clustered and the raw write path resolve an endpoint the
same way. The raw path now re-points endpoints BEFORE it mints stubs, so
an import that names a real file is no longer frozen onto a stub minted
for its unresolved spelling; only a genuinely external import
(`<Foundation/Foundation.h>`) still mints one (#2873).

An alias is committed only when exactly one node claims it, so two files
sharing a bare stem stay ambiguous and the import keeps its stub rather
than binding to whichever same-stem file was seen first.

Tests: two unit tests over `finalize_raw_graph_endpoints` (an old-stem
alias resolves to the real file node; an ambiguous alias stays
unresolved) and one end-to-end test that `extract --no-cluster` and the
clustered path agree on the import target. The new tests fail without
this change.

(cherry picked from commit acbec5f5c3)
2026-10-23 16:11:06 +01:00
nothariharan 9c5d56f28f test(watch): use the markdown language alias for the document override
The rcfile language table maps 'markdown' -> .md; 'md' is not a recognized
alias, so the override was ignored and the watch test never saw a document.

(cherry picked from commit c1890f376a)
2026-10-23 15:51:09 +01:00
nothariharan e4d8235378 test(yaml): add structural extraction coverage and update document tests (#2214)
- Add tests/test_yaml_extraction.py (classification, key nodes, contains edges,
  stable ids, scalar/empty documents).
- Drop .yaml/.yml from the oversized-document slicing parametrization: they are
  code now, not documents sent to the semantic pass.
- Point the language-override lifecycle test at .md so it still exercises a
  document override (yaml is no longer a document).

(cherry picked from commit b69b32e2f1)
2026-10-23 15:51:09 +01:00
nothariharan 6a21696caa fix(detect/extract): structurally extract .yaml/.yml config files (#2214)
YAML files were classified as documents, so code-only / AST-only runs
(graphify update) produced zero nodes from them. Move .yaml/.yml into the
code path like .json: add a PyYAML-based structural extractor (extract_yaml)
registered in _DISPATCH, add the suffixes to CODE_EXTENSIONS, drop them from
DOC_EXTENSIONS and the splittable-text set.

Deterministic ids derived from the file path; top-level and nested keys become
nodes with contains edges, capped at 500 pairs / depth 6 to avoid exploding on
data-heavy YAML.

(cherry picked from commit 2e5565a684)
2026-10-23 15:51:09 +01:00
nothariharan a8ce86f02e test(extract): pin #2945 module-import over-promotion regression
Adds a regression test that fails on the pre-fix resolver: a caller that
imports a module for a different symbol and calls a same-named function must
keep the edge INFERRED, never EXTRACTED.

(cherry picked from commit 7d41be8891)
2026-10-23 15:38:48 +01:00
nothariharan ac4b5e33dd fix(extract): don't promote module-imported same-named calls to EXTRACTED (#2945)
When an ambiguous bare call resolves to a candidate solely because the
caller imported the candidate's source module (not the symbol itself), the
edge was promoted to EXTRACTED, falsely certifying a same-named symbol that
was never actually imported. Keep the resolution (for graph connectivity) but
mark it INFERRED. Symbol-level (from X import Y) imports still promote to
EXTRACTED.

(cherry picked from commit e73ca4e4a7)
2026-10-23 15:38:48 +01:00
nothariharan c6d4c25135 fix(mcp): a substring near-miss is no longer the answer (#3917)
`get_node` / `get_neighbors` share `_resolve_single_node`, which takes the
first node of the winning tier. The substring tier matches a query anywhere
inside a label, so `get_node(label="MailController")` on a codebase with no
`MailController` returned `EmailController` as if it were the exact symbol,
with no hint that the name does not exist.

The resolver now splits the two fuzzy tiers by intent. A prefix match still
resolves, because the caller started typing the real name (`email` ->
`EmailController`). A substring-only match is a search hit, not the symbol
the caller named, so it returns `No exact match for '<query>'` followed by
up to five closest names with their source location, plus a `path::symbol`
retry example. `get_neighbors` inherits the same answer through the shared
resolver, so both tools report one lookup the same way (ADR-0001).

Exact, source-exact and prefix resolution, the ambiguity refusals, the
dotted/Python and `path::symbol` forms and scoring are unchanged. The other
near-miss case in the issue (`get_node(label="edit")` with several `.edit()`
methods) already refused as Ambiguous under ADR-0001; tests cover both.

Tests: the issue's MailController repro, prefix shorthand, exact-over-substring
precedence, the five-candidate cap.

(cherry picked from commit d3875f4f1c)
2026-10-22 13:47:04 +01:00
nothariharan a287c0795a fix(markdown): keep owner evidence when the edge already exists
The review bot flagged a real hazard in the owner-evidence bookkeeping: a
mention whose `references` edge is already in the graph returned early, so
the document never recorded that it cites the target. A later bare method
mention in the same document then lost its owner and was dropped.

`_add` now records the cited target before it decides whether the edge has
to be written, so the evidence survives an edge that is already there.

The pipeline cannot reach that state today (the resolver is handed a fresh
edge list, and the incremental context only carries contains/method/
inherits/imports edges), so this is hardening rather than a fix for a
reachable failure. The regression test drives the resolver directly with a
pre-existing class edge.

(cherry picked from commit 37efe877cf)
2026-10-22 13:46:52 +01:00
nothariharan 0620458b04 fix(markdown): a bare method name needs its class cited (#4609)
`resolve_markdown_mentions` linked any bare, parenthesis-less code span to
the corpus's single `_callable` carrying that label, and methods qualify.
A prose word in a code span (`redis` the server, `data`, `message`) then
became `heading --references--> SomeClass.word()` at INFERRED 0.95, on a
method that has nothing to do with the sentence. On the reporter's corpus
44 of 1,906 mention edges were words of this kind.

A bare single-name span is now resolved in three passes. Explicit evidence
(a cited path, a dotted qualifier chain, or a trailing `()`) resolves as
before. Bare mentions that do not name a method keep resolving, and their
targets are recorded per document. A bare mention that names a method is
kept only when its owner class is already cited in the same document, so
`redis` no longer links to `Cache.redis` while `successWithWarnings` next
to `HandlerResult` still does. Ambiguity, built-ins and the case-sensitive
label match are unchanged.

Tests cover the issue repro, the owner-cited case, the `()` case, a free
function, and the cross-document guard.

(cherry picked from commit 6bba91fc65)
2026-10-22 13:46:52 +01:00
nothariharan 8a982c4a92 fix(skill): a partly-read file is no longer a silent, permanent loss
The Read tool returns at most 2000 lines per call and reports no error when it
truncates, so a subagent that read only the head of a long file still writes a
well-formed chunk. Step B3 treated "chunk exists and parses" as success, and
because build_merge replaces a re-extracted file's nodes, the unread tail was
not merely missed: it was deleted, the run reported success, and the manifest
recorded the file as done so no later --update retried it. On a 4165-line file
that left 103 nodes covering 31% of the document, with 90 of 131 entries gone
and the manifest treating it as finished.

Three changes, in the fragments, so all thirteen disk-dispatching hosts pick
them up from one edit:

The extraction spec (verbose and compact) now states the cap and forbids
emitting nodes for a partly-read file, and asks the subagent to report a
top-level "coverage" map of file -> lines read. A short count is recoverable; a
missing entry is indistinguishable from a complete read, which is why the
machine check needs the prompt to ask.

Step B1 bounds a chunk by total lines as well as file count (20-25 files AND
~6000 lines), and gives any file past 2000 lines a chunk to itself. File count
alone was only half the mechanism: a subagent holding 25 files also dilutes
attention, which is how a 590-line plan came back with zero nodes.

Step B3.5 compares each reported coverage against the file's real length, names
what was short, and hands the list to the two places that decide whether a file
is ever looked at again: save_semantic_cache(partial_source_files=...) stamps
those entries partial, which load_cached treats as a miss, and
_stamped_manifest_files(partial_source_files=...) leaves them unstamped so
detect_incremental re-queues them. Both are the existing contract the library
path already uses for a truncated LLM response (#933, #1950), so the skill and
library paths now recover the same way. Nodes already found for those files are
kept; the next run's replace-on-re-extract swaps them for a complete set.

The check is fail-safe in the direction that loses nothing: no coverage reported
means no file is flagged, and a flagged file is re-read rather than trusted.
Codex collects subagent results in memory with no per-chunk files on disk, so it
gets the prompt-layer fix but not the Step B3.5 gate; its inline extraction has
no chunk file to compare against.

Tests execute the emitted python instead of matching its source (the #2126/#2641
convention), including a round trip through the real semantic cache: the
partly-read file must come back as uncached, while the fully-read file still
hits. Reverting the fix makes that round trip return an empty uncached list -
the file served from cache forever, which is the bug.

Fixes #2225

(cherry picked from commit 0b6a1868af)
2026-10-20 15:40:39 +01:00
nothariharan 28938a4732 feat(extract): add EJS (.ejs) template extractor (#3811)
EJS views sat in CODE_EXTENSIONS with no extractor, so an Express/Node app's templates were counted as code and contributed nothing (the #1689 warning). A .ejs file is HTML with <% %> scriptlets and inline <script> blocks, so feeding the whole file to the JS grammar made it one top-level ERROR.

Add extract_ejs: mask the template down to its JS regions (code-tag and <script> bodies), parse them with the TS grammar, and add the two relationships no JS grammar can see - dynamic import('./X') and the EJS <%- include('partial') %> composition edge, resolved to the real partial file. Wire .ejs into the dispatch, the jsts language family, the JS resolve/cache sets, and the hook source extensions.

(cherry picked from commit 3824cda537)
2026-10-12 22:58:40 +01:00
nothariharan 0778755e81 fix(cache): namespace AST cache by tree-sitter grammar versions (#4236)
(cherry picked from commit 90fadbd5e1)
2026-10-09 19:46:57 +01:00
nothariharan 4cf3dfba06 fix(analyze): exclude contains-only AST declarations from knowledge gap detection (#4205)
(cherry picked from commit bf55b069f8)
2026-10-08 14:27:06 +01:00
nothariharan 762cfd33ad fix(hooks): refuse a core.hooksPath that leaves the repository
hook install followed git's hooks path even when core.hooksPath resolved
outside the checkout, then created that directory and wrote post-commit
there. The bytes are Graphify's own hook, not repository-chosen code, but
the write still escapes the repo. Keep in-repo paths such as .husky, and
git's own hooks directory (including a linked worktree's shared .git/hooks).
Anything else falls back to that default.

Fixes #3869

Co-Authored-By: Grok 4.7 <noreply@x.ai>
(cherry picked from commit ee35087aea)
2026-10-04 20:40:34 +01:00
nothariharan af153f85ea fix(kotlin): keep annotated inferred properties in the graph
An annotation on a class property with no explicit type never assigned
`line`, so the annotation loop raised UnboundLocalError and _safe_extract
dropped the whole file. Set `line` before the type-node check so the file
and its attribute edge both survive.

Fixes #3884

Co-Authored-By: Grok 4.7 <noreply@x.ai>
(cherry picked from commit 03ba8cc9a3)
2026-09-29 13:49:39 +01:00