Skip to content

Commit 1b595f4

Browse files
committed
feat(config): add IdentityConfig and MemoryConfig
1 parent c264554 commit 1b595f4

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

src/config.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,38 @@ pub struct PluginConfig {
4343
pub public_url: Option<String>,
4444
}
4545

46+
/// User identity for AI agent context.
47+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
48+
#[serde(default)]
49+
pub struct IdentityConfig {
50+
pub name: Option<String>,
51+
pub role: Option<String>,
52+
pub vault_purpose: Option<String>,
53+
}
54+
55+
/// Memory layer feature flags.
56+
#[derive(Debug, Clone, Serialize, Deserialize)]
57+
#[serde(default)]
58+
pub struct MemoryConfig {
59+
pub identity_enabled: bool,
60+
pub timeline_enabled: bool,
61+
pub mining_enabled: bool,
62+
pub mining_strategy: String,
63+
pub mining_on_index: bool,
64+
}
65+
66+
impl Default for MemoryConfig {
67+
fn default() -> Self {
68+
Self {
69+
identity_enabled: true,
70+
timeline_enabled: true,
71+
mining_enabled: true,
72+
mining_strategy: "auto".into(),
73+
mining_on_index: true,
74+
}
75+
}
76+
}
77+
4678
/// HTTP REST API configuration.
4779
#[derive(Debug, Clone, Serialize, Deserialize)]
4880
#[serde(default)]
@@ -104,6 +136,10 @@ pub struct Config {
104136
/// HTTP REST API settings.
105137
#[serde(default)]
106138
pub http: HttpConfig,
139+
#[serde(default)]
140+
pub identity: IdentityConfig,
141+
#[serde(default)]
142+
pub memory: MemoryConfig,
107143
}
108144

109145
impl Default for Config {
@@ -118,6 +154,8 @@ impl Default for Config {
118154
obsidian: ObsidianConfig::default(),
119155
agents: AgentsConfig::default(),
120156
http: HttpConfig::default(),
157+
identity: IdentityConfig::default(),
158+
memory: MemoryConfig::default(),
121159
}
122160
}
123161
}
@@ -379,4 +417,33 @@ public_url = "https://vault.example.com"
379417
let config: Config = toml::from_str(toml).unwrap();
380418
assert_eq!(config.http.plugin.name.as_deref(), Some("my-vault"));
381419
}
420+
421+
#[test]
422+
fn test_identity_config_deserializes() {
423+
let toml_str = r#"
424+
[identity]
425+
name = "Test User"
426+
role = "Developer"
427+
vault_purpose = "notes"
428+
"#;
429+
let config: Config = toml::from_str(toml_str).unwrap();
430+
assert_eq!(config.identity.name, Some("Test User".into()));
431+
assert_eq!(config.identity.role, Some("Developer".into()));
432+
assert_eq!(config.identity.vault_purpose, Some("notes".into()));
433+
}
434+
435+
#[test]
436+
fn test_identity_config_defaults_to_empty() {
437+
let config = Config::default();
438+
assert!(config.identity.name.is_none());
439+
assert!(config.identity.role.is_none());
440+
}
441+
442+
#[test]
443+
fn test_memory_config_defaults() {
444+
let config = Config::default();
445+
assert!(config.memory.identity_enabled);
446+
assert!(config.memory.timeline_enabled);
447+
assert!(config.memory.mining_enabled);
448+
}
382449
}

0 commit comments

Comments
 (0)