Report Contract
The machine-readable reports are CIMVocabCheck's integration surface for everything that is not Java: CI systems, and tools or bindings written in .NET, Python, Rust, TypeScript, … They read a report instead of calling the API, so the report's shape is a published contract rather than an implementation detail.
--format | Document | Consumer |
|---|---|---|
text (default) | Compiler-style lines | Humans, terminal output |
json | The report described on this page | Bindings, custom tooling, jq |
codequality (alias gitlab) | Code Quality array | GitLab merge-request annotations |
sarif | SARIF 2.1.0 log | GitHub code scanning, Azure DevOps, IDE viewers |
All of them are written to stdout — redirect them to a file. A one-line human summary goes to
stderr so a CI log still shows the outcome, and the exit code
(0 clean, 1 findings, 2 usage, configuration or internal error — no report) is unchanged by
the format.
The JSON report
A query that looks for state-variable data in a graph scoped to the Equipment profile, with the CGMES 3.0 Equipment and StateVariables profiles loaded:
PREFIX cim: <http://iec.ch/TC57/CIM100#>
SELECT ?voltage WHERE {
GRAPH <urn:uuid:equipment> { ?voltage a cim:SvVoltage }
}
cim:SvVoltage is spelled correctly but belongs to StateVariables, so the finding carries the
profile it does exist in:
{
"contractVersion": "1.0",
"tool": { "name": "cimvocabcheck", "version": "1.4.2" },
"summary": { "files": 1, "valid": 0, "invalid": 1, "errors": 1, "warnings": 0, "infos": 0 },
"results": [
{
"file": "queries/voltages.rq",
"valid": false,
"annotations": [
{
"severity": "ERROR",
"code": "UNKNOWN_CLASS",
"line": 3,
"column": 43,
"term": "http://iec.ch/TC57/CIM100#SvVoltage",
"graph": "urn:uuid:equipment",
"message": "Class <http://iec.ch/TC57/CIM100#SvVoltage> does not exist in graph <urn:uuid:equipment> / selected profile [CoreEquipment-EU/3.0]. Exists in profile [StateVariables-EU/3.0].",
"foundInOtherProfiles": ["http://iec.ch/TC57/ns/CIM/StateVariables-EU/3.0"]
}
]
}
]
}
| Field | Notes |
|---|---|
contractVersion | Version of this contract, "<major>.<minor>" — not the tool version |
tool.name / tool.version | Always cimvocabcheck; the version is unknown when the engine runs from a checkout rather than a released artifact |
summary.files / valid / invalid | Input counts; a file is invalid when it has at least one ERROR after strictness |
summary.errors / warnings / infos | Finding counts for this document — i.e. after the --verbose filter, so they always account for exactly what results contains |
results[].file | The input as passed on the command line, or <stdin> for stdin — invoke with repository-relative paths |
results[].valid | Decided before filtering, so it does not change with --verbose |
annotations[].severity | ERROR, WARN, INFO, after strictness; tolerate others (see Compatibility) |
annotations[].code | The rule code — key automation off this, never off message |
annotations[].line / column | 1-based, when resolvable; columns count UTF-16 code units. Findings inside embedded SPARQL point at their line in the Turtle source |
annotations[].term | The offending IRI, when the finding is about one term. Reported verbatim, so it may contain non-ASCII characters (cim:Übertrager): an IRI, not necessarily a URI |
annotations[].graph | Named graph the finding occurred in, under per-graph scoping |
annotations[].message | Human-readable; not stable across releases |
annotations[].foundInOtherProfiles | For UNKNOWN_CLASS/UNKNOWN_PROPERTY: profiles where the term does exist — the "wrong profile in scope" hint — in IRI order |
Optional fields are omitted rather than emitted as null.
JSON Schema
The report is published as a JSON Schema (draft-07) at
cimvocabcheck/schemas/cimvocabcheck-report-1.schema.json.
Generate your binding's result types from it rather than hand-writing them; the file name carries
the contract major, so a future incompatible contract arrives as a new file next to this one.
The code and severity lists are open: each is an anyOf of the values known to this
version and a plain string. A report from a newer 1.x engine therefore still validates, and a
generator that follows the schema produces a string with documented values, not a closed enum
that would reject the next new code. CIMVocabCheck's own test suite validates the CLI's real
output against this file.
Compatibility
| Change | Contract bump | Consumer obligation |
|---|---|---|
| New optional field | minor | Ignore unknown fields |
| New rule code | minor | Treat an unrecognised code as a generic finding — never as an error |
New severity, always less severe than ERROR | minor | Treat an unrecognised severity as non-blocking; valid and the exit code stay authoritative |
| New output format | minor | — |
Rename/remove a field, rename a code, change what a code means, a severity that blocks like ERROR | major | New schema file, announced in the release notes |
A consumer should accept any report whose contractVersion major matches the one it was written
against. Message texts and the set of findings can change in any release — that is the tool
improving, not a contract break.
SARIF
--format sarif emits a SARIF 2.1.0 log: one run, whose driver declares a rule per code actually
reported, and one result per finding carrying its own level (ERROR → error, WARN → warning,
INFO → note). Because the level lives on the result, promoting severities with --strictness is
reflected in the log without redefining rules.
Artifact URIs are the file arguments, percent-encoded (my queries/q.rq → my%20queries/q.rq)
and relative to %SRCROOT%, so invoke the CLI with repository-relative paths. An absolute argument
becomes a file: URI, which code scanning cannot map onto the repository. A clean run still emits a valid log with an empty results array —
uploading it is what clears previously reported alerts.
- name: Validate SPARQL
run: java -jar cimvocabcheck-cli.jar --schema schemas -f sarif queries/*.rq > cimvocabcheck.sarif
continue-on-error: true # findings must not skip the upload below
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: cimvocabcheck.sarif
Finding fingerprints
The codequality and sarif reports both carry a stable fingerprint per finding — fingerprint
in Code Quality, partialFingerprints["cimvocabcheckFinding/v1"] in SARIF — and the same finding
has the same fingerprint in both. It is derived from the file, code and offending term. It
deliberately leaves out:
- the position, so editing a file above a finding does not close that finding and open a new one in GitLab or GitHub code scanning;
- the rendered message, so a finding stays trackable when its wording changes.
Repeated findings with the same file, code and term are told apart by their order of occurrence in the file. Every report lists a file's findings in source order — by line, then column — so that order is the same on every run over the same input.
Up to CIMVocabCheck 1.2, Code Quality fingerprints included the line and column. The first pipeline after upgrading therefore shows every existing finding as resolved and reported again, once; from then on they stay stable across edits above them. SARIF output is new since then, so it is not affected.
Writing a binding
There are three already — Python, .NET and Rust — all generated from this schema by one shared generator. For any other language:
- Batch. Loading a CGMES profile set costs about a second; validating a query after that costs almost nothing. Pass every input to one invocation instead of spawning per file.
- Pass argv, not a shell string — paths contain spaces.
- Treat exit code
2as a usage, configuration or internal failure, not as "invalid input": stdout holds no report in that case. - Pin the contract, not the wording. Switch on
code, tolerate codes you do not know, and ignore fields you do not know. - Generate the result type from the schema rather than hand-writing it, and regenerate on every contract minor with a CI check that fails when the two have drifted apart.