openkind-core
The canonical Jev wire contract, data structures, and validation rules for
openkind.
openkind-core is the foundational crate of the openkind workspace. It defines the Jev wire types (SystemRequest, SystemResponse, Question, Answer, State) and the validation invariants of the TypeSafe Jev API contract, spoken over HTTP and gRPC.
It depends on no other workspace crate. The engine, API, server, CLI, client, runtime, backends, bench, and schema-generation crates all depend on it.
Quickstart
use HashMap;
use ;
let mut questions = with_hasher;
questions.insert;
let request = SystemRequest ;
assert!;
Question maps use WireHashState, a foldhash-based hasher, so construct them with HashMap::with_hasher(WireHashState::default()) rather than HashMap::new().
Wire types
SystemRequest: the/v1/systemonerequest body, withstate,model, and a map of question ID toQuestion.API_VERSION("jev-compatible-0.1") pins the wire version.SystemResponse: oneAnswerper question ID plus required tokenUsage.Question: a tagged enum ofNoulQuestion,ChoiceQuestion, andScoreQuestion.instructionsaccepts a string, object, or array, and Choice criteria values may benull.Answer: a tagged enum ofNoulAnswer,ChoiceAnswer, andScoreAnswer.NoulAnswercarries onlynouland has noconfidencefield, per the spec.State: polymorphic input accepting plain text, a JSON object, or a JSON array.ModelInfo/ModelsResponse: wire structures forGET /v1/models.
Every wire float (probabilities, score, noul, confidence) is f64, so JSON round-trips exactly; an f32 would turn 0.92 into 0.9200000166893005.
Validation
validate_request(&req)rejects empty question maps, empty instructions, Choice questions without options, Score rubrics with fewer than two non-empty levels, and Noul criteria with emptytrue/falsedescriptions. It also caps requests at 10,000 questions and questions at 10,000 criteria options.validate_response_for_request(&resp, &req)and its retainedResponseContractcheck each answer against its request: answer type, selected Choice option, probability keys, sum-to-one distributions within tolerance,confidenceandnoulbounds in[0.0, 1.0], and Score legend, index, and score consistency.validate_response(&resp, &criteria)remains for callers that only hold a criteria map.
JSON schemas
The request, question, answer, and state types derive schemars::JsonSchema. The committed schemas under schemas/ are generated by the separate openkind-gen-schemas crate with cargo run -p openkind-gen-schemas -- --write and are never hand-edited.
Testing
Module unit tests sit in src/, and tests/conformance.rs pins the wire format to examples and rules from the Jev spec.
License
See the MIT license. Cargo metadata declares MIT OR Apache-2.0.