cd318253e made the package map independent of worker scheduling by
sorting every candidate of a package name by depth and path before the
first-wins insertion. That also reordered the candidates of ONE manifest:
a pyproject.toml pushes src/<name> first and <name> second, the first had
always won, and after the sort the shallower second one did, for every
Python package. Imports that used to bind their own package then fell to
the same-name fallback: in flask, `from flaskr import create_app` in
examples/tutorial bound the celery example's create_app.
The dispatcher now stamps each entry with the manifest that yielded it and
its position among that manifest's entries, and the merge orders by package
name, the manifest's depth and path, and that position. Different manifests
are still ordered by the repository, not by the run; one manifest's entries
keep the order its parser chose.
ei_pkgmap_one_manifest_keeps_its_candidate_order hands a pyproject.toml and
a sibling's to the merge in both worker orders;
ei_python_example_project_import_binds_its_own_package indexes the flask
shape and checks the import's target file. Both fail without this change.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
A project-name miss runs two cache scans: the internal-name fallback,
which this branch already polls, and the project listing in the
not-found error, which opens every database again until its 4 KiB name
buffer is full. A hook from a directory with no index runs that listing
once per ancestor it probes, so an abandoned request kept opening
databases after the fallback had stopped (#2796).
collect_db_project_names now polls project_scan_should_stop before each
database like the other cache scans, and build_project_list_error takes
the request's server (NULL in verify_project_indexed, which has none in
scope). A cancelled listing answers with the bare reason instead of a
partial list. The name-miss regression test now counts both scans and
asserts that the cancelled reply carries no listing.
Refs #2796
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The per-language passes scanned the whole type registry per definition
and all of a file's imports per use, and Python copied its import arrays
on every add, so a file's pass grew with the square of its definitions or
imports. Rows are now found by name (lsp_name_rows.h) or through an
opt-in tail index on the registry, and every site falls back to the scan
it replaces when an allocation fails. No cap, budget or early exit is
added, and no lookup may miss what the scan found:
complexity_name_rows_answer_as_a_scan_does and
complexity_registry_tail_answers_as_a_scan_does compare both routes.
Counted work when the input doubles, before and after, per growth test
(all named complexity_*_is_linear or *_are_linear, counted through the
existing lsp_work.h steps):
Python import join 4.00x to 2.13x, wide from-import 4.00x to 1.95x
Go import uses, registration, generic registration 4.00x to 2.00x
Java import uses 3.25x, static imports 3.22x, class registration
3.65x, short-name fallback 3.76x; now 1.55x to 2.00x
Kotlin import uses 3.48x to 2.04x, class registration 3.85x to 2.23x
TypeScript import uses 3.98x to 1.80x, class registration 3.78x to
1.86x, JavaScript registry lookups 3.79x to 1.84x
Rust import uses 3.99x to 1.79x, registration 3.16x to 1.84x,
derive registration 3.46x to 1.81x
C# registration 3.34x to 1.46x
PHP import uses 3.58x, short-name fallback 3.68x, method returns
3.68x; now 2.00x
The two PHP method-return loops start at the lowest row of the existing
method iterator. TypeScript's registry is indexed once the file's
definitions are in, keeping first-registered answers.
No graph content changes: flask, django, helm, gitea, two Java subtrees
of elasticsearch, Exposed, nest, tokio, jellyfin and composer index
identically before and after on one worker. phpunit has no comparison:
it does not finish within 1,700 s on one worker with either binary.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
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>
Two extraction defects that lost or misattributed graph content.
C#: operator_declaration was no function kind, so `operator+` had no node
and every call in its body was attributed to the file: the constructor
call inside `operator+` produced `Vec(Module) CALLS Vec2`. The operator is
now a Method named by its token, spelled like C++'s `operator+` and
`operator true`, through the shared name resolver the def side and the
call scope both use. Overloads merge into one node. The matrix case
mkc_c2_csharp_operator_plus counted CALLS >= 2 and passed only through
that misattributed edge; it is now a green guard asserting the Method node
and the operator's own CALLS edge, and mkc_c2_csharp_operator_overloads
pins overloads, `operator -` and `operator true`. The `a + b` operator
site is still no CALLS edge.
C: the assignment node set held only assignment_expression, so `x++`,
`--x` and `c->n++` left no WRITES edge although the write resolver already
handles update_expression. The C set now includes it (GLSL shares the
set). pipeline_c_increment_writes pins WRITES for postfix and prefix forms
on a file-level variable and a struct member, next to a plain-assignment
control.
The C++ set is left alone on purpose: a bare C++ name can be an
implicit-this member, so a local counter's `i++` binds by name to an
unrelated member. On leveldb at least 29 of the 74 edges this would add
are such false bindings; on redis the C change adds 647 edges with at
least 18 of them false, below the rate of the existing assignment rule.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
path_alias.c had 40 raw allocator sites outside the memory core. Every
allocation and its free now go through cbm_alloc/cbm_free in one class,
and the two cbm_strndup copies the file freed itself come from a
core-backed helper. cbm_path_alias_resolve keeps strdup, because
pass_pkgmap.c and the tests free its result with free(); the baseline
drops from 40 to 1. No behaviour changes.
The nearest-ancestor test built its collection with calloc/strdup and
freed it through cbm_path_alias_collection_free; it now frees what it
built with the allocator it used.
Checked under the production allocator, where a block freed by the wrong
side crashes: nest (34 tsconfig files with paths) and immich index
identically to before, and a synthetic project with an extending nested
tsconfig stays identical through full, fallback and incremental reindex
steps.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The in-process updater refuses a tar.gz that inflates past 500 MiB, but no
test reached that refusal, and the limit had no seam. A test-only setter,
in the block that already holds the extractor under
CBM_CLI_ENABLE_TEST_API, lowers the limit, so
cli_update_refuses_an_archive_over_the_decompression_limit sees a 1 MiB
archive refused over a 64 KiB limit and accepted under the real one. With
the check removed the test fails on its refusal assertion.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Three sites did work per definition that grew with the file.
The struct field fold scanned all of a file's definitions for every
struct; it now chains each owner's fields once (lookup probes 4.00x to
2.00x when the file doubles).
Every top-level C# class walked the compilation unit's children by index
to find a file-scoped namespace, and each index call steps over the
children before it; the namespace is now found once per file with a
cursor (sibling steps 7.99x to 2.00x).
The doc memo never refreshed an entry found as an ancestor, so a wide
root was evicted by its children's narrow lists and listed again every
few definitions; use now keeps it cached (3.99x to 2.00x).
The growth tests complexity_struct_field_fold_is_linear,
complexity_csharp_namespace_lookup_is_linear and
complexity_doc_lookup_keeps_a_wide_root_cached count work through new
seam-only counters (resolve_stats.h), never time; product builds compile
the counters out. No graph content changes: flask, helm, nccl and
jellyfin index identically before and after.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Brings in #2974 (incl. the jsonnet scanner patch) and #2970. One conflict:
scripts/vendored-checksums.txt, where #2974 and the vba vendoring both
rewrite the MANIFEST.md line. Resolved by taking main's file and
regenerating it with scripts/security-vendored.sh --update; against main it
differs only in the MANIFEST.md line and the five vba lines, and the
integrity verify passes.
THIRD_PARTY.md, MANIFEST.md and tests/test_parse_coverage.c merged cleanly;
each equals main plus this branch's own change (identical patch-ids), and
test_parse_coverage.c has 76 TEST and 76 RUN_TEST entries (71 at the merge
base, +2 from main, +3 from this branch). The MANIFEST summary (164
grammars) and ABI line (9/78/77) match a recount from the tree.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Follow-up to the include_overrides proposal (the previous commit), with
the September review applied:
- possible_callees is computed for the outbound rows the page requests,
so pages stay exactly-once and the list is bounded by limit;
- implementations are found with one per-node OVERRIDE query
(cbm_store_find_edges_by_target_type) and followed transitively with a
visited set, so C.m is listed for a call to A.m when C : B : A; the walk
stops at 5000 nodes per response and says so (possible_callees_truncated);
- under max_output_tokens the section yields before any other field or
graph row and the response reports possible_callees_omitted;
- the tree format renders it as a tree table;
- the list lives in CBM_DYN_ARRAYs and a failed lookup marks it
incomplete instead of failing the trace, so src/mcp/mcp.c keeps its raw
allocator baseline;
- the tool description keeps "Rows keep qn/hop with explicit totals,
relations, and continuations.".
Two rules beyond the review. Only callables are contracts or
implementations: OVERRIDE edges now also link tfvars values and kustomize
overlays. And a contract lists implementations only when a traced call
reaches it through an instance receiver: a super()/base call is bound to
the parent and a call on a constructed object or a type runs the declared
method itself (Django: 1,075 super() calls reach overridden methods).
include_overrides joins the cursor identity only when set: without it a
cursor is the token main mints, so the default output stays
byte-identical to main and cursors already handed out stay valid.
Main's topology/deploy/run modes stay in the schema. Eight tests replace
the single combined assert: the shape and the unchanged default, a
two-level hierarchy, include_tests and non-callable filtering, the tree
table, paging, the budget, static calls, and the cursor identity.
Co-authored-by: lorenzozanee <wyz0707@proton.me>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The receiver gate now runs from an explicit per-language allowlist set by
measurement instead of applying to every language not exempted:
- full gate: Go, C++, C#, Lua, Tcl, Groovy, Elixir;
- suffix_match-only: Scala, Rust, PHP;
- off: everything else (Java, Kotlin, Swift, Ruby, Objective-C, Dart, C,
Python, the JS/TS family, Perl, and every unmeasured language).
Each language was measured on a pinned corpus with fresh seeds and hand-read
samples of the refused CALLS; a language is gated only where the share of
refused edges that were wrong is at least ~85% (Rust 88% for suffix_match,
80% for unique_name, so suffix-only; PHP 30/30 suffix, 60% unique; Elixir
30/30 and 24/25). Rust removes 4,503 false CALLS on meilisearch, PHP 938 on
koel, Elixir 1,885 on plausible; off languages are byte-identical.
Also new C/C++ evidence: a candidate whose owner type the caller's own module
declares binds (`Widget w(n); w.get_id()`), which fixes the cpp/S3
lsp_resolution_probe case the full C++ gate refused in the previous commit.
registry_receiver_gate_runs_by_measured_language replaces the JVM-only test
and pins full, suffix-only and off languages, including an unmeasured one.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The using-directive walk kept its pending nodes in a fixed 256-entry
stack and silently skipped every child it had no room for. Children are
pushed in source order, so a wide file lost its last subtrees: with 300
namespace blocks before it, the namespace holding `using static
System.Math;` was never walked and its unqualified `Sqrt` call bound to
nothing. The stack now starts inline and doubles on the file's arena.
Pinned by cslsp_using_after_many_namespace_blocks, which asserts the
C.X -> Math.Sqrt call behind 300 namespace blocks.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
yyjson's strict writer refuses a whole document over one byte that is not
UTF-8, and source text can be in any encoding. Two pipeline documents carry
it: the per-file LSP surface and the unresolved-call detail. One such byte
made surface_row_build fail the whole job, so the repository lost every
surface row and each later incremental run declined to a full rebuild
(no_surface_rows). It also latched unresolved-call capture off for the rest
of the run.
Add cbm_json_write_text to foundation/json_writer.h. A valid document is
written exactly as before, so surface shas and details do not change. Only a
refused document is written again with the flags the layout writer already
uses (#2907): each undecodable byte becomes an escaped U+FFFD.
Pinned by pipeline_non_utf8_source_keeps_surfaces_and_unresolved_capture (a
latin-1 byte in a string-named TS method and in a Python __all__ entry) and
json_write_text_keeps_valid_documents_and_repairs_refused_ones.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
cbm_gbuf_insert_edge ignored a failed cbm_da_push: it registered the edge in
the dedup and secondary indexes and returned a positive id while the primary
array, which the dump and free read, did not hold it. A retry then hit the
dedup entry and appeared to succeed, so the edge was lost and leaked. Compare
the count around the append; on failure free the edge and return 0 before any
index registration.
Pinned by gbuf_edge_append_oom_is_not_success, which fails the edge array's
first growth through a new test-only, one-shot, class-filtered realloc failure
hook (cbm_mem_test_fail_next_realloc, compiled only with CBM_MEM_TEST_API in
the test and TSan flag sets).
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Indexing go/grafana__loki produced a different graph from one run to the
next: each index reported one or two jsonnet files as parse_partial, a
different set every time, and indexing only its 68 jsonnet files reported
21-37 of them, with real definitions and their CALLS/DEFINES/IMPORTS/USAGE
edges missing. Parsed one at a time, every one of those files is clean,
and CBM_WORKERS=1 gave the same graph on every run.
The vendored jsonnet external scanner kept its state (inside a string,
and which quote) in three file-scope globals, so every indexing worker's
parser shared one copy. tree-sitter restores the scanner state right
before each scan and saves it right after; another thread's write in that
window changed the scan in flight, and a quoted string ran past its
closing quote. Its deserialize also ignored the zero-length call that
starts a parse, so a file ending inside an unterminated quote left that
state to every later parse in the process, and no later ||| text block
could be lexed.
The state now lives in the payload from ..._external_scanner_create(),
and deserialize resets it before reading. Lexing logic and the 3-byte
serialized state are unchanged. MANIFEST.md records the local patch next
to the properties scanner's, THIRD_PARTY.md notes it must be re-applied
on re-vendor, and scripts/vendored-checksums.txt is repinned.
Two single-threaded tests in parse_coverage pin it: a second parser run
from inside parser A's input callback, at the byte after A's opening
quote, must not break A's string; and a parse that ends inside a string
must not stop the next one from lexing a ||| block. Both fail on the
unpatched scanner. With the patch, 30 indexes of the 68 files and 5 of
the whole repo each give one result, with no jsonnet file partial.
lint-vendored-scanners (now part of lint-ci) rejects mutable file-scope
state in vendored scanners and the headers next to them. properties and
jsonnet both had it; haskell's and purescript's read-only cases are
whitelisted with their reasons.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Two manifests can declare the same package name: cli/cli has its own go.mod and
a test fixture's copy with the same module path. cbm_pkgmap_build kept the
first entry in worker order, and which worker parses which manifest is thread
scheduling, so about one index run in thirty mapped the module to the fixture
directory. IMPORTS edges fell from 3,869 to 690 and CALLS from 19,898 to
12,392, with status "indexed" and nothing logged.
The candidates are now ordered by package name, depth below the repository
root and path before the first-wins insertion, so the winner is a property of
the repository. The sequential builders go through the same function.
Two tests hand the same manifests to the merge in both worker orders.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
#1897's receiver-chain gate judged only chains rooted in a type and let a
lower-case root through ("a value whose type the chain does not show"),
and the two suffix_match exits of resolve_multi_with_imports were never
gated. So a member call no LSP had typed bound whatever project symbol
shared its final name: kafka's `tp.topic()` on a TopicPartition bound
ConsumerRecord.topic, gardener's `strings.Join` bound pkg/utils/net.Join,
finagle's `Future.exception` a thrift service method.
At the same name-only exits (unique_name, suffix_match, and now the
import fallback) a CALLS resolve of a member call whose receiver is a
value or a `new X(...)` constructor binds only on evidence that it means
the chosen candidate: a chain segment names its ancestry word by word
(`repo` / Repo, `cleanerManager` / LogCleanerManager, `otel_guard` /
OtelGuard, the receiver of `verify(x)` / `when(x)`), it lives in the
caller's own module, it is import-reachable, or, for a C/C++ call onto a
struct member, the C member resolver decides it from the object's type.
When another candidate is the field-type hint's own pick the call is
left for that re-pick. Otherwise the guess is refused: a veto, never a
re-pick. Self receivers (this, self, cls, super, base, this_, _this) and
`::` paths are exempt; import_map, same_module, qualified_suffix and
lsp_* are untouched. A type root is checked at the import fallback too.
Scope by measured language (share of refused edges that were wrong, hand-
read seeded samples): whole for Go (50/50), C++ (25/26), C#, Lua, Tcl,
Groovy and C; suffix_match picks only for Scala (kafka 29/30, finagle on
#2360 28/30). Left out: Java (suffix_match-only still 47/60), Kotlin
(unmeasured), Ruby (3/15), and Python, the JS/TS family, Perl and PHP,
whose own guards run after resolution and keep their HTTP classification.
kafka 4.0.0 loses 5,189 CALLS (Scala 5,183) and 620 fake async routes,
finagle on #2360 6,302 Scala CALLS and 13 false HTTP_CALLS, gardener 339
Go CALLS, redis 15, otel 168. Deterministic; incremental matches full.
The #2121 controls for value roots now give their candidate a value
receiver's evidence (the caller's own module), which a type root would
not admit.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Brings in #2957 (sql became a self-maintained fork), #2959 and #2962.
Both sides added a self-maintained grammar fork, so every conflict keeps
both additions:
- MANIFEST.md summary: 164 grammars = 139 vendored-from-upstream + 20
self-maintained (sql moved over on main, vba added here) + 5
registry-disagreement; the ABI tally stays 9/78/77 (sql stayed ABI 15).
The notes and the forks table carry both the sql and the vba rows.
- THIRD_PARTY.md: thirteen further self-maintained forks including sql and
vba; main's sql paragraph, then this branch's tree-sitter-vba section.
- tests/test_parse_coverage.c: both test blocks and both sets of
RUN_TEST registrations.
- scripts/vendored-checksums.txt: regenerated with
security-vendored.sh --update; against main only the MANIFEST.md line
and the five vba files differ.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
A partial parse leaves lines the graph has no edges from, so the engine
reads a gap's text: when it names a definition the walk reached, the
definition around the gap is reached too. The match took the short name of
every reached node, fields and types included, and a gap outside every
definition seeded its whole file. In this repository that cascaded: one
replay fired 312 distinct gaps, most on words like `idx`, `n`, `index` and
`used`. The file-scope gap at src/foundation/compat_thread.c:109
(`__attribute__((used))`) fired on any reached field named `used` and seeded
the whole file, including cbm_mutex_init, which the memory core calls, so
nearly every change reached every role handler and the runner's main
(RUNNER_REACHED) through cbm_free.
User decision R155 (2026-11-11): a gap's words match only the names of
reached functions, methods, variables and macros of at least three
characters, the kinds of definition a hidden call or read can name; and a gap
outside every definition seeds the definitions that start on its own lines,
never its whole file.
Test: test_impact_engine_parse_gaps_name_only_reached_functions. Before the
fix a changed field `used` and a changed two-letter global `nn` fire gaps in
unrelated helpers, and a file-scope gap naming a reached function seeds the
whole file; the existing function-name gap test still passes.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Vendors harumiWeb/tree-sitter-vba (MIT, (c) 2026 harumiWeb) at
83c5c3c3c721 (tag v0.14.5, upstream HEAD), its vba dialect, as a
self-maintained fork in tools/tree-sitter-vba/. This is the precondition
for VB6/VBA extraction (#2564, ported after #1179); it registers no
language yet.
Why generated here: upstream does not track its generated parser (its
ADR 0002), so the fork carries upstream's grammar source in upstream's
layout with no local patch, and parser.c is generated in this repository
with tree-sitter-cli 0.25.10 (ABI 15), the generator every fork here
uses. Upstream's own copy is generated by 0.26.9.
Why this pin: v0.13.0 (the pin #2564 carried) exposes the same procedures
but misreads statements without an ERROR node. On the three corpora
below it yields 1,276 expression_statement nodes where v0.14.5 yields 56
(`Err.Raise a, b, c` after a label loses its callee), and it leaves an
ERROR at `Case obj Is Nothing`.
Why the vba dialect rather than upstream's vb6 one: measured with the
CLI on kellyethridge/VBCorLib @ 100acbbae0c0 (655 VB6 files),
Kr00l/VBCCR @ 4b86c5c2c075 (161 VB6 files, 70 .ctl) and upstream's 481
VBA examples, procedures outside ERROR nodes are 14,084/14,084,
12,385/1,552 and 8,104/6,573 (vba/vb6). vb6 rejects the PtrSafe/LongPtr
forms dual-target VB6 keeps inside #If VBA7 blocks and then loses whole
files; vba never sees fewer procedures in any file. vb6's parser.c is
also 75.8 MB against 48.3 MB.
Provenance by hash: common/define-grammar.js is upstream's blob
5e1f7d758ce1; vba/grammar.js minus its 40-line provenance header is
upstream's blob 9247dbbfe166. Two independent generations are
byte-identical, and identical to a generation from upstream's own layout
and tree-sitter.json. The generated node-types.json is upstream's
checked-in file byte-identical (500e635610), and the parse-table counts
equal upstream's own generated parser. Review: 0 non-ASCII bytes, 0
unmatched characters on full tokenization, one comment (the generator
stamp), no string literal with a space, no external scanner, no call
outside the tree-sitter macros. No upstream script, package hook or
binary was run or vendored.
- internal/cbm/vendored/grammars/vba/: the generated parser.c, the
tree_sitter/ headers (byte-identical to copies already vendored) and
upstream's MIT LICENSE byte-identical.
- internal/cbm/grammar_vba.c: compiles and links tree_sitter_vba. No
CBMLanguage, extension or alias routes to it yet; extraction adds them
under the vb6/vba names (vb and visualbasic mean VB.NET).
- MANIFEST.md (fork note with the measurements and known gaps, forks
table, 164 grammars, ABI recount), THIRD_PARTY.md (fork list and a vba
section), scripts/vendored-checksums.txt, and the FORKS entry in
scripts/audit-license-provenance.py.
- README.md and the Chocolatey nuspec say 164 languages: the
language-count contract defines the count as the vendored grammar
directories.
- tests/test_parse_coverage.c: a dual-target VB6 class module (IDE class
header, Declare in both #If VBA7 branches, Property Get/Let/Set,
Implements, events, a label, bare calls) parses with no ERROR node and
every bare call keeps its callee; a CRLF VB6 form parses clean; broken
source is still flagged. The class case fails on v0.13.0 and on the vb6
dialect.
Refs #721, #2564
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The registry ranks a test candidate below real code. For a reference
made by test or test-double code that is the wrong way round: tests and
mocks use their own helpers. Since every definition in a test file ranks
as test (previous commit), kafka's clients tests calling `new MockTime()`
bound TopologyTestDriver.MockTime in streams/test-utils/src/main, a
test-support module no rule marks, instead of the clients test helper
they import.
The calling definition's own verdict (cbm_pipeline_caller_is_test: the
extractor's verdict stored on its node, cbm_is_test_file and
cbm_registry_test_double_path on its file) now reaches the registry from
both call resolvers and both USAGE / READS / WRITES resolvers. For a
test or test-double caller no candidate takes the test penalty, so
proximity alone ranks; production references keep the full rule. The
per-file resolve cache records the bit, since a test and a production
function of one file can ask for the same name.
Proof:
- Production-caller CALLS/USAGE/WRITES on kafka are edge-for-edge equal
to the previous commit; gardener production CALLS too. The
production->test-file tables and the #2427 gains are unchanged.
- kafka `new MockTime()` from tests: 487 constructor and 17 class calls
bind the clients helper again (previous commit: 654 went to
TopologyTestDriver.MockTime).
- gardener mock packages bind their own symbols: USAGE into test-double
files 4959 -> 5132, WRITES 61 -> 137.
- Test-caller CALLS that differ from main (16,373 on kafka) are mostly
name-only member guesses either way; 24 judged (seed 162): 7 better,
6 worse, 10 wrong both ways, 1 equivalent. kafka TESTS edges: 64,603
on main, 57,518 here.
- Two runs identical; incremental matches full for every caller outside
the edited files.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
#2427 (b3ec08da) ranks registry candidates by the extractor's stored
test verdict instead of the old QN substring scan. The extractor gives a
definition its file's verdict only for functions, methods and the module
(extract_defs.c), so a variable, field, class, struct or interface in a
test file keeps is_test=false. The QN scan had masked that: Java and
Scala QNs spell src.test and test class names. Since #2427 such a symbol
ranks as production code, and a name-only match (suffix_match) from
production code picks it whenever it shares more of the caller's path
than the real candidate. finagle's `Future.exception` bound to a Variable
in TimeoutFactoryTest; Go structs in _test.go files won the same way.
The three registry seeders (pass_definitions.c, pass_parallel.c,
pipeline_incremental.c) now also apply cbm_is_test_file, the rule the
extractor computes is_test_file with, on the same path and language, so
every definition in a test file ranks as test, in full and incremental
indexes alike. Ranking only: the stored is_test property, TESTS edges
and importance keep their own rules.
Proof, production-source edges into test files (cbm_is_test_file on both
ends), pre-#2427 cf337a6d / main b3ec08da / this change:
kafka 4.0.0 985bc995 CALLS 849 / 1023 / 750 (onto Variables 6/362/6)
USAGE 5936 / 8254 / 5832, WRITES 163 / 218 / 121
gardener 58d1ab91 CALLS 125 / 123 / 52 (onto Structs 75/75/4)
USAGE 837 / 730 / 572, WRITES 323 / 254 / 160
finagle ca472deb CALLS 281 / 505 / 273, USAGE 1568 / 2436 / 1541
finagle with #2360 CALLS 566 -> 300 (Variables 391 -> 107)
Every edge #2427 moved from a test file to production stays there
(gardener USAGE 125, WRITES 51, CALLS 1; kafka CALLS 59, USAGE 45,
WRITES 13; finagle USAGE 17, CALLS 7). Only suffix_match CALLS move. Two
runs are identical, and an incremental re-index of 25 seeded files
matches the full index for every caller outside the edited files.
On kafka the change also restores about 6,800 suffix_match CALLS from
test files, with their TESTS edges, that main had lost because an
unmarked test-file field won the ranking and the CALLS guard refused it;
they are the edges the index had before #2427.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
- registry_test_double_path_table: the anchored predicate's positives
(fake, mock, mocks, testing, testutil directory segments; mock_*.go,
fake_*.go) and negatives (inspect, latest, contest, fakeroot, mockery,
testingutil, mocking.go, mock_store.py, a file named fake, a different
case, NULL).
- registry_swift_overload_choice_uses_stored_verdicts: the Swift overload
choosers score with the verdicts stored at registration; without them the
smaller QN, a test double, wins the tie.
- pipeline_registry_ranks_by_extractor_verdict_full_and_incremental: the
`latest` vs `_test.go` misranking the QN scan made, through a full index,
a closure-repair incremental run and a forced legacy-partial run.
- pipeline_registry_ranks_test_doubles_last_full_and_incremental: a
generated fake that out-ranks the real package on proximity, through the
same three runs.
Each fails with the piece it pins reverted (predicate, seeder verdict,
incremental seeder rule, closure-repair verdict carry, Swift verdict carry).
Co-authored-by: Chad <4307099+BobbieBarker@users.noreply.github.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Brings the branch up to main f5d57465f. Conflicts and how each was resolved:
- pipeline.h: registration now goes through cbm_registry_add_lang_in_module
with cbm_registry_add and cbm_registry_add_lang as thin wrappers. The
extractor's is_test verdict is threaded through all three as their last
parameter (the convention this branch set for cbm_registry_add), and main's
doc comment on cbm_registry_add is kept with the branch's verdict note.
- pass_definitions.c, pass_parallel.c: main's registration block (generated
members -> cbm_registry_add_qn_only, Swift signatures) is kept and
cbm_registry_add_lang_in_module receives def->is_test.
cbm_registry_add_qn_only needs no verdict: those entries never reach the
by-name buckets the scorer reads.
- pipeline_incremental.c: main's registry_seed_t visitor is kept and passes
cbm_node_is_test(node), so the incremental seed gives the same verdict as
the full index.
- registry.c includes: both foundation/arena.h (main) and foundation/log.h
(branch).
- registry.c index_under_name: takes both the verdict and main's language.
The branch's drop-on-failed-growth rule now covers the lang side array
too, since it shares is_test_cap: an entry that cannot get both bytes is
dropped and logged (registry.verdict_alloc_failed).
- registry.c best_by_import_distance: the branch's unconditional verdict
read plus main's optional lang_flags tie-break input.
- registry.c resolve_multi_with_imports: the filtered view always copies
both side arrays (no "flags may be absent" case is left).
- registry.c cbm_registry_fuzzy_resolve: the branch's
filter_import_reachable fix, now carrying the languages along with the
verdicts, so the filtered subset is scored with its own verdicts and
tie-broken with its own languages.
- registry.c cbm_registry_add body: main's layout (the body lives in
cbm_registry_add_lang_in_module, cbm_registry_add is a wrapper) with the
verdict passed to both index_under_name keys.
- tests/test_registry.c: main's renamed `proximity` registry (Windows
defines `near`) with the verdict argument.
Semantic follow-through in code main added since the branch's base (each
relied on "no verdict means ask is_test_qn", which this branch deletes):
- qn_lang_flags, candidates_without_members and registry_entry_language
no longer guard against side arrays that cover only part of a bucket:
under the drop rule every entry of a non-empty bucket has both.
- The Swift overload choosers (swift_choose_receiver,
swift_choose_candidate) passed NULL verdicts. cbm_registry_swift_candidates
now copies each match's stored verdict from its by-name bucket into a
parallel byte array (same allocation as the match lists), and the choosers
carry it through their receiver and import filters, so every
best_by_import_distance call scores with stored verdicts.
- Test call sites main added (test_registry.c 74 cbm_registry_add,
17 cbm_registry_add_lang, 9 cbm_registry_add_lang_in_module;
test_pipeline.c 6; test_callable_sig.c 3) pass `false`, as the branch's
own call sites do; only those lines were re-wrapped.
is_test_qn has no remaining definition or call site.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Three changes to how PR CI consumes the test-impact selection (user
decisions R150 and R151, 2026-11-11).
Fork PRs. select-tests ran only when vars.TEST_IMPACT_MODE was `gate`, and
GitHub passes no repository variables to a pull_request run from a fork:
all 24 fork runs in the last 40 PR runs skipped the job, maintainer-started
ones included. The condition is now (vars.TEST_IMPACT_MODE || 'gate') ==
'gate'. Setting the variable to anything else (e.g. `shadow`) still turns
the gate off for same-repository and Dependabot PRs; for fork PRs the off
switch is the default in the expression on main. No pull_request_target,
no new permissions, no secrets.
Base tooling. select-tests built and ran the PR checkout's own engine,
test-impact-select.sh and selection.py, so a change to them could narrow
its own tests. The job now checks out the merge base (HEAD^1 of the merge
ref) into a worktree, builds that engine and runs that copy of the script
with --repo pointing at the PR checkout. test-impact-select.sh separates
the tooling (its own checkout) from the repository under test (--repo).
Until this lands, a PR's merge base has no --repo: the job then fails and,
as before, every test runs.
All legs. Only the Linux x86_64 test leg consumed a selection. A narrowed
answer now also produces portable/ (selection.py --whole-suites with the
platform-specific suites of the base and HEAD), and the arm64 and macOS
test-unix legs and the Windows leg run that view: platform-neutral suites
as selected, every platform-specific suite whole. No portable view, no
narrowing there. Sanitizer, TSan, MSan, diag and LSan lanes still run
every test. The shard harness already slices the selected list, so the
sharded arm64 leg and the shard-completeness proof need no change.
docs/SMART_CI.md and README.md follow; tests/test_lane_wiring_contract.sh
pins the new wiring.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
selection.py learns two things the CI needs to narrow test legs other than
Linux x86_64, where the coverage map is recorded:
- `platform-suites --repo DIR --rev REV...` lists the platform-specific
runner suites: those whose defining test file holds a SKIP_PLATFORM( call
or an #if/#ifdef on an OS or architecture macro (the two markers
scripts/check-no-test-skips.sh names for a genuinely platform-specific
test), and those tests/test_main.c registers under such a conditional.
Every revision given is read and the results are united, so a change
cannot declassify a suite by dropping its conditionals. Any git failure
exits 1.
- `filter --whole-suites FILE` writes the view for such a leg: every listed
suite runs whole there, its per-test tokens collapsed to the suite; a
listed suite the answer did not select is added and marked optional (a
build that does not register it drops it with a notice, as a full run
never runs it); the answer's own required suites stay required. An
unusable list runs everything.
Nothing consumes the new view yet. Contract cases in
tests/test_test_impact_selection.sh.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The test runner's __cbm_rss_tree_root role starts a __cbm_rss_tree_hold
child, and no test names __cbm_rss_tree_hold itself: the test that spawns
the root does. The role lift excludes every handler from its literal scan
(a handler naming its own literal is no spawner), so a change reaching the
hold handler found no test naming it and vetoed the whole selection with
RUNNER_REACHED. In the last 40 PR runs that veto decided 14 of the 39
engine answers, every one on __cbm_rss_tree_hold.
A handler that names another role's literal starts that role. Reaching the
started role now reaches its starters too: their literal scan selects their
spawners, and the started role counts as named when a starter does. A role
that a test names directly and that another role also starts now selects
both sets of spawners; before, only the direct ones ran. Runner files that
define no suite are read for starters as well, since handlers live there.
The RUNNER_REACHED note for a role now carries the call chain from the
handler to the changed code, as the main-reach note does, and names the
role it starts when the veto comes from a starter.
Test: test_impact_engine_role_started_by_a_role_selects_its_spawners
(before the fix: run_all, "the change reaches the test-runner role
__fx_hold_role, which no test names").
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Valid SQLite migration files were reported parse_partial because the
vendored SQL grammar (DerekStride/tree-sitter-sql @ 851e9cb257ba) rejects
SQLite syntax they use: PRAGMA, AUTOINCREMENT, a trigger's BEGIN ... END
body, a column named `key` after the first column, WITHOUT ROWID, an
unparenthesized trigger WHEN, INSERT OR IGNORE, and CREATE VIRTUAL TABLE
... USING fts5(...). Each became an ERROR node; the trigger's error region
in atuin's ai_session schema also swallowed the CREATE TABLE after it.
The `key` case is lexical: after a comma inside a column list the grammar
also accepts MySQL's `KEY name (cols)` index, so `key` lexes as that
keyword there and `key TEXT NOT NULL` became a malformed index.
Fix: sql becomes a self-maintained fork of the pin we already vendored,
following the pascal model. tools/tree-sitter-sql/ holds upstream's
grammar.js + grammar/ (blob-identical to the pin and to upstream main @
3c99273f9b32, where its corpus lives) and one patch,
patches/sqlite-dialect.patch, touching grammar/ only:
- PRAGMA [schema.]name [= value | (value)] (new pragma_statement)
- AUTOINCREMENT as keyword_auto_increment, upstream's own change
(c042cde1e2a6, 2026-11-08, after our pin)
- `key` accepted as a column name; the type keywords that take no
arguments are accepted as a MySQL index name so `KEY name (name)` stays
an index
- WITHOUT ROWID
- a trigger body as the existing block node, after an optional
unparenthesized WHEN (precedence keeps Postgres `WHEN (...) EXECUTE
FUNCTION` trees unchanged)
- INSERT OR {ABORT | FAIL | IGNORE | REPLACE | ROLLBACK}
- CREATE VIRTUAL TABLE [IF NOT EXISTS] name USING module(args), aliased
to create_table (new module_argument node), so the table is extracted
as a Table like any other
Upstream node types keep their shape: upstream's 511 corpus cases pass
unchanged; test/corpus/sqlite.txt adds 11 (9 fail on the unpatched
grammar, 2 controls pass on both). The vendored scanner.c is kept as is
(it carries our start_tag leak fix 0e61867d9, now listed under the
MANIFEST's "Local source patches"; upstream fixed the same leak after our
pin in ee2f84f9b857).
Provenance: without the patch, tree-sitter-cli 0.25.10 regenerates
upstream's shipped parser.c byte-for-byte except line 1 (upstream's
generator stamp has no version), and grammar.json, node-types.json and
tree_sitter/*.h byte-identical. Patched: three generations are
byte-identical (parser.c SHA-256 3c64e5c4...7887); ABI 15; states 30,622
-> 31,081, symbols 770 -> 782; 0 non-ASCII bytes, no string literal with
a space, one comment, the same call-position identifiers as before. Node
types only gain entries (pragma_statement, module_argument, four
keywords; create_table gains a `module` field).
Proof, indexed from scratch with isolated caches (main 6d34ca15 vs this
change): dani-garcia/vaultwarden @ 58a980f8 migrations/sqlite (116
files) parse_partial 3 -> 0, graph identical (303 nodes, 446 edges);
atuinsh/atuin @ 2535161e *.sql (69 files) 19 -> 7: all 12 valid SQLite
files clean; the 7 left are the invalid `ALTER TABLE ... DROP INDEX`
down migration and the 2 MySQL + 4 Postgres files, same ranges as
before; graph +2 Table nodes (the fts5 table and the table the trigger
error swallowed), +2 DEFINES, +3 USAGE lineage edges. No newly flagged
file. Control: helm @ 9b88efd6 indexes to an identical graph (12,251
nodes, 39,561 edges).
Registered like pascal: MANIFEST.md fork rows + notes (ABI tally
recounted, unchanged), the audit FORKS map, THIRD_PARTY.md, vendored
checksums. LICENSE stays upstream's MIT byte-identical.
Tests: parse_coverage carries the two SQLite tests from #2246 as written
(sqlite_valid_migration_not_flagged, red before this change, and the
sqlite_malformed_still_flagged control) and adds `key` columns, WITHOUT
ROWID, a WHEN trigger with INSERT OR IGNORE plus an fts5 table (asserted
as a Table), PRAGMA forms, and two controls: MySQL's KEY index still
clean, and ALTER TABLE ... DROP INDEX still flagged.
Distilled from #2246.
Co-authored-by: Kerf <kerfern@hotmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>