Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ repository = "https://github.com/hartsock/modulex-mcp"
[workspace.dependencies]
modulex-core = { path = "crates/modulex-core", version = "=0.1.0" }

# agent-store: causal-store substrate (Generation counter, SqliteBackend).
agent-store = "0.1"

agent-bridle-core = "0.1.0"
agent-bridle-tool-web = "0.1.0"
anyhow = "1.0"
Expand Down
1 change: 1 addition & 0 deletions crates/modulex-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test-support = []
[dependencies]
agent-bridle-core = { workspace = true }
agent-bridle-tool-web = { workspace = true, optional = true }
agent-store = { workspace = true }
anyhow = { workspace = true }
blake3 = { workspace = true, optional = true }
rusqlite = { workspace = true }
Expand Down
27 changes: 26 additions & 1 deletion crates/modulex-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,17 @@ pub struct McpConfig {
pub deny: Vec<String>,
}

/// Agent state store location (`[store]`).
/// Agent state store config (`[store]`).
#[derive(Clone, Debug, Default, Deserialize)]
pub struct StoreConfig {
/// SQLite path; empty = `$MODULEX_STORE` → `~/.modulex/store.db`.
#[serde(default)]
pub path: String,
/// Backend-selection policy — a flat knob, `[store] backend = "sqlite"`.
/// Defaults to the safe, daemonless SQLite backend; change direction
/// (Postgres, later) by editing config, not code.
#[serde(flatten)]
pub policy: agent_store::StorePolicy,
}

/// A fixed date to count down to.
Expand Down Expand Up @@ -367,6 +372,26 @@ pub fn expand_tilde(path: &str) -> PathBuf {
mod tests {
use super::*;

#[test]
fn store_backend_is_a_flat_policy_knob() {
// The agent-store StorePolicy flattens into [store] as a flat knob,
// alongside `path`, parsed via the real Config path.
let cfg = Config::from_toml(
r#"
[store]
path = "/tmp/x.db"
backend = "postgres"
"#,
)
.unwrap();
assert_eq!(cfg.store.path, "/tmp/x.db");
assert_eq!(cfg.store.policy.backend, agent_store::BackendKind::Postgres);

// Default: no backend key => the safe SQLite default.
let cfg = Config::from_toml("[store]\npath = \"/tmp/y.db\"\n").unwrap();
assert_eq!(cfg.store.policy.backend, agent_store::BackendKind::Sqlite);
}

#[test]
fn minimal_routine_parses_with_flattened_params() {
let cfg = Config::from_toml(
Expand Down
2 changes: 1 addition & 1 deletion crates/modulex-core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Engine {
(!config.store.path.is_empty()).then_some(config.store.path.as_str()),
home.as_deref(),
);
let store = match crate::store::Store::open(&path) {
let store = match crate::store::Store::open_with_policy(&config.store.policy, &path) {
Ok(store) => Some(Arc::new(store)),
Err(e) => {
eprintln!(
Expand Down
Loading
Loading