Skip to content

feat(hook): show the graph nodes behind a nudged call, and tighten its wording - #1

Closed
andrebrait wants to merge 158 commits into
L4XB:fix/cap-soft-hook-nudgesfrom
pfBlockerNG:feat/nudge-hints
Closed

andrebrait wants to merge 158 commits into
L4XB:fix/cap-soft-hook-nudgesfrom
pfBlockerNG:feat/nudge-hints

Conversation

@andrebrait

Copy link
Copy Markdown

A follow-up on top of your Graphify-Labs#3443 branch, offered here so the soft nudge lands as one change. Your budget decides when a nudge fires. This PR changes what a firing nudge says: agents in our downstream build kept treating it as noise, even within the budget.

What changes

  • Call-specific hint. A firing nudge, and the strict-mode deny, now ends with a command built from the call and up to five matching graph nodes with file and line:
    Start with: `graphify explain "load_config()"`
    What the graph already has for this call:
    - load_config() (src/app.py L10)
    
    For a search, the hint comes from the Grep pattern or the pattern argument of grep/rg/ag/ack. Value-taking flags are skipped, and find/fd are excluded because they match file names. For a read, it lists the file's symbols in line order. An exact label match suggests explain, and anything else suggests query.
  • Cheap and fail-safe. The hint scans graph.json labels directly instead of loading the query stack, which cost about 1.5 s per hook call on a 15k-node graph. Measured: 0.3–0.5 s on 3k–15k-node graphs. Graphs over 24 MiB, a malformed graph, no match, or any error all fall back to the unchanged plain nudge. Graph text is sanitised to one line with no control characters or backticks and a capped length, because graph.json is repository content.
  • Narrower wording. "…or to modify/debug specific lines" excused nearly every targeted read. The nudge and the deny now allow raw reads only once the exact file and lines are known.
  • Always-on rule. The Claude, AGENTS.md and Gemini blocks now name the moment to query ("before your first grep, search or source-file read") instead of "for codebase questions". Recorded as a sanctioned skillgen edit. The Kiro and Antigravity blocks use different sentences and are unchanged.

The branch first merges current v8, as you did in d7ba4af. The README conflict was resolved to v8's side, since the strict-mode note moved to the docs site.

Tests: new cases in tests/test_hook_guard.py and tests/test_hook_strict.py cover hint content and ranking, the 5-node cap, flag parsing, path-only and short-term non-matches, hostile labels, malformed and oversized graphs, and the deny hint. The skillgen guards (--check, --always-on-roundtrip) pass. The full suite passes except test_collect_files_skips_hidden and test_warning_carries_no_hardcoded_issue_number, which fail the same way on plain v8 here.

safishamsi and others added 30 commits October 5, 2026 17:46
A Solidity enum value is a discriminant case, not a declared member, so it
should hang off its enum with a case_of edge like every other language that
has enums (Java Graphify-Labs#1719, C#, Swift, Rust, VB.NET). Solidity was the lone
remaining outlier, routing enum values through the same contains path used
for struct fields.

The relation is not cosmetic: case_of targets are excluded from constructor
binding, so an enum value named like a type could previously be mistaken for
one. Struct fields keep contains, since a field is a real declaration.

Add a regression test asserting enum values get case_of (and not contains)
while a struct field keeps contains.

(cherry picked from commit fdd9950)
A PowerShell enum member is a discriminant case, not a declared field, so it
should hang off its enum with a case_of edge like every other language that
has enums (Java Graphify-Labs#1719, C#, Swift, Rust, VB.NET). PowerShell was routing enum
members through the same contains path used for class members.

The relation is not cosmetic: case_of targets are excluded from constructor
binding, so an enum member named like a type could previously be mistaken for
one.

Update the existing enum test to expect case_of and add a focused regression
test asserting enum members get case_of (and not contains) while the file
still contains the enum type via contains.

(cherry picked from commit 011dda9)
A trigger exists to run a routine, but the create_trigger branch only linked
the trigger to its ON table and ignored the EXECUTE FUNCTION/PROCEDURE clause
entirely. The routine a trigger fires — its whole reason to exist — was never
represented in the graph.

Register function/procedure node ids in a routine_nids map (mirroring
table_nids) and, in create_trigger, read the object_reference after EXECUTE and
emit an `executes` edge to that routine. Resolution is name-based against
routines defined in the same file (a trigger's function is declared before it);
when the routine is not in this file the edge is skipped rather than guessing a
cross-file target or minting a bare-name stub that could never rewire onto a
`name()` function node.

Add regression tests for the resolved case and the fail-closed case.

(cherry picked from commit ea39929)
Objective-C is an object-oriented extractor that already emits @interface,
@implementation and @protocol type nodes, but plain `enum` and
`typedef enum` definitions were dropped entirely: both the enum type and all
of its enumerators were invisible in the graph.

Handle `enum_specifier` (and the `typedef enum { ... } Name;` form, where the
name is the typedef alias), emitting a type node plus a node and `case_of` edge
per enumerator — the same shape every other language with enums uses (Java
Graphify-Labs#1719, C++ Graphify-Labs#3939, Swift). A nameless enum and a bodyless `enum X y;` reference
are skipped so no phantom node is minted.

NS_ENUM/NS_OPTIONS is deliberately out of scope: it is a macro call that
tree-sitter-objc parses into an ERROR subtree, so there is no clean AST to
read. Documented in the test.

Add regression tests for the plain, typedef, and skip cases.

(cherry picked from commit 2d30c41)
Enum extraction (Graphify-Labs#4056) is only tested with the plain form,
`TColor = (clRed, clGreen, clBlue)`. The valued form nests an explicit
ordinal under declEnumValue -> defaultValue, beside the value's identifier,
so a change to how the value's name is read could leak the literal into the
label, or emit it as a node, without any test noticing.

Add a test for `TColor = (clRed = 1, clGreen = 2)` asserting the type node,
a `case_of` edge to each bare value name and to nothing else, and that
neither literal becomes a node.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1b05d15)
…ot minted

Graphify-Labs#4050 emits a node + case_of edge per `union(enum)` variant but
deliberately does not recurse into a variant's nested-struct payload.
Extend the tagged-union test to pin that: `rectangle: struct { w, h }`
is minted as a variant, while its `w`/`h` fields are not, and
`rectangle` owns no case_of edges of its own.

Fixes Graphify-Labs#4074

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 994bb2e)
Graphify-Labs#4027 taught the Elixir extractor defmacro, defmacrop, defguard and
defguardp, but the regression test only exercised the first three. Add a
defguardp clause to the fixture and assert its node is extracted, so
dropping defguardp from the extractor's keyword list fails this test.

Closes Graphify-Labs#4076

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 345b66b)
`class Foo[A: Ordering]` (and the same on case classes, traits and enums)
now emits a `references` edge with the `type_bound` context from the type
to each bound, reusing the method-level path from Graphify-Labs#2046.

Closes Graphify-Labs#4080

Co-Authored-By: Grok Bot <[email protected]>
(cherry picked from commit d1257ef)
A 0-byte file has no line 1, so the file node's source_location=L1 was an
anchor that can never resolve. Leave it None (how other location-less file
nodes already look) in the shared tree-sitter path, and keep the node: an
empty __init__.py is still a module other files import.

Closes Graphify-Labs#4041

Co-Authored-By: Grok Bot <[email protected]>
(cherry picked from commit 29597ad)
Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit aca5651)
Graphify-Labs#3976 made recv?.M() resolve through the receiver-typed path but only
tested field receivers. Add a test that `this?.Save()` inside a class
resolves to the enclosing class's Save() like `this.Save()`, and not to
an unrelated class's Save().

Fixes Graphify-Labs#4077

(cherry picked from commit 6ce8348)
Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit 42dc0a7)
Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit 1575f86)
Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit 0a7c77c)
Preserve subsequent script blocks and byte offsets when a script ends in a line comment. Fixes Graphify-Labs#4072.

Co-authored-by: Codex <[email protected]>
(cherry picked from commit fc48f65)
…Graphify-Labs#4066)

graph.json is written "directed": false and carries direction in arc order
(Graphify-Labs#563), or in _src/_tgt markers on legacy files (Graphify-Labs#2309). A plain undirected
node_link_graph load re-orders endpoints by node-list position, so every
link whose target precedes its source in the node list came back reversed
(79% of links on graphify's own graph).

query, path/explain, affected, merge-graphs and the MCP server already
restore direction. The remaining reloaders did not:

- export html / neo4j / falkordb (cypher.txt and --push) / obsidian canvas
- graph.html re-rendered by update, watch and the git hooks
- the git merge driver, which wrote the reversal into the committed
  graph.json, even when merging three identical copies

Add paths.restore_arc_direction, the inline idiom query and merge-graphs
already use, and apply it in load_node_link_graph and the export loader.
to_cypher, to_canvas and push_to_neo4j/falkordb now read _src/_tgt as
to_html already does. The merge driver writes direction back into arc
order before saving, as to_json does, so the committed file keeps the
post-Graphify-Labs#563 convention.

global add has the same bug and is fixed separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 5a461c9)
The call walker only visited `command` nodes, so every method invocation
was dropped from the call graph. A method call parses as an
invokation_expression (callee in the member_name child, args in
argument_list); a bare property read ($this.Name) is a separate
member_access node and correctly produces no call.

Handle invokation_expression and resolve the member name against a
method-only label map so a member call binds to a method, never to a free
function that merely shares the name (fail-closed on unknown receivers).

Fixes Graphify-Labs#3992

(cherry picked from commit 1e6a902)
Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit 8a98287)
Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit 99159f3)
Pass dedup=False into graph construction so repeated labels do not collapse distinct non-AST identities. Preserve existing AST and document-file twin reconciliation. Fixes Graphify-Labs#4019.

Assisted-by: OpenAI Codex (GPT-6)
(cherry picked from commit 1f3805f)
…ible; BENCHMARK

Signed-off-by: Mr-Neutr0n <[email protected]>
(cherry picked from commit c7bbf6c)
The split-host runbook told the agent to skip to Part C when every doc,
paper and image hit the semantic cache. Part C reads
.graphify_semantic.json unconditionally and only the Step B3 merge writes
it, so a second run on an unchanged mixed corpus failed with
FileNotFoundError; writing an empty file instead dropped every cached node.

The all-cached case now skips B1/B2 but still runs B3. Step B0 also clears
.graphify_chunk_*.json before dispatch: B3 merges every chunk on disk, and a
leftover from an interrupted run would otherwise be merged as fresh.

The aider and devin monoliths keep the old sentence; they are pinned to the
v8 baseline by --monolith-roundtrip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit bab1bb2)
Co-Authored-By: Claude Opus 4.8 <[email protected]>
extract_dmf minted each element id from its window's node id, which
already embeds the file stem. The stem is absolute at extraction time and
extract()'s id remap only rewrites the leading copy, so the nested copy
kept the checkout path and the OS username inside every element id.

Use the window name instead. Element ids no longer depend on where the
repo is checked out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B8gwEpjajiWHVW3c9smuKf
(cherry picked from commit 3d9021f)
Keep operator scopes separate from their containing file and ordinary normalized identifiers, including nested bindings.

Co-Authored-By: OpenAI Codex <[email protected]>
(cherry picked from commit dc43c7c)
… raw reads

The always-on blocks now tell the assistant to pass the rule to every
subagent that explores code (a fresh subagent may never see a nudge before
it starts reading) and to read raw files only for lines the graph or an
earlier read already located, matching the hook's narrowed wording.
andrebrait added a commit to pfBlockerNG/graphify that referenced this pull request Oct 11, 2026
Squashed carry of pfBlockerNG/graphify feat/nudge-hints (093dc19), which merges v8 into L4XB:fix/cap-soft-hook-nudges.
andrebrait added a commit to andrebrait/integration-ci that referenced this pull request Oct 11, 2026
Hassannzidan and others added 21 commits October 11, 2026 20:47
…PHIFY_OUT is empty or "."

A set-but-empty GRAPHIFY_OUT (a blank .env / docker-compose / CI entry)
or GRAPHIFY_OUT=. made the purge target <project>/"" == the project
itself, and rmtree deleted the whole project.

- paths: treat a blank GRAPHIFY_OUT as unset; "." / ".." fall back to
  graphify-out with a warning. GRAPHIFY_OUT_NAME and out_path() follow.
- install: before any uninstaller runs, refuse --purge (exit 1, nothing
  changed) when the target is the project, a parent of it, the home
  folder or a filesystem root. This also covers an absolute GRAPHIFY_OUT.
- hooks: the rebuild bodies resolve the output dir via graphify.paths
  instead of reading the env var directly.

Fixes Graphify-Labs#4328

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7d6befb)
Some OpenAI-compatible gateways return a usage object whose token-count
fields are null. Reading them verbatim left None in result["input_tokens"] /
result["output_tokens"], which crashed extraction for the whole chunk
(TypeError: '<' not supported between 'NoneType' and 'int' in the ollama
low-token warning; None also propagated through the per-chunk merge).

Coerce null counts to 0 at read time in _call_openai_compat, _call_azure,
_call_claude, and _call_bedrock, matching the existing `or 0` idiom already
used on the claude-cli path.

Fixes Graphify-Labs#4325

Signed-off-by: Raphael Malikian <[email protected]>
(cherry picked from commit 640005f)
…hods; broadcast/pipe calls

- Unwrap `::RetType` (alongside `where`) around a definition's call head, so
  `function f(x)::Float64` is no longer dropped.
- Name method definitions via `_def_name`: `Base.show`, `Base.:+`, bare
  operators, and functors `(c::Circle)(x)`. The id uses the bare name so all
  methods of a generic function share one node; the label keeps the qualifier.
- Emit `calls` edges for broadcast calls (`f.(xs)`) and pipes (`x |> f`, `.|>`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit cf3648e)
_norm built the dedup key with re.sub(r"[\W_]+", " ", ...). \w does not
match Unicode combining marks (Mn/Mc: vowel signs, viramas), so they were
deleted like punctuation: "हिंदी" became "ह द", and "कि", "की", "के" all
collapsed to "क", merging three distinct nodes in Pass 1.

Treat a character as part of a word when it is alphanumeric or a combining
mark; everything else still collapses to a single space. Output is
unchanged for strings without combining marks (checked against the old
implementation on ~190k random strings).

Known gaps: ZWJ/ZWNJ still act as separators; ids.normalize_id and the
dormant build.deduplicate_by_label keep the old recipe.

(cherry picked from commit ccd81ce)
…e CWD (Graphify-Labs#4281)

Nodes are root-relative by dedup time, but _rank_path resolved them, which
prepends the CWD. From root/firmware, a node keyed as
firmware/firmware/lib/portal.html and its edge as firmware/lib/portal.html,
so the edge never followed the renamed node.

Resolve only absolute paths. _source_key is unchanged: at extraction time
relative paths are CWD-relative.

Co-authored-by: Gijs Mos <[email protected]>
(cherry picked from commit 22f87c2)
…ot (Graphify-Labs#4281)

Run from a subdirectory of the scan root, a root-relative node path is resolved
against the CWD, so the renamed node's key stops matching its edges' and the
edges stay on the survivor. Fails on v8; fixed in the next commit.

Co-authored-by: Gijs Mos <[email protected]>
(cherry picked from commit f369742)

# Conflicts:
#	tests/test_dedup.py
…names

explain and query exited 0 when no node matched, the same status as an
answer, and path exited 1 for an ambiguous endpoint, a missing one and a
missing graph file alike. A script or an agent could not tell a refusal
from an answer without parsing the text.

explain, path and query now exit 3 when a name is ambiguous (the
candidates are listed) and 4 when no node matches. Messages and output
streams are unchanged; "no path found" between two existing nodes is
still an answer. The codes are documented in --help and the README.

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 13dc240)
explain listed the 20 most connected neighbors and "... and N more" with
no option to see the rest, and the token-budget notices of query,
get_neighbors and get_community said "raise the token budget" without
the value that would return everything, so a caller retried with a guess.

explain gets --all, and its cut line names the total and the option.
The budget notices now give the smallest budget that returns the whole
output, computed with the same rule that does the cut.

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 769184d)
…abs#4066)

global add loaded graph.json with a plain undirected node_link_graph, so
every link whose target precedes its source in the node list was written
to ~/.graphify/global-graph.json reversed. Stamp _src/_tgt with
restore_arc_direction before the load, as the export loader and
load_node_link_graph do since Graphify-Labs#4088.

The external-node dedup rewired edge endpoints but not the markers, so a
deduplicated repo's markers named a node that no longer exists. Remap
_src/_tgt along with the endpoints.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 4778483)
…-Labs#2048)

`case class Point(x: Int) derives Show, Eq` (and the same on enums) now
emits a `references` edge with the `derives` context from the type to each
derived typeclass, next to the class-level context bounds it resembles. A
qualified name (`derives cats.Show`) links by its last segment.

Co-Authored-By: Grok Bot <[email protected]>
(cherry picked from commit e6ccd59)
Persist validated Codex extraction responses as chunk files so the shared B3 merge preserves semantic nodes and edges.

Fail before cache and graph updates when extraction responses are missing or invalid.

Add regression coverage for chunk merging, cached reruns, and failure handling.

Fixes Graphify-Labs#4311

Co-authored-by: OpenAI Codex <[email protected]>
(cherry picked from commit da5850f)
…cted

A committed graphify-out/graph.json is rewritten whole on every build, so
its pull-request diffs are large by design. Assistants reviewing such PRs
flagged them as churn and proposed skipping the rebuild or its hooks. The
Claude, AGENTS.md and Gemini blocks now say the diff is expected.

(cherry picked from commit e6cf17c)
Co-Authored-By: OpenAI Codex <[email protected]>
(cherry picked from commit cac64a0)
AI-Assistance: OpenAI Codex
(cherry picked from commit 4907979)
Give each binding of a use tree the import edge that v8 produces for
its equivalent plain use declaration. Preserve aliases, path comments,
separator whitespace, nested prefixes and self/glob binding behavior.

Keep the old group edge as call evidence until the call pass finishes;
exclude per-binding edges from that pass, then remove private markers.
Plain imports and all call edges retain their current-v8 behavior.
AST cache schema 6 -> 7 rejects results written before expansion.

Replace the earlier broad resolver in Graphify-Labs#4135 with this syntax-only fix.
The resolver is preserved on local branch wip/rust-use-resolver.

On current v8, all 30 new tests and the full 6642-test suite pass.
Fresh ripgrep builds have 864 import edges instead of 247, with every
call unchanged. Existing name-based import rewiring can still produce
wrong matches, just as it does for equivalent plain declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex <[email protected]>
(cherry picked from commit 2669ee4)
graph.json was pretty-printed (indent=2), so every PR that commits a
rebuilt graph reports tens of thousands of changed lines. GitHub's PR
line counts ignore .gitattributes (-diff, binary), so only the file's
content can fix it: one line of compact JSON is +1 -1.

Every writer of a project graph.json now emits separators=(",", ":")
with no indent: to_json, the `update` raw/no-cluster candidate text,
prune, merge-driver, merge-graphs, `extract --no-cluster` and the global
graph. Readers are unaffected.

`update` compares parsed data, not bytes, so an existing indented graph
would have been "unchanged" forever. It is now rewritten compact once,
then left alone.

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 4c31235)
Co-Authored-By: Claude Opus 4.8 <[email protected]>
# Conflicts:
#	tests/test_skillgen.py
#	tools/skillgen/gen.py
andrebrait added a commit to pfBlockerNG/graphify that referenced this pull request Oct 11, 2026
Squashed carry of pfBlockerNG/graphify feat/nudge-hints (7897b71), which merges v8 into L4XB:fix/cap-soft-hook-nudges.
@andrebrait

Copy link
Copy Markdown
Author

Closing: Graphify-Labs#3443's budget shipped in Graphify 0.9.87 without this change, so it's now proposed directly on v8 as Graphify-Labs#4368. Thanks again for taking the earlier follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.