converge_core/
lib.rs

1// Copyright 2024-2025 Aprio One AB, Sweden
2// Author: Kenneth Pernyer, kenneth@aprio.one
3// SPDX-License-Identifier: LicenseRef-Proprietary
4// All rights reserved. This source code is proprietary and confidential.
5// Unauthorized copying, modification, or distribution is strictly prohibited.
6
7//! # Converge Core
8//!
9//! A correctness-first, context-driven multi-agent runtime.
10//!
11//! Converge is an Agent OS where:
12//! - Context is the API
13//! - Agents collaborate through data, not calls
14//! - Execution proceeds until a fixed point
15//! - Convergence is explicit and observable
16//!
17//! ## Quick Start
18//!
19//! ```
20//! use converge_core::{Engine, Context, ContextKey};
21//! use converge_core::agents::{SeedAgent, ReactOnceAgent};
22//!
23//! // Create engine and register agents
24//! let mut engine = Engine::new();
25//! engine.register(SeedAgent::new("seed-1", "initial data"));
26//! engine.register(ReactOnceAgent::new("hyp-1", "derived insight"));
27//!
28//! // Run until convergence
29//! let result = engine.run(Context::new()).expect("should converge");
30//!
31//! // Inspect results
32//! assert!(result.converged);
33//! assert!(result.context.has(ContextKey::Seeds));
34//! assert!(result.context.has(ContextKey::Hypotheses));
35//! println!("Converged in {} cycles", result.cycles);
36//! ```
37//!
38//! ## Core Concepts
39//!
40//! - [`Context`]: The shared, typed, evolving state of a job
41//! - [`Agent`]: A capability that reads context and emits effects
42//! - [`AgentEffect`]: Buffered output (facts) from an agent
43//! - [`Engine`]: The convergence loop that coordinates agents
44//!
45//! ## Guarantees
46//!
47//! - **Determinism**: Same input → same output
48//! - **Termination**: Budgets prevent infinite loops
49//! - **Isolation**: Agents never call each other
50//! - **Auditability**: All changes are traceable
51
52mod agent;
53pub mod agents;
54mod context;
55mod effect;
56mod engine;
57mod error;
58pub mod invariant;
59pub mod llm;
60pub mod model_selection;
61pub mod prompt;
62pub mod root_intent;
63pub mod validation;
64
65pub use agent::{Agent, AgentId};
66pub use context::{Context, ContextKey, Fact, ProposedFact, ValidationError};
67pub use effect::AgentEffect;
68pub use engine::{Budget, ConvergeResult, Engine};
69pub use error::ConvergeError;
70pub use invariant::{Invariant, InvariantClass, InvariantError, InvariantResult, Violation};
71pub use model_selection::{
72    AgentRequirements, ComplianceLevel, CostClass, DataSovereignty, ModelSelectorTrait,
73};
74pub use prompt::{AgentPrompt, AgentRole, Constraint, OutputContract, PromptContext, PromptFormat};
75pub use root_intent::{
76    Budgets, IntentConstraint, IntentId, IntentKind, IntentValidationError, Objective, RootIntent,
77    Scope, ScopeConstraint, SuccessCriteria, SuccessCriterion, ConstraintSeverity,
78};
79
80#[cfg(test)]
81mod tests {
82    #[test]
83    fn crate_compiles() {
84        // Placeholder: proves the crate structure is valid
85    }
86}