1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2026 Mahmoud Harmouch.
//
// Licensed under the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! # `cognition` - closed-loop agent cognition.
//!
//! This module implements the **ThinkLoop**: a PID-style feedback control system
//! that lets agents iteratively reason toward a natural-language goal using live
//! DuckDuckGo search as the information plant, without any LLM or GPU.
//!
//! ## Sub-modules
//!
//! | Module | Key Type | Role |
//! |-----------------|---------------------------------|----------------------------------------------------|
//! | `signal` | [`signal::CognitionSignal`] | Per-iteration error, gain, and reward scalar |
//! | `memory` | [`memory::HotStore`] etc. | Two-tier bounded/unbounded memory |
//! | `goal` | [`goal::GoalEvaluator`] | Convergence comparator (Jaccard distance) |
//! | `reflect` | [`reflect::Reflector`] | Query formulation + memory consolidation |
//! | `search` | [`search::SearchOracle`] | DuckDuckGo plant with in-process cache |
//! | `loop` | [`r#loop::ThinkLoop`] | The controller that stitches everything together |
//! | `attribution` | [`attribution::CausalAttributor`]| Counterfactual causal attribution |
//! | `hypothesis` | [`hypothesis::HypothesisGenerator`]| Novel causal hypothesis formation |
//! | `drive` | [`drive::InternalDrive`] | Internalized motivation and curiosity signals |
//!
//! ## Quick example
//!
//! ```rust
//! use lmm_agent::cognition::r#loop::ThinkLoop;
//! use lmm_agent::cognition::search::SearchOracle;
//!
//! #[tokio::main]
//! async fn main() {
//! let mut oracle = SearchOracle::new(5);
//! let mut lp = ThinkLoop::builder("How does Rust handle memory?")
//! .max_iterations(10)
//! .convergence_threshold(0.25)
//! .build();
//!
//! let result = lp.run(&mut oracle).await;
//! println!(
//! "converged={} in {} steps, error={:.3}",
//! result.converged, result.steps, result.final_error
//! );
//! }
//! ```
//!
//! ## See Also
//!
//! * [Autonomous agent - Wikipedia](https://en.wikipedia.org/wiki/Autonomous_agent)
//! * [Control theory - Wikipedia](https://en.wikipedia.org/wiki/Control_theory)
pub use ;
pub use ;
pub use GoalEvaluator;
pub use ;
pub use ;
pub use ;
pub use r#loop::;
pub use ;
pub use Reflector;
pub use SearchOracle;
pub use ;
// Copyright 2026 Mahmoud Harmouch.
//
// Licensed under the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.