#4997's _collision_aware matched any alphanumeric id suffix, which also matches
a class member id (classid_methodname), so a type-annotated field following a
method had its reference stolen onto the method in TS/JS/C#. Restrict the
sibling match to the actual underscore-collision salt (a 6-char sha1 hex, per
_underscore_salted_nid) and add a method-then-field regression test.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`ids.py:make_id` strips the underscore edges off every part, so a module that
declares both `_main` and `main` mints one plain id for the pair. The AST
extractor already deals with that: `_python_pre_scan_underscore_collisions`
salts the collision apart (#3302) and leaves the plain id on the unique public
spelling, which here means `main()` keeps `cli_main` and `_main()` gets
`cli_main_<hash>`.
The import-aware symbol pass never learned that rule. It walks the top-level
defs itself and rebuilds each caller id straight from the bare name, so `_main`
also arrived as `cli_main` — the public sibling's node — and every call inside
`_main` to an imported symbol was emitted a second time, sourced from `main()`
and marked EXTRACTED at a line that belongs to `_main`.
Resolve the caller against the final graph instead. When the id the walk
produced is shared by more than one declaration, pick the one whose line
encloses the call. Node ids, edges and raw_calls are all final by the time
this pass runs, so the salted spelling is available. A name with no collision
never enters the branch and keeps the exact behaviour it had.
Fixes#4994
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit de30ba0e86)
_nudge_allowed caps soft nudges per session and per subagent (#3435). When
Claude Code compacts a long conversation (auto or /compact) it keeps the
session id, but the compacted context no longer holds the earlier nudges or
the graph context. The cap is already spent, so for the rest of the session
the agent reads and greps raw files and never hears about the graph again.
Claude Code fires SessionStart with source "compact" after compaction.
`graphify install` (Claude Code only) now also registers a SessionStart hook
with matcher "compact" that runs `graphify hook-guard compact`. It deletes the
session's .nudges counter, the counter of every subagent of that session
(<key>-<16 hex>) and the session's strict-mode .denied marker, so the next
qualifying Read/Grep nudges again and strict mode can redirect once more.
Other sessions' markers are untouched; startup, resume, clear and fork do not
reset. When a graph exists it returns a one-line SessionStart
additionalContext that names the graph and the query commands. Any error
prints nothing and exits 0.
Install merges the entry like the PreToolUse ones (other SessionStart hooks
are kept, re-install does not duplicate it); uninstall removes it from
settings.json and settings.local.json. The cap and the per-agent and stamp
rules are unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 53bf0a1d76)
The Read|Glob matcher gives the read nudge, but Bash goes to `hook-guard
search`, which only reacted to search commands. `cat src/app.py`,
`head -50 src/app.py`, `tail`, `nl`, `less`, `more` and `bat` read indexed
code with no nudge at all, and `sed -n 1,80p src/app.py` got the generic
search nudge without the file's symbols. Claude Code reads files this way a
lot, especially with the Bash tool in auto mode.
`hook-guard search` now checks Bash commands for a file reader in an executed
position (the #3121 parsing, factored out of _bash_invokes_search into
_bash_commands so both use it) naming an existing in-project code file. Such a
call goes through the Read path: the same Read nudge with the file hint, the
stale variant, and the same per-agent budget. It is never denied, also in
strict mode. Targets outside the project or inside the graph output are
skipped (#1840, #4961), as are docs (`cat README.md` stays silent, as the
existing tests pin), non-graphed extensions, writes (`cat > x.py`, a stdout
redirect, `sed -i`), stdin reads (`echo x | cat`) and paths with shell
expansion. sed counts as a reader only with -n/--quiet/--silent; without it a
sed on a file stays a search, as before.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 13d133ea68)
Covers the unimported builtin, the imported control case, module-only import evidence, a local same-named class, by-name dispatch, and unchanged non-builtin INFERRED resolution.
(cherry picked from commit 59eb928f51)
A bare Python name resolves through the caller module's own bindings. The cross-file resolver matched any bare callee by label, so a file that never bound NotImplementedError linked to a package class of that name. Module-level import evidence from the same file could even promote the wrong edge to EXTRACTED.
Accept a builtin-named Python callee only when the caller imports that exact symbol. The imported control case still resolves as EXTRACTED; non-builtin INFERRED resolution is unchanged.
(cherry picked from commit 9a2427d105)
Fixed rather than derived from dir(builtins), so extraction stays deterministic across interpreter versions. Kept separate from _LANGUAGE_BUILTIN_GLOBALS: that set gates extraction, where dropping a raw call would also drop the import evidence for a same-named project class.
(cherry picked from commit 21279c932a)
The language-builtin exclusion ran for every non-path mention, so a dotted
mention like `Repository.open` was discarded before its qualifier evidence was
checked — even though the qualifier proves the reference. Builtin-named methods
(open/get/list/map/filter/update/...) are pervasive, so real cross-references
silently produced no edge. Apply the builtin filter only to bare single-name
mentions (len(names) == 1). Add a regression test.
(cherry picked from commit 85f344a64e)
watch is a long-lived process, so a cache that outlived one reconcile call
would answer with a stale header dialect after an edit. Rebuild three times in
one process and assert every rebuild resolves the file again.
Moving the memo to module scope turns this test red and nothing else.
(cherry picked from commit 4024792e2d)
The cap was asserted against a reference implementation, not against the
shipped sniffer, so read_bytes()[:CAP] could come back and every test would
stay green. Assert the exact read sizes on a file larger than the cap, for .h
and .m, and grow the .m pipeline fixture past the cap so its byte assertion can
fail. With an unbounded fh.read() both new tests go red.
The H1 and H4 variants can no longer differ now that the reconcile path does
not sniff .h at all, so test_cost_variants and the meaning differential were
asserting the same thing four times. The frozen node set is the guard that
still bites.
(cherry picked from commit 8db559def5)
_is_objc_header and _is_cpp_header sliced read_bytes() down to 256 KiB, so a 4 MB single-header library was fully read and allocated twice per call. read the head directly instead. Same bytes inspected, same answer, no full-file allocation.
(cherry picked from commit 60342b7ee1)
_reconcile_existing_graph tested _get_extractor per node, and a .h resolution read the whole file twice inside the sniffers. Reconcile only needs to know whether the source is AST-owned, which every .h dialect always is, so the header sniff is skipped for that caller and the answer is memoized by identity.
Keying by identity also resolves source_file against the project root, so a relative path no longer makes both sniffs swallow an OSError when the process CWD is outside the project.
(cherry picked from commit cc65f4dbc4)
Reconcile calls _get_extractor once per node, and for a .h that call reads the whole file twice. The suite counts asks, real extractor resolutions and bytes read per variant, and freezes the survivor node set so the perf changes that follow can prove they changed no decision.
(cherry picked from commit 2edb9f979c)
An exported CDPATH makes the cd builtin print the resolved directory to stdout. The git-dir captures only silence stderr, so they became two-line values and the toplevel anchor exited via '|| exit 0', silently skipping every generated rebuild. Prefix both cd calls with CDPATH= and add a regression that runs the real guard under an exported CDPATH.
Co-Authored-By: TRAE <noreply@trae.ai>
(cherry picked from commit 009f9fdb5f)
#4816's _partial line used escaped double quotes (encoding=\"utf-8\"), which
work in the bash-wrapped runbook but break test_update_manifest_preservation,
which execs the manifest block as raw Python. Match the single-quote style the
rest of the file already uses so the line is valid in both contexts, and
regenerate the skill artifacts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fold the hooks/perf/TypeScript and this query/skill/install/watch batch into
a single 0.9.102 CHANGELOG section (0.9.102 and 0.9.103 were never published),
and keep the version at 0.9.102.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rendered from the fragment and generator changes via the skillgen
module, then blessed into expected/. No fragment or generator
source changed here, only its render.
(cherry picked from commit bfeabedf7e)
A bridge or god node question's neighbour listing only shows code
that already has an edge to the hub, so a module that reimplements
the hub's own job instead of calling it never shows up there, even
though it depends on the exact same behavior. One real case: two
server modules that hard coded a date utility's offset instead of
calling the shared helper read as unrelated to the bridge, when they
were in fact the most useful finding the question could have
surfaced.
The query flow now adds a check for exactly this shape, scoped to a
hub or bridge question: after the normal answer, grep the corpus for
one or two literal, distinctive things the hub does, in files that
have no edge to it in the traversed subgraph, and report any hits
separately as bypasses. It also asks the answer to call out when a
shared utility's own community label actually names its heaviest
consumer, a labelling quirk that otherwise reads as if the consumer
were the bridge.
The aider and devin monolith skills carry their own copy of this
query section, so the same paragraph was added there too, right
where their own save result step already follows the answer.
(cherry picked from commit 26daf32bc5)
The PR's parity test asserted an external CJS require emits no calls/inherits
edge, matching ESM. On the current tree an external require binding is a real
local node that new/extends resolve to, while an external ESM default mints
none - a pre-existing asymmetry outside #4688's intra-project ./ require fix.
Pin the real behavior so a future change is deliberate.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bare `exports = X` only rebinds the local exports binding in CommonJS and
must not mint a default export. Chained `module.exports = exports = Foo`
must export Foo, not the intermediate name `exports`.
Co-Authored-By: Grok Bot
(cherry picked from commit 47cb49ef0a)
After #4634 stopped minting a module-scope node for
`const X = require('./m')`, `class A extends X` lost its inherits
edge entirely. Record whole-module require bindings and
`module.exports = Name` as symbol import/export facts so heritage
resolves to the required class, matching ESM default imports.
Fixes#4688
Co-Authored-By: Grok Bot
(cherry picked from commit d9132a85ca)
An incremental rebuild derives its change set from the manifest inside the lock,
so it names no paths and had nothing to append to .pending_changes, while
.pending_full would have meant "re-extract everything". Losing the lock therefore
dropped the request, and the False it returned was indistinguishable from the
"queued, it will run" answer a caller gets for the other two kinds.
This is latent rather than an incident: no non-blocking incremental caller exists
today, because the CLI blocks on the lock and the watcher and hooks pass explicit
paths. The fix completes the design.
The request is now recorded as a .pending_incremental marker, and any holder that
drains it runs an incremental pass, including a holder whose own request was a
full one. Reported by review on #4769.
Fixes the latent drop for #4769's incremental kind.
(cherry picked from commit 3e6138c3bc)
When to_json() refuses to shrink graphify-out/graph.json under the #479
shrink guard, the skill instructs the user to re-run with --force.
However, Step 4 in tools/skillgen/fragments/core/core.md invoked to_json()
without force=True, preventing intentional shrinks from ever succeeding.
Update Step 4 to instruct the agent on substituting IS_FORCE and pass
force=IS_FORCE to to_json. Regenerate committed skill artifacts and
expected/ snapshots via skillgen, and add regression tests in
tests/test_skillgen.py.
Fixes#4777.
Co-Authored-By: Gemini <noreply@google.com>
(cherry picked from commit 6776be6cc3)
Deleting the list there broke the case where Step 9 runs after the update;
the comment keeps the next reader from moving the cleanup back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit df22be56d6)
- Run each runbook block under `bash -e`. Step 9 runs cleanup commands after
its Python, so a Step 9 that failed before saving the manifest still exited
0, and the doc stayed queued from the merge: the Step 9 case passed without
Step 9 having done anything.
- Give the partly-read docs new nodes of their own and assert those survive
the merge. The seeded graph already had a node with the same id and source,
so dropping this run's nodes before the merge still passed.
- List two partly-read docs, so a parse that keeps only the first entry fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 39af15ab83)
Deleting .graphify_partial.txt in the merge block undid the fix whenever an
agent ran Step 9 after the update: Step 9 found no list and stamped the
partly-read doc, where before this branch it read the list and left the doc
queued. Step 9's manifest code handles --update mode, and agents do run it
after an update (#837).
The first --update block now deletes a list an earlier run left, before
detection. This run's list stays for the merge block and for Step 9, and a
stale one still cannot hold back a doc this run serves from the cache.
Tests: run the runbook's populate block too; add a case that runs the
rendered Step 9 after the merge; cover scan roots '.' and 'docs' with a nested
doc and both list-entry forms (absolute, root-relative); skip without bash;
drop BASH_ENV and ENV from the subprocess environment; derive the hosts from
the render instead of a hardcoded list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d19a2b112a)
Step B3.5 lists the files a subagent read only partway in
graphify-out/.graphify_partial.txt. A full build's Step 9 passes that list to
_stamped_manifest_files, so those files stay unstamped and the next --update
queues them again (#2225). --update does not run Step 9: its runbook writes the
manifest itself and did not pass the list. A doc read partway during an
--update was stamped as done, and kept its partial node set until its content
changed again.
The update runbook now reads the list the way Step 9 does and passes it as
partial_source_files. It also removes the list once the manifest is saved.
--update never runs Step 9, which deletes it after a full build, and only B3.5
rewrites it, so a later run that skips B3.5 would read it again: a doc it
names that came back as a cache hit would stay unstamped on every run.
Edited the shared update fragment, then regenerated the 14 per-host
references/update.md files and their expected/ snapshots. The new test runs
the rendered runbook's merge block on a seeded project and asks
detect_incremental what the next run would queue.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 257f3f77c0)
Every `graphify uninstall` now visits the user's global CLAUDE.md and
CODEBUDDY.md, also for users who never installed the skill there, so a
section they wrote under a `# graphify` heading must not go with
graphify's registration. In those files only a section carrying the
registration bullet graphify has always written (`- **graphify** (`...`)`
with the `/graphify` trigger, in every version since the first) is
removed; a hand-written one stays, and a file holding both is left as is
with a hint rather than guessed at. The project-scoped removal keeps its
existing behavior.
Also: a BOM no longer hides a block on the file's first line and is
written back as found, and a file without the heading is never decoded,
so an unrelated non-UTF-8 file draws no "skipped" warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a7bd4e61e4)
A global `graphify install --platform claude` (or `windows`) registers the
skill with a `# graphify` block in ~/.claude/CLAUDE.md ($CLAUDE_CONFIG_DIR/
CLAUDE.md when that is set), and `--platform codebuddy` does the same in
~/.codebuddy/CODEBUDDY.md. `graphify uninstall`, `graphify claude uninstall`
and `graphify codebuddy uninstall` deleted the global skill but left the
block, so every Claude Code or CodeBuddy session kept being told to use a
skill that no longer existed. Only the project-scoped uninstall removed its
registration.
Remove the global registration wherever the global skill is removed,
resolving the file exactly as install does, CLAUDE_CONFIG_DIR included
(#2694); a test pins the two to the same file. The removal follows the
project-scoped rules: only the exact `# graphify` H1 block goes (#2062),
line endings are kept (#4360), a symlinked file is edited in place (#3805),
and the file is deleted only when nothing else was in it. Like install
(#3474), it skips an unreadable or unwritable file with a hint instead of
aborting the rest of the uninstall; the project-scoped removal shares that
helper, so it now degrades the same way. A project-scoped uninstall still
leaves the global skill and its registration alone (#2215).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8ab30ab40a)
query scores node names only, so a test named after a bug (UsernameValidatorsTests) wins the
exact-name tier, and the answer is ordered by hop and degree, so hub files fill the budget.
On 177 SWE-bench Lite questions 43% of the start nodes were tests.
Inside query only, test, doc, config and sourceless nodes now count x0.3 unless the question
asks about them (reusing paths._is_test_path), and the answer is listed file by file, best
file first. path, explain, traversal, the budget and the per-term seed guarantee are
unchanged. Top-5 on 293 SWE-bench Lite and Verified questions: 49% -> 56% (26 gained, 4 lost).
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 9b2e076b76)
Mapea las posiciones de bytes a texto normalizado en una sola pasada y
evita reiniciar la búsqueda en cada carácter de un identificador largo.
Co-authored-by: Codex <noreply@openai.com>
(cherry picked from commit 87f1514ebd)
La gramática puede perder declaraciones después de plantillas etiquetadas
con tipos o anotaciones calificadas por import. Normalizar sólo los tipos
identificados conserva las posiciones y evita relaciones dinámicas falsas.
Co-authored-by: Codex <noreply@openai.com>
(cherry picked from commit 7da2f1b910)
Only omit hints when recognized literal targets all resolve outside the project. Preserve advisory hints for mixed paths and uncertain shell syntax.
Fixes#4961
Co-Authored-By: OpenAI Codex <noreply@openai.com>
(cherry picked from commit 2ef48b214f)
A Grep pinned to one unindexed file (pyproject.toml, a config) spent the session's single strict deny on a target the graph cannot answer. Apply Read's indexed-file check to single-file targets; directory searches are unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 1b89dfa50c)
Share Read’s existing one-denial-per-session gate with dedicated Grep, respecting the query stamp and project/output boundaries. Bash and Glob remain advisory. Pass --strict through installed search hooks and document both-mode silence for irrelevant targets.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
(cherry picked from commit 6f38228510)
A checkout can write unchanged source after the tracked graph. Consult the exact extraction-manifest row when timestamps look newer; keep real content changes, uncertain evidence and pending updates advisory. Reuse the manifest writer’s streamed digest and preserve conservative fallbacks.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
(cherry picked from commit 8a8234a582)