Skip to main content

Crate cortexkit_role_classifier

Crate cortexkit_role_classifier 

Source
Expand description

Wire contract of the classifier/v1 role.

A classifier module takes a batch of items and a set of questions, calls one hosted classifier model for each item, and returns the provider’s answers untouched. It claims the role by listing PROVIDES in its manifest’s capabilities.provides and answers every op in REQUIRED_OPS.

CONTRACT.md, next to this crate’s Cargo.toml, is the role document: it marks every rule pinned, and says where each provider shape comes from. The types here are the wire shapes it describes:

  • describe: the role.describe answer;
  • question: the providers’ shared question shape, used both in a classify.run request and in the provider request it is forwarded in;
  • request: the classify.run request and its validators;
  • reply: the classify.run reply and the provider’s answer objects;
  • provider: the provider-side request and response;
  • identity: the batch body identity that decides replay versus batch_id_reuse;
  • errors: admission refusal codes, per-item error codes and classes;
  • vectors (with the test-vectors feature): the role’s vector files, compiled in, so a module’s tests can use the same bytes.

The batch rules this role shares with the other model-batch roles (the error vocabulary, batch identity hashing, the image shape, the status mapping) are cortexkit-model-batch’s; the modules above re-export them at their classifier/v1 paths.

Maps whose key order is part of what a provider documents (questions, choice options, probabilities) are IndexMaps, so a decoded and re-encoded object keeps its order. Every enumeration a consumer decodes (question type, error class) decodes open: an unknown value is kept as a string rather than refused. Decoding is not validating: the request validators still refuse an unknown question type, which a runner can neither check nor map.

Modules§

describe
role.describe: the module’s limits and every model it serves.
errors
Error codes, their classes, and the two error shapes of classify.run.
identity
The batch body identity: what decides whether a re-sent batch_id is a replay or batch_id_reuse.
ops
Names of the ops a classifier module serves.
provider
The provider side: what a runner sends each provider for one item, and what the provider answers. Both starting providers share one shape (Cloudflare calls clef “fully Jev-API compatible”); CONTRACT.md cites the documentation each shape comes from.
question
The providers’ shared question shape, and the images an item may carry.
reply
classify.run replies and the provider’s answer objects.
request
classify.run requests and their validators.

Structs§

IndexMap
A hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.

Constants§

PROVIDES
The capability identifier a classifier module lists in its manifest’s capabilities.provides, and the role member of its role.describe answer.
REQUIRED_OPS
Ops every classifier/v1 module serves.
ROLE
The role name.
VERSION
The only major this crate defines.