Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(ingestion): add COBOL language support (#1770)

Raghav Chamadiya0e0bb09008a5
diff --git a/README.md b/README.md
index 2e8030149..dabf76a2b 100644
--- a/README.md
+++ b/README.md
@@ -155,7 +155,7 @@ local, all deterministic, no extra LLM calls.
| Foundation | What it contributes |
|---|---|
-| **Graph** | File + symbol dependencies across 25 AST-parsed languages, confidence-stamped call resolution, communities, centrality, cycles, and execution flows |
+| **Graph** | File + symbol dependencies across 26 AST-parsed languages, confidence-stamped call resolution, communities, centrality, cycles, and execution flows |
| **Git** | Hotspots, ownership, co-change, bus factor, and bug-fix history: behavioral signals static analysis cannot see |
| **Docs** | A wiki for every module and file, rebuilt incrementally with freshness and confidence scoring plus hybrid search |
| **Decisions** | Architectural rationale mined from five index-time sources plus human and agent capture, each claim traced to evidence |
@@ -481,8 +481,8 @@ the orchestrators. Full matrix and the contributor recipe:
## Supported languages
-**25 languages parsed to AST · 39 on a five-rung ladder · framework-aware across
-all of them.**
+**26 languages parsed to AST · 40 on a five-rung ladder · framework-aware where
+an ecosystem handler exists.**
"Do you support X" has five useful answers, not two, so languages land on a
ladder and every rung says what it buys you.
@@ -513,6 +513,7 @@ ladder and every rung says what it buys you.
<img src="https://img.shields.io/badge/PHP-777BB4?style=flat-square&logo=php&logoColor=white" alt="PHP" />
<img src="https://img.shields.io/badge/Dart-0175C2?style=flat-square&logo=dart&logoColor=white" alt="Dart" />
<img src="https://img.shields.io/badge/Delphi-EE1F35?style=flat-square&logo=delphi&logoColor=white" alt="Object Pascal / Delphi" />
+ <img src="https://img.shields.io/badge/COBOL-005CA5?style=flat-square" alt="COBOL" />
<img src="https://img.shields.io/badge/GDScript-478CBF?style=flat-square&logo=godotengine&logoColor=white" alt="GDScript / Godot" />
<img src="https://img.shields.io/badge/VB.NET-945DB7?style=flat-square&logo=dotnet&logoColor=white" alt="VB.NET" />
<img src="https://img.shields.io/badge/Elixir-6E4A7E?style=flat-square&logo=elixir&logoColor=white" alt="Elixir" />
@@ -529,15 +530,15 @@ still doing real work rather than being ignored:
| Rung | Languages | What you get |
|---|---|---|
| **Full** (13) | Python · TypeScript · JavaScript · Svelte · Vue · Java · Kotlin · Go · Rust · C++ · C# · Scala · Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges, **and code-health markers** |
-| **Good** (10) | C · Swift · PHP · Dart · Object Pascal · GDScript · VB.NET · Elixir · F# · Objective-C | All of the above except the full health suite |
+| **Good** (11) | C · Swift · PHP · Dart · Object Pascal · COBOL · GDScript · VB.NET · Elixir · F# · Objective-C | All of the above except the full health suite, subject to the language-specific ceilings in the full matrix |
| **Partial** (2) | Luau / Roblox · Razor / Blazor | Luau: AST symbols and `require()` resolution, Rojo and `.luaurc` aware. Razor: component symbols, `@code` and component-tag call edges, C# health markers; no import resolution yet |
| | | ⎯⎯ *tree-sitter parsing stops here; the rungs below come from git and imports* ⎯⎯ |
| **Lightweight** (6) | Clojure · Haskell · Lean 4 · Erlang · HTML · QML | A real file-to-file import graph, and no symbol-level claims |
| **Structural** (8) | R · Zig · Julia · Elm · OCaml · Crystal · Nim · D | Git history: blame, hotspots, co-change, ownership, bug history |
**Every language ships in the open-source distribution.** None is gated behind
-the commercial licence, and none will be. Languages on the way up the ladder,
-including **COBOL**, are on the
+the commercial licence, and none will be. COBOL now ships at the Good tier;
+languages still moving up the ladder are tracked on the
**[roadmap →](ROADMAP.md#languages)**.
SQL and dbt projects get real `ref()` / `source()` lineage, shell scripts get
diff --git a/ROADMAP.md b/ROADMAP.md
index e216333bc..2fb98ebc5 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -34,13 +34,12 @@ Languages land on a five-rung ladder rather than a yes/no list, because "do you
support X" has five different useful answers. Each rung is defined, with what it
buys you, in
[docs/layers/LANGUAGE_SUPPORT.md](docs/layers/LANGUAGE_SUPPORT.md). Today that
-ladder covers **39 languages, 25 of them parsed to a full AST**.
+ladder covers **40 languages, 26 of them parsed to a full AST**.
### New languages
| Language | Status | Why it is on the list |
|---|---|---|
-| **COBOL** | **In development** | Asked for by enterprises with mainframe estates evaluating repowise. The codebases that most need an institutional-memory layer are often the ones whose authors have already retired. |
| **PL/SQL** | Planned | We already parse SQL through sqlglot. Packages, procedures and triggers are where the business logic actually lives. |
| **ABAP** | Exploring | The same argument as COBOL, in SAP estates. |
| **RPG / AS400** | Exploring | Named alongside COBOL often enough to track. |
@@ -53,6 +52,7 @@ ladder covers **39 languages, 25 of them parsed to a full AST**.
| Language | Status | Next |
|---|---|---|
+| COBOL | Planned | Copybook resolution, source-format normalization, broader dialect coverage, and health markers |
| Vue, Svelte | In development | Options-API members, `{#each}` and `v-for` head bindings, `.svelte.ts` rune modules |
| C#, Scala, Ruby | Planned | Dataflow dialects, which is what Extract Method needs in order to lift a span safely |
| Kotlin | Exploring | Dataflow is blocked on the grammar and needs either a grammar upgrade or a text-based jump seam. We would rather say blocked than planned. |
diff --git a/docs/README.md b/docs/README.md
index a0086b8d6..0ff057f52 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -59,7 +59,7 @@ your agent in under five minutes, with no API key.
| [layers/DECISIONS.md](layers/DECISIONS.md) | Architectural decisions mined from your repo and from your own agent sessions |
| [layers/DEAD_CODE.md](layers/DEAD_CODE.md) | Unreachable files, unused exports, and zombie packages by confidence tier |
| [layers/SECURITY.md](layers/SECURITY.md) | The local pattern scan: what the sixteen patterns catch, what they do not, and how far to trust the result |
-| [layers/LANGUAGE_SUPPORT.md](layers/LANGUAGE_SUPPORT.md) | What works per language: 25 parsed to a full AST, 39 on the five-rung ladder |
+| [layers/LANGUAGE_SUPPORT.md](layers/LANGUAGE_SUPPORT.md) | What works per language: 26 parsed to a full AST, 40 on the five-rung ladder |
| [layers/WIKI.md](layers/WIKI.md) | The generated wiki: page types, what `update` re-renders, styles, output language |
## Scale it
diff --git a/docs/architecture/language-support.md b/docs/architecture/language-support.md
index 3551da973..e4faf6de0 100644
--- a/docs/architecture/language-support.md
+++ b/docs/architecture/language-support.md
@@ -199,7 +199,10 @@ SPEC = LanguageSpec(
display_name="MyLang",
extensions=frozenset({".ml"}),
grammar_package="tree_sitter_mylang", # PyPI package name
+ grammar_loader="language", # package loader function
+ grammar_loader_args=(), # args for shared grammar packs
scm_file="mylang.scm", # query file name
+ dead_code_exempt=False, # only for unobservable external entry
heritage_node_types=frozenset({"class_declaration"}),
entry_point_patterns=("main.ml",),
manifest_files=("mylang.toml", "mylang.build.json"),
@@ -211,6 +214,21 @@ SPEC = LanguageSpec(
)
```
+Most grammar wheels expose a zero-argument `language()` function returning a
+PyCapsule. Shared grammar packs can instead declare `grammar_loader_args`; the
+loader may return either a capsule or a constructed `tree_sitter.Language`.
+COBOL uses this seam with
+`tree_sitter_language_pack.get_language("cobol")`, because no standalone
+Python COBOL grammar wheel exists. The pack downloads and caches that grammar
+on first use; the ordinary missing-grammar fallback still applies if it is not
+available.
+
+Set `dead_code_exempt=True` only when the runtime's entry paths fundamentally
+live outside the repository graph. COBOL uses it because JCL, schedulers and
+dynamic program calls cannot be proven by static source reachability. The flag
+suppresses file- and symbol-level dead-code claims without disabling parsing,
+call resolution or the rest of graph analysis.
+
Then register it in `languages/specs/__init__.py` by importing the module and
slotting it into the `ALL_SPECS` tuple. **Order matters**: `LanguageRegistry`
builds its extension map first-spec-wins, so place more specific languages ahead
@@ -365,7 +383,8 @@ sets from the registry automatically.
## What a new language does *not* get for free
-Steps 1–5 give you symbols, imports and a call graph. They do **not** give you:
+Steps 1–5 give you the symbols, imports and calls your query captures. They do
+**not** give you:
- **Code-health markers.** The complexity walker uses its own per-language
node-type map (`analysis/health/complexity/languages.py`), independent of your
diff --git a/docs/business/COMMERCIAL.md b/docs/business/COMMERCIAL.md
index 602fef6a6..f616ab51a 100644
--- a/docs/business/COMMERCIAL.md
+++ b/docs/business/COMMERCIAL.md
@@ -42,7 +42,7 @@ scale, in a regulated or security-sensitive environment**:
All of the following ship in `pip install repowise` today, free for internal use.
- **[Five intelligence layers](../layers/INTELLIGENCE_LAYERS.md)**: Graph
- (tree-sitter AST across 25 languages, two-tier dependency graph, call
+ (tree-sitter AST across 26 languages, two-tier dependency graph, call
resolution, heritage extraction, Leiden communities, PageRank / betweenness /
SCC), Git (hotspots, ownership, co-change pairs, bus factor, significant
commits, contributor profiles, module health), Documentation (a wiki page per
@@ -99,17 +99,19 @@ All of the following ship in `pip install repowise` today, free for internal use
## 3. First-class language coverage
-Repowise parses **25 languages to a full AST** and places **39 on a five-rung
+Repowise parses **26 languages to a full AST** and places **40 on a five-rung
ladder**, so "do you support X" gets the rung as its answer rather than a yes or a
no. Both numbers matter and neither is worth quoting alone.
-The 25 are the top three rungs. At **Full tier sit 13** (Python, TypeScript,
+The 26 are the top three rungs. At **Full tier sit 13** (Python, TypeScript,
JavaScript, Svelte, Vue, Java, Kotlin, Go, Rust, C++, **C#**, Scala, and Ruby) with
AST parsing, import resolution, named bindings, call resolution, heritage
extraction, multi-project workspace resolvers, framework-aware edges, per-language
-dynamic-hint extractors, and code-health markers. A further **10 at Good tier** (C,
-Swift, PHP, Dart, Object Pascal/Delphi, GDScript, VB.NET, Elixir, F#, Objective-C) get all of that except the full
-health suite, with GDScript and F# also lacking framework edges and named bindings, and Luau
+dynamic-hint extractors, and code-health markers. A further **11 at Good tier** (C,
+Swift, PHP, Dart, Object Pascal/Delphi, COBOL, GDScript, VB.NET, Elixir, F#,
+Objective-C) get most of that without the full health suite. COBOL resolves
+literal `CALL` and local `PERFORM` targets but not copybooks or dynamic calls;
+GDScript and F# also lack framework edges and named bindings. Luau
and Razor/Blazor are partial. SQL/dbt, shell, HTML, and the config formats are
handled by dedicated extractors on top of that.
@@ -123,8 +125,8 @@ would not survive a technical evaluation. Full ladder:
[LANGUAGE_SUPPORT.md](../layers/LANGUAGE_SUPPORT.md).
**Languages are never gated.** Every one of them ships in the AGPL distribution,
-including the ones still climbing. What is on the way up, **COBOL** among them,
-is on the public [roadmap](../../ROADMAP.md#languages). Where you need a language
+including the ones still climbing. COBOL now ships at the Good tier; remaining
+work is on the public [roadmap](../../ROADMAP.md#languages). Where you need a language
or framework that is not there, §5.4 covers having it built and maintained by us
as a commercial line item, and the result still ships to everyone under AGPL.
diff --git a/docs/layers/GRAPH.md b/docs/layers/GRAPH.md
index 5dcde3368..50a2f2431 100644
--- a/docs/layers/GRAPH.md
+++ b/docs/layers/GRAPH.md
@@ -11,7 +11,7 @@ that **every edge carries its own evidence**.
<p>
<img src="https://img.shields.io/badge/17-edge_types-3178C6?style=flat-square&labelColor=0A0A0A" alt="17 edge types" />
<img src="https://img.shields.io/badge/29-resolution_origins-059669?style=flat-square&labelColor=0A0A0A" alt="29 resolution origins" />
- <img src="https://img.shields.io/badge/25-languages-F59520?style=flat-square&labelColor=0A0A0A" alt="25 languages" />
+ <img src="https://img.shields.io/badge/26-languages-F59520?style=flat-square&labelColor=0A0A0A" alt="26 languages" />
<img src="https://img.shields.io/badge/22-framework_detectors-7F52FF?style=flat-square&labelColor=0A0A0A" alt="22 framework detectors" />
<img src="https://img.shields.io/badge/0-LLM_calls-1E293B?style=flat-square&labelColor=0A0A0A" alt="zero LLM calls" />
<img src="https://img.shields.io/badge/compiler_graded-7_of_7_cells_undominated-DC2626?style=flat-square&labelColor=0A0A0A" alt="no tool is both more precise and more complete, in 7 of 7 compiler-graded cells" />
diff --git a/docs/layers/INTELLIGENCE_LAYERS.md b/docs/layers/INTELLIGENCE_LAYERS.md
index 9846514ba..77238c43d 100644
--- a/docs/layers/INTELLIGENCE_LAYERS.md
+++ b/docs/layers/INTELLIGENCE_LAYERS.md
@@ -43,7 +43,7 @@ requirement for the index.
## Graph Intelligence
tree-sitter parses your source into a **two-tier dependency graph**: file nodes
-and symbol nodes (functions, classes, methods). 25 languages parse to a full
+and symbol nodes (functions, classes, methods). 26 languages parse to a full
AST; see [`LANGUAGE_SUPPORT.md`](LANGUAGE_SUPPORT.md) for per-language tiers.
A **confidence-scored call resolver** handles import aliases, barrel
diff --git a/docs/layers/LANGUAGE_SUPPORT.md b/docs/layers/LANGUAGE_SUPPORT.md
index 04511fb0e..7190e535a 100644
--- a/docs/layers/LANGUAGE_SUPPORT.md
+++ b/docs/layers/LANGUAGE_SUPPORT.md
@@ -1,7 +1,7 @@
# Language Support
-**25 languages parsed to a full AST · 39 on the five-rung ladder ·
-framework-aware across all of them.** "Do you support X" has five useful answers
+**26 languages parsed to a full AST · 40 on the five-rung ladder ·
+framework-aware where an ecosystem handler exists.** "Do you support X" has five useful answers
rather than two, so every language lands on a rung and the rung says what it
buys you. Everything else in your repo still appears in the wiki and is tracked
through git history. This page is the "what works for my language today"
@@ -30,6 +30,7 @@ reference.
<img src="https://img.shields.io/badge/PHP-777BB4?style=flat-square&logo=php&logoColor=white" alt="PHP" />
<img src="https://img.shields.io/badge/Dart-0175C2?style=flat-square&logo=dart&logoColor=white" alt="Dart" />
<img src="https://img.shields.io/badge/Delphi-EE1F35?style=flat-square&logo=delphi&logoColor=white" alt="Object Pascal / Delphi" />
+ <img src="https://img.shields.io/badge/COBOL-005CA5?style=flat-square" alt="COBOL" />
<img src="https://img.shields.io/badge/GDScript-478CBF?style=flat-square&logo=godotengine&logoColor=white" alt="GDScript / Godot" />
<img src="https://img.shields.io/badge/VB.NET-945DB7?style=flat-square&logo=dotnet&logoColor=white" alt="VB.NET" />
<img src="https://img.shields.io/badge/Elixir-6E4A7E?style=flat-square&logo=elixir&logoColor=white" alt="Elixir" />
@@ -58,14 +59,14 @@ produce meaningful output.
| Tier | Languages | What you get |
|------|-----------|--------------|
| **Full** (13) | Python · TypeScript · JavaScript · Svelte · Vue · Java · Kotlin · Go · Rust · C++ · C# · Scala · Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges, **and code-health markers** |
-| **Good** (10) | C · Swift · PHP · Dart · Object Pascal · GDScript · VB.NET · Elixir · F# · Objective-C | Everything above except the full health suite. Dart and Object Pascal *do* get health markers, and C, F# and Objective-C get the complexity-derived ones; Swift, PHP, GDScript, VB.NET and Elixir don't yet. GDScript has a dedicated import resolver and Godot-specific framework edges but no named bindings (see [Known gaps](../architecture/language-support.md#gdscript--godot)) |
+| **Good** (11) | C · Swift · PHP · Dart · Object Pascal · COBOL · GDScript · VB.NET · Elixir · F# · Objective-C | Everything above except the full health suite. Dart and Object Pascal *do* get health markers, and C, F# and Objective-C get the complexity-derived ones; Swift, PHP, COBOL, GDScript, VB.NET and Elixir don't yet. GDScript has a dedicated import resolver and Godot-specific framework edges but no named bindings (see [Known gaps](../architecture/language-support.md#gdscript--godot)) |
| **Partial** (2) | Luau / Roblox · Razor / Blazor | Luau: AST symbols and `require()` resolution (Rojo / `.luaurc` aware), no health markers yet. Razor: a component symbol per file, call edges from `@code` blocks and component tags, C# health markers; no import resolution yet |
| | | ⎯⎯ *tree-sitter parsing stops here. The rungs below are derived from git and imports, not from an AST.* ⎯⎯ |
| **Lightweight** (6) | Clojure · Haskell · Lean 4 · Erlang · HTML · QML | A real file-to-file import graph, no symbol-level claims |
| **Structural** (8) | R · Zig · Julia · Elm · OCaml · Crystal · Nim · D | Git history only: blame, hotspots, co-change. No AST parsing |
-The first three rungs are the **25 languages parsed to a full AST**; all five are
-the **39** on the ladder. Both numbers are worth stating and neither is worth
+The first three rungs are the **26 languages parsed to a full AST**; all five are
+the **40** on the ladder. Both numbers are worth stating and neither is worth
stating alone, so if you only take one thing from this page, take the rung your
language sits on rather than either count.
@@ -89,7 +90,7 @@ meaningless for a script invoked by name. See
| Heritage (extends / implements) | ✅ | ✅ | — | — | — |
| Named bindings | ✅ | ✅ | — | — | — |
| Code-health markers | ✅ | Dart, Pascal | Razor | — | — |
-| Dead code detection | ✅ | ✅ | ✅ | ✅ | ✅ |
+| Dead code detection | ✅ | ✅* | ✅ | ✅ | ✅ |
| Semantic search & wiki pages | ✅ | ✅ | ✅ | ✅ | ✅ |
Scala's import resolution is partial: it shares the JVM index with Java and
@@ -98,6 +99,9 @@ Good language resolves imports outright. On the Partial rung the two languages
split: Luau resolves `require()` and has no health markers, Razor has C#
health markers and no import edges yet.
+\* COBOL is excluded from dead-code claims: JCL, schedulers and dynamic program
+calls are external entry paths that the repository graph cannot observe.
+
---
## Why these graphs are different
@@ -242,15 +246,24 @@ directives are blanked, so a Razor file carries no import edges yet.
## Good tier
-AST parsing, symbol extraction, import resolution, call resolution, named
-bindings and heritage, with a dedicated workspace resolver per language.
+AST parsing, symbol extraction and static call resolution, plus the
+language-appropriate dependency surface. Languages with imports add named
+bindings, heritage and a workspace resolver where their syntax supports them.
-| Language | Extensions | Import resolution |
+| Language | Extensions | Dependency resolution |
|----------|-----------|--------------|
| **C** | `.c` | `#include` via `compile_commands.json` (shares the C++ grammar) |
| **Swift** | `.swift` | SPM `Package.swift` target → directory mapping, intra-module type references, `@main` entry points |
| **PHP** | `.php` | `use Foo\Bar\Baz` with composer.json PSR-4 longest-prefix resolution; Laravel, TYPO3 edges |
| **Dart** | `.dart` | `import` / `export` / `part` URIs, `package:` via every `pubspec.yaml`, Flutter route tables and `runApp()` edges. **Health markers included** |
+| **COBOL** | `.cbl` `.cob` `.cobol` `.cpy` | Program IDs, sections, paragraphs and data levels; literal `CALL` and `PERFORM` targets resolve to program/procedure symbols. Dynamic calls and `COPY` edges are deliberately silent |
+
+COBOL is Good rather than Full because it has no code-health walker. Its static
+dependency surface is narrower than a module language's: literal program calls
+and local procedure transfers resolve, while copybook resolution, dynamic
+`CALL data-item`, dialect-specific syntax and source-format preprocessing are
+explicitly deferred. Dead-code findings are also suppressed because JCL and
+scheduler entry points usually live outside the indexed source graph.
| **Object Pascal** | `.pas` `.pp` `.dpr` `.dpk` `.lpr` `.inc` | `uses` clauses via the generic unit-name → file-stem fallback; project files as entry points. **Health markers included** |
| **GDScript** | `.gd` | `preload(...)` / `load(...)` / `extends "res://..."` resolved as absolute paths from the nearest `project.godot`, so a repo holding many Godot projects keeps each project's `res://` namespace separate, plus scene, autoload and `class_name` edges (see [GDScript / Godot](../architecture/language-support.md#gdscript--godot)) |
| **VB.NET** | `.vb` | `Imports` through the same MSBuild project index C# uses: `.vbproj` / `.sln` parsing, `<RootNamespace>`-aware namespace lookup, NuGet package references |
@@ -379,7 +392,18 @@ cannot check.
- **Template dialects are invisible.** Django/Jinja, Go templates, ERB,
Handlebars, Blade and Thymeleaf parse as HTML and yield nothing.
- **Svelte and Vue binding forms are skipped.** `{#each x as y}` and
- `v-for="x in xs"` parse as JS but mean something else.
+ `v-for="x in xs"` *parse* as JS but mean something else, so they are skipped: a
+ parse that succeeds with the wrong meaning is worse than a skip. Component
+ props are set by the parent as markup attributes and never imported by name, so
+ the unused-export pass is suppressed for both.
+- **Object Pascal type kinds collapse.** `record` / `interface` / class-helper /
+ enum / type alias all report as `kind="class"`, and its `extends` vs
+ `implements` split is inferred from the `I`-prefix naming convention rather
+ than guaranteed by the language.
+- **COBOL support is intentionally COBOL-85 shaped.** Literal `CALL` and
+ `PERFORM` resolve, and `.cpy` files are parsed when indexed directly, but
+ `COPY` does not create an edge. Dynamic program names, dialect extensions and
+ fixed/free-format preprocessing beyond what the grammar accepts stay silent.
- **Razor has no import edges**, and an attribute-bound handler carries none.
- **Object Pascal's `extends`/`implements` split is a naming heuristic**,
inferred from the `I`-prefix convention rather than a language guarantee.
@@ -411,6 +435,7 @@ Per-language mechanics behind these:
| Dart | Good | riverpod / get_it dynamic hints, dataflow dialect |
| GDScript | Good | The health dialects (complexity, performance, dataflow) that would take it to Full; the grammar supports all three |
| Object Pascal | Good | Assertion and performance markers, a dedicated `uses` resolver |
+| COBOL | Good | Copybook resolution, source-format normalization, dialect coverage, health markers |
| VB.NET | Good | Health markers, project-level `<Import Include=...>` as implicit imports |
| Elixir | Good | Health markers, and a call-resolution strategy beyond same-file |
| F# | Good | The health markers beyond complexity, and a resolver that reads the AST index instead of the declared-name regex |
diff --git a/packages/core/src/repowise/core/analysis/dead_code/analyzer.py b/packages/core/src/repowise/core/analysis/dead_code/analyzer.py
index e661a40b1..2aa5a6352 100644
--- a/packages/core/src/repowise/core/analysis/dead_code/analyzer.py
+++ b/packages/core/src/repowise/core/analysis/dead_code/analyzer.py
@@ -24,12 +24,12 @@ import structlog
from ...ingestion.models import REACHABILITY_USE_EDGE_TYPES
from .constants import (
_CONTAINER_USE_LANGUAGES,
+ _DEAD_CODE_EXEMPT_LANGUAGES,
_DEFAULT_DYNAMIC_PATTERNS,
_DELIBERATELY_UNUSED_ANNOTATIONS,
_FRAMEWORK_DECORATOR_SUFFIXES,
_FRAMEWORK_DECORATORS,
_NEVER_PACKAGE_DIRS,
- _NON_CODE_LANGUAGES,
_is_fixture_path,
never_flag_match,
)
@@ -336,8 +336,6 @@ def _non_importable_kinds(language: str) -> frozenset[str]:
return _UNIVERSAL_NON_IMPORTABLE
return _UNIVERSAL_NON_IMPORTABLE | extra
-
-
# Preserved for tests / external callers that imported the old name.
# New code should prefer ``_non_importable_kinds(language)``.
_NON_IMPORTABLE_SYMBOL_KINDS: frozenset[str] = _UNIVERSAL_NON_IMPORTABLE | frozenset({"interface"})
@@ -854,7 +852,7 @@ class DeadCodeAnalyzer:
# (Go / JVM / C-C++) — lives in the predicate, which the overview
# assembler calls with the same state so the two cannot disagree.
# See :mod:`file_reachability`.
- if node_data.get("language", "unknown") in _NON_CODE_LANGUAGES:
+ if node_data.get("language", "unknown") in _DEAD_CODE_EXEMPT_LANGUAGES:
continue
if node_data.get("is_test", False):
continue
@@ -1092,7 +1090,7 @@ class DeadCodeAnalyzer:
continue
node_data = self.graph.nodes[node]
- if node_data.get("language", "unknown") in _NON_CODE_LANGUAGES:
+ if node_data.get("language", "unknown") in _DEAD_CODE_EXEMPT_LANGUAGES:
continue
# Framework-instantiated files (Spring stereotypes, JAX-RS
# resources, Quarkus components, Spring Data repos, …) have
@@ -1730,7 +1728,8 @@ class DeadCodeAnalyzer:
# every file under the candidate dir is config/data (YAML,
# JSON, MD, TOML), it is not a package — it is metadata.
has_code_file = any(
- self.graph.nodes.get(f, {}).get("language", "unknown") not in _NON_CODE_LANGUAGES
+ self.graph.nodes.get(f, {}).get("language", "unknown")
+ not in _DEAD_CODE_EXEMPT_LANGUAGES
for f in files
)
if not has_code_file:
@@ -1860,6 +1859,7 @@ class DeadCodeAnalyzer:
return True
return False
+
def _matches_dynamic_patterns(self, path: str, patterns: tuple[str, ...]) -> bool:
name = Path(path).stem
return any(fnmatch.fnmatch(name, pattern) for pattern in patterns)
@@ -1877,4 +1877,3 @@ class DeadCodeAnalyzer:
dt = dt.replace(tzinfo=UTC)
return (now - dt).days > days
return False
-
diff --git a/packages/core/src/repowise/core/analysis/dead_code/constants.py b/packages/core/src/repowise/core/analysis/dead_code/constants.py
index 142c70c8b..ee01e06e8 100644
--- a/packages/core/src/repowise/core/analysis/dead_code/constants.py
+++ b/packages/core/src/repowise/core/analysis/dead_code/constants.py
@@ -25,6 +25,12 @@ from repowise.core.ingestion.languages.registry import REGISTRY as _LANG_REGISTR
# languages plus "unknown".
_NON_CODE_LANGUAGES: frozenset[str] = _LANG_REGISTRY.unparseable_or_unknown_languages()
+# Code languages whose files/symbols are entered through an external runtime
+# that the static graph cannot observe (COBOL via JCL/schedulers, for example).
+_DEAD_CODE_EXEMPT_LANGUAGES: frozenset[str] = (
+ _NON_CODE_LANGUAGES | _LANG_REGISTRY.dead_code_exempt_languages()
+)
+
# Patterns that should never be flagged as dead.
_NEVER_FLAG_PATTERNS: tuple[str, ...] = (
# Shell scripts are invoked by name from CI configs, Makefiles, and humans
diff --git a/packages/core/src/repowise/core/ingestion/extractors/cobol.py b/packages/core/src/repowise/core/ingestion/extractors/cobol.py
new file mode 100644
index 000000000..086898387
--- /dev/null
+++ b/packages/core/src/repowise/core/ingestion/extractors/cobol.py
@@ -0,0 +1,66 @@
+"""COBOL naming and procedure-range helpers for the declarative parser."""
+
+from __future__ import annotations
+
+import re
+
+from tree_sitter import Node
+
+_SECTION_SUFFIX = re.compile(r"\s+SECTION\s*\.\s*$", re.IGNORECASE)
+_PARAGRAPH_SUFFIX = re.compile(r"\s*\.\s*$")
+_PROGRAM_ID_IN_ERROR = re.compile(r"\bPROGRAM-ID\s*\.\s*([A-Z0-9][A-Z0-9-]*)", re.IGNORECASE)
+_PROCEDURE_HEADERS = frozenset({"section_header", "paragraph_header"})
+
+
+def normalize_cobol_symbol_name(raw_name: str, node_type: str) -> str:
+ """Return COBOL's case-insensitive identifier in a stable graph form."""
+ name = raw_name.strip()
+ if node_type in {"program_definition", "ERROR"}:
+ recovered = _PROGRAM_ID_IN_ERROR.search(name)
+ if recovered:
+ name = recovered.group(1)
+ elif node_type == "section_header":
+ name = _SECTION_SUFFIX.sub("", name)
+ elif node_type == "paragraph_header":
+ name = _PARAGRAPH_SUFFIX.sub("", name)
+ return name.upper()
+
+
+def normalize_cobol_call_target(raw_name: str, _node_type: str) -> str:
+ """Canonicalize static ``CALL`` literals and ``PERFORM`` labels."""
+ name = raw_name.strip()
+ if len(name) >= 2 and name[0] == name[-1] and name[0] in {"'", '"'}:
+ name = name[1:-1]
+ return name.upper()
+
+
+def cobol_symbol_end_line(node: Node, default_end_line: int) -> int:
+ """Extend a section/paragraph header across the procedure body it owns.
+
+ The COBOL grammar represents procedure headers and statements as siblings,
+ unlike languages whose function node wraps its body. Extending the range
+ lets the generic caller-attribution pass select the innermost paragraph.
+ """
+ if node.type == "ERROR":
+ ancestor = node.parent
+ while ancestor is not None:
+ if ancestor.type == "program_definition":
+ return max(default_end_line, ancestor.end_point[0] + 1)
+ ancestor = ancestor.parent
+ return default_end_line
+
+ if node.type not in _PROCEDURE_HEADERS or node.parent is None:
+ return default_end_line
+
+ siblings = node.parent.named_children
+ current = next((index for index, child in enumerate(siblings) if child.id == node.id), None)
+ if current is None:
+ return default_end_line
+
+ stop_types = {"section_header"} if node.type == "section_header" else _PROCEDURE_HEADERS
+ for index in range(current + 1, len(siblings)):
+ if siblings[index].type in stop_types:
+ previous = siblings[index - 1]
+ return max(default_end_line, previous.end_point[0] + 1)
+
+ return max(default_end_line, node.parent.end_point[0] + 1)
diff --git a/packages/core/src/repowise/core/ingestion/language_configs.py b/packages/core/src/repowise/core/ingestion/language_configs.py
index 2aa10d387..b7c5f15e7 100644
--- a/packages/core/src/repowise/core/ingestion/language_configs.py
+++ b/packages/core/src/repowise/core/ingestion/language_configs.py
@@ -12,6 +12,13 @@ from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
+from tree_sitter import Node
+
+from .extractors.cobol import (
+ cobol_symbol_end_line,
+ normalize_cobol_call_target,
+ normalize_cobol_symbol_name,
+)
from .extractors.visibility import (
csharp_visibility,
dart_visibility,
@@ -30,6 +37,10 @@ from .extractors.visibility import (
)
+def _identity_name(name: str, _node_type: str) -> str:
+ return name
+
+
@dataclass
class LanguageConfig:
"""Per-language metadata used by ASTParser.
@@ -65,6 +76,14 @@ class LanguageConfig:
# what tells them apart downstream (see ``Symbol.is_declaration``).
declaration_node_types: frozenset[str] = field(default_factory=frozenset)
+ # Optional syntax-level normalization hooks. Most grammars capture a bare
+ # identifier and use the defaults. Languages whose grammar exposes a full
+ # header or quoted static target can normalize without branching in the
+ # parser.
+ symbol_name_fn: Callable[[str, str], str] = _identity_name
+ call_target_name_fn: Callable[[str, str], str] = _identity_name
+ symbol_end_line_fn: Callable[[Node, int], int] | None = None
+
# Call-site node types that name a symbol without invoking it. Rust's
# ``foo!(..)`` expands a ``macro_rules! foo``; which symbol the name means
# is the same question a call asks, so these still run the call tiers, but
@@ -540,6 +559,26 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {
# guessed).
parent_class_types=frozenset({"declType"}),
),
+ "cobol": LanguageConfig(
+ symbol_node_types={
+ "program_definition": "module",
+ # PROGRAM-ID without its terminal period is recovered as ERROR;
+ # cobol.scm predicates the capture to that header only.
+ "ERROR": "module",
+ "section_header": "function",
+ "paragraph_header": "function",
+ "data_description": "variable",
+ },
+ # COPY/include resolution is intentionally outside this good-tier cut.
+ import_node_types=[],
+ export_node_types=[],
+ visibility_fn=public_by_default,
+ parent_extraction="none",
+ parent_class_types=frozenset(),
+ symbol_name_fn=normalize_cobol_symbol_name,
+ call_target_name_fn=normalize_cobol_call_target,
+ symbol_end_line_fn=cobol_symbol_end_line,
+ ),
"gdscript": LanguageConfig(
symbol_node_types={
# `class_name Foo` names the script-level class. The node spans
diff --git a/packages/core/src/repowise/core/ingestion/languages/registry.py b/packages/core/src/repowise/core/ingestion/languages/registry.py
index 864a1e959..cacdd1b18 100644
--- a/packages/core/src/repowise/core/ingestion/languages/registry.py
+++ b/packages/core/src/repowise/core/ingestion/languages/registry.py
@@ -127,6 +127,10 @@ class LanguageRegistry:
"""Return tags for languages with no AST parser."""
return frozenset(s.tag for s in self._specs.values() if s.is_passthrough)
+ def dead_code_exempt_languages(self) -> frozenset[str]:
+ """Languages whose external runtime makes static reachability unsound."""
+ return frozenset(s.tag for s in self._specs.values() if s.dead_code_exempt)
+
def unparseable_data_languages(self) -> frozenset[str]:
"""Config/markup/data plus infra passthrough tags, without ``openapi``
and ``unknown``.
diff --git a/packages/core/src/repowise/core/ingestion/languages/spec.py b/packages/core/src/repowise/core/ingestion/languages/spec.py
index 230c20bc6..383f40807 100644
--- a/packages/core/src/repowise/core/ingestion/languages/spec.py
+++ b/packages/core/src/repowise/core/ingestion/languages/spec.py
@@ -33,10 +33,14 @@ class LanguageSpec:
is_infra: bool = False # True for dockerfile, makefile, terraform, shell
is_passthrough: bool = False # True = no AST parser (config/data/markup)
is_api_contract: bool = False # True for proto, graphql, openapi
+ # True when files/symbols are invoked primarily by an external runtime and
+ # static reachability therefore cannot support dead-code claims.
+ dead_code_exempt: bool = False
# -- Tree-sitter -----------------------------------------------------
grammar_package: str | None = None # "tree_sitter_python"
grammar_loader: str = "language" # function name in grammar package
+ grammar_loader_args: tuple[str, ...] = () # args for shared grammar packs
scm_file: str | None = None # "python.scm" — None = no AST queries
shares_grammar_with: str | None = None # C shares cpp grammar
diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py b/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py
index e1555856f..929bbc2f8 100644
--- a/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py
+++ b/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py
@@ -14,6 +14,7 @@ from ..spec import LanguageSpec
from .asciidoc import SPEC as _ASCIIDOC
from .c import SPEC as _C
from .clojure import SPEC as _CLOJURE
+from .cobol import SPEC as _COBOL
from .cpp import SPEC as _CPP
from .crystal import SPEC as _CRYSTAL
from .csharp import SPEC as _CSHARP
@@ -104,6 +105,7 @@ ALL_SPECS: tuple[LanguageSpec, ...] = (
_SCALA,
_DART,
_PASCAL,
+ _COBOL,
_GDSCRIPT,
_VBNET,
# -----------------------------------------------------------------
diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/cobol.py b/packages/core/src/repowise/core/ingestion/languages/specs/cobol.py
new file mode 100644
index 000000000..83e809719
--- /dev/null
+++ b/packages/core/src/repowise/core/ingestion/languages/specs/cobol.py
@@ -0,0 +1,26 @@
+"""LanguageSpec for COBOL 85 source and copybook files."""
+
+from ..spec import LanguageSpec
+
+SPEC = LanguageSpec(
+ tag="cobol",
+ display_name="COBOL",
+ extensions=frozenset({".cbl", ".cob", ".cobol", ".cpy"}),
+ # COBOL has no standalone Python grammar wheel. The language pack ships
+ # the maintained ABI-14 nolanlwin/yutaro-sakamoto grammar and returns a
+ # ready-to-use tree_sitter.Language from get_language("cobol").
+ grammar_package="tree_sitter_language_pack",
+ grammar_loader="get_language",
+ grammar_loader_args=("cobol",),
+ scm_file="cobol.scm",
+ # JCL, schedulers and dynamic CALL data-items invoke programs outside the
+ # source graph. Without those inputs, unused/unreachable claims are unsound.
+ dead_code_exempt=True,
+ import_support="none",
+ entry_point_patterns=(),
+ manifest_files=(),
+ shebang_tokens=(),
+ builtin_calls=frozenset({"ACCEPT", "DISPLAY", "GOBACK", "STOP"}),
+ builtin_parents=frozenset(),
+ color_hex="#005CA5",
+)
diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.py
index f9cb442cc..fbc4742e5 100644
--- a/packages/core/src/repowise/core/ingestion/models.py
+++ b/packages/core/src/repowise/core/ingestion/models.py
@@ -41,6 +41,7 @@ LanguageTag = Literal[
"luau",
"dart",
"pascal",
+ "cobol",
"gdscript",
"vbnet",
# Passthrough code languages (no AST parser yet — empty ParsedFile,
diff --git a/packages/core/src/repowise/core/ingestion/parser.py b/packages/core/src/repowise/core/ingestion/parser.py
index 79b28591e..a17212448 100644
--- a/packages/core/src/repowise/core/ingestion/parser.py
+++ b/packages/core/src/repowise/core/ingestion/parser.py
@@ -819,7 +819,10 @@ def _build_language_registry() -> dict[str, Language]:
try:
mod = __import__(spec.grammar_package)
loader_fn = getattr(mod, spec.grammar_loader)
- lang_obj = Language(loader_fn())
+ loaded = loader_fn(*spec.grammar_loader_args)
+ # Standalone grammar wheels return a PyCapsule; shared grammar
+ # packs may return the fully constructed Language directly.
+ lang_obj = loaded if isinstance(loaded, Language) else Language(loaded)
registry[spec.tag] = lang_obj
except Exception as exc:
log.debug(
@@ -1261,7 +1264,7 @@ class ASTParser:
continue
def_node = def_nodes[0]
- name = _node_text(name_nodes[0], src)
+ name = config.symbol_name_fn(_node_text(name_nodes[0], src), def_node.type)
if not name:
continue
@@ -1395,6 +1398,8 @@ class ASTParser:
# the trailing body sibling or call-site attribution stops at the
# signature line.
end_line = def_node.end_point[0] + 1
+ if config.symbol_end_line_fn is not None:
+ end_line = config.symbol_end_line_fn(def_node, end_line)
if export_type is not None:
end_line = export_type.range_node.end_point[0] + 1
# F#: the captured node is the binding's left-hand side, so its
@@ -2066,7 +2071,10 @@ class ASTParser:
continue
site_node = site_nodes[0]
- target_name = _node_text(target_nodes[0], src).strip()
+ target_node = target_nodes[0]
+ target_name = config.call_target_name_fn(
+ _node_text(target_node, src).strip(), target_node.type
+ )
if not target_name:
continue
diff --git a/packages/core/src/repowise/core/ingestion/queries/cobol.scm b/packages/core/src/repowise/core/ingestion/queries/cobol.scm
new file mode 100644
index 000000000..ca83b2f2a
--- /dev/null
+++ b/packages/core/src/repowise/core/ingestion/queries/cobol.scm
@@ -0,0 +1,40 @@
+; repowise — COBOL 85 symbols and static call sites
+; nolanlwin/yutaro-sakamoto grammar, ABI 14 (tree-sitter-language-pack)
+
+; A program definition wraps all four divisions, giving its symbol a useful
+; whole-program range while the name stays the PROGRAM-ID value.
+(program_definition
+ (identification_division
+ (program_name) @symbol.name)) @symbol.def
+
+; IBM course material commonly omits the terminal period after PROGRAM-ID.
+; The grammar recovers the rest of the program but places the header in a
+; direct ERROR node. Older tree-sitter query compilers reject ERROR as a
+; declared child of program_definition, so capture the recovery node directly;
+; the predicate keeps unrelated errors out and the COBOL range hook restores
+; the containing program's end line.
+((ERROR) @symbol.name @symbol.def
+ (#match? @symbol.name "PROGRAM-ID\\s*\\."))
+
+; The grammar exposes headers as leaf nodes, including their punctuation.
+; LanguageConfig normalizes those names and extends their ranges over the
+; following sibling statements for caller attribution.
+(section_header) @symbol.name @symbol.def
+(paragraph_header) @symbol.name @symbol.def
+
+; Every COBOL data level is useful structural context, including copybook
+; contents when a .cpy file is indexed directly.
+(data_description
+ (entry_name) @symbol.name) @symbol.def
+
+; Only literal CALL targets are statically knowable. Identifier/data-item
+; targets are deliberately silent until data-flow support exists.
+(call_statement
+ x: (string) @call.target) @call.site
+
+; PERFORM paragraph/section calls are same-file procedure edges.
+(perform_statement_call_proc
+ procedure: (perform_procedure
+ (label
+ (qualified_word
+ (WORD) @call.target)))) @call.site
diff --git a/pyproject.toml b/pyproject.toml
index 3fa671d2c..ccc189eb5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -50,6 +50,9 @@ dependencies = [
"tree-sitter-scala>=0.23,<1",
"tree-sitter-php>=0.23,<1",
"tree-sitter-pascal>=0.11,<1",
+ # No standalone Python wheel exists for COBOL. This pack supplies the
+ # maintained ABI-14 grammar and caches it on first use.
+ "tree-sitter-language-pack>=1.14,<2",
"tree-sitter-luau>=1.2,<2",
"tree-sitter-bash>=0.23,<1",
"tree-sitter-gdscript>=6.1,<7",
diff --git a/tests/unit/dead_code/test_cobol_external_entry.py b/tests/unit/dead_code/test_cobol_external_entry.py
new file mode 100644
index 000000000..aef0d08cb
--- /dev/null
+++ b/tests/unit/dead_code/test_cobol_external_entry.py
@@ -0,0 +1,48 @@
+"""COBOL programs are entered by JCL/schedulers outside the source graph."""
+
+from __future__ import annotations
+
+import networkx as nx
+
+from repowise.core.analysis.dead_code.analyzer import DeadCodeAnalyzer
+
+
+def _graph(language: str) -> nx.DiGraph:
+ graph = nx.DiGraph()
+ path = f"jobs/payroll.{language}"
+ symbol_id = f"{path}::PAYROLL"
+ graph.add_node(
+ path,
+ node_type="file",
+ language=language,
+ is_entry_point=False,
+ is_test=False,
+ symbol_count=1,
+ )
+ graph.add_node(
+ symbol_id,
+ node_type="symbol",
+ file_path=path,
+ language=language,
+ name="PAYROLL",
+ kind="module",
+ visibility="public",
+ start_line=1,
+ end_line=20,
+ )
+ graph.add_edge(path, symbol_id, edge_type="defines")
+ return graph
+
+
+def test_cobol_file_and_symbols_are_not_reported_as_dead() -> None:
+ report = DeadCodeAnalyzer(_graph("cobol"), git_meta_map={}).analyze(
+ {"detect_zombie_packages": False}
+ )
+ assert report.findings == []
+
+
+def test_ordinary_code_language_remains_in_scope() -> None:
+ report = DeadCodeAnalyzer(_graph("python"), git_meta_map={}).analyze(
+ {"detect_zombie_packages": False}
+ )
+ assert {finding.kind for finding in report.findings} == {"unreachable_file"}
diff --git a/tests/unit/ingestion/parser/test_cobol.py b/tests/unit/ingestion/parser/test_cobol.py
new file mode 100644
index 000000000..c319cab15
--- /dev/null
+++ b/tests/unit/ingestion/parser/test_cobol.py
@@ -0,0 +1,122 @@
+"""COBOL 85 parsing and static call-graph coverage."""
+
+from __future__ import annotations
+
+import pytest
+
+from repowise.core.ingestion.call_resolver import CallResolver
+from repowise.core.ingestion.languages.registry import REGISTRY
+from repowise.core.ingestion.parser import ASTParser
+
+from ._helpers import _make_file_info
+
+grammar_pack = pytest.importorskip(
+ "tree_sitter_language_pack", reason="run `uv sync --all-packages`"
+)
+try:
+ grammar_pack.get_language("cobol")
+except Exception as exc: # pragma: no cover - depends on first-use grammar cache/network
+ pytest.skip(f"COBOL grammar unavailable: {exc}", allow_module_level=True)
+
+
+MAIN_SOURCE = b""" IDENTIFICATION DIVISION.
+ PROGRAM-ID. main-app.
+ DATA DIVISION.
+ WORKING-STORAGE SECTION.
+ 01 CUSTOMER-RECORD.
+ 05 CUSTOMER-NAME PIC X(30).
+ PROCEDURE DIVISION.
+ main-section SECTION.
+ main-paragraph.
+ CALL 'worker' USING CUSTOMER-RECORD.
+ PERFORM cleanup.
+ cleanup.
+ STOP RUN.
+"""
+
+WORKER_SOURCE = b""" IDENTIFICATION DIVISION.
+ PROGRAM-ID. WORKER.
+ PROCEDURE DIVISION.
+ ENTRY-PARAGRAPH.
+ GOBACK.
+"""
+
+
+def _cobol(path: str):
+ return _make_file_info(path, "cobol")
+
+
+class TestCobolRegistration:
+ def test_extensions_and_shared_grammar_loader(self) -> None:
+ spec = REGISTRY.get("cobol")
+ assert spec is not None
+ assert {REGISTRY.from_extension(ext) for ext in (".cbl", ".cob", ".cobol", ".cpy")} == {
+ "cobol"
+ }
+ assert spec.grammar_package == "tree_sitter_language_pack"
+ assert spec.grammar_loader == "get_language"
+ assert spec.grammar_loader_args == ("cobol",)
+
+
+class TestCobolSymbols:
+ def test_program_procedures_and_data_items(self, parser: ASTParser) -> None:
+ result = parser.parse_file(_cobol("main.cbl"), MAIN_SOURCE)
+ symbols = {(symbol.name, symbol.kind): symbol for symbol in result.symbols}
+
+ assert ("MAIN-APP", "module") in symbols
+ assert ("MAIN-SECTION", "function") in symbols
+ assert ("MAIN-PARAGRAPH", "function") in symbols
+ assert ("CLEANUP", "function") in symbols
+ assert ("CUSTOMER-RECORD", "variable") in symbols
+ assert ("CUSTOMER-NAME", "variable") in symbols
+ assert not result.parse_errors
+
+ def test_program_id_without_terminal_period_recovers_name(self, parser: ASTParser) -> None:
+ source = b""" IDENTIFICATION DIVISION.
+ PROGRAM-ID. COURSE01
+ AUTHOR. EXAMPLE.
+ PROCEDURE DIVISION.
+ MAIN-PARAGRAPH.
+ STOP RUN.
+"""
+ result = parser.parse_file(_cobol("course.cobol"), source)
+ modules = [symbol for symbol in result.symbols if symbol.kind == "module"]
+ assert [symbol.name for symbol in modules] == ["COURSE01"]
+
+ def test_procedure_ranges_attribute_calls_to_the_innermost_paragraph(
+ self, parser: ASTParser
+ ) -> None:
+ result = parser.parse_file(_cobol("main.cbl"), MAIN_SOURCE)
+ paragraph = next(symbol for symbol in result.symbols if symbol.name == "MAIN-PARAGRAPH")
+ calls = {call.target_name: call for call in result.calls}
+
+ assert calls["WORKER"].caller_symbol_id == paragraph.id
+ assert calls["CLEANUP"].caller_symbol_id == paragraph.id
+
+
+class TestCobolCalls:
+ def test_static_call_and_perform_resolve(self, parser: ASTParser) -> None:
+ main = parser.parse_file(_cobol("main.cbl"), MAIN_SOURCE)
+ worker = parser.parse_file(_cobol("worker.cbl"), WORKER_SOURCE)
+ parsed = {"main.cbl": main, "worker.cbl": worker}
+ resolver = CallResolver(parsed, {path: set() for path in parsed})
+
+ resolved = resolver.resolve_file("main.cbl", main.calls)
+ targets = {edge.callee_id: edge.origin for edge in resolved}
+
+ assert targets["worker.cbl::WORKER"] == "global_unique"
+ assert targets["main.cbl::CLEANUP"] == "same_file"
+
+ def test_dynamic_call_target_is_deliberately_silent(self, parser: ASTParser) -> None:
+ source = b""" IDENTIFICATION DIVISION.
+ PROGRAM-ID. DYNAMIC-CALLER.
+ DATA DIVISION.
+ WORKING-STORAGE SECTION.
+ 01 PROGRAM-NAME PIC X(8).
+ PROCEDURE DIVISION.
+ MAIN-PARAGRAPH.
+ CALL PROGRAM-NAME.
+ STOP RUN.
+"""
+ result = parser.parse_file(_cobol("dynamic.cbl"), source)
+ assert result.calls == []
diff --git a/tests/unit/ingestion/test_language_capabilities.py b/tests/unit/ingestion/test_language_capabilities.py
index 66d107429..fe8f1a99c 100644
--- a/tests/unit/ingestion/test_language_capabilities.py
+++ b/tests/unit/ingestion/test_language_capabilities.py
@@ -239,6 +239,9 @@ class TestImportSupportTiers:
def test_unknown_language_reports_none(self) -> None:
assert REGISTRY.import_support_for("klingon") == "none"
+ def test_cobol_is_exempt_from_static_dead_code_claims(self) -> None:
+ assert REGISTRY.dead_code_exempt_languages() == frozenset({"cobol"})
+
class TestLanguageTagParity:
def test_every_spec_tag_is_a_language_tag(self) -> None:
diff --git a/uv.lock b/uv.lock
index 6e26fecaa..001da6544 100644
--- a/uv.lock
+++ b/uv.lock
@@ -3092,6 +3092,7 @@ dependencies = [
{ name = "tree-sitter-java" },
{ name = "tree-sitter-javascript" },
{ name = "tree-sitter-kotlin" },
+ { name = "tree-sitter-language-pack" },
{ name = "tree-sitter-luau" },
{ name = "tree-sitter-objc" },
{ name = "tree-sitter-pascal" },
@@ -3192,6 +3193,7 @@ requires-dist = [
{ name = "tree-sitter-java", specifier = ">=0.23,<1" },
{ name = "tree-sitter-javascript", specifier = ">=0.23,<1" },
{ name = "tree-sitter-kotlin", specifier = ">=1,<2" },
+ { name = "tree-sitter-language-pack", specifier = ">=1.14,<2" },
{ name = "tree-sitter-luau", specifier = ">=1.2,<2" },
{ name = "tree-sitter-objc", specifier = ">=3.0.2,<4" },
{ name = "tree-sitter-pascal", specifier = ">=0.11,<1" },
@@ -4163,6 +4165,23 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/fb/b9/12fa97f63d2b7517c6f5d16938f0c5bfe84d925c652c75ff1c5e29bf6a44/tree_sitter_kotlin-1.1.0-cp39-abi3-win_arm64.whl", hash = "sha256:e030f127a7d07952907adb9070248bd42fb86dc76fd92744727551b50e131ee7", size = 310414, upload-time = "2025-01-09T19:02:16.23Z" },
]
+[[package]]
+name = "tree-sitter-language-pack"
+version = "1.14.3"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "tree-sitter" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/c5/43/0d186f771ff8558d69439b8f0396263e1f6941872837cab85346aec99f02/tree_sitter_language_pack-1.14.3.tar.gz", hash = "sha256:5f55908261f4ce53cfaea26f3d70f40197733dd06e885a6327cc6e406e269da4", size = 82317, upload-time = "2026-08-05T19:15:34.08Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/0a/07/0ed8acb286353bbc9dc6724c6fc32b902d85a1da16567788d72d74b3ee88/tree_sitter_language_pack-1.14.3-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:3ae067d4114d8b1b1c80fdafe7479f6ebbdee76002e0b357e16c6ace897ba66d", size = 2197537, upload-time = "2026-08-05T19:15:26.639Z" },
+ { url = "https://files.pythonhosted.org/packages/48/bc/ff15c101fb874f8c80f0f722420915884a1233ddae3eff920f56a5b16b76/tree_sitter_language_pack-1.14.3-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:3b56028bba472b774cdd00eedd2744a1e663a003c522c18071642f2501016212", size = 2091122, upload-time = "2026-08-05T19:15:27.868Z" },
+ { url = "https://files.pythonhosted.org/packages/fa/93/fe18a7da47f9189c75584c6996568d6052f0c9b5b29831cc49f213c8b7e0/tree_sitter_language_pack-1.14.3-cp310-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:b13726ed2c402035ed1b601080a3597a3346dd49764f4b92d09c6f5a1d7d1214", size = 2248100, upload-time = "2026-08-05T19:15:29.455Z" },
+ { url = "https://files.pythonhosted.org/packages/bf/5c/70fa8a6d2bcc2578d38e1853382591134584eea8fa9556477c533d793f0c/tree_sitter_language_pack-1.14.3-cp310-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:c9df8545df48ee11744f9fbd1dcc972a270df9ea485321ce29e352dd64cb1a4c", size = 2357083, upload-time = "2026-08-05T19:15:30.787Z" },
+ { url = "https://files.pythonhosted.org/packages/4a/0a/8525e8ac227504bb4cb1691cb07f8c13eae21e8017bf5b3aa126157d4060/tree_sitter_language_pack-1.14.3-cp310-abi3-win_amd64.whl", hash = "sha256:7aa7786929058d948179e99d1ad16a67d105a3d0bdeca2a11ed2b098edeb0a03", size = 2135211, upload-time = "2026-08-05T19:15:31.928Z" },
+ { url = "https://files.pythonhosted.org/packages/8b/b9/3b7ff538a73ecbfa66d0067be7273fa9775bb8ce361b7a436b921f51358f/tree_sitter_language_pack-1.14.3-cp310-abi3-win_arm64.whl", hash = "sha256:4b0874abbc577e6f81c08a81457fdbea7bb10f50d62ebf33aab54f3fef7d6105", size = 2043231, upload-time = "2026-08-05T19:15:33.074Z" },
+]
+
[[package]]
name = "tree-sitter-luau"
version = "1.2.0"