2 Commits
Author SHA1 Message Date
Martin Vogel d5ff422922 perf(extract): linear flat labels, usage climbs, spawn checks and Go route bindings
Four extraction sites did work that grew with the square of the file.

Flat labels: NASM instructions and ObjectScript routine statements each
walked back over every earlier sibling for the label above them. A search
now stops at the sibling the previous search under the same parent started
from and takes what that search found, with one memo per ancestor level
for NASM's climb. Which label a statement gets is unchanged.

Usage classifiers: each identifier's binding, write and argument-label
classifiers climbed towards the root, so nesting d levels deep cost d per
identifier. A climb that reaches the root undecided now records the path
it settled, and the next climb stops where it meets it.

Spawn checks: every call's spawn check read all of its file's import
rows, on both call resolvers. The rows are indexed on the first question
between cbm_spawn_file_begin and cbm_spawn_file_end around each file's
call loop. Other rows, an over-long name or a failed allocation read the
rows as before, with the same answer.

Go route bindings: for every route call the receiver's binding was found
by walking back over all earlier statements in the block. A block's
bindings are now read once, sorted by name and source order in the file's
scratch arena; each question is a binary search for the last binding
before the asking statement.

Growth tests, counted work when the input doubles, before and after:
complexity_flat_preceding_label_is_linear 4.00x to 2.00x;
complexity_usage_classifiers_on_deep_nesting_are_linear 3.99x to 2.00x;
complexity_spawn_match_is_linear_in_a_files_imports 4.00x to 2.00x, with
complexity_spawn_file_index_answers_as_the_rows_do comparing both routes
across nine languages; complexity_go_route_bindings_are_near_linear 4.00x
to 2.00x (2.18x for group bindings), with
handles_go_group_binding_forms_*_issue686 pinning the binding forms on
both pipelines. No graph content changes: gitea, helm, flask, nest,
tokio, nccl and jellyfin index identically before and after. Each
remaining sibling or parent step still walks the parent's children
inside tree-sitter; that needs a syntax index.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-14 00:47:41 +01:00
Martin Vogel 42a9320200 graph: one identity per conditional definition, SPAWNS edges, no cross-language guesses
The test-impact engine selects tests by walking the graph, so it can only
be as right as the graph. Three gaps made it wrong:

One identity for a definition's mutually exclusive variants
- A definition written once per #if/#else branch, per #[cfg], per
  platform file (foo_linux.c / foo_win.c, platform directories) or per Go
  build tag is ONE node. The graph buffer keeps every variant's span in a
  `variants` node property (definition labels only), so a change in any
  variant maps to the definition.
- Extraction now sees definitions inside conditional blocks where it
  skipped them: C++/C#/ObjC class members under #if (one cursor walk,
  conditional block types per language in lang_specs), Elixir defs under
  if/unless, Fortran .F90/.F95/.F03/.F08, Rust #[cfg] twins (no more
  `name#cfg(...)` QNs that lost every call), C platform files and
  directories (non-static file-scope functions).
- Haskell: the vendored scanner reads only an #if group's first branch.
  The grammar stays upstream; every further branch is parsed as its own
  same-length view (cpp_branch_views.c) and adds what the raw parse
  missed. haskell/bytestring: no new partial parses, +27 functions,
  IMPORTS 322 -> 329, 131 definitions with variant spans.
- Incremental closure repair re-parses every file of such a definition
  when one of them changes (variant partners through DEFINES), so a
  repair equals a full index.

No cross-language name guesses
- A name-only resolution (unique_name, suffix_match, qualified_suffix,
  field_type_hint, and same_module across files that only share a path
  stem) never binds a symbol another language defines.
- Bash imports are the files a script sources: every top-level command
  was read as an import of its name (`set -e` imported "set", bound to a
  TSX method in 137 scripts here).
- This repository: cross-language CALLS 5,916 -> 5,091; the remainder are
  C/C++ pairs, builtins and same-stem module collisions (recorded).

SPAWNS edges (per language, like the HTTP client patterns)
- A call that starts a program (subprocess.run, exec.Command,
  child_process.spawn, posix_spawn, system, Process.Start, Command::new,
  ... about 30 languages, through the file's own imports) gets a SPAWNS
  edge to a Process node named after the program (literal first word, or
  <dynamic>) instead of a CALLS guess. No target resolution. Both
  resolvers ask at the same point (parity test).

The engine follows the graph
- Seeds map changed lines through every variant span; a test written
  once per #if branch is one test; when a change reaches a non-test
  `main`, the tests that spawn processes are reached too (the process
  runs main, and main reaches everything).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-06 02:44:56 +02:00