diff --git a/crates/generation/src/bin/absolute_real_model_run.rs b/crates/generation/src/bin/absolute_real_model_run.rs index d8870a4..ed6c3e1 100644 --- a/crates/generation/src/bin/absolute_real_model_run.rs +++ b/crates/generation/src/bin/absolute_real_model_run.rs @@ -64,9 +64,14 @@ enum Provider { ClaudeCli(ClaudeCliClient), } +/// Reads `GENERA_CANDIDATES` via `generation::orchestrate::candidate_count`, default 8. +fn batch_candidate_count() -> usize { + generation::orchestrate::candidate_count() +} + fn main() -> Result<()> { let repo_root = repo_root(); - let candidate_count = generation::orchestrate::candidate_count(); + let candidate_count = batch_candidate_count(); let (provider, model_label) = if std::env::var("GENERA_PROVIDER").as_deref() == Ok("anthropic") { let client = match AnthropicClient::from_env() { @@ -352,3 +357,28 @@ fn main() -> Result<()> { Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + + /// `GENERA_CANDIDATES` is process-global state, so every case lives in one `#[test]` + /// run sequentially -- two tests each mutating it could otherwise race under cargo's + /// default parallel test runner. + #[test] + fn candidate_count_reads_env_unset_valid_and_invalid() { + std::env::remove_var("GENERA_CANDIDATES"); + assert_eq!(batch_candidate_count(), 8); + + std::env::set_var("GENERA_CANDIDATES", "32"); + assert_eq!(batch_candidate_count(), 32); + + std::env::set_var("GENERA_CANDIDATES", "0"); + assert_eq!(batch_candidate_count(), 8); + + std::env::set_var("GENERA_CANDIDATES", "not-a-number"); + assert_eq!(batch_candidate_count(), 8); + + std::env::remove_var("GENERA_CANDIDATES"); + } +}