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:
@@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
[infer]
|
||||
socket = "/tmp/infer.sock"
|
||||
model = "some-model"
|
||||
|
||||
[slots]
|
||||
main = 0
|
||||
background = 1
|
||||
|
||||
[expect]
|
||||
template_sha256 = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
|
||||
n_ctx = 4096
|
||||
slots = 2
|
||||
|
||||
[paths]
|
||||
home = "/srv/boxmaker"
|
||||
|
||||
[channel]
|
||||
socket = "/run/boxmaker/loop/loop.sock"
|
||||
|
||||
[loop]
|
||||
tool_iterations = 3
|
||||
repeat_detection = false
|
||||
tool_result_cap = 1024
|
||||
|
||||
[baseline]
|
||||
system = "prompts/agent.md"
|
||||
Reference in New Issue
Block a user