Skip to main content

locode_engine/
config.rs

1//! Static per-session configuration for the loop.
2
3use std::path::PathBuf;
4use std::time::Duration;
5
6use locode_provider::{CacheHint, SamplingArgs};
7
8/// Everything the loop needs that isn't the provider, registry, preamble, or sink.
9#[derive(Debug, Clone)]
10pub struct EngineConfig {
11    /// The session identifier (stamped into the report + `Init`).
12    pub session_id: String,
13    /// The harness pack in use, e.g. `grok` (stamped into the report + `Init`).
14    pub harness: String,
15    /// The wire schema in use, e.g. `anthropic`/`mock` (the provider's `api_schema`).
16    pub api_schema: String,
17    /// The model id (for `Init`).
18    pub model: String,
19    /// The working directory handed to each tool call.
20    pub cwd: PathBuf,
21    /// The path-jail root (ADR-0008), handed to each `ToolCtx`.
22    pub workspace_root: PathBuf,
23    /// The max sample→dispatch turns before terminating with `MaxTurns`
24    /// (ADR-0005 amendment 2026-07-18). **`None` (the default) = unlimited** —
25    /// every studied harness defaults to no cap (Claude Code's `maxTurns?` is
26    /// enforced only when set; grok's `max_turns: Option<u32>` defaults `None`;
27    /// codex has no turn cap at all).
28    pub max_turns: Option<u32>,
29    /// Bounded loop-level resample budget on retryable provider errors (ADR-0007).
30    pub resample_retries: u32,
31    /// Base backoff between resamples; the nth retry waits `base * n`. Set to zero
32    /// in tests to avoid real sleeps.
33    pub resample_backoff: Duration,
34    /// Provider-neutral sampling knobs.
35    pub sampling_args: SamplingArgs,
36    /// Prompt-cache placement hint for the wire.
37    pub cache_hint: CacheHint,
38}
39
40impl Default for EngineConfig {
41    fn default() -> Self {
42        Self {
43            session_id: String::new(),
44            harness: String::new(),
45            api_schema: String::new(),
46            model: String::new(),
47            cwd: PathBuf::from("."),
48            workspace_root: PathBuf::from("."),
49            max_turns: None,
50            resample_retries: 2,
51            resample_backoff: Duration::from_millis(500),
52            sampling_args: SamplingArgs::default(),
53            cache_hint: CacheHint::default(),
54        }
55    }
56}