Skip to content

feat: add elicit_* newtype crates for csv, bincode, and nom error types #7

Description

@crumplecup

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:

  1. Derive or implement JsonSchema (likely as { "type": "string" } with a descriptive title, since these are opaque error types)
  2. Implement Elicitation using the Generator pattern (enumerate error modes, construct the error from the selected mode)
  3. Implement Deref/DerefMut and From/Into for transparent use as drop-in field replacements
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions