Skip to main content

Crate mif_problem

Crate mif_problem 

Source
Expand description

Dual-consumer error output: an RFC 9457 Problem Details envelope, shared across the MIF (Modeled Information Format) workspace’s crates.

A command-line tool or MCP server now answers to two audiences: the human who reads the terminal, and the LLM agent that parses the bytes and decides whether to retry, escalate, or abandon. The human is served by an error enum’s ordinary Display output (unchanged). The agent is served by ProblemDetails — a serializable RFC 9457 Problem Details envelope carrying the five standard members plus the three agent extensions (retry_after, suggested_fix, code_actions) and an Applicability marker on every suggested fix and code action.

This workspace deliberately has no shared top-level error type (see this repo’s CLAUDE.md, “Why thiserror for Errors”) — mif-schema, mif-ontology, mif-frontmatter, mif-embed, and mif-store each fail in genuinely different ways and keep their own thiserror enum. This crate does not change that: instead of one central Error enum with a meta() match (the pattern this crate adapts from attested-delivery/rust-template’s crates/problem.rs), each crate’s own error enum implements ToProblem directly, using ProblemMeta to keep its own per-variant type-URI/status/exit-code bookkeeping in one place.

Structs§

CodeAction
A structured edit an agent can apply directly, modeled on the LSP CodeAction interface.
ProblemDetails
An RFC 9457 Problem Details envelope for machine consumers.
ProblemMeta
Reusable per-variant problem-type metadata.
SuggestedFix
A recovery suggestion tagged with an Applicability marker.

Enums§

Applicability
How confidently an agent may apply a SuggestedFix or CodeAction.
OutputFormat
The rendering format for an error reported to a consumer.

Constants§

ERROR_TYPE_BASE_URI
Base URI under which this workspace’s problem-type identifiers are namespaced.

Traits§

ToProblem
Implemented by each crate’s own error enum to map it to a ProblemDetails envelope.

Functions§

classify_io_error
Classifies a std::io::Error for RFC 9457 rendering.