Skip to content

Latest commit

 

History

History
121 lines (92 loc) · 6.39 KB

README.md

File metadata and controls

121 lines (92 loc) · 6.39 KB

The regression gate

One command that answers: did this change make indexing slower, change the graph, or make codegraph_explore answer worse?

npm run build:kernel && npm run build
npm run gate

It takes six to eight minutes and calls no model. It exits 1 on a regression and prints which project and which check.

Nothing runs it for you. It is run by hand, by the maintainer or by an agent working on the engine:

  • before you open a pull request that touches extraction, resolution, the synthesizers or codegraph_explore;
  • before merging someone else's pull request: check the branch out and run it there (gh pr checkout <number>, build, npm run gate);
  • before every release, with --against the last release (below).

Why it exists

The test suite says what the engine should do in the cases someone wrote down. Twice in November 2026 a change passed all of it and shipped a regression:

  • 1.6.4 hung on minified bundles (#3501). A fix to which event reaches which listener (#3362) was measured for accuracy on six real projects and for speed on two, all of them hand-written code. On a script minified to one line it took 37 seconds for a 0.4 MB file and six minutes for a 0.7 MB one. The large-file work in 1.6.5 did not reach it either: its benchmark had no one-line script with listeners in it.
  • An answer sized to the symbols a query names lost them (#3514, caught before release). 173 of 1,033 questions lost a definition the release showed, and 92 came back as "No relevant code found", in 36 of 72 README rows.

Both were found by running real input through two builds and comparing. Nothing did that unless someone thought to choose the right input. This is the same set of inputs every time, chosen by nobody who wrote the change.

What it checks

It indexes a fixed set of projects with the build, each in a process of its own:

  • a small generated project for every language, framework, router and bridge the README lists (the generators in scripts/benchmarks/large-files/);
  • the engine's own source at a release tag, as a real codebase;
  • real files that reports named, fetched from the npm registry and checked by checksum.

and compares what it gets with expected.json, the results of the last build that was accepted.

Check Fails when It caught
GRAPH The nodes, edges or unresolved references of a project are not exactly what is kept (a hash of scripts/dump-graph.mjs). Any change to what is indexed or linked that nobody declared.
SPEED A project takes longer than its budget (five times what it took when its results were kept, never under 5 seconds). With --against <dist>: a third longer than that build on the same machine. The minified bundle: 1.2 seconds kept, 37 measured.
GROWTH A generated file four times the size takes more than eight times as long, past 3 seconds. Work that grows with the square of a file, in a pass no real file here reaches.
ANSWERS codegraph_explore no longer shows a definition it showed for a kept question, answers one with nothing, or an answer grows by more than a quarter. The 173 lost definitions and the 92 empty answers.
SETUP A project could not be fetched or built, or has nothing kept. A check that did not run is not a check that passed.

When it fails

GRAPH. Your change altered what the engine indexes or links in those projects.

  • You meant to (a fix to resolution, a new kind of edge): look at what changed before you accept it. node scripts/benchmarks/large-files/compare-graphs.mjs <dist of main> dist <project> prints the lines only one build has. Then npm run gate -- --update, commit expected.json, and say in the pull request which projects changed and why. The file has one project a line, so the reviewer sees them.
  • You did not (a speed fix, a refactor, a change somewhere else): that is the regression. A change meant to make something faster changes no graph.

SPEED. Run it again with nothing else running. Still over: profile it (docs/design/large-file-performance.md, "Finding the cause"). To compare with another build on your machine, which is tighter than a budget: npm run gate -- --against ../baseline/dist.

GROWTH. Something in the pass does work for each symbol, reference or match that reads the whole file. docs/design/large-file-performance.md lists the shapes.

ANSWERS. For the whole picture across two builds, run the sweep in scripts/benchmarks/explore-answers/. A gain (more of what a question names is shown) is printed as a note: --update keeps it, so that losing it again fails.

Do not update expected.json to make a failure go away. Update it when the new result is the one you want and you can say why.

Adding to it

  • Every report of slow or wrong indexing that names a public file adds that file to REAL_FILES in gate.mjs, with its checksum, in the pull request that fixes it. A generated file has the shapes someone thought of; a reported one has the shape nobody did. #3501 named its file and its checksum, and it is the first entry.
  • A new language, framework or bridge gets a case in other-languages.mjs (already the rule), and with that a project here.
  • Then npm run gate -- --update.

Before a release

An ordinary run compares with what was kept. Before a release, also compare with the last release itself, on one machine:

git worktree add --detach ../baseline v1.6.5
(cd ../baseline && npm ci && npm run build:kernel && npm run build)
npm run gate -- --against ../baseline/dist      # speed, to a third
# and the explore-answer sweep: scripts/benchmarks/explore-answers/README.md

A project the last release cannot index in time is printed as a note and the run goes on: there is no time of its to compare with. 1.6.5 is that build on the bundle of #3501, which it does not finish and the build after it indexes in six seconds.

What it does not check

  • That the graph is right. It checks that it did not change unseen; npm test holds what is right.
  • Whether an agent does better with the answers. That is the agent comparison in docs/AGENTS.md, which runs a model.
  • Windows. What is kept was recorded on macOS and is the same in a Linux container; Windows has not been run, and npm test is where a platform difference shows.
  • Times on your machine against times on another. Budgets are wide on purpose; --against is the precise comparison.