Harn diagnostics
Use this skill when changing errors, warnings, explain output, repair metadata,
or fix application behavior. Use it also when you need to look up what a
HARN-<CAT>-<NNN> code means.
Pair it with [[harn-language]] for syntax and type contracts and [[harn-agent]] for autonomy gating.
Code index (look up any HARN-* code)
Every diagnostic harn check, harn lint, and harn fmt emit carries a stable
HARN-<CAT>-<NNN> code. The code registry is the single source of truth. It is
crates/harn-parser/src/diagnostic_codes.rs, plus the per-code explanation in
crates/harn-parser/src/diagnostic_codes/explanations/<CODE>.md. Everything
below is generated from it, so never hand-maintain a parallel list.
- Look up one code:
harn explain HARN-TYP-014(human-readable) or
harn explain HARN-TYP-014 --json (structured: category, summary, repair,
safety class, related codes).
- Full index of every code:
harn explain --catalog(add
--format markdown or --format json). This is the complete cheat sheet —
one entry per code with its summary, repair, and safety class.
- Committed artifacts (kept in sync by CI):
docs/src/diagnostics.md— the rendered index, grouped by category.docs/diagnostics-catalog.json—schemaVersion: 1structured contract
consumed by downstream tooling (IDE diagnostic panels, hosted error pages).
Tools should read this, not regex prose.
- Regenerate after changing the registry or an explanation:
make sync-diagnostics-catalog (CI guard: make check-diagnostics-catalog).
The category prefixes below are the mental map for the index; harn explain
resolves any individual code.
Start here
- Parser diagnostics live primarily in
crates/harn-parser/. - Typechecker diagnostics live in
crates/harn-parser/src/typechecker/. - Lint diagnostics live in
crates/harn-lint/. - CLI rendering and
harn explainlive undercrates/harn-cli/src/commands/. - Repair planning and apply flows live under
crates/harn-cli/src/commands/fix.rs. - Conformance
.errorfixtures are the executable spec for intentional failures. - LSP diagnostics should derive from the same core metadata as CLI diagnostics.
- Do not fork diagnostic meaning between CLI, LSP, and docs.
Diagnostic categories
TYPcovers type mismatch and typechecker failures.PARcovers parser syntax failures.NAMcovers naming and resolution failures.CAPcovers capability and trust-boundary failures.LLMcovers LLM provider and model-call failures.ORCcovers orchestration and workflow failures.STDcovers stdlib and builtin failures.PRMcovers prompt-template failures.MODcovers module-system and import failures.LNTcovers lint findings.FMTcovers formatter findings.IMPcovers import and package integration failures.OWNcovers ownership and lifetime-style constraints.RCVcovers recovery and resume failures.MATcovers match and exhaustiveness failures.- Codes use the stable
HARN-<CAT>-<NNN>format.
Message rules
- Keep messages stable, specific, and actionable.
- Point at the smallest useful span.
- Do not blame the user; describe the invalid construct.
- Mention the expected shape before the found shape when useful.
- Include a short help string only when it reduces guesswork.
- Avoid diagnostics that require reading compiler internals.
- Prefer one primary error over many cascading errors.
- Preserve existing code identifiers unless the old code was wrong.
- Keep warnings clearly distinguishable from blocking errors.
- Update explanations when changing a diagnostic's meaning.
Structured metadata
- Preserve
code. - Preserve
severity. - Preserve source spans.
- Preserve labels and notes.
- Preserve related spans.
- Preserve machine-applicable
FixEditvalues. - Preserve repair ids and summaries.
- Preserve repair safety classes.
- Preserve structured diagnostic details used by LSP code actions.
- Avoid parsing human-readable messages in downstream tools.
Repair safety
- Format-only edits can be auto-applied when they are byte-local and deterministic.
- Syntax-local repairs can be auto-applied only when they cannot change intent.
- Type or semantic repairs should usually be propose-only.
- Cross-file edits need higher review.
- Capability, network, shell, and mutation repairs need explicit approval.
harn fix --planshould explain why each repair is or is not safe.harn fix --applymust respect the declared safety ceiling.- Do not hide skipped or rejected repairs.
- Keep repairs idempotent.
- Add tests for both plan and apply surfaces when safety behavior changes.
Cross-surface alignment
- CLI rendering should show the stable code.
harn explainshould resolve every registered code.- LSP diagnostics should expose matching codes and repair metadata.
- JSON surfaces should keep codes machine-readable.
- Conformance
.errorfiles should lock user-visible failures. - Docs should describe public diagnostics when users can act on them.
- Generated diagnostic catalogs must stay in sync with the registry.
- Do not hand-edit generated catalog artifacts.
- Use [[harn-testing]] for fixture and JSON report coverage.
- Use [[harn-tracing]] if diagnostics are stored in transcripts or receipts.
Verify
- Parser/typechecker changes:
make test ARGS='-p harn-parser <filter>'. - Lint changes:
make test ARGS='-p harn-lint <filter>'. - CLI explain changes:
make test ARGS='-p harn-cli --test <test-name>'. - Repair changes: targeted
harn fixtests andmake lint-test-patterns. - Intentional failure fixtures:
HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- test conformance --filter <name>.
- Rendered lint smoke:
HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- lint <path>.
- JSON diagnostics smoke: use the relevant
--jsoncommand when available. - LSP changes: targeted
make test ARGS='-p harn-lsp <filter>'. - Catalog drift: run the generator/check command documented by the touched catalog.
- Broad gate for shared diagnostic changes:
make test.