Skip to content

feat: add codegraph walk (M21) - #50

Merged
jgrodziski merged 5 commits into
mainfrom
feat/walk-generalized
Nov 23, 2026
Merged

jgrodziski merged 5 commits into
mainfrom
feat/walk-generalized

Conversation

@jgrodziski

Copy link
Copy Markdown
Contributor

What this does

codegraph explain asked one fixed question of every unit. This adds codegraph walk: the same bottom-up walk (operations → types → modules, each prompt shown what was already answered about its dependencies), with your question, of the units you select, into its own store. explain becomes the built-in walk, and takes the same selection flags and instructions.

codegraph walk model.jsonl --src DIR --prompt "Which of these is audited, and what does the audit record?" \
  --include 'edge:annotationUse>name:Audited' --closure dependencies --dry-run
codegraph walk --print-definition > audit.json      # a codegraph.walk/1 file: task per level, instructions, answer fields
codegraph walk model.jsonl --src DIR --walk audit.json --provider claude-code
codegraph insights model.jsonl --walk audit --id ID
codegraph explain model.jsonl --src DIR --exclude 'file:**/generated/**' --instructions @context.md

Plan and decisions: PLAN.md §22 (Phase 19, M21a–M21d), with an "As built" note per step.

The commits

Commit What
feat(analyzer): add entity selectors The selector grammar (id:, kind:, trait:, lang:, name:, module:, file:, edge:, edge-in: as flag terms; the same plus all / any / not as JSON), pure computation over the graph, with a property suite.
feat(insights,cli): add codegraph walk The engine asks through one seam, WalkSpec; explain is the built-in spec, a codegraph.walk/1 definition is another. A selection picks the units asked, never the units walked. One store per walk (<model>.N.walk.db / .walk.jsonl, header codegraph.walkRecords/1), refused to any other walk. The walk command, explain's new flags, insights --walk N.
feat(navigator-ui): show a walk's answers The Navigate panel shows a walk's answer (badge, walk name, model, confidence, every declared field by name) when serve --insights points at a walk's store.
docs: document walk and walk definitions docs/insights.md, docs/cli.md, README, CLAUDE.md, four new site pages and the pages they touch; a test runs every definition the docs print.
docs(plan): add M21, the generalized walk PLAN.md §22 and the two cross-references it renumbers.

Insights and the CLI are one commit: main's CLI does not typecheck against the new insights package alone, so splitting them would leave a commit that does not build.

What must not change, and how it was checked

  • Explain is byte-identical. A golden suite (packages/cli/test/golden/explain, 37 files) pins explain's plan, estimate, prompts and JSON output from before the seam; it passes unchanged.
  • A paid store still plans the same. On a copy of a real, paid PetClinic explain store, explain --dry-run --json is byte-identical before and after, and the store file's sha256 is unchanged.
  • The insights store is still not a cache. decode → import → export of a walk's side-car is the identity (tested property); a walk's store is refused to explain and to any other walk, bytes untouched.

Verification

Run on the tree these commits hold, before committing:

  • pnpm -r build, pnpm run typecheck, eslint: clean
  • @codegraph/insights: 467 passed, 1 skipped · @codegraph/cli: 1238 passed (56 files) · @codegraph/navigator-ui: 124 passed
  • site: hugo --minify --gc, 206 pages, no warning

Not re-run after committing, and CI has not run on this branch yet.

One live run

One paid walk on a copy of Spring PetClinic (sonnet through Claude Code, controllers and their dependencies): 139 units, 83 calls, 0 failed, 127 s, 200 779 prompt + 43 814 completion tokens, $0.94. A second run planned 0 calls.

The output estimate was a flat guess of 500 tokens per block; it is now the means of that run: 500 per operation block, 620 per type block. Module takes the type's figure.

Against the bill, the estimate was 12.4 % above on input (operations 21.6 % above, types 7.0 % below) and, with the old flat 500, 5.3 % below on output (types 19.3 % below).

Known limits

  • The output figures rest on one run: one corpus, one model, one question, no declared answer field. Modules and declared fields are unmeasured, and the figures are in-sample for that run.
  • The input estimate's per-level error (operations over, types under) is reported, not investigated.
  • The trivial-member rule skips by name, so it skipped setAllowedFields, an @InitBinder method. "trivial": "ask" in the definition asks them all.
  • WEBSITE.md §4 does not list the four new site pages yet.
  • Two tests outside this change are flaky under load: e2e-exit-codes.test.ts (near vitest's 60 s worker timeout) and one import.test.ts case when a temp directory name contains MB.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PKCVgyRgXptvGiT9iooEcs

jgrodziski and others added 5 commits November 22, 2026 17:19
Which entities a filter names, in core's vocabulary (PLAN §22.3, M21b):
one AST with a text surface (id:, kind:, trait:, lang:, name:GLOB,
module:GLOB, file:GLOB, edge:KIND[>TERM], edge-in:KIND[<TERM]) and a
JSON surface (all / any / not). A selector is compiled against a view,
so edges are read through it; an unknown kind or trait is a usage
error. Hand-counted on the Java fixture and held by properties.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyRgXptvGiT9iooEcs
The bottom-up walk asks its question through one seam (WalkSpec);
explain is the built-in spec and its default output is pinned byte for
byte by a golden suite on the five fixtures (PLAN §22, M21).

insights:
- a codegraph.walk/1 definition is data: a task per level,
  instructions, entity instructions, a closed field grammar compiled
  to Zod; its fingerprint hashes what the definition says
- a selection (analyzer selectors, nearest-container rule, exclude
  wins, closure, trivial members) picks the units asked, never the
  units walked
- one store per walk, <model>.N.walk.db and its .walk.jsonl export
  (codegraph.walkRecords/1), refused to another walk or another answer
  shape with its bytes untouched; no migration of explain's store
- a read-only reader for a walk's store

cli:
- walk: --prompt, --prompt-file, --instructions, --walk FILE, --name,
  --include/--exclude/--levels/--closure, --print-definition, and
  every run flag of explain, through one shared runner
- explain takes the selection flags, --instructions and --walk FILE;
  --scope is --include id:; its task, blocks and store are unchanged
- insights --walk N and serve --insights read a walk's store
- a walk's output estimate uses per-level figures measured on a live
  PetClinic run (operation 500, type 620; module takes the type's)

The two packages change together: the CLI does not compile against
the seam without its own half.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyRgXptvGiT9iooEcs
When serve --insights points at a walk's store, the Navigate panel
shows the answer as an inference: the badge "LLM answer", the walk's
name, the model and its claimed confidence, then the answer, each
declared field by its name, and the description (PLAN §22.5).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyRgXptvGiT9iooEcs
docs/insights.md (IN-9), docs/cli.md, README and CLAUDE.md; on the
site a how-to, three reference pages (walk, insights, the walk
definition and its selectors) and the pages that named explain alone.
The cost passages state the PetClinic run the output figures come
from and the estimate's error on it.

A test parses every codegraph.walk/1 block and every --include and
--exclude term of the docs through the real parsers, so an example
cannot rot.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyRgXptvGiT9iooEcs
§22: the seam, the definition, selection, one store per walk, the CLI,
the eight steps with their verification and the as-built notes,
including the live PetClinic walk (83 calls, 0 failed, $0.94) and the
measured output figures. Milestones and decisions move to §23 and
§24; the two references outside the plan follow.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyRgXptvGiT9iooEcs
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
codegraph 93d5c7c Commit Preview URL

Branch Preview URL
Nov 23 2026, 07:35 AM

@jgrodziski
jgrodziski merged commit 8ae2417 into main Nov 23, 2026
52 checks passed
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.

1 participant