domain tier

domain-classify

Polymorphic AI classification — job queue + result store keyed by (entity_type, entity_id)

Polymorphic AI classification — job queue + result store keyed by (entity_type, entity_id)

Tierdomain
Roleunclassified (baselined)
Pathcrates/domain/classify
Edition2021
Targetsdomain_classify
Public items25 across 0 modules
Tests11

What it is for

Polymorphic AI classification library crate (Sprint 0.6).

Any entity can be classified by an AI model. This crate provides:

per (tenant_id, entity_type, entity_id, classification_type) tuple; re-classify replaces).

implement (enqueuenext_pendingmark_runningcomplete | fail).

crates can use in their own unit tests without standing up Postgres.

Polymorphic via (entity_type: String, entity_id: Uuid) — no hard FK to the target entity. Same shape used by domain-taxonomy.taggings, content-assets.attachments, operations-approval-workflow.

Gate 1.5 Q4: greenfield crate; rust-cms-engine becomes the first downstream consumer (wiring entity_type="catalog_item"); the existing rust-inventory-ai classify worker stays on its legacy classify_status columns until a later sprint ports it.

Capabilities

Classification

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub struct Classification
Classification :: fn id(& self) -> Uuid
Classification :: fn created_at(& self) -> DateTime <Utc>
Classification :: fn updated_at(& self) -> DateTime <Utc>
Classification :: fn deleted_at(& self) -> Option <DateTime <Utc>>

ClassifyError

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub enum ClassifyError

ClassifyJob

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub struct ClassifyJob
ClassifyJob :: fn id(& self) -> Uuid
ClassifyJob :: fn created_at(& self) -> DateTime <Utc>
ClassifyJob :: fn updated_at(& self) -> DateTime <Utc>

ClassifyJobStatus

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub enum ClassifyJobStatus
ClassifyJobStatus :: fn is_terminal(& self) -> bool
ClassifyJobStatus :: fn as_str(& self) -> & 'static str
ClassifyJobStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

ClassifyService

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub trait ClassifyService

EnqueueRequest

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub struct EnqueueRequest

InMemoryClassifyService

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub struct InMemoryClassifyService
InMemoryClassifyService :: fn new() -> Self
InMemoryClassifyService :: async fn enqueue(& self, req : EnqueueRequest) -> Result <ClassifyJob>
InMemoryClassifyService :: async fn next_pending(& self, handler_key : & str, limit : usize) -> Result <Vec <ClassifyJob>>
InMemoryClassifyService :: async fn mark_running(& self, job_id : Uuid) -> Result <()>
InMemoryClassifyService :: async fn complete(& self, job_id : Uuid, result : serde_json::Value, confidence : Option <f32>, source_prompt_template_id : Option <Uuid>, source_prompt_version_id : Option <Uuid>,) -> Result <Classification>
InMemoryClassifyService :: async fn fail(& self, job_id : Uuid, error : & str) -> Result <()>
InMemoryClassifyService :: async fn latest_for(& self, tenant_id : Uuid, entity_type : & str, entity_id : Uuid, classification_type : & str,) -> Result <Option <Classification>>

Result

Polymorphic AI classification library crate (Sprint 0.6).

Item
pub type Result<T>: std::result::Result <T, ClassifyError>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub enum ClassifyErrorErrors that can occur in classify operations.
pub type Result<T>: std::result::Result <T, ClassifyError>Result type for classify operations.
pub enum ClassifyJobStatusLifecycle status of a classification job.
ClassifyJobStatus :: fn is_terminal(& self) -> boolReturns true if the status is terminal (no further transitions).
ClassifyJobStatus :: fn as_str(& self) -> & 'static strCanonical string form (matches the DB CHECK constraint).
ClassifyJobStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct ClassificationA classification result for one (tenant, entity_type, entity_id, classification_type) tuple
Classification :: fn id(& self) -> Uuid
Classification :: fn created_at(& self) -> DateTime <Utc>
Classification :: fn updated_at(& self) -> DateTime <Utc>
Classification :: fn deleted_at(& self) -> Option <DateTime <Utc>>
pub struct ClassifyJobA pending / running / terminal classification job.
ClassifyJob :: fn id(& self) -> Uuid
ClassifyJob :: fn created_at(& self) -> DateTime <Utc>
ClassifyJob :: fn updated_at(& self) -> DateTime <Utc>
pub struct EnqueueRequestInput to ClassifyService::enqueue.
pub trait ClassifyServiceOrchestrates classification jobs
pub struct InMemoryClassifyServiceIn-memory implementation of ClassifyService for unit tests in downstream crates
InMemoryClassifyService :: fn new() -> SelfCreates a new empty in-memory classify service.
InMemoryClassifyService :: async fn enqueue(& self, req : EnqueueRequest) -> Result <ClassifyJob>
InMemoryClassifyService :: async fn next_pending(& self, handler_key : & str, limit : usize) -> Result <Vec <ClassifyJob>>
InMemoryClassifyService :: async fn mark_running(& self, job_id : Uuid) -> Result <()>
InMemoryClassifyService :: async fn complete(& self, job_id : Uuid, result : serde_json::Value, confidence : Option <f32>, source_prompt_template_id : Option <Uuid>, source_prompt_version_id : Option <Uuid>,) -> Result <Classification>
InMemoryClassifyService :: async fn fail(& self, job_id : Uuid, error : & str) -> Result <()>
InMemoryClassifyService :: async fn latest_for(& self, tenant_id : Uuid, entity_type : & str, entity_id : Uuid, classification_type : & str,) -> Result <Option <Classification>>

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into foundation, infrastructure.

Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-comments, domain-competitive-intel, domain-contact, domain-conversation-engine, … (41 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)domain
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/domain/classify
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_domain["domain"] --> n_foundation["foundation"]
  n_domain["domain"] --> n_infrastructure["infrastructure"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways
`infrastructure-prompts`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
chrono^0.4serdenoalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways
tokio-test^0.4noalways

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["domain-classify"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  SELF -->|runtime| n_infrastructure_prompts["infrastructure-prompts"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libdomain_classify`src/lib.rs`

Error model

Error typeNamed by
ClassifyErrorResult

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

No workspace crate depends on this one.

Verification

KindCount
Unit tests11
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root800

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1125
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 11
    "No rustdoc detected" : 14

Metrics

MetricValue
Rust source files1
Source lines838
Code lines627
Public API items25
Public modules0
Tests11
Examples0
Cargo features0
Direct runtime dependencies8
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "enum" : 2
    "method" : 17
    "struct" : 4
    "trait" : 1
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 627
    "Blank or comment" : 211

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All domain · Manual