test(fleet): keep CLI parsing regression at the CLI boundary

Move the real worker argv regression into the existing CLI test module,
preserving both policy values and parser assertions without a new Fleet
dependency on the top-level CLI. No module baseline or production changes.

Validation: focused Rust 1 passed, 0 failed, 0 ignored; module boundary
Python 23 passed; module graph baseline passed. npm test 670 passed and
check:web passed at parent 1b1744b; this follow-up changes tests only.

Signed-off-by: Hunter B <[email protected]>
This commit is contained in:
Hunter B committed 2026-09-29 06:51:02 -07:00
1 parent 1b1744bfa1
commit 0f48161ad5
2 files changed
+38 -29

No files matched your search

-29
View File
@@ -1216,35 +1216,6 @@ mod tests {
);
}
#[test]
fn worker_command_policy_prompt_that_looks_like_a_flag_parses() {
use clap::Parser as _;
// A Markdown bullet list, and a policy that reads exactly like one of
// exec's own flags; the latter makes clap reject a split
// `--append-system-prompt <value>` pair.
for policy in ["- Never push to main\n- Never touch .git/config", "--hooks"] {
let exec = FleetExecConfig {
append_system_prompt: policy.to_string(),
..FleetExecConfig::default()
};
let cmd = build_worker_exec_command("codewhale", &task("audit"), &exec, None);
let cli = crate::Cli::try_parse_from(
std::iter::once("codewhale".to_string()).chain(cmd.args),
)
.unwrap_or_else(|e| panic!("{policy:?}: {e}"));
let Some(crate::Commands::Exec(args)) = cli.command else {
panic!("expected exec command");
};
assert_eq!(args.append_system_prompt.as_deref(), Some(policy));
assert!(
args.prompt.last().is_some_and(|p| p.contains("audit")),
"{policy}"
);
assert!(!args.hooks, "{policy:?} must stay text, not a flag");
}
}
#[test]
fn worker_command_threads_positive_task_budgets_and_caps_steps() {
let mut task = task("audit");
+38
View File
@@ -15577,6 +15577,44 @@ mod terminal_mode_tests {
Cli::try_parse_from(args).expect("CLI args should parse")
}
#[test]
fn worker_command_policy_prompt_that_looks_like_a_flag_parses() {
use crate::fleet::executor::build_worker_exec_command;
use codewhale_config::FleetExecConfig;
use codewhale_protocol::fleet::FleetTaskSpec;
let task: FleetTaskSpec = serde_json::from_value(serde_json::json!({
"id": "t1",
"name": "Smoke",
"objective": "prove it runs",
"instructions": "audit",
"worker": { "role": "reviewer", "tool_profile": "read-only" }
}))
.unwrap();
// A Markdown bullet list, and a policy that reads exactly like one of
// exec's own flags; the latter makes clap reject a split
// `--append-system-prompt <value>` pair.
for policy in ["- Never push to main\n- Never touch .git/config", "--hooks"] {
let exec = FleetExecConfig {
append_system_prompt: policy.to_string(),
..FleetExecConfig::default()
};
let cmd = build_worker_exec_command("codewhale", &task, &exec, None);
let cli = Cli::try_parse_from(std::iter::once("codewhale".to_string()).chain(cmd.args))
.unwrap_or_else(|e| panic!("{policy:?}: {e}"));
let Some(Commands::Exec(args)) = cli.command else {
panic!("expected exec command");
};
assert_eq!(args.append_system_prompt.as_deref(), Some(policy));
assert!(
args.prompt.last().is_some_and(|p| p.contains("audit")),
"{policy}"
);
assert!(!args.hooks, "{policy:?} must stay text, not a flag");
}
}
#[test]
fn sessions_archive_cli_keeps_legacy_listing_and_export_options() {
let legacy = parse_cli(&["codewhale", "sessions", "--limit", "7", "--search", "work"]);