Commit Graph
313 Commits
Author SHA1 Message Date
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 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 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 e5b3972429 fix(grammar): give the jsonnet scanner per-parser state
Indexing go/grafana__loki produced a different graph from one run to the
next: each index reported one or two jsonnet files as parse_partial, a
different set every time, and indexing only its 68 jsonnet files reported
21-37 of them, with real definitions and their CALLS/DEFINES/IMPORTS/USAGE
edges missing. Parsed one at a time, every one of those files is clean,
and CBM_WORKERS=1 gave the same graph on every run.

The vendored jsonnet external scanner kept its state (inside a string,
and which quote) in three file-scope globals, so every indexing worker's
parser shared one copy. tree-sitter restores the scanner state right
before each scan and saves it right after; another thread's write in that
window changed the scan in flight, and a quoted string ran past its
closing quote. Its deserialize also ignored the zero-length call that
starts a parse, so a file ending inside an unterminated quote left that
state to every later parse in the process, and no later ||| text block
could be lexed.

The state now lives in the payload from ..._external_scanner_create(),
and deserialize resets it before reading. Lexing logic and the 3-byte
serialized state are unchanged. MANIFEST.md records the local patch next
to the properties scanner's, THIRD_PARTY.md notes it must be re-applied
on re-vendor, and scripts/vendored-checksums.txt is repinned.

Two single-threaded tests in parse_coverage pin it: a second parser run
from inside parser A's input callback, at the byte after A's opening
quote, must not break A's string; and a parse that ends inside a string
must not stop the next one from lexing a ||| block. Both fail on the
unpatched scanner. With the patch, 30 indexes of the 68 files and 5 of
the whole repo each give one result, with no jsonnet file partial.

lint-vendored-scanners (now part of lint-ci) rejects mutable file-scope
state in vendored scanners and the headers next to them. properties and
jsonnet both had it; haskell's and purescript's read-only cases are
whitelisted with their reasons.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-13 18:07:03 +01:00
Martin Vogel ae573f940e Merge branch 'main' into feat/svn-state-reader 2026-11-10 18:54:12 +01:00
Martin Vogel 97f8da2cb7 Merge origin/main into java-external-gate
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-03 18:09:34 +01:00
Martin Vogel b8c5ec77c5 Merge origin/main into java-external-gate
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-03 03:46:43 +01:00
Martin Vogel 08b84e4011 Merge origin/main into fix/php-inline-html-2000
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-03 01:40:29 +01:00
Martin Vogel 94b36e82df Merge origin/main into java-external-gate
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 18:25:02 +01:00
Martin Vogel a508219299 Merge origin/main into feat/ruby-lsp-per-file
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 18:09:59 +01:00
Martin Vogel ff74ab0982 Merge origin/main into fix/php-inline-html-2000
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 18:09:51 +01:00
Martin Vogel 5808426aca Merge origin/main into java-external-gate
Brings the branch up to main (a5b248f4); it was 670 commits behind.

One conflict, in src/pipeline/pass_calls.c: main (d4273ae9) moved the
LSP-target lookup of resolve_single_call into calls_emit_lsp_target and
the registry fallback into calls_registry_resolution. The Java gate of
this branch now lives in those helpers, unchanged in effect:

- resolve_single_call computes java_external once, as before, and passes
  it to both helpers;
- calls_emit_lsp_target looks a Java lsp_external callee up strictly by
  QN with no tail match, as the branch did inline;
- calls_registry_resolution skips the name guess for such a call, next
  to the Rust and PHP vendor skips.

pass_parallel.c, pass_lsp_cross.c, lsp_resolve.h, Makefile.cbm and the
test registrations merged without conflicts.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 02:39:51 +01:00
Martin Vogel e8cb85cf0f Merge origin/main into fix/php-inline-html-2000
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-01 21:30:01 +01:00
Martin Vogel 360ab15cdb Merge origin/main into feat/ruby-lsp-per-file
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-01 21:18:25 +01:00
Petteri Ponsimaa 6e54ac3ce7 Merge origin/main into feat/nextjs-app-router-routes
Main took semantic index version 12 for its Markdown section change, so
the Next.js App Router routes move to version 13 with their own history
entry. pipeline_nextjs_semantic_upgrade_issue759 now starts from a
version-12 index.

Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
2026-11-01 17:19:23 +02:00
Martin Vogel c2faaaa3d0 Merge branch 'main' into exp/r32-mimalloc-win-test-init 2026-10-31 21:30:35 +01:00
Martin Vogel 9bb891b669 ci: move macOS runners to macos-15 and pin the deployment target to 14.0
GitHub retires the macos-14 runner image on 2026-11-02, and its brownouts
already cancel our macos-14 jobs. Move every macos-14 runner reference to
macos-15 (arm64): the release darwin-arm64 build, the unix-macos14 and
tsan-mac test legs, the smoke-mac PR leg (its two matrix.os guards move in
lockstep), the release smoke, both soak legs, the memwaste event lane, the
bug-repro board, the cache warmer and the all-platform smoke. Lane names
stay unchanged: select-lanes.sh, ci-ok and the lane contracts key on them,
never on the runner label.

Two broad legs already ran on macos-15 (_test.yml BROAD_UNIX, _smoke.yml
BROAD_UNIX) and smoke.yml listed both images, so the moved legs would have
duplicated them. Those duplicates are dropped; PR CI keeps exactly the
same legs.

Without an explicit minimum, clang stamps the binary with the SDK's
default (LC_BUILD_VERSION minos), so a release built on macos-15 would
refuse to start on macOS 14. Makefile.cbm now folds
-mmacosx-version-min=14.0 into CC/CXX next to ARCHFLAGS for Apple targets
(detected from the compiler's target, not the host), so it reaches every
compile and link, vendored objects included, on every build path.

Proof on macOS 26.6 / SDK 26.5: the production binary built from
origin/main reports minos 26.0; with this change it reports minos 14.0,
with zero warnings under -Werror, no weak imports and an identical
undefined-symbol set. The test runner (direct make, no env.sh) is minos
14.0 too; platform and daemon_ipc suites pass.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-30 23:44:25 +01:00
Martin Vogel 192fdb918f test(windows): try FLS init for the MinGW test allocator (R32 experiment)
The Windows test leg (CLANG64 x86_64, ASan+UBSan) has a nondeterministic
crash that only shows on trees with mimalloc 3.5.3: 1-3 suites die in their
first test with 0xC0000005 and no sanitizer report. mimalloc 3.5.3 is the
first version whose loader hooks are live on MinGW: TLS callbacks in
.CRT$XLB/.CRT$XLY run _mi_auto_process_init under the loader lock and
_mi_thread_done on every thread detach.

As an experiment, compile the MinGW TEST allocator with
MI_WIN_INIT_USE_FLS=1. That build carries none of those hooks: process init
runs once from the priority-101 constructor and thread-done goes through a
fiber-local destructor. FLS also needs MI_DEBUG=1, because its internal
assertion that the FLS key exists fires on the first thread init, which runs
before the key is allocated, and that would abort every MI_DEBUG=2 process at
startup. Level 1 keeps the fill patterns, padding and double-free checks.

The production allocator flags (MIMALLOC_CFLAGS) are unchanged on every
platform, and on macOS and Linux MIMALLOC_CFLAGS_TEST is byte-identical.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-30 22:55:31 +01:00
Petteri Ponsimaa 1237096a46 Merge origin/main into feat/nextjs-app-router-routes
Main has used semantic index versions 10 and 11 since this branch took 10,
so the Next.js App Router routes move to version 12 with their own history
entry: an index main wrote at 11 rebuilds once for the new Routes.
pipeline_nextjs_semantic_upgrade_issue759 now starts from a version-11 index.
The other conflicts were tests both sides added at the same place; both kept.

Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
2026-10-29 22:13:57 +02:00
Ben Fairless 41f27cca4b Merge branch 'main' into feat/ruby-lsp-per-file 2026-10-29 15:53:17 +08:00
Ben Fairless b86e65df39 Merge branch 'main' into feat/ruby-lsp-per-file 2026-10-28 19:38:05 +08:00
Martin Vogel 3d65c609e1 fix(mem): define MI_MINGW_UCRT64 for MinGW mimalloc builds
mimalloc 3.5.3 treats a MinGW build as having a process-attach hook only
when MI_MINGW_UCRT64 is defined (src/prim/windows/prim.c). Upstream's
CMake sets it; Makefile.cbm did not. src/prim/prim.c therefore also
compiled its constructor, and _mi_auto_process_init ran twice on Windows:
once from that constructor and once from the CRT TLS callback.

The second run flushes the delayed-output buffer to stderr again, and the
first flush had left a newline in it, so every Windows run started with a
blank line on stderr. That is what failed smoke-win's one-line --version
check. In the MI_DEBUG=2 test build the same second run reaches
mi_assert_internal(mi_out_default == NULL) in options.c, which aborts.
3.3.2 had no such condition.

Define it for IS_MINGW builds in both the production and the test
mimalloc flags. Every MinGW toolchain this repository builds with (MSYS2
CLANG64 and CLANGARM64) is UCRT. No vendored source changes.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-28 01:07:23 +01:00
Martin Vogel 7e55bc110b Merge branch 'main' into fix/mimalloc-3.5.3-preinit-free 2026-10-27 20:03:26 +01:00
Martin Vogel 674b088826 Merge origin/main into feat/nextjs-app-router-routes
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-25 22:05:37 +01:00
harshitaajoshi 460ed148ca Merge remote-tracking branch 'origin/main' into fix/php-inline-html-2000 2026-10-25 14:59:32 -05:00
Timur Nizametdinov 808100974c feat(java): no name guess for calls on a proven-external receiver
When the Java resolver resolves a call's receiver to a type outside the
project (a JDK package, or a package no project file declares), the call
gets strategy lsp_external. Both pipeline paths (pass_calls.c and
pass_parallel.c) then look the target up strictly by QN through
cbm_pipeline_java_external_target and skip the registry's name guess, so
no edge is created to an unrelated project method of the same name. This
is the rule the Rust path follows since #2053.

Positive proof only: a receiver of unknown type keeps the existing guess,
and a seeded JDK type that lacks the called method stays no_method_match.
Type variables (T, ID) are never taken for package-qualified types.
A package counts as the project's when any registry layer holds a
project type in it (the layer above the shared registry is a per-file
overlay), and a path-derived spelling counts as the project's also for
a file at the repository root. java_receiver_is_external memoizes its
answer per package.

A type of the caller's own package, or of its own file, now shadows
java.lang (JLS 6.4.1): java_resolve_type_name looks the JVM package up
before the java.lang auto-import. Before the gate that wrong first answer
was harmless, since the name guess still found the project class; with
the gate a project `Enum` or `Process` would read as external.

Only the parallel path builds the Java cross registry, so on the
sequential path the gate does not fire yet; the next commit adds it.

Tests: java_typed_calls_parallel (external receivers get no edge; a
project receiver keeps its edge, also when its type is missing from a
project package or shares its simple name with a java.lang type),
parallel_java_external_target_contract.

Signed-off-by: Timur Nizametdinov <7229951+tfactor2@users.noreply.github.com>
2026-10-21 22:01:40 +02:00
Martin Vogel 5aa31bee62 ci: parallelize cppcheck with isolated whole-program state
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-21 20:50:57 +02:00
Petteri Ponsimaa fa331ed5e6 feat(extraction): route Next.js App Router handlers
app/**/route.{ts,js} files produced 0 Route nodes, so cross-repo
intelligence found no edges into a Next.js backend (#759).

cbm_extract_nextjs_routes fills route_path/route_method on the
existing Function definition for each exported HTTP-verb handler.
It adds no pass and no synthetic definitions; the route-node pass
builds the Route and HANDLES edge as it does for other frameworks.
CBM_SEMANTIC_INDEX_VERSION goes from 9 to 10 so existing indexes
re-extract once.

Fixes #759

Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
2026-10-21 10:00:24 +03:00
Martin Vogelandlzl51230 0a5b30befa feat(watcher): add the Subversion working-copy observation core
Add src/watcher/svn_state.c, the inert first part of the SVN support
agreed in #1127: a parser for `svn status --xml --verbose` output read
from a FILE *, and resolution of a system `svn` client from PATH. It runs
no process and nothing calls it yet; running the client through the
bounded subprocess route and the opt-in watcher strategy are the
follow-up.

The parser, the PATH pinning, the path-safety rules and the signature
design are carried over from the #1127 contribution. Changed for this
landing, per the review there:

- unversioned trees are walked from an explicit heap work stack, so tree
  depth never reaches the native stack;
- every file and directory is opened one component at a time without
  following it and measured on the open handle (openat + fstat on POSIX;
  on Windows the handle's final path must equal root/relative);
- symlinks, FIFOs, sockets, devices, unreadable and oversized files are
  skipped and counted instead of turning the observation UNCERTAIN;
- the size cap applies to the bytes actually read;
- every heap allocation goes through the memory core;
- ':' and '\' are ordinary bytes in POSIX names;
- MSYS2 and Cygwin clients are recognised by the runtime DLL beside the
  executable instead of the install prefix, and Cygwin paths get the
  /cygdrive spelling.

The svn_state suite needs no Subversion install: status documents in
the svn 1.14 layout and fake client executables that are never run.

Refs #1127

Co-authored-by: lzl51230 <14934913+lzl51230@users.noreply.github.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-21 00:34:35 +02:00
Martin VogelandFelix Rath f9f44b5869 fix(mem): vendor mimalloc 3.5.3 so free(NULL) before init is safe
With mimalloc 3.3.2's release build, free(NULL) before the allocator's
constructor dereferenced a page map that does not exist yet. glibc 2.44's
newlocale() does exactly that during libstdc++ start-up, so every Linux
binary died with SIGSEGV before main (reported with a reproduction in
#2562). Upstream fixed it in b2226c19 (mimalloc #1341), first released in
v3.4.4; v3.5.3, upstream's latest published release, contains it.

Vendored from microsoft/mimalloc tag v3.5.3 (tag object deac3dcf, commit
d4881d338125e1cb7c47ba4cfb398d6f7c0c8d45): LICENSE, include/ and src/,
written blob by blob from a bare clone. Before the local patches were
reapplied, the staged LICENSE blob and include/ and src/ trees had the
tag's exact object ids (50 files; src/arena-meta.c is gone upstream).
Afterwards the only differences are two documented hunks:

- src/prim/unix/prim.c: macOS always recommits on decommit, carried from
  63fb7b3d (the phys_footprint fix).
- src/prim/osx/alloc-override-zone.c: one comment reworded, because
  scripts/security-vendored.sh rejects the upstream "fork()" spelling
  even inside a comment. No code change.

The reproducible-banner patch (no __DATE__/__TIME__) is dropped: upstream
removed the build clock in v3.4.5 (mimalloc #1355). The two Makefile
comments that pointed at that patch now say so.

The production object is built with -DMI_PROFILE=0: mimalloc 3.5.2+
compiles its allocation-sampling profiler in by default, with a sample
countdown on the allocation path, and the product never uses it.

vendored/mimalloc/PATCHES.md records the pin, a re-verification recipe,
the check that pins each patch and the refresh procedure; THIRD_PARTY.md
points at it, the SBOM version is 3.5.3 and scripts/vendored-checksums.txt
is regenerated (mimalloc lines only; security-vendored.sh passes).

Measured on Apple M5 Pro (macOS 26.6), full indexes, 2 interleaved reps,
main fceb25d8 (3.3.2) -> this change: TypeScript peak phys_footprint
1.07/1.01 -> 1.04/1.04 GB, peak RSS 1.87/1.84 -> 1.85/1.86 GB, wall
30.6/29.1 -> 29.3/30.0 s; django footprint 0.41/0.41 -> 0.38/0.39 GB,
RSS 0.59/0.59 -> 0.58/0.60 GB, wall 6.5/6.2 -> 6.5/6.5 s. The graphs are
identical: full node and edge hashes, node and edge census, no dangling
edges (django 68022 nodes / 322464 edges, TypeScript 306239 / 835984).
The same tree without the recommit patch peaks at 2.09/2.04 GB footprint
on TypeScript, so 63fb7b3d still does its job. Linux arm64 (glibc 2.39,
gcc 13.3): both trees build without warnings; django peak RSS 0.67/0.68
GB on main, 0.69/0.68 GB with this change.

Co-authored-by: Felix Rath <felixm.rath@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-21 00:33:51 +02:00
Martin Vogel 453b21e680 ci(codeql): PR scan per language inside PR CI, full scan on main
Bring CodeQL back to pull requests as jobs of PR CI itself (needed by
ci-ok, no polling), narrowed to first-party code, while push to main,
the weekly run, the dry run and the release keep the full scan.

- codeql.yml: one leg per language (c-cpp, javascript-typescript,
  python, actions), scope in .github/codeql/codeql-config.yml. The full
  scan traces the whole build, vendored C included. The PR scan
  (light: true) analyses each selected language's whole first-party
  scope; c-cpp compiles the third-party objects before tracing
  (scripts/build.sh --vendored-only) and then traces the first-party
  build plus the vendored files the PR changes (--reuse-vendored
  --retrace-from, make -W). Diff-informed analysis (codeql-action
  v4.38.1, forced on for PR calls) only restricts reported alerts.
  The alert check moves into each leg and reads the analysed ref.
  Push and PR runs cancel superseded runs per language; dispatched
  runs never cancel. Compiler cache off so every compile is traced.
- pr.yml: a codeql job runs the legs of the selected codeql-* lanes;
  ci-ok needs it.
- select-lanes.sh: codeql-cpp/-js/-py/-actions lanes, selected by a
  change in their scope (any C/C++ incl. vendored; JS/TS, Python and
  workflows inside the config's paths minus paths-ignore) and by every
  full run (undeterminable diff, workflows, build, CodeQL machinery).
  --codeql-scope LANGUAGE prints a list's in-scope paths.
- codeql-retrace-vendored.sh: the vendored C files a PR changes (empty,
  never narrowing, when the diff cannot be determined).
- Makefile.cbm: cbm-third-party builds the vendored prod objects only.
- tests: the gate contract pins the new layout; the selector contract
  pins that a C change always selects the C scan, an undeterminable
  diff selects every language, and a vendored-only change retraces
  exactly the changed vendored files. Selector fixtures, ci-ok's job
  map, the replay's codeql-action failures (lane codeql-cpp) and the
  interface probes follow.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-20 23:09:09 +02:00
Martin Vogel 091f32086d Merge branch 'main' into fix/php-inline-html-2000 2026-10-20 19:30:06 +02:00
Ben Fairless 0c26a3cf56 Merge branch 'main' into feat/ruby-lsp-per-file 2026-10-20 19:23:08 +08:00
Martin Vogel a22271570e Merge pull request #2677 from DeusData/feat/deploy-graph-gaps
feat(deploy): render Helm images, mark default-valued images, link crds and werf charts
2026-10-20 06:34:12 +02:00
harshitaajoshi 09dc36d261 fix(extract): parse PHP past inline HTML so symbols after ?> reach the graph (#2000)
Signed-off-by: harshitaajoshi <j.harshitaa06@gmail.com>
2026-10-19 23:11:02 -05:00
Martin Vogel 67ff40d5cb fix(kotlin): resolve calls through typed class properties (#1555)
The cross-file Kotlin walk resolved a call on a typed method parameter by
type, but a call on a class property - a primary-constructor val, a body
property or `this.prop` - fell to the name guess. The cross registry held
each own-file class from its extraction defs, whose properties carry no type
(constructor vals none at all), and the walk's typed AST registration of the
same class was added behind that entry under the same QN, so every lookup
returned the field-less one. Constructor injection is the common Kotlin
dependency shape, so `repository.inserir(...)` on an injected port bound to
whichever same-named method the guess found, including an implementation of
another port (#1555).

The walk now registers the file's own declarations into an overlay chained
to the cross registry and checked first, indexed once the top-level
declarations are collected. The sole-definer fallback walks the whole chain
so its candidate set is unchanged.

Typing more receivers exposed resolution gaps that the untyped receivers had
hidden; each would otherwise turn a typed call into a wrong name guess:
- a member of the receiver class wins over a same-named extension of the
  same file (Kotlin resolution order; the overlay holds both);
- `x.hashCode()` / `toString()` / `equals()` on a receiver typed by another
  file: the per-file pass emits the kotlin.Any placeholder, the cross pass
  the declared override, and two targets at one occurrence are ambiguous to
  the call join. The per-file placeholder is dropped when the cross pass
  resolves the same occurrence;
- the same members on a stdlib or JDK type (`count.toString()` on an Int)
  resolve to the kotlin.Any builtin instead of a seeded stdlib member that
  has no graph node;
- a property READ on a typed receiver whose QN the graph spells differently
  (a nested class's property) never becomes a CALL_REFERENCE to a
  same-named function: the reference join falls back by name to
  non-callable targets only, which binds the property's own node;
- a typed value without an `invoke` operator (`private val handshake:
  Handshake?`) no longer shadows the same-named member function;
- inside a lambda whose typed receiver becomes `this` (`repo.let { .. }`),
  and inside a member extension, the enclosing class's members stay
  callable bare (the implicit-receiver chain); a call naming a class stays
  a constructor call.

Fixes #1555

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-18 16:42:30 +02:00
Martin Vogel d21949ef2c feat(deploy): render Helm images, mark default-valued images, link crds and werf charts
Four gaps of the deployment graph, closed together.

Images named from a default value keep their Image; the edge says so.
A Dockerfile FROM / COPY --from filled by an ARG default (an ARG chain
names each ARG) carries default_of, as do compose `${X:-d}` images and
`docker build -t ${IMAGE:-x}` tags. An override found in the repository
adds its own edge: compose build.args and --build-arg make the Image the
build names DEPEND_ON the base they choose {override_of}; compose's .env
replacing an inline default marks the effective edge override_of and keeps
the default as {ref: image_default}, an image the service does not run.

Helm template images render (helm_template.c): a bounded Go
text/template + Sprig evaluator over the vendored gotmpl grammar, with
values read the way Helm reads them (go-yaml v2 scalars, float64 numbers,
Helm's coalesce). Each templated container image renders from its chart
family's defaults -- include / define helpers, with / range / if, subchart
values under their alias, global -- and the object USES it {default_of:
the values keys read}; the chart DEPLOYS it. A value that does not render
(a .Release field, lookup, a missing define, a field of a missing map, a
function not modelled) names no Image; a rendered value is checked against
the image reference grammar first. Releases render their charts with their
values: a Flux HelmRelease's spec.values, a kustomize helmCharts entry's
valuesFile + valuesInline (a chart in chartHome now links locally), a
Terraform helm_release's values + set (literals only; set_sensitive is
never read) -- each image that differs is the release's own DEPLOYS
{override_of}. A release of a chart outside the repository names images by
convention only where its values' `repository` names a registry host
{inferred: values}; a host-less one names none.

A chart DEPLOYS the CRDs of its crds/ {phase: crds}. A werf `.helm` dir
beside werf.yaml is a chart named after the werf project.

Incremental runs: a werf.yaml edit and a werf chart's values / templates
decline like a Chart.yaml chart's; a release's values file (a kustomize
valuesFile, a Terraform file()) declines too -- Terraform's now IMPORTS
{local_name: values} it, like kustomize's valuesFile.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-17 21:14:39 +02:00
Martin Vogel 8df0639c62 Break-glass merge PR #2642 2026-10-14 23:56:37 +02:00
Martin Vogel 8b4d5e8b5b perf(store): in-memory adjacency layer for trace_path and degree filters
On a kernel-scale index (8.5M nodes, 16.9M edges) trace_path's recursive
CTE and search_graph's per-row degree subqueries spend seconds in B-tree
seeks. graph_mem reads the edges once, in one sequential scan of the
covering UNIQUE index, into a typed CSR (node id -> out/in neighbours with
interned edge types) and answers both from RAM:

- store_bfs (shortest-path mode): BFS over the layer with the CTE's exact
  semantics (minimal hop per node, the start only via a cycle back to it,
  (hop, id) order, probe row, JOIN-skips for ids without a node row); node
  rows and edge collection still come from SQL. Trail mode is unchanged.
- cbm_store_search with min/max_degree: the two correlated COUNT(*)
  subqueries become cbm_adj_degree(); filter, order, page and total are the
  same SQL.

Layers live in a process-wide registry (the daemon closes its stores after
every request), refcounted across request threads, allocated through the
memory core (CBM_MEM_CLASS_STORE) and bounded: all layers stay under a
quarter of the budget, idle ones are evicted oldest-first, and a layer that
does not fit is not built (SQL path, never a partial layer). A layer is
keyed by db path + store generation + the rollback-journal file state (the
header change counter every rollback commit bumps), read in one read
transaction with the scan; only read-only query stores of sealed DBs
qualify. The file state matters: the cross-repo pass writes CROSS_* edges
into other projects' published DBs in place without a new generation; such
a DB is in WAL mode and keeps the SQL path until the next publish.

Kernel, macOS, same index, fresh daemon: trace_path schedule 7.5 s -> 21 ms
warm (1.23 s first call incl. a 1.2 s build), search_graph Function
min_degree 50 4.2 s -> 170 ms warm (1.35 s first). Layer: 16,890,273 edges,
237 MB. Responses byte-identical to the baseline on django, redis and the
kernel (tools, Cypher and extra BFS/degree cases).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-14 22:19:02 +02:00
Martin Vogel ce0ed0e3b9 feat(infra): an Ansible playbook or task file IMPORTS what it includes
Ansible's composition produced no structure: kubespray's 40 playbooks,
roles and task files, tied together by 217 import_playbook /
include_tasks / import_tasks / include_role / import_role / roles:
directives, were unconnected YAML files.

A playbook or task file -- a YAML file whose top level is a sequence;
manifests, values, CI and compose files are mappings -- now IMPORTS
{local_name: <directive>, via: ansible, line} what each directive names:
import_playbook a playbook from its directory; include_tasks /
import_tasks / include a task file from its directory, else from its
role's tasks/; roles: items and include_role / import_role a role's
Folder, roles/<name> at or above its directory (a role by "./" / "../"
path from the directory). The ansible.builtin. prefix is understood; a
templated target links nothing.

Measured on 17 infrastructure repositories: 211 of 211 composition pairs
of kubespray against an independent reading, nothing else in any
corpus; deterministic over three runs; the incremental re-index equals
a full index in 4 scenarios (an included file edited or deleted, an
include pointed elsewhere, a playbook edited).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-14 18:25:40 +02:00
Martin Vogel 6316733532 feat(infra): a container's environment reaches its own program
The variables a container sets (K8s env, compose environment, Dockerfile ENV)
were container-scoped EnvVars of their own, joined to nothing: the readers of
a name point at the global EnvVar, which every program reading that name
shares, so a join through it was in the right program for 23 % of the pairs.

Each scoped EnvVar now CONFIGURES {strategy:env_read, dockerfile} the readers
of its name inside the files the container's image is built from:
- the image: a K8s container's literal image, built from exactly one
  Dockerfile (Image -DEPENDS_ON {via:build}->); a compose service's own build,
  else its image's; a Dockerfile's own ENV. A K8s image reference now names
  its container (USAGE {ref:image, container}), so a two-container pod joins
  each container to its own image.
- its files: the context sources COPY / ADD put into the final stage, the
  stages it is built FROM and the stages it copies from, resolved in the
  build context (the Dockerfile's directory or the repository root, the one
  the sources exist under), less the context's .dockerignore, never a test
  file. They are kept on the Dockerfile's Module (image_context, image_files,
  image_ignore).

pass_docker now reads COPY / ADD from the instruction's own text, as Docker
does: the grammar lost a JSON form opening with `/` and, after a word with a
trailing blank, took the following instructions for more sources.

Incremental: every run recomputes every join edge. A closure repair reads the
inputs of the files it leaves alone from the store and replaces the stored
edges wholesale; a .dockerignore (now a semantic-manifest control) changing,
or a deletion of a file an image copies, rebuilds in full.
CBM_SEMANTIC_INDEX_VERSION 8 -> 9.

Measured on 17 infrastructure repositories: 80 pairs, 80 correct by hand;
the graph matches an independent reading of the Dockerfiles 80/80.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-13 21:27:36 +02:00
Martin Vogel 77bc4927f9 fix(extraction): fold local URLs without changing topic identities
Refs #2291, #706, #1147. Preserve raw argument values and carry URL projections separately through compaction and spill.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-13 00:31:19 +02:00
Martin Vogel 2cd0956560 Break-glass merge PR #2597 2026-10-12 20:15:14 +02:00
Martin Vogel 8a7cbab13b Merge origin/main into feat/infra-graph
Brings in #2596 (MSan: hidden uninitialized reads) and #2068 (CodeAtlas
web).

README: main's CBM Atlas line and this branch's infrastructure-as-code
line are both kept.

tools/list metadata: main and this branch each stayed under the 20 KiB
discovery budget, but together they reached 20,809 bytes. The branch's
wording is shorter now (search_graph kind/namespace, one hint per trace
mode: 136 bytes less), and the reviewed budget is 21 KiB so the
topology/deploy/run modes keep their usage hints.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 19:07:18 +02:00
Martin Vogel 738cfebb60 fix(fuzz): link UBSan's C++ runtime into the fuzz binary
The cbm-fuzz rule links through $(CC), the C driver. On Linux, clang's C
driver links UBSan's C runtime but leaves out its C++ part
(ubsan_standalone_cxx), while the C++ objects (preprocessor.cpp and the
vendored simplecpp) carry -fsanitize=vptr checks. The link failed with
undefined references to __ubsan_vptr_type_cache and
__ubsan_handle_dynamic_type_cache_miss, so the fuzz job has never built in
CI since it was added (dry runs 37212102899 and 38186491924).

-fsanitize-link-c++-runtime on the link line pulls that runtime in.

Checked in an ubuntu:24.04 arm64 container with CI's packages (clang 18,
llvm, libclang-rt-dev):
- a minimal reproduction (a C++ virtual call under -fsanitize=undefined,
  linked through clang) fails with exactly those two symbols without the
  flag, and links and runs with it;
- `make fuzz` links cbm-fuzz (lsp_all.o was compiled with -g0 added: the
  12.5 GB container ran out of memory on it with full debug info, which
  CI's runner does not);
- macOS Homebrew clang accepts the flag under -Werror.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 06:31:53 +02:00
Martin Vogel 4d9592b5fb Merge pull request #2068 from DeusData/feat/codeatlas-web
CBM Lens Beta: graph exploration and architecture workspace
2026-10-12 05:38:30 +02:00
Martin Vogel 2d291002df Merge origin/main into feat/infra-graph
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 19:26:41 +02:00
Martin Vogel 0392068d49 Merge main into CBM Lens Beta
Reconcile the complete Atlas and Lens stream with current main while retaining both histories. Preserve architecture functionality, current process and watcher safeguards, test infrastructure, and dependency security updates. Add coverage for Git-environment isolation combined with child-local overrides.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 16:57:48 +02:00
Martin Vogel 2ec0185b9a feat(docker): a Dockerfile DEPENDS_ON the images it builds on
Dockerfiles were Module + ENV/ARG Variables only: the 261 FROM and
114 COPY --from lines of the infra corpora joined nothing, and build
files named for a variant were not indexed at all.

- pass_docker (new, end of the K8s pass): FROM <image> and
  COPY --from=<image> -> DEPENDS_ON {via: from | copy-from, image,
  stage, line} from the Dockerfile's Module to an Image node. ARG
  defaults are expanded (global ARGs in FROM, a stage's ARG / ENV in
  COPY); a stage (by name or index), scratch and an ARG without a value
  are no image.
- Image (new label, as approved): one node per repository, normalised
  (docker.io for no registry host, library/ for an official image, a
  registry host and port kept); tag and digest stay on the edge.
- Detection: Dockerfile.<x>, Dockerfile-<x>, Dockerfile_<x>,
  Containerfile[.<x>] and <x>.Dockerfile are Dockerfiles, unless the
  suffix is a language extension of its own (Dockerfile.j2 stays a
  Jinja template) or a BuildKit ignore file.
- QNs: a Dockerfile.<variant> keeps its suffix (fqn.c and helpers.c,
  which must agree); dropping it gave the variant the plain
  Dockerfile's QN, merging both Modules. Covered by this branch's
  index-format bump.
- Incremental: an Image no DEPENDS_ON / USAGE edge touches any more is
  dropped on both routes, like a Process without SPAWNS; the
  unreferenced-node GC takes a list of edge types.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 11:42:35 +02:00
Martin Vogel b8a5050813 feat(shell,ci): scripts and CI jobs SPAWNS the scripts they run
"Which CI jobs run hack/ci/run-e2e-tests.sh, and what does that script
start?" had no answer: a command running a script of the repository drew
no edge (SPAWNS reached Process nodes only, and repository scripts were
left out), and CI configurations were not read at all.

- A shell script, Make recipe or CI command that runs a script of the
  repository -- by its path (./hack/x.sh, "$ROOT/hack/x.sh") or through a
  shell (bash -e hack/x.sh) -- SPAWNS that script: its Module (the source
  of the script's own edges, so CI -> script -> deploy chains connect),
  else its File. The path must resolve to exactly one file; a program that
  is no repository file keeps its Process edge.
- A new pass_ci.c reads GitHub Actions workflows and composite actions
  (run: steps with their working directory, shell, env literals,
  ${{ github.workspace }} and ${{ github.action_path }}; no pwsh step, no
  step of a Windows job) and Prow job configs (container command + args,
  exec'd; bash -c TEXT as shell; a decorated job starts in the checkout).
  The shell layer evaluates them like a script; their DEPLOYS and SPAWNS
  edges come from the workflow / job file and carry "ci" and "job".
- env A="$X/y" PROGRAM: an assignment with an unknown value is no longer
  taken for the program (it made a Process named after the value's last
  segment and hid the program).

Measured on 17 repositories against an independent reading (libyaml for
the CI files, a separate shell reader for the commands): 292 of 292
script runs linked, 292 of 292 correct -- from Prow jobs (115 containers),
GitHub Actions steps, shell scripts and Make recipes, across 10
repositories (kubermatic, gardener, kube-hetzner, cluster-api, deckhouse,
k8s.io, ...); CI Process and deploy edges 4 of 4. Only SPAWNS (+295),
DEPLOYS (+1), Process (+3) and Chart (+1) changed; three runs build
identical graphs; index time unchanged (kubermatic 2.95 -> 2.93 s,
gardener 5.25 -> 5.25 s, kube-hetzner 1.13 -> 1.14 s, medians); editing or deleting scripts, workflows,
Prow jobs and Makefiles leaves the graph a fresh index builds (two
scenarios differ in SEMANTICALLY_RELATED edges and Make pattern-rule
nodes exactly as the previous build does).

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