Skip to content

graph: draw the existing graph, and every rebuild keeps the languages the index chose (#1480) - #1642

Merged
swapnilpaliwal-sd merged 1 commit into
0.1.5from
fix/graph-verb-reuses-index-flags
Sep 28, 2026
Merged

swapnilpaliwal-sd merged 1 commit into
0.1.5from
fix/graph-verb-reuses-index-flags

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

Refs #1480. A broken graph is repaired on the path that issue describes (ax_contract.ensure_graph). After this change the repair keeps the index's languages. It does not fix that issue's silent wait.

What was wrong

  • axiomcode graph and the MCP axiomcode_graph tool always ran axiomcode-graph build. That ran axiomcode-build with no flags, so it detected every language in the tree.
  • On a repository indexed with --lang python (or with --src / --library), that request never matched the recorded graph. So every call rebuilt the whole graph, in every language present.
    • A few stray .js or .ts files were enough to start a JavaScript or TypeScript Souffle compile.
    • The rebuild left a graph behind for each extra language. Later queries answered from it: on a C# project, a stray TypeScript graph took over context answers.
  • The output was hard for an agent to use:
    • a raw Python dict of counts
    • a ../../../ page path, relative to the caller's working directory
    • advice to run axiomcode-graph build . --library, a command agents do not have
  • axiomcode help graph documented axiomcode-graph build/export. The dispatcher help said the verb was "current by construction".
  • The page drew only the main language's graph, even when the repository had been indexed in several languages.
  • The damage outlived the call. A build with no language recorded the languages it detected as the index's own choice (lang_auto: true in the file table). After one graph, every background refresh re-detected them too: on a C# project indexed with --lang csharp, an edit plus a commit then solved csharp, typescript and javascript. Other paths reached axiomcode-build with no language in the same way: a bare index re-run "to make sure", and a query repairing a broken graph pointer (ax_contract.ensure_graph).

The change

  • axiomcode graph now reads the file table the index recorded: its languages, --src and --library.
    • Graph up to date (no source file differs): the page is drawn from the existing graph. The engine does not run.
    • Graph out of date: it is rebuilt with the flags it was indexed with, before the page is drawn. The environment comes from the same code the background refresh uses (ax_fresh.rebuild_env, moved out of worker), so the two cannot drift. Only the languages the index chose are solved, and no graph appears for a language it left out.
    • No graph yet, or flags passed explicitly: the verb indexes first, as before.
  • One rule for every rebuild, in axiomcode-build. When a build names no language and the graph there was indexed with an explicit --lang (lang_auto: false), the build keeps that --lang, and its --src unless one is given. ax_fresh.py chosen reads them from the file table. This covers the refresh, --fresh, a broken-graph repair, a bare index and graph. A bare index prints that it kept them, and --lang or AXIOMCODE_REINDEX=1 chooses again. A graph whose languages were detected is still detected again, so a language added later still gets its graph.
  • A repository indexed in several languages is drawn in all of them, on one page. The page reads .axiomcode/lang/<lang> beside the main graph. Their ids carry the language, so none collide.
  • The output is now prose:
    • how the graph was obtained (up to date, rebuilt and with which flags, or first index)
    • the counts
    • the axiomcode index … --library advice, when it applies
    • the page's absolute path, last
  • These now describe the same behaviour: the axiomcode help graph docstring, axiomcode help index, the dispatcher help, SKILL.md (and its copy), the MCP axiomcode_graph description, and the README row. build and export are still accepted as older spellings.

Tests

tests/graph_verb.py has 21 checks, all passing locally. It builds real graphs.

  • Indexed repository: Python under app/ with a stray .js file, indexed with --lang python --src app.
    • Current graph: graph leaves the graph file untouched (same file, same mtime), writes no .axiomcode/lang and prints prose with the absolute page path. The page holds nothing from outside --lang or --src.
    • After an edit: the graph is rebuilt with --lang python --src app, the page shows the new function, and no JavaScript graph appears.
  • Near-miss control: a Java and Python repository indexed with no --lang. graph draws both languages on one page, keeps both graphs and rebuilds neither. Its detected languages are not pinned (chosen prints nothing), so a rebuild still detects them.
  • Every rebuild path: C# with a stray TypeScript front end, indexed with --lang csharp. Each of these solves C# alone, with no TypeScript graph and a csharp stamp:
    • an edit plus a commit, then the background refresh
    • a bare index (which says it kept --lang csharp)
    • a query that repairs a broken graph pointer
  • Surfaces: axiomcode help graph and the MCP description say the same.

Other suites run locally:

  • tests/refresh.py passes for --lang csharp and --lang java, and for --lang python on its first run. Moving the refresher's rebuild environment into rebuild_env did not change its behaviour. A second Python run failed one timing check: it expects the rebuild reason "found by the timer", but under load the MCP server's own start-up kick saw the edit first. The rebuild itself ran.
  • tests/surfaces.py, tests/manifests.py and packaging/copies.py --check pass.

Smoke

One project per language, each indexed fresh with --lang on 9d626cc. graph was then run with the installed build ("before") and with this branch ("after"). JavaScript and TypeScript compiles were capped at 150 s locally, so each "before" run that started one was stopped there.

project before: time, languages solved, stray graph left after, graph current after one source edit
Python, 653 files 167 s (stopped): python + javascript 1 s, no engine run, no stray graph python only: 86 s, no stray graph
Java, 116 files 2 s, up to date (one language); dict output and relative path 1 s, prose, absolute path java only: 9 s
C#, 110 files plus a small front end 166 s (stopped): csharp + typescript + javascript, left a stray lang/typescript graph 1 s, no engine run, no stray graph csharp only: 10 s, no stray graph

Commit on the C# project: an edit plus a commit, then the background refresh.

  • Before: on the project the old graph had run on, the refresh solved csharp + typescript + javascript (JavaScript was stopped).
  • After, with this branch: csharp only, 6 s, no stray graph.

The file table after graph:

  • Before: csharp,typescript,javascript, lang_auto: true (Python project: python,javascript).
  • After: csharp, lang_auto: false.

A table already rewritten by the old graph still reads as detected, and is not repaired by this change. Re-indexing with --lang fixes it.

Not yet measured on the full corpus or on held-out projects; the smoke numbers above are the only corpus numbers.

… the index chose

`axiomcode graph` ran axiomcode-build with no flags, which detects every
language in the tree. On a repository indexed with --lang it rebuilt the
whole graph on every call, started JavaScript/TypeScript compiles for
stray files, left a graph for each, and recorded the detected languages
as the index's choice, so every later refresh solved them too.

- graph draws from graph.sqlite when the file table says it is current,
  and otherwise rebuilds with the recorded --lang/--src/--library
  (ax_fresh.rebuild_env, shared with the background refresh)
- axiomcode-build: a build that names no language keeps an explicit
  --lang (and --src) recorded in the file table (ax_fresh.py chosen), so
  the refresh, a broken-graph repair, a bare index and graph never solve a
  language the index left out; detected languages are still detected again
- the page draws every language graph the repository has
- prose counts, the page's absolute path, and `axiomcode index --library`
  as the advice; help, SKILL.md, the MCP description and README agree
- tests/graph_verb.py: 21 checks with a detected-languages control
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit 9ee9d59 into 0.1.5 Sep 28, 2026
12 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the fix/graph-verb-reuses-index-flags branch September 28, 2026 15:33
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