Metadata-Version: 2.4
Name: kanonik-core
Version: 0.4.3
Summary: Find where BPMN/DMN models and code disagree (Camunda 7 and 8) – deterministic, local, CI-ready; map interface fields to a glossary
Author: Mykhaylo Khazanovych
License-Expression: Apache-2.0
Project-URL: Homepage, https://kanonik.eu
Project-URL: Source, https://github.com/der-weisse-schwan/kanonik-core
Project-URL: Changelog, https://github.com/der-weisse-schwan/kanonik-core/blob/main/CHANGELOG.md
Keywords: bpmn,dmn,camunda,zeebe,static-analysis,process-automation,glossary,wsdl,openapi,shacl
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: rdflib>=7
Requires-Dist: rapidfuzz>=3
Requires-Dist: scikit-learn>=1.3
Requires-Dist: pyyaml>=6
Provides-Extra: neo4j
Requires-Dist: neo4j>=5; extra == "neo4j"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pyshacl>=0.26; extra == "test"
Requires-Dist: regex; extra == "test"
Requires-Dist: rstr; extra == "test"
Dynamic: license-file

# Kanonik Core

[![PyPI](https://img.shields.io/pypi/v/kanonik-core)](https://pypi.org/project/kanonik-core/)
[![Python](https://img.shields.io/pypi/pyversions/kanonik-core)](https://pypi.org/project/kanonik-core/)
[![CI](https://github.com/der-weisse-schwan/kanonik-core/actions/workflows/ci.yml/badge.svg)](https://github.com/der-weisse-schwan/kanonik-core/actions/workflows/ci.yml)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/der-weisse-schwan/kanonik-core/blob/main/LICENSE)

**Find the places where your BPMN models and your code no longer agree – before production does.**

A job type with a typo. A worker that was switched off and never switched on again. A decision table the process
calls but nobody deployed. A process variable spelled `mitarbeiterID` in one class and `mitarbeiterId` in another.
None of this breaks the build, the unit tests usually pass, and reviewers rarely read BPMN XML. In production the
instance just stops.

Kanonik Core reads your repository – BPMN, DMN and code – and lists every such mismatch with the file and place to fix.
It runs locally or in CI, needs no access to a Camunda cluster, uses no AI and sends no data anywhere. Same input, same
result.

## See it in 30 seconds

```bash
pip install kanonik-core
git clone https://github.com/der-weisse-schwan/kanonik-core && cd kanonik-core   # for the examples
kanonik-pruefen --repo examples/kreditantrag
```

```markdown
# BPMN ↔ code: findings

4 findings · 1 process and 3 decisions in the models · 2 classes in the code

| Rule                    | Findings | What happens in production                              |
|-------------------------|----------|---------------------------------------------------------|
| Job without worker      | 1        | Instances get stuck at this step.                       |
| Variable name mismatch  | 1        | The value never arrives; decisions work with empty data.|
| Decision missing        | 1        | The business rule task fails at runtime.                |
| Decision never called   | 1        | Outdated rule – or a call is missing.                   |

## Job without worker
- B03 Job notify-customer has no worker (missing, fix in: code)
  'Kunden benachrichtigen' (kreditantrag.bpmn) expects a worker for the job type notify-customer; no code
  handles it – the process stops at this point. A worker for it is disabled (enabled = false):
  KreditWorker.notifyCustomer.
```

The full report: [examples/kreditantrag/expected/findings.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/kreditantrag/expected/findings.md).

## What it finds

| Finding | Example | In production |
|---|---|---|
| **Job without worker** | the model expects `ship-goods`, no worker handles it (or it is disabled) | instances get stuck |
| **Worker without model** | a worker for `refund-payment` that no model uses | dead code – or a typo on one side |
| **Process start without model** | code starts `bestellung-v2`, the model is `bestellung` | every start fails |
| **Message without sender** | the process waits for `PaymentReceived`, nobody sends it | instances wait forever |
| **Variable name mismatch** | `remaimingAmount` read, `remainingAmount` written (also case: `ID` vs `Id`) | the value never arrives |
| **Decision missing** | a business rule task calls a decision no DMN file contains | the step fails |
| **Decision never called** | a decision in a DMN file that nothing calls | outdated rule – or a forgotten call |
| **Placeholder instead of logic** | an empty worker, a gateway that always takes the same path | results silently missing |
| **Naming mismatch** | task “Send receipt” sends the message `InvoiceSent` | model and code mean different things |
| **Hard-coded data** | a REST endpoint that ignores its input and sends fixed values | every call sends the same data |
| **Model not readable** | a BPMN/DMN file that is not valid XML | cannot be deployed |

Measured on public projects (camunda-8-examples, camunda-bpm-examples, Camunda Marketplace blueprints with code): every
finding was a real defect, no false alarms; nearly all deliberately planted defects were found
([details](https://github.com/der-weisse-schwan/kanonik-core/blob/main/bpmn_code/README.md)).

## Try it on your project

```bash
pip install kanonik-core                        # Python 3.10 or newer
kanonik-pruefen --repo path/to/your-project     # report: ./kanonik-befunde/befunde.md (and befunde.json)
```

Options: `--sprache de` for a German report, `--out <folder>`, `--dienst name=path` (several times) for a repository
with several services, `--streng` to exit with code 1 when there are findings.

## Use it in CI

### GitHub Actions

```yaml
name: Kanonik
on: [pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: der-weisse-schwan/kanonik-core@v0.4.3
```

Every finding appears as an annotation on the changed file in the pull request – on the BPMN element or the Java
method –, the full report lands in the job summary and as artifact `kanonik-befunde`.

| Input | Default | Meaning |
|---|---|---|
| `path` | `.` | folder to check |
| `language` | `en` | report and annotations in `en` or `de` |
| `fail-on` | `error` | fail on findings that break at runtime (`error`), on any finding (`warning`) or `never` |
| `services` | – | one `name=path` per line for a repository with several services |
| `upload-sarif` | `false` | also send the findings to GitHub Code Scanning (needs `security-events: write`; private repositories need GitHub Advanced Security) |
| `upload-report` | `true` | upload the report folder as artifact |

Outputs: `findings`, `errors`, `report`, `sarif`.

### Any other CI

```bash
pip install kanonik-core
kanonik-pruefen --repo . --streng            # exit code 1 when there are findings
```

The report folder `kanonik-befunde/` contains `befunde.md` (for people), `befunde.json` (for scripts; each finding has
a stable key `schluessel`, so runs can be compared) and `befunde.sarif` (SARIF 2.1.0 for code scanning tools and IDEs).

## Examples

Four fictitious projects with planted defects – each runs in seconds ([overview](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/README.md)):

| Example | Stack | Shows |
|---|---|---|
| [Credit application](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/kreditantrag/) | Camunda 8, DMN, Java and Go workers | decisions checked against process and code |
| [Online order](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/bestellung/) | Camunda 8, Spring Boot microservices | the full range of checks |
| [Leave request](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/urlaubsantrag/) | Camunda 7, Spring delegates | Camunda 7 support |
| [Library interface](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/bibliothek-schnittstelle/) | WSDL/XSD, code lists, glossary | which glossary terms the interface really contains |

## The second tool: glossary ↔ interface

Business and IT often use different words for the same thing. `kanonik-kg` reads your interfaces (WSDL/XSD, OpenAPI,
AsyncAPI, JSON Schema) and your glossary (CSV, YAML or JSON) and shows which terms the interface really contains,
which terms are missing and which fields have no agreed term – plus the interface as a graph with SHACL shapes. The graph is written as CSV and Cypher; to load it straight into Neo4j
(`--neo4j-uri`), install the driver with `pip install "kanonik-core[neo4j]"`.

```bash
kanonik-kg run --wsdl examples/bibliothek-schnittstelle/dienste --codelists examples/bibliothek-schnittstelle/codelisten \
               --glossar examples/bibliothek-schnittstelle/glossar.csv --out out/
```

Report: [examples/bibliothek-schnittstelle/expected/glossary.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/examples/bibliothek-schnittstelle/expected/glossary.md)
(`--sprache de` for German). Details: [kg/README.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/kg/README.md).

## What it reads

- **Camunda 8:** Spring `@JobWorker` (with or without `type`, `enabled = false`), Java client `.jobType(…)`, workers in
  Go, C#, Node and Python (job type), execution and task listeners, connectors (element templates, `io.camunda:…`),
  business rule tasks and DMN.
- **Camunda 7:** `JavaDelegate` and listeners (class, `${bean}`, `${bean.method(…)}`), external tasks, `decisionRef`.
- **Code:** Java (Spring, Kafka, REST), process variables, messages, process starts.

## Limits

- The code is read as text, not compiled. Job types computed at runtime (`type="=variable"`) cannot be checked.
- Workers in languages other than Java are recognised by their job type only.
- Names in the models (task names, ids) appear in the report as written; rule keys and some identifiers are German
  (`job_ohne_worker`) – the report shows an English name next to them.

## FAQ

**Does it need my Camunda cluster or credentials?** No. It only reads files in the repository.

**Does it send code anywhere or use an LLM?** No. Everything runs locally and deterministically.

**What if a finding is intended?** Thresholds and word lists are configurable (`python -m kanonik.annahmen`); each
finding has a stable key you can filter on in CI.

**How does it relate to Kanonik?** Kanonik Core is the open part of [Kanonik](https://kanonik.eu). Kanonik additionally
checks models, code and interfaces against the business specification itself – which requirement is implemented
where, and what is missing.

## More

- Technical reference: [bpmn_code/README.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/bpmn_code/README.md) (rules, readers, measurement),
  [kg/README.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/kg/README.md) (interfaces, glossary, graph)
- [CHANGELOG.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/CHANGELOG.md) · [CONTRIBUTING.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/CONTRIBUTING.md) · [SECURITY.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/SECURITY.md) · [NOTICE](https://github.com/der-weisse-schwan/kanonik-core/blob/main/NOTICE)
- Deutsch: [README.de.md](https://github.com/der-weisse-schwan/kanonik-core/blob/main/README.de.md)

License: Apache-2.0 ([LICENSE](https://github.com/der-weisse-schwan/kanonik-core/blob/main/LICENSE)).
