domain tier

domain-conversation-engine

Assembles a reply by filling a stored phrase from a subject's own fields, and decides which registered intent a message expresses -- refusing rather than guessing when a slot is missing, when two intents are too close to separate, or when a consumer's guard says the intent is not permitted in the conversation's current state. Pure logic, zero I/O, zero AI calls: it decides what to say and when to abstain, it never fetches, renders to a channel, or asks a model.

Assembles a reply by filling a stored phrase from a subject's own fields, and decides which registered intent a message expresses -- refusing rather than guessing when a slot is missing, when two intents are too close to separate, or when a consumer's guard says the intent is not permitted in the conversation's current state. Pure logic, zero I/O, zero AI calls: it decides what to say and when to abstain, it never fetches, renders to a channel, or asks a model.

Tierdomain
Rolecapability
Pathcrates/domain/conversation-engine
Edition2021
Targetsdomain_conversation_engine
Public items45 across 2 modules
Tests76

What it is for

Assemble a reply; never compose one.

A reply is a stored phrase with named slots, filled from whatever the consumer knows about the subject under discussion. There is no generation step here and no model call: this crate decides what to say from data it is handed, and — more often than is comfortable — decides to say nothing and hand the conversation to a human instead.

It refuses in three distinct places, and the distinction matters because each catches a failure the others cannot see:

hole in it, a blank, or a plausible default. A question about a measurement nobody recorded is unanswerable regardless of how well it was understood.

the best candidate is below its floor, when the runner-up is too close to separate from it, or when the intent is one whose consequences warrant a stricter bar than the rest.

consumer implements decides whether an otherwise correct intent may be acted on in the conversation's current state. This crate defines the question and guarantees it is asked; it does not know what the states are.

The first two are about the answer. The third is about the moment — a correctly understood question about collection, asked before anything has been reserved, is not answerable just because it was understood.

Capabilities

crate root

Assemble a reply; never compose one.

Item
pub const CANCEL_INTENT: & str

AskReason

Assemble a reply; never compose one.

Item
pub enum AskReason

HandoffReason

Assemble a reply; never compose one.

Item
pub enum HandoffReason

Reply

Assemble a reply; never compose one.

Item
pub enum Reply
fn respond(registry : & IntentRegistry, candidates : & Candidate, templates : & Template, subject : & dyn SlotSource, guard : & dyn TransitionGuard,) -> Reply
fn respond_to_action(intent : impl Into <String>, templates : & Template, subject : & dyn SlotSource, guard : & dyn TransitionGuard,) -> Reply

CartHold

Who else wants this, and what they have offered.

Item
pub struct CartHold
CartHold :: fn new(holder : impl Into <String>) -> Self
CartHold :: fn offering(holder : impl Into <String>, offer : i64) -> Self

Interest

Who else wants this, and what they have offered.

Item
pub struct Interest
Interest :: fn new(holds : Vec <CartHold>) -> Self
Interest :: fn holds(& self) -> & CartHold
Interest :: fn cart_count(& self) -> usize
Interest :: fn others(& self, viewer : & str) -> usize
Interest :: fn highest_offer(& self) -> Option <i64>
Interest :: fn next_highest(& self, viewer : & str) -> Option <i64>
Interest :: fn is_leading(& self, viewer : & str) -> bool
Interest :: fn bidding(& self, rounds_used : u8, elapsed_secs : u64) -> Bidding
Interest :: fn as_slots <'a>(& 'a self, viewer : & 'a str) -> InterestSlots <'a>

InterestSlots

Who else wants this, and what they have offered.

Item
pub struct InterestSlots<'a>

InterestSlots<'_>

Who else wants this, and what they have offered.

Item
InterestSlots<'_> :: fn slot(& self, name : & str) -> Option <String>

offer (other)

Haggling, decided by arithmetic.

Item
fn buy_now(policy : & OfferPolicy, offered : i64, bidder : & str, state : & Bidding) -> BuyNowOutcome
fn closure(policy : & OfferPolicy, state : & Bidding) -> Option <CloseReason>
fn close(policy : & OfferPolicy, state : & Bidding) -> OfferOutcome
fn evaluate(policy : & OfferPolicy, offered : i64, bidder : & str, state : & Bidding) -> OfferOutcome

Bidding

Haggling, decided by arithmetic.

Item
pub struct Bidding

BuyNowOutcome

Haggling, decided by arithmetic.

Item
pub enum BuyNowOutcome

CloseReason

Haggling, decided by arithmetic.

Item
pub enum CloseReason

Notify

Haggling, decided by arithmetic.

Item
pub struct Notify

OfferOutcome

Haggling, decided by arithmetic.

Item
pub enum OfferOutcome
OfferOutcome :: fn intent(& self) -> & 'static str
OfferOutcome :: fn notification(& self) -> Option <& Notify>

OfferPolicy

Haggling, decided by arithmetic.

Item
pub struct OfferPolicy
OfferPolicy :: fn new(asking : i64) -> Self
OfferPolicy :: fn with_discount_percent(mut self, percent : u8) -> Self
OfferPolicy :: fn with_refer_below_percent(mut self, percent : u8) -> Self
OfferPolicy :: fn with_min_increment(mut self, increment : i64) -> Self
OfferPolicy :: fn with_rebid_rounds(mut self, rounds : u8) -> Self
OfferPolicy :: fn with_close_after(mut self, rounds : u8, secs : u64) -> Self
OfferPolicy :: fn with_buy_now_premium_percent(mut self, percent : u8) -> Self
OfferPolicy :: fn buy_now_price(& self, state : & Bidding) -> i64
OfferPolicy :: fn floor(& self) -> i64

ReferReason

Haggling, decided by arithmetic.

Item
pub enum ReferReason

StandingOffer

Haggling, decided by arithmetic.

Item
pub struct StandingOffer
StandingOffer :: fn new(amount : i64, holder : impl Into <String>) -> Self

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

domain_conversation_engine

flowchart TD
  n_domain_conversation_engine["domain_conversation_engine"]
  n_domain_conversation_engine --> n_interest["interest"]
  n_domain_conversation_engine --> n_offer["offer"]

Public surface

`crate root`

ItemWhat it is
pub enum ReplyEverything the engine can conclude from one inbound message
pub enum AskReasonWhy the engine put a choice back to the reader
pub enum HandoffReasonWhy the engine declined to answer
fn respond(registry : & IntentRegistry, candidates : & Candidate, templates : & Template, subject : & dyn SlotSource, guard : & dyn TransitionGuard,) -> ReplyThe one entry point: decide, then either render or abstain
pub const CANCEL_INTENT: & strThe intent a "No" button carries when the engine offers one itself
fn respond_to_action(intent : impl Into <String>, templates : & Template, subject : & dyn SlotSource, guard : & dyn TransitionGuard,) -> ReplyThe turn after a reader taps a button

`interest`

ItemWhat it is
pub struct CartHoldOne person holding an item, with the offer they have made if any
CartHold :: fn new(holder : impl Into <String>) -> SelfSomeone holding the item at the asking price, without an offer.
CartHold :: fn offering(holder : impl Into <String>, offer : i64) -> SelfSomeone holding the item and offering a number for it.
pub struct InterestEvery live hold on one item.
Interest :: fn new(holds : Vec <CartHold>) -> Self
Interest :: fn holds(& self) -> & CartHold
Interest :: fn cart_count(& self) -> usizeHow many carts this item is sitting in.
Interest :: fn others(& self, viewer : & str) -> usizeHow many carts other than this reader's
Interest :: fn highest_offer(& self) -> Option <i64>The best offer anyone has made.
Interest :: fn next_highest(& self, viewer : & str) -> Option <i64>The best offer made by anyone other than this reader
Interest :: fn is_leading(& self, viewer : & str) -> boolIs this reader's offer the best one standing? False when they have made no offer at all, even if nobody else has either — leading is something you do with a number, not by being present.
Interest :: fn bidding(& self, rounds_used : u8, elapsed_secs : u64) -> BiddingThe negotiation state the offer rules work against
Interest :: fn as_slots <'a>(& 'a self, viewer : & 'a str) -> InterestSlots <'a>This item's interest as slot values, from one reader's point of view.
pub struct InterestSlots<'a>Interest expressed as template slots
InterestSlots<'_> :: fn slot(& self, name : & str) -> Option <String>

`offer`

ItemWhat it is
pub struct OfferPolicyWhat the seller will accept, and how long they will go on about it.
OfferPolicy :: fn new(asking : i64) -> SelfThe operator's stated rule: 20% off, refer below half, two rebids for an outbid holder, and a window that closes after three rounds or a day.
OfferPolicy :: fn with_discount_percent(mut self, percent : u8) -> Self
OfferPolicy :: fn with_refer_below_percent(mut self, percent : u8) -> Self
OfferPolicy :: fn with_min_increment(mut self, increment : i64) -> Self
OfferPolicy :: fn with_rebid_rounds(mut self, rounds : u8) -> Self
OfferPolicy :: fn with_close_after(mut self, rounds : u8, secs : u64) -> Self
OfferPolicy :: fn with_buy_now_premium_percent(mut self, percent : u8) -> Self
OfferPolicy :: fn buy_now_price(& self, state : & Bidding) -> i64What it costs to end the window early and take the item
OfferPolicy :: fn floor(& self) -> i64The lowest acceptable price, in minor units
pub struct StandingOfferThe best offer currently held, and who holds it.
StandingOffer :: fn new(amount : i64, holder : impl Into <String>) -> Self
pub struct BiddingWhere the negotiation has got to
pub struct NotifyA message to put in somebody else's queue
pub enum CloseReasonWhy the window is shut.
pub enum ReferReasonWhy an offer stopped being the engine's business.
pub enum OfferOutcomeWhat to do about one offer.
OfferOutcome :: fn intent(& self) -> & 'static strThe conventional intent name for this outcome, so a consumer can key a template and a guard by it like any other intent.
OfferOutcome :: fn notification(& self) -> Option <& Notify>The message owed to somebody who is not the sender, if any.
pub enum BuyNowOutcomeWhat happens when someone tries to take the item outright.
fn buy_now(policy : & OfferPolicy, offered : i64, bidder : & str, state : & Bidding) -> BuyNowOutcomeTake the item now rather than waiting out the window
fn closure(policy : & OfferPolicy, state : & Bidding) -> Option <CloseReason>Has the window shut?
fn close(policy : & OfferPolicy, state : & Bidding) -> OfferOutcomeWho takes it, if the window shut now.
fn evaluate(policy : & OfferPolicy, offered : i64, bidder : & str, state : & Bidding) -> OfferOutcomeDecide one offer against the state of the negotiation

Re-exports. Exported here, defined elsewhere.

ExportDefined in
Actionaction::Action
{Bidding,Notify,OfferOutcome,OfferPolicy,StandingOffer}offer::{Bidding,Notify,OfferOutcome,OfferPolicy,StandingOffer}
{Candidate,IntentDecision,IntentRegistry,IntentRule,Risk}intent::{Candidate,IntentDecision,IntentRegistry,IntentRule,Risk}
{CartHold,Interest}interest::{CartHold,Interest}
{GuardVerdict,PermitAll,TransitionGuard}guard::{GuardVerdict,PermitAll,TransitionGuard}
{RenderError,SlotSource,Template}template::{RenderError,SlotSource,Template}

Boundary

Depends on no other workspace tier.

Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, … (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)capability
Locationcrates/domain/conversation-engine
Vocabulary in force (lexicon)current

Dependencies

Runtime. None.

Development. None.

Build. None.

Depended on by. 1 workspace crate.

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

flowchart LR
  n_application_conversation["application-conversation"] -->|uses| SELF
  SELF["domain-conversation-engine"]
  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_conversation_engine`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfacenone detected
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.

1 workspace crate depends on this one: application-conversation.

Verification

KindCount
Unit tests76
Integration tests0
Examples0
Doctests0

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

ModuleTestsExamplesConsumers
crate root605
interest300
offer1201

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc3545
Public modules with a //! block22
pie showData
    title Public items with rustdoc
    "Documented" : 35
    "No rustdoc detected" : 10

Metrics

MetricValue
Rust source files7
Source lines2378
Code lines1634
Public API items45
Public modules2
Tests76
Examples0
Cargo features0
Direct runtime dependencies0
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 1
    "enum" : 7
    "function" : 6
    "method" : 24
    "struct" : 7
pie showData
    title Rust source composition
    "Code" : 1634
    "Blank or comment" : 744

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