mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-12-05 04:47:43 +08:00
fix/python-module-range-v2
700
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
24eb264530 |
perf(python): restrict module binding scans to qualified-name ranges
Preserve registry array order and full-scan fallback when optional query storage is unavailable. Keep temporary range storage scoped to each module operation and shared type indexes in the registry owner arena. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
033c1e0116 |
fix(lsp): skip unnamed funcs in the unindexed QN lookup
lookup_func_self guards a NULL qualified_name in its indexed bucket scan and its post-finalize tail scan, but not in the linear scan an unfinalized registry takes. Iterating a fallback chain checks every base entry for shadowing against the head, so a head holding a func without a qualified name crashed in strcmp (ASan SEGV in pylsp_prefix_order_matches_iterator_and_chain_shadowing). The linear scan now skips such entries like the other two. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
23e291058c |
perf(python): index unresolved submodule prefix probes
Reuse a stable arena-owned function QN order for ambiguity marking and submodule prefix lookup, preserving exact lookup policy and appended tails. Add prefix/index failure regressions and a pipeline operation-count case. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
c278f4b013 |
fix(python): drop always-false bounds from namespace import capture
The __all__ literal guard compared a uint32_t child count against SIZE_MAX / sizeof(char *), which is always false on LP64 and failed the GCC build (-Werror=type-limits). One bound now covers both limits on every platform: the names are counted in an int, and count * sizeof(*names) <= INT_MAX also fits a 32-bit size_t. Building one import fact moves into py_ns_import_fact, and the module-name child is skipped with ts_node_eq: for a plain import the module is the null node, which equals no child. The loop no longer tests `from` after the from-only prelude, which cppcheck 2.20 misread as always false (knownConditionTrueFalse). Emitted facts are unchanged. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
de1819e73e |
fix(python): preserve ordered namespace metadata
Capture ordered Python namespace facts and retain them through compact, spill, and versioned LSP surfaces. Reject unavailable metadata before incremental reuse and rebuild on Python namespace changes or deletion. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
78aea85b68 |
fix(python): resolve class-body and decorator calls
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
132ded8c60 |
fix(python): separate package symbol scope from file identity
Resolve symbols declared in __init__.py under their package while retaining the raw module identity for file and top-level caller nodes. Carry explicit language through registry callers, select Python package imports, preserve long exact names, and report scope allocation failures without partial output. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
bf5ea5a460 |
fix(python): join module-level calls to exact LSP resolutions
Preserve the arena-owned raw Module caller name so top-level resolutions join the extractor in both pipeline drivers. Add occurrence and ownership controls, including package modules and named lambdas. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
e9e72d093c |
fix(lsp): evaluate operator and receiver chains iteratively
The depth guard of the C/C++ and Python expression evaluators (C_EVAL_DEPTH_LIMIT, PY_LSP_MAX_EVAL_DEPTH = 256) now reports a sticky per-file failure that stops the walk and drops every LSP resolution of the file. Both evaluators recursed once per chain link, so a 300-term sum or a C++ fluent chain of ~130 calls counted as 256 levels of nesting: one long expression cost its whole file every LSP call edge. A chain's length is not nesting, and the guard must not decide graph content for it. c_eval_expr_type and py_eval_expr_type now first walk down the chain operands below the node (the operand the evaluator evaluates first and derives the link's type from), then evaluate them innermost first at the caller's depth, keeping pending links on a small arena-owned stack in the context that nested evaluations share. When a link is evaluated, its chain operand is already memoized, so the evaluator's own recursive call into it is a memo hit one frame deep. Every node is still evaluated by the unchanged inner evaluator, evaluation does not mutate scope within one outermost call, and only operands the recursion itself evaluates are pre-evaluated, so the types are exactly the recursive ones. No longer counted as depth (any length): - C/C++: binary operators other than == != < > <= >= && || (those yield bool without evaluating an operand), member access (. and ->), calls on a non-name callee, subscripts, conditional consequences, parentheses, comma lists. - Python: binary operators, attribute access, calls on obj.m(...), f()() and (expr)(), subscripts, the else branch of a conditional, parentheses. Still counted, unchanged guard and reporting (genuine nesting): - C/C++: call arguments used for template argument deduction, std::move/std::forward operands, unary, pointer and update operands, assignment left sides, lambda return expressions, co_await, fold and _Generic operands. - Python: tuple/list/set elements, dictionary keys and values, the true branch of a conditional, await operands, next()/iter()/assert_type() arguments, called lambdas. Proof: - New c_lsp and py_lsp tests build chains of 300, 2,000 and 20,000 terms (a binary + chain and a .a() receiver chain) next to an unrelated s.m(). On the previous evaluator, and with this change reverted, all four fail at 300 terms: the depth error is recorded and the file resolves 0 calls (C++ per-file; Python per-file and through the cross-file dispatch). With it, every size records no error, resolves run -> S.m, and the chain's result type resolves x.done() / the final .done(). - Real input, isolated cache, before and after: redis 4f20cb48 (C): 36,876 CALLS, 10,699 LSP-resolved; django fb113765 (Python): 60,123 CALLS, 25,153 LSP-resolved. Identical CALLS edge sets on both (0 lost, 0 gained, 0 strategy changes), 0 files with an LSP error before and after, wall time unchanged (redis 5.5 s, django 9.1-10.2 s both ways). Refs #1527 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
c3c97a99d7 |
fix(lsp): bound repeated resolver work without truncating large files
Memoize C expression evaluation, index repeated scope and registry queries, and report incomplete walks explicitly on memo or depth failure. Refs #1527 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
5d4b50fe1c | Break-glass merge PR #2450 | ||
|
|
95555795e6 | Break-glass merge PR #2478 | ||
|
|
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> |
||
|
|
65a93fab40 |
fix(grammar): accept non-ASCII letters in Pascal identifiers (#2211)
Delphi code that calls 1C's OLE API through late-bound Variants uses
Cyrillic member names (v8_Base.<Cyrillic>.<Cyrillic>('1', Now),
NM.<Cyrillic>()). Every such name produced a tree-sitter ERROR node, so the
unit was reported as parse_partial and a procedure whose own name is
Cyrillic was dropped from the graph.
Root cause is upstream tree-sitter-pascal (Isopod, the pin we vendor):
its identifier token is ASCII-only, /[&]?[a-zA-Z_]+[0-9_a-zA-Z]*/, and
there is no other token a non-ASCII letter can lex as.
Fix: pascal becomes a self-maintained fork of the pin we already vendored
(Isopod/tree-sitter-pascal @ 042119eca2e1, v0.10.2 = upstream master),
following the arkts model. One patch
(tools/tree-sitter-pascal/patches/unicode-identifiers.patch) changes only
that token to /[&]?[\p{L}_][\p{L}\p{M}\p{Nd}_]*/. Keywords are still
extracted from this `word` token, so begin/end/procedure lex as before
(`begin` glued to Cyrillic letters is one identifier; `&begin` stays an
escaped identifier). Node types are unchanged. The \p{} classes compile
to numeric code-point ranges: the vendored parser.c has 0 non-ASCII bytes.
Regenerated with tree-sitter-cli 0.25.10 --abi 14 (ABI unchanged, no
external scanner; tree_sitter/parser.h is byte-identical to chialisp's).
Fidelity: the UNPATCHED grammar regenerated with 0.25.10 gives the same
symbol/token/field/production counts as upstream's shipped parser and
byte-identical parse trees on upstream's 88 corpus cases and its three
examples/*.pas (37,773 tree lines for codetoolmanager.pas); the patched
parser gives the same identical trees on all of those ASCII inputs and
passes all 88 corpus cases.
Proof (7 Pascal files: the report's snippet, a Cyrillic procedure with
keyword-boundary cases, an ASCII control, a broken unit, upstream's three
examples; fresh caches): parse_partial 3 -> 1 (only the genuinely broken
unit remains), nodes 581 -> 582 (the Cyrillic-named procedure), edges
1480 -> 1482 (+1 DEFINES, +1 SEMANTICALLY_RELATED); per-file function
counts for the ASCII files are unchanged.
Registered like arkts: MANIFEST.md fork row + note, audit FORKS map,
THIRD_PARTY.md, vendored checksums. LICENSE stays upstream's MIT,
byte-identical.
Tests: parse_coverage gains the report's snippet and a Cyrillic-named
procedure (not partial, definitions extracted), an ASCII control, and a
guard that broken Pascal is still flagged; the fork carries
test/corpus/unicode_identifiers.txt.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
2ef6ba7101 |
fix(extract): name macro-wrapped C/C++ definitions after the macro argument (#946, #1957)
Why: a function-like macro in a definition's declarator,
`void CBasePlayer::__API_HOOK(ReloadWeapons)(int slot)` or
`static void FNAME(first_caller)(void)`, parses as a function_declarator
nested directly inside the definition's own function_declarator. The
declarator walk descended to the terminal identifier, which is the MACRO,
so every definition wrapped by the same macro got one qualified name.
ReGameDLL_CS's hook definitions landed as 20 nodes literally named
__API_HOOK, and the Linux kernel's arch/x86/kvm/mmu/paging_tmpl.h (19
FNAME(...) definitions) as a single Function FNAME. The last definition
won, calls in every other body were sourced to it with a call line
outside its range, and callers never reached the real functions. The C
LSP had its own copy of the walk: it named the caller after the macro and
bound the macro's argument list as the function's parameters, so member
calls through a real parameter went unresolved.
Fix: cbm_c_macro_wrapped_name_node() recognises the shape. Valid C/C++
never nests two function_declarators directly (a function cannot return a
function; a function-pointer return has a parenthesized_declarator in
between), so the nesting always means a macro call. When that macro is a
plain or class-qualified name taking exactly one bare-name argument, the
definition is named after the argument; any other shape (multi-argument
wrappers, non-name arguments) keeps today's walk. The shared C-family
declarator resolver uses it, so the def name, the call-scope QN and the
unified extractor agree; the C LSP uses it too and keeps the outer
(real) parameter list. The class scope of `Cls::MACRO(x)` was already
derived from the qualified name and is unchanged.
Proof: dev builds of origin/main
|
||
|
|
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> |
||
|
|
4d9592b5fb |
Merge pull request #2068 from DeusData/feat/codeatlas-web
CBM Lens Beta: graph exploration and architecture workspace |
||
|
|
2d291002df |
Merge origin/main into feat/infra-graph
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
02c0288ff3 |
fix(grammars): the WIT scanner's create function returns NULL
tree_sitter_wit_external_scanner_create() is declared to return void * but had an empty body. tree-sitter's runtime stores its result as the scanner payload (parser.c ts_parser__external_scanner_create), so every WIT parse used an indeterminate value, which C11 6.9.1p12 makes undefined. The scanner never reads its payload, so ordinary builds were unaffected, and the vendored build's -w hid -Wreturn-type. MemorySanitizer reports it at wit/scanner.c:13 from grammar_labels, grammar_probe_e, grammar_regression and lang_contract. Those four suites were excluded from the MSan lane because the report itself crashed and posed as a stack overflow (fixed in the msan.sh commit of this series). Recorded in MANIFEST.md's local-patch table. Upstream bytecodealliance/tree-sitter-wit still has the empty body at 059bfdd1af72, the last change to src/scanner.c. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
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>
|
||
|
|
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> |
||
|
|
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>
|
||
|
|
78eace4fd3 |
doc-links: ship the doc-comment families that passed their held-out audit
The held-out audit of the eight new languages is scored. Each tier is a
language and a reference form, read on a sample of 150 links (census below
150) from repositories never used to build or tune the resolvers. Three
blind reading rounds; bar: Wilson 95% lower bound >= 0.90 and point >= 0.95.
tier population judged correct Wilson low
go doc_link 5980 150 150 0.975
java link 23934 150 150 0.975
java linkplain 1372 150 150 0.975
java see 7711 150 150 0.975
java throws 650 150 150 0.975
java value 79 79 79 0.954
kotlin kdoc_link 3888 150 150 0.975
kotlin sample 279 150 150 0.975
kotlin see 369 150 150 0.975
kotlin throws 73 73 73 0.950
rust intra_doc 14119 150 149 0.963
rust link_def 1491 150 150 0.975
perl pod_L 2255 150 150 0.975
ts/js link 1222 150 150 0.975
php see 5171 150 150 0.975
c doxygen_ref 463 150 150 0.975
c see 509 150 145 0.924
These 17 families now ship: a resolved reference is a MENTIONS edge.
TS/JS {@linkcode} (10 held-out links) and @see (18) were all judged
correct, but are too few to reach the bar; they stay held, as do the
diagram and OpenAPI link families (3 links on 21 held-out repositories).
The Go ship-gate test turned its family off and restored only the held
families afterwards; with Go shipping it left Go off for the tests that
follow it. It restores the production gates first now.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
abf65583e3 |
feat(docs): a section's text keeps its diagram's labels, not its syntax
A Markdown Section's docstring is its body collapsed and cut at 500 bytes. A diagram fence in that body put the format's syntax into it (`-->`, `participant`, `classDiagram`, `subgraph`), which names no code, and pushed the section's prose out of the cap. The doc -> code candidates are scored on that text. Each top-level diagram fence (mermaid, plantuml, puml, uml, dot, graphviz, d2) is now replaced in the section's text by the labels its diagram parser reads: the names of its elements, then its arrow labels, in source order. The parse runs into a scratch result, so the file's own Diagram and DiagramElement nodes are untouched. A section without such a fence keeps its text byte for byte; other fences stay as written. Measured before it was chosen, on held-out repositories (147 sections that embed diagrams, 503 section/candidate pairs, three blind reading rounds): fence as written 277 stored precision 0.45 42 sections with a correct candidate labels (this) 310 stored precision 0.54 56 sections with a correct candidate fence dropped 127 stored precision 0.54 29 sections with a correct candidate Labels gave 20 sections a correct candidate that the fence as written did not, and lost 6 (exact McNemar p = 0.009). Dropping the fence lost more than it gained. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
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>
|
||
|
|
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> |
||
|
|
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> |
||
|
|
d65f5f98ba |
Merge main into feat/doc-links-languages-diagrams
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
f4a49feba1 |
feat(docs): diagrams and OpenAPI operations in the graph
Diagrams name the parts of a system and how they connect; an OpenAPI document names its endpoints and their handlers. Both now enter the graph. Diagrams: - a Diagram node per diagram: a fenced block of a Markdown file (under its Section), a directive of a reST file (`.. mermaid::`, `.. uml::`, `.. graphviz::`, Sphinx `.. digraph::`), an Asciidoctor Diagram block of an AsciiDoc file (`[plantuml]`, `[source,mermaid]`, ...), or a diagram file of its own, named by its title, else by its file; - a DiagramElement node per element, DEFINES from its Diagram, and a DIAGRAM_ARROW edge per arrow (label, style, line); - formats: Mermaid (flowchart, sequence, class, ER, state, C4, architecture), PlantUML, Graphviz DOT, D2, draw.io (plain, compressed, .drawio.svg) and Excalidraw (.excalidraw, .excalidraw.json, .excalidraw.svg); .drawio.svg and .excalidraw.svg are no longer dropped as images; - an element's explicit link (Mermaid click/link, PlantUML [[url]], url of and !include, draw.io and Excalidraw link, DOT URL/href, D2 link) is a doc link read as a Markdown link, MENTIONS when it resolves. OpenAPI: - each operation of an OpenAPI or Swagger document (openapi.json and swagger.json, now read with the JSON grammar but no node per key, and any YAML or JSON file whose root says openapi/swagger) is a Route, named by the same QN a route its handler registers in code gets (cbm_route_canon_path, moved into the extraction library); - its operationId is a doc link to the handler: a dotted one (Connexion, with x-openapi-router-controller) as a qualified code name, a bare one when exactly one function or method of the repository has that name. The eight new link families are held until their held-out audit passes. Read on real repositories, which shaped the rules: Excalidraw drawings put text over shapes and draw arrows up to them without binding, so loose text names the smallest box it sits in and a loose arrow end meets the smallest named box it touches (the drawing's frame only at its border); arrows bound to free text meet the text; D2 block strings and nested blocks; DOT line breaks and sentence-long ids; PlantUML kinds of classes inside packages and nested classes (`..+`, nested -> container, so they do not collide with the container's association). Connexion's 24 specs: 160 operationIds, all linked to their handlers. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
523e68b13e |
feat(k8s): GitOps objects DEPLOYS what they deploy
A Flux Kustomization, an Argo Application and a HelmRelease each name what they put on a cluster -- a directory of the repository or a chart -- and none of it was an edge: "what deploys this kustomization" or "which release installs this chart" had no answer in the graph. DEPLOYS (a new edge type, approved for this program) links them to existing nodes only: - a Flux Kustomization / Argo Application -> the units its path applies: the outermost kustomizations below it (their Kustomization node) and the manifests outside any (their File), as the deploy scopes already read them; a path that is a chart dir -> that Chart; - a HelmRelease -> its chart: the repository chart dir of a Git or Bucket source, else the shared external Chart of that name (the node chart dependencies already use) for a Helm repository. Properties carry via (flux / argo / helmrelease) and the path or chart. Measured on 17 repositories against an independent reading of the manifests (units derived from kustomize closures, chart dirs and external chart names): 129 of 129 deploys linked, 129 of 129 correct (home-ops 92, k8s.io 36, flux example 1). Only DEPLOYS edges (and one external Chart) were added; three runs build identical graphs. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
73cd4b88ab |
feat(helm): templated manifests become objects with symbolic names
Most of an infrastructure repository's Kubernetes objects are written as
templates -- Helm charts, Go-template addons -- and those are YAML only
once rendered: `{{- if .Values.x }}` opens the document and `name: {{
include "app.fullname" . }}` is a flow mapping to a YAML parser. Across 17
repositories 92 % of the objects written in chart templates (1,127 of
1,233) never became Resources.
A templated manifest is now extracted from its skeleton: the text with
every action rewritten line for line, so document lines stay exact. A line
holding nothing but actions is blanked; an action inside text becomes a
symbolic scalar -- `<app.fullname>` for an include/template call, the first
`.`/`$` path otherwise (`<.Values.image.tag>`), else `<tpl>`. Objects get
the chart-scoped symbolic names IDENTITY.md describes
(`<app.fullname>-config`), and a reference or selector written with the same
expression meets them inside the chart. A templated namespace is the
deploy's; a templated apiVersion leaves the group unknown; a templated kind
is unidentifiable and skipped.
Measured on 17 repositories: objects written in chart templates as
Resources 8 % -> 94 % (1,166 of 1,233: prometheus-community 0 -> 343 of
357, microservices-demo 0 -> 84 of 84, deckhouse 431 of 479, gardener 149
of 151, kubermatic 133 of 136); kubermatic's templated addon objects 88 % ->
97 % (708 of 727). References and selectors touching templated objects,
201 sampled across 6 repositories and judged against the original template
text: 201 correct (4 by hand, quoting the sampler did not normalise). The
plain-manifest gates, include resolution and selectors are unchanged; three
runs build identical graphs; editing a template keeps incremental equal to
a full rebuild.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
1eb55031e6 |
perf(k8s): infra resolvers stay linear in the repository's copies
The complexity guard (O(n^2) detection) had no infrastructure corpus, and the infra resolvers looked candidates up by name across the whole repository and then filtered them: an object reference by "Kind/name", a selector by its rarest label pair, a custom resource by its CRD's group/kind, a controller's kind by the Go type's name. Independent copies share every name, so with k copies each lookup visited all k: the work grew ~4x per doubling while the edges stayed ~2x. Candidates are now looked up where they can match: - K8s references, selectors and CRDs through indexes keyed by the bundle (kustomize build root / chart / dir, and the deploy scopes for references) and the name, type or label pair; a source visits only the bundles it is in. The repository-wide fallback for a custom resource without a CRD beside it stays (it stands for every copy by design); - the operator pass through a (package dir, type) index: a controller's kind is one lookup in the imported or own package; only an import no module of the repository has still checks the same-named types. Group declarations are deduplicated through a set, not a scan. Child access in the K8s extractor goes through a tree cursor: ts_node_named_child(n, i) walks from the first child on every call, so the index loops over mapping pairs, sequence items and a file's documents were quadratic in a wide node. The guard gains fixtures (tests/fixtures/complexity/Kubernetes: a kustomize bundle with workloads, Service, Ingress, PDB, NetworkPolicy, HPA, RBAC, CRD + CR, cert-manager; tests/fixtures/complexity/Go: a controller-runtime operator with +groupName types and an embedded CRD), work counters g_k8s_candidates / g_op_candidates, and a gate on them and on the fixtures' own node and edge growth; fixture dirs now also apply to templated languages. An API group is one identity across a repository, so the fixtures' CRDs use groups no copy's Go code declares -- the guard measures accidental growth, not that by-design join. The originality check covers the infra sources and scans them against yaml-language-server, helm-ls, kustomize, Flux's kustomize package and controller-tools. Before: k8s candidates 126 -> 504 (4.00x), operator 45 -> 288 (6.40x) per doubling; after: 42 -> 84 and 6 -> 12 (2.00x), fixture edges 2.01x. On 17 infrastructure repositories the graphs are identical to before; three runs build identical graphs. Index wall time against origin/main, median of three: deckhouse 9.58 -> 9.59 s, kubermatic 2.93 -> 2.93 s, cloud-foundation-fabric 1.90 -> 1.90 s. A manifest of thousands of documents indexes ~10 % faster (2.40 -> 2.13 s). Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
128e3d8cf4 |
fix(rst): a section's text no longer reads an unwritten byte
rst_body cut a reST section's text at 500 bytes by setting a stop value past the end, then backing off from out[RST_BODY_MAX] while that byte looked like a UTF-8 continuation byte. That byte was never written, so where the text ended (499 or 500 bytes) depended on what the arena memory held, and when a multibyte character did not fit, bytes never written could end up in the text. Only whole characters are written now, and the text ends at the last one written. The same django tree indexed twice gave doc_link_candidates rows that differed in about 250 of 11,300 (through the section text's TF-IDF); with this change two runs are identical, and so are the 6,594 sections. The new test pins the cut at the boundary: a word that fills the 500 bytes, a two-byte character that would cross them, a word cut at a character. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
0e75e31e9c |
feat(k8s): exposed routes and policy selectors
What a cluster exposes and how its policies apply were not in the graph:
an Ingress or HTTPRoute was linked to its Services, but the host and path
it publishes had no node, and PodDisruptionBudgets and NetworkPolicies
selected nothing.
Exposed routes: each Ingress rule's host and http path, and each
HTTPRoute hostname with each path match of a rule, is a Route node
("<host or *><path>", QN __route__ingress__<route>, props via/host/path).
The declaring object DEFINES it, and the route maps (INFRA_MAPS {kind:
ingress|httproute}) to the Service it is sent to, resolved like the
object's own references. The route is not a code handler, so infra URL
matching never takes it for one.
Policy selectors: a PodDisruptionBudget's selector.matchLabels and a
NetworkPolicy's podSelector.matchLabels pick workloads by their pod
labels, like a Service selector: USAGE {ref: selector|podSelector}. An
empty selector (every pod of the namespace) and one with matchExpressions
draw nothing. An Argo Rollout is a workload for every selector.
Versioned manifests side by side (kubermatic's canal_v3.21..v3.29) declare
one Deployment in several files; as for references, a selector now picks
the copy in its own file when there is one, instead of every version.
Measured on 17 infrastructure repositories against an independent reading
of the documents: routes defined 29/29, route -> Service precision 11/11
(5 more need the deploy script that applies a directory recursively);
policy selectors precision 17/17 (the rest of the repository-wide pairs
cross bundles: an optional kustomize component, per-CNI test data);
references unchanged. Only the new nodes and edges were added, and 12
cross-version selector edges removed; three runs build identical graphs.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
191b581de6 |
feat(k8s): Flux, Argo, Cluster API, cert-manager and KKP references
An infrastructure repository wires its custom resources to each other:
a Flux Kustomization names its source and the Kustomizations it waits
for, a HelmRelease its chart source and values, a Cluster API Cluster its
infrastructure, control plane and class, a Certificate its issuer, a
Kubermatic Seed its kubeconfig. None of it was in the graph, and most of
it crosses kustomize roots, which the K8s references could not.
A second, curated reference table -- written from the API types of Flux,
Argo CD/Rollouts/Workflows, Cluster API, cert-manager and Kubermatic --
uses the same mechanics as the built-in one. Source kinds are qualified
by API group (a CloudNativePG `Cluster` is not a Cluster API one) and
paths may use `*` within a segment (any DNS-solver `*SecretRef`, any
cloud provider's credentialsReference). References become USAGE {ref};
Flux dependsOn becomes DEPENDS_ON {via: dependsOn}. An Argo Rollout's
pod template carries the pod references like any workload.
Deploy scopes: a Flux Kustomization's spec.path and an Argo
Application's source path deploy a repository directory -- the build of
a kustomization there, else every manifest below it, a nested
kustomization by its build, as Flux generates one. What a root deploy
reaches through such directories, transitively, is one scope (a
cluster), and a reference also meets its target inside a shared scope,
with the deploy's target namespace. A path naming no directory of the
repository (another artifact's layout) deploys nothing.
Measured on 17 infrastructure repositories against an independent
reading of the documents (bundles and deploy scopes re-derived): curated
references recall 168/168, precision 172/172 (4 targets sit in files the
reading skips for `{{` and were checked by hand); the built-in table is
unchanged at 257/258 and 257/257. Compared with the previous build only
USAGE and DEPENDS_ON edges were added (home-ops +104, cluster-api +94,
k8s.io +11, flux example +7, kubermatic +4); three runs build identical
graphs.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
3ef74c2307 |
feat(k8s): objects link to the objects they name
A Kubernetes object names the objects it runs with -- its service
account, mounted ConfigMaps and claims, env sources, the role a binding
grants, the Service an Ingress or webhook calls -- and none of that was
in the graph: across 17 infrastructure repositories, 0 object-to-object
references. Questions like "what breaks if this Secret changes" or "who
uses this ServiceAccount" had no edges to walk.
The K8s extractor now records, while it walks each document, the
references at known paths (written from the Kubernetes API, one table):
- pod spec (Pod, workloads, CronJob): serviceAccountName,
priorityClassName, imagePullSecrets, volumes (configMap, secret,
persistentVolumeClaim, projected sources), containers' env valueFrom
and envFrom -> USAGE {ref};
- RoleBinding / ClusterRoleBinding roleRef and ServiceAccount subjects,
HPA scaleTargetRef, StatefulSet serviceName, PVC storageClassName,
Ingress tls / ingressClassName, Gateway-API parentRefs -> USAGE {ref};
- Ingress and Gateway-API route backends, webhook configurations' and
APIServices' services -> INFRA_MAPS {kind};
- a custom resource -> the CRD declaring its group and kind -> USAGE
{ref: crd}.
The K8s pass resolves them after every object is registered, by name
(an O(1) index), inside the source's bundle and namespace (explicit, or
the source's own); an unresolved reference draws nothing. A name is one
object per kind and namespace, so same-named declarations in one bundle
are alternatives (versioned manifests side by side): the one in the
reference's own file wins. A CRD vendored twice: the copy deployed with
the resource, else all copies.
Measured against an independent resolver (Ruby over the parse tree, the
same table and bundle rules) on every plain manifest of the 17 corpora:
256 of 257 resolvable references are edges (the one left sits in a
directory .gitignore hides), and all 256 graph edges there are right.
In Go-templated files the truth parser cannot read, all 262 edges
kubermatic gets were checked against the source documents. Nothing else
in any graph changes; two runs are identical.
Tests: pod-spec references, RBAC / Ingress / HPA / webhook references,
CR -> CRD and an unresolved reference, bundle scope, alternatives in
one directory and a CRD vendored twice -- each fails without the change.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
2fdcbfe288 |
doc-links(php): a property's, constant's or case's doc block belongs to its type
PHP properties, class constants and enum cases have no graph node, so their
doc blocks were never read: cakephp has 36 @see references there, symfony
21. The PHP leg now uses the driver's loose_docs hook: a /** */ block right
above a property, constant or case is harvested with the type around it as
the source (as the field test's prototype attached it), and resolved like
any other reference written in that type (self:: is the type).
The driver marks as the file's only what a hook pushes with the file
stand-in (the C leg's prototype docs); a hook may push with a definition of
the file instead.
Proof (ship build, Apple M5 Pro / 48 GB, base
|
||
|
|
69ac2846f2 |
feat(k8s): every manifest document is an object with a stable identity
A Kubernetes manifest became at most one Resource: the extractor stopped
after the first document. A Deployment and its Service in one file --
the usual way to ship them -- left the Service out of the graph, and with
it every link from it; across 17 infrastructure repositories only 52% of
the objects in plain manifests existed as nodes.
Every document now yields its object, under an identity that holds
when names repeat:
- QN `<file>::<group>/<Kind>/<declared namespace or ->/<name>`, where
<file> is the File node's QN without `.__file__` (the extension kept,
so a.yaml/a.yml and dir/ + dir.yaml cannot collide), <group> the
apiVersion's group (`core` for v1). Same name in two namespaces = two
objects; one object twice in a file = one node with both spans.
- Properties `group`, `kind`, the declared `namespace` and `obj_key`
`<group>/<Kind>/<effective namespace>/<name>`, the logical identity
later joins use: `_` for a cluster-scoped kind, `?` when the deploy
decides the namespace. The display name stays `Kind/name`.
- Each object's selector or pod labels come from its own document, so
a Service links to the Deployment beside it.
- Values the YAML wraps are read through the wrapper: an anchored or
tagged name (`name: &name app`, `!!str`) and a flow-style label map
(`selector: { app: kdc }`, cut-short maps skipped whole so a selector
never loses pairs).
The Resource QNs change, so the index format moves to 2: every existing
index is rebuilt once on upgrade, keeping its ADR and project metadata.
On the 17 corpora (truth: every document of every plain manifest,
parsed independently): objects present as Resource 2,634 -> 4,996 of
5,025 (99%; the rest: a vendored CRD directory, multi-megabyte CRDs
the YAML grammar parses partially, one gitignored directory). Service ->
workload pairs whose objects are both in the graph 36 -> 219 of 219, all
219 linked; the 17 links outside that set are in Go-templated files the
truth parser skips and select what they should. Everything outside the
K8s objects is identical node for node and edge for edge; two runs are
identical.
Tests: every document an object, a selector across documents, one name
in two namespaces, the identity key and properties (incl. core group,
declared namespace, cluster scope), anchored/tagged names and flow
label maps fail on the old extractor; the extractor-level multi-document
test now pins both documents and their QNs.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
80e000a92a |
doc-links(c): Doxygen @ref and @see names become MENTIONS edges, held until their audit
A Doxygen comment in a .c or .h file (a block opening with slash-star-star
or slash-star-bang, a run of /// or //! lines) names code with `@ref name`
or `\ref name` (family doxygen_ref) and with the names an `@see`, `\see`,
`@sa` or `\sa` paragraph lists that have the shape of a symbol (`name`,
`name()`, `::name`, `Type::member`; family see). Code blocks, fences, code
spans, quoted labels and the word after \c, \p, \a, \b, \e, \em hold none; a
URL is the core's href family. A .h is parsed as C++, which does not change
the rule; other C++ and Objective-C files are not part of the leg.
C keeps no node for a function prototype, so the docs of a header's API
were never stored anywhere. The doc-link driver gets an optional loose_docs
hook, called after the definitions and the file's own doc: the C leg reads
every Doxygen block outside function bodies that no definition took, and
its references belong to the file (the File node is the source).
The scope ("c1") lists the definitions with nodes (function, variable,
type, enum constant, field, object-like and function-like macro) with their
qualified names, their linkage (static, or a type, constant or macro of a
.c file, is the file's own) and the parent of a constant or field, and the
pages, groups, anchors and sections the file's docs define.
doc_links_c.c resolves a name as Doxygen does, without imports:
- a page, group, anchor or section name is no code entity (graph_gap) and
never binds a symbol of the same name;
- then the documented file's own definitions (static ones too), its fields,
then what every file sees (external linkage, a header's types, constants
and macros); a static definition of another file is not visible;
- candidates count by qualified name (a prototype and its definition, #if
variants: one node); with `()` written a function or function-like macro
wins, then a definition wins over a macro;
- `Type::member`: a field of the struct or union Type, or a constant of the
enum Type;
- one candidate binds, several are ambiguous; a word of an @see paragraph
that names nothing and is a plain lowercase word is prose (Doxygen prints
it as text): no row; test code binds only from test code.
There is no scope_delta hook yet: a declaration or linkage change is a full
run.
The families are held (ships=false) until their held-out audit passes; the
suite ships them through the test seam.
Proof (ship build, Apple M5 Pro / 48 GB, base
|
||
|
|
7a321cac16 |
doc-links(php): PHPDoc @see references become MENTIONS edges, held until their audit
A PHP doc block names code with `@see Ref` at the start of a tag line (a
description may follow) and with inline `{@see Ref}`, both family `see`.
doclink_php.c harvests them (code spans and fenced blocks hold none; @link,
@uses and the other tags are not harvested; a URL is the core's href family)
and writes each file's scope: namespace blocks, use imports, types with
their supertypes already qualified in their own file, members, functions.
The persisted scope drops lines and imports: other files read names only.
Declarations inside a top-level conditional count as top level
(`if (!function_exists('f')) { function f() {} }`), never a function body.
doc_links_php.c resolves a reference as a FQSEN with PHP's own name rules:
- a leading backslash is taken as written; otherwise the first segment is
replaced when it is the alias of a class `use` of the namespace block the
reference is written in, else the block's namespace is put in front
(phpDocumentor's resolver);
- beyond that tool, as PHP itself has them: an unqualified function name is
taken from a `use function` import, else from the current namespace, else
from the global namespace; and self/static/parent name the documented
type and its superclass;
- a bare `name()` that would bind a function but is written in a type that
declares or inherits a method of that name is ambiguous (the method or the
function; the reference does not say which);
- members are looked up on the type, its traits, its superclass and its
interfaces (depth first); type, function and method names compare without
case, properties and constants with it;
- properties, class constants and enum cases have no graph node: graph_gap;
so has a type or function the graph folds into another one of the same
name in its file (two namespace blocks), which the scope flags;
- a name the repository does not declare is external outside the
repository's namespace roots (built-ins, Composer dependencies), else
missing. Residual: a function a dependency declares in the current
namespace is invisible, so the fallback would bind a global function of
that name.
There is no scope_delta hook yet: a declaration change is a full run.
The family is held (ships=false) until its held-out audit passes; the suite
ships it through the test seam.
Proof (ship build, Apple M5 Pro / 48 GB, base
|
||
|
|
f08641ee51 |
fix(k8s): a comment ahead of a YAML value no longer hides it
The K8s/Kustomize extractor took a mapping pair's value as the pair's second named child, and a block node's content as its first. A comment can be either: one trailing the key line (`metadata: # owned by ...`) sits in the pair ahead of the value, and a commented-out first entry (`resources:` then ` # - argocd.yaml ...` then ` - atlantis.yaml`) is the block node's first named child, ahead of the sequence. The whole list, or the object's metadata and with it its name, was lost. unwrap_pair_value now skips comments on both levels, and every value pick in the extractor goes through it: the kustomize list keys, kind, metadata and metadata.name. kubernetes/k8s.io's kubernetes/apps/kustomization.yaml starts its resources with a commented-out entry; its 13 Argo CD applications had no IMPORTS edge. Measured on all 17 infrastructure corpora against the previous build: k8s.io gains exactly those 13 edges (kustomize entries linked 107 -> 120 of 123), every other graph is identical except the known run-to-run order of `variants` on deckhouse's QN-colliding Go methods. Of 866 linkable local kustomize entries in the corpora, 862 are now linked. Three probes fail without the fix: entries after a commented-out entry, entries after a key-line comment, and a Deployment whose `metadata:` line carries a comment. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
196ca71cda |
doc-links(ts): JSDoc and TSDoc links become MENTIONS edges, held until their audit
A TypeScript, TSX or JavaScript doc comment (a block comment opening with a
slash and two stars) names code with {@link Ref}, {@linkcode Ref} (each with
an optional `|` label) and `@see Ref` at the start of a tag line that holds
no inline tag. doclink_ts.c harvests them (code spans and fenced blocks hold
none, {@linkplain} is not harvested, a hyphenated word after @see is prose, a
reference naming the declaration's own parameter is dropped, a URL is the
core's href family) and writes each file's scope: imports, exports, export *
barrels, top-level declarations, namespace bodies and functions or classes
declared inside a function body.
doc_links_ts.c resolves a reference as the TypeScript checker sees it from
the documented declaration, in one index over TS, TSX and JS files:
1. the namespaces around the reference, innermost first;
2. a function or class declared in the enclosing function body (the graph
gives it a file-level name: two of one name in one file share one node,
a graph gap);
3. the file's own top-level declarations;
4. its imports, followed through export { a as b }, export ... from and
export * barrels (cycle guard, depth bound; two barrels that answer
differently are ambiguous); a relative specifier resolves with the usual
extension and index rules, a bare one is external;
5. the standard library's global names: external;
6. the top-level declarations of script files (no import, no export): one
binds, several are ambiguous;
7. the members of the documented class or interface, `this.` included.
The other segments walk members or a module's exports. A member declared
without a node of its own is a graph gap; test code binds only from test
code. There is no scope_delta hook yet: an export change is a full run.
The families are held (ships=false) until their held-out audit passes; the
suite ships them through the test seam.
Proof: the TypeScript compiler (perf-bench/typescript b465fdbfe175), ship
build, against the field test's prototype records (cascade results left
out): 69 edges; 57 of the prototype's 61 pairs bound alike. The 4 others are
doc blocks without a definition of their own (on an `if` statement, a local
`var`, an enum member, a free-standing @typedef block), which the core does
not harvest. Of the 12 edges the prototype has no pair for, 4 are the same
targets the prototype resolved without recording a source node, and 8 bind
PropertyDescriptor to the repository's own src/lib/es5.d.ts, which the
prototype called an external library global (kept: the repository declares
it). Unresolved rows agree with the prototype's reasons apart from the
documented reason split (not_in_scope -> missing/ambiguous).
Known limit: package.json and tsconfig.json are not indexed (discovery
ignores them), so workspace packages and tsconfig `paths` stay external.
Tests (doc_mentions_ts): tokens with their lines; the scope blob and its
persisted form; every resolution rule, including a function-body
declaration that binds and two of one name that do not; incremental equals
full (a doc edit and a body edit repair one file, an export change is a full
run); 60 modules give the same edges and rows with one worker and several.
Each rule red with it reverted (the body declaration's visibility and its
line check, barrel ambiguity, the parameter rule, code spans, the library
globals).
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
75e317518c |
fix(hcl): index .tofu and .tfvars; only top-level blocks are Classes
- OpenTofu configuration (`.tofu`) and variable files (`.tfvars`) had no language and were never indexed (cloud-foundation-fabric: 104 `.tofu`, 208 `.tfvars`). - Every HCL `block` became a Class, nested ones included: a resource's `lifecycle`, `dynamic`/`content` and argument blocks were entities next to the resource (cloud-foundation-fabric: `dynamic` 1,342, `content` 205 beside 898 resources). Only a block directly in the file's body -- resource, data, module, variable, output, locals, provider, terraform, Terragrunt's include/dependency -- is a Class now. - A file's own assignments (a `.tfvars` file, Terragrunt `inputs`) sit one level below the root the variable walk scanned; none was extracted. They are Variables now. On real input (HCL Classes / .tofu+.tfvars files / HCL Variables), against main: cloud-foundation-fabric 6,324 -> 3,919 / 0 -> 312 / 0 -> 1,067, kubernetes/k8s.io 2,102 -> 1,590 / 0 -> 11 / 0 -> 42, kubespray 892 -> 804 / 0 -> 13 / 0 -> 174, eks-blueprints 924 -> 733, kube-hetzner 757 -> 683, deckhouse 976 -> 830; the terragrunt example keeps its 31 top-level blocks and gains 5 input Variables. Not changed here: the remaining HCL USAGE edges are generic name guesses (a `range` call resolves to a Class in <python-builtins>, module outputs to same-named outputs of unrelated modules), and the name-similarity config links now also see the 104 OpenTofu files. The nested-block, .tofu and .tfvars probes and the extension unit test fail without the change. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
b3e66e1bf1 |
fix(yaml): a Kubernetes manifest mints no Variables for its envelope
Every top-level key of a YAML file became a Variable, so each manifest
added `apiVersion`, `kind`, `metadata`, `spec` and `status` (deckhouse:
`kind` 1,358, `apiVersion` 1,347, `metadata` 1,336, `spec` 1,231). They
are the object's envelope, which its Resource node already carries, and
as config keys they fed name-similarity CONFIGURES links -- a Chart's
`apiVersion` "configured" every `*.apiVersion` helper in 46 charts.
A YAML document whose top level holds both `apiVersion` and `kind` now
mints no key Variables; other YAML keeps them.
On real input (Variables in YAML files / key_symbol CONFIGURES edges),
against main: deckhouse 11,892 -> 5,662 / 2,631 -> 2,167, gardener
2,282 -> 503 / 1,677 -> 650, kubernetes/k8s.io 1,862 -> 844,
onedr0p/home-ops 1,334 -> 41, kubermatic 7,911 -> 6,692,
prometheus-community/helm-charts 2,364 -> 2,301 (its templates open with
`{{- if }}` and do not parse as manifests).
The manifest probe fails without the check; a config-YAML probe guards
that other YAML keeps its Variables.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
f4277ae783 |
doc-links(perl): POD L<> codes become MENTIONS edges, held until their audit
A sub's POD section and the module's own POD (the File node's doc) name code with L<> codes: L<Module::Name>, L<Module::Name/section>, L</section>, with a `text|` prefix or not. doclink_perl.c reads them the way perlpodspec and Pod::Simple do (verbatim paragraphs and data regions hold none, an L inside an L is no link, a URL is the core's href family) and writes each file's scope: its packages, its subs and its headings. Lines are exact: a sub's doc is matched against the file's sections, and the module doc's runs (extract_defs.c) are found again in the source in order; a module doc is POD from its start, so a run that begins with text is read too. doc_links_perl.c resolves them: - a module is the file that declares its package; of several, the one the library layout names (.../Name/Space.pm), else ambiguous. The target is the file's File node, as the field test's audited prototype has it (a Module node is missing where a same-named Folder holds its qualified name, lib/Mojo.pm next to lib/Mojo/). - L<Module/section>: the sub its heading names when the module's file defines that sub; any other section is a place in the module's documentation, the module. - L</section>: a sub the heading names; a heading that names no sub is the page itself (local, neither edge nor row); a section the page has no heading for is missing. - a module the repository does not declare (CPAN, the core, a .pod page: discovery keeps no .pod file) and a man page are external; test code (t/, xt/, *.t, and cbm_is_test_file, which has no Perl rule) binds only from test code. There is no scope_delta hook yet: a change to a file's packages, subs or headings re-resolves every Perl reference. The family is held (ships=false) until its held-out audit passes; the suite ships it through the test seam. Tests (doc_mentions_perl): tokens with their lines, file-level and sub-level, each read once; every resolution rule; incremental equals full (a module doc edit and an added module-level reference repair the file, a heading change is a full run); 60 modules give the same edges and rows with one worker and several. Each rule red with it reverted (the module doc's line mapping, a module run read from its start, the missing section, the library layout). Mojolicious at 93f591742a7d (the family shipped, a measurement build) against the field test's prototype records of its .pm/.pl files: 950 (source, target) pairs both have; the 197 only the prototype has are all references within one file (570), which the core makes no edge of; 8 only here come from the extensionless scripts the prototype did not read. Every prototype row has its row here: external 102, missing 1, and the 172 targets in .pod pages external by the ruling for .pod pages. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
ef5359e3ee |
extract(perl): a module's POD that no sub holds is its File node's doc
A POD section whose =head / =item names a sub is that sub's doc (#2459). Everything else (NAME, DESCRIPTION, SEE ALSO, the text of a section around the subs it holds, sections that name an attribute or helper without a node) was stored nowhere, so nothing could read it. It is now the file's module doc, stored on the File node as Go package comments and Rust inner docs are: every POD block with the sections a sub's doc holds cut out, each remaining run as it stands in the source, in document order and joined by a blank line (a sub's doc joins its sections the same way); a run of only =cut, =pod, =over and =back lines is dropped. A section is marked when a sub's doc takes it, so the module doc is built after the definitions and the two never hold the same text. Its first line is noted for the doc-link layer. Mojolicious at 93f591742a7d: L< codes in stored docs 624 (subs, unchanged) + 1,595 (File nodes of 112 modules) = 2,219, the count of L<> codes in the POD of its .pm and .pl files, none stored twice. Test: doc_perl_module_doc_is_the_pod_no_sub_holds (the module doc's exact text, the sub's doc unchanged, no module doc when every section is a sub's); red at its first assertion with the module doc not built. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
3af25b432f |
doc-links(rust): intra-doc links become MENTIONS edges, held until their audit
Rustdoc's intra-doc links ([`Name`], [path], [text](path), the kind
disambiguators struct@, fn@, macro@ ...) and links that take their destination
from a link reference definition, bound the way rustdoc resolves them: the
item's module scope, its use declarations, the crate root and the crates
Cargo.toml names. The leg (doclink_rs.c extracts the links and each file's
scope, a Cargo.toml its crate facts; doc_links_rs.c resolves them) is ported
onto the restacked core: family rows carry their edge type, resolve() takes
the per-file state (none here). Both families are held (ships=false) until
their held-out audit passes; the suite ships them through the test seam.
The graph moved under the leg: cfg-gated twins are one definition with its
variants on one node (
|
||
|
|
a1190afbb0 |
doc-links(java, kotlin): Javadoc and KDoc references become MENTIONS edges, held until their audit
Java's {@link}, {@linkplain}, @see, @throws and {@value}, and Kotlin's [Name]
links, @see, @throws and @sample, bound the way javadoc and Dokka search for a
member (one resolver for both languages, so a Kotlin doc can name a Java type
and back). The leg (doclink_jvm.c extracts the references and each file's
scope; doc_links_jvm.c resolves them) is ported onto the restacked core:
family rows carry their edge type, resolve() takes the per-file state (none
here). All nine families are held (ships=false) until their held-out audit
passes; the suite ships them through the test seam.
The graph moved under the leg since it was written: a Java field's node is
named by the field alone (no longer by its whole declarator, `MAX = 10`), and
a field named like a method of its class has its own node,
<Owner>.<name>#field, where the method used to take the name. The tests
follow: the expected field names lose the initializer, a changed
initializer is a local change repaired file by file (it renamed the node
before, which forced a full run), and a field that shares its accessor's name
is now an edge target and a source (doc_mentions_jvm_java_families_and_reasons,
doc_mentions_jvm_node_ownership), where both were graph_gap rows.
Measured with the leg's binary (1078036f) and this one on the same input:
- elasticsearch subset (libs/ + server/src/main at f3dc4b0bd3a0, 5,956 files):
no edge lost; 66 new edges and 7 edges moved onto a field's own #field node;
81 graph_gap rows gone, no new row, no reason changed. A seeded sample of 8
of the gone rows read against the source: every new edge is right (a field
named like its accessor, enum constants, a field's own doc as the source).
- Exposed (Kotlin, c419caaab61f): identical, 896 edges and 371 rows.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
||
|
|
0c7ca34419 |
doc-links(go): Go doc links become MENTIONS edges, held until their audit
Go doc comments name code as doc links ([Name], [Recv.Name], [pkg.Name], [pkg.Recv.Name], an import path for pkg), the way go/doc/comment reads them. The Go leg (doclink_go.c extracts them and a go.mod's module path as the scope; doc_links_go.c resolves them against the package's declarations and its imports) is ported onto the restacked core: the family row carries its edge type, and resolve() takes the per-file state the core now passes (Go keeps none). The family is held (ships=false) until its held-out audit passes: a resolved doc link is a below_bar_tier row until then. The suite ships it through the test seam, like the other held families; doc_mentions_go_tokens asserts the production default. Kubernetes at 8c078bc32e90 with the family shipped (a measurement build): 1,928 edges (1,115 exact, 813 unique) and 101 rows (external 61, graph_gap 22, missing 18), the same numbers the leg measured on the old core. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |
||
|
|
6bdb971c90 |
fix(k8s): read manifests and kustomizations behind a leading comment
A comment between `---` and the mapping -- the `# yaml-language-server: $schema=...` line editors add -- is the YAML document's first named child. Both the manifest and the kustomization walker took that child as the content, found no mapping and skipped the document. The label scan for Service selectors also stopped at a leading `---`, treating the opening separator as the end of the first document. On onedr0p/home-ops (428 manifests open this way): Resource nodes 26 -> 318, kustomization entries resolved 1 -> 348 of 348. kubermatic 286 -> 300; flux2-kustomize-helm-example and microservices-demo unchanged. Each of the three new probes fails with its fix reverted. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> |