converge-domain 0.2.4

Domain-specific agents and examples for Converge
Documentation

Converge Domain

Domain defines meaning. Core defines truth. Providers fetch reality.

Business semantics and converging workflows for the Converge runtime.

Crates.io Documentation

Website: converge.zone | Docs: docs.rs | Crates.io: converge-domain


What Is converge-domain?

This crate is where "we can replace/augment business systems" becomes concrete and testable.

converge-domain provides:

  • Domain agents — Deterministic + LLM-governed agents for business workflows
  • Invariants — Business rules compiled from Gherkin-style specifications
  • Use case packs — Complete workflow compositions that converge

What converge-domain IS

Aspect Description
Business semantics Typed domain concepts, terminology, schemas
Workflow compositions Agent + invariant bundles that converge on outcomes
Policy enforcement Gherkin-style acceptance criteria and compliance rules
Deterministic + governed Rule-based agents with optional LLM enhancement

What converge-domain is NOT

Anti-pattern Why Not
Not an engine Engine lives in converge-core
Not providers Adapters live in converge-provider
Not orchestration No schedulers, queues, or control flow
Not external I/O Providers handle all vendor calls

Boundaries

┌─────────────────────────────────────────────────────────────────────────────┐
│                           RESPONSIBILITY MATRIX                             │
├─────────────────────────────────────────────────────────────────────────────┤
│  converge-domain          │  converge-core         │  converge-provider     │
│  ─────────────────────    │  ──────────────────    │  ────────────────────  │
│  Business semantics       │  Execution engine      │  External adapters     │
│  Workflow compositions    │  Convergence loop      │  LLM/search/vector     │
│  Domain agents            │  Agent trait           │  Capability ports      │
│  Invariants/policies      │  Invariant trait       │  Observation producers │
│  Gherkin specifications   │  Context authority     │  Provenance metadata   │
└─────────────────────────────────────────────────────────────────────────────┘

Dependency rules:

  • converge-domain depends on converge-core (for traits)
  • converge-domain depends on converge-provider (for capability traits, not implementations)
  • Domain agents call provider traits; they never make direct HTTP calls

Installation

[dependencies]
converge-domain = "0.2"

Related Crates

Crate Version Description
converge-core 0.6.1 Runtime engine, agent traits, capabilities
converge-provider 0.2.3 14+ LLM providers, model selection
converge-domain 0.2.3 12 business use cases

Use Cases

Business Strategy

Use Case Module Description
Growth Strategy growth_strategy Market signal analysis, competitor intelligence, strategy evaluation
Strategic Sourcing strategic_sourcing Vendor assessment, risk scoring, negotiation recommendations
SDR Sales sdr_sales Sales qualification funnel, lead scoring

Operations

Use Case Module Description
Supply Chain supply_chain Multi-warehouse routing, demand forecasting, cost optimization
Inventory Rebalancing inventory_rebalancing Cross-region transfers, financial impact analysis
Resource Routing resource_routing Task-resource matching, constraint satisfaction

Enterprise

Use Case Module Description
Meeting Scheduler meeting_scheduler Multi-participant availability, timezone normalization, conflict resolution
Release Readiness release_readiness Quality gates, risk assessment, go/no-go decisions
Compliance Monitoring compliance_monitoring Regulation parsing, violation detection, remediation proposals
HR Policy Alignment hr_policy_alignment Policy distribution, understanding signals, compliance tracking

Data & CRM

Use Case Module Description
Catalog Enrichment catalog_enrichment Product deduplication, schema validation, feed ingestion
CRM Account Health crm_account_health Churn risk scoring, upsell identification, action prioritization

Architecture Patterns

Each use case demonstrates:

  • Fan-out/fan-in — Parallel data collection → consolidated analysis
  • Pipeline stages — Seeds → Signals → Hypotheses → Strategies → Evaluations
  • Invariant enforcement — Domain-specific quality gates (Gherkin-style)
  • Idempotency — Context-based deduplication, not hidden state

Deterministic + LLM Variants

Each use case includes two implementations:

Variant Module Suffix Description
Deterministic (base) Rule-based, fully reproducible
LLM-governed _llm AI-powered analysis with structured output
// Deterministic version
use converge_domain::growth_strategy::StrategyAgent;

// LLM-governed version (proposals validated before becoming facts)
use converge_domain::growth_strategy_llm::StrategyAgentLlm;

Quick Start

Deterministic Mode

use converge_core::{Engine, Context, ContextKey, Fact};
use converge_domain::growth_strategy::{
    MarketSignalAgent, CompetitorAgent, StrategyAgent, EvaluationAgent,
    BrandSafetyInvariant, RequireMultipleStrategies
};

// Create engine with domain agents
let mut engine = Engine::new();
engine.register(MarketSignalAgent);
engine.register(CompetitorAgent);
engine.register(StrategyAgent);
engine.register(EvaluationAgent);

// Register invariants
engine.add_invariant(BrandSafetyInvariant);
engine.add_invariant(RequireMultipleStrategies::new(2));

// Seed with market data
let mut ctx = Context::new();
ctx.add_fact(Fact::new(
    ContextKey::Seeds,
    "market-data",
    "Q4 revenue: $2.3M, growth: 15% YoY"
))?;

// Run to convergence
let result = engine.run(ctx)?;

// Extract evaluated strategies
for fact in result.context.get(ContextKey::Evaluations) {
    println!("Strategy evaluation: {}", fact.content);
}

LLM-Governed Mode

use converge_domain::growth_strategy_llm::StrategyAgentLlm;
use converge_provider::AnthropicProvider;

// LLM agent emits ProposedFact (untrusted)
// Validators promote to Fact (trusted) after invariant checks
let provider = AnthropicProvider::from_env("claude-3-5-sonnet-20241022")?;
let llm_agent = StrategyAgentLlm::new(Box::new(provider));

engine.register(llm_agent);

Governance Model

LLM outputs are never trusted by default.

Agent (LLM) → ProposedFact → Validator → Invariant Check → Fact
     ↑                                         ↓
  untrusted                               authoritative

Every LLM-generated proposal:

  1. Is wrapped in ProposedFact with provenance
  2. Passes through domain validators
  3. Satisfies all registered invariants
  4. Only then becomes an authoritative Fact

Domain Evals

The crate includes a domain-level evaluation framework for testing use case quality:

use converge_domain::evals::{StrategyDiversityEval, StrategyQualityEval};
use converge_domain::eval_agent::EvalExecutionAgent;

// Create eval agent with domain-specific criteria
let mut eval_agent = EvalExecutionAgent::new("growth_eval");
eval_agent.register_eval(StrategyDiversityEval);
eval_agent.register_eval(StrategyQualityEval);

engine.register(eval_agent);

Testing

# Run all domain tests
cargo test -p converge-domain

# Run specific use case tests
cargo test -p converge-domain growth_strategy

# Run verbose integration test (cycle-by-cycle trace)
cargo test -p converge-domain --test growth_strategy_verbose -- --nocapture

Verbose Test Output

Each use case has a *_verbose.rs test that prints:

  • Agent registration
  • Cycle-by-cycle execution
  • Fact emissions
  • Invariant checks
  • Final convergence state

Repository

This crate is part of the Converge project.

Standalone repo: github.com/kpernyer/converge-domain

License

MIT