Commit Graph
2798 Commits
Author SHA1 Message Date
Martin Vogel f267c48163 Merge branch 'main' into fix/514-alias-dotted-basename 2026-11-17 23:34:50 +01:00
Martin Vogel 4a8ae8d9e3 Merge branch 'main' into fix/514-alias-dotted-basename 2026-11-17 22:10:44 +01:00
Martin Vogel 98910f9eda Merge origin/main into fix/scala-package-aware-imports
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-17 22:10:21 +01:00
Martin Vogel cdfdf26483 Merge pull request #2989 from DeusData/fix/pkgmap-keep-manifest-candidate-order
fix(pkgmap): keep one manifest's candidates in its parser's order (regression from #2974)
2026-11-14 23:03:40 +01:00
Martin Vogel bf190e9e14 Merge pull request #2971 from potto007/fix/abandoned-request-cancellation
fix(mcp): stop cache scans on request cancel
2026-11-14 13:19:39 +01:00
Martin Vogel 8ccdcbc9b2 fix(pkgmap): keep one manifest's candidates in its parser's order
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>
2026-11-14 11:50:12 +01:00
Martin Vogel 08ab4a09fe Merge pull request #2981 from DeusData/perf/linear-growth-sites
fix, perf: C# operator nodes, C increment writes and linear growth in extraction and eight language passes
2026-11-14 10:24:34 +01:00
Martin Vogel 8c1d141c88 Merge origin/main into fix/abandoned-request-cancellation
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-14 10:18:46 +01:00
Martin Vogel 2172281df3 Merge origin/main into fix/scala-package-aware-imports
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-14 10:15:49 +01:00
Martin Vogel b62a2ffaf9 Merge pull request #2977 from DeusData/fix/registry-receiver-gate
fix(registry): refuse name-only member calls nothing ties to the receiver
2026-11-14 02:18:32 +01:00
Martin Vogel 65d4c7be47 Merge pull request #2978 from DeusData/distill/2374-trace-possible-callees
feat(mcp): list possible override callees in trace_path (opt-in)
2026-11-14 01:56:55 +01:00
Martin Vogel d961310805 fix(mcp): stop the not-found project listing on request cancel
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>
2026-11-14 01:27:11 +01:00
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 334bad2e41 refactor(path-alias): allocate through the memory core
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>
2026-11-14 00:47:41 +01:00
Martin Vogel 6d838982cb test(cli): pin that an archive over the decompression limit is refused
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>
2026-11-14 00:47:41 +01:00
Martin Vogel 0a61c59471 perf(extract): linear struct field fold, C# file namespace and doc root
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>
2026-11-14 00:47:41 +01:00
Martin Vogel 4c52fb4e1a Merge origin/main into fix/scala-package-aware-imports
Brings in main up to 09bd6bb1 (#2967 FreeBSD peer pid, #2974 graph
variation and content loss fixes).

Resolutions:
- scripts/memory-core-baseline.txt (textual conflict): both sides
  lowered counts in the same hunk. pass_parallel.c keeps this branch's
  29 (arena QNs); pass_pkgmap.c takes main's 80 (#2974 dropped one raw
  free in cbm_pkgmap_build; this branch's pass_pkgmap.c additions add
  no raw site). Both values re-derived by scanning the merged tree with
  scripts/lint-memory-core.py; the lint passes.
- src/pipeline/pass_pkgmap.c (auto-merged): main's deterministic
  manifest order in cbm_pkgmap_build and this branch's Scala package
  index sit in separate functions; the merged file is main plus this
  branch's change unchanged (same per-file patch-id).
- tests/test_edge_imports.c, tests/test_pipeline.c (auto-merged): both
  sides' new tests are kept and registered; main's new tests call no
  function this branch re-signed. Same per-file patch-id as this
  branch's change.

Every other file equals main.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-14 00:17:43 +01:00
Martin Vogel d68f491a85 Merge pull request #2970 from DeusData/fix/test-impact-gap-matching
fix(test-impact): a parse gap names only reached functions, variables, macros
2026-11-14 00:15:52 +01:00
Martin Vogelandlorenzozanee 784b13f2ee fix(mcp): scope possible_callees to the page and to dispatching calls
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>
2026-11-14 00:14:27 +01:00
lorenzozanee a540bffb58 fix(mcp): expose possible override targets in trace_path
Signed-off-by: lorenzozanee <wyz0707@proton.me>
2026-11-14 00:14:27 +01:00
Martin Vogel ff1fa7d554 fix(registry): gate only the languages measured above the bar
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>
2026-11-14 00:14:04 +01:00
chidev 57205dcf51 fix(514): do not read a spelled module extension twice on an alias import
The alias resolver removes a spelled module extension. The module-name
helper then read the next dotted part as another extension, so
~/tokens.css.ts reached tokens.css and ~/worker.task.mjs.ts reached
worker.task.mjs when both files exist. What is left after the resolver
removed a spelled extension is now the whole file stem.

Refs #514

Signed-off-by: chidev <chicagowebdev@gmail.com>
2026-11-13 14:10:35 -06:00
chidev 31de63afb5 fix(514): keep a question mark in a folder name out of the query cut
An alias import of ~/dir?name/file was cut at the question mark and
reached src/dir.ts. Only a question mark in the file name starts a
bundler query. The dotted-alias test now also checks the Module label.

Refs #514

Signed-off-by: chidev <chicagowebdev@gmail.com>
2026-11-13 12:57:54 -06:00
chidev 2dffaf033f fix(514): keep non-JS alias imports on their module
A path-alias import of a dotted TypeScript file (~/cats/cat.service)
must keep the dotted name, but an alias import of a non-JS file
(~/styles/globals.css, ~/styles.css?url) must still drop its extension,
as it does on main. Keeping every extension sent the CSS imports away
from their module nodes.

The alias branch of cbm_pipeline_resolve_module now decides from the
file path, because filename dots and path separators both become dots
in a qualified name:

- an explicit JS/TS or JSON extension names its module;
- a module at exactly the imported path wins (styles.css, also beside
  styles.css.ts or styles/css.ts);
- else a dotted-name module at that path plus a module extension wins
  (theme.css.ts imported as ~/theme.css);
- else the extension drops, as on main.

A bundler ?query and a #fragment are cut before the extension is read.
The shared alias resolver in path_alias.c is back to main's behaviour,
so doc links keep the file identity they had.

Refs #514

Signed-off-by: chidev <chicagowebdev@gmail.com>
2026-11-13 11:19:44 -06:00
Martin Vogel c69cc84974 fix(pipeline): keep surfaces and unresolved-call capture on non-UTF-8 source
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>
2026-11-13 18:07:13 +01:00
Martin Vogel 71e1659dec fix(graph-buffer): fail edge insertion when the primary array cannot grow
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>
2026-11-13 18:07:08 +01:00
Martin Vogel cd318253e4 fix(pkgmap): pick the manifest nearest the root when two declare one package
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>
2026-11-13 18:06:53 +01:00
Antonio Espinosa 803cbf5cf6 fix(514): preserve dotted filename
Signed-off-by: Antonio Espinosa <antespi@gmail.com>
2026-11-13 08:37:04 -06:00
Martin Vogel a3e9c91ab9 Merge pull request #2967 from DeusData/distill/2492-freebsd-peer-pid
fix(daemon): read the peer pid on FreeBSD via LOCAL_PEERCRED
2026-11-13 07:38:19 +01:00
Martin Vogel ea98999e08 Merge origin/main into fix/scala-package-aware-imports
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-13 07:37:35 +01:00
Martin Vogel a0c7f28ef0 Merge pull request #2968 from DeusData/fix/registry-rank-test-file-defs
fix(registry): rank test-file definitions as test for production callers
2026-11-13 07:37:04 +01:00
Paul Otto e35c5cd5e0 fix(mcp): stop cache scans on request cancel
Github-Issue: #2796
Signed-off-by: Paul Otto <potto007@gmail.com>
2026-11-12 19:59:20 -07:00
Martin Vogel 0c1b45672b fix(registry): refuse name-only member calls nothing ties to the receiver
#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>
2026-11-12 23:59:59 +01:00
Martin Vogel e2257c5ab4 fix(test-impact): a parse gap names only reached functions, variables, macros
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>
2026-11-12 22:47:08 +01:00
Martin Vogel 799e8cd5a2 fix(registry): let test code rank test candidates like real code
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>
2026-11-12 21:17:55 +01:00
Martin VogelandYury Romanov c8de7dcb68 fix(daemon): read the peer pid on FreeBSD via LOCAL_PEERCRED
cbm_daemon_ipc_connection_peer_pid() had branches for Linux
(SO_PEERCRED), macOS (LOCAL_PEERPID) and NetBSD (LOCAL_PEEREID), but
FreeBSD defines none of them, so it fell through to `return 0`, and
runtime_accept_connection() closes every connection whose peer pid is
0: on FreeBSD the daemon rejected every client.

Read the peer credentials with getsockopt(SOL_LOCAL, LOCAL_PEERCRED)
into a struct xucred and accept only the expected layout version, the
caller's effective uid and a positive pid, mirroring the Linux branch.
The branch and its <sys/ucred.h> include compile only on FreeBSD.

Carried forward from #2492, which also raised three timeouts on every
platform; those are left out (CBM_STARTUP_TIMEOUT_MS covers slow hosts).

Co-authored-by: Yury Romanov <romanov@outlook.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-12 20:36:45 +01:00
Martin Vogel 7a0b0d25b2 fix(registry): rank every definition in a test file as test
#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>
2026-11-12 20:07:26 +01:00
Martin Vogel 583e71b6ac Merge origin/main into fix/scala-package-aware-imports (#2360)
Bring #2360 up to date with main b3ec08da (#2427 registry test verdict,
#2962 MSan CI, #2952 Windows stdio guard). The merge is clean and needs
no follow-up edit: #2360's code makes no cbm_registry_add* call and never
used is_test_qn, and Scala definitions register through the shared
seeders in pass_definitions.c, pass_parallel.c and pipeline_incremental.c,
which #2427 already passes the extractor verdict through for every
language. The branch's own change against main is byte-identical to
28948f29's against f5d57465.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-12 19:23:57 +01:00
Martin Vogel 74affb1990 Merge branch 'main' into fix/test-impact-gate 2026-11-12 19:07:58 +01:00
Martin VogelandChad 7e9186cf8a fix(incremental): carry the test verdict on closure-repair proxies
The incremental registry seed reads each stored node's test verdict back
with cbm_node_is_test, as the full build takes CBMDefinition.is_test. Main's
closure-repair route seeds that registry from cbm_delta_preseed proxies,
which load only the properties a resolver reads, and is_test was not among
them: every proxy scored as production, so a re-resolved caller could bind a
test helper the full build ranks last. On gardener a comment-only edit of
three files made the incremental index differ from a fresh full one by two
ranking edges (a WRITES into a _test.go function, a USAGE into
pkg/utils/test); with this change the only differences left are the 13
similarity / OVERRIDE / IMPLEMENTS edges main already shows on that edit.

The preseed now selects whether a row's properties carry "is_test":true and
adds just that member to the proxy's properties. Proxies are never written
back. If adding it cannot be allocated, the preseed fails like an id
mismatch does, rather than seed a proxy that would rank as production.

Co-authored-by: Chad <4307099+BobbieBarker@users.noreply.github.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 20:51:42 +01:00
Martin VogelandChad 6519e1a797 fix(registry): rank test doubles below real code by an anchored path rule
The extractor's verdict is the right primary signal, but Go projects keep
many test doubles in ordinary, non-test files: generated fake clientsets,
mock packages, mock_*.go files. The QN scan this branch removed happened to
rank those below real code; the verdict alone does not, so calls from
production code started resolving into them (gardener: about 570 call edges
newly landed in fake or mock files, 73 of them from production code).

cbm_registry_test_double_path is one registry-only predicate: a directory
segment named exactly fake, mock, mocks, testing or testutil, or a file
named mock_*.go or fake_*.go. It is anchored to whole segments and the
file-name prefix, so inspect, latest, contest, fakeroot or mockery never
match. All three registry seeders pass the extractor verdict OR this
predicate on the path the definition's node stores (pass_definitions.c,
pass_parallel.c, and the incremental seed in pipeline_incremental.c), so a
full and an incremental index rank alike. register_and_link_def now takes
the file's rel path for that, as pass_definitions.c already has it.

The rule only orders candidates when a call is resolved. It stays out of
cbm_is_test_path and cbm_is_test_file, so the stored is_test property,
TESTS edges and importance do not change.

Co-authored-by: Chad <4307099+BobbieBarker@users.noreply.github.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 20:28:54 +01:00
Martin Vogel 8a07514de0 style(registry): clang-format the declarations the main merge re-signed
index_under_name, swift_choose_candidate and the fuzzy path's
filter_import_reachable call gained parameters in the merge of main; this
re-wraps exactly those lines the way clang-format (LLVM 23) lays them out.
No code change.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 20:17:58 +01:00
Martin Vogel cb0289c142 Merge origin/main into fix/registry-test-bit
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>
2026-11-11 20:15:44 +01:00
Martin Vogel 28948f2923 fix(registry): a wildcard import binds no operator call
Follow-up for #2360. A Scala wildcard import (`import pkg._`,
`import pkg.Owner._`) gets an IMPORTS edge whose local name is "*", and
the import-map builders copy that name as a key. Scala operators are
method calls, so `h * width` is a call whose callee is "*" as well: it
matched the wildcard's key and bound to the wildcard's target, a CALLS
edge onto a File or Class that nothing calls (7 edges on twitter/finagle,
20 on apache/kafka, none on main).

resolve_import_map now treats a "*" prefix as no import name. The
wildcard entry stays in the import map, so the imported package still
counts as import-reachable for the other strategies; only the binding by
name is gone. Every import-map builder's keys reach this one lookup, so
the sequential and the parallel drivers are covered alike.

pipeline_scala_wildcard_import_binds_no_operator_call runs a package
wildcard, a member wildcard and a named import through both drivers: no
CALLS edge with the callee "*" may exist, all three IMPORTS edges stay,
and the named import still binds Helper.run through the import map. Red
without the check (parallel driver): both operator calls bind to
Consts through the import map.

Corpora, before vs after this commit: twitter/finagle ca472deb loses
exactly its 7 operator edges, apache/kafka 4.0.0 (985bc995) its 20 plus
the 3 TESTS edges derived from them; no other CALLS, IMPORTS or USAGE
edge moves, node identities are unchanged, and only the derived
importance scores and the SEMANTICALLY_RELATED ranking shift.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 20:03:02 +01:00
Martin Vogel ade7fc2326 fix(test-impact): a role started by another role inherits its spawners
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>
2026-11-11 19:50:30 +01:00
Martin Vogel deadc95666 refactor(pipeline): build the Scala index module QNs in an arena
Follow-up for #2360, memory-core ratchet. After the main merge
pass_pkgmap.c has one raw allocator site more than main's baseline (82 vs
81): the free of the cbm_pipeline_fqn_module_dir result in
scala_index_free_file_entry. The PR offset it by moving the namespace-map
key to cbm_mem_strdup, and main has since made that conversion itself.

The per-file module QNs now come from cbm_fqn_module_source_lang in a
build-time arena that scala_index_build destroys before it returns. That
is the helper the extractor builds definition QNs with, so the top-level
check compares against QNs made by the same rule; pkgmap_module_is_dir
becomes pkgmap_file_language. pass_pkgmap.c is back at 81.

Graph unchanged: twitter/finagle ca472deb and apache/kafka 4.0.0
(985bc995) index to identical nodes and edges with and without this
commit.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 19:41:54 +01:00
Martin Vogel 5893fbab5d fix(store): bump the index format for File-node package clauses
Follow-up for #2360. An index written before this change has no `package`
property on its File nodes. Both incremental routes read that property
back for the files they do not re-extract, so the first incremental run
after an upgrade would build the namespace map and the Scala top-level
index from the changed files' clauses only, and the fail-closed Scala
resolver would drop every import into an unchanged package until the
next full index.

- store.h: CBM_INDEX_FORMAT_VERSION 5 -> 6, so every existing index is
  rebuilt once (format_change_reindex) and records the property.
- test_index_format.c: index_format_v5_scala_packages_rebuild takes a
  format-5 index in the old shape (no File node carries its clause),
  edits the importer, refreshes, and asserts that the import into the
  unchanged package survives, that the rebuild ran, that every declaring
  File node has its clause and that the stored format is current. Red
  without the bump: the refresh stays incremental and Consumer.scala
  loses its IMPORTS edge to Target.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 19:41:54 +01:00
Martin Vogel 32a73eb7fd Merge origin/main into fix/scala-package-aware-imports (#2360)
Bring #2360 (package-aware Scala imports, closes #2153) up to date with
main f5d57465. The contributor's commit 14d43883 is untouched; every
conflict is resolved so that the change stays as written and main's
changes are kept.

Conflict resolutions:
- src/pipeline/pass_pkgmap.c: rebuilt as main's file plus the PR's own
  blocks. Main moved Strategy 2 (namespace map) out of
  cbm_pipeline_resolve_import_node into resolve_import_strategies, so the
  Scala dispatch (language == CBM_LANG_SCALA ->
  resolve_scala_namespace_import) and the declaring_file_is_scala guard on
  the generic namespace walk now sit there, directly before and inside
  Strategy 2 as in the PR; resolve_import_strategies takes the PR's
  language and scala_index. Main's namespace-map builder (fail-closed:
  NULL on a construction failure, an empty map when no file declares a
  namespace) stays the single implementation: it becomes the ctx-aware
  static namespace_map_build that records each clause as the File node's
  `package` property (the PR's file_node_set_package), and the public
  cbm_pipeline_namespace_map_build{,_names} and
  cbm_pipeline_namespace_map_free that main's tests and pipeline cleanup
  call are kept. The PR's key conversion to cbm_mem_strdup was already on
  main. cbm_pipeline_import_maps_build builds both maps on top of it.
  Main's PHP IMPORTS writer (cbm_pipeline_php_create_import_edges) calls
  the re-signed resolver with CBM_LANG_PHP and no Scala index.
- src/pipeline/pass_definitions.c, src/pipeline/pass_parallel.c: main's PHP
  branch in the IMPORTS writers kept, the PR's call with language and
  scala_index in the generic branch. Main publishes the namespace map to
  the pipeline (#1355) instead of freeing it, so only the Scala index is
  freed at the end of the pass; main's two new ABORT_PRESERVE_DB exits in
  the registry loop free the Scala index as well.
- src/pipeline/pass_calls.c: the PR's build_import_map(..., language, ...)
  call next to main's PHP vendor-name lines.
- src/pipeline/pipeline_internal.h: the PR's cbm_file_namespace_t, the
  cbm_scala_index_t declaration, the stored_namespaces context fields and
  the import-maps API next to main's env-join and Terraform types, stem
  marks, env-join base and PHP vendor declarations; main's public
  namespace-map declarations kept.
- src/pipeline/pipeline_incremental.c: incr_load_stored_namespaces and
  incr_free_stored_namespaces next to main's coverage helpers. Closure
  route: main's doc-link scopes are loaded first, then the stored package
  clauses, so a failed doc-link read cannot leak them; the context carries
  the PR's fields and main's. Legacy route: main removed the ADR capture
  (ADRs live in the sidecar database), so the PR's shared ADR/namespace
  abort becomes a read of the stored clauses after a successful graph load
  that shares the failed load's cleanup (a failed load logs and returns
  exactly as on main; stored_namespaces_failed returns
  ABORT_PRESERVE_DB as in the PR).
- tests/test_pipeline.c: main's file plus the PR's own hunks; the four
  RUN_TEST lines follow the same anchor line.
- tests/test_edge_imports.c: main's two PHP resolver tests (#1186) adapted
  to the re-signed cbm_pipeline_resolve_import_node (CBM_LANG_PHP, NULL
  Scala index), the convention the PR used for its own call sites.
- tests/test_extraction.c, tests/test_edge_imports.c: the PR's reformat of
  extract_ts_await_generic_call_issue2210 and its pipeline_internal.h
  include were already on main (e8a46c16e), so they drop out of the diff.
- scripts/memory-core-baseline.txt: recomputed against main's baseline:
  pass_definitions.c 11 -> 9 and pass_parallel.c 31 -> 29 (the PR drops
  their raw rels arrays); no line raised. pass_pkgmap.c is one raw site
  above main's baseline after this merge; the follow-up commit removes it.

The index format bump for the new File-node property follows in the next
commit.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 19:41:48 +01:00
Martin Vogel f5d57465fd Merge pull request #2951 from DeusData/distill/2215-idle-cadence-guard
test(daemon): pin the idle maintenance-probe cadence
2026-11-11 19:38:21 +01:00
Martin Vogel f61d7c0e0a Merge pull request #2170 from AmirF194/fix/2121-csharp-lowercase-receiver-type-keyword
fix(registry): recognize C# lower-case type keywords in receiver_chain_admits
2026-11-11 19:38:05 +01:00