Summary
Following the pattern established by elicit_uuid, we need newtype wrapper crates for error types from csv, bincode, and nom so that structs containing these errors can fully derive Elicit. This would enable agent-generated mocks for error-path testing.
Context
In the destination library we have the following error types that currently cannot derive Elicit:
| Error struct |
Blocking field type |
Crate |
Io |
std::io::Error |
std |
Csv |
csv::Error |
csv |
Decode |
bincode::error::DecodeError |
bincode |
Encode |
bincode::error::EncodeError |
bincode |
Nom |
nom::Err<nom::error::Error<String>> |
nom |
std::io::Error already has an Elicitation impl in primitives/errors.rs (using the Generator pattern), but is missing a JsonSchema impl, so the derive still fails.
csv::Error, bincode::error::DecodeError/EncodeError, and nom::Err are missing both an Elicitation impl and a JsonSchema impl.
Proposed solution
Add newtype wrapper crates following the elicit_uuid pattern:
elicit_io (or extend elicitation core) — newtype for std::io::Error with JsonSchema + Elicitation. The Generator pattern already exists in primitives/errors.rs; this just needs a JsonSchema impl and a newtype wrapper.
elicit_csv — newtype for csv::Error with Generator-based Elicitation + JsonSchema
elicit_bincode — newtypes for bincode::error::DecodeError and bincode::error::EncodeError
elicit_nom — newtype for nom::Err<nom::error::Error<String>>
Each newtype should:
- Derive or implement
JsonSchema (likely as { "type": "string" } with a descriptive title, since these are opaque error types)
- Implement
Elicitation using the Generator pattern (enumerate error modes, construct the error from the selected mode)
- Implement
Deref/DerefMut and From/Into for transparent use as drop-in field replacements
- Implement
Display, Debug, std::error::Error forwarding
Acceptance criteria
With these crates in place, the following should compile and work end-to-end in destination:
#[derive(Debug, JsonSchema, Elicit)]
pub struct Io {
path: std::path::PathBuf,
source: elicit_io::IoError, // or similar
line: u32,
file: String,
}
Notes
std::io::Error is the highest priority since the Elicitation impl already exists — it just needs a JsonSchema wrapper and newtype.
- The
nom error type is generic (nom::Err<nom::error::Error<String>>) — the newtype may need to fix the inner type to String to keep the schema concrete.
- All four cases use error types that cannot be meaningfully round-tripped through JSON; the Generator/mode enum pattern (as used for
io::Error today) is the right approach for all of them.
Summary
Following the pattern established by
elicit_uuid, we need newtype wrapper crates for error types fromcsv,bincode, andnomso that structs containing these errors can fully deriveElicit. This would enable agent-generated mocks for error-path testing.Context
In the
destinationlibrary we have the following error types that currently cannot deriveElicit:Iostd::io::ErrorCsvcsv::ErrorDecodebincode::error::DecodeErrorEncodebincode::error::EncodeErrorNomnom::Err<nom::error::Error<String>>std::io::Erroralready has anElicitationimpl inprimitives/errors.rs(using the Generator pattern), but is missing aJsonSchemaimpl, so the derive still fails.csv::Error,bincode::error::DecodeError/EncodeError, andnom::Errare missing both anElicitationimpl and aJsonSchemaimpl.Proposed solution
Add newtype wrapper crates following the
elicit_uuidpattern:elicit_io(or extendelicitationcore) — newtype forstd::io::ErrorwithJsonSchema+Elicitation. The Generator pattern already exists inprimitives/errors.rs; this just needs a JsonSchema impl and a newtype wrapper.elicit_csv— newtype forcsv::Errorwith Generator-basedElicitation+JsonSchemaelicit_bincode— newtypes forbincode::error::DecodeErrorandbincode::error::EncodeErrorelicit_nom— newtype fornom::Err<nom::error::Error<String>>Each newtype should:
JsonSchema(likely as{ "type": "string" }with a descriptive title, since these are opaque error types)Elicitationusing the Generator pattern (enumerate error modes, construct the error from the selected mode)Deref/DerefMutandFrom/Intofor transparent use as drop-in field replacementsDisplay,Debug,std::error::ErrorforwardingAcceptance criteria
With these crates in place, the following should compile and work end-to-end in
destination:Notes
std::io::Erroris the highest priority since theElicitationimpl already exists — it just needs a JsonSchema wrapper and newtype.nomerror type is generic (nom::Err<nom::error::Error<String>>) — the newtype may need to fix the inner type toStringto keep the schema concrete.io::Errortoday) is the right approach for all of them.