Commit Graph
1926 Commits
Author SHA1 Message Date
Martin Vogel 337f868d68 fix(doc-links): compare a PDF hit's nodes through same_definition
cppcheck 2.20 in CI (x86_64) reports the name comparison in collapse()'s
duplicate-node loop as knownConditionTrueFalse ("always false") on main
5d4b50fe. It is a false positive: the loop compares s->v[i] with s->v[0]
for i >= 1, two different nodes. Neither the arm64 lint image nor a
--platform=unix64 whole-tree run reproduces it, so it is CI-only.

The file/line/name comparison moves into a same_definition() helper.
Behaviour is unchanged: the same three fields, the same NULL-as-empty
handling; doc-link suites 56 passed.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 22:07:43 +02:00
Martin Vogel 95555795e6 Break-glass merge PR #2478 2026-10-12 21:04:49 +02:00
Martin Vogel 4d582ad0bd fix(extract): walk nested syntax iteratively, bound the args formatter
Four syntax-tree walkers recursed once per nesting level of the indexed
file, so their stack use followed the depth of the parse tree rather than
anything bounded. They walk iteratively now, with identical results.

- terminal_callee_leaf (extract_calls.c) and its PHP LSP mirror
  php_reference_callee_leaf descended one wrapper node per frame on a
  callee such as ((((f))))(...). Both are loops now: each step either
  returns or moves to the child the search continues in, so the nodes
  visited and the leaf chosen are unchanged.
- cbm_collect_error_regions and cbm_mark_pp_error_rows (cbm.c) recursed
  into every child that contains an error. One cursor walk now drives
  both. It stops on exactly the visible children ts_node_child
  enumerated, in the same order, and never enters an ERROR subtree.
- is_direct_argument_value (extract_usages.c) moved from a labeled
  argument's value to the argument itself by recursing. The grammar bounds
  that step, but it is a loop now, taking the slow-parent test note once
  per level as before.

calls_append_args (pass_calls.c) formatted each argument into a 512-byte
local and assumed the result fit. An argument that does not fit now ends
the array like one the props buffer cannot take. The parallel twin formats in
place and already stops on truncation.

Indexing this repository's src/ and internal/cbm/ with and without the
change gives byte-identical sorted dumps of nodes, edges per type, CALLS
edges and parse-coverage rows.

CBM_WORKER_STACK_SIZE moves to worker_pool.h so the new extraction tests
run on a thread of exactly the pipeline's size, in a forked child on POSIX
so an overflow is a signal instead of a dead runner. They nest 200,000
parentheses around a first-class callable and around an invalid token,
pin the labeled-argument classification across the loop conversion, and
hand the formatter an argument longer than its local buffer.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 20:23:54 +02:00
Martin Vogel b0dd5af4a6 fix(pipeline): restrict PHP imports to matching project namespaces
Filter non-PHP candidates before selection and distinguish an empty namespace map from missing namespace information.

Refs #1186.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 20:20:14 +02:00
Martin Vogel 2cd0956560 Break-glass merge PR #2597 2026-10-12 20:15:14 +02:00
Martin Vogel 08be0289e3 Break-glass merge PR #2610 2026-10-12 20:14:27 +02:00
Martin Vogel 78a67e3ea7 Break-glass merge PR #2607 2026-10-12 20:13:58 +02:00
Martin Vogel a90076a30d Break-glass merge PR #2608 2026-10-12 20:12:55 +02:00
Martin Vogel b1c61b21f1 Break-glass merge PR #2609 2026-10-12 20:12:24 +02:00
Martin Vogel d3b8d258be feat(index): doc_candidates setting and index_repository parameter
The doc<->code candidate scoring (#2574, doc_section_worker in
semantic_edges) scores every documentation section against the functions
that share a key term with it, key terms being those held by at most
funcs/20 functions. Its cost therefore grows with sections x functions.
Measured on 11 corpora (10-09 main vs 4d9592b5, semantic_edges): under a
second up to ~100k functions, +12.6 s on java (325k), +14.6 s on csharp
(451k), +174 s on the Linux kernel (784k functions, 28k sections), almost
all of the kernel's regression against v0.11.0.

A new boolean setting, doc_candidates (default true), and an optional
index_repository argument of the same name switch the scoring off: no
candidate rows are stored and nodes and edges are unchanged. The argument
wins over the setting. The index handler resolves the value once and
passes it to a daemon job or supervised worker as an argument, the same way
as the resource policy, so every route sees one decision; the session
auto-index reads the setting. With the switch off, a delta-route reindex
replaces the candidate rows it would otherwise keep, so turning it off
leaves no stale candidates. The default output is unchanged.

Tests (each fails on its assertion when the switch has no effect):
- pipeline_doc_candidates_off_stores_none_and_keeps_graph: no rows, same
  node and edge counts as the default run, which has rows;
- pipeline_doc_candidates_off_clears_rows_on_delta: a closure-repair
  reindex with the switch off removes the earlier rows;
- tool_index_repository_doc_candidates_switch: argument false -> none;
  setting default -> rows; setting false -> none; argument true over
  setting false -> rows.

Proof, release-built binaries on macOS arm64 (M5 Pro 18c/48 GB):
- django, main 4d9592b5 vs this change with defaults: nodes (63,441),
  edges (307,584) and doc_link_candidates rows (11,304) hash-identical;
- django with doc_candidates false: nodes and edges hash-identical, no
  candidate rows;
- Linux kernel with doc_candidates false: semantic_edges 17.9 s (191.9 s on
  main, 17.6 s before #2574), whole index 210.9 s (v0.11.0: ~234 s), no
  candidate rows.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 19:45:10 +02:00
Martin Vogel 2aeaabd51b refactor(discover): run git ls-files without a shell
Discovery reads the tracked-file set through the supervised subprocess
API instead of cbm_popen, so no shell parses the command:

- git is resolved to an absolute path from absolute PATH entries only
  (cbm_test_impact_find_git), never the current directory;
- the repository path is a single argv entry;
- the child environment drops repository-local variables, so an
  inherited GIT_DIR cannot redirect -C;
- core.fsmonitor is off for the call;
- stdout goes to a private mkstemp file that is read and removed.

discover.c needs no entry on the security allow-list.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 19:41:36 +02:00
Martin Vogel 2efbdd9852 test(doc_mentions_go): make the fixture index name the step it is in
The 2026-10-12 dry run (run 38186491924, windows-11-arm 2/2) killed
doc_mentions_go at the 900 s wall clock. The test framework prints a test's
name before running it, so the last line shows the hang was in
doc_mentions_go_local_rules, before the pipeline's first info line
(pipeline.discover). Nothing in the log says which step. The hang has not
come back: 0 of 32 runs on a local Windows arm64 VM, and the next CI
sample passed (run 38204190338, 80 s).

The steps before discovery have no deadline: the fixture's temp
directory, the fixture writes, three `git` children per index (git context
in cbm_pipeline_new and again in the run), staging, the coverage check and
the test config. This change makes each of them name itself at debug level,
and the Go suite's fixture index runs at debug level, so a recurrence ends
on the step it is stuck in:
- git_capture: spawn / read / close / done, with the git arguments;
- cbm_pipeline_run and its staged run: stage, staged, coverage,
  git_context, test_config, discover;
- go_index_lookup: mkdtemp, fixture, index; it raises the level to debug
  and restores the caller's level afterwards.

Debug level is otherwise unused on the indexing path, so the default
output does not change and only this suite's fixture indexes print the
markers.

Checked: doc_mentions_go passes 23 of 23 on macOS and on a Windows arm64
VM (win.sh test), each printing the same markers in order: 30 from the
helper, 60 pipeline setup steps and 120 git stages (10 indexes, 3 git
children each). clang-format is clean. CI's cppcheck 2.20 reports one style
finding in git_context.c (buf_size > 0 always true), which main has too, in
a function this change does not touch.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 19:11:19 +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 e53bcce43c fix(discover): a .gitignore never hides a file git tracks
git applies ignore rules to untracked paths only, but discovery applied
them to every path. A nested .gitignore line `manager`, meant for a
built binary, hid cluster-api's tracked config/manager/ kustomization,
and with it the Deployment its overlays point at.

When the indexed directory is in a git repository, discovery now reads
`git ls-files -z` once. A directory that git's rules ignore (.gitignore
files, info/exclude, the global excludes file) is still entered when it
holds tracked files. Inside it, untracked files and directories stay
ignored, as in git. A tracked file is kept although a rule matches it.
The built-in skip list, .cbmignore and the size cap apply as before. If
git cannot run, nothing changes.

On the 17 infra corpora git lists 34 tracked files that an ignore rule
matches. The fix indexes 26 of them, all from that list. The other 8 are
never indexed for other reasons: no language (.tfvars, .gitkeep) or a
built-in skip directory (vendor/). No file is lost and no untracked
file appears. cluster-api gains the manager kustomization (4 Resources,
its overlay IMPORTS), helm-charts a Chart, and otel-demo a Route.

Test: discover_gitignore_never_hides_tracked_files builds a real git
repository. It fails without the fix.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 19:07:09 +02:00
Martin Vogel cfab5d75f6 fix(graph): the id counter is never lowered after a parallel phase
After a parallel extract or resolve, the main buffer's counter was set to
the shared allocator's value. Merged worker nodes keep their shared ids,
and merged edges take fresh ids from the main counter after the highest
of them, so the main counter can end above the shared one. Setting it
down handed the merged edges' ids out a second time.

All four sync points (full route and closure repair, after extract and
after resolve) now go through cbm_pipeline_sync_next_id, which only
raises the counter. The delta preseed still pins it with
cbm_gbuf_set_next_id, as before.

On the 17 infra corpora the old sync left 94,239 duplicate edge ids in
the buffer (11 corpora; deckhouse 44,959), and the fix leaves none. The
persisted graph does not change, because the dump numbers edges itself.
The duplicates matter to anything that finds buffer edges by id:
cascade_delete_edges unindexes by id and then frees the edge, so a
duplicate can leave a freed edge in an index.

Tests: a parallel full index with the counters pinned by a test seam
fails with a duplicate edge id without the fix. Both full-route and both
closure-repair syncs are checked to run through the helper.
gbuf_raise_next_id_never_lowers covers the new buffer call.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 19:06:56 +02:00
Martin Vogel 70543ba829 fix(cypher): free a partially parsed MATCH pattern
parse_match_pattern allocated the pattern's node and relationship arrays
and returned on a parse error without freeing them. Its callers count a
pattern only after it parsed, so cbm_query_free never saw it: every query
whose pattern failed partway leaked, including every named path
(`MATCH p = (...)`, not supported, fails at the first node). The element
whose parse failed leaked too (its variable, label or properties), and
parse_props freed only the array, not the entries it had already parsed.

The fuzz job found it on its first run, from a checked-in seed:
`MATCH p = (a:Class)-[:INHERITS*1..3]->(b:Class) RETURN a.name, length(p)`
(LeakSanitizer: 288 bytes in 2 allocations).

parse_match_pattern now frees and zeroes the pattern on every failure,
counting the failed element (parse_node and parse_rel zero it first, so
only what they allocated is freed). parse_props frees its parsed entries
on every failure through one helper.

New test cypher_parse_error_frees_partial_pattern drives five failure
points: a named path, a property list after one entry, a cut-off
relationship, a missing label after a relationship, and a second MATCH
clause's properties.

Checked with the fuzz binary (clang 18 ASan/LSan, arm64 container) on the
five queries: before this change the first four leak (288, 306, 339 and
348 bytes); after it all five are clean, and scripts/fuzz.sh all --runs
20000 --seed 1 passes for extract, cypher and config. The fifth goes
through the same parse_props failure as the second. macOS: the cypher
suite passes, 217 tests.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 06:31:53 +02:00
Martin Vogel a67a3f417a fix(sha256): build the ARMv8 SHA2 path with GCC 11
GCC 11's arm_neon.h declares the SHA2 intrinsics under
`#pragma GCC target ("+nothing+crypto")`. sha256_blocks_arm was marked
`target("+sha2")`, a narrower target, so GCC 11 refused to inline
vsha256hq_u32 and friends ("target specific option mismatch") and the
build stopped. GCC 13 accepts "+sha2", which is why PR CI (ubuntu-24.04-arm)
stayed green; the dry run's ubuntu-22.04-arm leg (GCC 11) failed on all
three shards (run 38186491924).

GCC now gets "+crypto", which implies "+sha2" on every GCC. The function
still uses only SHA2 instructions, and the runtime HWCAP check gates it.
clang keeps "sha2".

Checked in arm64 containers:
- sha256.c with CI's ASan/UBSan flags compiles on GCC 11, 12, 13 and 14;
  GCC 11 with "+sha2" fails with the CI errors;
- a known-answer harness ("abc", "", a 1 MiB pattern) matches hashlib on
  the arm-sha2 backend and the forced portable backend, GCC 11 and 14,
  -O0 and -O2.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-12 06:03:54 +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 5d10cb7af7 fix: make Lens settings and impact history portable
Normalize Windows cache paths when reporting runtime settings and resolve
Git executables before spawning history queries. Keep executable lookup
results per thread and cover the ownership contract deterministically.

Support Git 2.43 while denying history-query network transports, and close
the activity database on daemon startup failure so Windows can clean up.

Validation: 463 native macOS tests, 421 Windows tests, 44 MSan UI tests,
and focused canonical lint passed. Production-only revert checks confirm
the repaired failures.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 23:14:24 +02:00
Martin Vogel 2522a06c6d fix(discover): a short file name is read no further than its end
The Dockerfile-variant check read the character after "Dockerfile" /
"Containerfile" before it knew the name held that base, so every name
shorter than the base was read past its end. GCC's AddressSanitizer
caught it once the doc-link layer began asking the language of short
code file names (a.go): 27 to 51 suites aborted per Linux shard. The
base is compared first now.

The test passes each short name in a heap block of exactly its size;
under GCC ASan it fails without the fix (heap-buffer-overflow in
lang_dockerfile_variant).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 22:11:56 +02:00
Martin Vogel 7b379f05b8 fix(infra): no identifiers Windows headers define as macros
winbase.h defines IGNORE and minwindef.h defines IN, so the Windows
build failed on the Dockerfile-variant suffix in language.c and the
Image reference edge types in pass_docker.c. Renamed to DOCKERIGNORE
and REF_TYPES.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 20:25:42 +02:00
Martin Vogel a19d7a45fb Use memory core for Lens response ownership
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 20:16:34 +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 4587fd2848 feat(mcp): trace_path run mode; the container layer documented and guarded
trace_path mode=run walks what a Service or workload runs: traffic to
the workload (INFRA_MAPS), the Image its container runs (USAGE), the
Dockerfile that builds it and what that builds on (DEPENDS_ON), the
program its ENTRYPOINT starts (SPAWNS) and the environment each
container is given (CONFIGURES) -- Service -> Deployment -> Image ->
Dockerfile -> main in one call.

The README lists the Image label, the container edges (a Dockerfile's
bases and entrypoint, image references, the build vias, compose
services, container environment) and the new mode.

The complexity guard gets the container layer: a fixture with
multi-stage Dockerfiles, an ENTRYPOINT script and a compose project
building two components of one repository, its nodes and edges gated
linear per copy, and the Image edges the component split examines
gated linear too -- every copy's builds join one repository Image by
design, so that join must stay linear.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 19:26:10 +02:00
Martin Vogel 5ff46cde09 Fix Lens configuration lint diagnostics
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 19:03:41 +02:00
Martin Vogel 231bcbf6f5 feat(docker): a repository built per component splits into component Images
An image is its repository, tag and digest on the edges -- until one
repository is built from several Dockerfiles, one per component tag:
opentelemetry-demo builds every service as
ghcr.io/open-telemetry/demo:<version>-<service>, so its one Image was
built from 25 Dockerfiles and a walk from any service through the image
reached all of them.

Such a repository is now split by component: its build tags without
their common prefix / suffix (cut at separators -- latest-frontend,
latest-cart -> frontend, cart). A component built from exactly one
Dockerfile, with no unknown part, becomes an Image of its own,
`<repo>:*-<component>` {repository, component, tag_pattern}; its build
edges leave from it, and every reference whose tag names a component (a
K8s container, a compose service, a FROM) uses it -- whatever its
version, the longest component a tag holds as whole parts, none on a
tie. Everything else stays on the repository Image, which goes when no
edge is left (now on the full route too). Recomputed whole each run.

A closure repair cannot re-point the references of files it does not
repair, so when the run's component Images differ from the previous
ones it hands over to a full rebuild.

Edges are deleted by pointer (cbm_gbuf_delete_edges): after the
parallel resolve merge, cbm_gbuf_set_next_id can hand an edge id out
twice, and a delete by id took unrelated edges with it.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 18:49:18 +02:00
Martin Vogel cf41bdc6d6 Secure Lens history reads and verify shipped browser dependencies
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 18:12:30 +02:00
Martin Vogel 4ed6064c31 feat(infra): the environment a container is given is its own EnvVar
Each variable a K8s container's env (containers, initContainers,
ephemeralContainers at any depth), a compose service's environment (map
or list) or a Dockerfile's last stage ENV (with the stages it is built
FROM) sets is now an EnvVar of that container -- of the image, for ENV:
`<owner QN>#env/<container | ->/<name>` {env_key, scope, container,
source}, owned by the declaring file, and the owner CONFIGURES it
{strategy: env_set, source, line}. `source` says where the value comes
from (value, configMapKeyRef, secretKeyRef, fieldRef, resourceFieldRef,
fileKeyRef, compose, dockerfile); the value itself is never read into
the graph.

Two containers setting PORT are two nodes, and neither is joined to the
global EnvVar PORT a program's readers share: the same name is read by
other programs (measured on 17 infra repositories, a join through the
global node is in the setter's own program for 23 % of the pairs).

Docker drops comment lines before it joins continued lines, but the
grammar ends an instruction at one; the Dockerfile pass now reads such a
comment line as a bare continuation (rows and offsets unchanged), so
`ENV A=1 \` / `# url` / `B=2` sets B too.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 17:46:07 +02:00
Martin Vogel 08e0474a36 Harden CBM Lens integration against current main
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 17:35:04 +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 afeaca0217 Complete child-local environments and ObjectScript parse deadlines
Merge validated environment overrides into a child-owned environment on POSIX and Windows, preserving caller PATH lookup for executable names. Forward each ObjectScript export parse timeout to the extractor.

Cover inherited and replaced values, empty values, duplicate overrides, parent isolation, invalid names, executable lookup, and timeout forwarding.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 16:33:38 +02:00
Martin Vogel 21332dd8f1 feat(shell): a container build command builds its images from the Dockerfile
docker / podman / nerdctl [buildx | image | builder] build and buildah
bud in a script, a Make recipe or a CI step now say which Dockerfile
builds which image: each -t / --tag image DEPENDS_ON {via: build, tool:
docker-build, file, image, line} the Dockerfile -f names (against the
cwd the shell layer tracks), else <context>/Dockerfile -- one file of
the repository, as for every other path of the layer.

The repository is the image's identity, so a tag of unknown value keeps
it: $(DOCKER_REPO)/etcd-launcher:$(TAG) with TAG from git still builds
quay.io/kubermatic/etcd-launcher (the word is cut at the tag's ':' after
its last '/', outside $( ) ${ } and backticks, and only that part is
evaluated; a registry port is no tag). An unknown context or Dockerfile
is no build. Make recipes mentioning a container tool are parsed.

These edges, like every image build edge, are recomputed whole each run.
An incremental run reads again the files that run a container build:
the shell pass marks their File node {"declares_build": true} (resolved
or not), the closure route reads the marks from the staging store, the
full-load route from its buffer -- a mark per file, so a second file
building the same image keeps the edge when the first goes.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 16:06:18 +02:00
Martin Vogel 72b8176ffe feat(docs): a diagram section's candidates carry its diagram family's p
A Markdown section that embeds a diagram is about its candidate functions
more often than the Markdown curve says, by how much depends on the
diagram's kind. 553 candidates from such sections in 16 held-out
repositories, judged blind in three rounds:

                 0.20-0.30  0.30-0.40  0.40+  local extras
  prose            0.24       0.28      0.45     0.275
  structural       0.32       0.46      0.57     0.78 (9 items)

Structural is Mermaid sequence/class/ER/C4/architecture and PlantUML
C4/class/sequence/use-case/component; prose any other Mermaid or PlantUML
kind. A section takes the highest family of the Diagram nodes it defines;
its function candidates at or inside the doc's home and its local extras
carry the family's value, and the first band is now stored. Outside
functions, files, folders, other formats and sections without a diagram
keep the Markdown curve.

On kubernetes' apiserver folder the sequence-diagram section's
candidates move from 0.22/0.51 to 0.46/0.57, the flowchart sections gain
five first-band candidates at 0.24, other sections and the graph are
unchanged.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 15:46:00 +02:00
Martin Vogel ccf28b676c feat(compose): a compose service is a Resource with its image, build and dependencies
Compose files produced no service nodes: 156 services, 108 depends_on
and links, 98 images and 69 builds in the infra corpora joined nothing.
A compose service is now a Resource {ecosystem: compose, kind: Service}
(QN <file>::compose/Service/-/<name>, the file DEFINES it, its own line
span), and it

- DEPENDS_ON {via: depends_on} the services of the same file its
  depends_on (a list, or a mapping's keys) and links name;
- USAGE {ref: image} the Image of its image (.env interpolated);
- DEPENDS_ON {via: build, tool: compose} the Dockerfile its build names
  (a context, or context + dockerfile).

With the Dockerfile's SPAWNS, a compose service now reaches what its
container runs: on opentelemetry-demo checkout and product-catalog
reach their Go main, payment / quote / agent / chatbot / mcp their
entry scripts.

pass_ci.c: one compose walk serves cbm_build_sites and the new
cbm_compose_services; pass_docker.c makes the nodes (first pass) and
their edges (second).

Incremental: a compose service is a Resource but no K8s bundle input,
so a compose edit stays a closure repair; a changed .env beside a
compose file feeds its images and builds and declines to the full
rebuild.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 14:59:45 +02:00
Martin Vogel cbe2b420d6 feat(docker): an image a skaffold or compose file builds DEPENDS_ON its Dockerfile
The image a workload runs and the Dockerfile that builds it were not
joined: Service -> Deployment -> Image stopped there. Build
configurations now say which Dockerfile builds which image:

- skaffold: build.artifacts (top level and profiles) with the docker
  builder -- image, context (default the file's directory),
  docker.dockerfile (default Dockerfile, relative to the context);
  ko / jib / bazel / buildpacks / custom / kaniko artifacts are none.
- compose: services with build (a context, or context / dockerfile)
  and image; ${X}, ${X:-d}, ${X-d}, $X from the project's .env.

Each becomes Image -DEPENDS_ON {via: build, tool, file, image, line}->
the Dockerfile's Module (pass_ci.c reads the YAML, pass_docker.c
links). On microservices-demo the chain is now whole:
Service/frontend -> Deployment/frontend -> Image frontend ->
src/frontend/Dockerfile -> main (src/frontend/main.go).

These edges belong to the build configuration declaring them, not to
either end, so every run recomputes them whole from all build files
(read through the File nodes, on every route): the incremental routes
drop the old set first (the staging graph before the delta patch, the
full-load buffer before the inbound-edge capture), and the delta patch
writes them even between nodes that both pre-existed.
cbm_gbuf_delete_edges_from_label / cbm_delta_drop_edges_from_label
delete a type's edges by source label.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 14:00:29 +02:00
Martin Vogel 75b98a4c55 Merge main into feat/doc-links-languages-diagrams
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 13:51:56 +02:00
Martin Vogel 9ae9266135 feat(k8s): a workload USAGE {ref: image} the Image its containers run
A Kubernetes object running a container now links to the Image of its
literal image reference: containers, initContainers and
ephemeralContainers at any depth, so pod templates of workloads,
CronJobs and custom resources all count. It is the node a Dockerfile
building on, or building, that image joins -- the run half of
Service -> ... -> main().

- extract_k8s: a new CBM_K8S_FACT_IMAGE for a literal image leaf;
  a shell substitution ($(X), ${X}) or a template expression is none.
- pass_k8s: the facts become USAGE {ref: image, image} edges from the
  object's Resource to the shared Image node.
- pass_docker: cbm_pipeline_image_node() is the one place an image
  reference becomes an Image (normalised repository); a reference with
  a character no image reference can hold -- a Helm template's
  placeholder such as <.Values.image.repository> -- is no image.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 12:52:59 +02:00
Martin Vogel 3b498cf15f feat(docker): a Dockerfile SPAWNS what its container runs
The last stage's ENTRYPOINT (else CMD) of a Dockerfile now SPAWNS
{api: dockerfile, instruction, program, line} what the image runs:

- the Go main of the package a stage built with `go build -o OUT PKG`
  and the image copied in (COPY --from=<stage>, followed across
  stages; a file package, a directory, or the .go files copied into
  it);
- the repository file it runs: an interpreter's script (python, node,
  php, ...), a copied script by path, or a CMD file under an inherited
  ENTRYPOINT (distroless node / python);
- otherwise the program's Process.

Container paths map back through COPY and WORKDIR. A context source is
looked up under the Dockerfile's directory and the repository root;
the one candidate that is the file (or Go main package) wanted wins,
two or none are no edge. `sh -c`, a variable program and arguments to
an inherited ENTRYPOINT are no edge. ARG / ENV expand COPY paths and
go build -o / package arguments.

This closes the Dockerfile half of Service -> ... -> main(): on
microservices-demo every Go service Dockerfile reaches its main and
every Python / Node one its server script.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 12:13:28 +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 a48852d77e perf(terraform): find a helm_release block by its QN; gate the Phase 3 resolvers
The complexity guard did not cover the shell, Make, CI, Terraform and
chartRef resolvers. Extending it found one quadratic lookup: a
helm_release's block node was looked up among every node of that name
and walked for the one in the same file, so modules sharing a release
name (the common `helm_release "this"`) made each lookup scan all of
them. tf_candidates went 12 -> 42 per doubling (3.50).

- pass_terraform: look the block up by the QN its definition got
  (cbm_fqn_compute + cbm_gbuf_find_by_qn), keeping the file check.
  6 -> 12 (2.00). Output identical on the three corpora with
  helm_release; incremental equals full.
- Counters: g_tf_candidates (new), Make rule probes into
  g_sh_candidates, chartRef in-edges into g_k8s_candidates.
- test_complexity: the fixture copier recurses into directories; new
  fixtures Bash (composite action -> make -> scripts -> kubectl / helm),
  HCL (helm_release of a module chart and of an external one), a Go
  chart loader, and a Flux HelmRelease chartRef; sh_candidates and
  tf_candidates are gated (non-vacuous, ratio), with fx_Bash and
  fx_HCL nodes and edges.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 10:46:49 +02:00
Martin Vogel 932e5a9f57 feat(mcp): trace_path deploy mode; topology follows DEPLOYS
The DEPLOYS and SPAWNS edges of the infrastructure layer had no trace
preset: "which CI job, through which script, installs this chart?" took
hand-picked edge_types.

- trace_path mode=deploy walks DEPLOYS, SPAWNS and CALLS: outbound from
  a CI job, script or Make rule to the scripts, make targets and programs
  it starts and the manifests, kustomizations and charts it deploys;
  inbound from a chart back to the job.
- mode=topology also follows DEPLOYS, so a Flux Kustomization reaches the
  kustomization its path applies and a HelmRelease its chart.
- README: the DEPLOYS edge type, make targets under SPAWNS, the trace
  modes.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 10:16:00 +02:00
Martin Vogel 77f328300c feat(k8s): a HelmRelease with chartRef DEPLOYS the chart its OCIRepository fetches
A Flux HelmRelease that names its chart through `spec.chartRef` (kind
OCIRepository) instead of `spec.chart.spec` drew only a USAGE edge to the
OCIRepository: "which releases deploy chart X" had no answer for it. In
onedr0p/home-ops every one of 68 releases is written this way.

The K8s extractor now records the URL an OCIRepository fetches; the K8s
pass follows each HelmRelease's resolved chartRef to that repository and
draws DEPLOYS to the shared external Chart of the oci:// URL's last
segment (properties: via helmrelease, chart, external, url). A URL with
a variable, or a chartRef naming no repository, draws no edge.

Measured on 17 repositories against an independent reading of the Flux
objects: GitOps DEPLOYS 199 of 199 linked and correct (was 129 of 164;
home-ops 160, flux2-kustomize-helm-example 3). Only DEPLOYS (+70) and
external Charts (+44) changed; three runs build identical graphs;
index time unchanged (deckhouse 9.63 -> 9.60 s, k8s.io 3.71 -> 3.70 s,
home-ops 0.88 -> 0.87 s, medians); editing the OCIRepository's URL, the HelmRelease's chartRef,
or deleting the repository leaves the graph a fresh index builds.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 09:36:37 +02:00
Martin Vogel 459af04cb6 fix(cli): name the failing update step and its OS error
On macOS the signed-candidate preparation folded every step into one
boolean, so each failure printed the same line: "signed update candidate
preparation failed". A full /tmp read exactly like a broken codesign. That
is what a cli test hit on 2026-10-09, while a multi-GB index was filling a
nearly full disk.

Each step now records why it failed, and the update prints, for example:

  error: signed update candidate preparation failed while writing the
  unsigned candidate: No space left on device

The staging functions in activation_transaction.c keep the errno of the
failing write (or sync, close, read) through their cleanup, so a caller can
name it. The non-macOS path adds the OS error to its existing "failed to
stage verified update" line (POSIX only; Windows reports through
GetLastError). A failed fingerprint of the staged file now gets its own
message instead of "...: activation transaction completed".

A test seam makes the next staging write fail with a chosen errno. The new
test cli_update_names_the_failing_staging_step_and_os_error fails without
the cli.c change and passes with it, and checks that the old executable
stays in place. Also checked on real input: with /tmp on a small volume
that fills between two updates, the update prints the line above.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 09:00:23 +02:00
Martin Vogel cb497a8218 fix(incremental): drop Process nodes no SPAWNS reaches any more
A Process node exists only as the target of a SPAWNS edge (a call or a
shell command starting a program) and belongs to no file. When the last
file starting the program was deleted or edited, an incremental re-index
removed the edge but kept the node, which a full index never makes: the
two diverged (gardener: deleting hack/tools.mk left install-promtool.sh
and install-protoc.sh behind).

Both incremental routes now drop such nodes: the full-load route on its
in-memory graph before the post-passes (new
cbm_gbuf_delete_unreferenced), the closure-repair route on the staging
database right after the patch, the first point where that route sees
the whole graph (its in-memory buffer holds no edges).

A full index is unchanged on 17 repositories (all graphs identical).
Deleting a makefile included by another, a script CI jobs run, or a
makefile a recipe makes into now leaves the graph a fresh index builds,
apart from SEMANTICALLY_RELATED edges, which differ as before.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 09:00:14 +02:00
Martin Vogel 7842cd8a69 fix(make): a node per rule target; target-variable lines are no rules
Make rules were read with three gaps:

- A rule naming several targets (`seed-up seed-dev seed-down: ...`,
  `kind-% seed-%:`) became one Function named after its first target:
  `seed-down` had no node, so nothing could link `make seed-down` and a
  search for it found nothing. Every target now gets a Function over the
  rule's span (without fingerprint, structural profile or body tokens, so
  the copies of one recipe do not read as similar code), and the recipe's
  DEPLOYS / SPAWNS edges leave from each of them.
- A target-specific variable line (`kind-%: export X := y`) was taken for
  a rule: a phantom Function for its first target, or a variant span
  merged into the real rule of that name. Such a line is no rule now. Its
  tree-sitter ERROR region is no longer masked, so the file reports it
  as partially parsed, as for any other unparsed region.
- `include hack/tools.mk` imported a Folder `hack/tools` (local name
  "mk\n\n": the generic import reader kept the directive's newlines and
  split at the extension). Make includes are read on their own now: every
  name of include / -include / sinclude, outside recipes, imports that
  file; a name with a variable reference is left out.

Measured on 17 repositories against an independent reading: make runs
linked 298 of 300 (was 282), all 298 correct; the 2 left pick their
target in an if/else, which stays unknown by design. Graph changes are
confined to Makefiles (gardener +26 targets, 13 phantoms removed;
deckhouse +4), their edges, and two side effects of new nodes:
SEMANTICALLY_RELATED edges elsewhere re-rank, and one Go member
reference in deckhouse lost its unique-name binding to a new Make rule
of the same name. Three runs build identical graphs; index time unchanged (deckhouse 9.61 -> 9.60 s,
gardener 5.24 -> 5.27 s, cluster-api 2.68 -> 2.68 s, medians);
renaming a target, editing a Makefile or an included file leaves the
graph a fresh index builds (gardener's Makefile edit differed before,
through the phantom nodes, and no longer does).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 08:30:28 +02:00
Martin Vogel b080e982de feat(shell): make TARGET SPAWNS the rule of TARGET
"Which CI jobs and scripts run `make verify`, and through which
makefile?" had no answer: a `make` command drew no edge.

- make [-C DIR] [-f FILE] [VAR=V] TARGET... -- from a shell script, a Make
  recipe ($(MAKE), which is make unless the makefile sets it) or a CI step
  -- SPAWNS the rule node of each TARGET: in the makefile make reads (the
  first -f, else GNUmakefile / makefile / Makefile of the directory, -C
  cumulative, resolved like any path to exactly one), else in the files
  it includes, in reading order. Includes are read when linking, with the
  makefile's variables, so an unchanged makefile is followed too. An
  unknown -C / -f value, an unknown or ruleless target, and a bare `make`
  draw no edge. Properties: program make, path (the makefile), target.
- A Make variable whose value spans backslash-continued lines is folded to
  one line, as make reads it: expanded into a recipe line it added lines,
  so every later command of that line was attributed to a later rule.

Measured on 17 repositories against an independent reading (its own make
argument parser and rule / include reader): 282 of 300 make runs linked,
282 of 282 correct (cluster-api 115, kubermatic 72, gardener 56,
otel-demo 21, deckhouse 17, k8s.io 1). The 18 not linked are targets that
are not the first of a multi-target rule (`seed-up seed-dev seed-down:`),
which have no node of their own yet. Only SPAWNS (+282) changed; three
runs build identical graphs; index time unchanged (cluster-api 2.67 ->
2.67 s, gardener 5.24 -> 5.24 s, kubermatic 2.94 -> 2.95 s, medians);
renaming or adding a rule,
editing the command or the workflow leaves the graph a fresh index
builds (deleting a makefile differs only in SEMANTICALLY_RELATED edges,
as the previous build does).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 07:39:09 +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
Martin Vogel a197d0c684 feat(terraform): a helm_release DEPLOYS its chart
A Terraform module installing a chart with `resource "helm_release"` had no
edge to the chart: "which modules install this chart" had no answer.

A new Terraform / OpenTofu pass (run at the end of the K8s pass, like the
shell pass) reads the helm_release blocks of .tf / .tofu files and links,
to existing nodes only, from the block's node (resource.helm_release.<name>):
- chart = "./charts/x" or "${path.module}/charts/x": the Chart of that
  directory of the module;
- a repository and a chart name, or chart = "oci://.../<name>": the shared
  external Chart of that name (the node chart dependencies use).
Values are read from string literals and ${path.module} only; a variable
chart, or a directory without a Chart.yaml, is no edge. Properties: via
terraform, the chart, external, line.

Measured on 17 repositories against an independent reading of the
Terraform files: 21 of 21 releases linked, 21 of 21 correct (EKS
blueprints 17, k8s.io 3, kube-hetzner 1). Only these DEPLOYS edges and 8
external Charts were added; three runs build identical graphs; index time
unchanged (cloud-foundation-fabric 1.91 -> 1.89 s, EKS blueprints 0.87 ->
0.88 s, k8s.io 3.44 -> 3.45 s, medians); editing or deleting the files
leaves the graph a fresh index builds.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 05:27:23 +02:00
Martin Vogel ae93174b70 feat(go): an installer's chart loads DEPLOYS the charts it installs
"Which charts does the kubermatic installer deploy?" had no answer in the
graph: pkg/install loads each chart with
helm.LoadChart(filepath.Join(opt.ChartsDirectory, MonitoringChartsPrefix,
NodeExporterChartName)) and installs it, and nothing linked the function to
the chart directory.

The Go operator pass now reads chart loads: a call of a chart loader --
the Helm SDK's loader.Load / loader.LoadDir, or a top-level function of the
repository whose body reads <param>/Chart.yaml or hands its parameter to
the SDK loader -- DEPLOYS {via: helm-sdk, chart, line} from the calling
function to the Chart its argument names. The argument is evaluated over
string literals, the package's constants (an imported package's through
the file's imports), filepath.Join / path.Join, + and a local assigned
once in the function; a parameter stays unknown. A leading unknown part
(a charts root chosen at run time) leaves a known tail: linked to the one
chart directory ending with it, or, when two do, to <root>/<tail> where the
other loads under the same root expression put that root (property
"root").

Measured on 17 repositories against an independent reading of the Go
sources (its own constant evaluation, imports and suffix matching): 33 of
33 chart loads linked, 33 of 33 correct, all in kubermatic (27 installer
functions, every chart-name constant of pkg/install that the installer
loads; 6 integration tests loading testdata charts). Only these DEPLOYS
edges were added; three runs build identical graphs; index time unchanged
(kubermatic 2.94 s, gardener 5.22 -> 5.24 s, deckhouse 9.62 -> 9.59 s,
medians). Files mentioning a chart are summarized as they are read and
read again only when a loader exists.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 05:03:19 +02:00
Martin Vogel 352d047782 feat(shell): programs a script starts by path SPAWNS their Process
"Which scripts drive kubermatic-installer?" had no answer in the graph: a
script running ./_build/kubermatic-installer deploy ... or a Make recipe
running $(CONTROLLER_GEN) starts another program, and the call resolvers
draw SPAWNS for that only in code with a spawn API.

The shell pass now draws it for scripts and recipes too: a program started
by a path (./_build/x, ${DIR}/x, $(LOCALBIN)/x, /usr/sbin/x) SPAWNS the
Process of its name -- the node and edge shape pass_spawns.c uses, with
api "shell". The name is the last segment of the path's value, or, the
value unknown, the word's literal last segment. Not drawn: a path naming
a file of the repository (a script of its own), `command -v X` (a lookup,
not a run), a name that a branch leaves undecided. The commands inside
$( ) and <( ) are read too, each in a subshell of its own, for deploys as
well.

Make: recipes are now read line by line as make runs them (a tab-led line
and its continuations): tree-sitter-make can run one recipe_line over
several lines when a quote opens in "Don't" and closes lines later, and
an inner line kept its @ prefix. Rules tree-sitter-make leaves inside an
ERROR node (an indented, nested ifeq before them) are read, and their
variables count when no conditional encloses their line.

Measured on 17 repositories against an independent reading of the scripts
and Makefiles (its own tokenizer, variable expansion and directory
tracking): 229 matched; of the 231 edges drawn, 229 agree and 2 are scripts
in .txt golden files cbm reads as bash; the 29 rows only the reading has
are its own line-based misreadings (case patterns, multi-line arrays and
strings), names a branch leaves undecided, a Go-templated script and a
directory discovery excludes. kubermatic: every hack script running
kubermatic-installer deploy SPAWNS it. Only SPAWNS edges and Process nodes
were added (231, 115); deploys unchanged (86 of 86); three runs build
identical graphs; index time unchanged within 1 s (deckhouse 9 s,
gardener 5 s, kubermatic 2 s).

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