Add the paths, channel, loop and baseline config tables

Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
2026-09-18 17:36:20 -07:00
parent 06298d6a8e
commit ec5d887daa
4 changed files with 185 additions and 1 deletions
+75 -1
View File
@@ -82,6 +82,60 @@ impl Default for Limits {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Default)]
#[serde(deny_unknown_fields, default)]
pub struct Channel {
pub socket: std::path::PathBuf,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(deny_unknown_fields, default)]
pub struct Paths {
pub home: std::path::PathBuf,
}
impl Default for Paths {
fn default() -> Self {
Self {
home: std::env::var_os("BOXMAKER_HOME")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| std::path::PathBuf::from("/var/lib/boxmaker")),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(deny_unknown_fields, default)]
pub struct Loop {
pub tool_iterations: u32,
pub repeat_detection: bool,
pub tool_result_cap: usize,
}
impl Default for Loop {
fn default() -> Self {
Self {
tool_iterations: 8,
repeat_detection: true,
tool_result_cap: 16_384,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(deny_unknown_fields, default)]
pub struct Baseline {
pub system: std::path::PathBuf,
}
impl Default for Baseline {
fn default() -> Self {
Self {
system: std::path::PathBuf::from("system.md"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
@@ -92,6 +146,14 @@ pub struct Config {
pub sampling: Sampling,
#[serde(default)]
pub limits: Limits,
#[serde(default)]
pub paths: Paths,
#[serde(default)]
pub channel: Channel,
#[serde(default)]
pub r#loop: Loop,
#[serde(default)]
pub baseline: Baseline,
}
#[derive(Debug)]
@@ -118,6 +180,18 @@ impl Config {
pub fn load(path: &std::path::Path) -> Result<Config, ConfigError> {
let text =
std::fs::read_to_string(path).map_err(|e| ConfigError::Read(path.to_path_buf(), e))?;
toml::from_str(&text).map_err(|e| ConfigError::Parse(path.to_path_buf(), e))
let mut config: Config =
toml::from_str(&text).map_err(|e| ConfigError::Parse(path.to_path_buf(), e))?;
if let Some(parent) = path.parent() {
config.baseline.system = parent.join(&config.baseline.system);
}
Ok(config)
}
pub fn channel_socket(&self) -> std::path::PathBuf {
if self.channel.socket.as_os_str().is_empty() {
self.paths.home.join("run/loop/loop.sock")
} else {
self.channel.socket.clone()
}
}
}