# openmainframeproject/cobol-check architecture

> Architecture diagram of the GitHub repository openmainframeproject/cobol-check, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openmainframeproject/cobol-check
- Repository: https://github.com/openmainframeproject/cobol-check

## Overview

1. **Repository shape**
   This is a dual-repo project: a **Java/Gradle command-line tool** at the root, plus a **Visual Studio Code extension** under `vs-code-extension/`. The Java tool is the core engine; the VS Code extension is a client/UI wrapper around the same Cobol-check workflow.

2. **Primary runtime: Java CLI engine**
   The main application entrypoint is `org.openmainframeproject.cobolcheck.Main`. The Java code is organized around feature controllers and workers, suggesting a staged batch pipeline rather than a long-lived service. The build produces a runnable JAR and ZIP distribution (`build/libs`, `build/distributions`).

3. **End-to-end data flow**
   The core flow is: **read command-line/config → parse Cobol test suites → expand/prepare Cobol sources and copybooks → generate or modify test Cobol → launch external Cobol execution → capture output → format results**. The system is built to work on local files and external Cobol toolchains, not to embed a Cobol compiler itself.

4. **Input boundary: Cobol sources and `.cut` test suites**
   The repository contains real Cobol sample programs under `src/main/cobol/` and test suites under `src/test/cobol/`. The `.cut` files are the test-suite format that the parser consumes. This is the key domain boundary: plain Cobol source files and Cobol-check test description files enter the pipeline.

5. **Test-suite parsing and code generation**
   The `features/testSuiteParser` package is the heart of the Cobol-check DSL. It contains the parser, keyword extraction, mock handling, before/after hooks, and generation logic (`TestSuiteParser`, `KeywordExtractor`, `MockGenerator`, `CobolGenerator`, `WhenOtherGenerator`, etc.). This subsystem turns test-suite declarations into executable Cobol test code and tracks syntax/semantic errors.

6. **Cobol source interpretation and copybook expansion**
   The `features/interpreter` and `services/cobolLogic` packages handle Cobol-specific analysis: line classification, tokenization, replace processing, paragraph/section tracking, numeric field handling, and copybook expansion. The `CopybookExpander`, `Interpreter`, and replace/tokenizer classes are critical because Cobol syntax and copybook inclusion materially affect how tests are generated and where assertions can be inserted.

7. **Preparation and merge stage**
   The `features/prepareMerge` package indicates an intermediate phase that merges or prepares source and generated artifacts before execution. This is where file selection and file-system layout matter, especially for mixed inputs like expanded copybooks, generated test files, and output directories.

8. **Execution boundary: external Cobol runtime**
   Cobol-check does not execute Cobol itself; it shells out through `features/launcher`. The `ProcessLauncher` abstraction has platform-specific implementations for Linux and Windows, which is a major architectural boundary. The launcher writes process output and likely invokes GnuCOBOL or another installed Cobol runtime/compiler via scripts such as `scripts/linux_gnucobol_run_tests` and `scripts/windows_gnucobol_run_tests.cmd`.

9. **Result formatting and reporting**
   Execution results are transformed into multiple output shapes by the launcher formatter layer: `JUnitDto`, `TableDocumentDto`, and formatters for `XML`, `HTML`, and text. This is the reporting boundary consumed by CI and by users who need machine-readable test output or human-readable summaries.

10. **Configuration, platform, and utility layer**
   Shared infrastructure lives under `services/`: config loading, message localization, logging, versioning, platform detection, path/file helpers, and tuple/string helpers. These are cross-cutting concerns that support all stages of the pipeline, especially platform-specific execution and file resolution.

11. **VS Code extension architecture**
   The extension is a separate TypeScript project with a **client** and **server**. The client layer handles extension activation, config, launch orchestration, output parsing, and test-tree UI. The server layer provides language-service behavior for `.cut` files. The extension bundles its own Cobol-check distribution and sample Cobol files under `vs-code-extension/Cobol-check/`, acting as an integrated front end rather than a thin remote client.

12. **Test assets and validation strategy**
   The repo is heavily test-driven with Java unit/integration tests, approval-test fixtures, and Cobol sample programs. The `testfiles/`, `testsuites/`, and `src/test/cobol/` directories provide end-to-end scenarios for parsing, generation, mocking, and result formatting. CI workflows in `.github/workflows/` and the separate approval scripts show that the architecture is validated across OS/platform boundaries.

13. **Important architectural constraint**
   The project’s main complexity comes from **Cobol syntax handling plus cross-platform process execution**. For a diagram, the most important boundaries are:  
   - Cobol-check parser/generator vs. external Cobol toolchain  
   - Java core vs. VS Code extension  
   - source/test files vs. generated/expanded artifacts  
   - platform-neutral logic vs. Windows/Linux launcher implementations

Main entry points: [`vs-code-extension/client/src/services/CobolCheckLauncher.ts`](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckLauncher.ts) (Ext launcher), [`src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParser.java`](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParser.java) (Test parser), [`src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java`](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java) (Cobol interp), [`src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandlerController.java`](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandlerController.java) (Args)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_java_core["Java CLI core"]
  node_main(("Main<br/>CLI entry<br/>[Main.java]"))
  node_args["Args<br/>input setup"]
  node_parser["Test parser<br/>dsl parser"]
  node_cobgen["Cobol gen<br/>code generator"]
  node_interp["Cobol interp<br/>source analysis"]
  node_copybook["Copybook expander<br/>copybook expansion"]
  node_prepmerge["Prepare merge<br/>artifact staging"]
  node_runner["Test runner<br/>orchestration"]
  node_launch["Launcher<br/>process boundary"]
  node_fmt["Formatters<br/>reporting<br/>[Formatter.java]"]
  node_writer["Cobol writer<br/>file output"]
  node_services["Shared services<br/>cross-cutting<br/>[Config.java]"]
  node_process["OS launchers<br/>platform impl"]
  node_runtime{{"Cobol runtime<br/>external toolchain"}}
end

subgraph group_vscode_ext["VS Code extension"]
  node_ext_main(("Extension<br/>VS Code entry<br/>[extension.ts]"))
  node_ext_cfg["Ext config<br/>settings"]
  node_ext_launch["Ext launcher<br/>client orchestration"]
  node_ext_parse["Input parser<br/>cut parser"]
  node_ext_out["Output parser<br/>result parsing"]
  node_lang_srv["Language server<br/>TS server<br/>[server.ts]"]
  node_bundled_core[("Bundled core<br/>packaged runtime")]
end

subgraph group_repo_assets["Cobol assets"]
  node_test_assets["Test suites<br/>domain assets"]
  node_cobol_src["Cobol sources<br/>domain assets"]
end

node_main -->|"bootstraps"| node_args
node_args -->|"reads config"| node_services
node_args -->|"starts flow"| node_runner
node_runner -->|"parses suites"| node_parser
node_parser -->|"generates"| node_cobgen
node_parser -->|"emits artifacts"| node_writer
node_runner -->|"analyzes source"| node_interp
node_interp -->|"expands includes"| node_copybook
node_interp -->|"uses helpers"| node_services
node_cobgen -->|"prepares run"| node_prepmerge
node_prepmerge -->|"hands off"| node_launch
node_launch -->|"platforms"| node_process
node_process -->|"invokes"| node_runtime
node_launch -->|"formats results"| node_fmt
node_fmt -->|"persists output"| node_writer
node_test_assets -->|"input"| node_parser
node_cobol_src -->|"input"| node_interp
node_ext_main -->|"activates"| node_ext_cfg
node_ext_main -->|"orchestrates"| node_ext_launch
node_ext_launch -->|"reads input"| node_ext_parse
node_ext_launch -->|"reads output"| node_ext_out
node_ext_launch -->|"uses bundle"| node_bundled_core
node_bundled_core -->|"invokes"| node_runtime
node_lang_srv -->|"supports UI"| node_ext_main
node_bundled_core -->|"ships samples"| node_test_assets

click node_main "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/Main.java"
click node_args "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandlerController.java"
click node_parser "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParser.java"
click node_cobgen "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java"
click node_interp "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java"
click node_copybook "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/CopybookExpander.java"
click node_prepmerge "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/prepareMerge/PrepareMergeController.java"
click node_runner "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/workers/CobolTestRunner.java"
click node_launch "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/launcher/LauncherController.java"
click node_fmt "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/launcher/Formatter/Formats/Formatter.java"
click node_writer "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/writer/WriterController.java"
click node_services "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/services/Config.java"
click node_process "https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/launcher/ProcessLauncher.java"
click node_ext_main "https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/extension.ts"
click node_ext_cfg "https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckConfiguration.ts"
click node_ext_launch "https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckLauncher.ts"
click node_ext_parse "https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckInputParser.ts"
click node_ext_out "https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckOutputParser.ts"
click node_lang_srv "https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/server/src/server.ts"
click node_test_assets "https://github.com/openmainframeproject/cobol-check/tree/Developer/src/test/cobol"
click node_cobol_src "https://github.com/openmainframeproject/cobol-check/tree/Developer/src/main/cobol"
click node_bundled_core "https://github.com/openmainframeproject/cobol-check/tree/Developer/vs-code-extension/Cobol-check"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_args,node_parser,node_cobgen,node_interp,node_copybook,node_prepmerge,node_runner,node_launch,node_fmt,node_writer,node_services,node_process,node_runtime toneBlue
class node_ext_main,node_ext_cfg,node_ext_launch,node_ext_parse,node_ext_out,node_lang_srv,node_bundled_core toneAmber
class node_test_assets,node_cobol_src toneMint
```

## Components

### Java CLI core

Gradle-based Cobol-check engine and packaged runtime

- [Main](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/Main.java): CLI entry · Java application entrypoint · `src/main/java/org/openmainframeproject/cobolcheck/Main.java`
- [Args](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandlerController.java): input setup · Command-line argument handling and environment bootstrap · `src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandlerController.java`
- [Test parser](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParser.java): dsl parser · Parses .cut suites, keywords, mocks, hooks, and generation rules · `src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParser.java`
- [Cobol gen](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java): code generator · Generates executable Cobol from parsed test-suite declarations · `src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java`
- [Cobol interp](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java): source analysis · Interprets Cobol structure, tokens, paragraphs, and copybooks · `src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java`
- [Copybook expander](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/CopybookExpander.java): copybook expansion · Expands included copybooks and normalizes source layout · `src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/CopybookExpander.java`
- [Prepare merge](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/prepareMerge/PrepareMergeController.java): artifact staging · Selects, prepares, and merges source and generated files before run · `src/main/java/org/openmainframeproject/cobolcheck/features/prepareMerge/PrepareMergeController.java`
- [Test runner](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/workers/CobolTestRunner.java): orchestration · Coordinates generation and execution workflow · `src/main/java/org/openmainframeproject/cobolcheck/workers/CobolTestRunner.java`
- [Launcher](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/launcher/LauncherController.java): process boundary · Launches external Cobol toolchain through OS-specific process launchers · `src/main/java/org/openmainframeproject/cobolcheck/features/launcher/LauncherController.java`
- [Formatters](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/launcher/Formatter/Formats/Formatter.java): reporting · Transforms execution results into JUnit, XML, HTML, table, and text outputs · `src/main/java/org/openmainframeproject/cobolcheck/features/launcher/Formatter/Formats/Formatter.java`
- [Cobol writer](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/writer/WriterController.java): file output · Writes generated Cobol artifacts and output files · `src/main/java/org/openmainframeproject/cobolcheck/features/writer/WriterController.java`
- [Shared services](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/services/Config.java): cross-cutting · Config, platform, logging, messages, paths, and Cobol helpers · `src/main/java/org/openmainframeproject/cobolcheck/services/Config.java`
- [OS launchers](https://github.com/openmainframeproject/cobol-check/blob/Developer/src/main/java/org/openmainframeproject/cobolcheck/features/launcher/ProcessLauncher.java): platform impl · Windows and Linux process-launch implementations · `src/main/java/org/openmainframeproject/cobolcheck/features/launcher/ProcessLauncher.java`
- **Cobol runtime**: external toolchain · External Cobol compiler/runtime invoked by scripts

### VS Code extension

TypeScript extension with client and language server

- [Extension](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/extension.ts): VS Code entry · Extension activation and UI orchestration · `vs-code-extension/client/src/extension.ts`
- [Ext config](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckConfiguration.ts): settings · Reads and applies Cobol-check extension configuration · `vs-code-extension/client/src/services/CobolCheckConfiguration.ts`
- [Ext launcher](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckLauncher.ts): client orchestration · Starts Cobol-check runs from the editor · `vs-code-extension/client/src/services/CobolCheckLauncher.ts`
- [Input parser](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckInputParser.ts): cut parser · Parses editor input and .cut test tree structure · `vs-code-extension/client/src/services/CobolCheckInputParser.ts`
- [Output parser](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/client/src/services/CobolCheckOutputParser.ts): result parsing · Parses execution output back into extension views · `vs-code-extension/client/src/services/CobolCheckOutputParser.ts`
- [Language server](https://github.com/openmainframeproject/cobol-check/blob/Developer/vs-code-extension/server/src/server.ts): TS server · Server-side support for .cut language features · `vs-code-extension/server/src/server.ts`
- [Bundled core](https://github.com/openmainframeproject/cobol-check/tree/Developer/vs-code-extension/Cobol-check): packaged runtime · VS Code-bundled Cobol-check distribution, scripts, and sample files · `vs-code-extension/Cobol-check`

### Cobol assets

Sample Cobol sources, test suites, and generated fixtures

- [Test suites](https://github.com/openmainframeproject/cobol-check/tree/Developer/src/test/cobol): domain assets · .cut suites used to drive parser, generator, and end-to-end scenarios · `src/test/cobol`
- [Cobol sources](https://github.com/openmainframeproject/cobol-check/tree/Developer/src/main/cobol): domain assets · Sample Cobol programs and copybooks used by the engine · `src/main/cobol`

## Connections

- Main → Args: bootstraps · Main delegates startup to argument and environment setup
- Args → Shared services: reads config · Arguments resolve paths, config, platform, and messages
- Args → Test runner: starts flow · CLI dispatches the batch pipeline
- Test runner → Test parser: parses suites · Test suites are turned into executable generation plans
- Test parser → Cobol gen: generates · Parsed DSL drives Cobol test code generation
- Test parser → Cobol writer: emits artifacts · Generated source and intermediate files are written out
- Test runner → Cobol interp: analyzes source · Cobol source is interpreted before generation and insertion
- Cobol interp → Copybook expander: expands includes · Copybooks are resolved and expanded as part of interpretation
- Cobol interp → Shared services: uses helpers · Cobol analysis relies on shared helpers and logic services
- Cobol gen → Prepare merge: prepares run · Generated Cobol is staged with source artifacts
- Prepare merge → Launcher: hands off · Prepared inputs are passed to the execution boundary
- Launcher → OS launchers: platforms · Launcher selects Linux or Windows process implementation
- OS launchers → Cobol runtime: invokes · OS process wrappers call the external Cobol toolchain
- Launcher → Formatters: formats results · Raw execution output is converted into structured reports
- Formatters → Cobol writer: persists output · Formatted reports and artifacts are written to disk
- Test suites → Test parser: input · .cut files are the parser's primary domain input
- Cobol sources → Cobol interp: input · Cobol sources and copybooks enter the interpreter pipeline
- Extension → Ext config: activates · Extension startup loads settings
- Extension → Ext launcher: orchestrates · Extension coordinates run launch and UI updates
- Ext launcher → Input parser: reads input · Editor content and test tree are parsed before launch
- Ext launcher → Output parser: reads output · Execution output is parsed back into extension state
- Ext launcher → Bundled core: uses bundle · The extension runs its packaged Cobol-check distribution
- Bundled core → Cobol runtime: invokes · Bundled scripts shell out to the Cobol runtime
- Language server → Extension: supports UI · Language-server features augment the extension client
- Bundled core → Test suites: ships samples · Bundled distribution includes sample Cobol and .cut files
