mjdi docsv0.10.0latest
The validation output contract (P0-06)
Every diagnostic mjdi controls carries a stable identifier — a pinned
Source: mjdi/docs/validation-output-contract.md
Every diagnostic mjdi controls carries a stable identifier — a pinned
MJDI-XXX code that never changes meaning and never gets renumbered —
embedded in the message text, next to the human-readable explanation.
Humans read the message; tooling and issue trackers match the ID.
The ID scheme
| Prefix | Stage | Where it fires |
|---|---|---|
MJDI-E* | compile-time | registration guards and graph validation (compilation fails) |
MJDI-R* | runtime | raisable Error during resolution |
MJDI-A* | abort | fatal misuse (process aborts) |
MJDI-D* | debug | opt-in destructor-time diagnostics (P0-03) |
The current catalog (30 entries)
- MJDI-E001 alias target is not registered — registration-time report
- MJDI-E001 alias target is not registered — validation-time report
- MJDI-E002 cached provider requires
Copyable - MJDI-E003 class provider is not
Injectable - MJDI-E004 duplicate provider registration
- MJDI-E005 linear service reached the value-returning path
- MJDI-E006 linear service without the
mjdi_linearannotation - MJDI-E007 missing provider for a dependency
- MJDI-E008 override of an unregistered service
- MJDI-E009 unregistered linear service consumed with the visitor overload
- MJDI-E010 visitor overload requires the linear annotation
- MJDI-E011 resolve of an unregistered service
- MJDI-E012
set_valueon an unregistered service - MJDI-E013
set_valueon a non-value provider - MJDI-E014 class provider construction requires
Injectable - MJDI-E015 circular dependency between services
- MJDI-E016 singleton depends on a scoped service
- MJDI-E017 alias target is not a class provider — registration-time report
- MJDI-E017 alias target is not a class provider — validation-time report
- MJDI-E018 alias source is not
Injectable - MJDI-E019 circular alias chain — validation-time report
- MJDI-E019 circular alias chain — registration-time report
- MJDI-E020
explain_resolutionof an unregistered service - MJDI-R001 scoped service resolved without a scope
- MJDI-R002 value provider resolved before
set_value - MJDI-R003 re-entrant resolution detected
- MJDI-R004 factory failure with preserved cause
- MJDI-A001 inject marker read before resolution
- MJDI-D001 tracked container dropped without
close() - MJDI-D002 tracked scope dropped without
close_scope()
The policy
- IDs are pinned in
scripts/gen_diagnostics.py. A new diagnostic is assigned the next unused number in its series; existing IDs never change. Retired IDs are recorded in the catalog'sretired_idsand can never be reused for a different condition. - One condition, one ID. The same condition reported from two code paths (e.g. the registration-time and validation-time alias checks) shares one ID; the catalog lists both reports, titled as variants.
- IDs are separated from messages. The message text is free to improve
(clearer wording, better remediation) as long as the ID and the leading
mjdi:fragment stay stable — the compile-fail fixtures and the runtime tests pin the stable fragments, so a wording change that breaks users' greps fails CI. - Every cataloged ID is verified embedded in its builder's source
(
tests/python/test_diagnostics.py), and the generator validates the reverse: every message builder in the library is cataloged. The catalog can never drift from the code in either direction. - Machine-readable catalog:
diagnostics/catalog.json(validated againstdiagnostics/schema.json) carries per-entry severity, stage, cause, quick fix, docs link, and bad/good examples — the same file the IDE integration consumes.
What the compiler provides (and does not)
Mojo emits unstructured text diagnostics: there is no stable compiler
diagnostic-code channel for constraint failures, no structured
machine-readable output for a failed comptime assert, and no way to
attach metadata (severity, docs link) to a compiler error. mjdi therefore
manufactures its own contract: the constraint-failure message text IS the
diagnostic, and the embedded MJDI-XXX code is the stable identifier.
Tooling that wants structure should match the code (the
problem matchers do exactly that).
Compiler-diagnostic limitations (documented, not hidden)
- The ID appears at the END of the message; compiler output between the message and the code location is compiler-controlled and can change with compiler versions.
- mjdi cannot suppress or reorder compiler notes around its diagnostics.
- A compile-time failure reports the FIRST failing assert in the walk; mjdi cannot collect multiple validation errors into one report.