Commit Graph
5661 Commits
Author SHA1 Message Date
Martin Vogel 7ea7612a78 Merge remote-tracking branch 'origin/main' into fix/cpp-test-body-caller-land
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>

# Conflicts:
#	internal/cbm/cbm.c
#	internal/cbm/extract_defs.c
#	src/pipeline/pass_lsp_cross.c
2026-11-19 18:07:09 +01:00
Martin Vogel 3a8f82b3d6 Merge pull request #3040 from DeusData/refactor/lsp-engine-table-type-scope-rows
refactor(lsp): one engine table for the cross-file pass; declared-type rows for more languages
2026-11-19 18:05:39 +01:00
Martin Vogel cbf4254e0f Merge pull request #3041 from DeusData/feat/site-hook-and-scope-facts
feat(pipeline): site hook and per-file scope facts for the shared cross-file layer
2026-11-19 18:05:14 +01:00
Martin Vogel 4f8b66e2d6 Merge pull request #3037 from DeusData/fix/discover-deploy-env-landing
fix(discover): index deploy config files, skip env only as a virtualenv
2026-11-19 02:37:03 +01:00
Martin Vogel f6f12246fa Merge pull request #3035 from DeusData/fix/ci-tests-stop-hashing-the-runner
test: stop hashing the test runner in the copied-image and install tests
2026-11-19 02:24:57 +01:00
Martin Vogel 25a7e248a6 Merge remote-tracking branch 'origin/main' into shared/scope-land
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-19 01:57:36 +01:00
Martin Vogel 74816034e9 Merge remote-tracking branch 'origin/main' into shared/core-land
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-19 01:37:18 +01:00
Martin Vogel 3649ba3349 Merge pull request #3030 from DeusData/fix/c-include-lookup-repo-root
C/C++: resolve #include against the indexed repository root
2026-11-19 01:31:59 +01:00
Martin Vogel 68d9470151 feat(lsp): the declared-type step's fields for the further engines
Everything the remaining engine slices need from the shared step lands
at once, so each of them appends rows and touches no shared code:

Type-scope rows state every field. New ones, unused by the Go and Python
rows (their graphs are unchanged):
- scope_source: MODULE_IMPORTS (the own module, then the import map; Go,
  Python), INCLUDE_CLOSURE (a caller-supplied visible() answers a name:
  C and C++ once the include closure exists) or LEXICAL_NESTING (the
  namespaces of the file enclosing the definition, innermost first: Ruby
  constants).
- colon_paths: `a::B` is one spelling whose QN joins with `.`; a leading
  `::` gets no identity.
- open_imports: import-map entries under the key "*" name open packages;
  a name nothing else binds is the one type of that name across them, or
  none.
- implicit_external: a predicate for the language's implicit external
  scope (java.lang and the like); a name it declares gets no identity.
- nested_types: a bare name written inside a type is first that type's
  member type, then each enclosing type's, before the module; member
  types of supertypes are not seen (a possible answer, not a proven one).

The calling file's own table, cbm_type_scope_file_imports: each local its
named imports bind, with the verified type identity, from the same scope
the collector attaches with. A walk reaches it through
cbm_pxc_file_scope(f->ctx, ...); every driver now hands the walks the
pipeline context in CBMCrossLspRegistries.ctx (behaviour unchanged: a
struct with no registry built is read like none).

One row-driven field fold (pxc_fold_fields) replaces
pxc_fold_struct_fields and pxc_fold_py_field_types. The engine row says
where fields come from ("Field" definitions with raw types: Go, C, C++;
annotations resolved to project QNs: Python), the owner label, that only
the last owner of a QN takes them (Python) and which of the row's
languages fold (C and C++, not CUDA: kept as before). One hash of the
owners, one pass over the fields, one chain per owner.

Tests: each new field through the public step API with a hand-made row,
each with its negative partner; the calling-file table (Python, Go, open
key, a star import); cbm_pxc_file_scope per engine; counted work of the
nested and open lookups at two sizes; the fold's rows (Go and C fold in
declaration order, CUDA none). Go and Python graphs are identical to
before on their development repositories, as are C and C++.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-19 00:18:00 +01:00
Martin Vogel dc5dc25e4a refactor(lsp): one table of engines in the cross-file pass
The cross-file pass decided per language in five places: which shared
registry to build (three copies of the same six calls, in the sequential
driver, pipeline.c and pipeline_incremental.c), which registry a language
reads (an inline switch), whether a language has a cross-file walk (a
switch), how to walk one file against a registry (a switch in the
dispatch, with Rust's lazy registry and TypeScript's own def filter as
special paths of its fallback) and how to walk one file over a def list
(a switch in cbm_pxc_run_one_with_php_bindings, plus cbm_pxc_run_one_ts).

They are now one static table, one row per engine (Go, Python, the C
family, C#, the TypeScript family, Java, PHP, Kotlin, Rust): the
languages it serves, its shared-registry builder, whether that registry
is lazy (Rust) and read without an overlay, its walk against a registry,
its per-file walk, whether its defs skip the module filter (Rust), and
whether it reads declared-type identities (Go, Python). Each engine's two
walk wrappers keep its present calls exactly. CBMCrossLspRegistries is one
slot per row; the three drivers build through the table. An engine plugs
in by adding its row; the dispatch no longer names a language.

Behaviour is unchanged: on one development repository per engine
language (Go, Python, TypeScript/JavaScript/TSX, Rust, Ruby, Java, C#,
PHP, Kotlin, C, C++) and a Perl fixture, the graph of the base and of this
change are identical (nodes, edges and properties) with one worker and
with the default worker count. The per-engine log line
lsp_cross_prepare.builder replaces the fixed six-pair
lsp_cross_prepare.builders line.

Test: type_scope_engine_table_rows pins the rows: the thirteen languages
that had a walk and no other, the shared registries built eagerly (go
python c cs ts java, in that order), the shared rows of the C and
TypeScript families, and identities wanted exactly where the declared-type
step has a row.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-19 00:18:00 +01:00
Martin Vogel db73949260 feat(extract): per-file scope facts for Protobuf, kept through compaction and the surface
The shared cross-file layer needs, per file of a language without an
engine, what the file defines and includes in source order: the facts
its visibility closure will read. This lifts the language-neutral half
of the parked include-scope branch's extract_scope.c (round 5) with its
Protobuf handlers only.

- cbm.h: CBMScopeEvent {name, qual, pos, index, kind, flags} and
  CBMFileResult.scope at the tail. Kinds DEF, INCLUDE, ASSIGN (a name
  defined here that the graph has no node for), QREF (a qualified type
  reference as written), OPAQUE (a parse error); flags REEXPORT
  (`import public`) and CONDITIONAL (inside a parse error). The values
  are the branch's, so its shell and Make kinds keep their numbers.
- CBMImport.start_byte, in padding (the struct stays 40 bytes):
  parse_spec_imports records the statement every row came from, which
  is how an INCLUDE event finds its row.
- extract_scope.c: one cursor walk driven by a row per language (node
  kinds and roles, the label of a type's definition, the package
  statement, the nesting kind); Protobuf is the only row. A DEF is the
  definition result->defs already holds; its full name carries the
  package and the enclosing messages.
- result_compact.c: the events and their strings move with the result,
  and so through a spill.
- lsp_surface.c: the "is" key stores the facts by rank (bytes that move
  keep the stored bytes and the surface hash), only for a language with
  a row, so every other file's stored row is unchanged;
  cbm_lsp_surface_scope_from_json reads them back.

The walk matches its rules on named nodes only: the branch also matched
the anonymous `import` keyword token, which gave every import statement
a second include event (31 on the development repositories' Protobuf
files). Apart from those, the stored facts equal the branch's round-5
binary's for every .proto file of etcd, nest, prometheus, cli, vagrant
and a fixture tree. Graphs are unchanged on both routes.

tests/test_scope_facts.c: the definitions, includes and references of
one file; nothing for a language without a row; a parse error is
opaque; compaction keeps the facts; the surface round trip; the hash
follows the facts, not the bytes; the walk's work grows linearly.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 23:48:13 +01:00
Martin Vogel c8bdd5d528 feat(pipeline): one site hook for the shared cross-file layer
The shared cross-file layer (scope facts for languages without an engine)
needs one place where it can answer a call or usage site before main's
name chain, the same on the sequential and on the parallel route, without
the resolvers being edited for each rule.

site_bind.{c,h} is that place. Both call resolvers (pass_calls.c,
pass_parallel.c) and both usage resolvers (pass_usages.c,
pass_parallel.c) ask it at the same sites: a call no engine row matched
that does not require one, and a usage no engine row was found for. A
PROVEN answer replaces the chain where the chain runs (a call keeps every
later step of main: service classification, spawn, field policy,
guards); POSSIBLE and NO_ANSWER leave the chain as it is. A begin and an
end step per file hold the file's state and hand the layer the buffer the
file's edges went to, so an answer drawn after main's own edges needs no
further edit of the resolvers.

No language has a row yet: every file is inactive and every site gets
NO_ANSWER. Graphs are byte-identical to the base on both routes (etcd,
click, devise and two fixtures, one worker and padded past 50 files;
nodes and edges compared with strategy and properties).

tests/test_site_bind.c pins the contract for a language without a row:
no answer at a call or a usage, no edge drawn at the file's end.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 23:48:13 +01:00
Martin Vogel 88dbd8eb4f test: link TRE into the image probe on Windows
compat_regex.c is backed by the vendored TRE library on Windows, so the
probe failed to link there (undefined tre_regcomp/tre_regexec/tre_regfree,
CLANG64 job 135123199250). Link TRE_OBJ_TEST / TRE_OBJ_TSAN into the two
probe flavours as the runners do; both are empty on every other platform.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 23:30:53 +01:00
Martin Vogel 9b4645bd65 Merge origin/main into fix/c-include-lookup-repo-root
Brings the branch up to main 33f2973a (#3034 declared types for Go and
Python, #3032, #3031, #2983 and the action bumps).

src/pipeline/lsp_surface.c: #3034 rewrote the surface row build (the row
is hashed without type identities and re-encoded with them for storage)
while this branch added each row's included-file list. Kept main's
hashing and re-encoding and added the included-file list after it; the
row's failure path frees both, and the final row text always comes from
the default allocator as before.

Everything else merged without conflict. Merged tree, macOS arm64
ASan/UBSan: pipeline, incremental, index_format, store_nodes,
store_graph_digest, extraction, c_lsp, parallel, go_lsp and py_lsp,
2,374 passed.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 23:30:36 +01:00
Martin Vogel 703c4e8623 Merge pull request #3031 from DeusData/fix/test-cli-update-fixture-limit
test(cli): size the update tests' decompression limit to their fixture
2026-11-18 23:13:11 +01:00
Martin Vogel 33f2973a64 Merge pull request #3034 from DeusData/feat/declared-type-scope-go-python-2
feat(lsp): resolve declared types in the scope that wrote them (Go, Python)
2026-11-18 23:05:14 +01:00
Martin Vogel 7929b7d025 test: index an Ansible tree under deploy/ through the sequential semantic pass
A playbook naming a role extracts no imports of its own: its IMPORTS
edges come from the Ansible pass, so the semantic pass builds its import
map from those edges (the slow path). Now that deploy/ is walked for its
configuration files, every repository holding Ansible under deploy/ takes
that path through the sequential pass: trees of 50 files or fewer at any
worker count, any tree at one worker.

pipeline_ansible_under_deploy_sequential_pass indexes a two-file tree at
the default worker count, the same tree at one worker, and the tree with
60 more files at one worker; each must draw the role import, and the
graph must not depend on the worker count.

The test runner's memory core is libc malloc/free, so a fault on this
path that needs the production allocator binding cannot show there. The
smoke already indexes a small project with the shipped binary on every
platform (scripts/smoke-test.sh, Phase 2, where the large templated C++
header guards the tree-sitter allocator); that project now also holds the
playbook and its role under deploy/. Phase 2 must report the project
indexed, and Phase 3 checks that the role import was drawn, so the slow
path was reached.

The smoke check needs the semantic pass to allocate its slow-path
import-map keys through the memory core
(fix/semantic-import-map-allocator); land this after that fix.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 21:21:43 +01:00
Martin Vogel a21efacfde test(pipeline): incremental routes see deploy/ config files as a full index does
Every incremental route rediscovers with the full index's rule, so a
configuration file added to or edited in deploy/ after the first index
must reach the graph while program source there stays out. The test adds a
manifest through the route the planner picks (closure repair declines a new
file: full route) and one through the forced full-load route, edits a
manifest (closure repair declines a changed Kubernetes manifest: full
route), edits the program source there (no input changed: no-op route) and
edits the deploy script (closure repair), and compares each result with a
fresh full index of the same tree.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 21:21:43 +01:00
Martin Vogel f9158d9e6a fix(discover): index deploy config files, skip env only as a virtualenv
Discovery skipped every directory named deploy, deployed or env, at any
depth. The deploy rule came in because build output copied into deploy/
produced duplicate Class and Method nodes (discover_deploy_excluded_full_mode),
but it also dropped what deploy/ usually holds: Kubernetes manifests, Helm
charts, Kustomize overlays, Terraform, Dockerfiles, Compose files and
scripts. The env rule was meant for Python virtual environments and dropped
ordinary packages and settings folders of that name (a Go package env, a
Python env module).

deploy/ and deployed/ are now walked for their deployment and configuration
files only. A file there, at any depth, is kept when its language (the
registry's own classification, by name and shebang) is deployment
configuration in the language registry (cbm_language_is_deployment_config):
the build-configuration languages the registry's build_config_language
already names (Makefile, CMake, YAML, TOML, JSON, INI, Dockerfile; now one
list, cbm_language_is_build_config, which build_config_language delegates
to), Properties, XML, JSON5, Jsonnet, Jinja2, Kustomize, Go Template, HCL,
Bicep, Nix, Puppet, Pkl, DotEnv, and the shells Bash, Zsh, Fish and
PowerShell. Program source, SQL and Groovy stay out, and so do the
dependency manifests the package-map walk skips there (package.json,
go.mod, Cargo.toml, pyproject.toml, pom.xml, *.gemspec, ...: one list,
cbm_discover_is_package_manifest, now shared with that walk). Each is
recorded as a skip-list drop. A .cbmignore negation of the directory lifts
the rule, and below a JVM source root it does not apply, as for every
built-in skip.

A directory named env is skipped only when it holds pyvenv.cfg,
bin/activate, Scripts/activate or conda-meta/history as a regular file.
Each marker is decided from the directory listings by its exact stored
name, one component at a time and without following links, so a
case-insensitive disk answers as a case-sensitive one does.

The pinned test-impact inventory makes the same decision: the directory
rule in cif_directory_reason, the virtual-environment test against its own
file list by exact name, and a config-only flag on each row that the
language step honours, so its file list stays equal to discovery's. The
package-manifest walk keeps skipping deploy/ and deployed/, and the JVM
doc-link classifier keeps calling a deploy package not indexed.

Pinned by
- discover_deploy_indexes_config_files_only: one file per kept language
  indexed under deploy/, each dropped kind beside it not, and the same
  files under ops/ all indexed;
- discover_env_skipped_only_as_virtualenv: every marker, conda included,
  skips its env; a Go package and a settings folder named env are indexed;
  markers that differ only in letter case do not count;
- discover_env_venv_marker_through_symlink_not_followed;
- test_impact_classify_matches_discovery_in_deploy_and_env and
  test_impact_classify_matches_discovery_on_env_layouts: one table each,
  both code paths;
- doc_mentions_jvm_deploy_package_not_indexed: the guard first, then a
  deploy package reads not_indexed and an env package binds.
discover_deploy_excluded_full_mode passes unchanged. Two JVM doc-mention
fixtures used a plain src/a/env/ package as their example of a directory
discovery skips by name; that package is indexed now, so they use tmp/.
The repro board's always-skip table no longer lists env.

A large generated tree under deploy/ now costs what the same tree costs
under any other name; a .cbmignore line such as deploy/generated/
excludes it (docs/cbmignore.md).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 21:21:38 +01:00
Martin Vogel 6d80cce23c test: stop hashing the test runner in the copied-image and install tests
The daemon_runtime copied-image probes and the CLI install/update tests
made full SHA-256 passes over the sanitized test runner (about 520 MB on
macOS arm64, about 790 MB on hosted x86) or over copies of it: about 10
passes per daemon_runtime run and 66 passes plus 31 staged, fsync'd
copies in the cli suite. On hosted x86 jobs that draw an Intel Xeon
runner one pass takes 70-95 s (1-3 s on AMD EPYC), so the copied-image
probes ran out of their 60 s budget and the cli suite ran past its
3600 s wall clock: the verdict depended on the CPU the job drew.

A small dedicated executable, the image probe, now takes the runner's
place in those tests. It links only the daemon runtime, the foundation
layer and mimalloc (about 2 MB) and carries the roles the tests need
(serve, the HELLO and activation clients, --version for installs); the
role code moved from tests/test_main.c. Makefile.cbm builds
<runner>-image-probe beside each runner flavour with that flavour's
flags as an order-only prerequisite of the runner, leaving out
workspace.c and slab_alloc.c, which serve the indexer. The copied-image
tests run the daemon from the probe and the clients from identical or
changed copies of it; the install tests stage and publish the probe
through the existing self-path seam. Production verification is
unchanged.

macOS arm64 ASan/UBSan: runner 518,227,624 bytes, probe 1,981,480 bytes;
daemon_runtime, daemon_bootstrap, daemon_frontend, cli,
activation_transaction and agent_clients: 575 passed, 1 skipped, 1
host-specific failure that also fails on main here; contracts pass.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 21:04:57 +01:00
Martin Vogel 5c89385d88 Merge pull request #3032 from DeusData/fix/semantic-import-map-allocator
fix(semantic): allocate slow-path import-map keys through the memory core
2026-11-18 20:52:14 +01:00
Martin Vogel 1b64aaf6f5 fix(cpp): match only a test's own body in the preprocessed view
The preprocessed view named a function definition as a raw test when its
first and last lines mapped onto that test's span. Lines alone also match
two other bodies:

- a method of a local class inside a one-line test, or one running from the
  test's head line to its closing line: the call it makes was drawn from
  the test (preprocessed view) and from the File (raw view, where main
  draws calls in local-class methods);
- a function written on the line of a one-line test,
  `static int helper3() { return s03(); } TEST(Pair, Helper) { ... }`:
  the helper's body was named as the test, a false TEST_Pair_Helper -> s03.

Now only a top-level definition of the preprocessed view (directly in the
file, or in a namespace, extern, template or conditional body) is matched,
and none when two such definitions map onto one span: no answer, never a
pick, and the body is named as it would be without the rule. The view's
top-level definitions are indexed once per file; a body is looked up by a
binary search.

Two tests on one line with one head spelled through a project macro stay
as before: the shared span gives no answer, the preprocessed view names
that body from its own expanded head, and its call is drawn from the test
and from the File (main's own edge, the right target).

Pinned by pipeline_cpp_gtest_view_guard_local_class_method,
pipeline_cpp_gtest_view_guard_helper_on_test_line and
pipeline_cpp_gtest_view_guard_shared_line_macro_head (sequential and
parallel resolver), each with a plain one-test-per-span partner.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:28:09 +01:00
Martin Vogel accfcf6fa7 fix(lsp): an overload decorator imported under another name
`from typing import overload as ovl` followed by `@ovl` was not recognised as @overload (the decorator's last dotted name is matched against `overload`), so the implementation's return annotation still gave the call its type: `make().replace(cls=AliasText).css()` drew Alias.css where python3 runs AliasText.css. A plain decorator name now also counts when the module's imports bind it to typing's or typing_extensions' overload (the module's namespace facts, `from ... import overload as X`); `@typing.overload`, `@tp.overload` and `@overload` match as before. A method of the same class under an ordinary decorator keeps its identity.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:52 +01:00
Martin Vogel 28f20234c1 fix(lsp): an overloaded Python function whose declarations differ takes no identity
A function declared with @overload is typed at a call by the overload its arguments select (scrapy's `response.replace(cls=HtmlResponse)` is an HtmlResponse); the implementation's annotation (`-> Response`) is the type of no call, and neither is any one overload's. A definition whose QN the file also declares with @overload (`overload`, `typing.overload`, `t.overload`) now takes no identity from its annotations when the definitions of that QN declare different return types, so main's answer stays; when they all declare the same one (sqlalchemy's Connection.execution_options, `-> Connection` throughout), every call has that type and the identity stays. python3 runs Text.css for the fixture's `replace(cls=Text)` and Response.css for `opts(a=1)`; a plain method of the same class keeps its identity.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:45 +01:00
Martin Vogel d2d4f02891 fix(lsp): a Go local type shadows the package's type only in its block
A type declared inside a function shadowed the package's type of that name for the rest of the whole function, so after the `if` block or outside the closure that declared it, a value of the package's type was typed unknown and its calls lost their edges. The walker now binds each type parameter and each local type name in its own lexical scope (the function, a block, a func literal) under a key no identifier can spell (`#T`), and a lookup asks the scope chain: a local type shadows from its declaration to the end of its block, as in Go. `go run` decides the new fixture (Block p1, Clo p2p1).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:37 +01:00
Martin Vogel 148dd0521f fix(lsp): a Python name a body declares global and binds takes no identity
`global R` in a class body (run at import) or in a function body that binds R (`from pkg.b import R`) rebinds the module's R, so an annotation naming R in that module may mean that other binding (python3: pkg.b.R after the class body). Like a name the module binds twice, R now takes no identity there. The extractor records the names a body declares global and binds (CBMDefTypeFacts.global_names: assignments, imports, for and with targets, a nested def's or class's name, del and except targets count, the declaration alone does not), and the step marks them as bound more than once in the file's module bindings. The names join the definition's stored row (field_defs, as `name:` without a type), so an edit that adds or drops one is not a one-file repair. A function that declares `global R` and only reads it keeps the identity.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:29 +01:00
Martin Vogel ae5bae2950 fix(lsp): del and except-as unbind a name in a Python class body
A class body's `del D` and `except ValueError as E` counted as bindings of the class, so a method annotation naming D or E after them took no identity, although by then the name is the module's again (Python unbinds an except target when its clause ends). The class-body list now takes the body's top-level statements in order: a binding holds from its statement on, and a later top-level `del` unbinds it unless a method is defined between the two (evaluated at definition time its annotation saw the class's binding, evaluated lazily the module's: no one answer, so the name stays bound); a `del` inside a compound statement may not run and unbinds nothing. An except target is a binding only for a definition inside its clause. python3.15 and 3.14 (lazy annotations) and 3.9 (eager) agree on the module's E and D; D2, bound when its method was defined, differs between them and keeps the abstention.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:21 +01:00
Martin Vogel 05ef90bf70 perf(extract): a Go struct's embedded-type text in one linear pass
go_struct_embedded_text joined each embedded type's spelling onto the text so far with a new sprintf, copying the whole prefix again for every embed: quadratic in the number of embedded types. It now measures the spellings in one cursor pass over the field list and copies them into one arena buffer in a second: linear, with the same text. A test seam counts the work (cursor steps and bytes copied), and a test extracts structs of 2000 and 4000 embedded types: the work doubles, and the last spelling is in the list.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:13 +01:00
Martin Vogel 817a292a72 test(lsp): edges the type-scope tests expect, besides those they forbid
The checks that an edge is absent gain partners that require one: the class-and-module test reaches a second class's method through the same shape; the embedded-names test calls through Ping, Lock2 and UseSame and requires Here exactly once, and Use's targets are labelled by build (Item on linux, Item2 elsewhere, as `go run` answers per platform); the function-declared-types test requires the calls into the generic functions themselves (First, Box.Get). The incremental harness can check the graph before and after the edit (ts_incremental_checked); the 17-embeds, 66-fields and class-body-edit tests now require the edges the edit keeps or drops, which 18d5f14e's routes did not draw (a per-file route that kept 15 embedded types, a 63-field limit on every route, a class body outside the stored row).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:09:04 +01:00
Martin Vogel e17059f64f fix(cpp): name a test body alike in the raw and the preprocessed view
Every C/C++ file is read twice: raw, and after the built-in preprocessor,
whose calls are merged with the raw ones. The second view spelled a test
head differently whenever the expansion changed it: a project macro among
the arguments (`#define MY_SUITE RealSuite`, `TEST(MY_SUITE, ViaMacro)`),
a comment inside the head (gone after preprocessing), or a project's own
one-argument TEST macro (expanded to `void test_alpha()`). It then named
the body with a name no definition carries, and a call written there was
drawn twice: from the test node (raw view) and from the File (second view).

The def walk now records each GoogleTest definition's raw line span. In
the second view a function definition whose first and last lines map, by
the preprocessor's line map, onto exactly one recorded span is that test,
whatever its expanded head reads (cbm_test_span_owner_qn). The call scope,
the enclosing-function helper and the C/C++ engine all ask it, so every
call has one source. Two tests on one line share a span and keep the names
their own heads give. Where the second view cannot be matched to a raw test
(a head written by a project macro whose raw definition is not a test),
nothing changes against main: that body's second-view calls stay at the
File, as they always were.

The test's name also drops comments from the head's arguments:
`TEST(CommentSuite /* c */, Commented)` is TEST_CommentSuite_Commented,
not TEST_CommentSuite_/* c */.

Pinned by cpp_gtest_preprocessed_view_names_the_raw_test (calls, engine
rows and references of both views at the raw test, for the three shapes),
cpp_gtest_preprocessed_view_one_line_pair, the growth guard
cpp_gtest_preprocessed_view_lookup_growth (spans sorted once per file,
binary search per body) and pipeline_cpp_gtest_preprocessed_view_one_source
(one CALLS source per call, sequential and parallel resolver).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 19:07:18 +01:00
Martin Vogel 29d8a64121 fix(cpp): name the caller of a call in a GoogleTest body like its definition
The def walk names `TEST(Suite, Case) {...}` (and TEST_F, TEST_P,
TYPED_TEST, TYPED_TEST_P) TEST_Suite_Case (#1266), but the three places
that name the caller of a call kept the bare macro: the call-scope walk
(compute_func_qn), the enclosing-function helper behind the reference
extractors (cbm_enclosing_func_qn) and the C/C++ engine
(c_process_function). No node carries that name, so every call and
reference written in a test body was sourced at the File node.

One helper, cbm_cpp_test_macro_name, now produces the name for all four,
gated by cbm_cpp_test_macro_names_on (C++ or CUDA, gtest preset on; on
when nothing is configured). The engine learns the gate from the file's
extraction result (CBMFileResult.cpp_test_macro_names): the per-file run
reads it, the cross-file dispatch passes it on both routes. With the
preset off, the definition and every caller keep the bare name as before.

Each call keeps its target and its strategy; only its source moves from
the File to the test. Measured precision can still fall on a repository
with many tests (fmt: 77.4% to 74.4% under the M0.5 metric) without any
new wrong resolution: a guess main repeats in N tests was one File edge,
judged once; it is now N edges, one per test, each judged.

Pinned by cpp_gtest_body_caller_is_test_node (text call, reference and
engine caller of all five forms and inside a namespace),
conventions_gtest_preset_names_body_callers (both preset states, text
path and engine), pipeline_cpp_gtest_body_calls_start_at_test_node
(CALLS start at the test nodes, the engine-bound edge keeps its lsp_
strategy, none at the File node; sequential and parallel resolver) and
pipeline_cpp_gtest_caller_incremental_matches_full (a body edit through
closure repair gives the full graph, sequential and parallel).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 18:43:18 +01:00
Martin Vogel 3c187ab99a test(cli): size the update tests' decompression limit to their fixture
On macOS, cli_update_agent_configs_finish_before_guard_release and
cli_update_names_the_failing_staging_step_and_os_error package the test
runner itself as the fake release. The in-process updater, which exists
only in test builds, refuses a tar.gz that inflates past 500 MiB
(DECOMPRESS_MAX_BYTES), and an ASan runner carrying every vendored grammar
sits right at that limit. The ObjectScript v1.11.0 parse tables add about
4.9 MB to the runner, which took both CI macOS runners over it: the
archive was refused as "binary not found in archive" right after its
checksum was verified, so the first test got rc 1 and the second never
reached the staging write that fails with ENOSPC. Linux packages
/bin/true and was not affected.

The limit keeps its own test,
cli_update_refuses_an_archive_over_the_decompression_limit. These two
tests only need their archive accepted, so they set the limit to twice
the fixture's inflated tar, which the doubling decompression buffer can
never exceed, and restore it right after the update runs.

x86_64 ASan runner under Rosetta, the macos-15-intel analog: main
1ec2f262 is 520,665,520 bytes and passes; 0bde6dea is 525,530,264 bytes
and fails both tests with the CI messages; main plus only the vendored
grammar directories of 086967955 is 525,502,864 bytes and fails the same
way. With this change both tests pass at 525,530,264 bytes, and fail
again with it reverted.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
(cherry picked from commit 9d3f2af1ec)
2026-11-18 18:17:27 +01:00
Martin Vogel c4bb3b31ea Merge pull request #2983 from b84330808/fix-crlf-line-splice
fix(extract): read a CRLF line splice in C-family strings as LF does (#1546)
2026-11-18 18:15:26 +01:00
Martin Vogel d1986a2e45 fix(semantic): allocate slow-path import-map keys through the memory core
The semantic pass builds a file's import map from its extracted imports
or, when the file extracted none, from the IMPORTS edges another pass drew
for it (the slow path). The slow path copied each key with cbm_strndup,
which is libc strndup, while free_import_map releases every key with
cbm_free. In the product build cbm_free is mi_free, and on macOS the
mimalloc global override is off, so the key was a foreign block.

An Ansible playbook is such a file: it extracts no imports, and the
Ansible pass gives it IMPORTS edges for its roles and includes. On macOS
the index worker crashed in the semantic pass (SIGSEGV in mi_free, or
SIGBUS in mi_usable_size) on every repository of 50 files or fewer
holding a role or an include, for example these two files:

  site.yml    "- hosts: all\n  tasks:\n    - include_tasks: other.yml\n"
  other.yml   "- debug:\n    msg: hi\n"

and on any repository indexed with one worker (kubespray). The same pass
runs for the frozen test-impact index and for changed files on the
incremental route.

The slow-path key is now allocated with cbm_alloc under the semantic
class, like the fast path's cbm_mem_strdup keys.

The test suite never saw the crash: the test build backs the memory core
with the C runtime allocator, where cbm_free is free. The new test
indexes a playbook with a role and an include once, to warm what the
process builds once and keeps (the pretrained token table), then takes
the semantic class's live block and byte counts around a second,
identical full index and an incremental re-index after an edit, and
requires them to end where they started. The memory core counts only the
blocks it hands out, so a key it takes back without having handed it out
leaves the class below its start on every platform, independent of the
allocator, of where the string landed and of what ran before the test.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 18:06:51 +01:00
Martin Vogel 700c1ce9b2 fix(lsp): an annotation alone binds no class attribute
A class body's `x: T` without a value records an annotation and binds nothing, so a method annotation naming x still means the module's x; the class-body list no longer counts it (main's python_typed_field_external_import_stays_unresolved asserts that such a class gets no field_defs). The class-body test gains an annotation-only name whose method keeps its identity.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 07:31:14 +01:00
Martin Vogel 8b8e5496e3 perf(lsp): a smaller per-definition identity index
A definition's identity index (cbm_type_scope_index) held a 24-byte slot per entry in a table of at least four, plus the string copy: about 140 bytes for one identity, 300 for three, retained in the registry arena for the resolve phase. Entries are 12 bytes of offsets into the copy now, and up to four identities (most definitions) are a plain list a lookup scans, a bounded cost; more stay a hash table. The answers are the same. Also formats the round-3 lines clang-format reported.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 07:08:20 +01:00
Martin Vogel 8d801b64ae test(lsp): a generic type's field and a class-body edit on the repair route
The type-parameter test also reads an exported field of a generic type from another package (m.Box[p2.E]{}.V.Hello()), and an incremental test edits a class body so that it binds the name a method annotation uses (same lines): the class's bindings are part of its stored row, so the run is not a one-file repair that keeps a stale caller edge.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 06:59:14 +01:00
Martin Vogel a1c003423e fix(lsp): Go embedded field names, function-declared types, all fields
Three defects the second review found in the Go engine, and one limit
beside them:

- The unqualified type name of an embedded field is a field of its depth
  (Go spec), so in `Server{ Config; base.Handler }` the selector s.Config is
  the embedded Config even where Handler has a field Config one level down,
  and an embedded func type `Logger` shadows a promoted method Logger. The
  member lookup saw named fields only: a deeper field won (main's right
  edge replaced by a wrong one) and a deeper method was called. Every
  registry route now names each embedded type as a field of the embedding
  type: typed as the embedded type when its QN is known, of unknown type
  otherwise (it shadows and answers nothing, e.g. sync.Mutex). A QN of
  several definitions (build variants, foo and foo_test) shadows every field
  name any of them declares, so no deeper member of that name is selected
  where they disagree.
- The walker typed a function's type parameter, its generic receiver's,
  and a type the function declares itself (`type T struct{...}` in the body)
  as the package's own T, which now promoted T's embedded members. Those
  names shadow the package's types in the function (a local type from its
  declaration on); they are unknown to the walker, which abstains. Main's
  own false edge from a type parameter to a method of the package's T goes
  with it.
- The per-file route replaced the walked file's struct fields and embedded
  types with a scan of its syntax tree that kept 15 embedded types and 63
  fields, while the full index took them from the definitions: a one-file
  repair lacked edges the full index had. Every route now takes them from
  the definitions, all of them; parse_field_defs and the in-file scan keep
  every field too (the 63-field limit cut both routes alike and decided
  which field calls resolve).

The agreement table's joins are linear now (one buffer each).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 06:58:06 +01:00
Martin Vogel b8e7c1e4e3 fix(lsp): class-body bindings, Go type parameters, one facts record
Three defects the second review found, and its memory finding:

- A Python class body binds names besides its nested definitions
  (`Config = OtherConfig`, an import, an annotated name, a for, with,
  except or match target, a walrus, global/nonlocal/del), and inside its
  methods' annotations such a name is the class attribute, not the
  module's class of that name. The extractor lists them per class
  (CBMDefTypeFacts.class_bindings) and the declared-type step gives none of
  them an identity; a name the body does not bind keeps its own. They also
  join the class's field_defs as `name:` (an attribute of unknown type the
  Python registrar skips), so they are part of the stored row the
  incremental planner compares: an edit of a class body is never a stale
  repair.
- A class and a module of one QN (class Thing in pkg/a/__init__.py beside
  pkg/a/Thing.py) share their members' QNs, so a member edge through the
  class's identity named the module's function. A type QN the graph holds
  as a module gets no identity (the graph the import map reads).
- A Go type parameter in a definition's types (`func First[T any](xs []T)
  T`, `func (b Box[T]) Get() T`, `type Box[T any] struct{ v T }`) was read
  by the cross registrars as the package's own type of that name, and the
  embedded-member promotion carried that to its embedded types. The
  extractor records a Go definition's type parameters (its own, its generic
  receiver's), and the cross-file texts spell them `any`: no registrar reads
  them as a project type.

The three definition fields the declared-type step added (type_params,
value_type, go_embedded) were 24 bytes on every definition of every
language. They move to one optional record, CBMDefTypeFacts, allocated in
the result arena only for a Go or Python definition that has a fact, which
also carries the Go type parameters and the class bindings: 8 bytes per
definition for the pointer. Compaction and the spill walk it.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 06:57:54 +01:00
Martin Vogel 18d5f14e60 feat(lsp): promote embedded Go struct members across files
Go promotes the methods and fields of an embedded type to the struct that
embeds it. A struct of another file reached the Go registrars without its
embedded types (unnamed fields are neither fields nor base classes), and
the walked file's own structs qualified `logging.LogHolder` against the
file's module, so `o.Hello()` through an embedded `base.Base` was lost.

The extractor records a struct's embedded types as written
(CBMDefinition.go_embedded; no graph edge is drawn from it), the pipeline
hands them to the cross-file LSP, the declared-type scope step resolves
their spellings in the declaring file's scope, and one Go-specific hook
(go_embedded_qns) turns them into the QNs the member lookup falls through
to: the identity, or for a bare name the declaring package's own type. The
walked file's own structs take the same answer through their imports.

The member lookup walked embedded types depth-first and took the first hit
in declaration order at any depth. It now follows Go's selector rule for
methods and fields alike: breadth-first, the member at the shallowest depth
wins, two at that depth (or a field and a method) is no selection, and an
outer field of the name shadows every promoted method; in one file as
across files.

A struct QN of several definitions (a package and its external test
package, build-tagged variants) keeps what every definition agrees on: the
fields declared with the same type text and identity, and the embedded
types only when all embed the same, so prometheus' build-tagged
labels.Builder keeps its shared `base` field and the answer never depends
on file order. An embedded type swapped for another package's type of the
same name is a change of the named type the closure planner declines on.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 05:19:03 +01:00
Martin Vogel dc81846a8e feat(lsp): type Go package-level values across files
`pkg.Default.Get()` and a bare `Default.Get()` of another file of the
package stayed untyped: Variable definitions carried no type, and the Go
registrars ignored them. A package-level `var`/`const` now records the
type its declaration or its single initializer spells (`T`, `T{}`, `&T{}`,
`new(T)`, a const block's implicit repetition; nothing inferred) in
CBMDefinition.value_type. The pipeline hands it to the cross-file LSP as
the Variable's type, the Go registrars register the value under
<package>.<name> with CBM_FUNC_FLAG_VALUE, and `pkg.V` / `V` evaluate to
that type. The type is not written to the graph: no Variable node of any
language carries one today.

A value is never a call target, on every route: the walker's callable
lookups and the fast resolve of unresolved calls both skip it, so a call
through a function-typed value keeps main's edge and strategy.

A directory holds both `package foo` and `package foo_test`, and their
package-level names share one directory QN. A value whose QN another
definition also has (a value of another type or identity, a function of
the other package) is registered for neither, so the answer never depends
on file order; values of one QN that spell the same type with the same
identities (build variants of one declaration) give one answer and stay.
The struct rule of the earlier commit becomes the same kind of rule: a
struct QN whose definitions all spell the same fields with the same
identities keeps them.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 05:19:03 +01:00
Martin Vogel dfa846771f feat(lsp): bind Go closure parameters wherever the literal stands
The Go walker recursed into a func literal's body as plain children of the
enclosing scope; its declared parameters were bound only when the literal
was evaluated as an expression (an argument, an assignment). A literal in
a composite literal's field value, a test table's
`run: func(reg *httpmock.Registry) { reg.Register(...) }`, left `reg`
untyped and every call through it unresolved. The walker now walks every
func literal it reaches with its parameters bound, through the same helper
the evaluator uses.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 05:19:03 +01:00
Martin Vogel bdc27776eb fix(lsp): Go struct fields on their own registry entry
Both Go registrars attached a struct's fields to the FIRST registry entry of
its qualified name: a receiver placeholder when a method of the struct was
registered first. A type lookup after finalize answers with the LAST entry
of that name, so the fields were never seen and every field chain through
such a struct died (helm's `r.cfg.Releases.DeployedAll`). The fields are now
parsed onto the struct's own entry, the placeholder keeping them too for the
first-registered readers.

Go module QNs are directories: a package and its external test package
(`foo`, `foo_test`), or build-tagged variants, can declare two structs of
one QN, and which entry a lookup answers with depends on file order. Such a
QN keeps no fields in either registrar, as before this change, where its
fields were never visible.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 05:19:03 +01:00
Martin Vogel fc263770fc feat(lsp): resolve declared types once, in the scope that wrote them
A definition's declared types travel to other files as source text, and
the Go and Python cross registrars qualified that text against the
defining module only: a type the defining file imported from a third file
became `<defining module>.<Name>`, a name nobody registered, and every
call through it was lost.

A shared step (src/pipeline/type_scope.{h,c}) resolves every type name a
definition's return, parameter and field texts write once, in the scope of
the file that wrote it: the file's own module, then what its imports bind
(the LSP import map). A name gets an identity only when that scope gives
exactly one answer and the answer is a project definition of a type label
the engine registers. One description row per language (Go, Python):

- An import that names no project definition is no answer (`Self` from
  typing, `logging.Logger`), and neither is a path a package re-exports:
  the step cannot prove one through the engine's export fold.
- Go imports bind packages: a bare name never resolves through one, and an
  own-module name is left to the engine, so a type parameter cannot take
  an identity.
- Python looks a name up in the def's own scopes first: a def inside a
  function gets none, and so does a name its enclosing class body
  declares, a PEP 695 type parameter of the file (new extraction field
  CBMDefinition.type_params), a name the module binds more than once (its
  ordered namespace facts: an import and a TypeVar, two imports), and any
  name of a module with a star import or a parse error.

Identities ride on CBMLSPDef.type_scope ("spelling=QN|..."), are stored in
the LSP surface row ("ty", codec version 5) for the routes that do not
re-extract a file, and are left out of the surface hash and the Python
namespace comparison: a body edit stays a one-file repair. An identity
also depends on other files' type definitions; the closure planner
declines when a changed file gains a type definition, or when a type some
stored identity names changes or leaves its file
(cbm_lsp_surface_identity_decline), so the depth-1 closure stays exact.

The Go and Python registrars read identities through a per-def index
(cbm_type_scope_index / cbm_type_scope_find: one hash probe per lookup),
and the per-file selection follows them to the declaring modules, walking
each module once. Every loop the step adds has a counted-work growth test.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 05:19:03 +01:00
Martin Vogel beba7f8c0c C/C++: re-extract a header's includers in an incremental refresh
A C-family file's preprocessed pass reads the repository files its quoted
#include lines name, so its graph changes with their bytes even when its
own bytes do not. An incremental refresh after an edit to a header alone
re-extracted only the header, and its includers kept their old expansion.

- The #include lookup resolves only to files the index run covers (its
  discovery, through CBMIncludeScope and the pipeline context's
  indexed_files), so every file an expansion depends on is in the run's
  manifest.
- Each file's lsp_surface row records the files its lookup read
  (included_files; transitive, since the headers a header includes are on
  the includer's own list). It is not part of surface_sha.
- The closure planner adds every stored file whose record names a changed
  or deleted file to the delta as a changed file, which then goes through
  the same surface comparison. One pass over the stored rows.
- CBM_INDEX_FORMAT_VERSION 6 -> 7: an index written before records no
  included files, so it is rebuilt once.
- The graph and content digests cover the new column; a database without
  it keeps its previous digest stream.

Tests: pipeline_c_header_edit_refreshes_includers_incrementally (a header
edit reaches a direct and a transitive includer; the refresh equals a
fresh full index) and index_format_v6_included_files_rebuild.

Refs #2993

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 04:05:30 +01:00
Martin Vogel 9c2348640b Merge origin/main into fix-crlf-line-splice
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 03:02:14 +01:00
Martin Vogel 9ce3259bee Merge origin/main into fix/c-include-lookup-repo-root
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 01:48:06 +01:00
Martin Vogel 08a7a586a4 Merge pull request #2975 from lev-os/fix/514-alias-dotted-basename
fix(514): keep dotted alias imports and non-JS alias imports on their module
2026-11-18 01:19:23 +01:00
Martin Vogel f267c48163 Merge branch 'main' into fix/514-alias-dotted-basename 2026-11-17 23:34:50 +01:00
Martin Vogel 649eb5e9c9 Merge pull request #2360 from htarnacki/fix/scala-package-aware-imports
feat(scala): parse import selectors and resolve package-aware imports (#2153)
2026-11-17 23:34:26 +01:00