graph/walk: gather context by walking the graph with a decision model - #10
Open
Evanfeenstra wants to merge 12 commits into
Open
Evanfeenstra wants to merge 12 commits into
Evanfeenstra wants to merge 12 commits into
Conversation
…KEY) or a wrapped LLM - evaluate.ts: modelEvaluate = one experimental_evaluate call; the hand-rolled generateObject backend is gone - llm.ts: resolveEvaluationModel — jev/typesafe/<id> via @ai-sdk/typesafe-ai, default to jev when the key is set, else STRUT_LLM_* wrapped in the SDK's EvaluationLanguageModel - bump ai 7.0.106 / @ai-sdk/anthropic 4.0.57 so provider-utils dedupes - docs: plan, AGENTS.md, step example
Evanfeenstra
force-pushed
the
worktree-graph-walk
branch
from
September 18, 2026 16:21
b8198e1 to
7cc991c
Compare
…from reads jarvis-style reads hide nodes whose `status` is a processing state (incl. `error`), so every failed run was invisible to search, neighbors and graph/walk. One-shot boot migration moves existing data, the StrutRun schema node and the fulltext index; idempotent, ledger-stamped.
…eshold 0.7 - Evidence is labelled by its EVIDENCED_BY verdict + result (claim in the snippet); arriving edge attributes are shown to the decider - Evidence repeating a seen verdict + claim folds into the first (merged, similar_results) instead of being judged again, this hop or later - relevance says no to what only repeats the gathered context - threshold default 0.5 -> 0.7, sufficient stop at 0.8
…lause - A retired Check (retired_at) or superseded Claim (belief_valid_to) is never offered (explicit start excepted): their stale TESTS/ABOUT edges and SUPERSEDES chains cost a judgment each and a hop per version - The "no if it only repeats what's gathered" relevance clause made jev reject the Claims (every Evidence snippet carries the claim text); merging already does the de-duplication
A guard against walks that stall while jev's `sufficient` hovers below 0.8. Tuned on the youtube-clip walks, which still found claims at hops 7-11: a 2-hop window or a 0.9 bar would have cut 3-4 of 5 claims, so at this setting it does not fire there. walk-chat-demo §1 marked done.
The graph/walk step as a chat tool (src/ai/walk-tool.ts): an async-generator
execute bridges runWalk's per-hop emit to preliminary results, which the chat
logs as `tool-progress` events; toModelOutput hands the model only
{ goal, stopped, decider, nodes }. GET /chat/:id/progress/:toolCallId serves a
finished call's hop events for chats loaded from history.
In the flyout, WalkView folds the hop events (walk-graph.ts) into a d3-force
graph ported from hive (WalkGraph.tsx) — one simulation for the component's
life, nodes kept by id — played back at 400 ms a hop, with a decider pill,
replay, node details and "open run" for kept StrutRun nodes.
# Conflicts: # AGENTS.md # package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A
graph/walklib step that gathers context for a goal by walking the knowledge graph. At each hop a decision model judges the options; there's no generative agent loop.The walk is code. It seeds from
startref_ids or aquerysearch. Each hop fetches one node's neighbors (thegraph/graph-neighborscall: importance-sorted, capped at 50, same excluded types) and makes ONE decider call asking three independent questions:relevant_c<i>(boolean): one per new neighbor.next(choice): this hop's candidates, the frontier's best, ornone.sufficient(boolean).Kept nodes are ordered by relevance. The walk stops on
sufficient,maxNodes,none,maxHops, or an empty frontier.Output is a context bundle for an
llm/agentstep:{ goal, nodes: [{ref_id, node_type, name, relevance, hop, via, properties}], hops, stopped, usage }, provenance-marked with the expanded and kept nodes. Every hop emits a nested run event (<path>/NNN-hop), so a walk shows up in the events panel like an agent's tool calls.The decider is
experimental_evaluate(ai@7).src/evaluate.tsexposesmodelEvaluate(model), one evaluate call behind an injectableEvaluatetype, so tests script it.resolveEvaluationModel(insrc/llm.ts) picks the model:model: jev(orjev-<ver>/typesafe/<id>): TypeSafe's evaluation model via@ai-sdk/typesafe-ai, keyed byTYPESAFE_AI_API_KEYfrom the secret store, then env. It's non-generative, runs in 70–500 ms, bills $0.042/MTok for input with output free, and returns calibrated probabilities.next_probabilitiesis filled in from its choice probabilities.STRUT_LLM_MODEL/STRUT_LLM_PROVIDER.llmstep, then wrapped in the SDK'sEvaluationLanguageModel(the same wrapper asanthropic.evaluationModel), so every aieo provider works as a fallback.Dependencies: adds
@ai-sdk/typesafe-aiand@ai-sdk/provider-utils, and bumpsaito 7.0.106 and@ai-sdk/anthropicto 4.0.57 so provider-utils dedupes.deriveNodeNamemoves from three graph steps into_shared.ts, since the walker is a fourth user.plans/graph-walk.mdrecords the design.Verification
tsc --noEmitis clean.npm test: 832 pass. New tests:src/evaluate.test.tsruns the realexperimental_evaluateover a fake jev-shaped evaluation model and over a wrapped fake language model, and covers the resolver's routing.src/steps/lib/graph/walk.test.tswalks an in-memory graph with a scripted decider.test:graphincludes a live case that walks a seeded Neo4j graph through the real reader with a scripted decider.experimental_evaluatecall through the fallback path (haiku) returned sensible relevance and next choices in about 1.4 s.Not in this PR
TYPESAFE_AI_API_KEYin the build env), and no full walk has run against a real model. The three question instructions will want tuning on a first real walk.Example: