A configuration check prints "Missing required field: name". An editor extension finds that string, extracts the field name, and underlines the relevant location. A developer then improves the wording: "Task name is required". The message is clearer for a person, but the extension no longer displays the error.

When software parses human-readable wording, an editorial change becomes an interface change. I want the consumer to have an error code, a location, and a format version it can rely on. The explanation can then be improved separately.

We will use a small CLI that validates a task configuration. We will define a JSON report and a consumer on which compatibility changes can be checked. This is an independent educational example. Its commands, fields, and versioning policy are not presented as NexFlow's current interface.

Who reads the result?

Our report has two consumers. CI needs to know whether validation completed and whether the configuration contains errors. The editor extension needs an explanation and a path to the problematic value.

Neither needs to identify the error by recognizing the phrase "Missing required field". We introduce a stable code, CONFIG_REQUIRED, for that purpose. The message can be in English or Russian and can include more explanation. As long as the code retains its meaning, machine processing does not depend on that wording.

The codes also need a contract. If CONFIG_REQUIRED used to mean a missing field but now means an unknown reference, the JSON structure remains valid while the integration misleads its user. A schema alone cannot establish that kind of compatibility.

A small report with explicit meaning

Start with this record:

{ "format_version": 1, "tool_version": "1.4.0", "valid": false, "diagnostics": [ { "code": "CONFIG_REQUIRED", "severity": "error", "message": "Missing required field: name", "path": ["tasks", 0, "name"] } ] } 

tool_version identifies the program that performed validation. format_version identifies a generation of the diagnostic contract. They need not change together: several releases of the program may emit the same report format.

Here, path is a sequence of keys and indexes: the name field of the first item in tasks. The string "0" differs from the number 0. The string denotes an object key; the number denotes an array index. Exact line-and-column highlighting could be added separately, with its index origin and units defined. A consumer is not expected to derive a line number from a logical path alone.

A successful result has valid: true and diagnostics: []. Under this educational contract, a warning does not make the configuration invalid; an error does. Those rules need to be explicit, or the two consumers may interpret the same report differently.

Paths and messages must not repeat secret field values. A diagnostic about an invalid token can point to its location without including the token. Using JSON does not, by itself, make a log safe to publish.

JSON goes to stdout, explanations to stderr

For configcheck validate config.json --format json, we agree that stdout contains exactly one JSON document. Progress output, debugging information, and human explanations can go to stderr when needed.

This output does not meet that contract:

Checking configuration... {"format_version":1,"tool_version":"1.4.0","valid":true,"diagnostics":[]} 

The first line already prevents json.loads from parsing the entire stream. Two adjacent JSON objects without a separate framing protocol do not become one JSON document either. The Python json documentation explicitly notes this property. An event stream can use another documented format, but an existing output mode must not silently switch to it.

For this exercise, exit status 0 means completed validation without configuration errors, 1 means completed validation with configuration errors, and 2 means a tool failure. This is our choice, not a universal CLI convention. On status 2, the consumer does not accept partial output as a completed validation result.

The JSON and exit status must agree. If stdout says valid: false while the process exits with 0, CI should not pick the convenient half of the result and let the build pass.

What version 1 can accept

Suppose a diagnostic needs an optional hint. The old extension displays message and does not yet use hints. A release can retain format_version: 1 if ignoring additional fields was part of the original agreement.

That requires the old consumer to behave accordingly. If its JSON Schema uses additionalProperties: false, a new hint makes the record invalid under that schema. JSON Schema documents that behavior directly. An open-ended extension policy and an unchanged closed set of fields are incompatible promises.

Our educational report allows unknown fields, provided they do not change the meaning of the required ones. This choice applies to diagnostic reports, not arbitrary settings that influence execution. An unknown execution option may reasonably require rejection rather than being ignored.

Unknown diagnostic codes are allowed too. The extension displays their messages and severity generically; it does not lose a diagnostic because it lacks a special icon for the new code. An unknown severity such as fatal, however, is not silently treated as success. Our supported values are error, warning, and info.

A new required field, a different path type, a changed code meaning, or different rules for valid may require a new contract generation. Our old consumer rejects format_version: 2 with an explicit unsupported-format error. It does not guess the meaning from similar-looking keys.

Check the contract before displaying the result

This is the main function from diagnostics_consumer.py. It preserves extra fields, but its decision depends on validated required fields.

"""An illustrative CLI report consumer, independent of any product contract.""" import json def load_report(stdout, returncode): if returncode not in (0, 1): raise ValueError("tool did not produce a completed validation result") report = json.loads(stdout) if not isinstance(report, dict): raise ValueError("report must be an object") version = report.get("format_version") if type(version) is not int or version != 1: raise ValueError("unsupported diagnostic format") if not isinstance(report.get("tool_version"), str): raise ValueError("tool_version must be a string") if type(report.get("valid")) is not bool: raise ValueError("valid must be a boolean") diagnostics = report.get("diagnostics") if not isinstance(diagnostics, list): raise ValueError("diagnostics must be a list") for item in diagnostics: if not isinstance(item, dict): raise ValueError("diagnostic must be an object") for name in ("code", "severity", "message"): if not isinstance(item.get(name), str) or not item[name]: raise ValueError(f"{name} must be a nonempty string") if item["severity"] not in ("error", "warning", "info"): raise ValueError("unsupported severity") path = item.get("path") if not isinstance(path, list) or not all( isinstance(part, str) or (type(part) is int and part >= 0) for part in path ): raise ValueError("path must contain keys or nonnegative indexes") has_error = any(item["severity"] == "error" for item in diagnostics) if report["valid"] != (not has_error): raise ValueError("valid and diagnostics disagree") if returncode != (0 if report["valid"] else 1): raise ValueError("exit status and report disagree") return report 

The module uses only Python's standard library. It checks field types, the format version, supported severity values, and agreement between diagnostics, result, and exit status. It consumes one limited format; it does not implement arbitrary JSON Schema validation.

A separate schema can document structure and support generators or other languages. If it is used alongside this consumer, their expectations need to agree, including which additions are allowed and which fields are required. Code semantics and compatibility policy still need a written explanation.

Test the change against the old consumer

Retain the original report as a fixture. Then create another version: tool version 1.4.1, the same format version, a Russian translation of message, an extra diagnostic hint, and a top-level duration_ms.

The old consumer should read both reports, retain CONFIG_REQUIRED, and still classify the result as invalid. That checks compatibility of this particular addition. A new consumer reading its own new report would not establish the same thing.

The failure cases belong beside it: an unknown format version, an unknown severity, a human log line before the JSON, disagreement between valid and the diagnostics, and disagreement with the exit status. An unknown diagnostic code with a known severity should remain visible.

Run the accompanying files with:

python3 -m unittest -v test_diagnostics_consumer.py 

The educational suite has nine tests. They cover the compatibility and rejection examples described here. They do not establish compatibility with every future CLI version or with an existing editor extension.

A version number needs a policy

A number helps when it stands for an agreement. If the producer changes a code's meaning and retains format_version: 1, the consumer cannot recover that old meaning. When diagnostics change, I would keep a small set of reports from the previous release and run the old consumer against the new records.

If several consumer generations are supported, name them and check them. "Backward compatible" is too broad without saying for whom. A small tool can support one explicit generation without building a matrix of every historical version.

A transition can temporarily offer an explicit old-format option or release the producer and consumer together. The support period and rejection behavior should be published. Old data should not be silently replaced under the same identifier: retained reports may still be needed to investigate earlier checks.

Where NexFlow fits

NexFlow's public repository contains a versioned validation-diagnostics schema. At the inspected revision, it explicitly identifies the data as validation-only library data, without a product ABI or conformance claim. Its contractVersion, required fields, and rejection of additional properties differ from the educational format above.

The optional-hint example therefore cannot be presented as a permitted change to that NexFlow contract. A closed schema requires its own decisions about consumer updates, migration, and version identity. The link pins a particular schema revision; it does not promise the behavior of a future public release.

Start with a consumer you already have

I would start with one consumer that currently parses message text. Identify the information it actually needs: a stable code, severity, and a path. Retain the original report and add a check for an ordinary wording change.

If translating the message still lets the extension locate the same field, and CI still distinguishes a configuration error from a failed validation process, we have an agreement we can test. We can now discuss the wording as an editorial choice without quietly removing the user's error highlighting.

References