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
+83
View File
@@ -141,3 +141,86 @@ fn load_reports_which_file_failed() {
let e: Box<dyn std::error::Error> = Box::new(Config::load(&missing).unwrap_err());
assert!(e.to_string().contains("does-not-exist.toml"));
}
// ---- M2b: paths, channel, loop and baseline ----
#[test]
fn the_m2b_tables_have_defaults() {
let c = Config::load(&fixture("minimal.toml")).unwrap();
assert_eq!(
c.channel.socket,
PathBuf::new(),
"empty means: under the home"
);
assert_eq!(c.channel_socket(), c.paths.home.join("run/loop/loop.sock"));
assert_eq!(
(
c.r#loop.tool_iterations,
c.r#loop.repeat_detection,
c.r#loop.tool_result_cap
),
(8, true, 16 * 1024)
);
// A relative system prompt is taken from the config file's directory.
assert_eq!(c.baseline.system, fixture("system.md"));
// The home comes from BOXMAKER_HOME when set, else /var/lib/boxmaker. Either way it is absolute.
assert!(c.paths.home.is_absolute(), "{:?}", c.paths.home);
}
#[test]
fn the_m2b_tables_can_be_set() {
let c = Config::load(&fixture("m2b.toml")).unwrap();
assert_eq!(c.paths.home, PathBuf::from("/srv/boxmaker"));
assert_eq!(
c.channel.socket,
PathBuf::from("/run/boxmaker/loop/loop.sock")
);
assert_eq!(
c.channel_socket(),
PathBuf::from("/run/boxmaker/loop/loop.sock")
);
assert_eq!(
(
c.r#loop.tool_iterations,
c.r#loop.repeat_detection,
c.r#loop.tool_result_cap
),
(3, false, 1024)
);
assert_eq!(
c.baseline.system,
fixture("prompts/agent.md"),
"relative to the config file"
);
let text = std::fs::read_to_string(fixture("m2b.toml")).unwrap();
let absolute = text.replace("prompts/agent.md", "/etc/boxmaker/system.md");
assert_eq!(
Config::parse(&absolute).unwrap().baseline.system,
PathBuf::from("/etc/boxmaker/system.md")
);
}
#[test]
fn unknown_keys_are_errors_in_the_m2b_tables_too() {
let text = std::fs::read_to_string(fixture("m2b.toml")).unwrap();
assert!(Config::parse(&text).is_ok());
for table in ["paths", "channel", "loop", "baseline"] {
let header = format!("[{table}]\n");
let bad = text.replacen(&header, &format!("{header}zz_unknown = 1\n"), 1);
assert!(
Config::parse(&bad).is_err(),
"[{table}] accepted an unknown key"
);
}
let partial = text.replace("tool_iterations = 3\nrepeat_detection = false\n", "");
let c = Config::parse(&partial).unwrap();
assert_eq!(
(
c.r#loop.tool_iterations,
c.r#loop.repeat_detection,
c.r#loop.tool_result_cap
),
(8, true, 1024),
"a partial table keeps the other defaults"
);
}