From 46852c60d5e48db0f863ac3e33173b2f08f6c452 Mon Sep 17 00:00:00 2001 From: Ignacio Martin Date: Mon, 16 Nov 2026 12:36:58 +0100 Subject: [PATCH 1/6] Select models by tier only in the DSL, CLI and swarm panel Scripts now name a tier per agent and never declare clients; the model profile is the single place a tier becomes a model. The CLI replaces --tiers-file with --tier AGENT=TIER and passes the profile to the compiler, and the TUI swarm form follows the new API. --- crates/gaviero-cli/src/main.rs | 84 +- crates/gaviero-cli/tests/state_modes_cli.rs | 23 +- crates/gaviero-dsl/src/ast.rs | 147 ++- crates/gaviero-dsl/src/compiler.rs | 812 +++++++------ crates/gaviero-dsl/src/for_loops.rs | 154 ++- crates/gaviero-dsl/src/inspect.rs | 134 ++- crates/gaviero-dsl/src/lib.rs | 65 +- crates/gaviero-dsl/src/parser.rs | 350 ++++-- crates/gaviero-dsl/src/profile.rs | 95 +- crates/gaviero-dsl/src/resolver.rs | 2 +- crates/gaviero-dsl/src/reviewers.rs | 3 +- crates/gaviero-dsl/src/tiers.rs | 95 -- crates/gaviero-dsl/src/workflow_params.rs | 660 +++-------- crates/gaviero-dsl/tests/compile.rs | 1027 ++++++++++++++--- .../tests/fixtures/test-profile.gaviero | 18 + .../gaviero-dsl/tests/loop_resume_contract.rs | 19 +- crates/gaviero-dsl/tests/profiles.rs | 309 ++--- crates/gaviero-dsl/tests/swarm_contract.rs | 133 +-- crates/gaviero-tui/src/app/swarm_run.rs | 78 +- .../gaviero-tui/src/panels/swarm_dashboard.rs | 70 +- 20 files changed, 2467 insertions(+), 1811 deletions(-) delete mode 100644 crates/gaviero-dsl/src/tiers.rs create mode 100644 crates/gaviero-dsl/tests/fixtures/test-profile.gaviero diff --git a/crates/gaviero-cli/src/main.rs b/crates/gaviero-cli/src/main.rs index ca4cbead..cde0e4ce 100644 --- a/crates/gaviero-cli/src/main.rs +++ b/crates/gaviero-cli/src/main.rs @@ -233,39 +233,29 @@ struct Cli { #[arg(long = "var", requires = "script")] vars: Vec, - /// Supply a workflow `param ` declared in a DSL script. Format: - /// `NAME=VALUE`. For roster params, the value is a comma-separated list - /// of `id=provider:model[@effort]` entries - /// (e.g. `--param roster=claude=claude:opus@max,codex=codex:gpt-5.5@high`). - /// List / roster params (`for t in `) also accept a DSL list literal - /// (`--param 'topics=[{id "a" focus "x"} {id "b"}]'`) or bare ids (`a,b`). - /// `tier:` may stand in for any model spec (e.g. `--param judge=tier:high`). + /// Supply a workflow list `param ` declared in a DSL script. + /// Format: `NAME=VALUE`, where the value is a comma-separated list of + /// `id=tier` entries (e.g. `--param roster=claude=top-claude,codex=top-codex`), + /// bare ids (`a,b`), or a DSL list literal + /// (`--param 'topics=[{id "a" focus "x"} {id "b" tier high}]'`). /// Required params without a default fail compilation when absent. /// Can be specified multiple times. Only valid with `--script`. #[arg(long = "param", requires = "script")] params: Vec, - /// Tier profile for a DSL script: a `.gaviero` file containing only - /// `tier ` bindings. Overrides tier lines from the script - /// and its `include`s (e.g. `profiles/doc-default.gaviero`). Agents must - /// `include "clients.gaviero"` (or equivalent) so named clients exist. - /// Only valid with `--script`. - #[arg(long = "tiers-file", requires = "script")] - tiers_file: Option, + /// Run one agent of a DSL script on another tier. Format: `AGENT=TIER` + /// (e.g. `--tier verifier=medium-codex`). Overrides the workflow's + /// `tiers { }` entry for that agent, which overrides the tier the agent + /// declares. Can be specified multiple times. Only valid with `--script`. + #[arg(long = "tier", value_name = "AGENT=TIER", requires = "script")] + agent_tiers: Vec, /// Model profile for a DSL script: the name of a /// `.gaviero/dsl/profiles/.gaviero` file (workspace folders first, then /// the workspace layer, then `$GAVIERO_ROOT`), or a path to a `.gaviero` - /// file. It binds the script's `tier` names to its own clients and - /// replaces the script's bindings for those tiers. Without this flag a - /// profile named `default`, if any, supplies only the tiers the script - /// leaves unbound. Only valid with `--script`. - #[arg( - long = "profile", - value_name = "NAME|PATH", - requires = "script", - conflicts_with = "tiers_file" - )] + /// file. It is the only place a tier gets its model. Without this flag + /// the profile named `default` is used. Only valid with `--script`. + #[arg(long = "profile", value_name = "NAME|PATH", requires = "script")] profile: Option, /// Print the N most recent retrieval manifests (Tier S / S4) and exit. @@ -1401,6 +1391,20 @@ fn parse_param_overrides(raw: &[String]) -> Result> { .collect() } +/// `--tier AGENT=TIER` pairs. +fn parse_agent_tiers(raw: &[String]) -> Result> { + raw.iter() + .map(|s| { + let (agent, tier) = s + .split_once('=') + .map(|(a, t)| (a.trim(), t.trim())) + .filter(|(a, t)| !a.is_empty() && !t.is_empty()) + .ok_or_else(|| anyhow::anyhow!("--tier `{s}`: expected AGENT=TIER"))?; + Ok((agent.to_string(), tier.to_string())) + }) + .collect() +} + fn resolve_model_spec(spec: &str, label: &str) -> Result { let trimmed = spec.trim(); gaviero_core::swarm::backend::shared::validate_model_spec(trimmed) @@ -4470,27 +4474,7 @@ async fn main() -> Result<()> { cli.prompt_file.as_deref(), ); let override_params = parse_param_overrides(&cli.params)?; - let override_tiers = if let Some(ref tiers_path) = cli.tiers_file { - let tiers_path = if tiers_path.is_absolute() { - tiers_path.clone() - } else { - std::env::current_dir() - .unwrap_or_else(|_| PathBuf::from(".")) - .join(tiers_path) - }; - let bindings = gaviero_dsl::load_tier_overrides(&tiers_path).map_err(|report| { - eprintln!("{:?}", report); - anyhow::anyhow!("tiers profile failed: {}", tiers_path.display()) - })?; - eprintln!( - "[tiers] profile {} ({} binding(s))", - tiers_path.display(), - bindings.len() - ); - bindings - } else { - Vec::new() - }; + let agent_tiers = parse_agent_tiers(&cli.agent_tiers)?; let profile = ProfileCatalog::scan(&workspace, &ScriptCatalog::global_scripts_dir()) .select( cli.profile.as_deref(), @@ -4509,7 +4493,7 @@ async fn main() -> Result<()> { cli.workflow.as_deref(), runtime_prompt.as_deref(), &override_vars, - &override_tiers, + &agent_tiers, &override_params, ) .map_err(|report| { @@ -4525,6 +4509,7 @@ async fn main() -> Result<()> { read_only_paths: Vec::new(), interface_contracts: std::collections::HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: Vec::new(), #[allow(deprecated)] @@ -4814,8 +4799,13 @@ async fn main() -> Result<()> { std::fs::write(&plan_path, &dsl_text).context("writing plan file")?; // Validate immediately so the user gets early feedback on syntax errors. + // The plan's agents name tiers, so it compiles against the profile a + // `--script` run of it would use: the `default` one. let plan_filename = plan_path.display().to_string(); - match gaviero_dsl::compile(&dsl_text, &plan_filename, None, None) { + let profile = ProfileCatalog::scan(&workspace, &ScriptCatalog::global_scripts_dir()) + .select(None, Some(&gaviero_core::memory::scope::hash_path(&repo)), &cwd) + .map_err(|message| anyhow::anyhow!(message))?; + match gaviero_dsl::compile(&dsl_text, &plan_filename, profile.as_ref(), None, None) { Ok(compiled) => { let agent_count = compiled.graph.node_count(); let units = compiled.work_units_ordered().unwrap_or_default(); diff --git a/crates/gaviero-cli/tests/state_modes_cli.rs b/crates/gaviero-cli/tests/state_modes_cli.rs index b349ca0b..3a954f22 100644 --- a/crates/gaviero-cli/tests/state_modes_cli.rs +++ b/crates/gaviero-cli/tests/state_modes_cli.rs @@ -15,14 +15,9 @@ fn gaviero_cli() -> PathBuf { } const SCRIPT: &str = r#" -client local { - model "ollama:qwen" - privacy public -} - agent writer { description "write the report" - client local + tier local scope { owned ["out/report.md"] } produces ["out/report.md"] prompt "Write the report." @@ -97,6 +92,18 @@ fn fake_ollama() -> String { format!("http://{addr}") } +/// The model profile every run here uses (`--profile`, beside the script): +/// the script names tier `local`, and this says it is the fake Ollama. +const PROFILE: &str = "client local { model \"ollama:qwen\" privacy public } +tier local local +"; + +fn profile_beside(script: &Path) -> PathBuf { + let path = script.with_file_name("local-profile.gaviero"); + std::fs::write(&path, PROFILE).unwrap(); + path +} + fn write_script(dir: &Path) -> PathBuf { let path = dir.join("wf.gaviero"); std::fs::write(&path, SCRIPT).unwrap(); @@ -112,6 +119,8 @@ fn run(script: &Path, workspace: &Path, extra: &[&str]) -> Output { Command::new(gaviero_cli()) .arg("--script") .arg(script) + .arg("--profile") + .arg(profile_beside(script)) .arg("--workspace") .arg(workspace) .arg("--ollama-base-url") @@ -156,6 +165,8 @@ fn run_from(cwd: &Path, script: &Path) -> Output { .current_dir(cwd) .arg("--script") .arg(script) + .arg("--profile") + .arg(profile_beside(script)) .arg("--ollama-base-url") .arg(fake_ollama()) .args(["--model", "ollama:qwen", "--no-mcp"]) diff --git a/crates/gaviero-dsl/src/ast.rs b/crates/gaviero-dsl/src/ast.rs index 749a856a..3ef0c25e 100644 --- a/crates/gaviero-dsl/src/ast.rs +++ b/crates/gaviero-dsl/src/ast.rs @@ -13,6 +13,8 @@ pub struct Script { /// A top-level declaration in a `.gaviero` file. #[derive(Debug, Clone)] pub enum Item { + /// A `client { … }` declaration. Only model profiles may declare one; + /// the public compile entry points reject it in scripts. Client(ClientDecl), Agent(AgentDecl), Workflow(WorkflowDecl), @@ -21,7 +23,8 @@ pub enum Item { /// Keys defined here are substituted compile-time across all agents. Vars(Vec), /// A top-level `tier ` alias — a named routing label - /// that resolves to a concrete client profile. See [`TierAlias`]. + /// that resolves to a concrete client. See [`TierAlias`]. Profile-only, + /// like [`Item::Client`]. TierAlias(TierAlias), /// `include "path"` — splices the items of another `.gaviero` file into /// the current script's top-level. Resolved by `compile_file` before @@ -33,7 +36,7 @@ pub enum Item { /// A top-level `include "path"` declaration. /// /// ```text -/// include "lib/clients.gaviero" +/// include "lib/prompts.gaviero" /// include "../shared/prompts.gaviero" /// ``` /// @@ -81,18 +84,17 @@ pub struct VarDecl { pub default: Option, } -/// Top-level `tier ` declaration. +/// Top-level `tier ` declaration of a model profile. /// /// ```text -/// client opus_deep { model "claude:opus" effort xhigh } -/// client codex_fast { model "codex:gpt-5.5" effort medium } -/// tier expensive opus_deep -/// tier cheap codex_fast +/// client opus { model "claude:opus" effort high } +/// client terra { model "codex:gpt-6.1-terra" effort medium } +/// tier high opus +/// tier medium terra /// ``` /// -/// An agent can then say `agent worker { tier cheap ... }` instead of binding -/// to a concrete client. The alias layer is meant for swapping concrete -/// bindings at the CLI (step 4) without touching agent definitions. +/// Scripts never bind a client: an agent says `tier high`, and the run's +/// profile says which model `high` is. #[derive(Debug, Clone)] pub struct TierAlias { /// Alias name. Accepts any identifier-shaped name — conventional values @@ -203,7 +205,7 @@ pub struct ExtraPair { /// ```text /// agent researcher { /// description "Research the codebase" -/// client claude_opus +/// tier high /// scope { owned ["docs/"] read_only ["src/**"] } /// prompt #" ... "# /// depends_on [other_agent] @@ -215,10 +217,10 @@ pub struct AgentDecl { pub name: String, pub name_span: Span, pub description: Option<(String, Span)>, - /// References a `ClientDecl` by name. - pub client: Option<(String, Span)>, - /// References a top-level `tier ` alias by name. - /// Mutually exclusive with `client` — enforced at compile time. + /// The agent's default `tier `, a tier of the run's model profile. + /// Required: the compiler rejects an agent without one. A workflow's + /// `tiers { }` block, `--tier`, or a list item's `tier` replace it before + /// compilation. pub tier_ref: Option<(String, Span)>, pub scope: Option, pub depends_on: Option<(Vec<(String, Span)>, Span)>, @@ -232,6 +234,9 @@ pub struct AgentDecl { /// Empty means no contract, and the runtime falls back to detecting /// whether the agent's owned files changed at all. pub produces: Vec, + /// Paths declared with `produces json [...]` (also in `produces`): the + /// runtime additionally requires them to parse as JSON. + pub produces_json: Vec, pub prompt: Option<(PromptSource, Span)>, pub max_retries: Option<(u8, Span)>, /// Wall-clock budget for one dispatch of this agent, in seconds. @@ -268,26 +273,15 @@ pub struct AgentDecl { pub file_id: u32, } -/// One reviewer in a `reviewers [ { id "…" model "provider:model" effort } … ]` -/// roster. The roster carries the model spec directly — no `client {}` -/// indirection — so reviewers can be supplied 100% externally via a workflow -/// `param`. `effort` is optional and overrides whatever the backend default -/// would be; backends that don't accept effort ignore it. +/// One item of a list param or `reviewers [ { id "…" tier } … ]` +/// roster. #[derive(Debug, Clone)] pub struct ReviewerEntry { pub id: String, pub id_span: Span, - /// Canonical `provider:model` spec (validated downstream by - /// `gaviero_core::swarm::backend::shared::validate_model_spec`), or - /// `tier:` to bind this reviewer to a tier instead. `None` for a - /// plain list entry (`for` keeps the body agent's own client); the - /// `reviewers` roster requires it. - pub model: Option, - /// Span of the `model` field when present, else the entry span. - pub model_span: Span, - /// Optional effort override (`off | auto | low | medium | high | xhigh | max`). - /// When `None`, the backend's default kicks in. - pub effort: Option<(String, Span)>, + /// `tier `: the clone made for this item runs on that tier instead + /// of its body agent's. `None` keeps the body agent's tier. + pub tier: Option<(String, Span)>, /// Free ` ""` fields, in source order (list params used by /// `for`; exposed as `{{.}}`). pub fields: Vec<(String, String, Span)>, @@ -313,53 +307,46 @@ impl ReviewerSource { } } -/// Explicit shape of a workflow `param` when the author uses `[...]` or `{...}`. +/// Explicit shape of a workflow `param` when the author writes a default. #[derive(Debug, Clone)] pub enum ParamShape { - /// `param [ { id "a" model "claude:opus" ... } ]` + /// `param [ { id "a" tier high ... } ]` Roster(Vec), - /// `param { model "provider:model" effort ... privacy ... extra { } }` - Client(ClientParamSpec), } -/// In-script default for a client workflow param (before CLI `--param` override). -#[derive(Debug, Clone, Default)] -pub struct ClientParamSpec { - pub model: Option<(String, Span)>, - pub effort: Option<(String, Span)>, - pub privacy: Option<(PrivacyLit, Span)>, - pub extra: Vec, - pub span: Span, -} - -/// Resolved kind after inferring bare `param ` declarations from usage. +/// A param's resolved kind. Params are lists; models are chosen by tiers +/// alone, so there is no model-valued param. #[derive(Debug, Clone)] pub enum ParamKind { + /// The in-script default, if any. Roster(Option>), - Client(ClientParamSpec), } -/// A workflow-level parameter declaration. +/// A workflow-level list parameter, iterated by `for` or `reviewers`. /// /// ```text -/// param roster [ { id "a" model "claude:opus" } ] // roster param -/// param judge { model "claude:sonnet" effort medium } // client param -/// param gate { model "tier:high" } // client param bound to a tier -/// param roster // required roster (CLI) -/// param gate { } // required client (CLI) +/// param roster [ { id "a" tier high } { id "b" tier high-codex } ] +/// param roster // required (CLI --param) /// ``` -/// -/// Bare `param ` (no `[...]` or `{...}`) infers kind from usage: -/// `reviewers ` → roster; `client ` on an agent → client. #[derive(Debug, Clone)] pub struct ParamDecl { pub name: String, pub name_span: Span, - /// When `None`, kind is inferred from `reviewers` / `client` references. + /// `None` for a bare `param `, whose value comes from `--param`. pub shape: Option, pub span: Span, } +/// One line of a workflow's `tiers { … }` block: run `agent` +/// on `tier` instead of the tier it declares. +#[derive(Debug, Clone)] +pub struct AgentTier { + pub agent: String, + pub agent_span: Span, + pub tier: String, + pub tier_span: Span, +} + /// How a consensus loop treats judge verdicts and whether a judge runs at all. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum ConsensusModeLit { @@ -509,6 +496,14 @@ pub struct ForBlock { pub mode_span: Span, pub agents: Vec<(String, Span)>, pub peer_template: Option<(String, Span)>, + /// `for in json "" …` — the list is read from this JSON file + /// at run time instead of a list param. When set, `list` holds the + /// literal `"json"`. The block is not cloned at compile time: its single + /// body agent compiles as a template and the runtime materialises one + /// clone per item (`gaviero_core::swarm::plan::RuntimeForOp`). + pub json_source: Option<(String, Span)>, + /// `max ` after the mode: cap on runtime items (json source only). + pub max_items: Option<(u32, Span)>, pub span: Span, } @@ -690,14 +685,52 @@ pub struct WorkflowDecl { /// Workflow-level parameter declarations. Resolved at compile time via /// CLI `--param NAME=VALUE` overrides; required when no default present. pub params: Vec, + /// `tiers { … }` — agents that run on another tier than + /// the one they declare in this workflow. `--tier agent=tier` overrides + /// entries of this block. + pub tiers: Vec, /// Optional pattern sugar (`pattern map_reduce { ... }`). Expanded into /// `CompiledPlan.fanout_ops` at compile time. pub pattern: Option, + /// `for … in json` blocks, recorded by `for` expansion (which replaces + /// each with a plain step / loop agent naming its body agent). Always + /// empty straight out of the parser. Emitted as + /// `CompiledPlan::runtime_fors`. + pub runtime_fors: Vec, + /// `budget { wall "" usd }` — run limits (see [`BudgetBlock`]). + pub budget: Option, pub span: Span, #[doc(hidden)] pub file_id: u32, } +/// The workflow-level `budget { wall "8h" usd 40 }` block. +/// +/// Values are kept as written; the compiler validates them (a duration is +/// `[s|m|h]`, `usd` must be positive, at least one field is set) so +/// the diagnostics carry their own text and span. A repeated field keeps its +/// first value, like every other workflow field. +#[derive(Debug, Clone)] +pub struct BudgetBlock { + pub wall: Option<(String, Span)>, + pub usd: Option<(f64, Span)>, + pub span: Span, +} + +/// One `for in json "" parallel [max ] { }` block +/// after expansion: the body agent compiles as a template unit and the +/// runtime clones it once per item of the JSON list. +#[derive(Debug, Clone)] +pub struct RuntimeForDecl { + pub var: String, + pub agent: String, + /// Path as written (compile-time vars are substituted by the compiler; + /// `{{ITER}}` / `{{PREV_ITER}}` survive to the runtime). + pub source: String, + pub max_items: Option, + pub span: Span, +} + // ── value literals ──────────────────────────────────────────────────────── #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/crates/gaviero-dsl/src/compiler.rs b/crates/gaviero-dsl/src/compiler.rs index fe5bbd67..6483b7fa 100644 --- a/crates/gaviero-dsl/src/compiler.rs +++ b/crates/gaviero-dsl/src/compiler.rs @@ -57,7 +57,7 @@ pub fn compile_ast_with_vars( workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], override_params: &[(String, String)], ) -> Result { let sources = vec![(filename.to_string(), source.to_string())]; @@ -67,7 +67,7 @@ pub fn compile_ast_with_vars( workflow, runtime_prompt, override_vars, - override_tiers, + agent_tiers, override_params, ) } @@ -85,10 +85,11 @@ pub fn compile_ast_with_sources( workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], override_params: &[(String, String)], ) -> Result { let mut script = script.clone(); + crate::workflow_params::apply_agent_tiers(&mut script, workflow, agent_tiers)?; expand_workflow_params_in_script(&mut script, workflow, override_params)?; if sources.is_empty() { @@ -115,7 +116,6 @@ pub fn compile_ast_with_sources( let mut prompt_map: HashMap<&str, &str> = HashMap::new(); let mut tier_alias_map: HashMap<&str, &TierAlias> = HashMap::new(); let mut script_vars: Vec<(String, String)> = Vec::new(); - let mut default_client: Option<&ClientDecl> = None; let mut errors: Vec = Vec::new(); for item in &script.items { @@ -166,22 +166,6 @@ pub fn compile_ast_with_sources( reason: format!("duplicate client name `{}`", c.name), }); } - // Track default client — only one is allowed - if c.is_default { - if default_client.is_some() { - errors.push(DslError::Compile { - src: src_for(c.file_id), - span: ( - c.name_span.start, - c.name_span.end.saturating_sub(c.name_span.start), - ) - .into(), - reason: "only one client can be declared `default`".into(), - }); - } else { - default_client = Some(c); - } - } } Item::Agent(a) => { if agent_map.insert(a.name.as_str(), a).is_some() { @@ -258,16 +242,11 @@ pub fn compile_ast_with_sources( } } - // ── Effective tier bindings (script/profile + CLI `--tiers-file`) ── - // - // CLI overrides win over `tier` lines from the script and its includes. - let mut effective_tier_bindings: HashMap = tier_alias_map + // ── Tier bindings: the profile's `tier` lines ── + let effective_tier_bindings: HashMap = tier_alias_map .values() .map(|ta| (ta.name.clone(), ta.client_ref.clone())) .collect(); - for (alias, client_ref) in override_tiers { - effective_tier_bindings.insert(alias.clone(), client_ref.clone()); - } // Validate every binding resolves to a declared client. for (alias, client_ref) in &effective_tier_bindings { @@ -372,7 +351,6 @@ pub fn compile_ast_with_sources( decl, &client_map, &effective_tier_bindings, - default_client, &prompt_map, &script_vars, override_vars, @@ -390,7 +368,6 @@ pub fn compile_ast_with_sources( decl, &client_map, &effective_tier_bindings, - default_client, &prompt_map, &script_vars, override_vars, @@ -448,6 +425,32 @@ pub fn compile_ast_with_sources( })); } + // ── Phase 5b: at most one loop per workflow ─────────────────── + // + // The runtime defers every dependent of a loop body to after the loops + // block, and Phase 6 makes a second loop depend on the first — so a + // second loop would run its agents once and never iterate. + if let Some(wf) = selected_workflow + && let Some((steps, _)) = &wf.steps + && let Some(second) = steps + .iter() + .filter_map(|s| match s { + StepItem::Loop(lb) => Some(lb), + _ => None, + }) + .nth(1) + { + return Err(DslErrors::single(DslError::Compile { + src: src_for(wf.file_id), + span: ( + second.span.start, + second.span.end.saturating_sub(second.span.start).max(1), + ) + .into(), + reason: "a workflow may contain at most one `loop` block".to_string(), + })); + } + // ── Phase 6: inject step-ordering barriers for loop blocks ──── // // Agents inside a `loop { }` block implicitly depend on all agents from @@ -506,7 +509,10 @@ pub fn compile_ast_with_sources( // ── Phase 8: extract LoopConfigs from workflow steps ──────── - let loop_configs = extract_loop_configs(selected_workflow, &script_vars, override_vars); + let mut loop_configs = extract_loop_configs(selected_workflow, &script_vars, override_vars); + for lc in &mut loop_configs { + lc.agent_ids = order_loop_agents(&lc.agent_ids, &work_units); + } let workflow_execution = if let Some(wf) = selected_workflow { if let Some((mode, _span)) = &wf.execution { @@ -525,6 +531,96 @@ pub fn compile_ast_with_sources( plan.loop_judge_units = loop_judge_units; plan.execution_mode = workflow_execution; + // `for … in json` steps. Compile-time vars resolve in the path now; + // `{{ITER}}` / `{{PREV_ITER}}` are left for the runtime pass. + if let Some(wf) = selected_workflow { + plan.runtime_fors = wf + .runtime_fors + .iter() + .map(|rf| gaviero_core::swarm::plan::RuntimeForOp { + unit_id: rf.agent.clone(), + var: rf.var.clone(), + source: apply_vars( + &rf.source, + &script_vars, + override_vars, + &[], + &[], + &rf.agent, + runtime_prompt, + ), + max_items: rf + .max_items + .unwrap_or(gaviero_core::swarm::plan::DEFAULT_MAX_SPAWN), + }) + .collect(); + } + + // `budget { wall "" usd }`. + if let Some(wf) = selected_workflow + && let Some(bb) = &wf.budget + { + let at = |span: &Span| (span.start, span.end.saturating_sub(span.start).max(1)); + let mut budget = gaviero_core::swarm::plan::RunBudget::default(); + if bb.wall.is_none() && bb.usd.is_none() { + errors.push(DslError::Compile { + src: src_for(wf.file_id), + span: at(&bb.span).into(), + reason: "`budget` needs `wall` or `usd`".to_string(), + }); + } + if let Some((wall, span)) = &bb.wall { + match parse_duration_secs(wall) { + Some(secs) => budget.wall_secs = Some(secs), + None => errors.push(DslError::Compile { + src: src_for(wf.file_id), + span: at(span).into(), + reason: "`wall` takes a duration like \"90s\", \"30m\" or \"8h\"".to_string(), + }), + } + } + if let Some((usd, span)) = &bb.usd { + if *usd > 0.0 { + budget.usd = Some(*usd); + } else { + errors.push(DslError::Compile { + src: src_for(wf.file_id), + span: at(span).into(), + reason: "`usd` must be positive".to_string(), + }); + } + } + plan.budget = Some(budget); + } + + // Tier bindings, resolved the way `compile_agent` resolves `tier `, + // so runtime items can name a `tier`. + for (alias, client_ref) in &effective_tier_bindings { + let Some(cd) = client_map.get(client_ref.as_str()) else { + continue; + }; + let extra = compile_extra(&cd.extra, &cd.name, sources, cd.file_id) + .map_err(DslErrors::single)?; + plan.tier_bindings.insert( + alias.clone(), + gaviero_core::swarm::plan::TierBinding { + model: cd.model.as_ref().map(|(m, _)| m.clone()), + effort: cd.effort.as_ref().map(|(e, _)| e.clone()), + extra, + privacy: cd + .privacy + .as_ref() + .map(|(p, _)| map_privacy(*p)) + .unwrap_or_default(), + tier: cd + .tier + .as_ref() + .map(|(t, _)| map_tier(*t)) + .unwrap_or_default(), + }, + ); + } + // Pattern sugar → fanout_ops (map_reduce only in v1). if let Some(wf) = selected_workflow && let Some(pattern) = &wf.pattern @@ -549,6 +645,22 @@ pub fn compile_ast_with_sources( } match pattern { PatternDecl::MapReduce(mr) => { + // Workers are materialised at run time and share the + // run root; repo-mode worktrees would need a per-worker + // provision + merge the runtime does not do. + if workflow_execution != gaviero_core::swarm::plan::ExecutionMode::Document + { + errors.push(DslError::Compile { + src: src_for(wf.file_id), + span: ( + mr.span.start, + mr.span.end.saturating_sub(mr.span.start).max(1), + ) + .into(), + reason: "`pattern map_reduce` requires `execution_mode document`" + .to_string(), + }); + } if !mr.reduce.0.is_empty() && !agent_map.contains_key(mr.reduce.0.as_str()) { errors.push(DslError::Compile { @@ -907,7 +1019,6 @@ fn compile_agent( decl: &AgentDecl, client_map: &HashMap<&str, &ClientDecl>, effective_tier_bindings: &HashMap, - default_client: Option<&ClientDecl>, prompt_map: &HashMap<&str, &str>, script_vars: &[(String, String)], override_vars: &[(String, String)], @@ -920,111 +1031,77 @@ fn compile_agent( NamedSource::new(filename, content.clone()) }; - // ── Reject mutually-exclusive client + tier ────────────────── + // ── The agent's tier → the profile's client ────────────────── // - // An agent may reference a concrete client OR a tier alias, but not both. - // Point the diagnostic at the tier field so the author sees the conflict - // on the newer surface syntax. - if let (Some((cn, _)), Some((tn, ts))) = (&decl.client, &decl.tier_ref) { + // `tier_ref` already carries the workflow's `tiers { }` block, `--tier` + // and a list item's `tier` (applied before cloning). It is the only way + // an agent gets a model. + let Some((tier_name, tier_span)) = &decl.tier_ref else { + let span = decl.name_span; return Err(DslError::Compile { src: src(), - span: (ts.start, ts.end.saturating_sub(ts.start).max(1)).into(), + span: (span.start, span.end.saturating_sub(span.start).max(1)).into(), reason: format!( - "agent `{}` declares both `client {}` and `tier {}` — pick one", - decl.name, cn, tn + "agent `{}` declares no tier — add `tier ` (e.g. `tier high`); \ + the run's model profile says which model each tier uses", + decl.name ), }); - } - - // Resolve the effective `ClientDecl` for this agent, if any. - // - // Order of precedence: - // 1. `client ` — explicit concrete binding. - // 2. `tier ` — resolve through tier alias → `ClientDecl`. - // 3. top-level `default` client. - // 4. no client — fall through to defaults + warning. - let resolved_client: Option<&ClientDecl> = - if let Some((client_name, client_span)) = &decl.client { - let cd = client_map - .get(client_name.as_str()) - .copied() - .ok_or_else(|| DslError::Compile { - src: src(), - span: ( - client_span.start, - client_span.end.saturating_sub(client_span.start).max(1), - ) - .into(), - reason: format!("undefined client `{}`", client_name), - })?; - Some(cd) - } else if let Some((tier_name, tier_span)) = &decl.tier_ref { - let client_ref = effective_tier_bindings - .get(tier_name.as_str()) - .ok_or_else(|| DslError::Compile { - src: src(), - span: ( - tier_span.start, - tier_span.end.saturating_sub(tier_span.start).max(1), + }; + let at_tier = ( + tier_span.start, + tier_span.end.saturating_sub(tier_span.start).max(1), + ); + let client_ref = effective_tier_bindings + .get(tier_name.as_str()) + .ok_or_else(|| { + let mut known: Vec<&str> = effective_tier_bindings.keys().map(String::as_str).collect(); + known.sort_unstable(); + DslError::Compile { + src: src(), + span: at_tier.into(), + reason: if known.is_empty() { + format!( + "agent `{}` uses tier `{}`, but no model profile is bound — choose \ + one with `--profile`, or add a `default` profile under \ + .gaviero/dsl/profiles/", + decl.name, tier_name ) - .into(), - reason: format!( - "agent `{}` references undefined tier alias `{}` — choose a profile \ - that binds it, or declare `tier {} ` in the script", - decl.name, tier_name, tier_name - ), - })?; - let cd = client_map - .get(client_ref.as_str()) - .ok_or_else(|| DslError::Compile { - src: src(), - span: ( - tier_span.start, - tier_span.end.saturating_sub(tier_span.start).max(1), + } else { + format!( + "agent `{}` uses tier `{}`, which the run's model profile does not \ + define (it defines: {})", + decl.name, + tier_name, + known.join(", ") ) - .into(), - reason: format!( - "tier alias `{}` references undefined client `{}`", - tier_name, client_ref - ), - })?; - Some(*cd) - } else { - default_client - }; + }, + } + })?; + let cd = client_map + .get(client_ref.as_str()) + .ok_or_else(|| DslError::Compile { + src: src(), + span: at_tier.into(), + reason: format!( + "tier alias `{}` references undefined client `{}`", + tier_name, client_ref + ), + })?; - let (tier, model, effort, extra, privacy) = if let Some(cd) = resolved_client { - let tier = cd - .tier - .as_ref() - .map(|(t, _)| map_tier(*t)) - .unwrap_or_default(); - let model = cd.model.as_ref().map(|(m, _)| m.clone()); - let effort = cd.effort.as_ref().map(|(e, _)| e.clone()); - let extra = compile_extra(&cd.extra, &cd.name, sources, cd.file_id)?; - let privacy = cd - .privacy - .as_ref() - .map(|(p, _)| map_privacy(*p)) - .unwrap_or_default(); - (tier, model, effort, extra, privacy) - } else { - // No explicit client, no tier alias, no default — warn if any - // clients are declared, then fall back to defaults. - if !client_map.is_empty() { - tracing::warn!( - agent = %decl.name, - "no client declared and no default client set; falling back to tier=Cheap/model=None. Declare a default client with `default` in the client block." - ); - } - ( - ModelTier::default(), - None, - None, - Vec::new(), - PrivacyLevel::default(), - ) - }; + let tier = cd + .tier + .as_ref() + .map(|(t, _)| map_tier(*t)) + .unwrap_or_default(); + let model = cd.model.as_ref().map(|(m, _)| m.clone()); + let effort = cd.effort.as_ref().map(|(e, _)| e.clone()); + let extra = compile_extra(&cd.extra, &cd.name, sources, cd.file_id)?; + let privacy = cd + .privacy + .as_ref() + .map(|(p, _)| map_privacy(*p)) + .unwrap_or_default(); // Build scope. Paths get the same compile-time var substitution as // prompts/descriptions so scripts can drive output roots via --var @@ -1059,6 +1136,7 @@ fn compile_agent( // {{ITER}} / {{PREV_ITER}} deliberately survive — the loop substitutes // them per pass so one declaration covers every iteration. let produces: Vec = decl.produces.iter().map(|p| sub(p)).collect(); + let produces_json: Vec = decl.produces_json.iter().map(|p| sub(p)).collect(); let depends_on = decl .depends_on @@ -1238,6 +1316,7 @@ fn compile_agent( description, scope, produces, + produces_json, depends_on, backend: AgentBackend::default(), model, @@ -1409,6 +1488,66 @@ fn extract_loop_configs( .collect() } +/// `[s|m|h]` → seconds (no suffix means seconds). `None` for any +/// other shape, for zero, and on overflow. +fn parse_duration_secs(text: &str) -> Option { + let text = text.trim(); + let (digits, unit) = match text.char_indices().last()? { + (i, 's') => (&text[..i], 1), + (i, 'm') => (&text[..i], 60), + (i, 'h') => (&text[..i], 3600), + _ => (text, 1), + }; + if digits.is_empty() || !digits.bytes().all(|b| b.is_ascii_digit()) { + return None; + } + let secs = digits.parse::().ok()?.checked_mul(unit)?; + (secs > 0).then_some(secs) +} + +/// Order a loop's agents so each comes after the loop agents it +/// `depends_on`. Stable: agents with no ordering constraint between them +/// keep their written order (`agents [...]` first, then `for` clones). +/// Dependencies on agents outside the loop play no part here — the loop as +/// a whole already runs after them. +/// +/// The sequential and stacked loop passes walk `agent_ids` in order, so this +/// is what makes `curator { depends_on [investigator] }` run after the +/// investigators in every pass. +fn order_loop_agents(agent_ids: &[String], work_units: &[WorkUnit]) -> Vec { + let members: HashSet<&str> = agent_ids.iter().map(String::as_str).collect(); + let deps_of = |id: &str| -> Vec<&str> { + work_units + .iter() + .find(|u| u.id == id) + .map(|u| { + u.depends_on + .iter() + .map(String::as_str) + .filter(|d| members.contains(d) && *d != id) + .collect() + }) + .unwrap_or_default() + }; + let mut placed: Vec = Vec::with_capacity(agent_ids.len()); + let mut remaining: Vec<&String> = agent_ids.iter().collect(); + while !remaining.is_empty() { + let next = remaining.iter().position(|id| { + deps_of(id) + .iter() + .all(|d| placed.iter().any(|p| p.as_str() == *d)) + }); + // Cycles are rejected before this runs; keep the rest as written + // rather than loop forever if one ever slips through. + let Some(idx) = next else { + placed.extend(remaining.into_iter().cloned()); + break; + }; + placed.push(remaining.remove(idx).clone()); + } + placed +} + fn resolve_var( key: &str, script_vars: &[(String, String)], @@ -1465,21 +1604,55 @@ mod tests { use crate::{lexer, parser}; use gaviero_core::types::ModelTier; + /// Bind tier `t` (most fixtures' agents use it) to a tier with no + /// model, the way a profile would. Fixtures that declare their own + /// clients and tier lines stand for an already-merged profile. + fn with_test_tier(mut script: Script) -> Script { + let bound = script + .items + .iter() + .any(|i| matches!(i, Item::TierAlias(t) if t.name == "t")); + if !bound { + let span: Span = (0..0).into(); + script.items.push(Item::Client(ClientDecl { + name: "__test_t".into(), + name_span: span, + tier: None, + model: None, + effort: None, + extra: Vec::new(), + privacy: None, + is_default: false, + span, + file_id: 0, + })); + script.items.push(Item::TierAlias(TierAlias { + name: "t".into(), + name_span: span, + client_ref: "__test_t".into(), + client_ref_span: span, + span, + file_id: 0, + })); + } + script + } + fn compile_str(src: &str) -> Result, DslErrors> { let (tokens, _) = lexer::lex(src); let (ast, errs) = parser::parse(&tokens, src, "test.gaviero"); assert!(errs.is_empty(), "parse errors: {:?}", errs); - compile_ast(&ast.unwrap(), src, "test.gaviero", None, None) + compile_ast(&with_test_tier(ast.unwrap()), src, "test.gaviero", None, None) .map(|c| c.work_units_ordered().expect("toposort in tests")) } const FULL_EXAMPLE: &str = r##" - client opus { tier coordinator model "claude-opus-4-7" } - client sonnet { tier execution model "claude-sonnet-4-6" } + client opus { tier coordinator model "claude-opus-4-7" } tier opus opus + client sonnet { tier execution model "claude-sonnet-4-6" } tier sonnet sonnet agent researcher { description "Research the codebase" - client opus + tier opus scope { owned ["docs/architecture.md"] read_only ["src/**"] } prompt #"Analyze the codebase and write a comprehensive architecture document."# max_retries 2 @@ -1487,7 +1660,7 @@ mod tests { agent implementer { description "Implement the feature" - client sonnet + tier sonnet depends_on [researcher] scope { owned ["src/feature/"] read_only ["docs/architecture.md"] } prompt #"Based on the architecture document, implement the feature."# @@ -1503,9 +1676,9 @@ mod tests { fn produces_substitutes_vars_but_defers_iter() { let src = r##" vars { OUT_DIR "plans/out" } - client sonnet { tier execution model "claude:sonnet" } + client sonnet { tier execution model "claude:sonnet" } tier sonnet sonnet agent writer { - client sonnet + tier sonnet scope { owned ["{{OUT_DIR}}/report-v*.md"] } produces [ "{{OUT_DIR}}/report-v{{ITER}}.md" @@ -1546,9 +1719,9 @@ mod tests { #[test] fn agent_timeout_is_declarable_and_zero_means_unbounded() { let src = r##" - client sonnet { tier execution model "claude:sonnet" } - agent quick { client sonnet timeout 90 prompt #"go"# } - agent unbounded { client sonnet timeout 0 prompt #"go"# } + client sonnet { tier execution model "claude:sonnet" } tier sonnet sonnet + agent quick { tier sonnet timeout 90 prompt #"go"# } + agent unbounded { tier sonnet timeout 0 prompt #"go"# } workflow w { steps [quick unbounded] } "##; let units = compile_str(src).expect("should compile"); @@ -1560,9 +1733,9 @@ mod tests { #[test] fn loop_irreconcilable_after_is_declarable_and_defaults_to_two() { let base = r##" - client sonnet { tier execution model "claude:sonnet" } - agent worker { client sonnet scope { owned ["a/"] } prompt #"go"# } - agent judge { client sonnet prompt #"judge"# } + client sonnet { tier execution model "claude:sonnet" } tier sonnet sonnet + agent worker { tier sonnet scope { owned ["a/"] } prompt #"go"# } + agent judge { tier sonnet prompt #"judge"# } "##; let plan = |extra: &str| { let src = format!( @@ -1571,7 +1744,7 @@ mod tests { let (tokens, _) = lexer::lex(&src); let (ast, errs) = parser::parse(&tokens, &src, "test.gaviero"); assert!(errs.is_empty(), "parse errors: {errs:?}"); - compile_ast(&ast.unwrap(), &src, "test.gaviero", None, None).expect("compiles") + compile_ast(&with_test_tier(ast.unwrap()), &src, "test.gaviero", None, None).expect("compiles") }; assert_eq!(plan("").loop_configs[0].irreconcilable_after, 2); assert_eq!( @@ -1613,7 +1786,7 @@ mod tests { #[test] fn undefined_client_ref() { - let src = r#"agent x { client nonexistent }"#; + let src = r#"agent x { tier nonexistent }"#; let result = compile_str(src); assert!(result.is_err()); let errs = result.unwrap_err(); @@ -1623,14 +1796,14 @@ mod tests { #[test] fn duplicate_agent_name() { - let src = r#"agent x { } agent x { }"#; + let src = r#"agent x { tier t } agent x { tier t }"#; let result = compile_str(src); assert!(result.is_err()); } #[test] fn agent_no_client_uses_defaults() { - let src = r#"agent simple { description "task" }"#; + let src = r#"agent simple { tier t description "task" }"#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].tier, ModelTier::Cheap); // Cheap is now the default assert_eq!(units[0].model, None); @@ -1640,8 +1813,8 @@ mod tests { #[test] fn client_effort_flows_to_work_unit() { let src = r#" - client deep { model "opus" effort high } - agent a { client deep description "task" } + client deep { model "opus" effort high } tier deep deep + agent a { tier deep description "task" } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].effort.as_deref(), Some("high")); @@ -1649,21 +1822,11 @@ mod tests { } #[test] - fn default_client_effort_flows_to_work_unit() { - let src = r#" - client deep { model "opus" effort xhigh default } - agent a { description "uses default" } - "#; - let units = compile_str(src).expect("should compile"); - assert_eq!(units[0].effort.as_deref(), Some("xhigh")); - } - - #[test] - fn explicit_client_effort_overrides_default() { + fn a_default_marker_does_not_choose_the_model() { let src = r#" - client fast { model "haiku" effort low default } - client deep { model "opus" effort high } - agent a { client deep description "task" } + client fast { model "haiku" effort low default } tier fast fast + client deep { model "opus" effort high } tier deep deep + agent a { tier deep description "task" } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].effort.as_deref(), Some("high")); @@ -1678,8 +1841,8 @@ mod tests { thinking_budget "8000" max_tokens "32768" } - } - agent a { client deep description "task" } + } tier deep deep + agent a { tier deep description "task" } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].extra.len(), 2); @@ -1687,21 +1850,6 @@ mod tests { assert_eq!(units[0].extra[1], ("max_tokens".into(), "32768".into())); } - #[test] - fn default_client_extras_flow_to_work_unit() { - let src = r#" - client deep { - model "opus" - default - extra { thinking_budget "4000" } - } - agent a { description "uses default" } - "#; - let units = compile_str(src).expect("should compile"); - assert_eq!(units[0].extra.len(), 1); - assert_eq!(units[0].extra[0].0, "thinking_budget"); - } - #[test] fn duplicate_extra_key_is_compile_error() { let src = r#" @@ -1711,8 +1859,8 @@ mod tests { thinking_budget "8000" thinking_budget "9000" } - } - agent a { client deep description "task" } + } tier deep deep + agent a { tier deep description "task" } "#; let err = compile_str(src).expect_err("duplicate extra key should fail"); let msg = format!("{:?}", err); @@ -1728,7 +1876,7 @@ mod tests { #[test] fn tier_alias_resolves_to_client_fields() { let src = r#" - client deep { model "opus" effort xhigh } + client deep { model "opus" effort xhigh } tier deep deep tier expensive deep agent a { tier expensive description "task" } "#; @@ -1739,11 +1887,12 @@ mod tests { #[test] fn a_misspelled_effort_is_a_compile_error() { + // A profile's client with a misspelled effort fails the compile. let src = r#" - client deep { model "claude:opus" effort hgih default } - agent a { prompt "p" } + client deep { model "claude:opus" effort hgih } tier deep deep + agent a { tier deep prompt "p" } "#; - let error = format!("{:?}", crate::compile(src, "t.gaviero", None, None).unwrap_err()); + let error = format!("{:?}", compile_str(src).unwrap_err()); assert!(error.contains("unknown effort `hgih`"), "{error}"); assert!(error.contains("xhigh"), "lists the valid names: {error}"); } @@ -1751,10 +1900,10 @@ mod tests { #[test] fn a_real_level_the_model_lacks_still_compiles() { let src = r#" - client fast { model "dsh:deepseek-flash" effort xhigh default } - agent a { prompt "p" } + client fast { model "dsh:deepseek-flash" effort xhigh } tier fast fast + agent a { tier fast prompt "p" } "#; - crate::compile(src, "t.gaviero", None, None).unwrap(); + compile_str(src).unwrap(); } #[test] @@ -1763,7 +1912,7 @@ mod tests { client deep { model "opus" extra { thinking_budget "8000" } - } + } tier deep deep tier expensive deep agent a { tier expensive description "task" } "#; @@ -1775,13 +1924,13 @@ mod tests { #[test] fn undefined_tier_alias_is_compile_error() { let src = r#" - client deep { model "opus" } + client deep { model "opus" } tier deep deep agent a { tier ghost description "task" } "#; let err = compile_str(src).expect_err("undefined alias should fail"); let msg = format!("{:?}", err); assert!( - msg.contains("undefined tier alias") && msg.contains("ghost"), + msg.contains("uses tier `ghost`") && msg.contains("it defines: deep, t"), "unexpected error: {}", msg ); @@ -1793,7 +1942,7 @@ mod tests { tier expensive ghost_client agent a { tier expensive description "task" } "#; - let err = compile_str(src).expect_err("alias→ghost client should fail"); + let err = compile_str(src).expect_err("alias→ghost tier should fail"); let msg = format!("{:?}", err); assert!( msg.contains("tier alias") && msg.contains("ghost_client"), @@ -1805,8 +1954,8 @@ mod tests { #[test] fn duplicate_tier_alias_is_compile_error() { let src = r#" - client a { model "opus" } - client b { model "haiku" } + client a { model "opus" } tier a a + client b { model "haiku" } tier b b tier cheap a tier cheap b "#; @@ -1819,26 +1968,10 @@ mod tests { ); } - #[test] - fn agent_cannot_declare_both_client_and_tier() { - let src = r#" - client deep { model "opus" } - tier expensive deep - agent a { client deep tier expensive description "task" } - "#; - let err = compile_str(src).expect_err("both client+tier should fail"); - let msg = format!("{:?}", err); - assert!( - msg.contains("both") && msg.contains("client") && msg.contains("tier"), - "unexpected error: {}", - msg - ); - } - #[test] fn tier_alias_with_custom_name_resolves() { let src = r#" - client c { model "haiku" effort low } + client c { model "haiku" effort low } tier c c tier blazingly_fast c agent a { tier blazingly_fast description "task" } "#; @@ -1848,10 +1981,10 @@ mod tests { } #[test] - fn explicit_client_takes_precedence_over_default() { + fn the_agent_tier_alone_chooses_the_client() { let src = r#" - client fast { model "haiku" default } - client deep { model "opus" } + client fast { model "haiku" default } tier fast fast + client deep { model "opus" } tier deep deep tier expensive deep agent a { tier expensive description "task" } "#; @@ -1862,56 +1995,28 @@ mod tests { #[test] fn extras_empty_when_no_extra_block() { let src = r#" - client deep { model "opus" } - agent a { client deep description "task" } + client deep { model "opus" } tier deep deep + agent a { tier deep description "task" } "#; let units = compile_str(src).expect("should compile"); assert!(units[0].extra.is_empty()); } #[test] - fn agent_no_client_uses_default_client() { + fn the_agent_tier_alone_chooses_the_client_and_its_tier_lit() { let src = r#" - client sonnet { tier cheap model "claude-sonnet-4-6" default } - agent a { description "uses default" } - "#; - let units = compile_str(src).expect("should compile"); - assert_eq!(units[0].tier, ModelTier::Cheap); - assert_eq!(units[0].model, Some("claude-sonnet-4-6".to_string())); - } - - #[test] - fn explicit_client_overrides_default() { - let src = r#" - client sonnet { tier cheap model "claude-sonnet-4-6" default } - client opus { tier expensive model "claude-opus-4-7" } - agent a { description "explicit opus" client opus } + client sonnet { tier cheap model "claude-sonnet-4-6" default } tier sonnet sonnet + client opus { tier expensive model "claude-opus-4-7" } tier opus opus + agent a { description "explicit opus" tier opus } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].tier, ModelTier::Expensive); assert_eq!(units[0].model, Some("claude-opus-4-7".to_string())); } - #[test] - fn multiple_defaults_is_compile_error() { - let src = r#" - client sonnet { tier cheap model "claude-sonnet-4-6" default } - client opus { tier expensive model "claude-opus-4-7" default } - agent a { description "test" } - "#; - let result = compile_str(src); - assert!(result.is_err(), "multiple defaults should error"); - let msg = format!("{:?}", result.unwrap_err()); - assert!( - msg.contains("default"), - "error should mention default: {}", - msg - ); - } - #[test] fn agent_no_scope_gets_dot_scope() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str(src).expect("compile"); assert_eq!(units[0].scope.owned_paths, vec!["."]); } @@ -1919,13 +2024,13 @@ mod tests { #[test] fn workflow_filter() { let src = r#" - agent a { description "a" } - agent b { description "b" } + agent a { tier t description "a" } + agent b { tier t description "b" } workflow only_a { steps [a] } "#; let (tokens, _) = lexer::lex(src); let (ast, _) = parser::parse(&tokens, src, "t"); - let compiled = compile_ast(&ast.unwrap(), src, "t", Some("only_a"), None).unwrap(); + let compiled = compile_ast(&with_test_tier(ast.unwrap()), src, "t", Some("only_a"), None).unwrap(); let units = compiled.work_units_ordered().expect("toposort in tests"); assert_eq!(units.len(), 1); assert_eq!(units[0].id, "a"); @@ -1933,10 +2038,10 @@ mod tests { #[test] fn undefined_workflow_step_errors() { - let src = r#"agent a { } workflow w { steps [a ghost] }"#; + let src = r#"agent a { tier t } workflow w { steps [a ghost] }"#; let (tokens, _) = lexer::lex(src); let (ast, _) = parser::parse(&tokens, src, "t"); - let result = compile_ast(&ast.unwrap(), src, "t", None, None); + let result = compile_ast(&with_test_tier(ast.unwrap()), src, "t", None, None); assert!(result.is_err()); let msg = format!("{:?}", result.unwrap_err()); assert!(msg.contains("ghost"), "{}", msg); @@ -1945,8 +2050,8 @@ mod tests { #[test] fn cycle_detection_simple() { let src = r#" - agent a { depends_on [b] } - agent b { depends_on [a] } + agent a { tier t depends_on [b] } + agent b { tier t depends_on [a] } "#; let result = compile_str(src); assert!(result.is_err()); @@ -1957,9 +2062,9 @@ mod tests { #[test] fn cycle_detection_three_nodes() { let src = r#" - agent a { depends_on [c] } - agent b { depends_on [a] } - agent c { depends_on [b] } + agent a { tier t depends_on [c] } + agent b { tier t depends_on [a] } + agent c { tier t depends_on [b] } "#; let result = compile_str(src); assert!(result.is_err()); @@ -1970,9 +2075,9 @@ mod tests { #[test] fn no_cycle_linear_chain() { let src = r#" - agent a { description "first" } - agent b { depends_on [a] description "second" } - agent c { depends_on [b] description "third" } + agent a { tier t description "first" } + agent b { tier t depends_on [a] description "second" } + agent c { tier t depends_on [b] description "third" } "#; let result = compile_str(src); assert!(result.is_ok(), "linear chain should not be a cycle"); @@ -1980,7 +2085,7 @@ mod tests { #[test] fn self_dependency_is_cycle() { - let src = r#"agent self_ref { depends_on [self_ref] }"#; + let src = r#"agent self_ref { tier t depends_on [self_ref] }"#; let result = compile_str(src); assert!(result.is_err()); let msg = format!("{:?}", result.unwrap_err()); @@ -1990,19 +2095,19 @@ mod tests { #[test] fn workflow_max_parallel_propagated() { let src = r#" - agent a { description "first" } + agent a { tier t description "first" } workflow w { steps [a] max_parallel 3 } "#; let (tokens, _) = lexer::lex(src); let (ast, _) = parser::parse(&tokens, src, "t"); - let compiled = compile_ast(&ast.unwrap(), src, "t", None, None).unwrap(); + let compiled = compile_ast(&with_test_tier(ast.unwrap()), src, "t", None, None).unwrap(); assert_eq!(compiled.max_parallel, Some(3)); } #[test] fn memory_merge_additive_read_ns() { let src = r#" - agent a { + agent a { tier t memory { read_ns ["agent-ns"] write_ns "agent-out" @@ -2028,7 +2133,7 @@ mod tests { #[test] fn memory_merge_workflow_write_ns_fallback() { let src = r#" - agent a { description "t" } + agent a { tier t description "t" } workflow w { steps [a] memory { write_ns "wf-default" } @@ -2041,7 +2146,7 @@ mod tests { #[test] fn memory_importance_and_staleness() { let src = r#" - agent scan { + agent scan { tier t memory { importance 0.8 staleness_sources ["src/" "Cargo.toml"] @@ -2055,7 +2160,7 @@ mod tests { #[test] fn memory_none_when_not_declared() { - let src = r#"agent a { description "task" }"#; + let src = r#"agent a { tier t description "task" }"#; let units = compile_str(src).unwrap(); assert!(units[0].read_namespaces.is_none()); assert!(units[0].write_namespace.is_none()); @@ -2065,7 +2170,7 @@ mod tests { #[test] fn undefined_depends_on_has_span() { - let src = r#"agent a { depends_on [nonexistent] }"#; + let src = r#"agent a { tier t depends_on [nonexistent] }"#; let result = compile_str(src); assert!(result.is_err()); let err = &result.unwrap_err().errors[0]; @@ -2086,20 +2191,20 @@ mod tests { let (tokens, _) = lexer::lex(src); let (ast, errs) = parser::parse(&tokens, src, "test.gaviero"); assert!(errs.is_empty(), "parse errors: {:?}", errs); - compile_ast(&ast.unwrap(), src, "test.gaviero", None, runtime_prompt) + compile_ast(&with_test_tier(ast.unwrap()), src, "test.gaviero", None, runtime_prompt) .map(|c| c.work_units_ordered().expect("toposort in tests")) } #[test] fn runtime_prompt_substituted_in_coordinator_instructions() { - let src = r##"agent x { prompt #"Task: {{PROMPT}}"# }"##; + let src = r##"agent x { tier t prompt #"Task: {{PROMPT}}"# }"##; let units = compile_str_with_prompt(src, Some("implement login")).unwrap(); assert_eq!(units[0].coordinator_instructions, "Task: implement login"); } #[test] fn runtime_prompt_fixed_prompt_unchanged() { - let src = r##"agent x { prompt #"Fixed task: do the thing"# }"##; + let src = r##"agent x { tier t prompt #"Fixed task: do the thing"# }"##; let units = compile_str_with_prompt(src, Some("ignored")).unwrap(); assert_eq!( units[0].coordinator_instructions, @@ -2109,28 +2214,28 @@ mod tests { #[test] fn runtime_prompt_fallback_no_prompt_field() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str_with_prompt(src, Some("do the thing")).unwrap(); assert_eq!(units[0].coordinator_instructions, "do the thing"); } #[test] fn runtime_prompt_none_no_prompt_field_empty() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str_with_prompt(src, None).unwrap(); assert_eq!(units[0].coordinator_instructions, ""); } #[test] fn runtime_prompt_substituted_in_description() { - let src = r#"agent x { description "Process {{PROMPT}}" }"#; + let src = r#"agent x { tier t description "Process {{PROMPT}}" }"#; let units = compile_str_with_prompt(src, Some("files")).unwrap(); assert_eq!(units[0].description, "Process files"); } #[test] fn runtime_prompt_multiple_placeholder_occurrences() { - let src = r##"agent x { prompt #"{{PROMPT}} and also {{PROMPT}}"# }"##; + let src = r##"agent x { tier t prompt #"{{PROMPT}} and also {{PROMPT}}"# }"##; let units = compile_str_with_prompt(src, Some("X")).unwrap(); assert_eq!(units[0].coordinator_instructions, "X and also X"); } @@ -2138,7 +2243,7 @@ mod tests { #[test] fn memory_read_query_and_limit_compiled() { let src = r#" - agent x { + agent x { tier t memory { read_query "custom search query" read_limit 10 @@ -2156,7 +2261,7 @@ mod tests { #[test] fn memory_write_content_compiled() { let src = r##" - agent x { + agent x { tier t memory { write_ns "output" write_content #"Findings: {{SUMMARY}}"# @@ -2174,7 +2279,7 @@ mod tests { #[test] fn memory_read_query_prompt_substitution() { let src = r#" - agent x { + agent x { tier t memory { read_query "find results for {{PROMPT}}" } @@ -2189,7 +2294,7 @@ mod tests { #[test] fn memory_fields_none_when_not_declared() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str(src).unwrap(); assert!(units[0].memory_read_query.is_none()); assert!(units[0].memory_read_limit.is_none()); @@ -2202,14 +2307,14 @@ mod tests { let (tokens, _) = lexer::lex(src); let (ast, errs) = parser::parse(&tokens, src, "test.gaviero"); assert!(errs.is_empty(), "parse errors: {:?}", errs); - compile_ast(&ast.unwrap(), src, "test.gaviero", None, None) + compile_ast(&with_test_tier(ast.unwrap()), src, "test.gaviero", None, None) } #[test] fn loop_config_extracted_verify() { let src = r#" - agent a { description "impl" } - agent b { description "test" } + agent a { tier t description "impl" } + agent b { tier t description "test" } workflow w { steps [ loop { @@ -2233,7 +2338,7 @@ mod tests { #[test] fn loop_config_extracted_command() { let src = r#" - agent fixer { description "fix" } + agent fixer { tier t description "fix" } workflow w { steps [ loop { @@ -2254,8 +2359,8 @@ mod tests { #[test] fn loop_config_extracted_agent() { let src = r#" - agent impl_agent { description "implement" } - agent judge { description "evaluate quality" } + agent impl_agent { tier t description "implement" } + agent judge { tier t description "evaluate quality" } workflow w { steps [ loop { @@ -2278,7 +2383,7 @@ mod tests { #[test] fn undefined_loop_judge_is_compile_error() { let src = r#" - agent impl_agent { description "implement" } + agent impl_agent { tier t description "implement" } workflow w { steps [ loop { @@ -2303,8 +2408,8 @@ mod tests { fn loop_stability_judge_timeout_strict_judge_defaults_and_overrides() { // Defaults when no judge-control fields are present. let src = r#" - agent impl_agent { description "implement" } - agent judge { description "judge" } + agent impl_agent { tier t description "implement" } + agent judge { tier t description "judge" } workflow w { steps [ loop { @@ -2323,8 +2428,8 @@ mod tests { // Explicit overrides. let src = r#" - agent impl_agent { description "implement" } - agent judge { description "judge" } + agent impl_agent { tier t description "implement" } + agent judge { tier t description "judge" } workflow w { steps [ loop { @@ -2350,25 +2455,28 @@ mod tests { let src = concat!( "prompt p #\"init {{REVIEWER_ID}}\"#\n", "prompt r #\"refine {{REVIEWER_ID}}\"#\n", - "client c { model \"claude:sonnet\" }\n", - "agent tinit { template true prompt p scope { owned [\"out/x-*\"] } }\n", - "agent tref { template true prompt r scope { owned [\"out/y-*\"] } }\n", - "agent judge { client c prompt \"judge\" }\n", + "client c { model \"claude:sonnet\" } tier c c\n", + "agent tinit { tier t template true prompt p scope { owned [\"out/x-*\"] } }\n", + "agent tref { tier t template true prompt r scope { owned [\"out/y-*\"] } }\n", + "agent judge { tier c prompt \"judge\" }\n", "workflow w { steps [ loop {\n", - " reviewers [ { id \"a\" model \"claude:sonnet\" } { id \"b\" model \"claude:sonnet\" } ]\n", + " reviewers [ { id \"a\" tier c } { id \"b\" } ]\n", " template_init tinit template_refine tref max_iterations 3 until agent judge\n", "} ] }\n", ); let plan = compile_plan(src).unwrap(); - let ids: Vec<_> = plan - .work_units_unordered() - .into_iter() - .map(|u| u.id.as_str()) - .collect(); + let units = plan.work_units_unordered(); + let ids: Vec<_> = units.iter().map(|u| u.id.as_str()).collect(); assert!(ids.contains(&"a-init")); assert!(ids.contains(&"b-init")); assert!(ids.contains(&"a-refine")); assert!(ids.contains(&"b-refine")); + // An entry's `tier` moves both of its clones; without one they keep + // the template's tier. + let model = |id: &str| units.iter().find(|u| u.id == id).unwrap().model.clone(); + assert_eq!(model("a-init").as_deref(), Some("claude:sonnet")); + assert_eq!(model("a-refine").as_deref(), Some("claude:sonnet")); + assert_eq!(model("b-refine"), None, "tier t has no model"); assert_eq!( plan.loop_configs[0].agent_ids, ["a-refine".to_string(), "b-refine".to_string()] @@ -2381,7 +2489,7 @@ mod tests { // Using an agent's name as `until agent ` is ambiguous at runtime // (shadowing the workflow unit_map). The compiler must reject it. let src = r#" - agent impl_agent { description "implement" } + agent impl_agent { tier t description "implement" } workflow w { steps [ loop { @@ -2405,7 +2513,7 @@ mod tests { #[test] fn no_loop_configs_when_no_loops() { let src = r#" - agent a { description "t" } + agent a { tier t description "t" } workflow w { steps [a] } "#; let plan = compile_plan(src).unwrap(); @@ -2415,9 +2523,9 @@ mod tests { #[test] fn loop_agents_included_in_work_units() { let src = r#" - agent pre { description "pre-step" } - agent looped { description "in loop" } - agent post { description "post-step" } + agent pre { tier t description "pre-step" } + agent looped { tier t description "in loop" } + agent post { tier t description "post-step" } workflow w { steps [ pre @@ -2441,10 +2549,10 @@ mod tests { #[test] fn loop_agents_depend_on_preceding_steps() { let src = r#" - agent init-a { description "first init" } - agent init-b { description "second init" } - agent refine { description "refine" } - agent judge { description "judge" } + agent init-a { tier t description "first init" } + agent init-b { tier t description "second init" } + agent refine { tier t description "refine" } + agent judge { tier t description "judge" } workflow w { steps [ init-a @@ -2475,7 +2583,7 @@ mod tests { #[test] fn impact_scope_compiled() { let src = r#" - agent x { + agent x { tier t scope { owned ["src/"] impact_scope true @@ -2488,7 +2596,7 @@ mod tests { #[test] fn impact_scope_false_by_default() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str(src).unwrap(); assert!(!units[0].impact_scope); } @@ -2496,7 +2604,7 @@ mod tests { #[test] fn context_block_compiled() { let src = r#" - agent x { + agent x { tier t context { callers_of ["src/auth.rs"] tests_for ["src/auth/"] @@ -2512,7 +2620,7 @@ mod tests { #[test] fn context_defaults_when_not_declared() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str(src).unwrap(); assert!(units[0].context_callers_of.is_empty()); assert!(units[0].context_tests_for.is_empty()); @@ -2522,7 +2630,7 @@ mod tests { #[test] fn tools_field_propagates_to_work_unit() { let src = r#" - agent x { + agent x { tier t description "runs cargo" tools ["Bash" "WebFetch"] } @@ -2533,7 +2641,7 @@ mod tests { #[test] fn tools_defaults_to_empty_when_absent() { - let src = r#"agent x { description "t" }"#; + let src = r#"agent x { tier t description "t" }"#; let units = compile_str(src).unwrap(); assert!(units[0].extra_allowed_tools.is_empty()); } @@ -2541,7 +2649,7 @@ mod tests { #[test] fn impact_tests_in_verify() { let src = r#" - agent a { description "t" } + agent a { tier t description "t" } workflow w { steps [a] verify { compile true impact_tests true } @@ -2556,7 +2664,7 @@ mod tests { #[test] fn impact_tests_in_loop_until() { let src = r#" - agent a { description "impl" } + agent a { tier t description "impl" } workflow w { steps [ loop { @@ -2583,9 +2691,9 @@ mod tests { fn loop_script(until_body: &str) -> String { format!( r#" - agent a {{ description "impl" }} - agent judge {{ description "evaluate" }} - agent judge2 {{ description "also evaluate" }} + agent a {{ tier t description "impl" }} + agent judge {{ tier t description "evaluate" }} + agent judge2 {{ tier t description "also evaluate" }} workflow w {{ steps [ loop {{ @@ -2653,8 +2761,8 @@ mod tests { fn until_and_substitutes_vars_in_every_command() { let src = r#" vars { OUT_DIR "reports" } - agent a { description "impl" } - agent judge { description "evaluate" } + agent a { tier t description "impl" } + agent judge { tier t description "evaluate" } workflow w { steps [ loop { @@ -2700,7 +2808,7 @@ mod tests { fn named_prompt_resolves() { let src = r#" prompt my-prompt "do the thing" - agent x { prompt my-prompt } + agent x { tier t prompt my-prompt } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].coordinator_instructions, "do the thing"); @@ -2710,13 +2818,13 @@ mod tests { fn named_prompt_with_runtime_prompt_substitution() { let src = r#" prompt body "task: {{PROMPT}}" - agent x { prompt body } + agent x { tier t prompt body } "#; let (tokens, _) = lexer::lex(src); let (ast, errs) = parser::parse(&tokens, src, "test.gaviero"); assert!(errs.is_empty(), "parse errors: {:?}", errs); let units = compile_ast( - &ast.unwrap(), + &with_test_tier(ast.unwrap()), src, "test.gaviero", None, @@ -2731,8 +2839,8 @@ mod tests { fn named_prompt_agent_substitution() { let src = r#" prompt body "write to {{AGENT}}-output.md" - agent alpha { prompt body } - agent beta { prompt body } + agent alpha { tier t prompt body } + agent beta { tier t prompt body } "#; let units = compile_str(src).expect("should compile"); let alpha = units.iter().find(|u| u.id == "alpha").unwrap(); @@ -2743,7 +2851,7 @@ mod tests { #[test] fn named_prompt_undefined_ref_errors() { - let src = r#"agent x { prompt missing-prompt }"#; + let src = r#"agent x { tier t prompt missing-prompt }"#; let result = compile_str(src); assert!(result.is_err()); let msg = format!("{}", result.unwrap_err().errors[0]); @@ -2755,7 +2863,7 @@ mod tests { let src = r#" prompt foo "first" prompt foo "second" - agent x { prompt foo } + agent x { tier t prompt foo } "#; let result = compile_str(src); assert!(result.is_err()); @@ -2765,14 +2873,14 @@ mod tests { #[test] fn inline_prompt_still_works() { - let src = r#"agent x { prompt "inline text" }"#; + let src = r#"agent x { tier t prompt "inline text" }"#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].coordinator_instructions, "inline text"); } #[test] fn inline_prompt_agent_substitution() { - let src = r#"agent my-agent { prompt "hello {{AGENT}}" }"#; + let src = r#"agent my-agent { tier t prompt "hello {{AGENT}}" }"#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].coordinator_instructions, "hello my-agent"); } @@ -2783,7 +2891,7 @@ mod tests { fn script_vars_substituted_in_prompt() { let src = r#" vars { PLANS "plans" } - agent x { prompt "write to {{PLANS}}/out.md" } + agent x { tier t prompt "write to {{PLANS}}/out.md" } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].coordinator_instructions, "write to plans/out.md"); @@ -2792,7 +2900,7 @@ mod tests { #[test] fn agent_vars_substituted_in_prompt() { let src = r#" - agent x { + agent x { tier t vars { MODEL "claude" } prompt "write to {{MODEL}}-output.md" } @@ -2808,7 +2916,7 @@ mod tests { fn agent_vars_override_script_vars() { let src = r#" vars { MODEL "default" } - agent x { + agent x { tier t vars { MODEL "claude" } prompt "model: {{MODEL}}" } @@ -2821,8 +2929,8 @@ mod tests { fn script_vars_used_when_no_agent_vars() { let src = r#" vars { PLANS "plans" } - agent x { prompt "path: {{PLANS}}/file.md" } - agent y { prompt "also: {{PLANS}}/other.md" } + agent x { tier t prompt "path: {{PLANS}}/file.md" } + agent y { tier t prompt "also: {{PLANS}}/other.md" } "#; let units = compile_str(src).expect("should compile"); assert_eq!(units[0].coordinator_instructions, "path: plans/file.md"); @@ -2836,7 +2944,7 @@ mod tests { // touching the file. let src = r#" vars { OUT_DIR "plans/log" } - agent x { + agent x { tier t scope { owned ["{{OUT_DIR}}/out.md" "src/{{AGENT}}/"] read_only ["{{OUT_DIR}}/" "src/"] @@ -2862,7 +2970,7 @@ mod tests { // {{ITER}} and {{PREV_ITER}} must NOT be substituted at compile time — // they are reserved for the runtime loop executor. let src = r##" - agent x { prompt #"read v{{PREV_ITER}} write v{{ITER}}"# } + agent x { tier t prompt #"read v{{PREV_ITER}} write v{{ITER}}"# } "##; let units = compile_str(src).expect("should compile"); assert_eq!( @@ -2874,7 +2982,7 @@ mod tests { #[test] fn iter_start_parsed_and_propagated() { let src = r#" - agent a { description "refine" } + agent a { tier t description "refine" } workflow w { steps [ loop { @@ -2895,7 +3003,7 @@ mod tests { #[test] fn iter_start_defaults_to_1() { let src = r#" - agent a { description "t" } + agent a { tier t description "t" } workflow w { steps [ loop { @@ -2915,7 +3023,7 @@ mod tests { // All three types of substitution should work together. let src = r#" vars { DIR "plans" } - agent claude { + agent claude { tier t vars { MODEL "claude" } prompt "Read {{DIR}}/codex-plan-v1.md write {{DIR}}/{{MODEL}}-plan-v2.md by {{AGENT}}" } @@ -2931,18 +3039,18 @@ mod tests { fn template_plan_refinement_example() { // Smoke-test the full plan_refinement.gaviero example structure let src = r##" - client opus { tier expensive model "claude-opus-4-7" privacy public } - client codex { tier expensive model "codex:gpt-5.4" privacy public } + client opus { tier expensive model "claude-opus-4-7" privacy public } tier opus opus + client codex { tier expensive model "codex:gpt-5.4" privacy public } tier codex codex vars { PLANS "plans" } prompt init-body #"Write to {{PLANS}}/{{MODEL_NAME}}-plan-v1.md"# prompt refine-body #"Read {{PLANS}}/claude-plan-v{{PREV_ITER}}.md write {{PLANS}}/{{MODEL_NAME}}-plan-v{{ITER}}.md"# - agent claude-init { vars { MODEL_NAME "claude" } client opus prompt init-body } - agent codex-init { vars { MODEL_NAME "codex" } client codex prompt init-body } - agent claude-refine { vars { MODEL_NAME "claude" } client opus prompt refine-body } - agent codex-refine { vars { MODEL_NAME "codex" } client codex prompt refine-body } + agent claude-init { vars { MODEL_NAME "claude" } tier opus prompt init-body } + agent codex-init { vars { MODEL_NAME "codex" } tier codex prompt init-body } + agent claude-refine { vars { MODEL_NAME "claude" } tier opus prompt refine-body } + agent codex-refine { vars { MODEL_NAME "codex" } tier codex prompt refine-body } workflow feature-plan-refinement { steps [ @@ -3004,12 +3112,13 @@ mod tests { #[test] fn map_reduce_pattern_emits_fanout_ops() { let src = r#" - agent discover { description "write spawn_manifest.json" } - agent reduce { + agent discover { tier t description "write spawn_manifest.json" } + agent reduce { tier t description "aggregate" depends_on [discover] } workflow map-reduce { + execution_mode document pattern map_reduce { discover discover reduce reduce @@ -3027,9 +3136,10 @@ mod tests { #[test] fn map_reduce_pattern_defaults_max_spawn() { let src = r#" - agent discover { description "d" } - agent reduce { description "r" depends_on [discover] } + agent discover { tier t description "d" } + agent reduce { tier t description "r" depends_on [discover] } workflow w { + execution_mode document pattern map_reduce { discover discover reduce reduce diff --git a/crates/gaviero-dsl/src/for_loops.rs b/crates/gaviero-dsl/src/for_loops.rs index 94b10e06..2876e4b4 100644 --- a/crates/gaviero-dsl/src/for_loops.rs +++ b/crates/gaviero-dsl/src/for_loops.rs @@ -20,7 +20,7 @@ use std::collections::{HashMap, HashSet}; use crate::ast::*; use crate::error::DslError; -use crate::workflow_params::{resolve_roster, roster_entry_tier, synth_client_from_entry}; +use crate::workflow_params::resolve_roster; /// Free-field names that would shadow a derived item var. const RESERVED_FIELDS: &[&str] = &["index", "count", "peers", "peer_count", "prev", "peer_block"]; @@ -83,7 +83,6 @@ pub(crate) fn expand_for_blocks( }) .collect(); - let mut new_clients: Vec = Vec::new(); let mut new_agents: Vec = Vec::new(); // body agent name → every clone of it (for fan-in rewriting). let mut clones_of: HashMap> = HashMap::new(); @@ -110,10 +109,14 @@ pub(crate) fn expand_for_blocks( // ── collect the blocks ──────────────────────────────────────── let mut blocks: Vec<(ForBlock, Placement)> = Vec::new(); let mut plain_steps: HashSet = HashSet::new(); + let mut stacked_loops: HashSet = HashSet::new(); for (i, step) in steps.iter().enumerate() { match step { StepItem::For(fb) => blocks.push((fb.clone(), Placement::Step(i))), StepItem::Loop(lb) => { + if lb.branch_chain == BranchChainLit::Stacked { + stacked_loops.insert(i); + } for fb in &lb.fors { blocks.push((fb.clone(), Placement::InLoop(i))); } @@ -130,10 +133,26 @@ pub(crate) fn expand_for_blocks( // ── validate blocks and resolve their lists ─────────────────── let mut resolved: Vec = Vec::new(); + // `for … in json` blocks: validated here, lowered (not cloned) below. + let mut runtime: Vec<(ForBlock, Placement)> = Vec::new(); let mut body_owner: HashMap = HashMap::new(); for (idx, (fb, placement)) in blocks.into_iter().enumerate() { let mut ok = true; - if fb.mode == ForMode::Sequential { + if fb.json_source.is_some() { + let in_stacked_loop = + matches!(placement, Placement::InLoop(i) if stacked_loops.contains(&i)); + ok &= validate_json_for( + &fb, + in_stacked_loop, + execution_document, + &agent_by_name, + errors, + ); + } else if let Some((_, span)) = fb.max_items { + errors.push(compile_err(span, "`max` applies only to `for … in json`".into())); + ok = false; + } + if fb.json_source.is_none() && fb.mode == ForMode::Sequential { if matches!(placement, Placement::InLoop(_)) { errors.push(compile_err( fb.mode_span, @@ -198,6 +217,13 @@ pub(crate) fn expand_for_blocks( } } + if fb.json_source.is_some() { + if ok { + runtime.push((fb, placement)); + } + continue; + } + // Resolve the list param. let items = match params_by_name.get(&fb.list) { None => { @@ -263,20 +289,8 @@ pub(crate) fn expand_for_blocks( clone.name = clone_name.clone(); clone.template = false; clone.item_vars = item_vars.clone(); - if entry.model.is_some() { - match roster_entry_tier(entry) { - Err(reason) => errors.push(compile_err(entry.span, reason)), - Ok(Some(tier)) => { - clone.client = None; - clone.tier_ref = Some((tier.to_string(), template.name_span)); - } - Ok(None) => { - let client_name = format!("__for_{}_{}", entry.id, agent); - new_clients.push(synth_client_from_entry(&client_name, entry)); - clone.client = Some((client_name, entry.span)); - clone.tier_ref = None; - } - } + if let Some(tier) = &entry.tier { + clone.tier_ref = Some(tier.clone()); } // depends_on: same-item siblings, then the sequential chain. let mut deps: Vec<(String, Span)> = Vec::new(); @@ -321,6 +335,27 @@ pub(crate) fn expand_for_blocks( let (Placement::Step(i) | Placement::InLoop(i)) = rf.placement; by_step.entry(i).or_default().push(bi); } + // A runtime `for` becomes its body agent: a plain step at top level, + // a loop agent inside a loop. The runtime clones it per JSON item. + let mut runtime_by_step: HashMap> = HashMap::new(); + for (fb, placement) in &runtime { + let (Placement::Step(i) | Placement::InLoop(i)) = *placement; + runtime_by_step.entry(i).or_default().push(fb); + } + let runtime_decls: Vec = runtime + .iter() + .map(|(fb, _)| RuntimeForDecl { + var: fb.var.clone(), + agent: fb.agents[0].0.clone(), + source: fb + .json_source + .as_ref() + .map(|(p, _)| p.clone()) + .unwrap_or_default(), + max_items: fb.max_items.map(|(n, _)| n), + span: fb.span, + }) + .collect(); let old_steps = std::mem::take(steps); let mut new_steps: Vec = Vec::new(); // The baseline of a loop is the top-level `for` step *immediately* @@ -330,6 +365,12 @@ pub(crate) fn expand_for_blocks( let mut previous_for: Option<(String, Vec)> = None; for (i, step) in old_steps.into_iter().enumerate() { match step { + StepItem::For(_) if runtime_by_step.contains_key(&i) => { + for fb in &runtime_by_step[&i] { + new_steps.push(StepItem::Agent(fb.agents[0].0.clone(), fb.span)); + } + previous_for = None; + } StepItem::For(_) => { for &bi in by_step.get(&i).map(Vec::as_slice).unwrap_or(&[]) { let rf = &resolved[bi]; @@ -340,6 +381,9 @@ pub(crate) fn expand_for_blocks( } } StepItem::Loop(mut lb) => { + for fb in runtime_by_step.get(&i).map(Vec::as_slice).unwrap_or(&[]) { + lb.agents.push((fb.agents[0].0.clone(), fb.span)); + } for &bi in by_step.get(&i).map(Vec::as_slice).unwrap_or(&[]) { let rf = &resolved[bi]; for name in &block_clones[bi] { @@ -366,6 +410,7 @@ pub(crate) fn expand_for_blocks( } } *steps = new_steps; + wf.runtime_fors = runtime_decls; } if !errors.is_empty() || clones_of.is_empty() { @@ -406,14 +451,74 @@ pub(crate) fn expand_for_blocks( } } - for client in new_clients { - script.items.push(Item::Client(client)); - } for agent in new_agents { script.items.push(Item::Agent(agent)); } } +/// Rules specific to `for in json "" parallel [max ] { }`. +/// The agent checks shared with list `for` blocks (defined, not a plain step, +/// one block only, `{{.id}}` in every owned / produces path) run in the +/// caller. Returns `false` on any error. +fn validate_json_for( + fb: &ForBlock, + in_stacked_loop: bool, + execution_document: bool, + agent_by_name: &HashMap, + errors: &mut Vec, +) -> bool { + let before = errors.len(); + let json_span = fb + .json_source + .as_ref() + .map(|(_, s)| *s) + .unwrap_or(fb.list_span); + if fb.mode == ForMode::Sequential { + errors.push(compile_err( + fb.mode_span, + "`for … in json` supports only `parallel`".into(), + )); + } + if let Some((_, span)) = &fb.peer_template { + errors.push(compile_err( + *span, + "`peer_template` is not available with `for … in json`".into(), + )); + } + if fb.agents.len() != 1 { + errors.push(compile_err( + fb.span, + "`for … in json` takes exactly one body agent".into(), + )); + } + if let Some((0, span)) = fb.max_items { + errors.push(compile_err(span, "`max` must be at least 1".into())); + } + if !execution_document { + errors.push(compile_err( + json_span, + "`for … in json` requires `execution_mode document`".into(), + )); + } + if in_stacked_loop { + errors.push(compile_err( + fb.span, + "`for … in json` cannot run inside a `branch_chain stacked` loop".into(), + )); + } + for (agent, span) in &fb.agents { + if let Some(decl) = agent_by_name.get(agent) + && decl.produces.is_empty() + { + errors.push(compile_err( + *span, + "the body of `for … in json` must declare `produces`".into(), + )); + } + } + errors.len() == before +} + /// Check ids and fields of a resolved list. Returns `false` on any error. fn validate_items(fb: &ForBlock, items: &[ReviewerEntry], errors: &mut Vec) -> bool { let before = errors.len(); @@ -455,7 +560,7 @@ fn validate_items(fb: &ForBlock, items: &[ReviewerEntry], errors: &mut Vec Vec<(Strin for (name, value, _) in &entry.fields { vars.push((key(name), value.clone())); } - if let Some(model) = &entry.model { - vars.push((key("model"), model.clone())); - } - if let Some((effort, _)) = &entry.effort { - vars.push((key("effort"), effort.clone())); + if let Some((tier, _)) = &entry.tier { + vars.push((key("tier"), tier.clone())); } vars.push((key("index"), (k + 1).to_string())); vars.push((key("count"), items.len().to_string())); diff --git a/crates/gaviero-dsl/src/inspect.rs b/crates/gaviero-dsl/src/inspect.rs index ac781058..a3f19693 100644 --- a/crates/gaviero-dsl/src/inspect.rs +++ b/crates/gaviero-dsl/src/inspect.rs @@ -39,7 +39,8 @@ pub struct ScriptInspection { pub accepts_prompt: bool, /// Execution mode when the script declares no workflow. pub default_execution: ExecutionMode, - /// Tiers the script binds itself, in declaration order. + /// Tiers the script asks for (agents, `tiers { }` blocks, list items), + /// in order of appearance. The profile must define each of them. pub tiers: Vec, } @@ -95,10 +96,8 @@ pub struct VarInspection { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ParamKindInfo { - /// `id=provider:model[@effort],…` + /// A list: `id=tier,…`, bare ids `a,b`, or a list literal `[{id "a" …}]`. Roster, - /// `provider:model[@effort]` - Client, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -127,6 +126,40 @@ fn tier_names(script: &Script) -> Vec { names } +/// The tiers a script asks for, in order of appearance: every agent's +/// `tier`, every workflow `tiers { }` entry and every list item's `tier`. +fn used_tier_names(script: &Script) -> Vec { + let mut names: Vec = Vec::new(); + let mut add = |name: &str| { + if !names.iter().any(|n| n == name) { + names.push(name.to_string()); + } + }; + for item in &script.items { + match item { + Item::Agent(agent) => { + if let Some((tier, _)) = &agent.tier_ref { + add(tier); + } + } + Item::Workflow(wf) => { + for entry in &wf.tiers { + add(&entry.tier); + } + for param in &wf.params { + if let Some(crate::ast::ParamShape::Roster(entries)) = ¶m.shape { + for (tier, _) in entries.iter().filter_map(|e| e.tier.as_ref()) { + add(tier); + } + } + } + } + _ => {} + } + } + names +} + /// Inspect a script on disk, resolving its includes. pub fn inspect_file(entry_path: &Path) -> Result { let (script, sources) = resolver::resolve(entry_path).map_err(miette::Report::new)?; @@ -196,7 +229,7 @@ fn inspect_script(script: &Script, sources: &[(String, String)]) -> ScriptInspec requires_prompt, accepts_prompt: requires_prompt || agent_without_prompt, default_execution: peek_workflow_execution_mode(script, None), - tiers: tier_names(script), + tiers: used_tier_names(script), } } @@ -242,7 +275,7 @@ mod tests { fn declared_vars_keep_their_defaults_and_unknown_placeholders_are_listed() { let info = inspect(concat!( "vars { OUT_DIR \"plans/out\" }\n", - "agent a {\n", + "agent a { tier t\n", " scope { owned [\"{{OUT_DIR}}/{{TARGET}}.md\"] }\n", " prompt #\"work on {{TARGET}}\"#\n", "}\n", @@ -270,7 +303,7 @@ mod tests { fn reserved_commented_and_agent_level_placeholders_are_not_inputs() { let info = inspect(concat!( "// mentions {{IN_A_COMMENT}}\n", - "agent a {\n", + "agent a { tier t\n", " vars { LOCAL \"x\" }\n", " prompt #\"{{PROMPT}} {{ITER}} {{AGENT}} {{LOCAL}}\"#\n", "}\n", @@ -289,7 +322,7 @@ mod tests { " NEEDED file\n", " AFTER \"y\"\n", "}\n", - "agent a { prompt #\"{{INPUT}} {{NEEDED}}\"# }\n", + "agent a { tier t prompt #\"{{INPUT}} {{NEEDED}}\"# }\n", )); let names: Vec<&str> = info.vars.iter().map(|v| v.name.as_str()).collect(); assert_eq!(names, ["PLAIN", "INPUT", "NEEDED", "AFTER"]); @@ -311,18 +344,30 @@ mod tests { const NEEDS_FILE: &str = concat!( "vars { NEEDED file\n PLAIN \"p\" }\n", - "client c { model \"claude:opus\" privacy public }\n", - "agent a { client c scope { owned [\"o.md\"] } prompt #\"read {{NEEDED}} {{PLAIN}}\"# }\n", + "agent a { tier t scope { owned [\"o.md\"] } prompt #\"read {{NEEDED}} {{PLAIN}}\"# }\n", "workflow w { steps [a] }\n", ); + /// `crate::compile_with_vars` against `tests/fixtures/test-profile.gaviero`. + fn compile_with_vars( + src: &str, + vars: &[(String, String)], + ) -> Result { + let profile = gaviero_core::script_profiles::SelectedProfile { + name: "test".into(), + path: Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/test-profile.gaviero"), + precedence: gaviero_core::script_profiles::ProfilePrecedence::OverridesScript, + }; + crate::compile_with_vars(src, "t", Some(&profile), None, None, vars, &[], &[]) + } + #[test] fn a_file_var_without_a_default_must_be_supplied() { - let err = crate::compile_with_vars(NEEDS_FILE, "t", None, None, &[], &[], &[]).unwrap_err(); + let err = compile_with_vars(NEEDS_FILE, &[]).unwrap_err(); assert!(format!("{err:?}").contains("file var `NEEDED`"), "{err:?}"); let vars = vec![("NEEDED".to_string(), "docs/a.md".to_string())]; - let plan = crate::compile_with_vars(NEEDS_FILE, "t", None, None, &vars, &[], &[]).unwrap(); + let plan = compile_with_vars(NEEDS_FILE, &vars).unwrap(); let shown = format!("{plan:?}"); assert!(shown.contains("read docs/a.md p"), "{shown}"); } @@ -331,7 +376,7 @@ mod tests { fn dir_vars_are_listed_apart_from_files_and_can_be_required() { let info = inspect(concat!( "vars {\n SRC dir \"src\"\n DATA dir\n IN file \"a.md\"\n}\n", - "agent a { prompt #\"{{SRC}} {{DATA}} {{IN}}\"# }\n", + "agent a { tier t prompt #\"{{SRC}} {{DATA}} {{IN}}\"# }\n", )); assert_eq!(info.dir_var_names(), ["SRC", "DATA"]); assert_eq!(info.file_var_names(), ["IN"]); @@ -342,28 +387,25 @@ mod tests { ); let src = NEEDS_FILE.replace("NEEDED file\n", "NEEDED dir\n"); - let err = crate::compile_with_vars(&src, "t", None, None, &[], &[], &[]).unwrap_err(); + let err = compile_with_vars(&src, &[]).unwrap_err(); assert!(format!("{err:?}").contains("dir var `NEEDED`"), "{err:?}"); } #[test] fn untyped_vars_compile_exactly_as_before() { let src = NEEDS_FILE.replace("NEEDED file\n", "NEEDED \"x.md\"\n"); - let plan = crate::compile_with_vars(&src, "t", None, None, &[], &[], &[]).unwrap(); + let plan = compile_with_vars(&src, &[]).unwrap(); assert!(format!("{plan:?}").contains("read x.md p")); } #[test] fn agent_level_vars_take_no_type() { - let src = concat!( - "client c { model \"claude:opus\" privacy public }\n", - "agent a { client c vars { X file \"y\" } prompt #\"{{X}}\"# }\n", - ); - assert!(crate::compile_with_vars(src, "t", None, None, &[], &[], &[]).is_err()); + let src = "agent a { tier t vars { X file \"y\" } prompt #\"{{X}}\"# }\n"; + assert!(compile_with_vars(src, &[]).is_err()); } #[test] - fn script_and_profile_tiers_are_listed_in_order() { + fn used_and_profile_tiers_are_listed_in_order() { let dir = tempfile::tempdir().unwrap(); let profile = dir.path().join("p.gaviero"); std::fs::write( @@ -373,17 +415,23 @@ mod tests { .unwrap(); assert_eq!(profile_tier_names(&profile).unwrap(), ["top", "low"]); + // A script lists the tiers it asks for: agents, then the workflow's + // `tiers { }` block and list items, deduplicated. let info = inspect(concat!( - "client c { model \"claude:opus\" privacy public }\n", - "tier mine c\n", "agent a { tier mine prompt #\"x\"# }\n", + "agent b { tier low prompt #\"x\"# }\n", + "workflow w {\n", + " tiers { a top }\n", + " param l [ { id \"x\" tier mine } { id \"y\" tier high } ]\n", + " steps [ a b ]\n", + "}\n", )); - assert_eq!(info.tiers, ["mine"]); + assert_eq!(info.tiers, ["mine", "low", "top", "high"]); } #[test] fn agent_without_a_prompt_accepts_one_without_requiring_it() { - let info = inspect("agent a { description \"do it\" }\n"); + let info = inspect("agent a { tier t description \"do it\" }\n"); assert!(info.accepts_prompt); assert!(!info.requires_prompt); } @@ -391,31 +439,19 @@ mod tests { #[test] fn params_report_kind_and_default_in_override_syntax() { let info = inspect(concat!( - "agent worker { prompt #\"w\"# }\n", - "agent judge { client gate prompt #\"j\"# }\n", + "agent worker { tier t prompt #\"w\"# }\n", + "agent judge { tier t prompt #\"j\"# }\n", "workflow w {\n", - " param gate { model \"claude:sonnet\" effort high }\n", - " param panel [ { id \"a\" model \"claude:opus\" } { id \"b\" model \"codex:x\" effort low } ]\n", + " param panel [ { id \"a\" tier high } { id \"b\" } ]\n", " param bare\n", - " steps [ loop { agents [worker] reviewers bare until agent judge } judge ]\n", + " steps [ loop { agents [worker] reviewers bare until agent judge } for x in panel parallel { judge } ]\n", "}\n", )); let params = &info.workflows[0].params; + assert_eq!(params[0].default.as_deref(), Some("a=high,b")); + assert_eq!(params[0].kind, ParamKindInfo::Roster); assert_eq!( - params[0], - ParamInspection { - name: "gate".into(), - kind: ParamKindInfo::Client, - default: Some("claude:sonnet@high".into()), - } - ); - assert_eq!( - params[1].default.as_deref(), - Some("a=claude:opus,b=codex:x@low") - ); - assert_eq!(params[1].kind, ParamKindInfo::Roster); - assert_eq!( - params[2], + params[1], ParamInspection { name: "bare".into(), kind: ParamKindInfo::Roster, @@ -433,7 +469,7 @@ mod tests { let default = topics.default.as_deref().unwrap(); assert_eq!( default, - r#"[{id "a" focus "storage"} {id "b" focus "network"} {id "c" focus "ui"}]"# + r#"[{id "a" focus "storage"} {id "b" focus "network"} {id "c" tier high focus "ui"}]"# ); let entries = crate::workflow_params::parse_reviewers_override(default).unwrap(); assert_eq!(entries.len(), 3); @@ -441,17 +477,17 @@ mod tests { let mut odd = entries[0].clone(); odd.fields[0].1 = "say \"hi\"".into(); - odd.model = Some("claude:opus".into()); + odd.tier = Some(("high-codex".into(), (0..0).into())); let literal = crate::workflow_params::list_literal_entry(&odd); let back = crate::workflow_params::parse_reviewers_override(&format!("[{literal}]")).unwrap(); assert_eq!(back[0].fields[0].1, "say \"hi\""); - assert_eq!(back[0].model.as_deref(), Some("claude:opus")); + assert_eq!(back[0].tier.as_ref().map(|(t, _)| t.as_str()), Some("high-codex")); } #[test] fn each_workflow_reports_its_execution_mode() { let info = inspect(concat!( - "agent a { prompt #\"x\"# }\n", + "agent a { tier t prompt #\"x\"# }\n", "workflow one { steps [a] }\n", "workflow two { execution_mode document steps [a] }\n", )); @@ -478,7 +514,7 @@ mod tests { let dir = tempfile::tempdir().unwrap(); std::fs::write( dir.path().join("lib.gaviero"), - "agent b { prompt #\"{{SHARED}}\"# }\n", + "agent b { tier t prompt #\"{{SHARED}}\"# }\n", ) .unwrap(); let path = dir.path().join("script.gaviero"); diff --git a/crates/gaviero-dsl/src/lib.rs b/crates/gaviero-dsl/src/lib.rs index 0341c5b9..01dac063 100644 --- a/crates/gaviero-dsl/src/lib.rs +++ b/crates/gaviero-dsl/src/lib.rs @@ -9,7 +9,6 @@ pub mod patterns; pub mod profile; pub mod resolver; pub mod reviewers; -pub mod tiers; pub mod workflow_params; // Re-export `CompiledPlan` as the primary output type. @@ -24,13 +23,16 @@ pub use inspect::{ ParamInspection, ParamKindInfo, ScriptInspection, VarInspection, WorkflowInspection, inspect_file, profile_tier_names, }; -pub use tiers::load_tier_overrides; -/// Compile a `.gaviero` DSL script into a [`CompiledPlan`]. +use gaviero_core::script_profiles::SelectedProfile; + +/// Compile an inline `.gaviero` script into a [`CompiledPlan`]. /// /// # Parameters /// - `source`: The raw script text. /// - `filename`: Used in error messages to identify the file. +/// - `profile`: The model profile that says which model each tier means. +/// Every agent declares a tier, so a script with agents needs one. /// - `workflow`: Optional workflow name to select from the script. /// - `None` and exactly one workflow declared → use it. /// - `None` and no workflow declared → run all agents in declaration order. @@ -46,30 +48,32 @@ pub use tiers::load_tier_overrides; pub fn compile( source: &str, filename: &str, + profile: Option<&SelectedProfile>, workflow: Option<&str>, runtime_prompt: Option<&str>, ) -> Result { - compile_with_vars(source, filename, workflow, runtime_prompt, &[], &[], &[]) + compile_with_vars(source, filename, profile, workflow, runtime_prompt, &[], &[], &[]) } /// Like [`compile`] but accepts variable / tier / param overrides. /// /// - `override_vars` — `--var KEY=VALUE` overrides. Beat script-level `vars {}`, /// lose to agent-level vars. -/// - `override_tiers` — `--tiers-file` bindings. Replace top-level `tier` -/// declarations. -/// - `override_params` — `--param NAME=VALUE` workflow-parameter overrides. -/// Roster params: `id=provider:model[@effort],...`. Client params: -/// `provider:model[@effort]`. Either model spec may instead be `tier:`. -/// Required params without an in-script default fail compilation when absent -/// here. +/// - `agent_tiers` — `--tier AGENT=TIER` overrides. Beat the selected +/// workflow's `tiers { }` block, which beats the tier the agent declares. +/// - `override_params` — `--param NAME=VALUE` list-param overrides: +/// `id=tier,...`, bare ids `a,b`, or a DSL list literal `[{id "a" …}]`. +/// Required params without an in-script default fail compilation when +/// absent here. +#[allow(clippy::too_many_arguments)] pub fn compile_with_vars( source: &str, filename: &str, + profile: Option<&SelectedProfile>, workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], override_params: &[(String, String)], ) -> Result { use miette::NamedSource; @@ -92,20 +96,23 @@ pub fn compile_with_vars( if !parse_errors.is_empty() { return Err(miette::Report::new(DslErrors::new(parse_errors))); } - let ast = match ast { - Some(a) => a, - None => return Err(miette::Report::msg("parsing produced no output")), + let Some(mut script) = ast else { + return Err(miette::Report::msg("parsing produced no output")); }; + let mut sources = vec![(filename.to_string(), source.to_string())]; + profile::reject_model_tables(&script, &sources).map_err(miette::Report::new)?; + if let Some(profile) = profile { + profile::apply_profile(&mut script, &mut sources, profile).map_err(miette::Report::new)?; + } // Phase 3: Compile - compiler::compile_ast_with_vars( - &ast, - source, - filename, + compiler::compile_ast_with_sources( + &script, + &sources, workflow, runtime_prompt, override_vars, - override_tiers, + agent_tiers, override_params, ) .map_err(miette::Report::new) @@ -113,7 +120,7 @@ pub fn compile_with_vars( /// Compile a `.gaviero` script from disk, resolving any `include "..."` /// statements transitively. This is the entry point you want for scripts -/// that share `client {}` / `prompt {}` / `vars {}` across files. +/// that share `prompt {}` / `agent {}` / `vars {}` across files. /// /// `entry_path` is the top-level script. `include` paths are resolved /// relative to the directory of the file containing the `include`. Cycles @@ -127,7 +134,7 @@ pub fn compile_file( workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], override_params: &[(String, String)], ) -> Result { compile_file_with_profile( @@ -136,7 +143,7 @@ pub fn compile_file( workflow, runtime_prompt, override_vars, - override_tiers, + agent_tiers, override_params, ) } @@ -144,18 +151,20 @@ pub fn compile_file( /// Like [`compile_file`], with the tiers bound by a model profile. Pick the /// profile with [`gaviero_core::script_profiles::ProfileCatalog::select`]. /// -/// Tier precedence: `override_tiers` > a chosen profile > the script's `tier` -/// lines > the implicit `default` profile. +/// A model is chosen in one way only: the profile says what each tier is, +/// and an agent's tier is `agent_tiers` (`--tier`) > the workflow's +/// `tiers { }` block > the agent's own `tier`. Scripts declare no clients. pub fn compile_file_with_profile( entry_path: &std::path::Path, - profile: Option<&gaviero_core::script_profiles::SelectedProfile>, + profile: Option<&SelectedProfile>, workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], override_params: &[(String, String)], ) -> Result { let (mut script, mut sources) = resolver::resolve(entry_path).map_err(miette::Report::new)?; + profile::reject_model_tables(&script, &sources).map_err(miette::Report::new)?; if let Some(profile) = profile { profile::apply_profile(&mut script, &mut sources, profile).map_err(miette::Report::new)?; } @@ -165,7 +174,7 @@ pub fn compile_file_with_profile( workflow, runtime_prompt, override_vars, - override_tiers, + agent_tiers, override_params, ) .map_err(miette::Report::new) diff --git a/crates/gaviero-dsl/src/parser.rs b/crates/gaviero-dsl/src/parser.rs index 9192129c..2187197e 100644 --- a/crates/gaviero-dsl/src/parser.rs +++ b/crates/gaviero-dsl/src/parser.rs @@ -21,11 +21,11 @@ enum ClientField { #[derive(Debug)] enum AgentField { Description(String, Span), - Client(String, Span), TierRef(String, Span), Scope(ScopeBlock), DependsOn(Vec<(String, Span)>, Span), - Produces(Vec), + /// `produces [...]` or `produces json [...]` (the bool). + Produces(Vec, bool), Prompt(PromptSource, Span), MaxRetries(u8, Span), Timeout(u64, Span), @@ -63,7 +63,15 @@ enum WorkflowField { EscalateAfter(u32, Span), Verify(VerifyBlock), Param(ParamDecl), + Tiers(Vec), Pattern(PatternDecl), + Budget(BudgetBlock), +} + +#[derive(Debug)] +enum BudgetField { + Wall(String, Span), + Usd(f64, Span), } #[derive(Debug)] @@ -96,7 +104,7 @@ enum LoopField { TemplateInit(String, Span), TemplateRefine(String, Span), ConsensusMode(ConsensusModeLit), - For(ForBlock), + For(Box), } #[derive(Debug, Clone)] @@ -108,8 +116,7 @@ enum ForItem { #[derive(Debug)] enum ReviewerField { Id(String, Span), - Model(String, Span), - Effort(String, Span), + Tier(String, Span), /// Free ` ""` field of a list-param entry. Free(String, String, Span), } @@ -127,7 +134,7 @@ enum MemoryField { // ── Parser builder ───────────────────────────────────────────────────────── -/// `[ { id "…" [model "…"] [effort …] [ ""]* } … ]` — the +/// `[ { id "…" [tier ] [ ""]* } … ]` — the /// list-param / roster literal. Shared by the script parser and /// [`parse_list_literal`] (the `--param NAME=[…]` CLI form). fn list_entries_parser<'src, I>() @@ -140,22 +147,23 @@ where Token::RawStr(s) => s, }; let kw_id = select! { Token::Ident(s) if s == "id" => () }; - // `effort` accepts the same shape as `client { effort }` — either - // an identifier (e.g. `high`) or a quoted string (e.g. `"max"`). - let effort_value = choice(( - select! { Token::Ident(s) => s }, - select! { Token::Str(s) => s }, - )); + // A tier name, as after an agent's `tier`. + let tier_name = select! { + Token::Ident(s) => s, + Token::TierCheap => "cheap".to_owned(), + Token::TierExpensive => "expensive".to_owned(), + Token::TierCoordinator => "coordinator".to_owned(), + Token::TierReasoning => "reasoning".to_owned(), + Token::TierExecution => "execution".to_owned(), + Token::TierMechanical => "mechanical".to_owned(), + }; let reviewer_field = choice(( kw_id .ignore_then(string.map_with(|v, e| (v, e.span()))) .map(|(v, s)| ReviewerField::Id(v, s)), - just(Token::KwModel) - .ignore_then(string.map_with(|v, e| (v, e.span()))) - .map(|(v, s)| ReviewerField::Model(v, s)), - just(Token::KwEffort) - .ignore_then(effort_value.map_with(|v, e| (v, e.span()))) - .map(|(v, s)| ReviewerField::Effort(v, s)), + just(Token::KwTier) + .ignore_then(tier_name.map_with(|v, e| (v, e.span()))) + .map(|(v, s)| ReviewerField::Tier(v, s)), // Free fields come last so `id` keeps its own meaning. Duplicates are // kept (in order) for the `for` expansion to report. select! { Token::Ident(s) => s } @@ -169,40 +177,29 @@ where .delimited_by(just(Token::LBrace), just(Token::RBrace)) .map_with(|fields, e| { let mut id: Option<(String, Span)> = None; - let mut model: Option<(String, Span)> = None; - let mut effort: Option<(String, Span)> = None; + let mut tier: Option<(String, Span)> = None; let mut free: Vec<(String, String, Span)> = Vec::new(); for f in fields { match f { - // A repeated `id` / `model` / `effort` keeps the first - // value and lands in `fields` under its own name, so the - // `for` expansion can report it as a duplicate field. + // A repeated `id` / `tier` keeps the first value and + // lands in `fields` under its own name, so the `for` + // expansion can report it as a duplicate field. ReviewerField::Id(v, s) => match id { None => id = Some((v, s)), Some(_) => free.push(("id".to_string(), v, s)), }, - ReviewerField::Model(v, s) => match model { - None => model = Some((v, s)), - Some(_) => free.push(("model".to_string(), v, s)), - }, - ReviewerField::Effort(v, s) => match effort { - None => effort = Some((v, s)), - Some(_) => free.push(("effort".to_string(), v, s)), + ReviewerField::Tier(v, s) => match tier { + None => tier = Some((v, s)), + Some(_) => free.push(("tier".to_string(), v, s)), }, ReviewerField::Free(k, v, s) => free.push((k, v, s)), } } let (id_value, id_span) = id.unwrap_or_else(|| (String::new(), e.span())); - let (model_value, model_span) = match model { - Some((v, s)) => (Some(v), s), - None => (None, e.span()), - }; ReviewerEntry { id: id_value, id_span, - model: model_value, - model_span, - effort, + tier, fields: free, span: e.span(), } @@ -711,11 +708,7 @@ where just(Token::KwDescription) .ignore_then(string.map_with(|s, e| (s, e.span()))) .map(|(v, s)| AgentField::Description(v, s)), - just(Token::KwClient) - .ignore_then(ident.map_with(|s, e| (s, e.span()))) - .map(|(v, s)| AgentField::Client(v, s)), - // `tier ` — references a top-level tier alias. Mutually - // exclusive with `client`; the compiler rejects agents that set both. + // `tier ` — the agent's default tier, bound by the profile. just(Token::KwTier) .ignore_then(tier_name.map_with(|s, e| (s, e.span()))) .map(|(v, s)| AgentField::TierRef(v, s)), @@ -724,8 +717,9 @@ where .ignore_then(ident_list.clone().map_with(|v, e| (v, e.span()))) .map(|(v, s)| AgentField::DependsOn(v, s)), just(Token::KwProduces) - .ignore_then(str_list.clone()) - .map(AgentField::Produces), + .ignore_then(select! { Token::Ident(s) if s == "json" => () }.or_not()) + .then(str_list.clone()) + .map(|(json, paths)| AgentField::Produces(paths, json.is_some())), just(Token::KwPrompt) .ignore_then(choice(( string.map_with(|s, e| (PromptSource::Inline(s), e.span())), @@ -759,7 +753,6 @@ where ) .map_with(|((name, name_span), fields), e| { let mut description = None; - let mut client = None; let mut tier_ref = None; let mut scope = None; let mut depends_on = None; @@ -771,15 +764,13 @@ where let mut vars: Vec<(String, String)> = Vec::new(); let mut tools: Vec = Vec::new(); let mut produces: Vec = Vec::new(); + let mut produces_json: Vec = Vec::new(); let mut template = false; for f in fields { match f { AgentField::Description(v, s) => { description.get_or_insert((v, s)); } - AgentField::Client(v, s) => { - client.get_or_insert((v, s)); - } AgentField::TierRef(v, s) => { tier_ref.get_or_insert((v, s)); } @@ -789,7 +780,10 @@ where AgentField::DependsOn(v, s) => { depends_on.get_or_insert((v, s)); } - AgentField::Produces(paths) => { + AgentField::Produces(paths, json) => { + if json { + produces_json.extend(paths.iter().cloned()); + } produces.extend(paths); } AgentField::Prompt(v, s) => { @@ -822,11 +816,11 @@ where name, name_span, description, - client, tier_ref, scope, depends_on, produces, + produces_json, prompt, max_retries, timeout_secs, @@ -953,18 +947,43 @@ where .map(|(v, s)| ForItem::PeerTemplate(v, s)), ident.map_with(|n, e| ForItem::Agent(n, e.span())), )); + // `in json ""` (runtime list) or `in `. The json form + // is tried first, so a list param that happens to be named `json` still + // parses: it is followed by a mode word, not a string. + let kw_json = select! { Token::Ident(s) if s == "json" => () }; + let kw_max = select! { Token::Ident(s) if s == "max" => () }; + let for_list = choice(( + kw_json + .map_with(|_, e| e.span()) + .then(string.map_with(|v, e| (v, e.span()))) + .map(|(json_span, (path, path_span))| { + (("json".to_string(), json_span), Some((path, path_span))) + }), + ident.map_with(|s, e| ((s, e.span()), None)), + )); + // Range checks (`max 0`, `max` without a json source, …) are semantic and + // live in `for_loops`, where the diagnostic text survives backtracking. + let for_max = kw_max.ignore_then(integer.map_with(|n, e| { + (u32::try_from(n).unwrap_or(u32::MAX), e.span()) + })); let for_block = kw_for .ignore_then(ident.map_with(|s, e| (s, e.span()))) .then_ignore(kw_in) - .then(ident.map_with(|s, e| (s, e.span()))) + .then(for_list) .then(for_mode.map_with(|m, e| (m, e.span()))) + .then(for_max.or_not()) .then( for_item .repeated() .collect::>() .delimited_by(just(Token::LBrace), just(Token::RBrace)), ) - .try_map(|((((var, var_span), (list, list_span)), (mode, mode_span)), items), span| { + .try_map( + |( + ((((var, var_span), ((list, list_span), json_source)), (mode, mode_span)), max_items), + items, + ), + span| { let mut agents = Vec::new(); let mut peer_template: Option<(String, Span)> = None; for item in items { @@ -996,12 +1015,15 @@ where mode_span, agents, peer_template, + json_source, + max_items, span, }) - }); + }, + ); let loop_field = choice(( - for_block.clone().map(LoopField::For), + for_block.clone().map(|fb| LoopField::For(Box::new(fb))), just(Token::KwReviewers) .ignore_then(reviewers_source) .map(LoopField::Reviewers), @@ -1075,7 +1097,7 @@ where let mut fors: Vec = Vec::new(); for f in fields { match f { - LoopField::For(fb) => fors.push(fb), + LoopField::For(fb) => fors.push(*fb), LoopField::Reviewers(v) => reviewers = v, LoopField::Agents(v) => agents = v, LoopField::Until(c) => { @@ -1152,43 +1174,15 @@ where // ── workflow declaration ────────────────────────────────────── - // `param [ ]` | `param { model ... }` - // Bare `param ` infers roster vs client from usage at compile time. - let param_client_block = client_field - .clone() - .repeated() - .collect::>() - .delimited_by(just(Token::LBrace), just(Token::RBrace)); - let param_body = choice(( - reviewer_literal_list.clone().map(ParamShape::Roster), - param_client_block.map_with(|fields, e| { - let mut spec = ClientParamSpec { - span: e.span(), - ..Default::default() - }; - for f in fields { - match f { - ClientField::Model(v, s) => { - spec.model.get_or_insert((v, s)); - } - ClientField::Effort(v, s) => { - spec.effort.get_or_insert((v, s)); - } - ClientField::Privacy(v, s) => { - spec.privacy.get_or_insert((v, s)); - } - ClientField::Extra(pairs) => { - spec.extra.extend(pairs); - } - ClientField::Tier(_, _) | ClientField::Default => {} - } - } - ParamShape::Client(spec) - }), - )); + // `param [ ]`, or bare `param ` (value from `--param`). let param_decl = just(Token::KwParam) .ignore_then(ident.map_with(|n, e| (n, e.span()))) - .then(param_body.or_not()) + .then( + reviewer_literal_list + .clone() + .map(ParamShape::Roster) + .or_not(), + ) .map_with(|((name, name_span), shape), e| { WorkflowField::Param(ParamDecl { name, @@ -1249,8 +1243,71 @@ where }) }); + // `budget { wall "" usd }` — contextual keywords; values are + // validated by the compiler. + let kw_budget = select! { Token::Ident(s) if s == "budget" => () }; + let kw_wall = select! { Token::Ident(s) if s == "wall" => () }; + let kw_usd = select! { Token::Ident(s) if s == "usd" => () }; + let usd_value = select! { + Token::Int(n) => n as f64, + Token::Float(v) => v as f64, + }; + let budget_field = choice(( + kw_wall + .ignore_then(string.map_with(|v, e| (v, e.span()))) + .map(|(v, s)| BudgetField::Wall(v, s)), + kw_usd + .ignore_then(usd_value.map_with(|v, e| (v, e.span()))) + .map(|(v, s)| BudgetField::Usd(v, s)), + )); + let budget_block = kw_budget + .ignore_then( + budget_field + .repeated() + .collect::>() + .delimited_by(just(Token::LBrace), just(Token::RBrace)), + ) + .map_with(|fields, e| { + let mut block = BudgetBlock { + wall: None, + usd: None, + span: e.span(), + }; + for field in fields { + match field { + BudgetField::Wall(v, s) => { + block.wall.get_or_insert((v, s)); + } + BudgetField::Usd(v, s) => { + block.usd.get_or_insert((v, s)); + } + } + } + block + }); + + // `tiers { … }` — `tiers` is contextual, so an agent may + // still be named `tiers`. + let kw_tiers = select! { Token::Ident(s) if s == "tiers" => () }; + let agent_tier = ident + .map_with(|n, e| (n, e.span())) + .then(tier_name.map_with(|t, e| (t, e.span()))) + .map(|((agent, agent_span), (tier, tier_span))| AgentTier { + agent, + agent_span, + tier, + tier_span, + }); + let tiers_block = kw_tiers.ignore_then( + agent_tier + .repeated() + .collect::>() + .delimited_by(just(Token::LBrace), just(Token::RBrace)), + ); + let workflow_field = choice(( param_decl, + tiers_block.map(WorkflowField::Tiers), just(Token::KwSteps) .ignore_then(step_list.map_with(|v, e| (v, e.span()))) .map(|(v, s)| WorkflowField::Steps(v, s)), @@ -1283,6 +1340,7 @@ where .map(|(n, s)| WorkflowField::EscalateAfter(n as u32, s)), verify_block.map(WorkflowField::Verify), pattern_block.map(WorkflowField::Pattern), + budget_block.map(WorkflowField::Budget), )); let workflow_decl = just(Token::KwWorkflow) @@ -1305,9 +1363,14 @@ where let mut escalate_after = None; let mut verify = None; let mut params: Vec = Vec::new(); + let mut tiers: Vec = Vec::new(); let mut pattern = None; + let mut budget = None; for f in fields { match f { + WorkflowField::Tiers(entries) => { + tiers.extend(entries); + } WorkflowField::Steps(v, s) => { steps.get_or_insert((v, s)); } @@ -1344,6 +1407,9 @@ where WorkflowField::Pattern(p) => { pattern.get_or_insert(p); } + WorkflowField::Budget(b) => { + budget.get_or_insert(b); + } } } WorkflowDecl { @@ -1360,7 +1426,10 @@ where escalate_after, verify, params, + tiers, pattern, + runtime_fors: Vec::new(), + budget, span: e.span(), file_id: 0, } @@ -1634,7 +1703,6 @@ mod tests { assert!(errs.is_empty(), "parse errors: {:?}", errs); if let Item::Agent(a) = &ast.unwrap().items[2] { assert!(matches!(&a.tier_ref, Some((n, _)) if n == "expensive")); - assert!(a.client.is_none()); } else { panic!("expected Agent item"); } @@ -1729,7 +1797,7 @@ mod tests { fn full_example_three_items() { let src = r#" client c { tier execution model "sonnet" } - agent a { client c description "task" } + agent a { tier c description "task" } workflow w { steps [a] } "#; let (ast, errs) = parse_str(src); @@ -1737,6 +1805,36 @@ mod tests { assert_eq!(ast.unwrap().items.len(), 3); } + /// `client` is no longer an agent field: an agent names a tier. + #[test] + fn agent_client_field_is_a_parse_error() { + let (_, errs) = parse_str(r#"agent a { client c }"#); + assert!(!errs.is_empty()); + } + + #[test] + fn workflow_tiers_block_parses() { + let src = r#" + agent a { tier t } + agent b { tier t } + workflow w { + tiers { a high b medium-codex } + steps [a b] + } + "#; + let (ast, errs) = parse_str(src); + assert!(errs.is_empty(), "{:?}", errs); + let Item::Workflow(w) = &ast.unwrap().items[2] else { + panic!("expected workflow"); + }; + let pairs: Vec<(&str, &str)> = w + .tiers + .iter() + .map(|t| (t.agent.as_str(), t.tier.as_str())) + .collect(); + assert_eq!(pairs, [("a", "high"), ("b", "medium-codex")]); + } + #[test] fn parse_error_missing_brace() { let src = "agent bad { description \"x\" "; @@ -2382,7 +2480,7 @@ mod tests { }; assert_eq!(entries.len(), 1); assert_eq!(entries[0].id, "a"); - assert!(entries[0].model.is_none()); + assert!(entries[0].tier.is_none()); assert_eq!(entries[0].fields.len(), 1); assert_eq!(entries[0].fields[0].0, "focus"); assert_eq!(entries[0].fields[0].1, "x"); @@ -2393,7 +2491,7 @@ mod tests { let src = r#" agent a { description "a" } workflow w { - param p [ { id "a" id "b" model "claude:opus" } ] + param p [ { id "a" id "b" tier high } ] steps [a] } "#; @@ -2406,7 +2504,7 @@ mod tests { panic!("expected list param"); }; assert_eq!(entries[0].id, "a"); - assert_eq!(entries[0].model.as_deref(), Some("claude:opus")); + assert_eq!(entries[0].tier.as_ref().map(|(t, _)| t.as_str()), Some("high")); assert!(entries[0].fields.iter().any(|(k, v, _)| k == "id" && v == "b")); } @@ -2512,6 +2610,60 @@ mod tests { assert!(!errs.is_empty()); } + #[test] + fn for_block_over_a_json_file_parses() { + let steps = workflow_steps( + r#" + agent worker { description "w" } + workflow w { steps [ for q in json "out/items.json" parallel max 4 { worker } ] } + "#, + ); + let StepItem::For(fb) = &steps[0] else { + panic!("expected For step"); + }; + assert_eq!(fb.var, "q"); + assert_eq!(fb.list, "json"); + assert_eq!( + fb.json_source.as_ref().map(|(p, _)| p.as_str()), + Some("out/items.json") + ); + assert_eq!(fb.max_items.map(|(n, _)| n), Some(4)); + assert_eq!(fb.mode, ForMode::Parallel); + } + + #[test] + fn for_block_over_a_json_file_without_max_parses() { + let steps = workflow_steps( + r#" + agent worker { description "w" } + workflow w { steps [ loop { for q in json "out/i-v{{PREV_ITER}}.json" parallel { worker } until agent worker } ] } + "#, + ); + let StepItem::Loop(lb) = &steps[0] else { + panic!("expected Loop step"); + }; + assert_eq!( + lb.fors[0].json_source.as_ref().map(|(p, _)| p.as_str()), + Some("out/i-v{{PREV_ITER}}.json") + ); + assert!(lb.fors[0].max_items.is_none()); + } + + #[test] + fn a_list_param_named_json_is_still_a_list_param() { + let steps = workflow_steps( + r#" + agent a { description "a" } + workflow w { steps [ for t in json parallel { a } ] } + "#, + ); + let StepItem::For(fb) = &steps[0] else { + panic!("expected For step"); + }; + assert_eq!(fb.list, "json"); + assert!(fb.json_source.is_none()); + } + #[test] fn agent_named_parallel_still_works_as_a_step() { let steps = workflow_steps( @@ -2526,12 +2678,14 @@ mod tests { } #[test] - fn list_literal_parses_free_fields_and_models() { + fn list_literal_parses_free_fields_and_tiers() { let entries = - parse_list_literal(r#"[{id "a" focus "x"} {id "b" model "claude:opus"}]"#).unwrap(); + parse_list_literal(r#"[{id "a" focus "x"} {id "b" tier high-codex}]"#).unwrap(); assert_eq!(entries.len(), 2); assert_eq!(entries[0].fields[0].0, "focus"); - assert_eq!(entries[1].model.as_deref(), Some("claude:opus")); + assert_eq!(entries[1].tier.as_ref().map(|(t, _)| t.as_str()), Some("high-codex")); + // A model is never an item field: models live in the profile. + assert!(parse_list_literal(r#"[{id "b" model "claude:opus"}]"#).is_err()); } #[test] diff --git a/crates/gaviero-dsl/src/profile.rs b/crates/gaviero-dsl/src/profile.rs index 7e575906..0c7d481e 100644 --- a/crates/gaviero-dsl/src/profile.rs +++ b/crates/gaviero-dsl/src/profile.rs @@ -1,14 +1,15 @@ -//! Merge a named model profile into a resolved script. +//! Model profiles: the one place a tier gets its model. //! //! A profile is a `.gaviero` file of `client` and `tier` declarations (plus //! `include`s of the same). It is self-contained: its tiers may only point at -//! its own clients, and those clients are renamed on merge, so a profile never -//! collides with what the script declares and a script cannot depend on it by -//! client name. Scripts reach a profile through `tier ` alone. +//! its own clients, and those clients are renamed on merge, so a script +//! cannot depend on them by name. Scripts declare neither clients nor tier +//! lines ([`reject_model_tables`]); they reach a profile through +//! `tier ` alone. use std::collections::HashSet; -use gaviero_core::script_profiles::{ProfilePrecedence, SelectedProfile}; +use gaviero_core::script_profiles::SelectedProfile; use miette::NamedSource; use crate::ast::{ClientDecl, Item, Script, Span, TierAlias}; @@ -20,6 +21,41 @@ pub fn profile_client_name(client: &str) -> String { format!("__profile_{client}") } +/// Reject `client { }` and `tier ` in a script (or a file it +/// includes): what a tier means belongs to the model profile, never to the +/// script. +pub(crate) fn reject_model_tables( + script: &Script, + sources: &[(String, String)], +) -> Result<(), DslErrors> { + const WHY: &str = "models are chosen in one place: a model profile \ + (.gaviero/dsl/profiles/.gaviero) maps tiers to clients, \ + and agents pick a tier with `tier `"; + let mut errors = Vec::new(); + for item in &script.items { + let (file_id, span, what) = match item { + Item::Client(c) => (c.file_id, c.span, format!("`client {}`", c.name)), + Item::TierAlias(t) => ( + t.file_id, + t.span, + format!("`tier {} {}`", t.name, t.client_ref), + ), + _ => continue, + }; + let (filename, content) = &sources[file_id as usize]; + errors.push(DslError::Compile { + src: NamedSource::new(filename, content.clone()), + span: (span.start, span.end.saturating_sub(span.start).max(1)).into(), + reason: format!("a script cannot declare {what} — {WHY}"), + }); + } + if errors.is_empty() { + Ok(()) + } else { + Err(DslErrors::new(errors)) + } +} + /// Merge `selected` into `script`. Diagnostics for the profile point at the /// profile's own files, which are appended to `sources`. pub(crate) fn apply_profile( @@ -28,43 +64,7 @@ pub(crate) fn apply_profile( selected: &SelectedProfile, ) -> Result<(), DslErrors> { let (profile, profile_sources) = resolver::resolve(&selected.path)?; - let (mut clients, mut tiers) = split_profile(profile, &profile_sources)?; - - match selected.precedence { - ProfilePrecedence::OverridesScript => { - let bound: HashSet<&str> = tiers.iter().map(|t| t.name.as_str()).collect(); - script - .items - .retain(|i| !matches!(i, Item::TierAlias(t) if bound.contains(t.name.as_str()))); - if clients.iter().any(|c| c.is_default) { - for item in &mut script.items { - if let Item::Client(c) = item { - c.is_default = false; - } - } - } - } - ProfilePrecedence::FillsGaps => { - let bound: HashSet = script - .items - .iter() - .filter_map(|i| match i { - Item::TierAlias(t) => Some(t.name.clone()), - _ => None, - }) - .collect(); - tiers.retain(|t| !bound.contains(&t.name)); - let script_has_default = script - .items - .iter() - .any(|i| matches!(i, Item::Client(c) if c.is_default)); - if script_has_default { - for client in &mut clients { - client.is_default = false; - } - } - } - } + let (clients, tiers) = split_profile(profile, &profile_sources)?; let offset = sources.len() as u32; sources.extend(profile_sources); @@ -121,6 +121,17 @@ fn split_profile( let mut declared = HashSet::new(); for client in &clients { + if client.is_default { + errors.push(error_at( + client.file_id, + client.name_span, + format!( + "client `{}` is marked `default`, which no longer means anything — \ + every agent declares a tier; remove `default`", + client.name + ), + )); + } if !declared.insert(client.name.as_str()) { errors.push(error_at( client.file_id, diff --git a/crates/gaviero-dsl/src/resolver.rs b/crates/gaviero-dsl/src/resolver.rs index bb8a41d1..302a64e7 100644 --- a/crates/gaviero-dsl/src/resolver.rs +++ b/crates/gaviero-dsl/src/resolver.rs @@ -257,7 +257,7 @@ mod tests { "main.gaviero", r#" include "lib.gaviero" - agent worker { client base prompt "hi" } + agent worker { tier base prompt "hi" } workflow w { steps [worker] } "#, ); diff --git a/crates/gaviero-dsl/src/reviewers.rs b/crates/gaviero-dsl/src/reviewers.rs index 2a3d7aec..6493d978 100644 --- a/crates/gaviero-dsl/src/reviewers.rs +++ b/crates/gaviero-dsl/src/reviewers.rs @@ -1,5 +1,4 @@ //! Backward-compatible re-exports — implementation lives in [`workflow_params`]. pub use crate::workflow_params::{ - expand_reviewers_in_script, expand_workflow_params_in_script, parse_client_override, - parse_reviewers_override, + expand_reviewers_in_script, expand_workflow_params_in_script, parse_reviewers_override, }; diff --git a/crates/gaviero-dsl/src/tiers.rs b/crates/gaviero-dsl/src/tiers.rs deleted file mode 100644 index 237e1bd3..00000000 --- a/crates/gaviero-dsl/src/tiers.rs +++ /dev/null @@ -1,95 +0,0 @@ -//! Load `tier ` bindings from a profile file for CLI overrides. - -use std::collections::HashSet; -use std::path::Path; - -use miette::NamedSource; - -use crate::ast::{Item, Script}; -use crate::error::{DslError, DslErrors}; -use crate::resolver; - -/// Parse a `.gaviero` tiers profile: top-level `tier ` lines only. -/// -/// `include "..."` is allowed so profiles can live beside shared libraries; other -/// top-level items (`client`, `agent`, `workflow`, …) are rejected. -pub fn load_tier_overrides(path: &Path) -> Result, miette::Report> { - let (script, sources) = resolver::resolve(path).map_err(miette::Report::new)?; - extract_tier_overrides(&script, &sources).map_err(miette::Report::new) -} - -fn extract_tier_overrides( - script: &Script, - sources: &[(String, String)], -) -> Result, DslErrors> { - let src_for = |fid: u32| -> NamedSource { - let (filename, content) = &sources[fid as usize]; - NamedSource::new(filename, content.clone()) - }; - - let mut out = Vec::new(); - let mut seen = HashSet::new(); - let mut errors = Vec::new(); - - for item in &script.items { - match item { - Item::TierAlias(ta) => { - if !seen.insert(ta.name.clone()) { - errors.push(DslError::Compile { - src: src_for(ta.file_id), - span: ( - ta.name_span.start, - ta.name_span.end.saturating_sub(ta.name_span.start).max(1), - ) - .into(), - reason: format!("duplicate tier alias `{}`", ta.name), - }); - continue; - } - out.push((ta.name.clone(), ta.client_ref.clone())); - } - Item::Vars(_) => {} - Item::Include(inc) => { - errors.push(DslError::Compile { - src: src_for(0), - span: ( - inc.span.start, - inc.span.end.saturating_sub(inc.span.start).max(1), - ) - .into(), - reason: "unexpected `include` after resolution in tiers profile — file a bug" - .into(), - }); - } - other => { - let (span, label) = match other { - Item::Client(c) => (c.span, "client"), - Item::Agent(a) => (a.span, "agent"), - Item::Workflow(w) => (w.span, "workflow"), - Item::Prompt(p) => (p.span, "prompt"), - Item::TierAlias(_) => unreachable!(), - Item::Vars(_) | Item::Include(_) => unreachable!(), - }; - errors.push(DslError::Compile { - src: src_for(0), - span: (span.start, span.end.saturating_sub(span.start).max(1)).into(), - reason: format!( - "tiers profile must contain only `tier` declarations, found `{label}`" - ), - }); - } - } - } - - if !errors.is_empty() { - return Err(DslErrors::new(errors)); - } - if out.is_empty() { - return Err(DslErrors::single(DslError::Compile { - src: src_for(0), - span: (0, 0).into(), - reason: "tiers profile contains no `tier ` bindings".into(), - })); - } - Ok(out) -} diff --git a/crates/gaviero-dsl/src/workflow_params.rs b/crates/gaviero-dsl/src/workflow_params.rs index 918c5a2b..3add9dc7 100644 --- a/crates/gaviero-dsl/src/workflow_params.rs +++ b/crates/gaviero-dsl/src/workflow_params.rs @@ -1,99 +1,108 @@ -//! Workflow parameter materialization: client params and roster expansion. -//! -//! Client params (`param judge { model "claude:sonnet" ... }` or bare `param judge` -//! when an agent says `client judge`) synthesize `__param_` clients and -//! rewrite agent bindings before compilation. +//! Workflow parameter materialization: list params and roster expansion, +//! plus the workflow `tiers { }` block. //! //! Roster params expand `loop { reviewers ... }` into per-reviewer agents. +//! A model is chosen by tier only: an agent declares `tier `, the +//! workflow's `tiers { agent tier }` block and `--tier agent=tier` replace it, +//! and a list item's `tier` replaces it for that item's clone. use std::collections::{HashMap, HashSet}; use crate::ast::*; use crate::error::{DslError, DslErrors}; -/// Synthesized client name for a workflow client param. -pub fn param_client_name(param: &str) -> String { - format!("__param_{param}") -} - -/// The tier named by a `tier:` model spec, if `model` is one. A param or -/// roster entry written this way binds its agent to the tier, leaving the -/// choice of model to the profile. -pub fn tier_of_model_spec(model: &str) -> Option<&str> { - model.strip_prefix("tier:").map(str::trim) -} +/// Apply the selected workflow's `tiers { }` block, then the `--tier` +/// overrides, to the agents' declared tiers. Runs before any cloning, so +/// `for` and roster clones inherit the result; an item's own `tier` still +/// wins for its clone. +pub(crate) fn apply_agent_tiers( + script: &mut Script, + workflow_name: Option<&str>, + cli_tiers: &[(String, String)], +) -> Result<(), DslErrors> { + let block: Vec = script + .items + .iter() + .filter_map(|i| match i { + Item::Workflow(wf) if workflow_name.is_none_or(|n| wf.name == n) => { + Some(wf.tiers.clone()) + } + _ => None, + }) + .flatten() + .collect(); + let agents: HashSet = script + .items + .iter() + .filter_map(|i| match i { + Item::Agent(a) => Some(a.name.clone()), + _ => None, + }) + .collect(); -/// The tier a client param resolves to. A tier fixes model, effort and -/// privacy together, so a spec that also sets those is contradictory. -fn client_spec_tier(spec: &ClientParamSpec) -> Result, String> { - let Some(tier) = spec.model.as_ref().and_then(|(m, _)| tier_of_model_spec(m)) else { - return Ok(None); - }; - if tier.is_empty() { - return Err("`tier:` needs a tier name, e.g. `tier:high`".into()); - } - if spec.effort.is_some() || spec.privacy.is_some() || !spec.extra.is_empty() { - return Err(format!( - "`tier:{tier}` cannot be combined with effort, privacy or extra — \ - the tier's client sets those" - )); + let mut errors = Vec::new(); + let mut seen: HashSet<&str> = HashSet::new(); + let mut chosen: HashMap = HashMap::new(); + for entry in &block { + let span = entry.agent_span; + let at = (span.start, span.end.saturating_sub(span.start).max(1)); + if !agents.contains(&entry.agent) { + errors.push(DslError::Compile { + src: miette::NamedSource::new("script", String::new()), + span: at.into(), + reason: format!("`tiers` names `{}`, which is not a defined agent", entry.agent), + }); + } else if !seen.insert(entry.agent.as_str()) { + errors.push(DslError::Compile { + src: miette::NamedSource::new("script", String::new()), + span: at.into(), + reason: format!("`tiers` sets agent `{}` twice", entry.agent), + }); + } + chosen.insert(entry.agent.clone(), (entry.tier.clone(), entry.tier_span)); } - Ok(Some(tier.to_string())) -} - -/// The tier a roster entry resolves to; see [`client_spec_tier`]. -pub(crate) fn roster_entry_tier(entry: &ReviewerEntry) -> Result, String> { - let Some(tier) = entry.model.as_deref().and_then(tier_of_model_spec) else { - return Ok(None); - }; - if tier.is_empty() { - return Err(format!( - "roster entry `{}`: `tier:` needs a tier name, e.g. `tier:high`", - entry.id - )); + for (agent, tier) in cli_tiers { + if !agents.contains(agent) { + errors.push(DslError::Compile { + src: miette::NamedSource::new("", String::new()), + span: (0, 1).into(), + reason: format!("--tier {agent}={tier}: `{agent}` is not a defined agent"), + }); + continue; + } + // A CLI tier has no place in the source; keep the agent's own span so + // an unknown tier is reported on the agent. + let span = chosen + .get(agent) + .map(|(_, s)| *s) + .unwrap_or_else(|| (0..0).into()); + chosen.insert(agent.clone(), (tier.clone(), span)); } - if entry.effort.is_some() { - return Err(format!( - "roster entry `{}`: `tier:{tier}` cannot be combined with effort — \ - the tier's client sets it", - entry.id - )); + if !errors.is_empty() { + return Err(DslErrors::new(errors)); } - Ok(Some(tier)) -} -/// Parse `--param NAME=provider:model[@effort]` for a client param. -pub fn parse_client_override(value: &str) -> Result { - let value = value.trim(); - if value.is_empty() { - return Err("client param override is empty".into()); - } - let (model_spec, effort) = match value.split_once('@') { - Some((m, e)) => (m.trim().to_string(), Some(e.trim().to_string())), - None => (value.to_string(), None), - }; - if model_spec.is_empty() || !model_spec.contains(':') { - return Err(format!( - "client param override must be `provider:model` or `provider:model@effort`, got `{value}`" - )); + for item in &mut script.items { + let Item::Agent(agent) = item else { continue }; + if let Some((tier, span)) = chosen.get(&agent.name) { + let span = if span.start == span.end { + agent.tier_ref.as_ref().map(|(_, s)| *s).unwrap_or(agent.name_span) + } else { + *span + }; + agent.tier_ref = Some((tier.clone(), span)); + } } - let span: chumsky::span::SimpleSpan = (0..0).into(); - Ok(ClientParamSpec { - model: Some((model_spec, span)), - effort: effort.map(|e| (e, span)), - privacy: None, - extra: Vec::new(), - span, - }) + Ok(()) } /// Parse a `--param NAME=...` value string into a roster / list param. /// /// Forms: -/// - a DSL list literal: `[{id "a" focus "x"} {id "b" model "claude:opus"}]` +/// - a DSL list literal: `[{id "a" focus "x"} {id "b" tier high}]` /// (any value whose trimmed form starts with `[`); -/// - the short form `id=provider:model[@effort](,id=provider:model[@effort])*`, -/// where a part without `=` is an id-only entry (`a,b,c`). +/// - the short form `id=tier(,id=tier)*`, where a part without `=` is an +/// id-only entry (`a,b,c`). pub fn parse_reviewers_override(value: &str) -> Result, String> { if value.trim_start().starts_with('[') { return crate::parser::parse_list_literal(value); @@ -104,39 +113,26 @@ pub fn parse_reviewers_override(value: &str) -> Result, Strin if part.is_empty() { continue; } - let Some((id, rest)) = part.split_once('=') else { - let span: chumsky::span::SimpleSpan = (0..0).into(); - out.push(ReviewerEntry { - id: part.to_string(), - id_span: span, - model: None, - model_span: span, - effort: None, - fields: Vec::new(), - span, - }); - continue; + let span: chumsky::span::SimpleSpan = (0..0).into(); + let (id, tier) = match part.split_once('=') { + Some((id, tier)) => (id.trim(), Some(tier.trim())), + None => (part, None), }; - let id = id.trim(); if id.is_empty() { return Err(format!("invalid roster entry `{part}` (empty id)")); } - let (model_spec, effort) = match rest.split_once('@') { - Some((m, e)) => (m.trim().to_string(), Some(e.trim().to_string())), - None => (rest.trim().to_string(), None), - }; - if model_spec.is_empty() || !model_spec.contains(':') { + if let Some(tier) = tier + && (tier.is_empty() || tier.contains([':', '@', ' '])) + { return Err(format!( - "invalid roster entry `{part}` (model must be `provider:model`)" + "invalid roster entry `{part}` (expected `id=`, e.g. `claude=top-claude`; \ + models are chosen by the profile's tiers)" )); } - let span: chumsky::span::SimpleSpan = (0..0).into(); out.push(ReviewerEntry { id: id.to_string(), id_span: span, - model: Some(model_spec), - model_span: span, - effort: effort.map(|e| (e, span)), + tier: tier.map(|t| (t.to_string(), span)), fields: Vec::new(), span, }); @@ -166,62 +162,40 @@ pub(crate) fn describe_workflow_params( .collect(); let usage = param_usage_for_workflow(wf, &agent_by_name); - let with_effort = |model: &str, effort: Option<&str>| match effort { - Some(e) => format!("{model}@{e}"), - None => model.to_string(), - }; - wf.params .iter() .filter_map(|decl| { let mut ignored = Vec::new(); - let kind = resolve_param_kind(&decl.name, decl, &usage, &mut ignored)?; - Some(match kind { - ParamKind::Roster(entries) => ParamInspection { - name: decl.name.clone(), - kind: ParamKindInfo::Roster, - default: entries.filter(|e| !e.is_empty()).map(|entries| { - // Free fields only survive in the literal form. - if entries.iter().any(|r| !r.fields.is_empty()) { - let items: Vec = - entries.iter().map(list_literal_entry).collect(); - return format!("[{}]", items.join(" ")); - } - entries - .iter() - .map(|r| { - let effort = r.effort.as_ref().map(|(e, _)| e.as_str()); - match &r.model { - Some(model) => { - format!("{}={}", r.id, with_effort(model, effort)) - } - None => r.id.clone(), - } - }) - .collect::>() - .join(",") - }), - }, - ParamKind::Client(spec) => ParamInspection { - name: decl.name.clone(), - kind: ParamKindInfo::Client, - default: spec.model.as_ref().map(|(model, _)| { - with_effort(model, spec.effort.as_ref().map(|(e, _)| e.as_str())) - }), - }, + let ParamKind::Roster(entries) = + resolve_param_kind(&decl.name, decl, &usage, &mut ignored)?; + Some(ParamInspection { + name: decl.name.clone(), + kind: ParamKindInfo::Roster, + default: entries.filter(|e| !e.is_empty()).map(|entries| { + // Free fields only survive in the literal form. + if entries.iter().any(|r| !r.fields.is_empty()) { + let items: Vec = entries.iter().map(list_literal_entry).collect(); + return format!("[{}]", items.join(" ")); + } + entries + .iter() + .map(|r| match &r.tier { + Some((tier, _)) => format!("{}={tier}", r.id), + None => r.id.clone(), + }) + .collect::>() + .join(",") + }), }) }) .collect() } -/// One entry in list-literal syntax: `{id "a" model "m" effort high focus "x"}`. +/// One entry in list-literal syntax: `{id "a" tier high focus "x"}`. pub fn list_literal_entry(entry: &ReviewerEntry) -> String { let mut out = format!("{{id {}", quote_literal(&entry.id)); - if let Some(model) = &entry.model { - out.push_str(&format!(" model {}", quote_literal(model))); - } - if let Some((effort, _)) = &entry.effort { - out.push_str(&format!(" effort {}", quote_literal(effort))); + if let Some((tier, _)) = &entry.tier { + out.push_str(&format!(" tier {tier}")); } for (name, value, _) in &entry.fields { out.push_str(&format!(" {name} {}", quote_literal(value))); @@ -239,28 +213,15 @@ fn quote_literal(value: &str) -> String { } } -/// Materialize client params and expand reviewer rosters for the selected workflow. +/// Resolve list params and expand reviewer rosters for the selected workflow. pub fn expand_workflow_params_in_script( script: &mut Script, workflow_name: Option<&str>, override_params: &[(String, String)], ) -> Result<(), DslErrors> { let mut errors = Vec::new(); - let mut new_clients: Vec = Vec::new(); let mut new_agents: Vec = Vec::new(); - let static_client_names: HashSet = script - .items - .iter() - .filter_map(|i| { - if let Item::Client(c) = i { - Some(c.name.clone()) - } else { - None - } - }) - .collect(); - let agent_by_name: HashMap = script .items .iter() @@ -275,10 +236,8 @@ pub fn expand_workflow_params_in_script( // Per-workflow resolved param kinds (used by roster pass). let mut kinds_by_workflow: HashMap> = HashMap::new(); - let mut client_rewrites: Vec<(String, String)> = Vec::new(); - let mut tier_rewrites: Vec<(String, String)> = Vec::new(); - // Pass 1 — materialize client params (immutable workflow borrow). + // Pass 1 — resolve param kinds (immutable workflow borrow). for item in &script.items { let Item::Workflow(wf) = item else { continue }; if let Some(name) = workflow_name @@ -305,77 +264,7 @@ pub fn expand_workflow_params_in_script( continue; } - kinds_by_workflow.insert(wf.name.clone(), resolved_kinds.clone()); - - for (param_name, kind) in &resolved_kinds { - let ParamKind::Client(spec) = kind else { - continue; - }; - if static_client_names.contains(param_name) { - errors.push(DslError::Compile { - src: miette::NamedSource::new("script", String::new()), - span: ( - params_by_name[param_name].name_span.start, - params_by_name[param_name] - .name_span - .end - .saturating_sub(params_by_name[param_name].name_span.start) - .max(1), - ) - .into(), - reason: format!( - "workflow param `{param_name}` conflicts with top-level `client {param_name}` — \ - use a different param or client name" - ), - }); - continue; - } - - let resolved = match resolve_client_spec( - param_name, - spec, - ¶ms_by_name[param_name], - override_params, - ) { - Ok(s) => s, - Err(e) => { - errors.push(e); - continue; - } - }; - - match client_spec_tier(&resolved) { - Ok(Some(tier)) => { - tier_rewrites.push((param_name.clone(), tier)); - continue; - } - Ok(None) => {} - Err(reason) => { - let name_span = params_by_name[param_name].name_span; - errors.push(DslError::Compile { - src: miette::NamedSource::new("script", String::new()), - span: ( - name_span.start, - name_span.end.saturating_sub(name_span.start).max(1), - ) - .into(), - reason: format!("workflow param `{param_name}`: {reason}"), - }); - continue; - } - } - - let synth_name = param_client_name(param_name); - new_clients.push(synth_client_from_spec(&synth_name, &resolved)); - client_rewrites.push((param_name.clone(), synth_name)); - } - } - - for (param_name, synth_name) in &client_rewrites { - rewrite_agent_client_param(script, param_name, synth_name); - } - for (param_name, tier) in &tier_rewrites { - rewrite_agent_tier_param(script, param_name, tier); + kinds_by_workflow.insert(wf.name.clone(), resolved_kinds); } if !errors.is_empty() { @@ -422,32 +311,6 @@ pub fn expand_workflow_params_in_script( } }; - let tier_problems: Vec = roster - .iter() - .filter_map(|entry| { - let reason = if entry.model.is_none() { - format!("roster entry `{}` needs `model`", entry.id) - } else { - roster_entry_tier(entry).err()? - }; - Some(DslError::Compile { - src: miette::NamedSource::new("script", String::new()), - span: ( - entry.span.start, - entry.span.end.saturating_sub(entry.span.start).max(1), - ) - .into(), - reason, - }) - }) - .collect(); - if !tier_problems.is_empty() { - errors.extend(tier_problems); - lb.reviewers = ReviewerSource::None; - expanded_steps.push(StepItem::Loop(lb)); - continue; - } - let init_template = lb.template_init.as_ref().map(|(name, span)| { match agent_by_name.get(name) { Some(a) => Ok((a, name.clone(), *span)), @@ -508,31 +371,11 @@ pub fn expand_workflow_params_in_script( Vec::new(); for entry in &roster { - let refine_client_name = if init_template.is_some() { - format!("__roster_{}_refine", entry.id) - } else { - format!("__roster_{}", entry.id) - }; - // A tier entry binds through the tier; it has no client of its own. - let needs_client = entry - .model - .as_deref() - .and_then(tier_of_model_spec) - .is_none(); - if needs_client { - new_clients.push(synth_client_from_entry(&refine_client_name, entry)); - } - if let Some((init_tpl, _, _)) = &init_template { - let init_client_name = format!("__roster_{}_init", entry.id); - if needs_client { - new_clients.push(synth_client_from_entry(&init_client_name, entry)); - } let init_agent = clone_reviewer_agent( init_tpl, &format!("{}-init", entry.id), entry, - &init_client_name, ); new_agents.push(init_agent.clone()); expanded_steps.push(StepItem::Agent( @@ -545,7 +388,6 @@ pub fn expand_workflow_params_in_script( refine_tpl, &format!("{}-refine", entry.id), entry, - &refine_client_name, ); let refine_agent = inject_peer_vars(refine_agent, &entry.id, &peer_ids); refine_agent_names @@ -563,9 +405,6 @@ pub fn expand_workflow_params_in_script( *steps = expanded_steps; } - for client in new_clients { - script.items.push(Item::Client(client)); - } for agent in new_agents { script.items.push(Item::Agent(agent)); } @@ -599,14 +438,12 @@ pub fn expand_reviewers_in_script( #[derive(Clone, Default)] struct ParamUsage { roster: bool, - client: bool, } fn param_usage_for_workflow( wf: &WorkflowDecl, - agent_by_name: &HashMap, + _agent_by_name: &HashMap, ) -> HashMap { - let param_names: HashSet = wf.params.iter().map(|p| p.name.clone()).collect(); let mut usage: HashMap = HashMap::new(); let Some((steps, _)) = &wf.steps else { return usage; @@ -617,120 +454,35 @@ fn param_usage_for_workflow( if let ReviewerSource::ParamRef(name, _) = &lb.reviewers { usage.entry(name.clone()).or_default().roster = true; } - for fb in &lb.fors { + for fb in lb.fors.iter().filter(|fb| fb.json_source.is_none()) { usage.entry(fb.list.clone()).or_default().roster = true; } - if let UntilCondition::Agent(judge, _) = &lb.until { - record_client_param_usage(&mut usage, judge, ¶m_names, agent_by_name); - } - } - StepItem::Agent(name, _) => { - record_client_param_usage(&mut usage, name, ¶m_names, agent_by_name); } + StepItem::Agent(..) => {} // A `for` iterates a list param, which is the roster kind. - StepItem::For(fb) => { + // (`for … in json` reads a file at run time and uses no param.) + StepItem::For(fb) if fb.json_source.is_none() => { usage.entry(fb.list.clone()).or_default().roster = true; } + StepItem::For(_) => {} } } usage } -fn record_client_param_usage( - usage: &mut HashMap, - agent_name: &str, - param_names: &HashSet, - agent_by_name: &HashMap, -) { - let Some(agent) = agent_by_name.get(agent_name) else { - return; - }; - if let Some((client_name, _)) = &agent.client - && param_names.contains(client_name) - { - usage.entry(client_name.clone()).or_default().client = true; - } -} - fn resolve_param_kind( name: &str, decl: &ParamDecl, usage: &HashMap, errors: &mut Vec, ) -> Option { - if let Some(shape) = &decl.shape { - return Some(match shape { - ParamShape::Roster(list) => ParamKind::Roster(Some(list.clone())), - ParamShape::Client(spec) => ParamKind::Client(spec.clone()), - }); + if let Some(ParamShape::Roster(list)) = &decl.shape { + return Some(ParamKind::Roster(Some(list.clone()))); } - - let u = usage.get(name).cloned().unwrap_or_default(); - match (u.roster, u.client) { - (true, true) => { - errors.push(DslError::Compile { - src: miette::NamedSource::new("script", String::new()), - span: ( - decl.name_span.start, - decl.name_span - .end - .saturating_sub(decl.name_span.start) - .max(1), - ) - .into(), - reason: format!( - "workflow param `{name}` is used as both a roster (`reviewers {name}`) \ - and a client (`client {name}`) — use distinct param names or add \ - explicit `[...]` / `{{...}}` syntax" - ), - }); - None - } - (true, false) => Some(ParamKind::Roster(None)), - (false, true) => Some(ParamKind::Client(ClientParamSpec { - span: decl.span, - ..Default::default() - })), - (false, false) => { - errors.push(DslError::Compile { - src: miette::NamedSource::new("script", String::new()), - span: ( - decl.name_span.start, - decl.name_span - .end - .saturating_sub(decl.name_span.start) - .max(1), - ) - .into(), - reason: format!( - "workflow param `{name}` is never referenced — use `reviewers {name}`, \ - `client {name}` on an agent, or remove the declaration" - ), - }); - None - } + if usage.get(name).is_some_and(|u| u.roster) { + return Some(ParamKind::Roster(None)); } -} - -fn resolve_client_spec( - name: &str, - spec: &ClientParamSpec, - decl: &ParamDecl, - override_params: &[(String, String)], -) -> Result { - if let Some((_, v)) = override_params.iter().find(|(k, _)| k == name) { - return parse_client_override(v).map_err(|e| DslError::Compile { - src: miette::NamedSource::new("", String::new()), - span: (0, 1).into(), - reason: format!("--param {name}: {e}"), - }); - } - - if spec.model.is_some() { - return Ok(spec.clone()); - } - - Err(DslError::Compile { + errors.push(DslError::Compile { src: miette::NamedSource::new("script", String::new()), span: ( decl.name_span.start, @@ -741,10 +493,12 @@ fn resolve_client_spec( ) .into(), reason: format!( - "workflow client param `{name}` has no `model` default and was not \ - supplied on the CLI — pass `--param {name}=provider:model[@effort]`" + "workflow param `{name}` is never referenced — iterate it with \ + `for x in {name}` or `reviewers {name}`, or remove the declaration \ + (params are lists; an agent's model comes from its `tier`)" ), - }) + }); + None } pub(crate) fn resolve_roster( @@ -772,16 +526,7 @@ pub(crate) fn resolve_roster( reason: format!("workflow param `{name}` is not a roster param"), })?; - let ParamKind::Roster(default) = kind else { - return Err(DslError::Compile { - src: miette::NamedSource::new("script", String::new()), - span: (span.start, span.end.saturating_sub(span.start).max(1)).into(), - reason: format!( - "`reviewers {name}` requires a roster param (`param {name} [ ... ]` \ - or bare `param {name}` used only in `reviewers`)" - ), - }); - }; + let ParamKind::Roster(default) = kind; if let Some((_, v)) = override_params.iter().find(|(k, _)| k == name) { return parse_reviewers_override(v).map_err(|e| DslError::Compile { @@ -805,7 +550,7 @@ pub(crate) fn resolve_roster( .into(), reason: format!( "workflow roster param `{name}` has no default and was not \ - supplied on the CLI — pass `--param {name}=id=provider:model[@effort],...`" + supplied on the CLI — pass `--param {name}=id=,...`" ), }), } @@ -813,43 +558,7 @@ pub(crate) fn resolve_roster( } } -fn synth_client_from_spec(name: &str, spec: &ClientParamSpec) -> ClientDecl { - let span = spec.span; - ClientDecl { - name: name.to_string(), - name_span: span, - tier: None, - model: spec.model.clone(), - effort: spec.effort.clone(), - extra: spec.extra.clone(), - privacy: spec.privacy.or(Some((PrivacyLit::Public, span))), - is_default: false, - span, - file_id: 0, - } -} - -pub(crate) fn synth_client_from_entry(name: &str, entry: &ReviewerEntry) -> ClientDecl { - ClientDecl { - name: name.to_string(), - name_span: entry.span, - tier: None, - model: entry.model.clone().map(|m| (m, entry.model_span)), - effort: entry.effort.clone(), - extra: Vec::new(), - privacy: Some((PrivacyLit::Public, entry.span)), - is_default: false, - span: entry.span, - file_id: 0, - } -} - -fn clone_reviewer_agent( - template: &AgentDecl, - name: &str, - entry: &ReviewerEntry, - client_name: &str, -) -> AgentDecl { +fn clone_reviewer_agent(template: &AgentDecl, name: &str, entry: &ReviewerEntry) -> AgentDecl { let mut vars = template.vars.clone(); vars.retain(|(k, _)| k != "REVIEWER_ID"); vars.push(("REVIEWER_ID".into(), entry.id.clone())); @@ -858,16 +567,11 @@ fn clone_reviewer_agent( name: name.to_string(), name_span: template.name_span, description: template.description.clone(), - client: Some((client_name.to_string(), entry.span)), - tier_ref: None, + tier_ref: entry.tier.clone().or_else(|| template.tier_ref.clone()), vars, template: false, ..clone_agent_shell(template) }; - if let Some(tier) = entry.model.as_deref().and_then(tier_of_model_spec) { - agent.client = None; - agent.tier_ref = Some((tier.to_string(), template.name_span)); - } if let Some(scope) = agent.scope.as_mut() { for path in scope.owned.iter_mut().chain(scope.read_only.iter_mut()) { *path = path.replace("{{REVIEWER_ID}}", &entry.id); @@ -875,7 +579,7 @@ fn clone_reviewer_agent( } // The output contract is per-reviewer for the same reason the owned globs // are: without the id prefix every clone would claim the same artefacts. - for path in agent.produces.iter_mut() { + for path in agent.produces.iter_mut().chain(agent.produces_json.iter_mut()) { *path = path.replace("{{REVIEWER_ID}}", &entry.id); } agent @@ -886,11 +590,11 @@ fn clone_agent_shell(template: &AgentDecl) -> AgentDecl { name: String::new(), name_span: template.name_span, description: None, - client: None, - tier_ref: None, + tier_ref: template.tier_ref.clone(), scope: template.scope.clone(), depends_on: template.depends_on.clone(), produces: template.produces.clone(), + produces_json: template.produces_json.clone(), prompt: template.prompt.clone(), max_retries: template.max_retries, timeout_secs: template.timeout_secs, @@ -905,30 +609,6 @@ fn clone_agent_shell(template: &AgentDecl) -> AgentDecl { } } -fn rewrite_agent_client_param(script: &mut Script, param_name: &str, synth_name: &str) { - for item in &mut script.items { - let Item::Agent(agent) = item else { continue }; - if agent.client.as_ref().is_some_and(|(n, _)| n == param_name) { - let span = agent.client.as_ref().unwrap().1; - agent.client = Some((synth_name.to_string(), span)); - } - } -} - -/// Turn every `client ` binding into `tier `. The span stays on -/// the agent's own `client` line, so a missing tier is reported in its file. -fn rewrite_agent_tier_param(script: &mut Script, param_name: &str, tier: &str) { - for item in &mut script.items { - let Item::Agent(agent) = item else { continue }; - if let Some((name, span)) = &agent.client - && name == param_name - { - agent.tier_ref = Some((tier.to_string(), *span)); - agent.client = None; - } - } -} - fn inject_peer_vars(mut agent: AgentDecl, self_id: &str, peer_ids: &[String]) -> AgentDecl { let others: Vec<&str> = peer_ids .iter() @@ -977,44 +657,26 @@ fn build_peer_read_block(peers: &[&str]) -> String { mod tests { use super::*; - #[test] - fn parse_client_override_with_effort() { - let spec = parse_client_override("claude:sonnet@medium").unwrap(); - assert_eq!(spec.model.as_ref().unwrap().0, "claude:sonnet"); - assert_eq!(spec.effort.as_ref().unwrap().0, "medium"); - } - - #[test] - fn parse_client_override_rejects_bare_model() { - let err = parse_client_override("opus").unwrap_err(); - assert!(err.contains("provider:model"), "got: {err}"); + fn tier_of(entry: &ReviewerEntry) -> Option<&str> { + entry.tier.as_ref().map(|(t, _)| t.as_str()) } #[test] fn parse_simple_two_reviewers() { - let entries = parse_reviewers_override("claude=claude:opus,codex=codex:gpt-5.5").unwrap(); + let entries = parse_reviewers_override("claude=top-claude,codex=top-codex").unwrap(); assert_eq!(entries.len(), 2); assert_eq!(entries[0].id, "claude"); - assert_eq!(entries[0].model.as_deref(), Some("claude:opus")); - } - - #[test] - fn parse_with_effort() { - let entries = - parse_reviewers_override("claude=claude:opus@max,codex=codex:gpt-5.5@high").unwrap(); - assert_eq!(entries[0].effort.as_ref().unwrap().0, "max"); - assert_eq!(entries[1].effort.as_ref().unwrap().0, "high"); + assert_eq!(tier_of(&entries[0]), Some("top-claude")); + assert_eq!(tier_of(&entries[1]), Some("top-codex")); } #[test] fn parse_list_literal_override() { - let entries = parse_reviewers_override( - r#"[{id "a" focus "x"} {id "b" model "claude:opus"}]"#, - ) - .unwrap(); + let entries = + parse_reviewers_override(r#"[{id "a" focus "x"} {id "b" tier high}]"#).unwrap(); assert_eq!(entries.len(), 2); assert_eq!(entries[0].fields[0].1, "x"); - assert_eq!(entries[1].model.as_deref(), Some("claude:opus")); + assert_eq!(tier_of(&entries[1]), Some("high")); } #[test] @@ -1022,14 +684,24 @@ mod tests { let entries = parse_reviewers_override("a,b").unwrap(); assert_eq!(entries.len(), 2); assert_eq!(entries[0].id, "a"); - assert!(entries[0].model.is_none()); + assert!(entries[0].tier.is_none()); assert_eq!(entries[1].id, "b"); } + /// Models are a profile's business: a roster entry names a tier, never + /// a `provider:model`, an effort or a `tier:` spec. + #[test] + fn parse_rejects_model_specs() { + for value in ["claude=claude:opus", "claude=opus@max", "claude=tier:high"] { + let err = parse_reviewers_override(value).unwrap_err(); + assert!(err.contains("id="), "{value}: {err}"); + } + } + #[test] - fn parse_rejects_missing_provider() { - let err = parse_reviewers_override("claude=opus").unwrap_err(); - assert!(err.contains("provider:model"), "got: {err}"); + fn a_list_literal_rejects_model_and_effort() { + assert!(parse_reviewers_override(r#"[{id "a" model "claude:opus"}]"#).is_err()); + assert!(parse_reviewers_override(r#"[{id "a" effort high}]"#).is_err()); } /// The block is substituted like any other prompt text, so its diff --git a/crates/gaviero-dsl/tests/compile.rs b/crates/gaviero-dsl/tests/compile.rs index e0e1a399..6f1db0d8 100644 --- a/crates/gaviero-dsl/tests/compile.rs +++ b/crates/gaviero-dsl/tests/compile.rs @@ -1,14 +1,90 @@ use gaviero_core::iteration::Strategy; +use gaviero_core::script_profiles::{ProfilePrecedence, SelectedProfile}; use gaviero_core::types::ModelTier; -use gaviero_dsl::compile; -const FULL_EXAMPLE: &str = r##" - client opus { tier coordinator model "claude-opus-4-7" privacy public } - client sonnet { tier execution model "claude-sonnet-4-6" } +/// The profile every inline test compiles against: `tests/fixtures/test-profile.gaviero`. +fn test_profile() -> SelectedProfile { + SelectedProfile { + name: "test".into(), + path: std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/test-profile.gaviero"), + precedence: ProfilePrecedence::OverridesScript, + } +} + +/// The model profile shipped with the examples (`examples/profiles/default.gaviero`). +fn example_profile() -> SelectedProfile { + SelectedProfile { + name: "default".into(), + path: std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("examples/profiles/default.gaviero"), + precedence: ProfilePrecedence::FillsGaps, + } +} +/// `gaviero_dsl::compile_file` with a profile: the examples' default profile +/// for a script under `examples/`, the test profile for any other file. +fn compile_file( + path: &std::path::Path, + workflow: Option<&str>, + prompt: Option<&str>, + vars: &[(String, String)], + agent_tiers: &[(String, String)], + params: &[(String, String)], +) -> Result { + let examples = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples"); + let profile = if path.starts_with(&examples) { + example_profile() + } else { + test_profile() + }; + gaviero_dsl::compile_file_with_profile( + path, + Some(&profile), + workflow, + prompt, + vars, + agent_tiers, + params, + ) +} + +/// `gaviero_dsl::compile` with the test profile. +fn compile( + source: &str, + filename: &str, + workflow: Option<&str>, + prompt: Option<&str>, +) -> Result { + gaviero_dsl::compile(source, filename, Some(&test_profile()), workflow, prompt) +} + +/// `gaviero_dsl::compile_with_vars` with the test profile. +fn compile_with_vars( + source: &str, + filename: &str, + workflow: Option<&str>, + prompt: Option<&str>, + vars: &[(String, String)], + agent_tiers: &[(String, String)], + params: &[(String, String)], +) -> Result { + gaviero_dsl::compile_with_vars( + source, + filename, + Some(&test_profile()), + workflow, + prompt, + vars, + agent_tiers, + params, + ) +} + +const FULL_EXAMPLE: &str = r##" agent researcher { description "Research and document the codebase architecture" - client opus + tier opus scope { owned ["docs/architecture.md"] read_only ["src/**"] @@ -22,7 +98,7 @@ const FULL_EXAMPLE: &str = r##" agent implementer { description "Implement the feature" - client sonnet + tier sonnet depends_on [researcher] scope { owned ["src/feature/"] @@ -88,18 +164,149 @@ fn lex_error_is_reported() { } #[test] -fn undefined_client_error() { - let src = r#"agent x { client ghost }"#; +fn undefined_tier_error_lists_the_profile_tiers() { + let src = r#"agent x { tier ghost }"#; let err = compile(src, "test.gaviero", None, None).unwrap_err(); let report = format!("{:?}", err); assert!(report.contains("ghost"), "report: {}", report); + assert!(report.contains("it defines: local, low, opus, sonnet, t"), "report: {}", report); +} + +// ── Tiers only ─────────────────────────────────────────────────── + +/// Every agent declares its default tier; there is no fallback client. +#[test] +fn an_agent_without_a_tier_is_an_error() { + let err = compile(r#"agent x { description "d" }"#, "test.gaviero", None, None).unwrap_err(); + let report = format!("{:?}", err); + assert!(report.contains("agent `x` declares no tier"), "report: {report}"); +} + +/// What a tier means lives in the profile alone: a script may not declare +/// a client or a tier line, nor bind an agent to a client. +#[test] +fn a_script_cannot_choose_models_itself() { + for (src, needle) in [ + ( + r#"client c { model "claude:opus" } agent x { tier t }"#, + "cannot declare `client c`", + ), + (r#"tier fast t agent x { tier t }"#, "cannot declare `tier fast t`"), + ] { + let report = format!("{:?}", compile(src, "test.gaviero", None, None).unwrap_err()); + assert!(report.contains(needle), "{src}: {report}"); + assert!(report.contains("model profile"), "{src}: {report}"); + } + // `client` is no longer an agent field at all. + assert!(compile(r#"agent x { client c }"#, "test.gaviero", None, None).is_err()); + // Nor is a model-valued param. + assert!( + compile( + r#"agent x { tier t } workflow w { param j { model "claude:opus" } steps [x] }"#, + "test.gaviero", + None, + None + ) + .is_err() + ); +} + +/// Without a profile no tier is bound, and the diagnostic says how to get one. +#[test] +fn no_profile_means_no_tier() { + let err = gaviero_dsl::compile(r#"agent x { tier t }"#, "test.gaviero", None, None, None) + .unwrap_err(); + let report = format!("{err:?}"); + assert!(report.contains("no model profile is bound"), "report: {report}"); +} + +const TIERED: &str = r#" + agent a { tier t } + agent b { tier t } + agent j { tier t prompt "judge" } + workflow w { + tiers { + b opus + j sonnet + } + steps [ a b loop { agents [a] until agent j } ] + } +"#; + +fn model_of(plan: &gaviero_dsl::CompiledPlan, id: &str) -> Option { + plan.work_units_unordered() + .into_iter() + .chain(plan.loop_judge_units.iter()) + .find(|u| u.id == id) + .unwrap_or_else(|| panic!("no unit {id}")) + .model + .clone() +} + +/// The workflow's `tiers { }` block moves an agent (and a loop judge) to +/// another tier; agents it does not name keep their own. +#[test] +fn the_workflow_tiers_block_overrides_an_agent_tier() { + let plan = compile(TIERED, "test.gaviero", None, None).expect("compile"); + assert_eq!(model_of(&plan, "a"), None, "tier t keeps its own"); + assert_eq!(model_of(&plan, "b").as_deref(), Some("claude-opus-4-7")); + assert_eq!(model_of(&plan, "j").as_deref(), Some("claude-sonnet-4-6")); +} + +/// `--tier agent=tier` beats the block, and reaches agents it does not name. +#[test] +fn cli_tier_overrides_the_block() { + let cli = vec![ + ("b".to_string(), "low".to_string()), + ("a".to_string(), "sonnet".to_string()), + ]; + let plan = compile_with_vars(TIERED, "test.gaviero", None, None, &[], &cli, &[]).unwrap(); + assert_eq!(model_of(&plan, "b").as_deref(), Some("claude:haiku")); + assert_eq!(model_of(&plan, "a").as_deref(), Some("claude-sonnet-4-6")); + assert_eq!(model_of(&plan, "j").as_deref(), Some("claude-sonnet-4-6")); +} + +#[test] +fn tier_overrides_must_name_real_agents_and_tiers() { + let unknown_agent = r#"agent a { tier t } workflow w { tiers { ghost opus } steps [a] }"#; + let report = format!("{:?}", compile(unknown_agent, "t.gaviero", None, None).unwrap_err()); + assert!(report.contains("`tiers` names `ghost`"), "{report}"); + + let twice = r#"agent a { tier t } workflow w { tiers { a opus a low } steps [a] }"#; + let report = format!("{:?}", compile(twice, "t.gaviero", None, None).unwrap_err()); + assert!(report.contains("sets agent `a` twice"), "{report}"); + + let cli = vec![("ghost".to_string(), "opus".to_string())]; + let err = compile_with_vars(TIERED, "t.gaviero", None, None, &[], &cli, &[]).unwrap_err(); + assert!(format!("{err:?}").contains("--tier ghost=opus"), "{err:?}"); + + let cli = vec![("a".to_string(), "nope".to_string())]; + let err = compile_with_vars(TIERED, "t.gaviero", None, None, &[], &cli, &[]).unwrap_err(); + assert!(format!("{err:?}").contains("uses tier `nope`"), "{err:?}"); +} + +/// A list item's `tier` moves its own clone; items without one keep the +/// body agent's tier — which the `tiers { }` block may have moved. +#[test] +fn a_list_item_tier_wins_for_its_clone() { + let src = r#" + agent worker { tier t scope { owned ["out/{{x.id}}.md"] } } + workflow w { + tiers { worker sonnet } + param items [ { id "a" } { id "b" tier opus } ] + steps [ for x in items parallel { worker } ] + } + "#; + let plan = compile(src, "test.gaviero", None, None).expect("compile"); + assert_eq!(model_of(&plan, "a-worker").as_deref(), Some("claude-sonnet-4-6")); + assert_eq!(model_of(&plan, "b-worker").as_deref(), Some("claude-opus-4-7")); } #[test] fn no_workflow_runs_all_agents() { let src = r#" - agent a { description "first" } - agent b { description "second" } + agent a { tier t description "first" } + agent b { tier t description "second" } "#; let units = compile(src, "test.gaviero", None, None) .unwrap() @@ -113,8 +320,8 @@ fn no_workflow_runs_all_agents() { #[test] fn workflow_name_selector() { let src = r#" - agent a { description "a" } - agent b { description "b" } + agent a { tier t description "a" } + agent b { tier t description "b" } workflow just_b { steps [b] } workflow both { steps [a b] } "#; @@ -129,7 +336,7 @@ fn workflow_name_selector() { #[test] fn multiple_workflows_without_selector_is_an_error() { let src = r#" - agent a { description "a" } + agent a { tier t description "a" } workflow first { steps [a] } workflow second { steps [a] } "#; @@ -140,7 +347,7 @@ fn multiple_workflows_without_selector_is_an_error() { #[test] fn parse_error_missing_closing_brace() { - let src = r#"agent x { description "hello" "#; + let src = r#"agent x { tier t description "hello" "#; let err = compile(src, "test.gaviero", None, None).unwrap_err(); let report = format!("{:?}", err); assert!(!report.is_empty()); @@ -149,8 +356,8 @@ fn parse_error_missing_closing_brace() { #[test] fn dependency_cycle_detected() { let src = r#" - agent a { depends_on [b] } - agent b { depends_on [a] } + agent a { tier t depends_on [b] } + agent b { tier t depends_on [a] } "#; let err = compile(src, "test.gaviero", None, None).unwrap_err(); let report = format!("{:?}", err); @@ -162,7 +369,7 @@ fn dependency_cycle_detected() { #[test] fn strategy_refine_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] strategy refine } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -175,7 +382,7 @@ fn strategy_refine_propagated() { #[test] fn strategy_single_pass_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] strategy single_pass } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -188,7 +395,7 @@ fn strategy_single_pass_propagated() { #[test] fn strategy_best_of_n_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] strategy best_of_3 } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -205,7 +412,7 @@ fn strategy_best_of_n_propagated() { #[test] fn test_first_true_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] test_first true } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -218,7 +425,7 @@ fn test_first_true_propagated() { #[test] fn max_retries_workflow_level_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] max_retries 3 } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -228,7 +435,7 @@ fn max_retries_workflow_level_propagated() { #[test] fn verify_block_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] verify { compile true clippy true test false } @@ -243,7 +450,7 @@ fn verify_block_propagated() { #[test] fn verify_block_all_true() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] verify { compile true clippy true test true } @@ -257,7 +464,7 @@ fn verify_block_all_true() { #[test] fn iteration_config_defaults_when_no_workflow() { - let src = r#"agent a { description "task" }"#; + let src = r#"agent a { tier t description "task" }"#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); // No workflow → defaults assert!(matches!( @@ -274,7 +481,7 @@ fn iteration_config_defaults_when_no_workflow() { #[test] fn escalate_after_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] escalate_after 5 } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -284,7 +491,7 @@ fn escalate_after_propagated() { #[test] fn attempts_propagated() { let src = r#" - agent a { description "task" } + agent a { tier t description "task" } workflow w { steps [a] attempts 4 strategy best_of_4 } "#; let compiled = compile(src, "test.gaviero", None, None).expect("should compile"); @@ -305,7 +512,7 @@ fn compile_example(filename: &str) -> Vec env!("CARGO_MANIFEST_DIR"), filename )); - gaviero_dsl::compile_file(&path, None, None, &[], &[], &[]) + compile_file(&path, None, None, &[], &[], &[]) .unwrap_or_else(|e| panic!("compiling {}:\n{:?}", filename, e)) .work_units_ordered() .expect("toposort") @@ -378,6 +585,7 @@ fn example_codebase_review() { .model .clone() }; + // Tier `medium` → sonnet, `high` → opus in the examples' default profile. assert_eq!(model_of("inventory").as_deref(), Some("claude:sonnet")); assert_eq!(model_of("review_module").as_deref(), Some("claude:opus")); assert_eq!(model_of("synthesize").as_deref(), Some("claude:sonnet")); @@ -460,20 +668,20 @@ fn example_codebase_review() { } #[test] -fn codebase_review_param_overrides_reviewer() { +fn codebase_review_tier_overrides_reviewer() { let path = std::path::PathBuf::from(format!( "{}/examples/codebase_review.gaviero", env!("CARGO_MANIFEST_DIR") )); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, None, None, &[], + &[("review_module".to_string(), "high-codex".to_string())], &[], - &[("reviewer".to_string(), "codex:gpt-5.6-sol@high".to_string())], ) - .expect("compile codebase_review with --param reviewer"); + .expect("compile codebase_review with --tier review_module"); let units = plan.work_units_ordered().expect("toposort"); let model_of = |id: &str| -> Option { units @@ -486,7 +694,7 @@ fn codebase_review_param_overrides_reviewer() { }; assert_eq!( model_of("review_module").as_deref(), - Some("codex:gpt-5.6-sol") + Some("codex:gpt-6.1-sol") ); assert_eq!(model_of("inventory").as_deref(), Some("claude:sonnet")); assert_eq!(model_of("halt_judge").as_deref(), Some("claude:sonnet")); @@ -494,30 +702,30 @@ fn codebase_review_param_overrides_reviewer() { } #[test] -fn codebase_review_param_overrides_both_roles() { +fn codebase_review_tier_overrides_several_agents() { let path = std::path::PathBuf::from(format!( "{}/examples/codebase_review.gaviero", env!("CARGO_MANIFEST_DIR") )); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, None, None, &[], - &[], &[ - ("reviewer".to_string(), "codex:gpt-5.6-sol@high".to_string()), - ("judge".to_string(), "codex:gpt-5.6-luna@medium".to_string()), + ("review_module".to_string(), "high-codex".to_string()), + ("inventory".to_string(), "low-codex".to_string()), ], + &[], ) - .expect("compile codebase_review with both --param overrides"); + .expect("compile codebase_review with two --tier overrides"); let units = plan.work_units_ordered().expect("toposort"); let review = units.iter().find(|u| u.id == "review_module").unwrap(); let inventory = units.iter().find(|u| u.id == "inventory").unwrap(); - assert_eq!(review.model.as_deref(), Some("codex:gpt-5.6-sol")); + assert_eq!(review.model.as_deref(), Some("codex:gpt-6.1-sol")); assert_eq!(review.effort.as_deref(), Some("high")); - assert_eq!(inventory.model.as_deref(), Some("codex:gpt-5.6-luna")); - assert_eq!(inventory.effort.as_deref(), Some("medium")); + assert_eq!(inventory.model.as_deref(), Some("codex:gpt-6-luna")); + assert_eq!(inventory.effort.as_deref(), Some("low")); } #[test] @@ -578,7 +786,7 @@ fn compile_example_plan(filename: &str) -> gaviero_core::swarm::plan::CompiledPl env!("CARGO_MANIFEST_DIR"), filename )); - gaviero_dsl::compile_file(&path, None, None, &[], &[], &[]) + compile_file(&path, None, None, &[], &[], &[]) .unwrap_or_else(|e| panic!("compiling {}:\n{:?}", filename, e)) } @@ -588,7 +796,7 @@ fn codebase_review_var_relocates_out_dir() { "{}/examples/codebase_review.gaviero", env!("CARGO_MANIFEST_DIR") )); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, None, None, @@ -634,14 +842,13 @@ fn template_update_docs() { .iter() .find(|u| u.id == "inventory") .expect("inventory"); - // Default profile is doc-cursor.gaviero (inventory → grok). The Cursor CLI - // id embeds the effort level, so `clients.gaviero` pins the full id. - assert_eq!(inventory.model.as_deref(), Some("cursor:grok-4.7-high")); + // inventory runs on `top`, the README writer on `medium`. + assert_eq!(inventory.model.as_deref(), Some("claude:fable")); let readme = units .iter() .find(|u| u.id == "write_readme_md") .expect("write_readme_md"); - assert_eq!(readme.model.as_deref(), Some("cursor:composer-2.5")); + assert_eq!(readme.model.as_deref(), Some("claude:sonnet")); assert_eq!(units[0].id, "inventory"); // Three write agents depend on inventory assert!(units[1].depends_on.contains(&"inventory".to_string())); @@ -669,22 +876,24 @@ fn example_pattern_map_reduce_emits_fanout() { assert!(units[1].depends_on.contains(&"discover".to_string())); } +/// Swapping every model at once is choosing another profile. #[test] -fn update_docs_tiers_file_overrides_profile() { +fn update_docs_profile_swaps_every_model() { let examples = std::path::PathBuf::from(format!("{}/examples", env!("CARGO_MANIFEST_DIR"))); let entry = examples.join("update_docs.gaviero"); - let codex_profile = examples.join("profiles/doc-codex.gaviero"); - let overrides = - gaviero_dsl::load_tier_overrides(&codex_profile).expect("load codex tiers profile"); - let plan = gaviero_dsl::compile_file(&entry, None, None, &[], &overrides, &[]) - .expect("compile with --tiers-file overrides"); - let inventory = plan - .work_units_ordered() - .expect("toposort") - .into_iter() - .find(|u| u.id == "inventory") - .expect("inventory"); - assert_eq!(inventory.model.as_deref(), Some("codex:gpt-6.1-sol")); + let codex = SelectedProfile { + name: "codex".into(), + path: examples.join("profiles/codex.gaviero"), + precedence: ProfilePrecedence::OverridesScript, + }; + let plan = gaviero_dsl::compile_file_with_profile(&entry, Some(&codex), None, None, &[], &[], &[]) + .expect("compile with the codex profile"); + let units = plan.work_units_ordered().expect("toposort"); + assert!( + units.iter().all(|u| u.model.as_deref().is_some_and(|m| m.starts_with("codex:"))), + "{:?}", + units.iter().map(|u| u.model.clone()).collect::>() + ); } #[test] @@ -708,16 +917,9 @@ fn template_plan_refinement() { .find(|u| u.id == "cursor-refine") .expect("cursor-refine"); - let expected_default = gaviero_core::types::ModelTier::default(); - for u in &[crefine, xrefine, urefine] { - assert_eq!( - u.tier, expected_default, - "agent {} should resolve to the default tier (roster synth client)", - u.id - ); - } - assert_eq!(crefine.model.as_deref(), Some("claude:opus")); - assert_eq!(xrefine.model.as_deref(), Some("codex:gpt-5.6-sol")); + // Each roster entry's `tier` sets its clone's model through the profile. + assert_eq!(crefine.model.as_deref(), Some("claude:fable")); + assert_eq!(xrefine.model.as_deref(), Some("codex:gpt-6-astra")); assert_eq!(urefine.model.as_deref(), Some("cursor:grok-4.7-high")); assert!( @@ -830,7 +1032,7 @@ fn template_plan_refinement() { fn plan_refinement_three_provider_roster() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/plan_refinement.gaviero"); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("feature-plan-refinement"), Some("multi-provider plan test"), @@ -838,7 +1040,7 @@ fn plan_refinement_three_provider_roster() { &[], &[( "roster".into(), - "claude=claude:opus@max,codex=codex:gpt-5.5@high,cursor=cursor:composer-2.5@medium" + "claude=top-claude,codex=high-codex,cursor=medium-cursor" .into(), )], ) @@ -986,7 +1188,7 @@ fn template_phased_plan() { fn compile_file_generic_consensus_with_reviewers() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/generic_consensus.gaviero"); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("generic-consensus"), Some("test topic"), @@ -1015,9 +1217,9 @@ fn generic_consensus_param_roster_override_swaps_to_three_reviewers() { std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/generic_consensus.gaviero"); let overrides = vec![( "roster".to_string(), - "claude=claude:opus@max,codex=codex:gpt-5.5@high,cursor=cursor:composer-2.5".to_string(), + "claude=top-claude,codex=high-codex,cursor=medium-cursor".to_string(), )]; - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("generic-consensus"), Some("test topic"), @@ -1050,7 +1252,7 @@ fn generic_consensus_param_roster_override_swaps_to_three_reviewers() { fn compile_file_scientific_research_default_roster() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("examples/scientific_research.gaviero"); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("scientific-research-consensus"), Some("test topic"), @@ -1092,13 +1294,13 @@ fn compile_file_scientific_research_default_roster() { fn compile_file_scientific_research_produces_is_per_reviewer() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("examples/scientific_research.gaviero"); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("scientific-research-consensus"), Some("test topic"), &[], &[], - &[("roster".into(), "a=claude:opus,b=codex:gpt-5.6-sol".into())], + &[("roster".into(), "a=high-claude,b=high-codex".into())], ) .expect("two-reviewer roster should compile"); @@ -1136,9 +1338,9 @@ fn compile_file_scientific_research_param_roster_override_to_two() { .join("examples/scientific_research.gaviero"); let overrides = vec![( "roster".to_string(), - "claude=claude:opus@max,codex=codex:gpt-5.5@high".to_string(), + "claude=top-claude,codex=high-codex".to_string(), )]; - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("scientific-research-consensus"), Some("test topic"), @@ -1179,9 +1381,9 @@ fn scientific_research_peer_block_substitutes_out_dir() { let vars = vec![("OUT_DIR".to_string(), "research/run-a".to_string())]; let overrides = vec![( "roster".to_string(), - "claude=claude:opus@max,codex=codex:gpt-5.5@high".to_string(), + "claude=top-claude,codex=high-codex".to_string(), )]; - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("scientific-research-consensus"), Some("test topic"), @@ -1213,14 +1415,13 @@ fn scientific_research_peer_block_substitutes_out_dir() { #[test] fn workflow_execution_document_parsed() { let src = r#" -client c { tier cheap model "claude:sonnet" effort low default } -agent a { client c scope { owned ["out/"] } prompt "x" } +agent a { tier t scope { owned ["out/"] } prompt "x" } workflow w { execution_mode document steps [a] } "#; - let plan = gaviero_dsl::compile(src, "test.gaviero", Some("w"), None).expect("compile"); + let plan = compile(src, "test.gaviero", Some("w"), None).expect("compile"); assert_eq!( plan.execution_mode, gaviero_core::swarm::plan::ExecutionMode::Document @@ -1228,10 +1429,10 @@ workflow w { } #[test] -fn scientific_research_judge_uses_client_param_default() { +fn scientific_research_judge_runs_on_its_own_tier() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("examples/scientific_research.gaviero"); - let plan = gaviero_dsl::compile_file( + let plan = compile_file( &path, Some("scientific-research-consensus"), Some("topic"), @@ -1249,19 +1450,19 @@ fn scientific_research_judge_uses_client_param_default() { } #[test] -fn client_param_override_swaps_judge_model() { +fn cli_tier_swaps_the_loop_judge_model() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/generic_consensus.gaviero"); - let overrides = vec![("judge".to_string(), "claude:haiku@low".to_string())]; - let plan = gaviero_dsl::compile_file( + let tiers = vec![("consensus-judge".to_string(), "low".to_string())]; + let plan = compile_file( &path, Some("generic-consensus"), Some("topic"), &[], + &tiers, &[], - &overrides, ) - .expect("judge param override should compile"); + .expect("--tier on the judge should compile"); assert_eq!( plan.loop_judge_units[0].model.as_deref(), Some("claude:haiku") @@ -1269,34 +1470,17 @@ fn client_param_override_swaps_judge_model() { assert_eq!(plan.loop_judge_units[0].effort.as_deref(), Some("low")); } +/// A roster entry names a tier, never a model: `id=provider:model` is +/// rejected with a pointer to the profile. #[test] -fn client_param_without_default_requires_cli() { - let src = concat!( - "prompt p #\"x\"#\n", - "agent judge { client gate prompt \"j\" }\n", - "workflow w {\n", - " param gate { }\n", - " steps [ judge ]\n", - "}\n", - ); - let err = gaviero_dsl::compile_with_vars(src, "inline.gaviero", Some("w"), None, &[], &[], &[]) - .expect_err("required client param must fail"); - let msg = format!("{err:?}"); - assert!( - msg.contains("gate") && (msg.contains("model") || msg.contains("CLI")), - "expected client-param required diagnostic, got: {msg}" - ); -} - -#[test] -fn generic_consensus_param_roster_missing_provider_is_rejected() { +fn generic_consensus_roster_rejects_model_specs() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/generic_consensus.gaviero"); let overrides = vec![( "roster".to_string(), - "claude=opus,codex=gpt-5.5".to_string(), + "claude=claude:opus,codex=codex:gpt-5.5".to_string(), )]; - let err = gaviero_dsl::compile_file( + let err = compile_file( &path, Some("generic-consensus"), Some("t"), @@ -1304,12 +1488,15 @@ fn generic_consensus_param_roster_missing_provider_is_rejected() { &[], &overrides, ) - .expect_err("model without provider prefix must fail"); + .expect_err("a model spec in a roster must fail"); let msg = format!("{err:?}"); - assert!( - msg.contains("provider:model"), - "expected provider:model diagnostic, got: {msg}" - ); + assert!(msg.contains("id="), "expected id= diagnostic, got: {msg}"); + + // A tier the profile does not define names the agent and the tier. + let overrides = vec![("roster".to_string(), "claude=nope".to_string())]; + let err = compile_file(&path, Some("generic-consensus"), Some("t"), &[], &[], &overrides) + .expect_err("an unknown tier must fail"); + assert!(format!("{err:?}").contains("uses tier `nope`"), "{err:?}"); } #[test] @@ -1317,10 +1504,9 @@ fn param_without_default_or_cli_value_is_required_error() { let src = concat!( "prompt p #\"x\"#\n", "prompt r #\"y\"#\n", - "client c { model \"claude:sonnet\" }\n", - "agent tinit { template true prompt p scope { owned [\"out/x-*\"] } }\n", - "agent tref { template true prompt r scope { owned [\"out/y-*\"] } }\n", - "agent judge { client c prompt \"j\" }\n", + "agent tinit { tier t template true prompt p scope { owned [\"out/x-*\"] } }\n", + "agent tref { tier t template true prompt r scope { owned [\"out/y-*\"] } }\n", + "agent judge { tier t prompt \"j\" }\n", "workflow w {\n", " param roster\n", " steps [ loop {\n", @@ -1332,7 +1518,7 @@ fn param_without_default_or_cli_value_is_required_error() { " } ]\n", "}\n", ); - let err = gaviero_dsl::compile(src, "inline.gaviero", None, None) + let err = compile(src, "inline.gaviero", None, None) .expect_err("required param without default must fail"); let msg = format!("{err:?}"); assert!( @@ -1349,41 +1535,71 @@ fn compile_file_resolves_include_and_compiles_workflow() { let tmp = tempfile::tempdir().unwrap(); let dir = tmp.path(); - // Library: shared client + tier alias + // Library: a shared agent and prompt let mut lib = fs::File::create(dir.join("lib.gaviero")).unwrap(); lib.write_all( - br#" - client sonnet { tier cheap model "claude:sonnet" } - tier cheap sonnet - "#, + br##" + prompt work #"do work"# + agent worker { + description "test" + tier sonnet + prompt work + } + "##, ) .unwrap(); - // Entry: agent + workflow that reference the included client + // Entry: a workflow that runs the included agent let entry = dir.join("main.gaviero"); let mut f = fs::File::create(&entry).unwrap(); f.write_all( br#" include "lib.gaviero" - agent worker { - description "test" - tier cheap - prompt "do work" - } workflow w { steps [worker] } "#, ) .unwrap(); - let plan = gaviero_dsl::compile_file(&entry, None, None, &[], &[], &[]) + let plan = compile_file(&entry, None, None, &[], &[], &[]) .expect("compile_file should succeed across include boundary"); let units = plan.work_units_ordered().unwrap(); assert_eq!(units.len(), 1); assert_eq!(units[0].id, "worker"); - assert_eq!(units[0].model, Some("claude:sonnet".to_string())); + assert_eq!(units[0].model, Some("claude-sonnet-4-6".to_string())); assert_eq!(units[0].tier, ModelTier::Cheap); } +/// An included file is part of the script: it may not declare clients +/// either, and the diagnostic points at the included file. +#[test] +fn compile_file_rejects_a_client_in_an_included_file() { + use std::fs; + use std::io::Write; + + let tmp = tempfile::tempdir().unwrap(); + let dir = tmp.path(); + fs::File::create(dir.join("clients.gaviero")) + .unwrap() + .write_all(br#"client base { model "claude:sonnet" }"#) + .unwrap(); + let entry = dir.join("main.gaviero"); + fs::File::create(&entry) + .unwrap() + .write_all( + br#" + include "clients.gaviero" + agent w { tier t prompt "x" } + workflow wf { steps [w] } + "#, + ) + .unwrap(); + + let err = compile_file(&entry, None, None, &[], &[], &[]).unwrap_err(); + let msg = format!("{:?}", err); + assert!(msg.contains("cannot declare `client base`"), "got: {msg}"); + assert!(msg.contains("clients.gaviero"), "got: {msg}"); +} + #[test] fn compile_file_reports_duplicate_decl_across_files() { use std::fs; @@ -1392,14 +1608,14 @@ fn compile_file_reports_duplicate_decl_across_files() { let tmp = tempfile::tempdir().unwrap(); let dir = tmp.path(); - // Both files declare `client base` — duplicate should be flagged. + // Both files declare `prompt base` — duplicate should be flagged. fs::File::create(dir.join("a.gaviero")) .unwrap() - .write_all(br#"client base { tier cheap model "claude:sonnet" }"#) + .write_all(br#"prompt base "one""#) .unwrap(); fs::File::create(dir.join("b.gaviero")) .unwrap() - .write_all(br#"client base { tier cheap model "claude:haiku" }"#) + .write_all(br#"prompt base "two""#) .unwrap(); let entry = dir.join("main.gaviero"); fs::File::create(&entry) @@ -1408,17 +1624,17 @@ fn compile_file_reports_duplicate_decl_across_files() { br#" include "a.gaviero" include "b.gaviero" - agent w { client base prompt "x" } + agent w { tier t prompt base } workflow wf { steps [w] } "#, ) .unwrap(); - let err = gaviero_dsl::compile_file(&entry, None, None, &[], &[], &[]).unwrap_err(); + let err = compile_file(&entry, None, None, &[], &[], &[]).unwrap_err(); let msg = format!("{:?}", err); assert!( - msg.contains("duplicate client name `base`"), - "expected duplicate-client diagnostic, got: {}", + msg.contains("duplicate prompt name `base`"), + "expected duplicate-prompt diagnostic, got: {}", msg ); } @@ -1427,9 +1643,9 @@ fn compile_file_reports_duplicate_decl_across_files() { fn compile_rejects_inline_include_with_helpful_diagnostic() { let src = r#" include "lib.gaviero" - client c { tier cheap model "claude:sonnet" } + agent a { tier t } "#; - let err = gaviero_dsl::compile(src, "inline.gaviero", None, None).unwrap_err(); + let err = compile(src, "inline.gaviero", None, None).unwrap_err(); let msg = format!("{:?}", err); assert!( msg.contains("compile_file") || msg.contains("--script"), @@ -1442,7 +1658,7 @@ fn compile_rejects_inline_include_with_helpful_diagnostic() { fn for_loops_plan(params: &[(String, String)]) -> gaviero_core::swarm::plan::CompiledPlan { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/for_loops.gaviero"); - gaviero_dsl::compile_file( + compile_file( &path, Some("for-loops"), Some("the release"), @@ -1535,16 +1751,15 @@ fn for_loops_parallel_inside_loop_becomes_loop_agents() { } const FOR_BASE_SRC: &str = r#" -client c { model "claude:sonnet" effort low default } -agent base { +agent base { tier t scope { owned ["out/{{t.id}}-v*.md"] } prompt "baseline {{t.id}}" } -agent rev { +agent rev { tier t scope { owned ["out/{{t.id}}-v*.md"] } prompt "review {{t.id}} v{{ITER}}" } -agent judge { prompt "VERDICT" } +agent judge { tier t prompt "VERDICT" } workflow w { execution_mode document param topics [ { id "a" } { id "b" } { id "c" } ] @@ -1562,7 +1777,7 @@ workflow w { #[test] fn for_loops_baseline_units_pair_a_for_step_with_its_loop() { let plan = - gaviero_dsl::compile_with_vars(FOR_BASE_SRC, "t.gaviero", Some("w"), None, &[], &[], &[]) + compile_with_vars(FOR_BASE_SRC, "t.gaviero", Some("w"), None, &[], &[], &[]) .expect("compiles"); let lc = plan.loop_configs.first().expect("loop config"); assert_eq!(lc.agent_ids, vec!["a-rev", "b-rev", "c-rev"]); @@ -1589,34 +1804,32 @@ fn for_loops_param_list_literal_override() { fn for_error(steps: &str, agents: &str, params: &str, document: bool) -> String { let src = format!( r#" -client c {{ model "claude:sonnet" effort low default }} -agent judge {{ prompt "VERDICT" }} +agent judge {{ tier t prompt "VERDICT" }} {agents} workflow w {{ {mode} param topics [ {{ id "a" }} {{ id "b" }} ] - param judgeparam {{ model "claude:sonnet" }} {params} steps [ {steps} ] }} "#, mode = if document { "execution_mode document" } else { "" }, ); - match gaviero_dsl::compile_with_vars(&src, "t.gaviero", Some("w"), None, &[], &[], &[]) { + match compile_with_vars(&src, "t.gaviero", Some("w"), None, &[], &[], &[]) { Ok(_) => panic!("expected a compile error for:\n{src}"), Err(e) => format!("{e:?}"), } } -const OK_AGENT: &str = r#"agent a { scope { owned ["out/{{t.id}}.md"] } prompt "x {{t.id}}" } -agent uses_judgeparam { client judgeparam prompt "j" }"#; +const OK_AGENT: &str = r#"agent a { tier t scope { owned ["out/{{t.id}}.md"] } prompt "x {{t.id}}" } +agent uses_judgeparam { tier t prompt "j" }"#; #[test] fn for_error_parallel_body_must_write_per_item_files() { let msg = for_error( "for t in topics parallel { a } uses_judgeparam", - r#"agent a { scope { owned ["out/shared.md"] } prompt "x" } -agent uses_judgeparam { client judgeparam prompt "j" }"#, + r#"agent a { tier t scope { owned ["out/shared.md"] } prompt "x" } +agent uses_judgeparam { tier t prompt "j" }"#, "", true, ); @@ -1635,8 +1848,8 @@ fn for_error_sequential_needs_document_mode() { fn for_error_unknown_item_field() { let msg = for_error( "for t in topics parallel { a } uses_judgeparam", - r#"agent a { scope { owned ["out/{{t.id}}.md"] } prompt "x {{t.nope}}" } -agent uses_judgeparam { client judgeparam prompt "j" }"#, + r#"agent a { tier t scope { owned ["out/{{t.id}}.md"] } prompt "x {{t.nope}}" } +agent uses_judgeparam { tier t prompt "j" }"#, "", true, ); @@ -1646,11 +1859,10 @@ agent uses_judgeparam { client judgeparam prompt "j" }"#, #[test] fn for_error_empty_list_from_cli() { let src = r#" -client c { model "claude:sonnet" effort low default } -agent a { scope { owned ["out/{{t.id}}.md"] } prompt "x" } +agent a { tier t scope { owned ["out/{{t.id}}.md"] } prompt "x" } workflow w { param topics [ { id "a" } ] steps [ for t in topics parallel { a } ] } "#; - let err = gaviero_dsl::compile_with_vars( + let err = compile_with_vars( src, "t.gaviero", Some("w"), @@ -1716,8 +1928,487 @@ fn for_error_sequential_inside_loop() { assert!(msg.contains("loop"), "{msg}"); } +// ── loop ordering and the one-loop rule ────────────────────────────────── + #[test] -fn for_error_over_a_client_param() { - let msg = for_error("for t in judgeparam parallel { a } uses_judgeparam", OK_AGENT, "", true); - assert!(msg.contains("not a list param"), "{msg}"); +fn loop_agent_ids_follow_intra_loop_depends_on() { + let src = r#" +agent inv { tier t scope { owned ["out/inv-v*.md"] } prompt "investigate v{{ITER}}" } +agent cur { tier t scope { owned ["out/cur-v*.md"] } depends_on [inv] prompt "curate v{{ITER}}" } +agent judge { tier t prompt "VERDICT" } +workflow w { + execution_mode document + steps [ + loop { + agents [cur inv] + max_iterations 2 + until agent judge + } + ] +} +"#; + let plan = compile_with_vars(src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .expect("compiles"); + let lc = plan.loop_configs.first().expect("loop config"); + assert_eq!(lc.agent_ids, vec!["inv", "cur"]); +} + +#[test] +fn error_two_loops_in_one_workflow() { + let src = r#" +agent a { tier t scope { owned ["out/a-v*.md"] } prompt "a v{{ITER}}" } +agent b { tier t scope { owned ["out/b-v*.md"] } prompt "b v{{ITER}}" } +agent judge { tier t prompt "VERDICT" } +workflow w { + execution_mode document + steps [ + loop { agents [a] max_iterations 2 until agent judge } + loop { agents [b] max_iterations 2 until agent judge } + ] +} +"#; + let err = compile_with_vars(src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .unwrap_err(); + let msg = format!("{err:?}"); + assert!( + msg.contains("a workflow may contain at most one `loop` block"), + "{msg}" + ); +} + +// ── `for … in json` (runtime lists) ────────────────────────────────────── + +const RUNTIME_FOR_AGENTS: &str = r#" +agent worker { tier t + scope { owned ["out/{{q.id}}.md"] } + produces ["out/{{q.id}}.md"] + prompt "MARK-{{q.id}} focus={{q.focus}}" +} +agent summary { tier t depends_on [worker] prompt "summarise" } +agent judge { tier t prompt "VERDICT" } +"#; + +fn runtime_for_compile( + workflow_body: &str, +) -> Result { + let src = format!("{RUNTIME_FOR_AGENTS}\nworkflow w {{ {workflow_body} }}\n"); + compile_with_vars(&src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .map_err(|e| format!("{e:?}")) +} + +fn runtime_for_error(workflow_body: &str) -> String { + runtime_for_compile(workflow_body).expect_err("expected a compile error") +} + +#[test] +fn runtime_for_top_level_emits_template_and_op() { + let plan = runtime_for_compile( + r#"execution_mode document + steps [ for q in json "out/items.json" parallel { worker } summary ]"#, + ) + .expect("compiles"); + let worker = unit(&plan, "worker"); + assert_eq!(worker.produces, vec!["out/{{q.id}}.md"]); + assert!(worker.coordinator_instructions.contains("MARK-{{q.id}}")); + assert_eq!(plan.runtime_fors.len(), 1); + let op = &plan.runtime_fors[0]; + assert_eq!(op.unit_id, "worker"); + assert_eq!(op.var, "q"); + assert_eq!(op.source, "out/items.json"); + assert_eq!(op.max_items, gaviero_core::swarm::plan::DEFAULT_MAX_SPAWN); + assert!(unit(&plan, "summary").depends_on.contains(&"worker".to_string())); +} + +#[test] +fn runtime_for_inside_loop_joins_loop_agents() { + let plan = runtime_for_compile( + r#"execution_mode document + steps [ loop { + for q in json "out/items-v{{PREV_ITER}}.json" parallel max 6 { worker } + max_iterations 3 + until agent judge + } ]"#, + ) + .expect("compiles"); + let lc = plan.loop_configs.first().expect("loop config"); + assert_eq!(lc.agent_ids, vec!["worker"]); + assert_eq!(plan.runtime_fors[0].source, "out/items-v{{PREV_ITER}}.json"); + assert_eq!(plan.runtime_fors[0].max_items, 6); +} + +#[test] +fn runtime_for_source_gets_compile_time_vars() { + let src = format!( + "{RUNTIME_FOR_AGENTS}\nvars {{ OUT_DIR \"research/x\" }}\nworkflow w {{ execution_mode document steps [ for q in json \"{{{{OUT_DIR}}}}/items.json\" parallel {{ worker }} ] }}\n" + ); + let plan = compile_with_vars(&src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .expect("compiles"); + assert_eq!(plan.runtime_fors[0].source, "research/x/items.json"); +} + +#[test] +fn tier_bindings_are_emitted() { + let plan = runtime_for_compile( + r#"execution_mode document + steps [ for q in json "out/items.json" parallel { worker } ]"#, + ) + .expect("compiles"); + // Every tier of the profile is emitted, so runtime items can name one. + let b = plan.tier_bindings.get("low").expect("tier low bound"); + assert_eq!(b.model.as_deref(), Some("claude:haiku")); + assert_eq!(b.effort.as_deref(), Some("low")); +} + +#[test] +fn runtime_for_error_sequential() { + let msg = runtime_for_error( + r#"execution_mode document steps [ for q in json "out/i.json" sequential { worker } ]"#, + ); + assert!(msg.contains("`for … in json` supports only `parallel`"), "{msg}"); +} + +#[test] +fn runtime_for_error_max_without_json() { + let msg = runtime_for_error( + r#"execution_mode document param topics [ { id "a" } ] + steps [ for q in topics parallel max 2 { worker } ]"#, + ); + assert!(msg.contains("`max` applies only to `for … in json`"), "{msg}"); +} + +#[test] +fn runtime_for_error_max_zero() { + let msg = runtime_for_error( + r#"execution_mode document steps [ for q in json "out/i.json" parallel max 0 { worker } ]"#, + ); + assert!(msg.contains("`max` must be at least 1"), "{msg}"); +} + +#[test] +fn runtime_for_error_peer_template() { + let msg = runtime_for_error( + r#"execution_mode document steps [ for q in json "out/i.json" parallel { worker peer_template "x" } ]"#, + ); + assert!( + msg.contains("`peer_template` is not available with `for … in json`"), + "{msg}" + ); +} + +#[test] +fn runtime_for_error_two_body_agents() { + let msg = runtime_for_error( + r#"execution_mode document steps [ for q in json "out/i.json" parallel { worker summary } ]"#, + ); + assert!(msg.contains("`for … in json` takes exactly one body agent"), "{msg}"); +} + +#[test] +fn runtime_for_error_needs_document_mode() { + let msg = runtime_for_error(r#"steps [ for q in json "out/i.json" parallel { worker } ]"#); + assert!( + msg.contains("`for … in json` requires `execution_mode document`"), + "{msg}" + ); +} + +#[test] +fn runtime_for_error_body_without_produces() { + let src = r#" +agent bare { tier t scope { owned ["out/{{q.id}}.md"] } prompt "x" } +workflow w { execution_mode document steps [ for q in json "out/i.json" parallel { bare } ] } +"#; + let msg = format!( + "{:?}", + compile_with_vars(src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .unwrap_err() + ); + assert!( + msg.contains("the body of `for … in json` must declare `produces`"), + "{msg}" + ); +} + +#[test] +fn runtime_for_error_inside_stacked_loop() { + let msg = runtime_for_error( + r#"execution_mode document steps [ loop { + for q in json "out/i.json" parallel { worker } + branch_chain stacked + until agent judge + } ]"#, + ); + assert!( + msg.contains("`for … in json` cannot run inside a `branch_chain stacked` loop"), + "{msg}" + ); +} + +#[test] +fn map_reduce_requires_document_mode() { + let src = r#" +agent d { tier t prompt "discover" } +agent r { tier t depends_on [d] prompt "reduce" } +workflow w { + steps [d r] + pattern map_reduce { discover d reduce r max_spawn 4 } +} +"#; + let msg = format!( + "{:?}", + compile_with_vars(src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .unwrap_err() + ); + assert!( + msg.contains("`pattern map_reduce` requires `execution_mode document`"), + "{msg}" + ); +} + +// ── budget { wall usd } ────────────────────────────────────────────────── + +fn budget_compile(block: &str) -> Result { + let src = format!( + "agent a {{ tier t prompt \"x\" }}\nworkflow w {{ steps [a] {block} }}\n" + ); + compile_with_vars(&src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .map_err(|e| format!("{e:?}")) +} + +#[test] +fn budget_block_compiles() { + let plan = budget_compile(r#"budget { wall "8h" usd 40 }"#).expect("compiles"); + let b = plan.budget.expect("budget"); + assert_eq!(b.wall_secs, Some(28800)); + assert_eq!(b.usd, Some(40.0)); +} + +#[test] +fn budget_usd_float() { + let plan = budget_compile(r#"budget { usd 12.5 }"#).expect("compiles"); + let b = plan.budget.expect("budget"); + assert_eq!(b.usd, Some(12.5)); + assert_eq!(b.wall_secs, None); +} + +#[test] +fn budget_wall_units() { + let secs = |w: &str| { + budget_compile(&format!("budget {{ wall \"{w}\" }}")) + .expect("compiles") + .budget + .unwrap() + .wall_secs + }; + assert_eq!(secs("90s"), Some(90)); + assert_eq!(secs("30m"), Some(1800)); + assert_eq!(secs("45"), Some(45)); + assert!(budget_compile("").unwrap().budget.is_none()); +} + +#[test] +fn budget_error_bad_duration() { + let msg = budget_compile(r#"budget { wall "eight hours" }"#).unwrap_err(); + assert!( + msg.contains(r#"`wall` takes a duration like \"90s\", \"30m\" or \"8h\""#) + || msg.contains("`wall` takes a duration like"), + "{msg}" + ); +} + +#[test] +fn budget_error_usd_not_positive() { + let msg = budget_compile(r#"budget { usd 0 }"#).unwrap_err(); + assert!(msg.contains("`usd` must be positive"), "{msg}"); +} + +#[test] +fn budget_error_empty() { + let msg = budget_compile(r#"budget { }"#).unwrap_err(); + assert!(msg.contains("`budget` needs `wall` or `usd`"), "{msg}"); +} + +// ── produces json ──────────────────────────────────────────────────────── + +#[test] +fn produces_json_compiles_into_both_lists() { + let src = r#" +vars { OUT_DIR "research/x" } +agent a { tier t + scope { owned ["{{OUT_DIR}}/*"] } + produces ["{{OUT_DIR}}/report.md"] + produces json ["{{OUT_DIR}}/frontier-v{{ITER}}.json"] + prompt "x" +} +workflow w { steps [a] } +"#; + let plan = compile_with_vars(src, "t.gaviero", Some("w"), None, &[], &[], &[]) + .expect("compiles"); + let a = unit(&plan, "a"); + assert_eq!( + a.produces, + vec!["research/x/report.md", "research/x/frontier-v{{ITER}}.json"] + ); + assert_eq!(a.produces_json, vec!["research/x/frontier-v{{ITER}}.json"]); +} + +// ── examples/deep_explore.gaviero ──────────────────────────────────────── + +/// The `{{name}}` placeholders of a text, without the braces. +fn regex_lite_placeholders() -> impl Fn(&str) -> Vec { + |text: &str| { + let mut out = Vec::new(); + let mut rest = text; + while let Some(start) = rest.find("{{") { + let after = &rest[start + 2..]; + match after.find("}}") { + Some(end) => { + out.push(after[..end].to_string()); + rest = &after[end + 2..]; + } + None => break, + } + } + out + } +} + +#[test] +fn example_deep_explore_compiles() { + // The script names no provider: models come from the profile, here the + // shipped `mixed` one (high = claude:opus, medium = codex terra), the way + // a run's implicit `default` profile fills its tiers. + let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples"); + let script = dir.join("deep_explore.gaviero"); + let profile = gaviero_core::script_profiles::SelectedProfile { + name: "default".into(), + path: dir.join("profiles/mixed.gaviero"), + precedence: gaviero_core::script_profiles::ProfilePrecedence::FillsGaps, + }; + let plan = gaviero_dsl::compile_file_with_profile(&script, Some(&profile), None, None, &[], &[], &[]) + .unwrap_or_else(|e| panic!("compiling deep_explore.gaviero:\n{e:?}")); + // Without a profile no tier is bound: the script declares none of its own. + assert!(gaviero_dsl::compile_file(&script, None, None, &[], &[], &[]).is_err()); + + // The only input is the run prompt (SWARM form Prompt box / --prompt): + // no file var for the form to ask for. + let inspection = gaviero_dsl::inspect_file(&script).expect("inspect"); + assert!(inspection.requires_prompt); + let vars: Vec<&str> = inspection.vars.iter().map(|v| v.name.as_str()).collect(); + assert_eq!(vars, ["OUT_DIR", "COLLECTION", "ACADEMIC_SERVER", "FALSIFY_TIER"]); + // Every agent declares its tier; the form learns which ones the profile + // must define. + assert_eq!(inspection.tiers, ["high", "top", "medium"]); + let with_prompt = gaviero_dsl::compile_file_with_profile( + &script, Some(&profile), None, Some("Map the failure modes of X."), &[], &[], &[], + ) + .expect("compile with a prompt"); + let curator_prompt = &with_prompt + .work_units_unordered() + .into_iter() + .find(|u| u.id == "curator") + .expect("curator") + .coordinator_instructions; + assert!(curator_prompt.contains("Map the failure modes of X."), "{curator_prompt}"); + // Every placeholder left after compiling is one the runtime fills: + // the loop pass or a runtime `for` item. A typo would reach the agent. + let runtime_placeholder = regex_lite_placeholders(); + for u in with_prompt + .work_units_unordered() + .into_iter() + .chain(with_prompt.loop_judge_units.iter()) + { + for found in runtime_placeholder(&u.coordinator_instructions) { + assert!( + found == "ITER" || found == "PREV_ITER" || found.starts_with("q."), + "unresolved {{{{{found}}}}} in {}", + u.id + ); + } + } + assert!(curator_prompt.contains("`academic` MCP server"), "{curator_prompt}"); + + let model = |id: &str| -> String { + plan.work_units_unordered() + .into_iter() + .chain(plan.loop_judge_units.iter()) + .find(|u| u.id == id) + .and_then(|u| u.model.clone()) + .unwrap_or_else(|| panic!("no model for {id}")) + }; + assert_eq!(model("scout"), "claude:opus", "tier high"); + assert_eq!(model("curator"), "claude:fable", "tier top"); + assert_eq!(model("investigator"), "claude:opus", "tier high"); + assert_eq!(model("synthesize"), "claude:fable", "tier top"); + // The auditors declare `tier medium`: another family than the + // investigators under this profile. + assert_eq!(model("verifier"), "codex:gpt-6.1-terra", "tier medium"); + assert_eq!(model("citation_check"), "codex:gpt-6.1-terra", "tier medium"); + assert!(plan.tier_bindings.contains_key("high"), "runtime items can name tier high"); + + // `--tier` moves one auditor for a run; the others keep their tier. + let moved = gaviero_dsl::compile_file_with_profile( + &script, + Some(&profile), + None, + None, + &[], + &[("verifier".to_string(), "top".to_string())], + &[], + ) + .expect("compile with --tier verifier=top"); + let verifier = moved + .work_units_unordered() + .into_iter() + .find(|u| u.id == "verifier") + .and_then(|u| u.model.clone()); + assert_eq!(verifier.as_deref(), Some("claude:fable")); + assert_eq!( + moved.loop_judge_units[0].model.as_deref(), + Some("codex:gpt-6.1-terra") + ); + + assert_eq!(plan.runtime_fors.len(), 1); + let op = &plan.runtime_fors[0]; + assert_eq!(op.unit_id, "investigator"); + assert_eq!(op.source, "research/explore/assignments-v{{ITER}}.json"); + assert_eq!(op.max_items, 6); + + let lc = plan.loop_configs.first().expect("loop config"); + // Dependency order inside every pass: curate → investigate → audit. + assert_eq!(lc.agent_ids, vec!["curator", "investigator", "verifier"]); + + let budget = plan.budget.as_ref().expect("budget"); + assert_eq!(budget.usd, Some(60.0)); + assert_eq!(budget.wall_secs, Some(10 * 3600)); + assert_eq!( + plan.execution_mode, + gaviero_core::swarm::plan::ExecutionMode::Document + ); + // `tier medium`: a different family from the curator under this + // profile, and movable per run with --tier stop_judge=…. + assert_eq!(model("stop_judge"), "codex:gpt-6.1-terra", "tier medium"); + + let curator = unit(&plan, "curator"); + assert_eq!(curator.produces_json.len(), 2); + assert_eq!( + unit(&plan, "verifier").produces_json, + vec!["research/explore/audit-v{{ITER}}.json"] + ); + assert_eq!( + unit(&plan, "scout").produces_json, + vec!["research/explore/landscape.json"] + ); + + // The shape the runtime launches: scope validation as `execute` runs it. + let units = plan.work_units_ordered().expect("toposort"); + let groups = gaviero_core::swarm::validation::add_baseline_units_to_loop_groups( + gaviero_core::swarm::validation::expand_loop_groups_with_roster_init( + plan.loop_configs.iter().map(|lc| lc.agent_ids.clone()).collect(), + &units.iter().map(|u| u.id.as_str()).collect::>(), + ), + &plan.loop_configs, + ); + let errors = gaviero_core::swarm::validation::validate_scopes(&units, &groups); + assert!(errors.is_empty(), "{errors:?}"); } diff --git a/crates/gaviero-dsl/tests/fixtures/test-profile.gaviero b/crates/gaviero-dsl/tests/fixtures/test-profile.gaviero new file mode 100644 index 00000000..95aac19f --- /dev/null +++ b/crates/gaviero-dsl/tests/fixtures/test-profile.gaviero @@ -0,0 +1,18 @@ +// Model profile for the DSL tests. Scripts name tiers only; this file says +// what each tier means. +// +// `t` maps to a client with no model: the unit compiles with `model = None` +// and runs on the workspace default model, the case most tests do not care +// about. + +client blank { } +client opus { tier coordinator model "claude-opus-4-7" privacy public } +client sonnet { tier execution model "claude-sonnet-4-6" } +client haiku { model "claude:haiku" effort low privacy public } +client local { model "ollama:qwen" privacy local_only } + +tier t blank +tier opus opus +tier sonnet sonnet +tier low haiku +tier local local diff --git a/crates/gaviero-dsl/tests/loop_resume_contract.rs b/crates/gaviero-dsl/tests/loop_resume_contract.rs index 9c8b34e8..bd0dbd61 100644 --- a/crates/gaviero-dsl/tests/loop_resume_contract.rs +++ b/crates/gaviero-dsl/tests/loop_resume_contract.rs @@ -33,18 +33,28 @@ fn unit_map<'a>(units: &[&'a WorkUnit]) -> HashMap<&'a str, &'a WorkUnit> { units.iter().map(|u| (u.id.as_str(), *u)).collect() } +/// The model profile shipped with the examples. +fn profile() -> gaviero_core::script_profiles::SelectedProfile { + gaviero_core::script_profiles::SelectedProfile { + name: "default".into(), + path: example("profiles/default.gaviero"), + precedence: gaviero_core::script_profiles::ProfilePrecedence::FillsGaps, + } +} + /// Compile `plan_refinement.gaviero` the way the operator's CLI invocation /// did, with a three-provider roster and a relocated `OUT_DIR`. fn compile_plan_refinement(out_dir: &str) -> gaviero_core::swarm::plan::CompiledPlan { - gaviero_dsl::compile_file( + gaviero_dsl::compile_file_with_profile( &example("plan_refinement.gaviero"), + Some(&profile()), Some("feature-plan-refinement"), Some("feature brief"), &[("OUT_DIR".to_string(), out_dir.to_string())], &[], &[( "roster".to_string(), - "claude=claude:opus@max,codex=codex:gpt-5.5@high,cursor=cursor:composer-2.5@high" + "claude=top-claude,codex=high-codex,cursor=high-cursor" .to_string(), )], ) @@ -199,8 +209,9 @@ fn scientific_research_resume_suppresses_the_init_round() { } write(tmp.path(), &format!("{out_dir}/problem.md"), "# problem"); - let plan = gaviero_dsl::compile_file( + let plan = gaviero_dsl::compile_file_with_profile( &example("scientific_research.gaviero"), + Some(&profile()), Some("scientific-research-consensus"), Some("research topic"), &[ @@ -210,7 +221,7 @@ fn scientific_research_resume_suppresses_the_init_round() { &[], &[( "roster".to_string(), - "claude=claude:opus@max,codex=codex:gpt-5.5@high".to_string(), + "claude=top-claude,codex=high-codex".to_string(), )], ) .expect("scientific_research.gaviero compiles"); diff --git a/crates/gaviero-dsl/tests/profiles.rs b/crates/gaviero-dsl/tests/profiles.rs index 705a9993..d9a58924 100644 --- a/crates/gaviero-dsl/tests/profiles.rs +++ b/crates/gaviero-dsl/tests/profiles.rs @@ -1,4 +1,8 @@ //! Model profiles: one provider-agnostic script, many sets of models. +//! +//! A profile is the only place a tier gets a model. A script names tiers: +//! every agent declares one, a workflow's `tiers { }` block or `--tier` +//! moves an agent to another, and a list item's `tier` moves its clone. use std::collections::HashMap; use std::fs; @@ -40,12 +44,14 @@ fn chosen(path: PathBuf) -> SelectedProfile { } } -fn implicit(path: PathBuf) -> SelectedProfile { - SelectedProfile { - name: "default".into(), - path, - precedence: ProfilePrecedence::FillsGaps, - } +fn compile_with( + script: &Path, + profile: Option<&SelectedProfile>, + agent_tiers: &[(String, String)], + params: &[(String, String)], +) -> Result { + compile_file_with_profile(script, profile, None, None, &[], agent_tiers, params) + .map_err(|report| format!("{report:?}")) } fn compile( @@ -53,8 +59,7 @@ fn compile( profile: Option<&SelectedProfile>, params: &[(String, String)], ) -> Result { - compile_file_with_profile(script, profile, None, None, &[], &[], params) - .map_err(|report| format!("{report:?}")) + compile_with(script, profile, &[], params) } /// (model, effort) of every unit, by id. @@ -71,6 +76,10 @@ fn model_of(plan: &CompiledPlan, id: &str) -> String { models(plan)[id].0.clone().expect("unit has a model") } +fn pair(model: &str, effort: &str) -> (Option, Option) { + (Some(model.into()), Some(effort.into())) +} + #[test] fn the_same_script_runs_on_different_providers_per_profile() { let dir = tempfile::tempdir().unwrap(); @@ -79,24 +88,12 @@ fn the_same_script_runs_on_different_providers_per_profile() { let mixed = chosen(write(dir.path(), "mixed.gaviero", MIXED_PROFILE)); let on_claude = models(&compile(&script, Some(&claude), &[]).unwrap()); - assert_eq!( - on_claude["worker"], - (Some("claude:haiku".into()), Some("low".into())) - ); - assert_eq!( - on_claude["planner"], - (Some("claude:fable".into()), Some("max".into())) - ); + assert_eq!(on_claude["worker"], pair("claude:haiku", "low")); + assert_eq!(on_claude["planner"], pair("claude:fable", "max")); let on_mixed = models(&compile(&script, Some(&mixed), &[]).unwrap()); - assert_eq!( - on_mixed["worker"], - (Some("dsh:deepseek-flash".into()), Some("high".into())) - ); - assert_eq!( - on_mixed["planner"], - (Some("codex:gpt-6-astra".into()), Some("xhigh".into())) - ); + assert_eq!(on_mixed["worker"], pair("dsh:deepseek-flash", "high")); + assert_eq!(on_mixed["planner"], pair("codex:gpt-6-astra", "xhigh")); } #[test] @@ -104,102 +101,55 @@ fn a_tier_nothing_binds_says_how_to_fix_it() { let dir = tempfile::tempdir().unwrap(); let script = write(dir.path(), "s.gaviero", AGNOSTIC_SCRIPT); let error = compile(&script, None, &[]).unwrap_err(); - assert!(error.contains("undefined tier alias"), "{error}"); - assert!(error.contains("profile"), "{error}"); -} + assert!(error.contains("no model profile is bound"), "{error}"); + assert!(error.contains("--profile"), "{error}"); -#[test] -fn a_chosen_profile_replaces_the_scripts_own_binding() { - let dir = tempfile::tempdir().unwrap(); - let script = write( + let partial = chosen(write( dir.path(), - "s.gaviero", - r#" - client pinned { model "claude:sonnet" } - tier low pinned - agent worker { tier low prompt "w" } - "#, - ); - let profile = chosen(write(dir.path(), "p.gaviero", CLAUDE_PROFILE)); - let plan = compile(&script, Some(&profile), &[]).unwrap(); - assert_eq!(model_of(&plan, "worker"), "claude:haiku"); -} - -#[test] -fn the_implicit_default_only_fills_what_the_script_leaves_open() { - let dir = tempfile::tempdir().unwrap(); - let script = write( - dir.path(), - "s.gaviero", - r#" - client pinned { model "claude:sonnet" } - tier low pinned - agent worker { tier low prompt "w" } - agent planner { tier top prompt "p" } - "#, - ); - let profile = implicit(write(dir.path(), "default.gaviero", CLAUDE_PROFILE)); - let plan = compile(&script, Some(&profile), &[]).unwrap(); - assert_eq!(model_of(&plan, "worker"), "claude:sonnet", "script keeps its tier"); - assert_eq!(model_of(&plan, "planner"), "claude:fable", "profile fills the gap"); + "p.gaviero", + "client small { model \"claude:haiku\" }\ntier low small\n", + )); + let error = compile(&script, Some(&partial), &[]).unwrap_err(); + assert!(error.contains("uses tier `top`"), "{error}"); + assert!(error.contains("it defines: low"), "{error}"); } +/// A script cannot choose a model itself: no clients, no tier lines, no +/// agent bound to a client — so a profile can never be shadowed. #[test] -fn a_concrete_client_binding_is_left_alone() { +fn a_script_cannot_declare_its_own_models() { let dir = tempfile::tempdir().unwrap(); - let script = write( - dir.path(), - "s.gaviero", - r#" - client pinned { model "claude:sonnet" } - agent worker { client pinned prompt "w" } - "#, - ); let profile = chosen(write(dir.path(), "p.gaviero", CLAUDE_PROFILE)); - let plan = compile(&script, Some(&profile), &[]).unwrap(); - assert_eq!(model_of(&plan, "worker"), "claude:sonnet"); -} - -#[test] -fn profile_and_script_may_use_the_same_client_names() { - let dir = tempfile::tempdir().unwrap(); - let script = write( - dir.path(), - "s.gaviero", - r#" - client small { model "codex:gpt-5.5" } - agent pinned { client small prompt "p" } - agent worker { tier low prompt "w" } - "#, - ); - let profile = chosen(write(dir.path(), "p.gaviero", CLAUDE_PROFILE)); - let plan = compile(&script, Some(&profile), &[]).unwrap(); - assert_eq!(model_of(&plan, "pinned"), "codex:gpt-5.5"); - assert_eq!(model_of(&plan, "worker"), "claude:haiku"); + for (body, needle) in [ + ( + "client pinned { model \"claude:sonnet\" }\nagent worker { tier low prompt \"w\" }\n", + "cannot declare `client pinned`", + ), + ( + "tier low small\nagent worker { tier low prompt \"w\" }\n", + "cannot declare `tier low small`", + ), + ("agent worker { client small prompt \"w\" }\n", "found 'client'"), + ] { + let script = write(dir.path(), "s.gaviero", body); + let error = compile(&script, Some(&profile), &[]).unwrap_err(); + assert!(error.contains(needle), "{body}: {error}"); + } } +/// With every agent declaring a tier, a `default` client means nothing; a +/// profile that marks one is told so. #[test] -fn profile_default_client_covers_unbound_agents() { +fn a_profile_default_client_is_rejected() { let dir = tempfile::tempdir().unwrap(); - let body = r#" - client main { model "claude:opus" default } - tier high main - "#; - let script = write( + let script = write(dir.path(), "s.gaviero", AGNOSTIC_SCRIPT); + let profile = chosen(write( dir.path(), - "s.gaviero", - r#" - client own { model "claude:sonnet" default } - agent worker { prompt "w" } - "#, - ); - let path = write(dir.path(), "p.gaviero", body); - - let plan = compile(&script, Some(&chosen(path.clone())), &[]).unwrap(); - assert_eq!(model_of(&plan, "worker"), "claude:opus", "chosen profile wins"); - - let plan = compile(&script, Some(&implicit(path)), &[]).unwrap(); - assert_eq!(model_of(&plan, "worker"), "claude:sonnet", "script default stays"); + "p.gaviero", + "client small { model \"claude:haiku\" default }\nclient big { model \"claude:opus\" }\ntier low small\ntier top big\n", + )); + let error = compile(&script, Some(&profile), &[]).unwrap_err(); + assert!(error.contains("marked `default`"), "{error}"); } #[test] @@ -223,7 +173,7 @@ fn a_profile_is_only_a_model_table() { let profile = chosen(write( dir.path(), "p.gaviero", - r#"client c { model "claude:opus" } tier low c agent stray { prompt "x" }"#, + r#"client c { model "claude:opus" } tier low c agent stray { tier t prompt "x" }"#, )); let error = compile(&script, Some(&profile), &[]).unwrap_err(); assert!(error.contains("only declare"), "{error}"); @@ -232,11 +182,7 @@ fn a_profile_is_only_a_model_table() { #[test] fn a_profile_tier_must_use_the_profiles_own_client() { let dir = tempfile::tempdir().unwrap(); - let script = write( - dir.path(), - "s.gaviero", - "client theirs { model \"claude:opus\" }\nagent w { client theirs prompt \"p\" }\n", - ); + let script = write(dir.path(), "s.gaviero", AGNOSTIC_SCRIPT); let profile = chosen(write(dir.path(), "p.gaviero", "tier low theirs\n")); let error = compile(&script, Some(&profile), &[]).unwrap_err(); assert!(error.contains("does not declare"), "{error}"); @@ -255,8 +201,11 @@ fn examples() -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")).join("examples") } +/// `tiered_review.gaviero` uses all three ways a tier is chosen: an agent's +/// own tier (`gather`, the reviewer template), the workflow's `tiers { }` +/// block (`verdict`) and a roster item's tier (`second`). #[test] -fn shipped_profiles_drive_the_agnostic_example_through_params_and_roster() { +fn shipped_profiles_drive_the_agnostic_example() { let script = examples().join("tiered_review.gaviero"); let expectations = [ ("claude", "claude:haiku", "claude:sonnet", "claude:opus", "claude:fable"), @@ -267,54 +216,39 @@ fn shipped_profiles_drive_the_agnostic_example_through_params_and_roster() { let profile = chosen(examples().join("profiles").join(format!("{name}.gaviero"))); let plan = compile(&script, Some(&profile), &[]).unwrap(); assert_eq!(model_of(&plan, "gather"), low, "{name}: agent tier"); - assert_eq!(model_of(&plan, "verdict"), medium, "{name}: client param"); - assert_eq!(model_of(&plan, "first-refine"), high, "{name}: roster"); - assert_eq!(model_of(&plan, "second-refine"), top, "{name}: roster"); + assert_eq!(model_of(&plan, "verdict"), medium, "{name}: workflow tiers block"); + assert_eq!(model_of(&plan, "first-refine"), high, "{name}: template tier"); + assert_eq!(model_of(&plan, "second-refine"), top, "{name}: item tier"); } } +/// A run moves an agent with `--tier` and a roster item with `--param`; +/// both name tiers, never models. #[test] -fn param_overrides_can_move_an_agent_to_another_tier_or_a_concrete_model() { +fn a_run_moves_agents_and_items_by_tier() { let script = examples().join("tiered_review.gaviero"); let profile = chosen(examples().join("profiles/claude.gaviero")); - let params = vec![ - ("judge".to_string(), "tier:top".to_string()), - ("panel".to_string(), "only=tier:low,pinned=codex:gpt-5.5@high".to_string()), - ]; - let plan = compile(&script, Some(&profile), ¶ms).unwrap(); - assert_eq!(model_of(&plan, "verdict"), "claude:fable"); + let tiers = vec![("verdict".to_string(), "top".to_string())]; + let params = vec![("panel".to_string(), "only=low,plain".to_string())]; + let plan = compile_with(&script, Some(&profile), &tiers, ¶ms).unwrap(); + assert_eq!(model_of(&plan, "verdict"), "claude:fable", "--tier beats the block"); assert_eq!(model_of(&plan, "only-refine"), "claude:haiku"); - assert_eq!(model_of(&plan, "pinned-refine"), "codex:gpt-5.5"); -} - -#[test] -fn a_tier_param_cannot_also_set_effort() { - let script = examples().join("tiered_review.gaviero"); - let profile = chosen(examples().join("profiles/claude.gaviero")); - - let client = vec![("judge".to_string(), "tier:top@low".to_string())]; - let error = compile(&script, Some(&profile), &client).unwrap_err(); - assert!(error.contains("cannot be combined"), "{error}"); - - let roster = vec![("panel".to_string(), "a=tier:top@low".to_string())]; - let error = compile(&script, Some(&profile), &roster).unwrap_err(); - assert!(error.contains("cannot be combined"), "{error}"); -} + assert_eq!(model_of(&plan, "plain-refine"), "claude:opus", "template tier"); -#[test] -fn a_misspelled_effort_in_a_param_override_is_rejected() { - let script = examples().join("tiered_review.gaviero"); - let profile = chosen(examples().join("profiles/claude.gaviero")); - let params = vec![("judge".to_string(), "claude:opus@hgih".to_string())]; - let error = compile(&script, Some(&profile), ¶ms).unwrap_err(); - assert!(error.contains("unknown effort `hgih`"), "{error}"); + for bad in ["only=tier:low", "pinned=codex:gpt-5.5@high"] { + let params = vec![("panel".to_string(), bad.to_string())]; + let error = compile(&script, Some(&profile), ¶ms).unwrap_err(); + assert!(error.contains("id="), "{bad}: {error}"); + } } -fn preflight(body: &str) -> Result<(), String> { +/// A profile client's model + effort pair is checked when a run starts. +fn preflight(profile: &str, script: &str) -> Result<(), String> { let dir = tempfile::tempdir().unwrap(); - let script = write(dir.path(), "s.gaviero", body); - let plan = compile(&script, None, &[]).expect("compiles: the check is at run start"); + let profile = chosen(write(dir.path(), "p.gaviero", profile)); + let script = write(dir.path(), "s.gaviero", script); + let plan = compile(&script, Some(&profile), &[]).expect("compiles: the check is at run start"); gaviero_core::swarm::pipeline::preflight_plan_models(&plan, "claude:sonnet", None) .map_err(|e| e.to_string()) } @@ -328,9 +262,10 @@ fn a_wrong_model_and_effort_pair_never_starts() { ("cursor:grok-4.7-high", "high", "model id"), ("ollama:llama3", "high", "does not use effort"), ] { - let error = preflight(&format!( - "client c {{ model \"{model}\" effort {effort} default }}\nagent worker {{ prompt \"p\" }}\n" - )) + let error = preflight( + &format!("client c {{ model \"{model}\" effort {effort} }}\ntier x c\n"), + "agent worker { tier x prompt \"p\" }\n", + ) .unwrap_err(); assert!(error.contains(expected), "{model} {effort}: {error}"); assert!(error.contains("agent 'worker'"), "names the agent: {error}"); @@ -345,69 +280,55 @@ fn a_right_pair_and_choosing_no_level_both_start() { ("cursor:grok-4.7-high", "auto"), ("ollama:llama3", "off"), ] { - preflight(&format!( - "client c {{ model \"{model}\" effort {effort} default }}\nagent worker {{ prompt \"p\" }}\n" - )) + preflight( + &format!("client c {{ model \"{model}\" effort {effort} }}\ntier x c\n"), + "agent worker { tier x prompt \"p\" }\n", + ) .unwrap_or_else(|e| panic!("{model} {effort}: {e}")); } } #[test] -fn an_unused_wrong_client_in_a_shared_pool_does_not_block_a_run() { +fn an_unused_wrong_tier_in_a_profile_does_not_block_a_run() { preflight( "client unused { model \"cursor:composer-2.5\" effort high }\n\ - client used { model \"claude:opus\" effort high default }\n\ - agent worker { prompt \"p\" }\n", + client used { model \"claude:opus\" effort high }\n\ + tier spare unused\n\ + tier main used\n", + "agent worker { tier main prompt \"p\" }\n", ) .unwrap(); } #[test] -fn a_roster_entry_is_checked_too() { +fn a_roster_item_tier_is_checked_too() { let error = preflight( - "client j { model \"claude:opus\" default }\n\ - agent tpl { template true prompt \"p\" }\n\ - agent judge { prompt \"j\" }\n\ - workflow w { steps [ loop { reviewers [ { id \"a\" model \"dsh:deepseek-flash\" effort medium } ] template_refine tpl until agent judge max_iterations 1 } ] }\n", + "client j { model \"claude:opus\" }\n\ + client bad { model \"dsh:deepseek-flash\" effort medium }\n\ + tier main j\n\ + tier flawed bad\n", + "agent tpl { tier main template true prompt \"p\" }\n\ + agent judge { tier main prompt \"j\" }\n\ + workflow w { steps [ loop { reviewers [ { id \"a\" tier flawed } ] template_refine tpl until agent judge max_iterations 1 } ] }\n", ) .unwrap_err(); assert!(error.contains("agent 'a-refine'"), "{error}"); } #[test] -fn a_tier_param_needs_a_tier_name() { - let script = examples().join("tiered_review.gaviero"); - let profile = chosen(examples().join("profiles/claude.gaviero")); - let params = vec![("judge".to_string(), "tier:".to_string())]; - let error = compile(&script, Some(&profile), ¶ms).unwrap_err(); - assert!(error.contains("needs a tier name"), "{error}"); -} - -#[test] -fn the_form_shows_tier_params_in_override_syntax() { +fn the_form_shows_list_params_in_override_syntax() { let inspection = gaviero_dsl::inspect_file(&examples().join("tiered_review.gaviero")).unwrap(); let params = &inspection.workflows[0].params; - let default_of = |name: &str| { - params - .iter() - .find(|p| p.name == name) - .and_then(|p| p.default.clone()) - }; - assert_eq!(default_of("judge").as_deref(), Some("tier:medium")); - assert_eq!( - default_of("panel").as_deref(), - Some("first=tier:high,second=tier:top") - ); + assert_eq!(params.len(), 1, "params are lists only"); + assert_eq!(params[0].name, "panel"); + assert_eq!(params[0].default.as_deref(), Some("first,second=top")); + assert_eq!(inspection.tiers, ["low", "high", "medium", "top"]); } #[test] -fn compile_file_still_works_with_no_profile() { +fn compile_file_without_a_profile_names_the_fix() { let dir = tempfile::tempdir().unwrap(); - let script = write( - dir.path(), - "s.gaviero", - "client c { model \"claude:opus\" default }\nagent w { prompt \"p\" }\n", - ); - let plan = gaviero_dsl::compile_file(&script, None, None, &[], &[], &[]).unwrap(); - assert_eq!(model_of(&plan, "w"), "claude:opus"); + let script = write(dir.path(), "s.gaviero", "agent w { tier low prompt \"p\" }\n"); + let error = gaviero_dsl::compile_file(&script, None, None, &[], &[], &[]).unwrap_err(); + assert!(format!("{error:?}").contains("no model profile is bound"), "{error:?}"); } diff --git a/crates/gaviero-dsl/tests/swarm_contract.rs b/crates/gaviero-dsl/tests/swarm_contract.rs index 3d58af22..f6c73091 100644 --- a/crates/gaviero-dsl/tests/swarm_contract.rs +++ b/crates/gaviero-dsl/tests/swarm_contract.rs @@ -14,28 +14,42 @@ //! `crates/gaviero-core/tests/swarm_execute_validation.rs`. The two //! files together pin the symmetry from both directions. +use gaviero_core::script_profiles::{ProfilePrecedence, SelectedProfile}; use gaviero_core::swarm::validation; +/// The profile shipped with the examples: generic tiers low / medium / +/// high / top, as a `--coordinated` plan finds in a `default` profile. +fn profile() -> SelectedProfile { + SelectedProfile { + name: "default".into(), + path: std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("examples/profiles/default.gaviero"), + precedence: ProfilePrecedence::FillsGaps, + } +} + +fn compile(src: &str, filename: &str) -> Result { + gaviero_dsl::compile(src, filename, Some(&profile()), None, None) +} + #[test] fn dsl_compiled_plan_passes_swarm_validate_scopes() { let src = r#" - client base { tier cheap model "claude:sonnet" } agent reader { description "read" - client base + tier medium scope { owned ["docs/"] read_only ["src/"] } } agent writer { description "write" - client base + tier medium depends_on [reader] scope { owned ["src/feature/"] read_only ["docs/"] } } workflow w { steps [reader writer] } "#; - let plan = gaviero_dsl::compile(src, "t4.gaviero", None, None) - .expect("DSL should compile this two-agent workflow"); + let plan = compile(src, "t4.gaviero").expect("DSL should compile this two-agent workflow"); let units = plan.work_units_ordered().expect("toposort"); assert_eq!(units.len(), 2); @@ -57,8 +71,9 @@ fn dsl_compiled_plan_passes_swarm_validate_scopes() { fn scientific_research_roster_passes_swarm_scope_validation() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("examples/scientific_research.gaviero"); - let plan = gaviero_dsl::compile_file( + let plan = gaviero_dsl::compile_file_with_profile( &path, + Some(&profile()), Some("scientific-research-consensus"), Some("test topic"), &[], @@ -92,22 +107,21 @@ fn dsl_does_not_catch_scope_overlap_swarm_validator_does() { // If a future change moves the check into the DSL, flip this test // to expect a compile-time error and update CLAUDE.md to match. let src = r#" - client base { tier cheap model "claude:sonnet" } agent a { description "a" - client base + tier medium scope { owned ["src/"] } } agent b { description "b" - client base + tier medium scope { owned ["src/"] } } workflow w { steps [a b] } "#; // DSL accepts the source. - let plan = gaviero_dsl::compile(src, "t4-overlap.gaviero", None, None) + let plan = compile(src, "t4-overlap.gaviero") .expect("DSL accepts overlap today (validation lives in swarm runtime)"); let units = plan.work_units_ordered().expect("toposort"); assert_eq!(units.len(), 2); @@ -133,40 +147,27 @@ fn dsl_does_not_catch_scope_overlap_swarm_validator_does() { /// T5 — Coordinator-emitted DSL shape compiles cleanly through the DSL /// pipeline. `swarm::coordinator::build_coordinator_dsl_prompt` instructs /// the model to produce a `.gaviero` workflow with this exact structure -/// (clients with `tier ` + `model`, `agent { description, client, scope, -/// depends_on, prompt #"..."# }` blocks, `workflow main { steps [...] }`). -/// If the prompt template ever drifts past what `gaviero_dsl::compile` -/// accepts, this test catches it at the DSL crate boundary instead of at -/// coordinator runtime. +/// (`agent { description, tier , scope, depends_on, +/// produces, timeout, prompt #"..."#, max_retries }` blocks, no clients, +/// `workflow main { steps [...] }`). If the prompt template ever drifts past +/// what `gaviero_dsl::compile` accepts, this test catches it at the DSL +/// crate boundary instead of at coordinator runtime. /// -/// The verified contract: compile → topo-sort → swarm scope/dependency -/// validation must all succeed for a representative coordinator output. -/// -/// Client names are free identifiers; the coordinator's "use `reasoning`, -/// `execution`, `mechanical` as client names" instruction is broken -/// against the lexer (those are reserved tier-value keywords). See the -/// `coordinator_prompt_uses_reserved_tier_words_as_client_names` test -/// below for the regression that pins that contract bug. +/// The verified contract: compile (against the run's profile) → topo-sort → +/// swarm scope/dependency validation must all succeed for a representative +/// coordinator output. #[test] fn coordinator_dsl_template_compiles_and_passes_swarm_validation() { - // Mirror the structural shape `build_coordinator_dsl_prompt` instructs - // the model to emit: - // - one client per tier - // - agents with description, client, scope { owned, read_only }, - // depends_on, prompt #" "#, max_retries - // - workflow main { steps [...] max_parallel } let src = r##" - client opus { tier expensive model "claude:opus" } - client sonnet { tier cheap model "claude:sonnet" } - client haiku { tier cheap model "claude:haiku" } - agent designer { description "Design the new module structure" - client opus + tier high scope { owned ["docs/design.md"] read_only ["src/"] } + produces ["docs/design.md"] + timeout 1800 prompt #" Read the existing code under src/ and produce a one-page design doc describing the new module layout. @@ -176,7 +177,7 @@ fn coordinator_dsl_template_compiles_and_passes_swarm_validation() { agent implementer { description "Implement the module per the design" - client sonnet + tier medium depends_on [designer] scope { owned ["src/feature/"] @@ -190,7 +191,7 @@ fn coordinator_dsl_template_compiles_and_passes_swarm_validation() { agent renamer { description "Update call sites for the rename" - client haiku + tier low depends_on [implementer] scope { owned ["src/api/"] @@ -208,12 +209,14 @@ fn coordinator_dsl_template_compiles_and_passes_swarm_validation() { } "##; - let plan = gaviero_dsl::compile(src, "coordinator-template.gaviero", None, None) + let plan = compile(src, "coordinator-template.gaviero") .expect("DSL must accept the coordinator's emit shape"); let units = plan.work_units_ordered().expect("toposort"); assert_eq!(units.len(), 3, "expected 3 work units"); assert_eq!(plan.max_parallel, Some(2)); + assert_eq!(units[0].model.as_deref(), Some("claude:opus"), "tier high"); + assert_eq!(units[2].model.as_deref(), Some("claude:haiku"), "tier low"); // Scope validation matches what `pipeline::execute` runs. let loop_groups = validation::expand_loop_groups_with_roster_init( @@ -245,21 +248,19 @@ fn coordinator_dsl_template_compiles_and_passes_swarm_validation() { #[test] fn coordinator_dsl_independent_agents_collapse_to_one_tier() { let src = r##" - client sonnet { tier cheap model "claude:sonnet" } - agent a { description "a" - client sonnet + tier medium scope { owned ["src/a/"] } } agent b { description "b" - client sonnet + tier medium scope { owned ["src/b/"] } } agent c { description "c" - client sonnet + tier medium scope { owned ["src/c/"] } } @@ -269,8 +270,7 @@ fn coordinator_dsl_independent_agents_collapse_to_one_tier() { } "##; - let plan = - gaviero_dsl::compile(src, "coordinator-parallel.gaviero", None, None).expect("DSL compile"); + let plan = compile(src, "coordinator-parallel.gaviero").expect("DSL compile"); let units = plan.work_units_ordered().expect("toposort"); let tiers = validation::dependency_tiers(&units).expect("tiers"); assert_eq!( @@ -281,39 +281,26 @@ fn coordinator_dsl_independent_agents_collapse_to_one_tier() { assert_eq!(tiers[0].len(), 3); } -/// Regression: pins the contract bug between -/// `swarm::coordinator::build_coordinator_dsl_prompt` and the DSL lexer. -/// -/// The coordinator's prompt template tells the model: -/// ``` -/// CLIENT NAMES to use: -/// - `reasoning` for reasoning-tier agents -/// - `execution` for execution-tier agents -/// - `mechanical` for mechanical-tier agents -/// ``` -/// but the DSL lexer reserves `reasoning`, `execution`, and `mechanical` -/// as tier-value keywords, so a model that follows the instructions -/// produces DSL the parser rejects. Until the prompt is fixed, swarm -/// `--coordinated` runs that obey the prompt are doomed to a parse error. -/// -/// This test asserts the failure today (the DSL rejects `client reasoning`) -/// so a future fix to the prompt → grammar contract surfaces here as a -/// failure-to-failure (the test would pass — flipping the assertion is -/// the signal to also delete this regression). +/// The plan the coordinator emits never declares clients: a plan that does +/// fails to compile, so the template must keep teaching `tier` only. #[test] -fn coordinator_prompt_uses_reserved_tier_words_as_client_names() { +fn a_coordinator_plan_with_clients_does_not_compile() { let src = r#" - client reasoning { tier expensive model "claude:opus" } + client deep { model "claude:opus" } agent a { description "a" - client reasoning - scope { owned ["src/a/"] } + tier high + scope { owned ["out/"] } + produces ["out/a.md"] + timeout 600 } "#; - let result = gaviero_dsl::compile(src, "regression.gaviero", None, None); - assert!( - result.is_err(), - "DSL still rejects `client reasoning` — if this test starts to pass, \ - the lexer or prompt has been fixed; remove this regression." - ); + let err = compile(src, "coordinator-names.gaviero").unwrap_err(); + assert!(format!("{err:?}").contains("cannot declare `client deep`"), "{err:?}"); + + let plan = compile(&src.replace(r#"client deep { model "claude:opus" }"#, ""), "c.gaviero") + .expect("the same plan without the client compiles"); + let units = plan.work_units_ordered().expect("toposort"); + assert_eq!(units[0].produces, vec!["out/a.md".to_string()]); + assert_eq!(units[0].timeout_secs, 600); } diff --git a/crates/gaviero-tui/src/app/swarm_run.rs b/crates/gaviero-tui/src/app/swarm_run.rs index 126d8626..18d1a5bb 100644 --- a/crates/gaviero-tui/src/app/swarm_run.rs +++ b/crates/gaviero-tui/src/app/swarm_run.rs @@ -862,18 +862,14 @@ fn active_tiers(app: &App) -> Vec { let root = &form.folders[form.selected_folder()].1; let canonical = std::fs::canonicalize(root).unwrap_or_else(|_| root.clone()); let repo = gaviero_core::memory::scope::hash_path(&canonical); - let mut tiers = ProfileCatalog::scan(&app.workspace, &ScriptCatalog::global_scripts_dir()) + // Only the profile defines tiers; the script merely names them, so a + // name the profile lacks would not compile and is not offered. + ProfileCatalog::scan(&app.workspace, &ScriptCatalog::global_scripts_dir()) .select(form.selected_profile().as_deref(), Some(&repo), root) .ok() .flatten() .and_then(|profile| gaviero_dsl::profile_tier_names(&profile.path).ok()) - .unwrap_or_default(); - for tier in &form.inspection.tiers { - if !tiers.contains(tier) { - tiers.push(tier.clone()); - } - } - tiers + .unwrap_or_default() } /// Bring the focused field's popup up to date after its text changed. @@ -1409,14 +1405,9 @@ mod tests { use std::time::Duration; const SCRIPT: &str = r#"// description: Write one report -client local { - model "ollama:qwen" - privacy public -} - agent writer { description "write the report" - client local + tier local scope { owned ["{{OUT_DIR}}/report.md"] } produces ["{{OUT_DIR}}/report.md"] prompt "Write the report about {{PROMPT}}." @@ -1512,6 +1503,18 @@ workflow run { let script_dir = dir.join(".gaviero/dsl/report"); std::fs::create_dir_all(&script_dir).unwrap(); std::fs::write(script_dir.join("report.gaviero"), source).unwrap(); + // Scripts name tiers only; the workspace's `default` profile says + // `local` is the fake Ollama. A test that writes its own profiles + // keeps them alone. + let profiles = dir.join(".gaviero/dsl/profiles"); + if !profiles.exists() { + std::fs::create_dir_all(&profiles).unwrap(); + std::fs::write( + profiles.join("default.gaviero"), + "client local { model \"ollama:qwen\" privacy public }\ntier local local\n", + ) + .unwrap(); + } std::fs::write( dir.join(".gaviero/settings.json"), serde_json::json!({ @@ -1659,7 +1662,7 @@ workflow run { open_filled_form(&mut app); std::fs::write( root.join(".gaviero/dsl/report/report.gaviero"), - "agent writer { client missing prompt \"x\" }\n", + "agent writer { tier missing prompt \"x\" }\n", ) .unwrap(); press_run(&mut app); @@ -1747,13 +1750,8 @@ workflow run { assert_eq!(app.swarm_dashboard.view, SwarmView::Run, "the last run can be reopened"); } - const FILE_SCRIPT: &str = r#"client local { - model "ollama:qwen" - privacy public -} - -agent writer { - client local + const FILE_SCRIPT: &str = r#"agent writer { + tier local scope { owned ["report.md"] } produces ["report.md"] prompt "Summarize {{BRIEF}}." @@ -1769,14 +1767,10 @@ workflow run { } "#; - const ROSTER_SCRIPT: &str = r#"client c { - model "ollama:qwen" - privacy public -} -agent worker { client c prompt "w" } -agent judge { client c prompt "j" } + const ROSTER_SCRIPT: &str = r#"agent worker { tier local prompt "w" } +agent judge { tier local prompt "j" } workflow run { - param panel [ { id "a" model "tier:low" } ] + param panel [ { id "a" tier low } ] steps [ loop { agents [worker] reviewers panel until agent judge } judge ] } "#; @@ -2029,7 +2023,9 @@ workflow run { open_panel(&mut app); handle_action(&mut app, Action::Enter); - // Profile selector first: auto -> fast. + // The form opens on the first input; go up to the Profile + // selector: auto -> fast. + app.swarm_dashboard.form.as_mut().unwrap().focus_field("Profile"); handle_action(&mut app, Action::CursorRight); handle_action(&mut app, Action::Tab); for _ in 0.."low".len() { @@ -2037,12 +2033,12 @@ workflow run { } assert_eq!( completion_matches(&app), - vec!["tier:quick".to_string(), "tier:deep".to_string()] + vec!["quick".to_string(), "deep".to_string()] ); handle_action(&mut app, Action::CursorDown); handle_action(&mut app, Action::Enter); - assert_eq!(field_text(&app, "panel"), "a=tier:deep"); + assert_eq!(field_text(&app, "panel"), "a=deep"); // Same field, the other profile. handle_action(&mut app, Action::CursorUp); @@ -2051,7 +2047,7 @@ workflow run { for _ in 0.."deep".len() { handle_action(&mut app, Action::Backspace); } - assert_eq!(completion_matches(&app), vec!["tier:glacial".to_string()]); + assert_eq!(completion_matches(&app), vec!["glacial".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -2062,19 +2058,19 @@ workflow run { open_panel(&mut app); handle_action(&mut app, Action::Enter); app.swarm_dashboard.form.as_mut().unwrap().focus_field("panel"); - assert_eq!(field_text(&app, "panel"), "a=tier:low"); + assert_eq!(field_text(&app, "panel"), "a=low"); // Alt+Enter: a new item below; typing fills it. handle_action(&mut app, Action::AltEnter); - type_text(&mut app, "b=ollama:x"); - assert_eq!(field_text(&app, "panel"), "a=tier:low,b=ollama:x"); + type_text(&mut app, "b=mid"); + assert_eq!(field_text(&app, "panel"), "a=low,b=mid"); // Backspace on an emptied item removes it and returns to the one above. handle_action(&mut app, Action::AltEnter); handle_action(&mut app, Action::Backspace); - assert_eq!(field_text(&app, "panel"), "a=tier:low,b=ollama:x"); + assert_eq!(field_text(&app, "panel"), "a=low,b=mid"); type_text(&mut app, "y"); - assert_eq!(field_text(&app, "panel"), "a=tier:low,b=ollama:xy"); + assert_eq!(field_text(&app, "panel"), "a=low,b=midy"); // Mouse: `x` removes the first item, `+` appends an empty one. let area = ratatui::layout::Rect::new(0, 0, 60, 20); @@ -2091,12 +2087,12 @@ workflow run { .unwrap_or_else(|| panic!("{needle} not drawn:\n{}", screen.join("\n"))) }; let (plus_x, plus_y) = at("(list) +"); - let (x_x, x_y) = at("x a=tier:low"); + let (x_x, x_y) = at("x a=low"); click(&mut app, x_x, x_y); - assert_eq!(field_text(&app, "panel"), "b=ollama:xy"); + assert_eq!(field_text(&app, "panel"), "b=midy"); click(&mut app, plus_x + "(list) ".len() as u16, plus_y); type_text(&mut app, "c"); - assert_eq!(field_text(&app, "panel"), "b=ollama:xy,c"); + assert_eq!(field_text(&app, "panel"), "b=midy,c"); } /// Open the form with a repo skill named `lint` available. diff --git a/crates/gaviero-tui/src/panels/swarm_dashboard.rs b/crates/gaviero-tui/src/panels/swarm_dashboard.rs index d0033048..f996a039 100644 --- a/crates/gaviero-tui/src/panels/swarm_dashboard.rs +++ b/crates/gaviero-tui/src/panels/swarm_dashboard.rs @@ -204,7 +204,7 @@ pub enum ListTarget { } /// A list param's value split into items, each in `--param` syntax: -/// `id=provider:model[@effort]`, `id`, or `{id "a" focus "x"}` when the entry +/// `id=tier`, `id`, or `{id "a" focus "x"}` when the entry /// has free fields. pub fn split_list_value(value: &str) -> Vec { let value = value.trim(); @@ -226,11 +226,8 @@ fn list_item_text(entry: &ReviewerEntry) -> String { if !entry.fields.is_empty() { return list_literal_entry(entry); } - match &entry.model { - Some(model) => match &entry.effort { - Some((effort, _)) => format!("{}={model}@{effort}", entry.id), - None => format!("{}={model}", entry.id), - }, + match &entry.tier { + Some((tier, _)) => format!("{}={tier}", entry.id), None => entry.id.clone(), } } @@ -313,7 +310,6 @@ impl FormField { } let kind = match self.role { FieldRole::Param(ParamKindInfo::Roster) => " (list)", - FieldRole::Param(ParamKindInfo::Client) => " (model)", FieldRole::File => " (file)", FieldRole::Dir => " (folder)", _ => "", @@ -328,9 +324,8 @@ impl FormField { FieldRole::Profile => "Which models the script's tiers use. ←/→ to change", FieldRole::Prompt => "Alt+Enter new line Alt+↑↓ resize $skill @file", FieldRole::Param(ParamKindInfo::Roster) => { - "id=provider:model[@effort] · id · {id \"…\" key \"…\"} Alt+Enter/+ add x or ⌫ on empty removes" + "id=tier · id · {id \"…\" key \"…\"} Alt+Enter/+ add x or ⌫ on empty removes" } - FieldRole::Param(ParamKindInfo::Client) => "provider:model[@effort] or tier:", FieldRole::Var => "Script variable. Empty leaves it unset", FieldRole::File => "An existing file. Type to search, as with @ in chat", FieldRole::Dir => "A folder. Type to search the workspace", @@ -442,6 +437,7 @@ impl SwarmForm { list_hits: Vec::new(), }; form.fields = form.build_fields(selected_folder, 0, 0); + form.focus = form.first_input_field(); form } @@ -449,9 +445,21 @@ impl SwarmForm { pub fn with_profiles(mut self, profiles: Vec) -> Self { self.profiles = profiles; self.fields = self.build_fields(self.selected_folder(), self.selected_workflow(), 0); + self.focus = self.first_input_field(); self } + /// The first field to type into. The Folder / Workflow / Profile + /// selectors above it start on a usable choice, and every script run + /// needs a profile, so the form opens on the Prompt (or first input) + /// rather than on a selector. + fn first_input_field(&self) -> usize { + self.fields + .iter() + .position(|f| !matches!(f.value, FieldValue::Choice { .. })) + .unwrap_or(0) + } + fn build_fields(&self, folder: usize, workflow: usize, profile: usize) -> Vec { let mut fields = Vec::new(); if self.folders.len() > 1 { @@ -502,11 +510,7 @@ impl SwarmForm { } if let Some(wf) = self.inspection.workflows.get(workflow) { for param in &wf.params { - let build = match param.kind { - ParamKindInfo::Roster => FormField::list_field, - ParamKindInfo::Client => FormField::text_field, - }; - fields.push(build( + fields.push(FormField::list_field( ¶m.name, FieldRole::Param(param.kind), param.default.clone(), @@ -796,12 +800,8 @@ impl SwarmForm { (FieldRole::File | FieldRole::Dir, Some(input)) => { prompt_input::update_path_autocomplete(input, &mut self.completion); } - (FieldRole::Param(kind), Some(input)) => { - prompt_input::update_tier_autocomplete( - input, - &mut self.completion, - kind == ParamKindInfo::Roster, - ); + (FieldRole::Param(_), Some(input)) => { + prompt_input::update_tier_autocomplete(input, &mut self.completion); } _ => self.completion.reset(), } @@ -2369,7 +2369,7 @@ mod tests { fn param(name: &str, default: Option<&str>) -> ParamInspection { ParamInspection { name: name.into(), - kind: ParamKindInfo::Client, + kind: ParamKindInfo::Roster, default: default.map(str::to_string), } } @@ -2414,7 +2414,7 @@ mod tests { fn untouched_defaults_are_not_passed_as_overrides() { let mut form = SwarmForm::new( row(), - inspection(vec![workflow("w", vec![param("judge", Some("claude:opus"))])]), + inspection(vec![workflow("w", vec![param("judge", Some("a=high"))])]), folders(), 1, ); @@ -2432,16 +2432,16 @@ mod tests { fn edited_values_are_passed_and_empty_undeclared_vars_are_not() { let mut form = SwarmForm::new( row(), - inspection(vec![workflow("w", vec![param("judge", Some("claude:opus"))])]), + inspection(vec![workflow("w", vec![param("judge", Some("a=high"))])]), folders(), 0, ); type_into(&mut form, "Prompt", "p"); - type_into(&mut form, "judge", "codex:x@low"); + type_into(&mut form, "judge", "a=low-codex"); type_into(&mut form, "OUT_DIR", "elsewhere"); let values = form.collect().unwrap(); - assert_eq!(values.params, vec![("judge".to_string(), "codex:x@low".to_string())]); + assert_eq!(values.params, vec![("judge".to_string(), "a=low-codex".to_string())]); assert_eq!(values.vars, vec![("OUT_DIR".to_string(), "elsewhere".to_string())]); } @@ -2464,8 +2464,8 @@ mod tests { let mut form = SwarmForm::new( row(), inspection(vec![ - workflow("one", vec![param("only_one", Some("a:b"))]), - workflow("two", vec![param("only_two", Some("c:d"))]), + workflow("one", vec![param("only_one", Some("a=low"))]), + workflow("two", vec![param("only_two", Some("b=high"))]), ]), folders(), 0, @@ -2871,7 +2871,7 @@ mod tests { let screen = render_rows(&mut dash, 60, 24).join("\n"); assert!(screen.contains("audit"), "{screen}"); assert!(screen.contains("Prompt *"), "{screen}"); - assert!(screen.contains("gate (model) *"), "{screen}"); + assert!(screen.contains("gate * (list)"), "{screen}"); assert!(screen.contains("OUT_DIR"), "{screen}"); assert!(screen.contains("Run"), "{screen}"); assert!(screen.contains("gate is required"), "{screen}"); @@ -2917,23 +2917,23 @@ mod tests { #[test] fn list_values_split_into_items_and_join_back() { - assert_eq!(split_list_value("a=claude:opus@high, b ,c"), ["a=claude:opus@high", "b", "c"]); + assert_eq!(split_list_value("a=high-claude, b ,c"), ["a=high-claude", "b", "c"]); assert_eq!( split_list_value(TOPICS), [r#"{id "a" focus "storage"}"#, r#"{id "b" focus "network"}"#] ); assert_eq!( - split_list_value(r#"[{id "a" model "codex:x" effort low}]"#), - ["a=codex:x@low"], + split_list_value(r#"[{id "a" tier low-codex}]"#), + ["a=low-codex"], "an entry without free fields reads in the short form" ); assert!(split_list_value("").is_empty()); - assert_eq!(join_list_items(&["a=codex:x", "", " b "]), "a=codex:x,b"); - let mixed = join_list_items(&[r#"{id "a" focus "x"}"#, "b=codex:y@low"]); - assert_eq!(mixed, r#"[{id "a" focus "x"} {id "b" model "codex:y" effort "low"}]"#); + assert_eq!(join_list_items(&["a=high", "", " b "]), "a=high,b"); + let mixed = join_list_items(&[r#"{id "a" focus "x"}"#, "b=low-codex"]); + assert_eq!(mixed, r#"[{id "a" focus "x"} {id "b" tier low-codex}]"#); let back = parse_reviewers_override(&mixed).unwrap(); - assert_eq!(back[1].effort.as_ref().unwrap().0, "low"); + assert_eq!(back[1].tier.as_ref().unwrap().0, "low-codex"); } #[test] From 78ed85e584b6111a32978bfe3165a734a82cb386 Mon Sep 17 00:00:00 2001 From: Ignacio Martin Date: Mon, 16 Nov 2026 12:36:59 +0100 Subject: [PATCH 2/6] Document tier-only scripts and rewrite examples around profiles Docs and example scripts drop client blocks and tier bindings in favor of per-agent tiers, and a single default model profile replaces the old client roster and doc profiles. A new deep_explore example shows the runtime for and budget features. --- ARCHITECTURE.md | 9 +- CLAUDE.md | 4 +- README.md | 22 +- crates/gaviero-cli/ARCHITECTURE.md | 8 +- crates/gaviero-cli/CLAUDE.md | 4 +- crates/gaviero-cli/README.md | 8 +- crates/gaviero-dsl/ARCHITECTURE.md | 58 ++++-- crates/gaviero-dsl/CLAUDE.md | 21 +- crates/gaviero-dsl/README.md | 195 ++++++++++++------ crates/gaviero-dsl/examples/clients.gaviero | 93 --------- .../examples/codebase_review.gaviero | 26 +-- crates/gaviero-dsl/examples/for_loops.gaviero | 12 +- .../examples/generic_consensus.gaviero | 22 +- .../examples/mcp_smoke_test.gaviero | 35 +--- .../examples/pattern_map_reduce.gaviero | 16 +- .../gaviero-dsl/examples/phased_plan.gaviero | 18 +- .../examples/plan_refinement.gaviero | 24 +-- .../examples/profiles/doc-claude.gaviero | 10 - .../examples/profiles/doc-codex.gaviero | 6 - crates/gaviero-tui/CLAUDE.md | 2 +- 20 files changed, 271 insertions(+), 322 deletions(-) delete mode 100644 crates/gaviero-dsl/examples/clients.gaviero delete mode 100644 crates/gaviero-dsl/examples/profiles/doc-claude.gaviero delete mode 100644 crates/gaviero-dsl/examples/profiles/doc-codex.gaviero diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index f5d5f5f9..820dc826 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -53,9 +53,9 @@ Terminal editor + headless CLI for AI agent orchestration. Rust 2024. `acp`, `agent_session` (+ `tool_agent/`), `context_planner`, `diff_engine`, `git`, `git_conflict`, `history`, `indent`, `iteration`, `mcp`, `memory`, `observer`, `path_pattern`, `query_loader`, `repo_map` (+ topology / symbol enrichment), `scope_enforcer`, `session_state`, `skills`, `swarm` (+ backends incl. `deepseek`), `terminal`, `tree_sitter`, `types`, `util`, `validation_gate`, `workspace`, `write_gate`. -### DSL (9) — [`lib.rs`](crates/gaviero-dsl/src/lib.rs) +### DSL (11) — [`lib.rs`](crates/gaviero-dsl/src/lib.rs) -`ast`, `compiler`, `reviewers`, `workflow_params`, `error`, `lexer`, `parser`, `resolver`, `tiers`. +`ast`, `compiler`, `reviewers`, `workflow_params`, `error`, `lexer`, `parser`, `resolver`, `profile`, `patterns`, `inspect`. A script names tiers only; the model profile (`profile.rs`) is the one place a tier becomes a model. ### Other crates @@ -165,10 +165,9 @@ pub use ::tree_sitter::{Language, Parser, Tree, Node, Query, QueryCursor, Point, // gaviero-dsl pub fn compile(...) -> Result; -pub fn compile_with_vars(..., override_vars, override_tiers, override_params) -> …; -pub fn compile_file(..., override_vars, override_tiers, override_params) -> …; +pub fn compile_with_vars(source, filename, profile, ..., override_vars, agent_tiers, override_params) -> …; +pub fn compile_file_with_profile(path, profile, ..., override_vars, agent_tiers, override_params) -> …; pub fn workflow_execution_mode(...) -> Result; -pub use tiers::load_tier_overrides; ``` Binaries expose no library API. diff --git a/CLAUDE.md b/CLAUDE.md index 198d790c..dd195bb4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,7 +42,7 @@ Subprocess coding agents (Claude Code, Codex, Cursor) reach core's in-process MC `.gaviero-workspace` files (any basename, fixed extension) describe multi-folder workspaces; bare directories are treated as single-folder workspaces — a bare directory holding a workspace file first asks whether to open that workspace instead (`--folder` skips the question). Dispatched at TUI startup in [crates/gaviero-tui/src/main.rs](crates/gaviero-tui/src/main.rs). `gaviero --workspace ` opens the workspace file already in ``, or has the first-run wizard ([crates/gaviero-tui/src/setup.rs](crates/gaviero-tui/src/setup.rs)) build `.gaviero-workspace` from the sub-folders the user picks. That setup screen is the only place initial configuration is authored — it runs before `App` exists, at every launch while the target has no `.gaviero/settings.json` (a folder's own, or the one beside an opened `.gaviero-workspace` file — the workspace layer), and offers: editor-only (preselected, also Esc — writes nothing; `App::enter_editor_only` hides the side panel and skips agents, memory, code graph, MCP, remote and the root `.cursor`/`.cursorignore` writes), minimal (`{}`), or full — a byte-for-byte copy of the global `$GAVIERO_ROOT/.gaviero/settings.json`, or gaviero's built-in full settings when that file does not exist. Workspaces get the same three choices for that one workspace-layer file, which every member inherits; `--workspace` on a directory without a workspace file first picks the members and writes it (editor-only then writes just the workspace file). A `gaviero-cli` run never creates `.gaviero/settings.json`: it finds the workspace the TUI would open by walking up from its run root ([crates/gaviero-cli/src/state.rs](crates/gaviero-cli/src/state.rs)) and shares its memory, or runs on throwaway state with `--isolated` (also the fallback when no workspace is found). -Scripts stay provider-agnostic by asking for a tier (`agent { tier high }`, `param x { model "tier:high" }`). **Model profiles** say what each tier means for a run: `.gaviero/dsl/profiles/.gaviero` holds only `client` + `tier` declarations (discovered like scripts — [crates/gaviero-core/src/script_profiles.rs](crates/gaviero-core/src/script_profiles.rs); merged in [crates/gaviero-dsl/src/profile.rs](crates/gaviero-dsl/src/profile.rs)). Chosen with `gaviero-cli --profile ` or the SWARM form; with no choice a profile named `default` fills only the tiers the script leaves open. Older per-script tier overrides still load via `gaviero-cli --tiers-file ` (`tier ` lines only — [crates/gaviero-dsl/src/tiers.rs](crates/gaviero-dsl/src/tiers.rs)). +Scripts choose models in one way only: by tier. Every agent declares its default tier (`agent { tier high }`); a workflow's `tiers { }` block moves agents in that workflow, `gaviero-cli --tier =` moves one for a run (beating the block), and a list item's `tier` moves its clone. Scripts never declare `client` blocks, `tier ` lines or model-valued params. **Model profiles** are the one place a tier becomes a model: `.gaviero/dsl/profiles/.gaviero` holds only `client` + `tier` declarations (discovered like scripts — [crates/gaviero-core/src/script_profiles.rs](crates/gaviero-core/src/script_profiles.rs); merged in [crates/gaviero-dsl/src/profile.rs](crates/gaviero-dsl/src/profile.rs)). Chosen with `gaviero-cli --profile ` or the SWARM form; with no choice the profile named `default` is used. Shipped example: [crates/gaviero-dsl/examples/profiles/default.gaviero](crates/gaviero-dsl/examples/profiles/default.gaviero). ### Agent Runtime Parity @@ -59,7 +59,7 @@ All interactive coding providers — Claude Code, Codex, Cursor, Ollama, DeepSee - **Model spec is `provider:model`.** Bare names are rejected at dispatch (`validate_model_spec`, [crates/gaviero-core/src/swarm/backend/shared.rs](crates/gaviero-core/src/swarm/backend/shared.rs)). Prefixes: `claude:`, `codex:`, `cursor:`, `ollama:`, `local:`, `deepseek:`, `dsh:`. - **Lock discipline.** Never hold a `Mutex` across I/O, parsing, or embedding. The memory `writer` task is the single owner of SQLite writes. - **Two-layer graph context.** The pre-prompt assembler injects `` (shallow filesystem-only folder map, [crates/gaviero-core/src/repo_map/topology.rs](crates/gaviero-core/src/repo_map/topology.rs)) plus `` (PageRank-ranked code outline). The TUI `/lite` chat command drops `` + memory + impact and keeps only topology. -- **Plan production.** When drafting implementation plans for other agents, assume Claude Code (`claude:fable` / `claude:opus`) or Codex (`codex:gpt-5.6-sol`) unless the user will implement themselves. Plans must be agent-executable: concrete work units, ownership boundaries, expected files/modules, verification steps, sequencing constraints. Example client roster: [crates/gaviero-dsl/examples/clients.gaviero](crates/gaviero-dsl/examples/clients.gaviero). Drafting is separate from *consuming*: a stored plan binds only while it is being executed — see the `plans/` rule under Rules. +- **Plan production.** When drafting implementation plans for other agents, assume Claude Code (`claude:fable` / `claude:opus`) or Codex (`codex:gpt-5.6-sol`) unless the user will implement themselves. Plans must be agent-executable: concrete work units, ownership boundaries, expected files/modules, verification steps, sequencing constraints. Example model profile (clients per tier): [crates/gaviero-dsl/examples/profiles/default.gaviero](crates/gaviero-dsl/examples/profiles/default.gaviero). Drafting is separate from *consuming*: a stored plan binds only while it is being executed — see the `plans/` rule under Rules. ## Rules diff --git a/README.md b/README.md index 413169c8..f7abb5d1 100644 --- a/README.md +++ b/README.md @@ -115,22 +115,16 @@ review src/auth/session.rs for race conditions **DSL workflow** (`review.gaviero`): ```gaviero -client sonnet { tier cheap model "claude:sonnet" effort low default } -client opus { tier expensive model "claude:opus" effort high } - -tier cheap sonnet -tier expensive opus - agent reviewer { description "Review the PR and identify issues" - client opus + tier high scope { read_only ["src/" "tests/"] } prompt "Review {{PROMPT}} and list all bugs and style issues." } agent fixer { description "Fix all issues found by the reviewer" - client sonnet + tier medium depends_on [reviewer] scope { owned ["src/" "tests/"] impact_scope true } prompt "Fix every issue in the reviewer's list." @@ -142,8 +136,20 @@ workflow review_and_fix { } ``` +A script names tiers only; a model profile (`.gaviero/dsl/profiles/default.gaviero`, see [the shipped one](crates/gaviero-dsl/examples/profiles/default.gaviero)) says which model each tier is: + +```gaviero +client sonnet { model "claude:sonnet" effort medium privacy public } +client opus { model "claude:opus" effort high privacy public } + +tier medium sonnet +tier high opus +``` + ```bash gaviero-cli --script review.gaviero --prompt "the auth module" +gaviero-cli --script review.gaviero --prompt "the auth module" --tier fixer=high # one agent, one run +gaviero-cli --script review.gaviero --prompt "the auth module" --profile codex # every model at once ``` **Skills** — turn-scoped instruction templates under `.gaviero/skills//SKILL.md`, invoked in chat with `$skill-name`. They are found in each folder's `.gaviero/skills/`, in the workspace's — the `.gaviero/skills/` beside the `.gaviero-workspace` file, also for a one-folder workspace or a member folder opened on its own — and in the global `$GAVIERO_ROOT/.gaviero/skills/` (folder beats workspace beats global). Adding or removing a skill is picked up while gaviero runs, even when the `skills/` directory is created after launch. Use `/skills` to list or `/skills search ` for semantic discovery; `/skills` also lists every folder it scanned and each skill it could not load, with the reason (a missing `description`, a frontmatter `name` that differs from the folder name, a folder name outside `A-Za-z0-9_-`). `SKILL.md` may be any letter case, start with a BOM, and use YAML block values (`description: >`). Optional `skills.extraRoots` (array of paths, default `[]`, `~` expanded) adds foreign roots such as `~/.claude/skills` or `~/.codex/skills`; a missing configured root is a chat warning, not a silent skip. diff --git a/crates/gaviero-cli/ARCHITECTURE.md b/crates/gaviero-cli/ARCHITECTURE.md index 9e4526b6..91331d89 100644 --- a/crates/gaviero-cli/ARCHITECTURE.md +++ b/crates/gaviero-cli/ARCHITECTURE.md @@ -99,10 +99,10 @@ parse Cli ├─ plan input: │ --task → synthetic WorkUnit (owned=["."]) │ --work-units → Vec JSON - │ --script → gaviero_dsl::compile_file(..., override_vars, - │ override_tiers, override_params) + │ --script → gaviero_dsl::compile_file_with_profile(..., profile, + │ override_vars, agent_tiers, override_params) │ + --workflow / --prompt / --prompt-file - │ + --var / --param / --tiers-file + │ + --var / --param / --tier / --profile │ ├─ iteration overlays (--max-retries, --attempts, --test-first, --no-iterate) ├─ --coordinated? → plan_coordinated → write .gaviero → exit @@ -151,7 +151,7 @@ Binary only — no library API. Public surface is the CLI: --repo / --workspace --task | --work-units | --script --workflow --prompt --prompt-file ---var KEY=VALUE --param NAME=VALUE --tiers-file +--var KEY=VALUE --param NAME=VALUE --tier AGENT=TIER --profile NAME|PATH --model --coordinator-model --ollama-base-url --auto-accept --resume --fresh --isolated --max-parallel --max-retries --attempts --test-first --no-iterate diff --git a/crates/gaviero-cli/CLAUDE.md b/crates/gaviero-cli/CLAUDE.md index 62f748f4..99332516 100644 --- a/crates/gaviero-cli/CLAUDE.md +++ b/crates/gaviero-cli/CLAUDE.md @@ -39,7 +39,7 @@ Full user-facing flag tables: [README.md](README.md). Do not duplicate every fie - **stdout = results, stderr = telemetry.** Observers always log to stderr. - **Model spec:** `provider:model` required. Accepted prefixes include `claude:`, `codex:`, `cursor:`, `ollama:`, `local:`, `deepseek:`, `dsh:` ([`validate_model_spec`](../gaviero-core/src/swarm/backend/shared.rs)). Default: workspace `agent.model`, then `claude:sonnet`. - **`--repo` vs `--workspace`:** `execution repo` vs `execution document` ([`workflow_execution_mode`](../gaviero-dsl/src/lib.rs)). Conflicts with each other; `--workspace` defaults to the plan file's directory when `--var PLAN_FILE=...` is set. -- **DSL precedence.** Tiers: `--tiers-file` or `--profile` (mutually exclusive) > script/includes > the implicit `default` profile. Vars: agent-level > `--var` > script-level. Params: `--param` (see [`workflow_params`](../gaviero-dsl/src/workflow_params.rs)). +- **DSL precedence.** Models: `--profile` (else the profile named `default`) says what each tier means; an agent's tier is `--tier AGENT=TIER` > the workflow's `tiers { }` > its own `tier`. Vars: agent-level > `--var` > script-level. Params: `--param` (see [`workflow_params`](../gaviero-dsl/src/workflow_params.rs)). - **State follows the TUI.** [`state::discover`](src/state.rs) walks the run root and its parents for `.gaviero/settings.json` or `.gaviero/memory.db` (never `$HOME`) and honours a `*.gaviero-workspace` listing that folder. Runs share that workspace's memory (`MemoryStores::open` at its state root, configured embedder, repo scope = the member folder containing the run root). `--isolated`, or no workspace found, means throwaway memory/graph/telemetry in a temp dir; settings are still read, skills are off, and synthesized agent configs are restored at exit. Admin commands require a discovered workspace; `--history` / `--mcp-stats` fall back to the run root. - **Never build a code graph for one root into another root's DB.** A build deletes every file it did not scan. A run from a workspace folder uses the graph the TUI keeps for that folder; subfolder runs use `/.gaviero/graphs//` (`RunState::graph_db`). - **Memory ops open the same `MemoryServices`** as the TUI; never bypass the writer task. @@ -49,7 +49,7 @@ Full user-facing flag tables: [README.md](README.md). Do not duplicate every fie - **Never add a flag without adding the field on `Cli` first.** Docs trail the struct. - **Never write directly to a file.** Synthetic-task mode still goes through the Write Gate (`AutoAccept` when `--auto-accept`). -- **Tier overrides only contain `tier` lines.** [`load_tier_overrides`](../gaviero-dsl/src/tiers.rs) rejects other items. +- **Models come from tiers only.** There is no `--tiers-file` and no model-valued `--param`; do not add one. `--param` values are list items (`id=tier`). - **Always validate the model spec via core** — do not re-parse prefixes in CLI code. - **Never document `--no-memory`.** It does not exist on `Cli`. diff --git a/crates/gaviero-cli/README.md b/crates/gaviero-cli/README.md index dc6d8209..7083b90a 100644 --- a/crates/gaviero-cli/README.md +++ b/crates/gaviero-cli/README.md @@ -151,9 +151,9 @@ No public library API. The `Cli` struct in `src/main.rs` is authoritative; this | `--prompt` | `` | Inline text replacing every `{{PROMPT}}` (requires `--script`) | | `--prompt-file` | `` | File contents replacing every `{{PROMPT}}` (requires `--script`) | | `--var` | `KEY=VALUE` | Override a `vars {}` entry (repeatable, requires `--script`) | -| `--param` | `NAME=VALUE` | Supply a workflow `param` (repeatable, requires `--script`) | -| `--profile` | `` | Model profile from `.gaviero/dsl/profiles/` or a file path (`client` + `tier` only; requires `--script`; conflicts with `--tiers-file`) | -| `--tiers-file` | `` | Tier overrides (`tier ` lines only; requires `--script`) | +| `--param` | `NAME=VALUE` | Supply a workflow list `param`: `id=tier,…`, ids, or a list literal (repeatable, requires `--script`) | +| `--profile` | `` | Model profile from `.gaviero/dsl/profiles/` or a file path (`client` + `tier` only; requires `--script`); default: the profile named `default` | +| `--tier` | `AGENT=TIER` | Run one agent on another tier; beats the workflow's `tiers { }` entry (repeatable; requires `--script`) | | `--coordinated` | — | Emit a reviewable plan and exit (requires `--task`) | | `--output` | `` | Save the generated plan (`--coordinated` only) | @@ -204,7 +204,7 @@ instead of overwriting it** — no flag required: gaviero-cli --script crates/gaviero-dsl/examples/plan_refinement.gaviero \ --workflow feature-plan-refinement \ --prompt-file brief.md --var OUT_DIR=plans/my-feature \ - --param roster=claude=claude:opus@max,codex=codex:gpt-5.6-sol@high + --param roster=claude=top-claude,codex=high-codex # Same command again: detects v3, resumes at v4 reading the v3 plans ``` diff --git a/crates/gaviero-dsl/ARCHITECTURE.md b/crates/gaviero-dsl/ARCHITECTURE.md index 29c2f2bb..d82bce4f 100644 --- a/crates/gaviero-dsl/ARCHITECTURE.md +++ b/crates/gaviero-dsl/ARCHITECTURE.md @@ -9,28 +9,31 @@ Conventions: [CLAUDE.md](CLAUDE.md). Language reference: [README.md](README.md). ## Topology ``` -.gaviero source (+ optional --tiers-file / --var / --param) +.gaviero source (+ model profile, optional --var / --tier / --param) │ ▼ compile_file only resolver::resolve (include graph, cycle-detect) │ ▼ lexer (logos) → parser (chumsky) → AST + │ + ▼ profile::reject_model_tables, then profile::apply_profile + workflow_params::apply_agent_tiers (tiers { } + --tier) │ ▼ - workflow_params::expand_… (client + roster params, then for_loops::expand_for_blocks) + workflow_params::expand_… (roster params, then for_loops::expand_for_blocks) │ ▼ compiler::compile_ast_with_* → CompiledPlan → gaviero-core::swarm ``` -Single synchronous library. Depends on [`gaviero-core`](../gaviero-core), logos, chumsky, miette, thiserror. No async; I/O only in `compile_file` / `load_tier_overrides` / `workflow_execution_mode`. +Single synchronous library. Depends on [`gaviero-core`](../gaviero-core), logos, chumsky, miette, thiserror. No async; I/O only in `compile_file*`, profile loading and `workflow_execution_mode`. --- ## Modules -**9 pub mods** ([`src/lib.rs`](src/lib.rs)): +**10 pub mods** ([`src/lib.rs`](src/lib.rs)): | Module | Role | |---|---| @@ -39,14 +42,14 @@ Single synchronous library. Depends on [`gaviero-core`](../gaviero-core), logos, | [`parser.rs`](src/parser.rs) | Chumsky → `Script` | | [`compiler.rs`](src/compiler.rs) | Semantic analysis → `CompiledPlan`; `peek_workflow_execution_mode` | | [`resolver.rs`](src/resolver.rs) | Transitive `include` resolution | -| [`workflow_params.rs`](src/workflow_params.rs) | `param` client + roster expansion (`--param`) | +| [`workflow_params.rs`](src/workflow_params.rs) | Workflow `tiers { }` + `--tier`, list params and roster expansion (`--param`) | | [`reviewers.rs`](src/reviewers.rs) | Compat re-exports of roster helpers | | [`for_loops.rs`](src/for_loops.rs) | Private: `for … parallel/sequential` expansion into per-item clones | -| [`tiers.rs`](src/tiers.rs) | `load_tier_overrides` for `--tiers-file` | -| [`profile.rs`](src/profile.rs) | Merges a model profile into the resolved script for `--profile` / the SWARM form | +| [`profile.rs`](src/profile.rs) | Rejects `client` / tier lines in scripts; merges the model profile (`--profile`, the SWARM form, or `default`) | +| [`inspect.rs`](src/inspect.rs) | A script's inputs (workflows, list params, vars, tiers used) for the SWARM form | | [`error.rs`](src/error.rs) | `DslError` / `DslErrors` (miette spans) | -Examples: **10** workflow scripts + **3** profiles under [`examples/`](examples) (`doc-claude`, `doc-codex`, `doc-cursor`). +Examples: **12** workflow scripts + **4** model profiles under [`examples/`](examples) (`default`, `claude`, `codex`, `mixed`). --- @@ -54,21 +57,31 @@ Examples: **10** workflow scripts + **3** profiles under [`examples/`](examples) ### AST ([`ast.rs`](src/ast.rs)) -`Script { items: Vec }` with `Client`, `Agent`, `Workflow`, `Prompt`, `Vars`, `TierAlias`, `Include`. Field-level detail lives in the source — do not duplicate here. +`Script { items: Vec }` with `Client`, `Agent`, `Workflow`, `Prompt`, `Vars`, `TierAlias`, `Include`. `Client` and `TierAlias` come only from the model profile: the public entry points reject them in a script. Field-level detail lives in the source — do not duplicate here. ### `CompiledPlan` / `ExecutionMode` Re-exported from core. [`workflow_execution_mode`](src/lib.rs) / [`peek_workflow_execution_mode`](src/compiler.rs) resolve `execution repo|document` for workspace anchoring before full compile. +Besides the DAG and `LoopConfig`s the compiler fills: + +- `runtime_fors` — one `RuntimeForOp { unit_id, var, source, max_items }` per `for … in json` step; `unit_id` names a template node in the graph whose `{{.*}}` placeholders survive compile. +- `tier_bindings` — every tier of the profile resolved to its client's model / effort / extra / privacy / tier, so runtime items (`for … in json` items, spawn-manifest workers) can name a `tier`. +- `budget` — the workflow's `budget { wall usd }` (`RunBudget`). + +`LoopConfig::agent_ids` is in dependency order: `depends_on` between agents of the same loop sorts them (stably). A workflow may contain at most one `loop`. + ### Params -[`workflow_params`](src/workflow_params.rs) expands client params (`provider:model[@effort]`) into synthetic `__param_*` clients and roster params into per-reviewer agent clones before semantic compile. +[`workflow_params`](src/workflow_params.rs) first applies the selected workflow's `tiers { agent tier }` block and the `--tier` overrides to the agents' declared tiers (`apply_agent_tiers`), then expands roster params into per-reviewer agent clones before semantic compile. A roster entry's `tier` replaces its clones' tier. Params are lists only; no param chooses a model. Its last pass, [`for_loops::expand_for_blocks`](src/for_loops.rs), expands `for in parallel|sequential { … }`: one clone `-` per item and body agent, item values in `AgentDecl::item_vars` (`.id`, `.`, `.index`, …), the sequential chain as `depends_on`, and fan-in `depends_on [body]` rewritten to every clone. A `for … parallel` inside a `loop` appends its clones to the loop's agents; when the step right before the loop is a top-level `for` over the same list, its clones become `LoopBlock::baseline_units`, emitted as `LoopConfig::baseline_units` (scope-group and resume pairing in core, alongside the roster's `-init`/`-refine` suffix rule). -### Tier overrides +`for in json "" …` blocks are **not** expanded at compile time: expansion validates them, replaces each with its single body agent (a plain step, or a loop agent), and records it in `WorkflowDecl::runtime_fors`, which the compiler emits as `CompiledPlan::runtime_fors`. The core pipeline ([`swarm/runtime_for.rs`](../gaviero-core/src/swarm/runtime_for.rs)) reads the list and clones the template when the step runs. + +### Models -[`load_tier_overrides`](src/tiers.rs) parses a profile that contains **only** `tier ` lines. CLI profile beats script/includes. +One way only. The model profile maps tiers to clients ([`profile.rs`](src/profile.rs)); every agent declares a tier; an agent's tier is `--tier` > the workflow's `tiers { }` > its own; a list item's `tier` moves its clone. `compile_agent` resolves `tier_ref` → profile tier → client; an agent without a tier, or a tier the profile lacks, is a compile error. --- @@ -78,11 +91,12 @@ Its last pass, [`for_loops::expand_for_blocks`](src/for_loops.rs), expands `for source / entry_path │ compile_file → resolver::resolve (cycle reject, canonical dedup) ▼ lexer::lex → parser::parse → Script - ▼ workflow_params::expand_workflow_params_in_script (client params → roster → for_loops::expand_for_blocks) + ▼ profile::reject_model_tables → profile::apply_profile + ▼ workflow_params::apply_agent_tiers → expand_workflow_params_in_script (roster → for_loops::expand_for_blocks) ▼ compiler::compile_ast_with_vars / compile_ast_with_sources index items → duplicate checks → select workflow merge vars (agent > CLI --var > script; AGENT/PROMPT reserved) - resolve prompts + tier aliases (--tiers-file last) + resolve prompts + agent tier → profile client apply_vars build WorkUnit / LoopConfig / IterationConfig / VerificationConfig (scope overlap is NOT checked here — swarm `validate_scopes` at execute) @@ -109,7 +123,7 @@ enum DslError { Lex {..}, Parse {..}, Compile {..}, Resolve {..} } Spans point at the originating file (multi-file via `NamedSource` in `compile_file`). No panics on the public API. -Representative failures: unknown client/tier/prompt, duplicate name, circular `depends_on`, reserved var shadow, missing workflow, unknown `{{KEY}}`, include cycle, `include` under inline `compile`. Scope overlap is a swarm-runtime failure (`validate_scopes`), not a DSL diagnostic. +Representative failures: agent without a tier, tier the profile lacks, `client` / tier line in a script, unknown prompt, duplicate name, circular `depends_on`, reserved var shadow, missing workflow, unknown `{{KEY}}`, include cycle, `include` under inline `compile`. Scope overlap is a swarm-runtime failure (`validate_scopes`), not a DSL diagnostic. --- @@ -118,32 +132,32 @@ Representative failures: unknown client/tier/prompt, duplicate name, circular `d ```rust // crates/gaviero-dsl/src/lib.rs pub fn compile( - source: &str, filename: &str, + source: &str, filename: &str, profile: Option<&SelectedProfile>, workflow: Option<&str>, runtime_prompt: Option<&str>, ) -> Result; pub fn compile_with_vars( - source: &str, filename: &str, + source: &str, filename: &str, profile: Option<&SelectedProfile>, workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], // --tier AGENT=TIER override_params: &[(String, String)], ) -> Result; -pub fn compile_file( - entry_path: &Path, +pub fn compile_file_with_profile( + entry_path: &Path, profile: Option<&SelectedProfile>, workflow: Option<&str>, runtime_prompt: Option<&str>, override_vars: &[(String, String)], - override_tiers: &[(String, String)], + agent_tiers: &[(String, String)], override_params: &[(String, String)], ) -> Result; +// compile_file(...) = compile_file_with_profile(.., None, ..) pub fn workflow_execution_mode( entry_path: &Path, workflow: Option<&str>, ) -> Result; pub use compiler::peek_workflow_execution_mode; -pub use tiers::load_tier_overrides; pub use error::{DslError, DslErrors}; pub use gaviero_core::swarm::plan::{CompiledPlan, ExecutionMode}; ``` diff --git a/crates/gaviero-dsl/CLAUDE.md b/crates/gaviero-dsl/CLAUDE.md index e0e07101..36196cb5 100644 --- a/crates/gaviero-dsl/CLAUDE.md +++ b/crates/gaviero-dsl/CLAUDE.md @@ -9,7 +9,7 @@ cargo test -p gaviero-dsl cargo clippy -p gaviero-dsl ``` -Examples: **11** workflows + **3** tier overrides (`doc-claude`, `doc-codex`, `doc-cursor`) + **3** model profiles (`claude`, `codex`, `mixed`) under [`examples/`](examples/). +Examples: **12** workflows + **4** model profiles (`default`, `claude`, `codex`, `mixed`) under [`examples/`](examples/). ## Architecture @@ -19,24 +19,22 @@ Examples: **11** workflows + **3** tier overrides (`doc-claude`, `doc-codex`, `d |---|---| | [`ast.rs`](src/ast.rs) | AST types. **Authoritative** DSL surface — read before extending docs or the parser. | | [`lexer.rs`](src/lexer.rs) / [`parser.rs`](src/parser.rs) | Logos → chumsky → AST. | -| [`compiler.rs`](src/compiler.rs) | Semantic analysis → `CompiledPlan` (cycles, tier resolution, var substitution). Scope overlap is validated at swarm runtime. | -| [`workflow_params.rs`](src/workflow_params.rs) | `param` materialization: client params + roster expansion (`--param`). | +| [`compiler.rs`](src/compiler.rs) | Semantic analysis → `CompiledPlan` (cycles, tier → profile client resolution, var substitution). Scope overlap is validated at swarm runtime. | +| [`workflow_params.rs`](src/workflow_params.rs) | Workflow `tiers { }` + `--tier` (`apply_agent_tiers`), list `param`s and roster expansion (`--param`). | | [`reviewers.rs`](src/reviewers.rs) | Compat re-exports only; impl lives in `workflow_params`. | -| [`for_loops.rs`](src/for_loops.rs) | Private: `for in parallel/sequential` expansion (last pass of `workflow_params`). | +| [`for_loops.rs`](src/for_loops.rs) | Private: `for in parallel/sequential` expansion (last pass of `workflow_params`); `for … in json` blocks are validated and lowered to their body agent + `WorkflowDecl::runtime_fors`, cloned at run time by core. | | [`resolver.rs`](src/resolver.rs) | `include` graph; drives `compile_file`. | -| [`tiers.rs`](src/tiers.rs) | `--tiers-file` loader (`tier` lines only). | -| [`profile.rs`](src/profile.rs) | Merges a model profile (`client` + `tier`) into a resolved script. | +| [`profile.rs`](src/profile.rs) | Merges a model profile (`client` + `tier`) into a resolved script; `reject_model_tables` refuses `client` / `tier ` in scripts. | | [`error.rs`](src/error.rs) | `DslError` / `DslErrors` (miette spans). | **Public API** ([`lib.rs`](src/lib.rs)): -- `compile` / `compile_with_vars` / `compile_file` — `override_vars`, `override_tiers`, `override_params`. -- `compile_file_with_profile` — `compile_file` plus a [`SelectedProfile`](../gaviero-core/src/script_profiles.rs). -- `load_tier_overrides` — backs `--tiers-file`. +- `compile` / `compile_with_vars` (inline, take a profile) / `compile_file` — `override_vars`, `agent_tiers` (`--tier`), `override_params`. +- `compile_file_with_profile` — `compile_file` plus a [`SelectedProfile`](../gaviero-core/src/script_profiles.rs). Without a profile no tier is bound, so any script with agents fails to compile. - `workflow_execution_mode` / `peek_workflow_execution_mode` — `repo` vs `document` anchoring before full compile. - `inspect_file` ([`inspect.rs`](src/inspect.rs)) — a script's inputs (workflows, params, vars, prompt use) without compiling; backs the TUI SWARM form. -**Precedence:** agent-level `vars {}` > CLI `--var` > script-level `vars {}`. Item vars (`for` / roster) are substituted before agent, CLI and script vars. Tier: `--tiers-file` > chosen profile > script/includes `tier` lines > implicit `default` profile. +**Precedence:** agent-level `vars {}` > CLI `--var` > script-level `vars {}`. Item vars (`for` / roster) are substituted before agent, CLI and script vars. Models — one way only: the profile (chosen, else the one named `default`) maps tiers to clients; an agent's tier is `--tier` > the workflow's `tiers { }` > its own required `tier`, and a list item's `tier` moves its clone. Scripts declare no clients or tier lines. Exact field shapes: [`ast.rs`](src/ast.rs). Language reference: [README.md](README.md). @@ -55,9 +53,8 @@ Exact field shapes: [`ast.rs`](src/ast.rs). Language reference: [README.md](READ - **Never extend the AST without updating [`ast.rs`](src/ast.rs).** Drift between AST and parser is the top DSL bug source. - **`effort` is checked twice** ([`swarm/backend/effort.rs`](../gaviero-core/src/swarm/backend/effort.rs)): a misspelled name fails compilation (`is_known_effort`), and a wrong model + effort pair fails `preflight_plan_models` before any agent starts. Pairs are checked on the agents a run uses, so an unused client in a shared pool blocks nothing. -- **Tier-override files contain `tier` lines only** ([`tiers.rs`](src/tiers.rs)). Reject other items with a diagnostic. +- **Scripts choose models by tier only.** Every agent declares `tier`; `client` blocks and `tier ` lines are profile-only (rejected in scripts and their includes by `reject_model_tables`); there are no model-valued params; list items and runtime JSON items carry `tier`, never `model` / `effort`. Do not add a second way. - **Profiles are closed model tables** ([`profile.rs`](src/profile.rs)): only `client` and `tier`, tiers point at the profile's own clients, and those clients are renamed on merge so they can never collide with the script's. -- **`tier:` is a model-spec form, not a provider.** It is accepted only where `workflow_params` reads a model (`param`, roster entries, `--param`), and cannot be combined with effort, privacy or extra. - **`include` is whole-file.** Inline paths (`compile`, `compile_with_vars`) must reject `include` and point callers to `compile_file`. - **Cycle detection lives in the resolver,** not the compiler. diff --git a/crates/gaviero-dsl/README.md b/crates/gaviero-dsl/README.md index 05c5d56a..16feaba7 100644 --- a/crates/gaviero-dsl/README.md +++ b/crates/gaviero-dsl/README.md @@ -20,9 +20,8 @@ cargo clippy -p gaviero-dsl ```bash gaviero-cli --script path/to/workflow.gaviero -gaviero-cli --script workflows/refactor.gaviero --var PLANS=output --param judge=claude:haiku@low -gaviero-cli --script examples/update_docs.gaviero \ - --tiers-file examples/profiles/doc-codex.gaviero +gaviero-cli --script workflows/refactor.gaviero --var PLANS=output --tier judge=low +gaviero-cli --script examples/update_docs.gaviero --profile codex ``` ### From the TUI @@ -43,19 +42,16 @@ gaviero-cli --script tmp/plan.gaviero ### Two-agent workflow ```gaviero -client reasoning { tier expensive model "claude:sonnet" } -client local_exec { tier cheap model "ollama:qwen2.5-coder:7b" privacy local_only } - agent design { description "Plan the refactor" - client reasoning + tier high scope { read_only ["src/" "tests/" "docs/"] } prompt "Inspect the implementation and produce a concrete refactor plan." } agent implement { description "Apply the refactor" - client local_exec + tier medium depends_on [design] scope { owned ["src/" "tests/"] read_only ["docs/"] impact_scope true } context { callers_of ["src/auth/session.rs"] tests_for ["src/auth/"] depth 2 } @@ -72,34 +68,33 @@ workflow refactor_auth { ### Shipped examples -Eleven workflow scripts, three tier overrides and three model profiles live in `examples/`: +Twelve workflow scripts and four model profiles live in `examples/`: | File | Demonstrates | |---|---| -| `clients.gaviero` | Shared client pool | -| `plan_refinement.gaviero` | Dual-model plan refinement with judge loop | +| `plan_refinement.gaviero` | Multi-provider plan refinement with judge loop (roster items on provider tiers) | | `generic_consensus.gaviero` | N-reviewer consensus via roster expansion | | `phased_plan.gaviero` | Dynamic phase extraction | | `codebase_review.gaviero` | Per-module review loop (findings only) | -| `update_docs.gaviero` | Parallel doc rewrite with `--tiers-file` | +| `update_docs.gaviero` | Parallel doc rewrite; swap models with `--profile` | | `security_audit_memory.gaviero` | `memory {}` overrides, `read_ns`, staleness | -| `tiered_review.gaviero` | Provider-agnostic script; models come from a profile | +| `tiered_review.gaviero` | The three ways a tier is chosen: agent `tier`, workflow `tiers { }`, item `tier` | +| `mcp_smoke_test.gaviero` | One probe per provider on provider-pinned tiers | +| `pattern_map_reduce.gaviero` | `pattern map_reduce`; spawn-manifest workers name a `tier` | +| `scientific_research.gaviero` | Literature-research consensus panel | | `for_loops.gaviero` | Explicit `for … parallel` / `for … sequential` over a list param | +| `deep_explore.gaviero` | Autonomous literature explorer on the `academic` MCP server: scout → loop (curator → runtime `for … in json` investigators → cross-family verifier, stop judge) → report + citation check; `budget`, `produces json`; tiers from the profile | -**Model profiles** (`examples/profiles/`, see [below](#model-profiles)): `claude.gaviero`, `codex.gaviero`, `mixed.gaviero`. - -**Tier overrides** (`examples/profiles/`, `tier ` lines only, for `--tiers-file`): `doc-claude.gaviero`, `doc-codex.gaviero`, `doc-cursor.gaviero`. +**Model profiles** (`examples/profiles/`, see [below](#model-profiles)): `default.gaviero` (generic `low`…`top` tiers plus `-claude` / `-codex` / `-cursor` and `high-deepseek`; copy it to `.gaviero/dsl/profiles/default.gaviero`), `claude.gaviero`, `codex.gaviero`, `mixed.gaviero`. The examples' rosters use the provider-pinned tiers, so they need a profile that defines them, such as `default.gaviero`. ```bash gaviero-cli --script crates/gaviero-dsl/examples/plan_refinement.gaviero \ --prompt "Add workspace settings cascade" ``` -Scripts that `include "clients.gaviero"` must be compiled via `compile_file` or `gaviero-cli --script` — inline `compile()` rejects includes. - ### Model strings -Canonical form is `provider:model`. Bare names are rejected at dispatch. +Model strings appear only in model profiles (`client { model "…" }`). Canonical form is `provider:model`; bare names are rejected at dispatch. | Provider | Examples | |---|---| @@ -117,8 +112,9 @@ The DSL has no runtime config — behaviour is declared in the script and adjust | Override | CLI flag | Precedence | |---|---|---| | Vars | `--var KEY=VALUE` | agent `vars {}` > CLI > script `vars {}` | -| Tiers | `--profile` or `--tiers-file` | CLI > script/includes > implicit `default` profile | -| Workflow params | `--param NAME=VALUE` | Required params without defaults must be supplied | +| What each tier means | `--profile NAME\|PATH` | chosen profile, else the profile named `default` | +| An agent's tier | `--tier AGENT=TIER` | CLI > workflow `tiers { }` > the agent's own `tier`; a list item's `tier` moves its clone | +| Workflow list params | `--param NAME=VALUE` | Required params without defaults must be supplied | Provider resolution, memory namespaces, and verification execution are configured via `.gaviero/settings.json` on the `gaviero-core` side. See [gaviero-cli](../gaviero-cli/README.md#configuration). @@ -139,22 +135,31 @@ A run is refused before it starts if a `file` var names nothing on disk. Use a p A `file` outside the run root is copied in, and an uncommitted one is copied into agent worktrees. `dir` has one effect only: the SWARM form completes the field with folders. At run time it is a string, so a folder need not exist and is never copied. -In the TUI's SWARM form `file` and `dir` vars complete as you type: `file` from the same list as `@` in chat, `dir` from the workspace's folders. The popup shows eight rows and scrolls through every match (Up/Down, PageUp/PageDown, wheel). Roster and client `param` fields complete `tier:` from the tiers the run would have: the profile selected on the form, then the script's own. +In the TUI's SWARM form `file` and `dir` vars complete as you type: `file` from the same list as `@` in chat, `dir` from the workspace's folders. The popup shows eight rows and scrolls through every match (Up/Down, PageUp/PageDown, wheel). List `param` items complete the tier after `id=` from the profile selected on the form. ### Model profiles -Write a script against tiers, not providers. Tier names are free-form; `low`, `medium`, `high` and `top` are the convention. +A script chooses models in one way only: by tier. Tier names are free-form; `low`, `medium`, `high` and `top` are the convention. + +- **Every agent declares its default tier** with `tier `. An agent without one is a compile error. +- **A workflow may move agents** to other tiers in its `tiers { … }` block; agents it does not name keep their own. +- **A run may move agents** with `--tier AGENT=TIER`, which overrides the block. +- **A list item's `tier`** (`{ id "a" tier top }`, `--param panel=a=top`) moves that item's clones; items without one keep their body agent's tier. ```gaviero agent gather { tier low prompt "…" } +agent judge { tier low prompt "…" } +agent review { tier high template true prompt "…" } workflow review { - param judge { model "tier:medium" } // client param - param panel [ { id "a" model "tier:top" } ] // roster - steps [ gather ] + tiers { judge medium } // this workflow's judge runs on medium + param panel [ { id "a" } { id "b" tier top } ] // b's clone runs on top + steps [ gather loop { reviewers panel template_refine review until agent judge } ] } ``` +A script never declares `client` blocks or `tier ` lines, not even in an included file — the compiler rejects them. There are no model-valued params, and list items take no `model` or `effort`. + A profile says what each tier means. It holds only `client` and `tier` declarations (`include` works, for a shared client pool), and tiers may mix providers: ```gaviero @@ -171,22 +176,22 @@ Profiles are looked up by file name in each workspace folder's `.gaviero/dsl/pro ```bash gaviero-cli --script review.gaviero --profile mixed gaviero-cli --script review.gaviero --profile ./one-off.gaviero -gaviero-cli --script review.gaviero --profile mixed --param judge=tier:high +gaviero-cli --script review.gaviero --profile mixed --tier judge=high ``` The TUI's SWARM form offers the same choice in a **Profile** selector. | Situation | Result | |---|---| -| Profile chosen | Its tiers replace the script's bindings for those names | -| No choice, a profile named `default` exists | It supplies only the tiers the script leaves unbound | -| Agent says `client ` | Untouched — a concrete client is a deliberate pin | -| A client in the profile is marked `default` | Used by agents that bind neither client nor tier | -| A tier nothing binds | Compile error | +| Profile chosen | It defines every tier of the run | +| No choice, a profile named `default` exists | It defines every tier of the run | +| No profile at all | Compile error naming `--profile` / the `default` profile | +| An agent's tier the profile does not define | Compile error listing the tiers it does define | +| A client in the profile is marked `default` | Compile error — every agent declares a tier | `effort` names are checked at compile time, so a misspelling is an error listing the valid names. A model + effort pair the model cannot run stops the run before any agent starts; `auto` and `off` suit every model. Each profile client sets both together, so changing profile keeps the pair valid. Cursor takes no `effort`: pick a model id that has the level in it (`cursor:grok-4.7-high`). -A profile's clients are private to it, so they cannot clash with the script's, and a tier fixes model, effort and privacy together: `tier:high@low` is an error. +A tier fixes model, effort, privacy and `extra` together, so nothing in a script can pair a tier with a different effort. ## API @@ -194,36 +199,34 @@ A profile's clients are private to it, so they cannot clash with the script's, a ```rust use gaviero_dsl::{ - compile, compile_with_vars, compile_file, - workflow_execution_mode, load_tier_overrides, - CompiledPlan, ExecutionMode, + compile, compile_with_vars, compile_file_with_profile, + workflow_execution_mode, CompiledPlan, ExecutionMode, }; -// Inline (no `include` statements) -let plan = compile(source, filename, Some("workflow_name"), Some("runtime prompt"))?; +// Inline (no `include` statements); `profile` says what each tier means +let plan = compile(source, filename, Some(&profile), Some("workflow_name"), Some("runtime prompt"))?; -// Inline + CLI overrides +// Inline + CLI overrides (`--var`, `--tier AGENT=TIER`, `--param`) let plan = compile_with_vars( - source, filename, Some("workflow_name"), Some("runtime prompt"), - &override_vars, &override_tiers, &override_params, + source, filename, Some(&profile), Some("workflow_name"), Some("runtime prompt"), + &override_vars, &agent_tiers, &override_params, )?; // From disk — resolves `include` transitively -let plan = compile_file(path, Some("workflow"), Some("prompt"), &[], &[], &[])?; +let plan = compile_file_with_profile(path, Some(&profile), Some("workflow"), Some("prompt"), &[], &[], &[])?; let mode: ExecutionMode = workflow_execution_mode(path, Some("my-workflow"))?; -let tiers = load_tier_overrides(path_to_profile)?; ``` -All compile functions return `Result` with source diagnostics on failure. +`profile` is a [`SelectedProfile`](../gaviero-core/src/script_profiles.rs), usually picked with `ProfileCatalog::select`. All compile functions return `Result` with source diagnostics on failure. -`CompiledPlan` is re-exported from `gaviero_core::swarm::plan`. Public modules: `ast`, `compiler`, `reviewers`, `workflow_params`, `error`, `lexer`, `parser`, `resolver`, `tiers`. +`CompiledPlan` is re-exported from `gaviero_core::swarm::plan`. Public modules: `ast`, `compiler`, `reviewers`, `workflow_params`, `error`, `lexer`, `parser`, `resolver`, `profile`, `patterns`, `inspect`. ### Language surface (summary) -- **Client** — model + tier + effort + optional `extra {}` provider pairs -- **Agent** — scope, prompt, dependencies, `produces []`, `context {}`, `memory {}`, `tools []` -- **Workflow** — steps, `verify {}`, iteration strategy, explicit `loop {}` blocks, `for … parallel|sequential` over list params +- **Client** (model profiles only) — model + effort + privacy + optional `extra {}` provider pairs, bound to a tier with `tier ` +- **Agent** — `tier` (required), scope, prompt, dependencies, `produces []`, `context {}`, `memory {}`, `tools []` +- **Workflow** — steps, `tiers {}`, `verify {}`, iteration strategy, explicit `loop {}` blocks, `for … parallel|sequential` over list params - **Include** — splice shared declarations; cycles rejected; requires `compile_file` - **Scope** — `owned`, `read_only`, `impact_scope` with glob patterns - **Produces** — exact artefact paths the agent must have written when its turn @@ -240,7 +243,7 @@ workflow w { execution_mode document // required by `for … sequential` param topics [ { id "a" focus "storage" } - { id "b" focus "network" model "tier:high" } + { id "b" focus "network" tier high } ] steps [ for t in topics parallel { @@ -258,17 +261,17 @@ workflow w { ``` - **List params** are the roster param kind with free fields: entries are - `{ id "…" [model "…"] [effort …] [ ""]* }`. `id` is required, + `{ id "…" [tier ] [ ""]* }`. `id` is required, unique, and matches `[A-Za-z0-9][A-Za-z0-9_.-]*`. Free-field names must not be DSL keywords; `index`, `count`, `peers`, `peer_count`, `prev` and `peer_block` are reserved. - **Clones** are named `-` (`a-analyst`, `b-analyst`, …). With - `model` (a `provider:model` or `tier:` spec) the clone binds to it as a - roster entry does; without it the clone keeps the body agent's own client. + `tier` the clone runs on that tier; without it the clone keeps the body + agent's tier (after the workflow's `tiers { }` and `--tier`). Body agents run only through their clones: listing one as a plain step, or in two `for` blocks, is an error. They need no `template true`. -- **Item vars** inside a clone: `{{t.id}}`, `{{t.}}`, `{{t.model}}` / - `{{t.effort}}` when set, `{{t.index}}` (1-based), `{{t.count}}`, `{{t.peers}}` +- **Item vars** inside a clone: `{{t.id}}`, `{{t.}}`, `{{t.tier}}` + when set, `{{t.index}}` (1-based), `{{t.count}}`, `{{t.peers}}` (other ids, comma-joined), `{{t.peer_count}}`, `{{t.prev}}` (sequential only; empty for the first item), and `{{t.peer_block}}` — the `peer_template` rendered once per peer with `{{peer}}` = the peer id, joined by newlines @@ -290,9 +293,58 @@ workflow w { (`LoopConfig::baseline_units`): they may own the same paths as the loop agents, and a resumed run skips them. - **CLI:** `--param 'topics=[{id "a" focus "x"} {id "b"}]'` (a DSL list - literal) or the short form `--param topics=a,b` / `id=provider:model[@effort],…`. + literal) or the short form `--param topics=a,b` / `id=tier,…`. +- **Inside a `loop`, `depends_on` between loop agents orders them within + every pass**: `curator { depends_on [investigator] }` runs after that pass's + investigators, on pass 1 and on every later pass. - **Not supported:** `for … sequential` inside a `loop`, `loop` inside `for`, - `for` inside `for`, lists produced at runtime (use `pattern map_reduce`). + `for` inside `for`, more than one `loop` per workflow. For lists only known + at run time see `for … in json` below. + +#### Runtime lists (`for … in json`) + +``` +for q in json "{{OUT_DIR}}/assignments-v{{ITER}}.json" parallel max 6 { investigator } +``` + +`for in json "" parallel [max ] { }` reads its list +from a JSON file when the step runs instead of from a list param. Example: +[`examples/deep_explore.gaviero`](examples/deep_explore.gaviero). + +- **Where:** a top-level step, or inside a loop that is not + `branch_chain stacked`. The workflow must declare `execution_mode document`. + Inside a loop the file is read again on every pass, with that pass's + `{{ITER}}` / `{{PREV_ITER}}` in the path; compile-time vars (`{{OUT_DIR}}`) + resolve when the script compiles. The path is relative to the workspace root. +- **The file** is a JSON array of flat objects. `id` is required, a string + matching `[A-Za-z0-9][A-Za-z0-9_.-]*`, unique. `tier` (a tier of the run's + profile) is optional; `model` and `effort` keys are rejected. Every other key is + a field: strings as written, numbers and bools as text, arrays and objects + as compact JSON. Values are not var-substituted. +- **Item vars:** `{{q.id}}`, `{{q.}}`, `{{q.tier}}`, + `{{q.index}}` (1-based), `{{q.count}}`, `{{q.peers}}`, `{{q.peer_count}}`. + A `{{q.x}}` that some item has no value for stops the run before any clone + starts. +- **Body:** exactly one agent. It must declare `produces`, and its `owned` and + `produces` paths must contain `{{q.id}}`. It may not also be a plain step or + the body of another `for`. +- **`max`:** defaults to 16. A list longer than `max` stops the run with an + error. An empty list runs no clone, and dependents still run. +- **Clones** are named `@` and run in parallel under the + workflow's `max_parallel`. +- **Fan-in is strict:** `depends_on [investigator]` waits for every clone of + the step; if any clone fails, the step fails and its dependents are skipped. +- **Resume:** at top level every clone is checkpointed and `--resume` re-runs + only the unfinished ones. Inside a loop a crashed pass re-runs whole + (passes resume from their artefacts, as for every loop). +- **Not supported:** `sequential`, more than one body agent, `peer_template`, + `execution_mode repo`. + +`pattern map_reduce { discover … reduce … max_spawn N }` runs on the same +machinery: it requires `execution_mode document`; the workers listed in the +discover agent's `spawn_manifest.json` run in parallel and are checkpointed +one by one; a missing manifest or one over `max_spawn` stops the run; and a +failed worker skips `reduce`. The `loop { reviewers … template_init … template_refine … }` roster sugar remains and keeps its `-init` / `-refine` names and `REVIEWER_ID` / @@ -329,6 +381,33 @@ Two checks enforce it, neither of which costs a model call: Agents that declare no `produces` fall back to a weaker check: the loop verifies that *something* the agent owns changed during the pass. +`produces json ["…"]` declares outputs that must also **parse as JSON**: the +paths join `produces`, and a file that exists but does not parse counts as +missing — same corrective retry, same per-pass delivery gate. Use it for files +another step reads, such as the list of a `for … in json`. Schemas stay in a +`until command "…"` check. + +### Budgets (`budget`) + +``` +workflow w { + budget { wall "8h" usd 40 } +} +``` + +- `wall` is `[s|m|h]` (no suffix = seconds). With + `gaviero-cli --run-timeout`, the smaller of the two applies; the TUI, which + passes no run timeout, gets the script's `wall`. +- `usd` caps the cost providers report. Only `claude:` and `deepseek:` report + cost; `codex:`, `cursor:`, `ollama:` and `dsh:` report none, and a run with + a `usd` budget names the units whose spend it cannot see when it starts. + Spend includes every retry and every `best_of_N` attempt, and judges. +- Both are checked before every dispatch — each agent, clone, worker, loop + pass and judge. A spent budget stops the run like `--run-timeout` does (no + error; the phase reads `run budget exhausted: …`). Spend is known only when a + dispatch returns, so agents already running in parallel can carry the total + past `usd`. + ### Composed exit conditions (`until … and …`) ``` @@ -374,14 +453,14 @@ explicit `"verdict": "irreconcilable"` from the judge stops the loop and writes `blockers` array. Repeat detection fingerprints the blockers' agent/criterion pairing rather than the prose, so a judge rephrasing itself does not reset the count. `0` disables it. -- **Params** — typed `param` on workflows; roster / list `id=provider:model[@effort],…`, bare ids `a,b`, or a DSL list literal `[{id "a" …}]` +- **Params** — list `param`s on workflows: `id=tier,…`, bare ids `a,b`, or a DSL list literal `[{id "a" …}]` Full language reference: see the prior detailed blocks in [ARCHITECTURE.md](ARCHITECTURE.md) or browse `examples/`. ## See Also - [gaviero-core](../gaviero-core/README.md) — execution runtime -- [gaviero-cli](../gaviero-cli/README.md) — `--script`, `--var`, `--param`, `--tiers-file` +- [gaviero-cli](../gaviero-cli/README.md) — `--script`, `--var`, `--param`, `--tier`, `--profile` - [Root ARCHITECTURE.md](../../ARCHITECTURE.md) — compilation pipeline ## License diff --git a/crates/gaviero-dsl/examples/clients.gaviero b/crates/gaviero-dsl/examples/clients.gaviero deleted file mode 100644 index 01b77c1c..00000000 --- a/crates/gaviero-dsl/examples/clients.gaviero +++ /dev/null @@ -1,93 +0,0 @@ -// Shared client profiles for example workflows. -// -// Model strings use the canonical `provider:model` form (validated at -// dispatch by gaviero-core). `tier` is omitted here: these examples bind -// agents to concrete clients by name (`client opus`). Add top-level -// `tier ` declarations when you want re-pointable routing. - -client fable { - model "claude:fable" - privacy public - effort max - default -} - -client opus { - model "claude:opus" - privacy public - effort max -} - -client sonnet { - model "claude:sonnet" - privacy public - // The judge emits a short JSON verdict — no deep reasoning needed. - effort medium -} - -client codex-6-1-sol { - model "codex:gpt-6.1-sol" - privacy public - // Codex's latest workhorse (catalog priority 1). - effort high -} - -client codex-6-1-terra { - model "codex:gpt-6.1-terra" - privacy public - effort high -} - -client codex-6-luna { - model "codex:gpt-6-luna" - privacy public - // Luna tops out at max; it has no `ultra`. - effort medium -} - -client codex-6-astra { - model "codex:gpt-6-astra" - privacy public - // Codex's frontier model. Older CLIs are served a catalog without it. - effort high -} - -client codex-5-6-sol { - model "codex:gpt-5.6-sol" - privacy public - // Astra, Sol and Terra are the Codex models that accept `ultra`. - effort high -} - -client codex-5-6-terra { - model "codex:gpt-5.6-terra" - privacy public - effort high -} - -client codex-5-6-luna { - model "codex:gpt-5.6-luna" - privacy public - effort medium -} - -client composer { - model "cursor:composer-2.5" - privacy public -} - -client grok { - // Cursor CLI id embeds effort (`agent --list-models`); grok-4.7 is the - // current grok generation — use the full id. - model "cursor:grok-4.7-high" - privacy public -} - -client dsh { - // DeepSeek via `dsh --profile acp` (npm `@deepseek-ai/dsh`) over the - // Agent Client Protocol; needs DEEPSEEK_API_KEY. `deepseek-flash` is - // V4.1-Flash (canonical API id). - model "dsh:deepseek-flash" - privacy public - effort high -} diff --git a/crates/gaviero-dsl/examples/codebase_review.gaviero b/crates/gaviero-dsl/examples/codebase_review.gaviero index 28b69ec1..aa72b16f 100644 --- a/crates/gaviero-dsl/examples/codebase_review.gaviero +++ b/crates/gaviero-dsl/examples/codebase_review.gaviero @@ -38,16 +38,14 @@ // never wrote is Failed, not Completed. {{ITER}} in produces is // substituted per pass. // -// Models: two workflow params — `reviewer` (expensive) and `judge` -// (cheap: inventory, halt_judge, synthesize). Pass a model spec on the -// CLI; no tiers file required. `@effort` is optional. +// Models: review_module runs on tier `high`, the other three on `medium`; +// the model profile says which models those are. Move one agent per run +// with `--tier`: // // gaviero-cli --script crates/gaviero-dsl/examples/codebase_review.gaviero \ // --var OUT_DIR=reviews/opus // gaviero-cli --script crates/gaviero-dsl/examples/codebase_review.gaviero \ -// --param reviewer=codex:gpt-5.6-sol@high --var OUT_DIR=reviews/gpt-5.6-sol - -include "clients.gaviero" +// --tier review_module=high-codex --var OUT_DIR=reviews/codex vars { OUT_DIR "reviews/latest" @@ -257,7 +255,7 @@ prompt synthesize-body #" // they arrive through synthesized `.mcp.json`, not `--tools`. agent inventory { description "Inventory modules in leaf-to-root order" - client judge + tier medium tools ["WebSearch" "WebFetch"] scope { owned ["{{OUT_DIR}}/inventory.md"] @@ -276,7 +274,7 @@ agent inventory { agent review_module { description "Review module {{ITER}} — findings only, no edits" - client reviewer + tier high tools ["WebSearch" "WebFetch"] depends_on [inventory] scope { @@ -290,7 +288,7 @@ agent review_module { agent halt_judge { description "Exit the review loop when MODULE_COUNT is covered or inventory STOP" - client judge + tier medium tools ["WebSearch" "WebFetch"] scope { read_only ["{{OUT_DIR}}/"] @@ -300,7 +298,7 @@ agent halt_judge { agent synthesize { description "Roll up per-module reviews into one summary" - client judge + tier medium tools ["WebSearch" "WebFetch"] // depends_on a loop body agent — post-loop dispatch waits until the // loop has finished every iteration, so synthesize sees every @@ -334,14 +332,6 @@ agent synthesize { // No compile/clippy/test verify — this workflow writes markdown only. workflow codebase_review { - param reviewer { - model "claude:opus" - effort max - } - param judge { - model "claude:sonnet" - effort medium - } steps [ inventory loop { diff --git a/crates/gaviero-dsl/examples/for_loops.gaviero b/crates/gaviero-dsl/examples/for_loops.gaviero index c10f7158..94793253 100644 --- a/crates/gaviero-dsl/examples/for_loops.gaviero +++ b/crates/gaviero-dsl/examples/for_loops.gaviero @@ -26,14 +26,16 @@ // gaviero-cli --script for_loops.gaviero --prompt "the release" \ // --param 'topics=[{id "db" focus "storage"} {id "net" focus "network"}]' // gaviero-cli --script for_loops.gaviero --prompt "the release" --param topics=db,net - -client sonnet { model "claude:sonnet" effort medium default } +// +// An item may carry `tier `: its clones run on that tier instead of +// the body agent's (here `c` runs its analyst and reviewer on `high`). vars { OUT_DIR "for-loops" } agent analyst { + tier medium description "Analyse {{t.focus}} for {{PROMPT}}" scope { owned ["{{OUT_DIR}}/{{t.id}}-notes.md"] } produces ["{{OUT_DIR}}/{{t.id}}-notes.md"] @@ -47,6 +49,7 @@ agent analyst { } agent editor { + tier medium description "Draft section {{t.id}}" scope { owned ["{{OUT_DIR}}/{{t.id}}-draft.md"] @@ -60,6 +63,7 @@ agent editor { } agent summarizer { + tier medium description "Summarise every analysis" depends_on [analyst] scope { @@ -72,6 +76,7 @@ agent summarizer { } agent reviewer { + tier medium description "Review the drafts ({{t.id}})" scope { owned ["{{OUT_DIR}}/{{t.id}}-review-v*.md"] @@ -85,6 +90,7 @@ agent reviewer { } agent judge { + tier medium description "Decide whether the reviews agree" scope { read_only ["{{OUT_DIR}}/"] } prompt #" @@ -98,7 +104,7 @@ workflow for-loops { param topics [ { id "a" focus "storage" } { id "b" focus "network" } - { id "c" focus "ui" } + { id "c" focus "ui" tier high } ] steps [ for t in topics parallel { diff --git a/crates/gaviero-dsl/examples/generic_consensus.gaviero b/crates/gaviero-dsl/examples/generic_consensus.gaviero index 87e0bef6..f286fa73 100644 --- a/crates/gaviero-dsl/examples/generic_consensus.gaviero +++ b/crates/gaviero-dsl/examples/generic_consensus.gaviero @@ -10,8 +10,9 @@ // --var PROBLEM_FILE=consensus/problem.md \ // --var OUT_DIR=consensus_runs/latest // -// Override the roster from the CLI (each entry is `id=provider:model[@effort]`): -// --param roster=claude=claude:opus@max,codex=codex:gpt-5.6-sol@high,cursor=cursor:composer-2.5 +// Override the roster from the CLI (each entry is `id=tier`, a tier of the +// run's model profile): +// --param roster=claude=top-claude,codex=high-codex,cursor=medium-cursor // // Modes (loop consensus_mode): // strict — only PASS ends early (after stability) @@ -110,11 +111,11 @@ prompt judge-body #" ``` "# -// Reviewer agent templates. They have no `client` of their own — each -// roster entry brings its model + effort, and the expansion pass binds the -// cloned agent to an anonymous client built from that entry. +// Reviewer agent templates. Their `tier` is the default; a roster entry's +// `tier` replaces it for that reviewer's clones. agent reviewer-init { template true + tier high description "Initial conclusion ({{REVIEWER_ID}}): {{PROMPT}}" scope { owned ["{{OUT_DIR}}/{{REVIEWER_ID}}-conclusion-v*.md"] @@ -125,6 +126,7 @@ agent reviewer-init { agent reviewer-refine { template true + tier high description "Refine conclusion ({{REVIEWER_ID}}): {{PROMPT}}" scope { owned [ @@ -138,7 +140,7 @@ agent reviewer-refine { agent consensus-judge { description "Judge consensus: {{PROMPT}}" - client judge + tier medium scope { read_only ["{{OUT_DIR}}/"] } @@ -146,16 +148,12 @@ agent consensus-judge { } workflow generic-consensus { - param judge { - model "claude:sonnet" - effort medium - } // Roster parameter — supplied externally. The default below runs a // two-reviewer panel (Claude + Codex) so the example works with no // CLI flag. Override via `--param roster=...` for a different panel. param roster [ - { id "claude" model "claude:opus" effort max } - { id "codex" model "codex:gpt-5.6-sol" effort high } + { id "claude" tier top-claude } + { id "codex" tier high-codex } ] steps [ diff --git a/crates/gaviero-dsl/examples/mcp_smoke_test.gaviero b/crates/gaviero-dsl/examples/mcp_smoke_test.gaviero index e432b55c..5fb7634b 100644 --- a/crates/gaviero-dsl/examples/mcp_smoke_test.gaviero +++ b/crates/gaviero-dsl/examples/mcp_smoke_test.gaviero @@ -28,8 +28,10 @@ // Probe a single client (used by the wrapper for fail-fast): // --workflow probe-claude | probe-codex | probe-cursor // -// To change a model, edit the `client` blocks below (e.g. claude:haiku for an -// even cheaper probe). Effort is kept low — this only checks connectivity. +// Each probe runs on a provider-pinned tier of the model profile +// (`low-claude`, `low-codex`, `low-cursor` in the shipped default profile). +// To change a model, edit the profile, or move one probe with +// `--tier probe_codex=medium-codex`. vars { OUT_DIR "." @@ -39,29 +41,6 @@ vars { PROBE_TASK "List the tools this server exposes, then call exactly one safe, read-only tool with a minimal argument and capture its raw response." } -// ── Clients ────────────────────────────────────────────────────────────────── -// Top-level (not workflow params) so every workflow in this file — including -// the single-client ones — resolves them regardless of which `--workflow` runs. - -client claude_probe { - model "claude:sonnet" - privacy public - effort low - default -} - -client codex_probe { - // Luna is the fast/affordable GPT-5.6 tier — right for a connectivity probe. - model "codex:gpt-5.6-luna" - privacy public - effort low -} - -client cursor_probe { - model "cursor:composer-2.5" - privacy public -} - // ── Probe prompt (shared) ──────────────────────────────────────────────────── prompt probe-body #" @@ -89,7 +68,7 @@ prompt probe-body #" agent probe_claude { description "MCP probe via Claude: {{MCP_SERVER}}" - client claude_probe + tier low-claude scope { owned ["{{OUT_DIR}}/probe_claude.probe"] } prompt probe-body max_retries 0 @@ -97,7 +76,7 @@ agent probe_claude { agent probe_codex { description "MCP probe via Codex: {{MCP_SERVER}}" - client codex_probe + tier low-codex scope { owned ["{{OUT_DIR}}/probe_codex.probe"] } prompt probe-body max_retries 0 @@ -105,7 +84,7 @@ agent probe_codex { agent probe_cursor { description "MCP probe via Cursor: {{MCP_SERVER}}" - client cursor_probe + tier low-cursor scope { owned ["{{OUT_DIR}}/probe_cursor.probe"] } prompt probe-body max_retries 0 diff --git a/crates/gaviero-dsl/examples/pattern_map_reduce.gaviero b/crates/gaviero-dsl/examples/pattern_map_reduce.gaviero index 1e52cd5d..427f85ad 100644 --- a/crates/gaviero-dsl/examples/pattern_map_reduce.gaviero +++ b/crates/gaviero-dsl/examples/pattern_map_reduce.gaviero @@ -11,15 +11,9 @@ // Consensus-style multi-reviewer loops are not pattern sugar — use // examples/generic_consensus.gaviero (loop + reviewers roster) instead. -client scout { - model "claude:sonnet" - effort medium - default -} - agent discover { description "Discover work shards and write spawn_manifest.json" - client scout + tier medium scope { owned ["spawn_manifest.json" "artifacts/"] read_only ["docs/" "src/"] @@ -33,7 +27,7 @@ agent discover { "workers": [ { "id": "shard-1", - "model": "claude:sonnet", + "tier": "medium", "description": "Review shard 1", "prompt": "…", "owned": ["artifacts/shard-1/"], @@ -42,13 +36,15 @@ agent discover { ] } - Cap workers at a small number. Do not implement the shards yourself. + Each worker's `tier` is a tier of the run's model profile (low, + medium, high, top); never name a model. Cap workers at a small + number. Do not implement the shards yourself. "# } agent reduce { description "Aggregate fan-out worker results" - client scout + tier medium depends_on [discover] scope { owned ["artifacts/summary.md"] diff --git a/crates/gaviero-dsl/examples/phased_plan.gaviero b/crates/gaviero-dsl/examples/phased_plan.gaviero index 27a30234..753d8bc5 100644 --- a/crates/gaviero-dsl/examples/phased_plan.gaviero +++ b/crates/gaviero-dsl/examples/phased_plan.gaviero @@ -46,11 +46,9 @@ // Both prompts and scope paths substitute {{OUT_DIR}} at compile time, so // a single --var override relocates every output the script produces. -// Shared client library. Agents bind to concrete clients (`client opus` -// for the deep-reasoning steps, `client sonnet` for the cheap gate / -// judge). Swap to a different profile by editing the `client` field on -// each agent below. -include "clients.gaviero" +// Models: the deep-reasoning steps run on tier `high`, the cheap gate and +// judge on `medium`. The model profile (`--profile`) says which models +// those are; `--tier =` moves one agent for a run. vars { OUT_DIR "plans/log" @@ -228,7 +226,7 @@ prompt audit-body #" agent analyse_plan { description "Extract phases from plan: {{PROMPT}}" - client opus + tier high scope { owned ["{{OUT_DIR}}/00-briefing.md"] read_only ["src/" "tests/" "Cargo.toml" "CLAUDE.md" "ARCHITECTURE.md"] @@ -249,7 +247,7 @@ agent analyse_plan { // because phase_executor and phase_gate share the same loop group. agent phase_executor { description "Execute phase {{ITER}} from briefing" - client opus + tier high depends_on [analyse_plan] scope { owned ["src/" "tests/" "{{OUT_DIR}}/phase-*.md"] @@ -261,7 +259,7 @@ agent phase_executor { agent phase_gate { description "Gate verdict after phase {{ITER}}" - client sonnet + tier medium depends_on [phase_executor] scope { owned ["{{OUT_DIR}}/gate-*.md"] @@ -273,7 +271,7 @@ agent phase_gate { agent phase_judge { description "Judge whether all briefing phases are done" - client sonnet + tier medium scope { read_only ["{{OUT_DIR}}/"] } @@ -282,7 +280,7 @@ agent phase_judge { agent final_audit { description "Final integration audit: {{PROMPT}}" - client opus + tier high depends_on [phase_gate] scope { owned ["{{OUT_DIR}}/99-audit.md"] diff --git a/crates/gaviero-dsl/examples/plan_refinement.gaviero b/crates/gaviero-dsl/examples/plan_refinement.gaviero index 329d18f2..5c5fefe6 100644 --- a/crates/gaviero-dsl/examples/plan_refinement.gaviero +++ b/crates/gaviero-dsl/examples/plan_refinement.gaviero @@ -29,13 +29,12 @@ // --prompt-file plans/research-consensus-ux-brief.md \ // --var OUT_DIR=plans/research-consensus-ux // -// Default roster is Claude + Codex + Cursor (own models). Override with: -// --param roster=claude=claude:opus@max,codex=codex:gpt-5.6-sol@high,cursor=cursor:composer-2.5 -// Grok (Cursor CLI id embeds effort — omit @effort): -// --param roster=...,cursor=cursor:grok-4.7-high +// Default roster is Claude + Codex + Cursor, each on its provider's top +// tier of the model profile. Override with: +// --param roster=claude=high-claude,codex=high-codex,cursor=medium-cursor // -// Roster entry format: `id=provider:model[@effort]` (comma-separated). -// Each `id` becomes {{REVIEWER_ID}} in artefact paths under {{OUT_DIR}}/. +// Roster entry format: `id=tier` (comma-separated). Each `id` becomes +// {{REVIEWER_ID}} in artefact paths under {{OUT_DIR}}/. // // Resuming: re-running the same command against an {{OUT_DIR}} that // already holds artefacts continues the panel instead of overwriting it. @@ -161,6 +160,7 @@ prompt judge-body #" agent reviewer-refine { template true + tier top description "Implementation plan panel ({{REVIEWER_ID}})" scope { owned ["{{OUT_DIR}}/{{REVIEWER_ID}}-refine-*.md"] @@ -178,7 +178,7 @@ agent reviewer-refine { agent convergence-judge { description "Judge implementation-plan convergence" - client judge + tier medium scope { read_only ["{{OUT_DIR}}/"] } @@ -187,14 +187,10 @@ agent convergence-judge { workflow feature-plan-refinement { execution_mode document - param judge { - model "claude:sonnet" - effort medium - } param roster [ - { id "claude" model "claude:opus" effort xhigh } - { id "codex" model "codex:gpt-5.6-sol" effort xhigh } - { id "cursor" model "cursor:grok-4.7-high" } + { id "claude" tier top-claude } + { id "codex" tier top-codex } + { id "cursor" tier top-cursor } ] steps [ diff --git a/crates/gaviero-dsl/examples/profiles/doc-claude.gaviero b/crates/gaviero-dsl/examples/profiles/doc-claude.gaviero deleted file mode 100644 index dd63e2ea..00000000 --- a/crates/gaviero-dsl/examples/profiles/doc-claude.gaviero +++ /dev/null @@ -1,10 +0,0 @@ -// Default tier bindings for update_docs.gaviero (Claude opus + sonnet). -// -// Override at runtime without editing the workflow: -// gaviero-cli --script update_docs.gaviero \ -// --tiers-file crates/gaviero-dsl/examples/profiles/doc-codex.gaviero - -tier inventory fable -tier writer_deep fable -tier writer_standard opus -tier recorder opus \ No newline at end of file diff --git a/crates/gaviero-dsl/examples/profiles/doc-codex.gaviero b/crates/gaviero-dsl/examples/profiles/doc-codex.gaviero deleted file mode 100644 index ee0c0aa2..00000000 --- a/crates/gaviero-dsl/examples/profiles/doc-codex.gaviero +++ /dev/null @@ -1,6 +0,0 @@ -// Codex tier bindings for update_docs.gaviero. - -tier inventory codex-6-1-sol -tier writer_deep codex-6-1-sol -tier writer_standard codex-5-6-luna -tier recorder codex-5-6-luna diff --git a/crates/gaviero-tui/CLAUDE.md b/crates/gaviero-tui/CLAUDE.md index 6ce927c1..851cdd9c 100644 --- a/crates/gaviero-tui/CLAUDE.md +++ b/crates/gaviero-tui/CLAUDE.md @@ -38,7 +38,7 @@ Workspace dispatch: directory → `Workspace::single_folder`; `*.gaviero-workspa **Observer bridge:** implements `WriteGateObserver` and `AcpObserver` from [`gaviero_core::observer`](../gaviero-core/src/observer.rs), plus the memory / manifest / MCP observers. Each holds an event-channel sender. **No background task mutates `App` directly.** -**SWARM panel** (`Alt+w`): [`panels/swarm_dashboard.rs`](src/panels/swarm_dashboard.rs) holds state and rendering, [`app/swarm_run.rs`](src/app/swarm_run.rs) launching and input. Three views: script picker (`ScriptCatalog`, plus a path typed in the filter), input form (`gaviero_dsl::inspect_file`, plus a Profile selector when any model profile exists; its Prompt field is the chat's box, [`widgets/prompt_input.rs`](src/widgets/prompt_input.rs), and `$skill` is expanded at launch; `file` and `dir` vars complete like `@`, and roster / client params complete `tier:` from the selected profile plus the script; a list param is `FieldValue::List`, one input per item in `--param` entry syntax, split / rejoined by `split_list_value` / `join_list_items` — short form unless an item is a `{…}` literal, so free fields survive), and the run (one row per planned agent; the selected agent's output below). A run is `pipeline::execute` in-process, prepared by the same [`script_run`](../gaviero-core/src/swarm/script_run.rs) helpers as `gaviero-cli --script`; keep the two in step. It uses the pipeline's Write Gate, not TURN REVIEW. Every update carries a run id so a stopped run's stragglers are dropped. This panel is the only way the TUI runs a script: chat has no `/run`, and `/swarm`, `/cswarm` and `/undo-swarm` stay gone. Remote does not mirror the panel. +**SWARM panel** (`Alt+w`): [`panels/swarm_dashboard.rs`](src/panels/swarm_dashboard.rs) holds state and rendering, [`app/swarm_run.rs`](src/app/swarm_run.rs) launching and input. Three views: script picker (`ScriptCatalog`, plus a path typed in the filter), input form (`gaviero_dsl::inspect_file`, plus a Profile selector when any model profile exists; its Prompt field is the chat's box, [`widgets/prompt_input.rs`](src/widgets/prompt_input.rs), and `$skill` is expanded at launch; `file` and `dir` vars complete like `@`, and list params complete the tier after `id=` from the selected profile; the form opens on its first input, below the Folder / Workflow / Profile selectors; a list param is `FieldValue::List`, one input per item in `--param` entry syntax, split / rejoined by `split_list_value` / `join_list_items` — short form unless an item is a `{…}` literal, so free fields survive), and the run (one row per planned agent; the selected agent's output below). A run is `pipeline::execute` in-process, prepared by the same [`script_run`](../gaviero-core/src/swarm/script_run.rs) helpers as `gaviero-cli --script`; keep the two in step. It uses the pipeline's Write Gate, not TURN REVIEW. Every update carries a run id so a stopped run's stragglers are dropped. This panel is the only way the TUI runs a script: chat has no `/run`, and `/swarm`, `/cswarm` and `/undo-swarm` stay gone. Remote does not mirror the panel. **Turn review (mandatory):** [`app/turn_review.rs`](src/app/turn_review.rs) + the dispatch task in [`app/side_panel.rs`](src/app/side_panel.rs). Each chat turn is bracketed by `app.turn_capture.begin/end` (core `turn_capture`); the session runs with `AgentOptions::host_capture` and the conversation's gate mode `AutoAccept`. A non-empty change set opens the TURN REVIEW left panel (non-modal) and blocks *that* conversation's next prompt (desktop keeps the typed prompt; remote gets `turn_review_pending`). Pending reviews and their decisions persist under `.gaviero/turns/pending/` and reopen on startup. Any host write made while a turn may be running — editor saves, review reverts, MCP config synthesis — must go through `turn_review::note_host_write` or it is attributed to the agent. From 77971b548302aaa76acd37e86ecc1015e2ea977a Mon Sep 17 00:00:00 2001 From: Ignacio Martin Date: Mon, 16 Nov 2026 12:37:00 +0100 Subject: [PATCH 3/6] Document tier-only scripts and rewrite examples around profiles Docs and example scripts drop client blocks and tier bindings in favor of per-agent tiers, and a single default model profile replaces the old client roster and doc profiles. A new deep_explore example shows the runtime for and budget features. --- .../gaviero-dsl/examples/deep_explore.gaviero | 686 ++++++++++++++++++ .../examples/profiles/default.gaviero | 53 ++ .../examples/profiles/doc-cursor.gaviero | 10 - .../examples/scientific_research.gaviero | 53 +- .../examples/security_audit_memory.gaviero | 21 +- .../examples/tiered_review.gaviero | 23 +- .../gaviero-dsl/examples/update_docs.gaviero | 23 +- 7 files changed, 796 insertions(+), 73 deletions(-) create mode 100644 crates/gaviero-dsl/examples/deep_explore.gaviero create mode 100644 crates/gaviero-dsl/examples/profiles/default.gaviero delete mode 100644 crates/gaviero-dsl/examples/profiles/doc-cursor.gaviero diff --git a/crates/gaviero-dsl/examples/deep_explore.gaviero b/crates/gaviero-dsl/examples/deep_explore.gaviero new file mode 100644 index 00000000..70923f98 --- /dev/null +++ b/crates/gaviero-dsl/examples/deep_explore.gaviero @@ -0,0 +1,686 @@ +// description: Autonomous literature explorer — scouts a field through the academic MCP server, grows a frontier of questions, investigates, audits every claim, and reports +// +// What it does +// +// 0. `scout` maps the actively researched field before any question is +// asked — what is settled, what the research front is working on now, +// and where it is not looking: a dozen reformulated searches, citation +// graphs around the anchor papers, the newest work citing them, and +// one async Consensus review. +// It opens a per-run corpus collection on the academic server, so full +// texts are ingested in the background while the loop runs. +// +// Each pass N of the loop: +// 1. `curator` folds pass N-1 (findings + the audit of them) into the +// frontier, generates new avenues with explicit operators (decompose, +// falsify, bridge, analogy, recency, gap, method transfer), scores +// them, and picks a portfolio: exploit / explore / falsify. +// Writes frontier-vN.json, assignments-vN.json, journal + archive. +// 2. `for q in json "…assignments-vN.json"` clones `investigator` once +// per assignment (`investigator@`). Each runs a fixed research +// protocol on the academic server: corpus passages first, then search, +// full-text reading, backward + forward snowballing with citation +// contexts, retraction and venue checks, and one deliberate attempt +// to falsify its own best claim. +// 3. `verifier` — on a different model family — audits every claim of +// the pass against the source itself: the work resolves, it is not +// retracted, and a passage in its full text says what the claim says. +// It also checks task fidelity (did the lane answer the question it +// was given, or a nearby easier one?). Writes audit-vN.json. +// 4. `stop_judge` (read-only, another family) ends the loop when the +// frontier is exhausted or saturated — never because lanes agree. +// +// Then `synthesize` writes the report from verified claims only, and +// `citation_check` resolves every reference in it once more. +// +// Why this shape (research/gaviero-dsl-autonomous-deep-research-2026-11-13-v2.md): +// an archive/frontier with recorded failures, explicit generation +// operators and a selection rule, an external auditor that checks claims +// against artefacts, critique and judging by a different family than +// the generator, fresh-context units well under an hour, a budget. +// +// The academic MCP server +// +// Every agent calls the `academic` server (`--var ACADEMIC_SERVER=…` to +// rename). It must be listed in `mcp.extraServers` of +// .gaviero/settings.json and allowed by `mcp.permissions`. Claude agents +// see its tools as `mcp__academic__`. The tools used: +// +// search_works OpenAlex + Semantic Scholar + Europe PMC search; +// with `collection`, queues open-access full text +// search_corpus passage search over ingested full text +// get_fulltext sections of a stored work (queues it when missing) +// resolve_work any id / title → one merged record +// get_references backward snowball (with_contexts) +// get_citations forward snowball, newest first (with_contexts) +// citation_graph subgraph around a work, or a whole collection +// expand_collection works cited by many papers of the collection but +// not in it — the blind spots of the corpus +// check_retraction Crossref / OpenAlex / PubMed retraction status +// search_evidence Consensus: study design, sample size, takeaway +// start_review / get_review async Consensus literature review +// get_author, get_journal, ingest_status, list_collections, server_status +// +// The Consensus-backed tools go through the academic server, which +// holds the Consensus subscription; no key or switch lives here. +// +// Throughput: the server is a URL server, and gaviero runs document-mode +// workflows with a remote MCP server one agent at a time (pipeline.rs: +// "document mode with remote MCP: reducing max_parallel … to 1"). Lanes +// of a pass therefore run in sequence; the curator sizes passes for that. +// +// Models +// +// The script names no provider: every agent declares a tier and the +// model profile says what each one means — the `default` profile in +// .gaviero/dsl/profiles/ unless the run picks another (`--profile`). +// `verifier`, `stop_judge` and `citation_check` default to `medium`. +// Run them on a family different from the investigators', either with a +// profile whose `medium` is another provider (the shipped `mixed` +// profile: Codex against Claude lanes) or per run with `--tier`, e.g. +// `--tier verifier=medium-codex --tier stop_judge=medium-codex`. +// Set FALSIFY_TIER to a tier of your profile on another provider (e.g. +// `high-codex` in the shipped default profile) and the curator puts each +// falsification lane on it, against the family that made the claim. +// +// Inputs +// +// The run's prompt is the research brief (SWARM form Prompt box, or +// `--prompt`). Name a document's path in it to build on that document. +// OUT_DIR where every artefact goes (one directory per run) +// COLLECTION academic-server collection; empty = the scout picks +// `explore-` and records it in landscape.json +// FALSIFY_TIER tier for falsification lanes; empty = the +// investigator's own tier +// +// gaviero-cli --script deep_explore.gaviero --prompt "" +// gaviero-cli --script deep_explore.gaviero --var OUT_DIR=research/explore-x \ +// --tier verifier=medium-codex --tier stop_judge=medium-codex --prompt "…" +// +// Artefacts (all under OUT_DIR) +// +// landscape.json / landscape.md scout's field map (pass 0) +// frontier-vN.json every question: open / active / closed / dead / parked +// assignments-vN.json this pass's lanes (the `for` list) +// -finding-vN.json one per lane, typed claims + search log +// audit-vN.json per-claim verification + pass metrics +// journal.md curator's decisions, one section per pass +// archive.md dead ends and why (never re-explored) +// report-draft.md, report.md, report-audit.md + +vars { + OUT_DIR "research/explore" + COLLECTION "" + ACADEMIC_SERVER "academic" + FALSIFY_TIER "" +} + +// ── Scout ───────────────────────────────────────────────────────────────────── + +prompt scout-body #" + You are the scout of an autonomous literature exploration. The field + is actively researched: many groups are publishing on it right now. + This run is not after a summary of that work — it is after avenues the + field is NOT already pursuing. So your map must show three things + precisely: what is settled, what the research front is working on + today (so the run does not re-propose it), and where nobody is + looking. Your map decides where the run starts; breadth and honesty + matter more than conclusions. + + The research brief: + {{PROMPT}} + + Tools: the `{{ACADEMIC_SERVER}}` MCP server (Claude names its tools + mcp__{{ACADEMIC_SERVER}}__). WebSearch / WebFetch only as a + fallback (see Failures). Budget: about 60 tool calls. + + 1. Call server_status to confirm the server is up. + 2. Collection. If "{{COLLECTION}}" is non-empty use it; otherwise pick + `explore-<3-5 word slug of the brief>` and call list_collections to + make sure it is new (append -2, -3 … if not). Pass it as + `collection` on every search_works call of this run. + 3. Decompose the brief into 4-8 facets: the core question, its + mechanisms, its measurements/methods, the populations or settings, + the competing explanations, and the adjacent fields that study the + same mechanism under another name. For each facet write 2-3 query + formulations in DIFFERENT vocabularies (the field's jargon, a + neighbouring field's jargon, plain language). LLM-chosen queries + collapse onto one vocabulary; that is the main way a scout misses + half a field. + 4. Run search_works for every formulation (limit 20-30). Rerun the two + most important ones with year_min set to two years ago — the newest + work is what search ranks lowest. + 5. Pick 3-6 anchor works: the most cited foundational work, the most + recent review, and the works several facets keep returning. For + each: resolve_work, then citation_graph (depth 2, max_nodes 60) and + get_citations sorted year_desc (limit 30). Anchors define the + field's clusters; their newest citers define its frontier. + 6. Run search_evidence for the core question (limit 20) to see study + designs and sample sizes, and start ONE start_review (mode "pro") + on the core question. Do not wait for it; record its thread_id — + the curator collects it later. + 7. Identify for the curator: + - settled: what the field treats as established, with the + strongest evidence for it; + - research front: the questions the last 2 years of work are + actively pursuing, and who is pursuing them. An avenue that is + already a research front is not new — the run may build on it + but must not re-propose it; + - clusters: groups of works that cite each other, with a label, + representative works and what each believes; + - live controversies: claims that citers dispute (look at + get_citations contexts: "in contrast to", "failed to + replicate", "however"); + - leading groups/authors (get_author on 2-3 recurring names); + - stated open problems ("remains unknown", "future work"); + - bridges: works cited from two clusters that rarely cite each + other — where new avenues usually are; + - blind spots: assumptions every cluster shares, methods or + populations nobody uses, results that stopped being followed + up, adjacent fields that study the same mechanism but are + never cited. + Seed questions come mostly from controversies, open problems, + bridges and blind spots — not from the research front. + + Failures. If a tool times out or returns 429, wait and retry once, + then move on and record it. If the academic server is unreachable + altogether, use WebSearch/WebFetch, mark every source `channel: web`, + and say so in `channels`. Never invent a work, an id or a number. + + Write {{OUT_DIR}}/landscape.json: + {"collection": "", + "consensus_thread": "", + "channels": {"academic": "ok|degraded|down", "web": "used|unused"}, + "facets": [{"id": "f1", "label": "…", "queries": ["…"]}], + "anchors": [{"work_id": "", "title": "…", "year": 0, "why": "…"}], + "settled": [{"claim": "…", "evidence": [""]}], + "research_front": [{"question": "…", "pursued_by": [""], "recent_works": [""]}], + "blind_spots": [{"text": "…", "why": ""}], + "clusters": [{"id": "c1", "label": "…", "works": [""], "position": "…"}], + "controversies": [{"claim": "…", "for": [""], "against": [""]}], + "open_problems": [{"text": "…", "source": ""}], + "bridges": [{"work_id": "…", "connects": ["c1", "c2"], "why": "…"}], + "groups": [{"author": "…", "openalex_id": "…", "focus": "…"}], + "seed_questions": [{"question": "…", "kind": "core|mechanism|method|contrarian|adjacent|gap|bridge|blind_spot", "why": ""}], + "search_log": [{"tool": "…", "args": "…", "result": ""}]} + + And {{OUT_DIR}}/landscape.md: a one-page human-readable map of the + same, ending with the 8-15 seed questions you would ask first and the + evidence that makes each one promising. +"# + +// ── Curator ─────────────────────────────────────────────────────────────────── + +prompt curate-body #" + You curate an autonomous literature exploration. Pass {{ITER}}. You + are the only agent that sees the whole run; investigators see one + question each. Your job is to make the frontier grow where the + evidence is thin or surprising, and shrink where it is settled. + + The research brief: + {{PROMPT}} + + Read, in this order: + - {{OUT_DIR}}/landscape.json (the scout's map; it names the + collection to use); + - {{OUT_DIR}}/frontier-v{{PREV_ITER}}.json, + {{OUT_DIR}}/audit-v{{PREV_ITER}}.json and every + {{OUT_DIR}}/*-finding-v{{PREV_ITER}}.json (none exist on pass 1; + seed the frontier from landscape.json instead); + - {{OUT_DIR}}/archive.md and {{OUT_DIR}}/journal.md if they exist. + + Tools: the `{{ACADEMIC_SERVER}}` MCP server, about 25 calls. + + A. Merge the previous pass. + - A question becomes `closed` only when the audit marks the claims + that answer it `supported`. `partial` keeps it open with a + narrower wording; `not_supported` or `cannot_verify` never close + anything. A lane the audit flags for task substitution did not + answer its question: reopen it. + - Unresolvable or retracted sources: drop their claims and log + them in archive.md. + - Add each finding's `children` as candidate questions, with the + finding as parent and depth = parent depth + 1. + - Move a question to `dead` (and append a line to archive.md: + question, why, evidence) when two lanes found nothing usable, or + the literature cannot answer it (it needs an experiment nobody + ran — mark it `parked` instead and keep it for the report). + - If landscape.json has a consensus_thread and pass 1 or 2 has not + collected it yet, call get_review; when finished, mine it for + claims to check and questions to add. + + B. Generate new avenues. Novel directions do not appear by asking + for "more questions"; apply each operator below to the current + state and keep only candidates with a concrete evidence hook: + - decompose: split a broad open question into testable parts; + - falsify: for the leading claim of the run, what result would + refute it — and has anyone looked? + - bridge: call expand_collection (dry_run true) on the collection — + works many of our papers cite but we have not read are blind + spots; also citation_graph on the collection to find clusters + that never cite each other; + - analogy: which other field studies the same mechanism under + another name? + - recency: what appeared in the last 12 months that cites our + anchors (get_citations year_desc on 1-2 anchors)? + - gap: open problems and "future work" statements found by lanes; + - method transfer: a method used in one cluster that would test a + claim of another. + + C. Score and dedupe. Each open question gets scores 0-3 for + relevance to the brief, expected information gain (how much the + answer would change the report), novelty (distance from the + field's own research front in landscape.json — a question active + groups are already pursuing scores 0 — and from closed, dead and + archived questions — near-duplicates are merged, not re-asked), + and tractability (can literature answer it?). + priority = relevance + gain + novelty + tractability − depth. + Limits: depth ≤ 3; at most 40 questions ever created; each depth + level gets at most half the new questions of the level above. + + D. Choose this pass's assignments — a portfolio, not a top-k: + - 1-2 exploit lanes: the highest-priority open questions; + - 1 explore lane: a high-novelty question from a bridge, analogy + or recency operator, even if its priority is lower; + - from pass 2 on, 1 falsify lane: attack the run's strongest + current claim. If "{{FALSIFY_TIER}}" is non-empty, give that lane + `"tier": "{{FALSIFY_TIER}}"` (a tier on another model family than + the investigators'); otherwise leave `tier` out. Never invent a + tier name: an unknown tier stops the run. + At most 5 lanes (lanes run one after another, ~40 min each). Fewer + when little is open. `[]` when nothing open is worth a lane. + Never assign a question already in archive.md. + + Write {{OUT_DIR}}/frontier-v{{ITER}}.json: + {"pass": {{ITER}}, "collection": "", + "questions": [{"id": "q7", "question": "…", "kind": "core|mechanism|method|contrarian|adjacent|gap|bridge|blind_spot", + "operator": "seed|decompose|falsify|bridge|analogy|recency|gap|method_transfer|child", + "parent": "", "depth": 0, + "status": "open|active|closed|dead|parked", + "scores": {"relevance": 0, "gain": 0, "novelty": 0, "tractability": 0}, "priority": 0, + "visits": 0, "supported_claims": ["#"], + "why": ""}], + "leading_claims": [""], + "metrics": {"open": 0, "closed": 0, "dead": 0, "parked": 0, "created_total": 0}} + + Write {{OUT_DIR}}/assignments-v{{ITER}}.json: a JSON array, one flat + object per lane, EVERY field present on every item (use "" when + empty) — a missing field stops the run: + [{"id": "-p{{ITER}}", "question": "…", + "lens": "exploit|explore|falsify", + "kind": "", + "why": "", + "start_from": "<2-5 work ids or DOIs to start from, comma-separated>", + "avoid": "", + "done_when": ""}] + A falsify lane may add "tier" (see D); no item names a model. + + Append a `## Pass {{ITER}}` section to {{OUT_DIR}}/journal.md: what + the previous pass changed, which operators produced which questions, + why these lanes, and what you deliberately did not pursue. +"# + +// ── Investigator ────────────────────────────────────────────────────────────── + +prompt investigate-body #" + You investigate one question of an autonomous literature exploration, + from a fresh context. Other lanes cover other questions; stay on yours. + + The research brief (context only — your question is below): + {{PROMPT}} + + Your assignment (lane {{q.index}} of {{q.count}}, pass {{ITER}}): + question: {{q.question}} + lens: {{q.lens}} (exploit = answer it well; explore = map + an unfamiliar direction and report what is there; + falsify = try hard to refute the named claim) + kind: {{q.kind}} + why: {{q.why}} + start from: {{q.start_from}} + avoid: {{q.avoid}} + done when: {{q.done_when}} + + Read {{OUT_DIR}}/landscape.json for the collection name and the + field map. Read other files under {{OUT_DIR}}/ only when you need them. + + Tools: the `{{ACADEMIC_SERVER}}` MCP server (Claude: + mcp__{{ACADEMIC_SERVER}}__), at most 3 search_evidence calls. + Budget: about 45 tool calls; stop searching when two consecutive searches bring + nothing new, and write up. + + Protocol: + 1. Corpus first. search_corpus (collection = the run's) with 2-3 + phrasings of the question: earlier lanes may already have ingested + the key texts. + 2. Search. search_works with 3+ formulations in different vocabularies + (pass the collection, so open-access full texts get ingested for + the verifier), plus one with year_min two years back. + 3. Read, do not skim. Pick the 3-6 works your answer will rest on and + read the relevant sections with get_fulltext (section = "results", + "discussion", "methods" …). A claim backed only by an abstract is + labelled `abstract_only`. If a work is not stored yet, get_fulltext + with the collection queues it; continue and check back at the end. + 4. Snowball. For each load-bearing work: get_references (backward — + what it rests on) and get_citations sorted year_desc with + with_contexts true (forward — how the field received it; look for + disputes, failed replications, extensions). Follow at most 2 hops. + 5. Weigh. check_retraction on every load-bearing source. When study + quality matters, search_evidence for design and sample size and + get_journal for the venue. Prefer primary studies and replications + over reviews; say when evidence is one group, one dataset or one + paper. + 6. Falsify. Make at least one deliberate search for evidence against + your strongest claim ("failed to replicate", "no effect", + "contrary to", the opposite mechanism). Report what you found, + including nothing. + 7. Propose. 1-3 child questions that your evidence makes promising — + each with the evidence hook (a dispute, a gap statement, an + unexpected result, a bridge). No generic "more research is needed". + + Fidelity. If the question as asked cannot be answered from the + literature, say so and set fidelity to "narrowed" or "substituted" + with the reason. Answering a nearby easier question while presenting + it as the asked one is the failure this run audits for. + + Failures. A timeout or 429: wait, retry once, then move on and log + it. If the academic server is down, use WebSearch/WebFetch and mark + those sources `channel: web`. Never invent a work, an id, a quote or + a number. Always write the file below, even if you found nothing — + set "outcome": "blocked" and explain. + + Write {{OUT_DIR}}/{{q.id}}-finding-v{{ITER}}.json: + {"assignment_id": "{{q.id}}", "question": "", + "outcome": "answered|partial|nothing_found|blocked", + "fidelity": "exact|narrowed|substituted", "fidelity_note": "…", + "analysis_run": "", + "answer": "", + "claims": [{"text": "", + "work_id": "", "title": "…", "year": 0, + "locator": "
", + "quote": "<≤40 words copied from the source, or empty>", + "evidence": "fulltext|abstract_only|citation_context|consensus", + "strength": "replicated|single_study|review|preprint|contested", + "confidence": "high|medium|low", + "channel": "academic|web"}], + "counter_evidence": [{"text": "…", "work_id": "…"}], + "children": [{"question": "…", "kind": "…", "why": ""}], + "dead_ends": [{"what": "…", "why": "…"}], + "search_log": [{"tool": "…", "args": "", "result": ""}]} +"# + +// ── Verifier ────────────────────────────────────────────────────────────────── + +prompt verify-body #" + You audit pass {{ITER}} of an autonomous literature exploration. You + are on a different model family from the investigators on purpose: + do not trust their summaries, check the sources. LLM research agents + routinely cite works that do not exist, cite real works for claims + they do not make, and answer an easier question than the one asked. + + The research brief: {{PROMPT}} + + Read {{OUT_DIR}}/assignments-v{{ITER}}.json and every + {{OUT_DIR}}/*-finding-v{{ITER}}.json listed there, plus + {{OUT_DIR}}/landscape.json for the collection name. If the assignment + list is empty, write the audit below with empty lists. + + Tools: the `{{ACADEMIC_SERVER}}` MCP server, about 60 calls. If there + are more claims than you can check, check every claim marked + confidence high or that would close a question, then a sample of the + rest, and say which were sampled. + + For each claim: + 1. Existence: resolve_work on its work_id (or title + year). A work + that does not resolve, or whose title/year differ materially, is + `not_supported` with reason "unresolvable". + 2. Status: check_retraction. Retracted → `not_supported`. + 3. Support: find the passage. search_corpus (collection) with the + claim's wording, or get_fulltext of the work at the claimed + locator. Compare the claim with what the passage says — scope, + direction, magnitude, population. Label: + supported the passage states it; + partial the passage states a weaker or narrower version; + not_supported the source does not say it, or says the opposite; + cannot_verify no full text yet (the claim stays unverified and + is rechecked next pass — say so). + Quote the passage you relied on (≤40 words). + 4. Reception: for supported claims that would close a question, one + get_citations (with_contexts) look for later disputes. + + For each finding: compare `analysis_run` and `answer` with the + assigned question. Flag `substituted` when it answered something else, + even if it said "exact". Flag claims that two lanes state in + contradiction. + + Write {{OUT_DIR}}/audit-v{{ITER}}.json: + {"pass": {{ITER}}, + "claims": [{"finding": "", "index": 0, "verdict": "supported|partial|not_supported|cannot_verify", + "reason": "…", "passage": "", "checked_via": "corpus|fulltext|abstract|citations", + "retracted": false, "resolved": true, "sampled": false}], + "fidelity": [{"finding": "", "verdict": "exact|narrowed|substituted", "note": "…"}], + "contradictions": [{"a": "#", "b": "#", "note": "…"}], + "metrics": {"claims": 0, "checked": 0, "supported": 0, "partial": 0, "not_supported": 0, + "cannot_verify": 0, "unresolvable": 0, "retracted": 0, + "new_children": 0, "novel_children": 0}, + "saturation": ""} + `novel_children` counts children that are not near-duplicates of + questions already in {{OUT_DIR}}/frontier-v{{ITER}}.json or archive.md. +"# + +// ── Stop judge ──────────────────────────────────────────────────────────────── + +prompt stop-body #" + Decide whether an autonomous literature exploration should run another + pass. The research brief: {{PROMPT}} + + Read {{OUT_DIR}}/frontier-v{{ITER}}.json (the questions as they stood + when this pass started), {{OUT_DIR}}/assignments-v{{ITER}}.json and + {{OUT_DIR}}/audit-v{{ITER}}.json (what this pass returned and how + much of it held up). Read findings only when the audit is ambiguous. + If {{OUT_DIR}}/audit-v{{PREV_ITER}}.json exists, compare the metrics. + + Return pass (stop) only when one of these holds: + - exhausted: no open question has priority ≥ 6 that the literature + can answer, and this pass's children are not novel; + - saturated: this pass and the previous one each added fewer than 2 + newly supported claims and fewer than 2 novel children; + - the brief's core questions all have supported answers and every + remaining open question is marginal to the brief. + Return fail (continue) otherwise — in particular when this pass opened + novel high-priority questions, or when key claims are still + cannot_verify and the next pass can check them. + + Never stop because the lanes agree with each other: agreement between + language models is not evidence. Never continue only because questions + exist: some questions are parked for the report on purpose. + + Reply with exactly one JSON object as your last output: + {"verdict": "pass" | "fail", "reason": ""} +"# + +// ── Report ──────────────────────────────────────────────────────────────────── + +prompt synth-body #" + Write the report of an autonomous literature exploration. + + The research brief: + {{PROMPT}} + + Inputs under {{OUT_DIR}}/: landscape.md / landscape.json, the latest + frontier-v*.json, every *-finding-v*.json, every audit-v*.json, + journal.md and archive.md. + + Use only claims some audit marked `supported` (or `partial`, stated + at the strength the audit found). A claim with no audit verdict, or + `cannot_verify`, may appear only in the "Unverified leads" section, + labelled as such. Do not add sources the run did not find. + + Write {{OUT_DIR}}/report-draft.md with these sections: + ## Answer — the direct answer to the brief, 1-3 paragraphs. + ## Findings — one subsection per closed question, ranked by + relevance to the brief: the claim, the evidence (strength: + replicated / single study / review / preprint), the counter- + evidence, and references as [n]. + ## New avenues — the directions this run opened that neither the + brief nor the field's current research front (landscape.json) + names: where each came from (bridge, analogy, blind spot, gap…), + why active groups are not already on it, + what evidence makes it promising, and the first study or + analysis that would test it. + ## Contested and open — live disputes, parked questions (what + experiment or data would answer them), and unverified leads. + ## How the field was explored — passes, lanes, operators used, + what was abandoned and why (from journal.md and archive.md). + ## Audit — claims checked, share supported / partial / not + supported / unverifiable, unresolvable or retracted sources, + task substitutions caught. + ## References — numbered; title, authors, venue, year, DOI or + OpenAlex id. +"# + +prompt cite-body #" + You are the final citation check of an autonomous literature + exploration. Read {{OUT_DIR}}/report-draft.md and the audit files + {{OUT_DIR}}/audit-v*.json. + + Tools: the `{{ACADEMIC_SERVER}}` MCP server. + 1. resolve_work every entry of `## References`; fix wrong metadata, + remove entries that do not resolve and every sentence that relied + only on them. + 2. check_retraction every entry. + 3. For each sentence in Findings and New avenues that cites [n], + confirm an audit verdict supports it; when none does, move the + sentence to "Unverified leads" or soften it to what the audit + found. + + Write {{OUT_DIR}}/report.md (the corrected report) and + {{OUT_DIR}}/report-audit.md (each change you made and why, plus + references checked / fixed / removed). +"# + +// ── Agents ──────────────────────────────────────────────────────────────────── + +agent scout { + description "Map the field before the first question" + tier high + tools ["WebSearch" "WebFetch"] + scope { + owned [ + "{{OUT_DIR}}/landscape.json" + "{{OUT_DIR}}/landscape.md" + ] + read_only ["{{OUT_DIR}}/"] + } + produces ["{{OUT_DIR}}/landscape.md"] + produces json ["{{OUT_DIR}}/landscape.json"] + timeout 2400 + prompt scout-body +} + +agent curator { + description "Curate the frontier, pass {{ITER}}" + tier top + depends_on [scout] + scope { + owned [ + "{{OUT_DIR}}/frontier-v*.json" + "{{OUT_DIR}}/assignments-v*.json" + "{{OUT_DIR}}/archive.md" + "{{OUT_DIR}}/journal.md" + ] + read_only ["{{OUT_DIR}}/"] + } + produces ["{{OUT_DIR}}/journal.md"] + produces json [ + "{{OUT_DIR}}/frontier-v{{ITER}}.json" + "{{OUT_DIR}}/assignments-v{{ITER}}.json" + ] + timeout 1800 + prompt curate-body +} + +agent investigator { + description "Investigate {{q.id}} ({{q.lens}})" + tier high + depends_on [curator] + tools ["WebSearch" "WebFetch"] + scope { + owned ["{{OUT_DIR}}/{{q.id}}-finding-v*.json"] + read_only ["{{OUT_DIR}}/"] + } + produces json ["{{OUT_DIR}}/{{q.id}}-finding-v{{ITER}}.json"] + timeout 2400 + prompt investigate-body +} + +agent verifier { + description "Audit the claims of pass {{ITER}}" + tier medium + depends_on [investigator] + scope { + owned ["{{OUT_DIR}}/audit-v*.json"] + read_only ["{{OUT_DIR}}/"] + } + produces json ["{{OUT_DIR}}/audit-v{{ITER}}.json"] + timeout 2400 + prompt verify-body +} + +agent stop_judge { + description "Decide whether the frontier is exhausted" + tier medium + scope { read_only ["{{OUT_DIR}}/"] } + prompt stop-body +} + +agent synthesize { + description "Write the report draft" + tier top + depends_on [verifier] + scope { + owned ["{{OUT_DIR}}/report-draft.md"] + read_only ["{{OUT_DIR}}/"] + } + produces ["{{OUT_DIR}}/report-draft.md"] + timeout 2400 + prompt synth-body +} + +agent citation_check { + description "Resolve every reference of the report" + tier medium + depends_on [synthesize] + scope { + owned [ + "{{OUT_DIR}}/report.md" + "{{OUT_DIR}}/report-audit.md" + ] + read_only ["{{OUT_DIR}}/"] + } + produces [ + "{{OUT_DIR}}/report.md" + "{{OUT_DIR}}/report-audit.md" + ] + timeout 1800 + prompt cite-body +} + +workflow deep-explore { + execution_mode document + max_parallel 4 + budget { wall "10h" usd 60 } + steps [ + scout + loop { + agents [curator verifier] + for q in json "{{OUT_DIR}}/assignments-v{{ITER}}.json" parallel max 6 { investigator } + max_iterations 6 + irreconcilable_after 0 + strict_judge false + judge_timeout 300 + until agent stop_judge + } + synthesize + citation_check + ] +} diff --git a/crates/gaviero-dsl/examples/profiles/default.gaviero b/crates/gaviero-dsl/examples/profiles/default.gaviero new file mode 100644 index 00000000..026de863 --- /dev/null +++ b/crates/gaviero-dsl/examples/profiles/default.gaviero @@ -0,0 +1,53 @@ +// Model profile: what each tier means when a run chooses no other. +// +// Scripts never name a model. Every agent declares a tier (`tier high`); a +// workflow may move an agent to another tier (`tiers { judge medium }`), and +// so may a run (`--tier judge=medium-codex`). This file is the one place a +// tier becomes a model. +// +// The generic tiers (low, medium, high, top) are on Claude. The +// - tiers pin a step to that level of one provider — use +// them to put a critic or a judge on another model family than the agents +// it checks. +// +// Copy this file to .gaviero/dsl/profiles/default.gaviero (workspace) or +// $GAVIERO_ROOT/.gaviero/dsl/profiles/default.gaviero (global) and edit it. + +client haiku { model "claude:haiku" privacy public effort low } +client sonnet { model "claude:sonnet" privacy public effort medium } +client opus { model "claude:opus" privacy public effort high } +client fable { model "claude:fable" privacy public effort max } + +client luna { model "codex:gpt-6-luna" privacy public effort low } +client terra { model "codex:gpt-6.1-terra" privacy public effort medium } +client sol { model "codex:gpt-6.1-sol" privacy public effort high } +client astra { model "codex:gpt-6-astra" privacy public effort high } + +client composer { model "cursor:composer-2.5" privacy public } +// The Cursor CLI id carries the effort (`agent --list-models`). +client grok { model "cursor:grok-4.7-high" privacy public } + +// DeepSeek through `dsh --profile acp`; accepts low, high and max effort. +client flash { model "dsh:deepseek-flash" privacy public effort high } + +tier low haiku +tier medium sonnet +tier high opus +tier top fable + +tier low-claude haiku +tier medium-claude sonnet +tier high-claude opus +tier top-claude fable + +tier low-codex luna +tier medium-codex terra +tier high-codex sol +tier top-codex astra + +tier low-cursor composer +tier medium-cursor composer +tier high-cursor composer +tier top-cursor grok + +tier high-deepseek flash diff --git a/crates/gaviero-dsl/examples/profiles/doc-cursor.gaviero b/crates/gaviero-dsl/examples/profiles/doc-cursor.gaviero deleted file mode 100644 index 36a259f8..00000000 --- a/crates/gaviero-dsl/examples/profiles/doc-cursor.gaviero +++ /dev/null @@ -1,10 +0,0 @@ -// Default tier bindings for update_docs.gaviero (Claude opus + sonnet). -// -// Override at runtime without editing the workflow: -// gaviero-cli --script update_docs.gaviero \ -// --tiers-file crates/gaviero-dsl/examples/profiles/doc-codex.gaviero - -tier inventory grok -tier writer_deep grok -tier writer_standard composer -tier recorder composer \ No newline at end of file diff --git a/crates/gaviero-dsl/examples/scientific_research.gaviero b/crates/gaviero-dsl/examples/scientific_research.gaviero index 433c0939..38491f14 100644 --- a/crates/gaviero-dsl/examples/scientific_research.gaviero +++ b/crates/gaviero-dsl/examples/scientific_research.gaviero @@ -119,22 +119,15 @@ // // The reviewer panel is a workflow parameter — supplied via // `--param roster=...`. The in-script default below runs a -// three-provider frontier panel at maximum research depth: -// Claude Opus + Codex GPT-5.6 Sol + Cursor Grok 4.6. Each roster -// entry is `id=provider:model[@effort]`; the id becomes the filename -// prefix and the model + effort bind the cloned reviewer agent to an -// anonymous client. Use distinct ids per reviewer. -// -// Cursor note: the Cursor backend does not forward `effort`; -// reasoning depth rides on the model id itself. -// `cursor:grok-4.7-high` is the canonical id (see -// clients.gaviero) — check variants with `agent --list-models` -// before inventing suffixes. -// -// The judge stays on `claude:sonnet` at `medium` — it only -// classifies summaries against a fixed rubric and runs once per -// iteration, so raising its effort multiplies cost without -// improving the verdict. +// three-provider frontier panel: the top Claude, Codex and Cursor +// tiers of the run's model profile. Each roster entry is `id=tier`; +// the id becomes the filename prefix and the tier sets the cloned +// reviewer's model. Use distinct ids per reviewer. +// +// The judge runs on tier `medium` — it only classifies summaries +// against a fixed rubric and runs once per iteration, so a larger +// model multiplies cost without improving the verdict. Move it for +// one run with `--tier convergence-judge=`. // // Files written per iteration N (N=1 for init, N=2..11 for refinement): // @@ -299,7 +292,7 @@ // --workflow scientific-research-consensus \ // --workspace /path/to/research-workspace \ // --prompt "Short topic title for logs" \ -// --param roster=claude=claude:opus@xhigh,codex=codex:gpt-5.6-sol@xhigh +// --param roster=claude=top-claude,codex=top-codex // ── Shared configuration ────────────────────────────────────────────────────── // @@ -886,12 +879,12 @@ prompt judge-body #" // // Two reviewer templates (init and refine) plus a fixed convergence // judge. The init / refine templates are cloned per roster entry by -// the loop expansion in crates/gaviero-dsl/src/reviewers.rs: +// the loop expansion in crates/gaviero-dsl/src/workflow_params.rs: // // - {{REVIEWER_ID}} is substituted with each entry's id in the // description, scope paths, and prompt body. -// - Each clone is bound to an anonymous client carrying that entry's -// model + effort. +// - Each clone runs on that entry's tier (the template's own `tier` +// when the entry names none). // - Refine clones additionally get {{PEER_IDS}}, {{PEER_COUNT}}, and // {{PEER_READ_BLOCK}} substituted for cross-reviewer prompting. // @@ -905,6 +898,7 @@ prompt judge-body #" agent reviewer-init { template true + tier top description "Initial scientific research analysis ({{REVIEWER_ID}}): {{PROMPT}}" tools ["WebSearch" "WebFetch"] scope { @@ -931,6 +925,7 @@ agent reviewer-init { agent reviewer-refine { template true + tier top description "Refine scientific research conclusion ({{REVIEWER_ID}}): {{PROMPT}}" tools ["WebSearch" "WebFetch"] scope { @@ -963,7 +958,7 @@ agent reviewer-refine { agent convergence-judge { description "Judge consensus across reviewer panel: {{PROMPT}}" - client judge + tier medium scope { read_only ["{{OUT_DIR}}/" "{{PLAN_FILE}}"] } @@ -976,12 +971,10 @@ agent convergence-judge { // The `roster` workflow parameter binds the loop's `reviewers` slot to // a list of provider entries. Override entirely from the CLI: // -// --param roster=claude=claude:opus@xhigh,codex=codex:gpt-5.6-sol@xhigh,cursor=cursor:grok-4.7-high +// --param roster=claude=top-claude,codex=top-codex,cursor=top-cursor // // The in-script default below runs that same three-provider frontier -// panel (Claude Opus + Codex GPT-5.6 Sol + Cursor Grok 4.7) so the -// example works with no flag. The Cursor entry's `effort` is a no-op — -// the Cursor backend does not forward it (see header roster note). +// panel so the example works with no flag. // // `execution_mode document` (see header) is declared on this workflow: // refine agents must read peer artefacts under {{OUT_DIR}}/, which @@ -1027,14 +1020,10 @@ agent convergence-judge { workflow scientific-research-consensus { execution_mode document - param judge { - model "claude:sonnet" - effort medium - } param roster [ - { id "claude" model "claude:opus" effort xhigh } - { id "codex" model "codex:gpt-5.6-sol" effort xhigh } - { id "cursor" model "cursor:grok-4.7-high" } + { id "claude" tier top-claude } + { id "codex" tier top-codex } + { id "cursor" tier top-cursor } ] steps [ diff --git a/crates/gaviero-dsl/examples/security_audit_memory.gaviero b/crates/gaviero-dsl/examples/security_audit_memory.gaviero index d41f5283..33e61309 100644 --- a/crates/gaviero-dsl/examples/security_audit_memory.gaviero +++ b/crates/gaviero-dsl/examples/security_audit_memory.gaviero @@ -14,18 +14,19 @@ // ── Clients ────────────────────────────────────────────────────────────────── // -// Pulls in the shared client library. The privacy-interaction bullet at -// the top of this file refers to a `privacy local_only` client; if you -// want to demonstrate that, add one locally: -// client local { privacy local_only } -// and bind the relevant agent to it. -include "clients.gaviero" +// Agents name tiers; the model profile maps them to clients. The +// privacy-interaction bullet at the top of this file refers to a +// `privacy local_only` client; to demonstrate it, give the run a profile +// with a local tier, e.g. +// client local { model "ollama:qwen" privacy local_only } +// tier local local +// and move the relevant agent onto it: `--tier verify=local`. // ── Agents ─────────────────────────────────────────────────────────────────── agent scan { description "Scan codebase for security vulnerabilities" - client opus + tier high scope { owned ["docs/security_findings.md"] read_only ["src/" "Cargo.toml" "Cargo.lock"] @@ -55,7 +56,7 @@ Use memory context for any prior audit results. agent fix { description "Fix identified vulnerabilities" - client sonnet + tier medium depends_on [scan] scope { owned ["src/"] @@ -78,7 +79,7 @@ primary reference. Apply minimal, targeted fixes without refactoring. agent write_tests { description "Write security regression tests" - client sonnet + tier medium depends_on [fix] scope { owned ["tests/security/"] @@ -98,7 +99,7 @@ Each test should verify that the specific vulnerability no longer exists. agent verify { description "Verify all fixes and tests pass" - client sonnet + tier medium depends_on [write_tests] scope { read_only ["src/" "tests/" "docs/security_findings.md"] diff --git a/crates/gaviero-dsl/examples/tiered_review.gaviero b/crates/gaviero-dsl/examples/tiered_review.gaviero index 3576ca64..3e947265 100644 --- a/crates/gaviero-dsl/examples/tiered_review.gaviero +++ b/crates/gaviero-dsl/examples/tiered_review.gaviero @@ -1,13 +1,17 @@ // description: Provider-agnostic review; models come from the profile // -// This script names no provider and declares no client: agents ask for a tier -// (`low`, `medium`, `high`, `top`), and the profile says what each one means. -// Run the same file on different models without editing it: +// This script names no provider and declares no client: every agent asks +// for a tier (`low`, `medium`, `high`, `top`), and the profile says what +// each one means. Run the same file on different models without editing it: // // gaviero-cli --script tiered_review.gaviero --profile claude --prompt "the auth module" // gaviero-cli --script tiered_review.gaviero --profile mixed --prompt "the auth module" // -// `model "tier:"` does the same for workflow params and rosters. +// Three places choose a tier, and each beats the one before it: +// 1. the agent's own `tier` — its default; +// 2. the workflow's `tiers { }` block — this workflow moves `verdict`; +// 3. `--tier =` on the command line, for one run. +// A roster or list item's `tier` moves that item's clone. agent gather { description "List the files relevant to the review" @@ -21,6 +25,7 @@ agent gather { agent reviewer_template { template true + tier high description "Review the listed files" scope { owned [".gaviero/review/{{REVIEWER_ID}}.md"] } prompt #" @@ -31,7 +36,7 @@ agent reviewer_template { agent verdict { description "Decide whether the reviews agree" - client judge + tier low scope { read_only [".gaviero/review/**"] } prompt #" Read the reviews in .gaviero/review/ and reply with a verdict on @@ -40,10 +45,12 @@ agent verdict { } workflow tiered_review { - param judge { model "tier:medium" } + tiers { + verdict medium + } param panel [ - { id "first" model "tier:high" } - { id "second" model "tier:top" } + { id "first" } + { id "second" tier top } ] steps [ gather diff --git a/crates/gaviero-dsl/examples/update_docs.gaviero b/crates/gaviero-dsl/examples/update_docs.gaviero index 5eaab919..8db67beb 100644 --- a/crates/gaviero-dsl/examples/update_docs.gaviero +++ b/crates/gaviero-dsl/examples/update_docs.gaviero @@ -14,14 +14,11 @@ // Usage: // gaviero-cli --script crates/gaviero-dsl/examples/update_docs.gaviero // -// Swap model combinations via a tiers profile (semantic role → client): -// gaviero-cli --script .../update_docs.gaviero \ -// --tiers-file .../profiles/doc-codex.gaviero - -// Client pool + default tier bindings (override with --tiers-file). -include "clients.gaviero" -// include "profiles/doc-claude.gaviero" -include "profiles/doc-cursor.gaviero" +// Models: inventory and the deep writers run on tier `top`, the standard +// writer and the recorder on `medium`. Swap every model at once with a +// model profile, or move one agent: +// gaviero-cli --script .../update_docs.gaviero --profile codex +// gaviero-cli --script .../update_docs.gaviero --tier write_readme_md=high // ── Shared configuration ────────────────────────────────────────────────────── // @@ -76,7 +73,7 @@ prompt doc_write_body #" agent inventory { description "Inventory all crates and their documentation state" - tier inventory + tier top scope { read_only [ "src/" "crates/" "Cargo.toml" @@ -118,7 +115,7 @@ The fixed context injected into every AI prompt. It must contain: "# } description "Rewrite {{DOC_NAME}} for all crates: {{PROMPT}}" - tier writer_deep + tier top depends_on [inventory] scope { owned [ @@ -158,7 +155,7 @@ The user-facing description of each crate/project. It must contain: "# } description "Rewrite {{DOC_NAME}} for all crates: {{PROMPT}}" - tier writer_standard + tier medium depends_on [inventory] scope { owned [ @@ -199,7 +196,7 @@ The deep technical description of a crate/project. It must contain: "# } description "Rewrite {{DOC_NAME}} for all crates: {{PROMPT}}" - tier writer_deep + tier top depends_on [inventory] scope { owned [ @@ -224,7 +221,7 @@ agent record_docs_update { REVIEW_SCOPE "CLAUDE.md (AI context), README.md (user guide), ARCHITECTURE.md (technical design)" } description "Record documentation update to memory: {{PROMPT}}" - tier recorder + tier medium depends_on [write_claude_md write_readme_md write_architecture_md] scope { read_only ["CLAUDE.md" "README.md" "ARCHITECTURE.md" "crates/"] From 0756d06a06de6b490959a442b490d70ba13d90ac Mon Sep 17 00:00:00 2001 From: Ignacio Martin Date: Mon, 16 Nov 2026 12:37:01 +0100 Subject: [PATCH 4/6] Add runtime for-loops, budgets, JSON outputs and cost totals to swarm The swarm runtime gains runtime for expansion, parallel dispatch, budget enforcement and produces-json validation, and retries now report the summed cost of every attempt. The coordinator prompt teaches tiers, produces and timeout, and the new WorkUnit field is carried through every constructor. --- crates/gaviero-core/src/iteration/mod.rs | 72 +- .../src/iteration/test_generator.rs | 1 + crates/gaviero-core/src/mcp/preflight.rs | 1 + .../gaviero-core/src/swarm/backend/runner.rs | 125 +- crates/gaviero-core/src/swarm/calibration.rs | 1 + crates/gaviero-core/src/swarm/coordinator.rs | 41 +- crates/gaviero-core/src/swarm/loop_resume.rs | 84 +- crates/gaviero-core/src/swarm/mod.rs | 1 + crates/gaviero-core/src/swarm/models.rs | 62 + crates/gaviero-core/src/swarm/pipeline.rs | 1113 ++++++++++++++--- crates/gaviero-core/src/swarm/plan.rs | 56 +- .../gaviero-core/src/swarm/plan_document.rs | 1 + crates/gaviero-core/src/swarm/privacy.rs | 1 + crates/gaviero-core/src/swarm/router.rs | 1 + crates/gaviero-core/src/swarm/runtime_for.rs | 425 +++++++ crates/gaviero-core/src/swarm/spawn.rs | 167 ++- crates/gaviero-core/src/swarm/validation.rs | 1 + .../gaviero-core/src/swarm/verify/combined.rs | 1 + crates/gaviero-core/tests/swarm_budget.rs | 338 +++++ .../tests/swarm_parallel_dispatch.rs | 367 ++++++ 20 files changed, 2574 insertions(+), 285 deletions(-) create mode 100644 crates/gaviero-core/src/swarm/runtime_for.rs create mode 100644 crates/gaviero-core/tests/swarm_budget.rs create mode 100644 crates/gaviero-core/tests/swarm_parallel_dispatch.rs diff --git a/crates/gaviero-core/src/iteration/mod.rs b/crates/gaviero-core/src/iteration/mod.rs index efa757c9..a896cf74 100644 --- a/crates/gaviero-core/src/iteration/mod.rs +++ b/crates/gaviero-core/src/iteration/mod.rs @@ -179,6 +179,8 @@ impl IterationEngine { let mut best: Option<(AgentManifest, usize)> = None; let mut detector = ConvergenceDetector::new(); + // Every attempt is paid for; the returned manifest carries the sum. + let mut total_cost_usd = 0.0_f64; for attempt in 0..n_attempts { let unit = self.unit_for_attempt(&work_unit, attempt); @@ -216,6 +218,7 @@ impl IterationEngine { }, }; + total_cost_usd += manifest.cost_usd; let succeeded = manifest.status == AgentStatus::Completed; let file_count = manifest.modified_files.len(); @@ -225,6 +228,8 @@ impl IterationEngine { } if succeeded { + let mut manifest = manifest; + manifest.cost_usd = total_cost_usd; return IterationResult { manifest, attempts_run: attempt + 1, @@ -239,7 +244,7 @@ impl IterationEngine { } } - let (manifest, _) = best.unwrap_or_else(|| { + let (mut manifest, _) = best.unwrap_or_else(|| { ( AgentManifest { work_unit_id: work_unit.id.clone(), @@ -254,6 +259,7 @@ impl IterationEngine { ) }); + manifest.cost_usd = total_cost_usd; IterationResult { attempts_run: n_attempts, all_passed: false, @@ -330,6 +336,8 @@ impl IterationEngine { let mut best: Option<(AgentManifest, usize)> = None; let mut detector = ConvergenceDetector::new(); + // Every attempt is paid for; the returned manifest carries the sum. + let mut total_cost_usd = 0.0_f64; for attempt in 0..n_attempts { let unit = self.unit_for_attempt(&work_unit, attempt); @@ -378,6 +386,7 @@ impl IterationEngine { }, }; + total_cost_usd += manifest.cost_usd; let succeeded = manifest.status == AgentStatus::Completed; let file_count = manifest.modified_files.len(); @@ -386,6 +395,8 @@ impl IterationEngine { } if succeeded { + let mut manifest = manifest; + manifest.cost_usd = total_cost_usd; return IterationResult { manifest, attempts_run: attempt + 1, @@ -399,7 +410,7 @@ impl IterationEngine { } } - let (manifest, _) = best.unwrap_or_else(|| { + let (mut manifest, _) = best.unwrap_or_else(|| { ( AgentManifest { work_unit_id: work_unit.id.clone(), @@ -414,6 +425,7 @@ impl IterationEngine { ) }); + manifest.cost_usd = total_cost_usd; IterationResult { attempts_run: n_attempts, all_passed: false, @@ -477,6 +489,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], #[allow(deprecated)] @@ -598,6 +611,61 @@ mod tests { assert!(result.all_passed); } + /// `best_of_N` pays for every attempt it runs; the manifest it returns + /// must say so, not just the winning (or last) attempt's cost. + #[tokio::test] + async fn best_of_n_reports_total_cost() { + let engine = IterationEngine::new(IterationConfig { + strategy: Strategy::BestOfN { n: 2 }, + ..Default::default() + }); + let mut unit = make_unit("t"); + unit.max_retries = 0; + + let result = engine + .run_with_backend_factory( + unit, + make_gate(), + Path::new("/tmp"), + None, + &[], + &NoopObserver, + None, + None, + None, + None, + None, + &[], + None, + None, + false, + None, + |_unit| { + Ok(Box::new(MockBackend::new( + "failing", + vec![ + UnifiedStreamEvent::Usage(crate::swarm::backend::TokenUsage { + input_tokens: 1, + output_tokens: 1, + cost_usd: Some(0.25), + duration_ms: None, + }), + UnifiedStreamEvent::Error("attempt failed".into()), + UnifiedStreamEvent::Done(StopReason::Error), + ], + )) as Box) + }, + ) + .await; + + assert_eq!(result.attempts_run, 2); + assert!( + (result.manifest.cost_usd - 0.5).abs() < 1e-9, + "two attempts at $0.25 each, got {}", + result.manifest.cost_usd + ); + } + #[tokio::test] async fn backend_factory_re_resolves_between_attempts() { let engine = IterationEngine::new(IterationConfig { diff --git a/crates/gaviero-core/src/iteration/test_generator.rs b/crates/gaviero-core/src/iteration/test_generator.rs index 030535c9..2c0d8f9d 100644 --- a/crates/gaviero-core/src/iteration/test_generator.rs +++ b/crates/gaviero-core/src/iteration/test_generator.rs @@ -73,6 +73,7 @@ impl TestGenerator { id: "test-generator".into(), description: format!("Generate tests for: {}", &task[..task.len().min(80)]), scope: scope.clone(), + produces_json: vec![], produces: vec![], depends_on: vec![], #[allow(deprecated)] diff --git a/crates/gaviero-core/src/mcp/preflight.rs b/crates/gaviero-core/src/mcp/preflight.rs index 9e51e28d..0c4f667c 100644 --- a/crates/gaviero-core/src/mcp/preflight.rs +++ b/crates/gaviero-core/src/mcp/preflight.rs @@ -336,6 +336,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/backend/runner.rs b/crates/gaviero-core/src/swarm/backend/runner.rs index fc1850ad..029ded42 100644 --- a/crates/gaviero-core/src/swarm/backend/runner.rs +++ b/crates/gaviero-core/src/swarm/backend/runner.rs @@ -370,6 +370,9 @@ async fn run_backend_inner( let mut all_modified: std::collections::HashSet = Default::default(); // Corrective suffix appended to the base prompt on retries let mut corrective: Option = None; + // Spend across every attempt: a corrective retry is paid for too, so each + // manifest below reports the total, not just its last turn. + let mut turn_cost_usd = 0.0_f64; for attempt in 0..max_attempts { let prompt = match &corrective { @@ -431,7 +434,7 @@ async fn run_backend_inner( branch: None, summary: Some(format!("Backend error: {}", e)), output: None, - cost_usd: 0.0, + cost_usd: turn_cost_usd, }); } }; @@ -443,7 +446,6 @@ async fn run_backend_inner( let mut error_msg = String::new(); let mut in_thinking = false; let mut read_count: usize = 0; - let mut turn_cost_usd = 0.0_f64; while let Some(event_result) = stream.next().await { let event = match event_result { @@ -797,7 +799,7 @@ async fn run_backend_inner( branch: None, summary: Some("completed".into()), output: None, - cost_usd: 0.0, + cost_usd: turn_cost_usd, }) } @@ -1007,6 +1009,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), @@ -1401,6 +1404,122 @@ mod tests { } } + /// `produces json`: a declared file that exists but does not parse as + /// JSON gets the corrective retry, then fails the agent. + #[tokio::test] + async fn invalid_json_produces_fails_after_retry() { + let tmp = tempfile::tempdir().unwrap(); + let workspace = tmp.path(); + + let events = vec![ + UnifiedStreamEvent::TextDelta( + " +{not json + +".into(), + ), + UnifiedStreamEvent::Done(StopReason::EndTurn), + ]; + let backend = MockBackend::new("test", events); + let write_gate = Arc::new(Mutex::new(WriteGatePipeline::new( + WriteMode::AutoAccept, + Box::new(NoopWriteGateObserver), + ))); + let observer = TestObserver::new(); + let mut unit = test_work_unit(); + unit.max_retries = 1; + unit.produces = vec!["src/report.json".into()]; + unit.produces_json = vec!["src/report.json".into()]; + + let manifest = run_backend( + &backend, + &unit, + write_gate, + workspace, + None, + &["default".to_string()], + &observer, + None, + None, + None, + None, + None, + &[], + None, + None, + false, + None, + ) + .await + .unwrap(); + + assert!( + workspace.join("src/report.json").exists(), + "the in-band block is applied, so the failure is about JSON, not absence" + ); + match &manifest.status { + AgentStatus::Failed(msg) => assert!(msg.contains("invalid JSON"), "got: {msg}"), + other => panic!("expected Failed, got {other:?}"), + } + } + + /// A corrective retry is paid for too: the manifest reports the cost of + /// every attempt, not just the last turn. + #[tokio::test] + async fn cost_accumulates_across_retries() { + let tmp = tempfile::tempdir().unwrap(); + let workspace = tmp.path(); + + let events = vec![ + UnifiedStreamEvent::TextDelta("Both files written.".into()), + UnifiedStreamEvent::Usage(crate::swarm::backend::TokenUsage { + input_tokens: 10, + output_tokens: 5, + cost_usd: Some(0.5), + duration_ms: None, + }), + UnifiedStreamEvent::Done(StopReason::EndTurn), + ]; + let backend = MockBackend::new("test", events); + let write_gate = Arc::new(Mutex::new(WriteGatePipeline::new( + WriteMode::AutoAccept, + Box::new(NoopWriteGateObserver), + ))); + let observer = TestObserver::new(); + let mut unit = test_work_unit(); + unit.max_retries = 1; // two attempts: the first, then one corrective retry + unit.produces = vec!["src/report.md".into()]; + + let manifest = run_backend( + &backend, + &unit, + write_gate, + workspace, + None, + &["default".to_string()], + &observer, + None, + None, + None, + None, + None, + &[], + None, + None, + false, + None, + ) + .await + .unwrap(); + + assert!(matches!(manifest.status, AgentStatus::Failed(_))); + assert!( + (manifest.cost_usd - 1.0).abs() < 1e-9, + "two attempts at $0.50 each, got {}", + manifest.cost_usd + ); + } + #[tokio::test] async fn test_run_backend_salvages_in_band_file_block_for_declared_output() { let tmp = tempfile::tempdir().unwrap(); diff --git a/crates/gaviero-core/src/swarm/calibration.rs b/crates/gaviero-core/src/swarm/calibration.rs index 7fda57ea..49aa6f76 100644 --- a/crates/gaviero-core/src/swarm/calibration.rs +++ b/crates/gaviero-core/src/swarm/calibration.rs @@ -173,6 +173,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/coordinator.rs b/crates/gaviero-core/src/swarm/coordinator.rs index 51ae76fc..68db3c0b 100644 --- a/crates/gaviero-core/src/swarm/coordinator.rs +++ b/crates/gaviero-core/src/swarm/coordinator.rs @@ -649,6 +649,7 @@ fn parse_work_unit_lenient(v: &serde_json::Value) -> Result { scope, // Coordinator-planned units have no declared output contract; the DSL // `produces` clause is the only source for one. + produces_json: vec![], produces: Vec::new(), depends_on, backend: AgentBackend::default(), @@ -927,16 +928,16 @@ fn build_coordinator_dsl_prompt(file_list: &[String], memory_context: &str) -> S OUTPUT FORMAT — you MUST respond with ONLY a valid `.gaviero` file, no prose:\n\n\ ```\n\ // Optional comment\n\ - client { tier model \"\" }\n\ - // tier is one of: coordinator | reasoning | execution | mechanical\n\n\ agent {\n\ description \"\"\n\ - client \n\ + tier \n\ scope {\n\ owned [\"path/\" \"file.rs\"] // files this agent may write\n\ read_only [\"other/\"] // files this agent may only read\n\ }\n\ depends_on [ ...] // omit if no dependencies\n\ + produces [\"path/exact-file.md\"] // optional: exact files the agent must write\n\ + timeout // optional: per-dispatch seconds, default 3600\n\ prompt #\"\n\ \n\ \"#\n\ @@ -955,16 +956,16 @@ fn build_coordinator_dsl_prompt(file_list: &[String], memory_context: &str) -> S - Maximize agents that can run simultaneously (same tier with no depends_on)\n\ - Only add depends_on when an agent TRULY needs another's output\n\ - Prefer wide shallow DAGs (2-3 tiers) over deep linear chains\n\n\ - TIER ASSIGNMENT:\n\ - - reasoning: multi-file semantic changes, interface redesigns, complex logic\n\ - - execution: single-file focused changes, test writing, error handling\n\ - - mechanical: renames, import updates, call-site propagation, formatting\n\n\ - CLIENT NAMES to use:\n\ - - `reasoning` for reasoning-tier agents\n\ - - `execution` for execution-tier agents\n\ - - `mechanical` for mechanical-tier agents\n\ - - Prefer omitting explicit `model` fields so runtime routing can choose the active provider.\n\ - Only set a concrete model when the task truly requires a provider-specific override.\n\n\ + TIER ASSIGNMENT — every agent declares exactly one `tier`:\n\ + - high: multi-file semantic changes, interface redesigns, complex logic\n\ + - medium: single-file focused changes, test writing, error handling\n\ + - low: renames, import updates, call-site propagation, formatting\n\ + - Never declare `client` blocks, `tier ` lines or model names: the run's\n\ + model profile decides which model each tier uses.\n\n\ + OUTPUTS AND TIME:\n\ + - `produces` lists literal file paths (not globs) the agent must have written when it\n\ + finishes; the run fails the agent if one is missing. Use it for deliverables.\n\ + - `timeout` bounds one dispatch in seconds (default 3600); raise it for long tasks.\n\n\ PROMPT CONTENT:\n\ - Each agent's prompt must be SELF-CONTAINED — include all context needed\n\ - Agents run in isolated git worktrees; they cannot access tmp/ or gitignored files\n\ @@ -1089,6 +1090,19 @@ mod tests { use crate::types::{FileScope, PrivacyLevel}; use std::collections::HashMap; + /// Scripts choose models by tier only, so the template teaches `tier` + /// on every agent and no `client` blocks — a plan with clients fails to + /// compile. It also teaches the output contract and the dispatch timeout. + #[test] + fn coordinator_prompt_teaches_tiers_only() { + let prompt = build_coordinator_dsl_prompt(&[], ""); + assert!(!prompt.contains("client deep"), "prompt still declares clients"); + assert!(!prompt.contains("client <"), "prompt still binds agents to clients"); + for needed in ["tier ", "produces", "timeout"] { + assert!(prompt.contains(needed), "prompt lacks {needed}"); + } + } + fn make_unit(id: &str, deps: &[&str]) -> WorkUnit { WorkUnit { id: id.into(), @@ -1098,6 +1112,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: deps.iter().map(|s| s.to_string()).collect(), backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/loop_resume.rs b/crates/gaviero-core/src/swarm/loop_resume.rs index a096a695..838a244b 100644 --- a/crates/gaviero-core/src/swarm/loop_resume.rs +++ b/crates/gaviero-core/src/swarm/loop_resume.rs @@ -126,13 +126,26 @@ pub fn detect( // Owned globs per loop agent. An agent with no owned paths cannot be // validated, so the whole loop opts out rather than resuming blind. - let mut owned: BTreeMap<&str, &[String]> = BTreeMap::new(); + // + // A runtime `for` template (`for q in json …`) still carries its item + // placeholders (`out/{{q.id}}-v*.md`); each placeholder matches any + // segment. Such an agent writes as many files per pass as that pass had + // items, so it only has to show at least one artefact per version — it + // takes no part in the "every reviewer produced the same set" rule. + let mut owned: BTreeMap<&str, Vec> = BTreeMap::new(); + let mut dynamic: std::collections::HashSet<&str> = std::collections::HashSet::new(); for agent_id in &loop_config.agent_ids { let unit = unit_map.get(agent_id.as_str())?; if unit.scope.owned_paths.is_empty() { return None; } - owned.insert(agent_id.as_str(), unit.scope.owned_paths.as_slice()); + if unit.scope.owned_paths.iter().any(|g| g.contains("{{")) { + dynamic.insert(agent_id.as_str()); + } + owned.insert( + agent_id.as_str(), + unit.scope.owned_paths.iter().map(|g| wildcard_placeholders(g)).collect(), + ); } let mut notes: Vec = Vec::new(); @@ -194,8 +207,20 @@ pub fn detect( )); continue; } - let mut vectors = per_agent.values().map(|c| &c.counts); + if per_agent + .iter() + .any(|(id, c)| dynamic.contains(id) && c.total() == 0) + { + notes.push(format!("v{version} incomplete — a runtime `for` wrote nothing")); + continue; + } + let mut vectors = per_agent + .iter() + .filter(|(id, _)| !dynamic.contains(*id)) + .map(|(_, c)| &c.counts); let Some(first) = vectors.next() else { + // Only runtime `for` members, each with at least one artefact. + last_complete = Some(*version); continue; }; if first.iter().sum::() == 0 { @@ -282,6 +307,27 @@ pub fn detect( }) } +/// Replace every `{{…}}` placeholder in a glob with `*`. +fn wildcard_placeholders(glob: &str) -> String { + let mut out = String::with_capacity(glob.len()); + let mut rest = glob; + while let Some(start) = rest.find("{{") { + out.push_str(&rest[..start]); + match rest[start..].find("}}") { + Some(end) => { + out.push('*'); + rest = &rest[start + end + 2..]; + } + None => { + out.push_str(&rest[start..]); + rest = ""; + } + } + } + out.push_str(rest); + out +} + /// Parse the trailing `-v` marker from a path's file name. fn parse_version(rel_path: &str) -> Option { let name = rel_path.rsplit('/').next()?; @@ -632,4 +678,36 @@ mod tests { assert_eq!(parse_version("plans/x/plan_log.md"), None); assert_eq!(parse_version("plans/x/claude-v2-notes.md"), None); } + + /// A runtime `for` member (`out/{{q.id}}-finding-v*.md`) writes a + /// different number of files each pass; a pass counts once it wrote any + /// and every other loop agent completed it. + #[test] + fn detect_handles_runtime_for_owned_globs() { + let tmp = tempfile::tempdir().unwrap(); + let root = tmp.path(); + write(root, "out/a-finding-v1.md", "x"); + write(root, "out/b-finding-v1.md", "x"); + write(root, "out/frontier-v1.json", "{}"); + write(root, "out/c-finding-v2.md", "x"); + write(root, "out/frontier-v2.json", "{}"); + // Pass 3 crashed: an investigator wrote, the curator never ran. + write(root, "out/a-finding-v3.md", "x"); + + let worker = unit("worker", &["out/{{q.id}}-finding-v*.md"]); + let curator = unit("curator", &["out/frontier-v*.json"]); + let map: HashMap<&str, &WorkUnit> = + [("worker", &worker), ("curator", &curator)].into_iter().collect(); + let resume = detect(root, &loop_config(&["worker", "curator"], "out", 1), &map) + .expect("passes 1 and 2 are complete"); + assert_eq!(resume.last_complete_iter, 2); + assert_eq!(resume.resume_iter_start, 3); + } + + #[test] + fn placeholders_become_wildcards() { + assert_eq!(wildcard_placeholders("out/{{q.id}}-v*.md"), "out/*-v*.md"); + assert_eq!(wildcard_placeholders("a/{{x}}/{{y}}.md"), "a/*/*.md"); + assert_eq!(wildcard_placeholders("plain/v*.md"), "plain/v*.md"); + } } diff --git a/crates/gaviero-core/src/swarm/mod.rs b/crates/gaviero-core/src/swarm/mod.rs index a0aa2bb4..7073333c 100644 --- a/crates/gaviero-core/src/swarm/mod.rs +++ b/crates/gaviero-core/src/swarm/mod.rs @@ -18,6 +18,7 @@ pub mod planner; pub mod privacy; pub mod replanner; pub mod router; +pub mod runtime_for; pub mod script_run; pub mod spawn; pub mod validation; diff --git a/crates/gaviero-core/src/swarm/models.rs b/crates/gaviero-core/src/swarm/models.rs index 0bb11e28..46d5d323 100644 --- a/crates/gaviero-core/src/swarm/models.rs +++ b/crates/gaviero-core/src/swarm/models.rs @@ -32,6 +32,11 @@ pub struct WorkUnit { /// gate then falls back to detecting whether its owned files changed at all. #[serde(default)] pub produces: Vec, + /// The subset of `produces` declared with `produces json [...]`: each must + /// also parse as JSON, or it counts as missing (same corrective retry and + /// loop delivery gate). + #[serde(default)] + pub produces_json: Vec, /// IDs of work units that must complete before this one starts. #[serde(default)] pub depends_on: Vec, @@ -187,6 +192,27 @@ impl WorkUnit { } }) .cloned() + .chain(self.invalid_json_artifacts(root)) + .collect() + } + + /// `produces json` paths that exist and are non-empty but do not parse + /// as JSON, each as `" (invalid JSON: )"`. Absent or empty + /// files are already reported by [`Self::missing_declared_artifacts`]. + fn invalid_json_artifacts(&self, root: &std::path::Path) -> Vec { + self.produces_json + .iter() + .filter(|rel| !rel.contains("{{")) + .filter_map(|rel| { + let text = std::fs::read_to_string(root.join(rel)).ok()?; + if text.is_empty() { + return None; + } + match serde_json::from_str::(&text) { + Ok(_) => None, + Err(e) => Some(format!("{rel} (invalid JSON: {e})")), + } + }) .collect() } } @@ -293,3 +319,39 @@ pub struct MergeConflict { pub resolved: bool, pub resolution_method: Option, } + +#[cfg(test)] +mod tests { + use super::*; + + /// Every `WorkUnit` field but `id` has a serde default. + fn json_unit(path: &str) -> WorkUnit { + serde_json::from_value(serde_json::json!({ + "id": "u", + "produces": [path], + "produces_json": [path], + })) + .expect("work unit fixture") + } + + #[test] + fn invalid_json_output_counts_as_missing() { + let tmp = tempfile::tempdir().unwrap(); + std::fs::write(tmp.path().join("out.json"), "{not json").unwrap(); + let missing = json_unit("out.json").missing_declared_artifacts(tmp.path()); + assert_eq!(missing.len(), 1, "{missing:?}"); + assert!(missing[0].starts_with("out.json (invalid JSON:"), "{missing:?}"); + } + + #[test] + fn valid_json_output_passes() { + let tmp = tempfile::tempdir().unwrap(); + std::fs::write(tmp.path().join("out.json"), r#"{"claims":[]}"#).unwrap(); + assert!(json_unit("out.json") + .missing_declared_artifacts(tmp.path()) + .is_empty()); + // Absent is reported once, as plain missing. + let absent = json_unit("nope.json").missing_declared_artifacts(tmp.path()); + assert_eq!(absent, vec!["nope.json".to_string()]); + } +} diff --git a/crates/gaviero-core/src/swarm/pipeline.rs b/crates/gaviero-core/src/swarm/pipeline.rs index ffb19552..27441e80 100644 --- a/crates/gaviero-core/src/swarm/pipeline.rs +++ b/crates/gaviero-core/src/swarm/pipeline.rs @@ -108,34 +108,73 @@ pub fn preflight_plan_models( Ok(()) } -/// Wall-clock budget for a whole swarm run. +/// Run limits: the wall clock (`--run-timeout` and the workflow's +/// `budget { wall }`, the smaller non-zero one) and the workflow's +/// `budget { usd }`. /// -/// Checked cooperatively rather than by wrapping `execute` in a timeout: a -/// hard cancel would throw away every manifest collected so far, and the -/// artefacts on disk are the point of a document workflow. Because every -/// dispatch is bounded by `WorkUnit::timeout_secs`, the gap between two checks -/// is bounded too, so cooperative checking cannot be starved. -struct RunDeadline { +/// Checked cooperatively before every dispatch rather than by wrapping +/// `execute` in a timeout: a hard cancel would throw away every manifest +/// collected so far, and the artefacts on disk are the point of a document +/// workflow. Because every dispatch is bounded by `WorkUnit::timeout_secs`, +/// the gap between two checks is bounded too. Spend is only known once a +/// dispatch returns, so agents already running in a parallel tier can carry +/// the total past `usd`. +struct RunLimits { start: std::time::Instant, - budget: Option, + wall: Option, + usd: Option, } -impl RunDeadline { - fn new(secs: u64) -> Self { +impl RunLimits { + fn new(run_timeout_secs: u64, budget: Option<&crate::swarm::plan::RunBudget>) -> Self { + let plan_wall = budget.and_then(|b| b.wall_secs).filter(|s| *s > 0); + let cli_wall = (run_timeout_secs > 0).then_some(run_timeout_secs); + let wall_secs = match (plan_wall, cli_wall) { + (Some(a), Some(b)) => Some(a.min(b)), + (a, b) => a.or(b), + }; Self { start: std::time::Instant::now(), - budget: (secs > 0).then_some(std::time::Duration::from_secs(secs)), + wall: wall_secs.map(std::time::Duration::from_secs), + usd: budget.and_then(|b| b.usd), } } - /// `Some(elapsed_secs)` once the budget is spent. - fn expired(&self) -> Option { - let budget = self.budget?; - let elapsed = self.start.elapsed(); - (elapsed >= budget).then_some(elapsed.as_secs()) + /// Why no further agent may start, if a limit is spent. + fn exhausted(&self, spent_usd: f64) -> Option { + if let Some(wall) = self.wall + && self.start.elapsed() >= wall + { + return Some(format!("wall budget of {}s spent", wall.as_secs())); + } + if let Some(usd) = self.usd + && spent_usd >= usd + { + return Some(format!("usd budget of ${usd:.2} spent (${spent_usd:.2})")); + } + None } } +/// Reported spend so far: every manifest's `cost_usd` (agents, clones, +/// workers and judges). Providers that report no cost contribute nothing. +fn spent_usd(all_manifests: &[AgentManifest]) -> f64 { + all_manifests.iter().map(|m| m.cost_usd).sum() +} + +/// Record a manifest and tell the observer the run's spend so far. +fn push_manifest( + all_manifests: &mut Vec, + manifest: AgentManifest, + observer: &dyn SwarmObserver, +) { + all_manifests.push(manifest); + observer.on_cost_update(&crate::swarm::verify::CostEstimate { + estimated_usd: spent_usd(all_manifests), + ..Default::default() + }); +} + /// A spawned agent task that dies with the run awaiting it. /// /// `tokio::spawn` detaches: without this, abandoning [`execute`] (a front end @@ -305,14 +344,74 @@ fn workspace_bash_inherited( /// Pending/Blocked/HardFailure all count as unmet. Tiers are supposed to /// have already run those deps; if they have not, dispatching the child is /// the bug that let `review_module` start after `inventory` Failed. +/// +/// A dependency on a `pattern map_reduce` discover agent also covers every +/// worker its wave recorded (`::` in `spawned_ids`): a +/// failed worker leaves the reduce agent unmet. fn unmet_dependency_ids(unit: &WorkUnit, exec_state: &ExecutionState) -> Vec { - unit.depends_on + let mut unmet: Vec = unit + .depends_on .iter() .filter(|d| !exec_state.status(d).is_success()) .cloned() + .collect(); + for dep in &unit.depends_on { + let prefix = format!("{dep}::"); + for key in &exec_state.spawned_ids { + if let Some(worker) = key.strip_prefix(&prefix) + && !exec_state.status(worker).is_success() + && !unmet.iter().any(|u| u == worker) + { + unmet.push(worker.to_string()); + } + } + } + unmet +} + +/// The loop agents `unit` depends on that have not completed this pass. +fn intra_loop_unmet( + unit: &WorkUnit, + loop_agent_ids: &[String], + pass_completed: &std::collections::HashSet, +) -> Vec { + unit.depends_on + .iter() + .filter(|d| loop_agent_ids.contains(d) && **d != unit.id) + .filter(|d| !pass_completed.contains(*d)) + .cloned() .collect() } +/// Dispatch tiers for one loop pass: `depends_on` between the loop's own +/// agents, in Kahn order, each tier listed in the loop's written order. +/// Dependencies outside the loop are already satisfied before the loop runs. +fn loop_pass_tiers( + loop_agent_ids: &[String], + unit_map: &std::collections::HashMap<&str, &WorkUnit>, +) -> Vec> { + let members: Vec = loop_agent_ids + .iter() + .filter_map(|id| unit_map.get(id.as_str())) + .map(|u| { + let mut u = (*u).clone(); + u.depends_on.retain(|d| loop_agent_ids.contains(d) && *d != u.id); + u + }) + .collect(); + let position = |id: &str| loop_agent_ids.iter().position(|a| a == id).unwrap_or(usize::MAX); + match validation::dependency_tiers(&members) { + Ok(mut tiers) => { + for tier in &mut tiers { + tier.sort_by_key(|id| position(id)); + } + tiers + } + // Cycles are rejected at compile time; fall back to one tier. + Err(_) => vec![loop_agent_ids.to_vec()], + } +} + fn skipped_for_unmet_deps(unit_id: &str, deps: &[String]) -> AgentManifest { let listed = deps .iter() @@ -351,7 +450,7 @@ fn record_unmet_dependency_skip( manifest.summary.as_deref().unwrap_or(""), ); exec_state.record_result(unit_id, manifest.clone()); - all_manifests.push(manifest); + push_manifest(all_manifests, manifest, observer); } /// Execute a swarm of work units from a compiled plan. @@ -523,7 +622,11 @@ pub async fn execute( // ── Single-agent fast path ──────────────────────────────────────────────── // One work unit → bypass worktrees, bus, and merge; run directly through // the IterationEngine so strategy / retry / model-escalation all apply. - if work_units.len() == 1 && plan.loop_configs.is_empty() { + if work_units.len() == 1 + && plan.loop_configs.is_empty() + && plan.runtime_fors.is_empty() + && plan.fanout_ops.is_empty() + { let unit = work_units.into_iter().next().unwrap(); // Resume support: skip if already completed. @@ -764,6 +867,37 @@ pub async fn execute( } } + // `for … in json` templates, and the clones each one ran most recently + // inside a loop (the delivery checks judge those, not the template). + let runtime_for_map: std::collections::HashMap<&str, &crate::swarm::plan::RuntimeForOp> = plan + .runtime_fors + .iter() + .map(|op| (op.unit_id.as_str(), op)) + .collect(); + let mut dynamic_clones: std::collections::HashMap> = + std::collections::HashMap::new(); + let limits = RunLimits::new(config.run_timeout_secs, plan.budget.as_ref()); + warn_unreported_budget_costs(plan, observer); + let dyn_ctx = DynamicCtx { + config, + limits: &limits, + semaphore: semaphore.clone(), + memory: memory.clone(), + memory_writer: &memory_writer, + observer, + validation: validation_pipeline.clone(), + board: shared_board.clone(), + analysis: &analysis, + pre_fetched_memory: pre_fetched_memory.clone(), + tier_router: &tier_router, + iteration_config: &plan.iteration_config, + bus: &bus, + run_id: &run_id, + plan_hash: &plan_hash, + static_units: &work_units, + loop_groups: &loop_groups, + }; + observer.on_phase_changed("running"); // Build a map from loop-agent id → iter_start for first-pass {{ITER}} substitution. @@ -802,6 +936,10 @@ pub async fn execute( // execute_module's loop iterations 2..N actually run, so test_audit sees // an empty workspace state. The deferral makes "depends on a loop body // agent" mean "depends on the loop body having fully iterated". + // + // A loop body agent is never a post-loop unit, even when it depends on + // another agent of its loop (`curator depends_on [investigator]`): the + // loop itself orders those agents inside every pass. let loop_body_agents: std::collections::HashSet = effective_loop_configs .iter() .flat_map(|lc| lc.agent_ids.iter().cloned()) @@ -825,6 +963,7 @@ pub async fn execute( } } } + out.retain(|id| !loop_body_agents.contains(id)); out }; @@ -848,19 +987,16 @@ pub async fn execute( )); } - let deadline = RunDeadline::new(config.run_timeout_secs); // 3. Execute tiers for (tier_idx, tier) in tiers.iter().enumerate() { - if let Some(elapsed) = deadline.expired() { + if let Some(reason) = limits.exhausted(spent_usd(&all_manifests)) { tracing::error!( - "Run budget of {}s exhausted after {}s — stopping before tier {}/{}", - config.run_timeout_secs, - elapsed, + "Run budget exhausted ({reason}) — stopping before tier {}/{}", tier_idx + 1, tiers.len() ); - observer.on_phase_changed("run budget exhausted"); + observer.on_phase_changed(&format!("run budget exhausted: {reason}")); break; } observer.on_tier_started(tier_idx + 1, tiers.len()); @@ -868,9 +1004,26 @@ pub async fn execute( if effective_max_parallel <= 1 || tier.len() <= 1 { // Sequential execution for unit_id in tier { - // Skip if already completed (resume support) + if let Some(reason) = limits.exhausted(spent_usd(&all_manifests)) { + tracing::error!("Run budget exhausted ({reason}) — not starting '{unit_id}'"); + observer.on_phase_changed(&format!("run budget exhausted: {reason}")); + break; + } + // Skip if already completed (resume support) — but finish a + // fan-out wave the checkpoint shows as incomplete. if exec_state.status(unit_id) == NodeStatus::Completed { tracing::info!("Skipping completed node '{}' (resume)", unit_id); + if fanout_wave_pending(plan, unit_id, &exec_state) { + run_fanout_wave_if_needed( + unit_id, + plan, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; + } continue; } // Stacked-mode loop body agents: tier dispatch hands them @@ -899,6 +1052,44 @@ pub async fn execute( continue; } + // A `for … in json` template: clone it per item and run the + // clones; the template's own record is the barrier. + if let Some(op) = runtime_for_map.get(unit_id.as_str()) { + let pass = loop_agent_first_iter + .get(unit_id.as_str()) + .map(|&is| (is, None)); + exec_state.set_status(unit_id, NodeStatus::Running); + let (manifest, clones) = run_runtime_for_step( + unit, + op, + pass, + &plan.tier_bindings, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; + if pass.is_some() { + dynamic_clones.insert(unit_id.clone(), clones); + } + let failed = !matches!(manifest.status, AgentStatus::Completed); + observer.on_agent_state_changed( + unit_id, + &manifest.status, + manifest.summary.as_deref().unwrap_or(""), + ); + exec_state.record_result(unit_id, manifest.clone()); + if let Err(e) = exec_state.save(&config.workspace_root, &plan_hash) { + tracing::warn!("Failed to save execution state checkpoint: {}", e); + } + push_manifest(&mut all_manifests, manifest, observer); + if failed { + break; + } + continue; + } + // Apply {{ITER}}/{{PREV_ITER}} for first pass of loop agents let _iter_unit_seq: Option; let unit: &WorkUnit = if let Some(&is) = loop_agent_first_iter.get(unit_id.as_str()) @@ -965,44 +1156,36 @@ pub async fn execute( if let Err(e) = exec_state.save(&config.workspace_root, &plan_hash) { tracing::warn!("Failed to save execution state checkpoint: {}", e); } - all_manifests.push(manifest); + push_manifest(&mut all_manifests, manifest, observer); if failed { break; } // Runtime fan-out: materialize + run SpawnManifest workers - if !failed - && let Err(e) = run_fanout_wave_if_needed( - unit_id, - plan, - config, - &context_files, - &memory, - &memory_writer, - observer, - git_coordinator.clone(), - validation_pipeline.clone(), - shared_board.clone(), - &analysis, - pre_fetched_memory.clone(), - &tier_router, - &plan.iteration_config, - &bus, - &mut all_manifests, - &mut exec_state, - &run_id, - &plan_hash, - worktree_mgr.as_mut(), - &make_observer, - ) - .await - { - tracing::warn!("fan-out after '{unit_id}' failed: {e:#}"); - } + run_fanout_wave_if_needed( + unit_id, + plan, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; } } else { // Parallel execution within tier let mut handles = Vec::new(); + // Ids in the same order as `handles`: skipped and deferred units + // are never spawned, so `tier[handle_idx]` would name the wrong + // unit when reporting a task error. + let mut spawned_ids: Vec = Vec::new(); + // `for … in json` templates of this tier. They fan out under the + // same semaphore, so they run after the tier's other agents are + // collected — never while a permit-holding task waits on them. + let mut deferred_runtime_fors: Vec = Vec::new(); + // Discover agents of this tier whose `pattern map_reduce` wave + // runs once the tier is collected (same reason as above). + let mut deferred_fanouts: Vec = Vec::new(); // Register all agents as Pending before spawning. Skip stacked // loop body agents (handled by the loop block) and post-loop @@ -1018,6 +1201,14 @@ pub async fn execute( if stacked_loop_agents.contains(unit_id) || post_loop_units.contains(unit_id) { continue; } + // Skip if already completed (resume support) + if exec_state.status(unit_id) == NodeStatus::Completed { + tracing::info!("Skipping completed node '{}' (resume)", unit_id); + if fanout_wave_pending(plan, unit_id, &exec_state) { + deferred_fanouts.push(unit_id.clone()); + } + continue; + } let unit = (*unit_map .get(unit_id.as_str()) .with_context(|| format!("work unit '{}' not found", unit_id))?) @@ -1034,6 +1225,15 @@ pub async fn execute( ); continue; } + if runtime_for_map.contains_key(unit_id.as_str()) { + deferred_runtime_fors.push(unit_id.clone()); + continue; + } + if let Some(reason) = limits.exhausted(spent_usd(&all_manifests)) { + tracing::error!("Run budget exhausted ({reason}) — not starting '{unit_id}'"); + observer.on_phase_changed(&format!("run budget exhausted: {reason}")); + break; + } // Apply {{ITER}}/{{PREV_ITER}} for first pass of loop agents let unit = if let Some(&is) = loop_agent_first_iter.get(unit_id.as_str()) { @@ -1138,9 +1338,13 @@ pub async fn execute( Ok::<_, anyhow::Error>(manifest) }))); + spawned_ids.push(unit_id.clone()); } - // Collect results + // Collect results. Every manifest is recorded in the execution + // state, exactly like the sequential branch: later tiers check + // their `depends_on` against it, loops check their first pass + // against it, and `--resume` reads it back from the checkpoint. for (handle_idx, handle) in handles.into_iter().enumerate() { match handle.await { Ok(Ok(manifest)) => { @@ -1173,18 +1377,27 @@ pub async fn execute( .await; } } - all_manifests.push(manifest); + if matches!(manifest.status, AgentStatus::Completed) + && plan + .fanout_ops + .iter() + .any(|op| op.after_unit == manifest.work_unit_id) + { + deferred_fanouts.push(manifest.work_unit_id.clone()); + } + exec_state.record_result(&manifest.work_unit_id, manifest.clone()); + push_manifest(&mut all_manifests, manifest, observer); } Ok(Err(e)) => { let err_msg = format!("{:#}", e); tracing::error!("Agent task error: {}", err_msg); - if let Some(unit_id) = tier.get(handle_idx) { + if let Some(unit_id) = spawned_ids.get(handle_idx) { observer.on_agent_state_changed( unit_id, &AgentStatus::Failed(err_msg.clone()), &err_msg, ); - all_manifests.push(AgentManifest { + let manifest = AgentManifest { work_unit_id: unit_id.clone(), status: AgentStatus::Failed(err_msg), modified_files: vec![], @@ -1192,19 +1405,21 @@ pub async fn execute( summary: Some("Agent task error".into()), output: None, cost_usd: 0.0, - }); + }; + exec_state.record_result(unit_id, manifest.clone()); + push_manifest(&mut all_manifests, manifest, observer); } } Err(e) => { let err_msg = format!("task panicked: {}", e); tracing::error!("{}", err_msg); - if let Some(unit_id) = tier.get(handle_idx) { + if let Some(unit_id) = spawned_ids.get(handle_idx) { observer.on_agent_state_changed( unit_id, &AgentStatus::Failed(err_msg.clone()), &err_msg, ); - all_manifests.push(AgentManifest { + let manifest = AgentManifest { work_unit_id: unit_id.clone(), status: AgentStatus::Failed(err_msg), modified_files: vec![], @@ -1212,11 +1427,65 @@ pub async fn execute( summary: Some("Agent task panicked".into()), output: None, cost_usd: 0.0, - }); + }; + exec_state.record_result(unit_id, manifest.clone()); + push_manifest(&mut all_manifests, manifest, observer); } } } } + if let Err(e) = exec_state.save(&config.workspace_root, &plan_hash) { + tracing::warn!("Failed to save execution state checkpoint: {}", e); + } + + for unit_id in &deferred_fanouts { + run_fanout_wave_if_needed( + unit_id, + plan, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; + } + + for unit_id in &deferred_runtime_fors { + let (Some(op), Some(template)) = ( + runtime_for_map.get(unit_id.as_str()), + unit_map.get(unit_id.as_str()), + ) else { + continue; + }; + let pass = loop_agent_first_iter + .get(unit_id.as_str()) + .map(|&is| (is, None)); + exec_state.set_status(unit_id, NodeStatus::Running); + let (manifest, clones) = run_runtime_for_step( + template, + op, + pass, + &plan.tier_bindings, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; + if pass.is_some() { + dynamic_clones.insert(unit_id.clone(), clones); + } + observer.on_agent_state_changed( + unit_id, + &manifest.status, + manifest.summary.as_deref().unwrap_or(""), + ); + exec_state.record_result(unit_id, manifest.clone()); + if let Err(e) = exec_state.save(&config.workspace_root, &plan_hash) { + tracing::warn!("Failed to save execution state checkpoint: {}", e); + } + push_manifest(&mut all_manifests, manifest, observer); + } } } @@ -1483,21 +1752,19 @@ pub async fn execute( } } exec_state.record_result(agent_id, manifest.clone()); - all_manifests.push(manifest); + push_manifest(&mut all_manifests, manifest, observer); } } for iteration in 1..loop_config.max_iterations { let current_iter_abs = loop_config.iter_start + iteration - 1; - if let Some(elapsed) = deadline.expired() { + if let Some(reason) = limits.exhausted(spent_usd(&all_manifests)) { tracing::error!( - "Run budget of {}s exhausted after {}s — stopping the loop at iteration {}", - config.run_timeout_secs, - elapsed, + "Run budget exhausted ({reason}) — stopping the loop at iteration {}", current_iter_abs ); - observer.on_phase_changed("run budget exhausted"); + observer.on_phase_changed(&format!("run budget exhausted: {reason}")); loop_terminated = true; break; } @@ -1516,24 +1783,27 @@ pub async fn execute( // judge turn. // Snapshot the pass now; the delivery gate itself runs only // if a judge is about to be dispatched (D-7). + // A runtime `for` member is judged through the clones it ran. + let (member_ids, member_map) = + expand_loop_members(&loop_config.agent_ids, &unit_map, &dynamic_clones); let delivery_after = - snapshot_loop_agents(&loop_config.agent_ids, &unit_map, &config.workspace_root); + snapshot_loop_agents(&member_ids, &member_map, &config.workspace_root); // A panel that delivers nothing at all, pass after pass, is // stuck. Deterministic conditions never reach the delivery // gate, so without this they would iterate to the budget. { let silent = loop_agents_without_delivery(DeliveryCheck { - agent_ids: &loop_config.agent_ids, - unit_map: &unit_map, + agent_ids: &member_ids, + unit_map: &member_map, all_manifests: &all_manifests, before: &loop_output_baseline, after: &delivery_after, workspace_root: &config.workspace_root, iter_abs: current_iter_abs, }); - let whole_panel_silent = !loop_config.agent_ids.is_empty() - && silent.len() == loop_config.agent_ids.len(); + let whole_panel_silent = + !member_ids.is_empty() && silent.len() == member_ids.len(); silent_streak = if whole_panel_silent { silent_streak.saturating_add(1) } else { @@ -1574,15 +1844,16 @@ pub async fn execute( make_observer: &make_observer, strict_judge: loop_config.strict_judge, judge_timeout_secs: loop_config.judge_timeout_secs, - loop_agent_ids: &loop_config.agent_ids, + loop_agent_ids: &member_ids, consensus_mode: loop_config.consensus_mode, verdict_output_dir: loop_config.verdict_output_dir.as_deref(), probe_dedup: &mut probe_dedup, delivery: DeliveryInputs { - unit_map: &unit_map, + unit_map: &member_map, before: &loop_output_baseline, after: &delivery_after, }, + limits: &limits, }; evaluate_loop_condition(&loop_config.until, current_iter_abs, &mut loop_ctx).await? }; @@ -1724,13 +1995,38 @@ pub async fn execute( observer.on_agent_state_changed(agent_id, &AgentStatus::Pending, "queued"); } + // `depends_on` between agents of this loop orders them inside + // the pass: each tier starts once the previous one finished. + let pass_tiers = loop_pass_tiers(&loop_config.agent_ids, &unit_map); + let mut pass_completed: std::collections::HashSet = + std::collections::HashSet::new(); + for pass_tier in &pass_tiers { let mut prepared: Vec<(String, WorkUnit, PathBuf, Option)> = Vec::new(); - for agent_id in &loop_config.agent_ids { + // Runtime `for` members of this tier fan out after the tier's + // other agents are collected (they share the semaphore). + let mut tier_runtime_fors: Vec = Vec::new(); + for agent_id in pass_tier { let unit_template = match unit_map.get(agent_id.as_str()) { Some(u) => u, None => continue, }; + let unmet = + intra_loop_unmet(unit_template, &loop_config.agent_ids, &pass_completed); + if !unmet.is_empty() { + record_unmet_dependency_skip( + agent_id, + &unmet, + observer, + &mut exec_state, + &mut all_manifests, + ); + continue; + } + if runtime_for_map.contains_key(agent_id.as_str()) { + tier_runtime_fors.push(agent_id.clone()); + continue; + } let unit = apply_iter_vars_with_gate_feedback( unit_template, iter_abs, @@ -1902,6 +2198,7 @@ pub async fn execute( manifest.summary.as_deref().unwrap_or(""), ); if matches!(manifest.status, AgentStatus::Completed) { + pass_completed.insert(agent_id.clone()); let b = bus.lock().await; b.broadcast( &manifest.work_unit_id, @@ -1921,15 +2218,87 @@ pub async fn execute( .await; } exec_state.record_result(&agent_id, manifest.clone()); - all_manifests.push(manifest); + push_manifest(&mut all_manifests, manifest, observer); + } + for agent_id in &tier_runtime_fors { + let (Some(op), Some(template)) = ( + runtime_for_map.get(agent_id.as_str()), + unit_map.get(agent_id.as_str()), + ) else { + continue; + }; + let (manifest, clones) = run_runtime_for_step( + template, + op, + Some((iter_abs, last_gate_failure.as_ref())), + &plan.tier_bindings, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; + dynamic_clones.insert(agent_id.clone(), clones); + observer.on_agent_state_changed( + agent_id, + &manifest.status, + manifest.summary.as_deref().unwrap_or(""), + ); + if matches!(manifest.status, AgentStatus::Completed) { + pass_completed.insert(agent_id.clone()); + } + exec_state.record_result(agent_id, manifest.clone()); + push_manifest(&mut all_manifests, manifest, observer); + } } } else { // Sequential fallback (max_parallel == 1 or a single loop agent). + // `agent_ids` is in dependency order (the compiler sorts it), + // so an agent runs only after the loop agents it depends on. + let mut pass_completed: std::collections::HashSet = + std::collections::HashSet::new(); for agent_id in &loop_config.agent_ids { let unit_template = match unit_map.get(agent_id.as_str()) { Some(u) => u, None => continue, }; + let unmet = + intra_loop_unmet(unit_template, &loop_config.agent_ids, &pass_completed); + if !unmet.is_empty() { + record_unmet_dependency_skip( + agent_id, + &unmet, + observer, + &mut exec_state, + &mut all_manifests, + ); + continue; + } + if let Some(op) = runtime_for_map.get(agent_id.as_str()) { + let (manifest, clones) = run_runtime_for_step( + unit_template, + op, + Some((iter_abs, last_gate_failure.as_ref())), + &plan.tier_bindings, + &dyn_ctx, + &mut exec_state, + &mut all_manifests, + &make_observer, + ) + .await?; + dynamic_clones.insert(agent_id.clone(), clones); + observer.on_agent_state_changed( + agent_id, + &manifest.status, + manifest.summary.as_deref().unwrap_or(""), + ); + if matches!(manifest.status, AgentStatus::Completed) { + pass_completed.insert(agent_id.clone()); + } + exec_state.record_result(agent_id, manifest.clone()); + push_manifest(&mut all_manifests, manifest, observer); + continue; + } let iter_unit = apply_iter_vars_with_gate_feedback( unit_template, @@ -1986,6 +2355,7 @@ pub async fn execute( }; if matches!(manifest.status, AgentStatus::Completed) { + pass_completed.insert(agent_id.clone()); let b = bus.lock().await; b.broadcast( &manifest.work_unit_id, @@ -2012,7 +2382,7 @@ pub async fn execute( } } exec_state.record_result(agent_id, manifest.clone()); - all_manifests.push(manifest); + push_manifest(&mut all_manifests, manifest, observer); } } } @@ -2024,8 +2394,11 @@ pub async fn execute( loop_config.iter_start + loop_config.max_iterations.saturating_sub(1); // Snapshot the pass now; the delivery gate itself runs only // if a judge is about to be dispatched (D-7). + // A runtime `for` member is judged through the clones it ran. + let (member_ids, member_map) = + expand_loop_members(&loop_config.agent_ids, &unit_map, &dynamic_clones); let delivery_after = - snapshot_loop_agents(&loop_config.agent_ids, &unit_map, &config.workspace_root); + snapshot_loop_agents(&member_ids, &member_map, &config.workspace_root); let final_outcome = { let mut loop_ctx = LoopConditionContext { config, @@ -2048,15 +2421,16 @@ pub async fn execute( make_observer: &make_observer, strict_judge: loop_config.strict_judge, judge_timeout_secs: loop_config.judge_timeout_secs, - loop_agent_ids: &loop_config.agent_ids, + loop_agent_ids: &member_ids, consensus_mode: loop_config.consensus_mode, verdict_output_dir: loop_config.verdict_output_dir.as_deref(), probe_dedup: &mut probe_dedup, delivery: DeliveryInputs { - unit_map: &unit_map, + unit_map: &member_map, before: &loop_output_baseline, after: &delivery_after, }, + limits: &limits, }; evaluate_loop_condition(&loop_config.until, final_iter_abs, &mut loop_ctx).await? }; @@ -2193,7 +2567,7 @@ pub async fn execute( if let Err(e) = exec_state.save(&config.workspace_root, &plan_hash) { tracing::warn!("Failed to save execution state checkpoint: {}", e); } - all_manifests.push(manifest); + push_manifest(&mut all_manifests, manifest, observer); if failed { // A post-loop failure aborts further post-loop dispatch // (e.g. final_verify shouldn't run if test_audit failed) @@ -2640,6 +3014,8 @@ struct LoopConditionContext<'a> { /// Inputs for the delivery gate, consulted only if a judge is about /// to be dispatched. delivery: DeliveryInputs<'a>, + /// Run limits: a spent budget dispatches no judge. + limits: &'a RunLimits, } /// What the delivery gate needs to decide whether the panel is intact. @@ -2860,6 +3236,14 @@ fn apply_iter_vars_full( .replace("{{PREV_ITER}}", &prev_str) }) .collect(), + produces_json: unit + .produces_json + .iter() + .map(|p| { + p.replace("{{ITER}}", &iter_str) + .replace("{{PREV_ITER}}", &prev_str) + }) + .collect(), coordinator_instructions, ..unit.clone() } @@ -3915,35 +4299,378 @@ fn force_stage_owned_ignored( Ok(()) } -/// Store an agent's execution result to memory (best-effort, never fails the pipeline). +/// With a `budget { usd }`, name the units whose provider reports no cost: +/// their spend never counts toward the limit. +fn warn_unreported_budget_costs(plan: &CompiledPlan, observer: &dyn SwarmObserver) { + if plan.budget.as_ref().and_then(|b| b.usd).is_none() { + return; + } + let reports_cost = |model: Option<&str>| { + model.is_some_and(|m| m.starts_with("claude:") || m.starts_with("deepseek:")) + }; + let mut ids: Vec = plan + .work_units_unordered() + .into_iter() + .chain(plan.loop_judge_units.iter()) + .filter(|u| !reports_cost(u.model.as_deref())) + .map(|u| u.id.clone()) + .collect(); + ids.sort(); + ids.dedup(); + if ids.is_empty() { + return; + } + let msg = format!( + "budget: cost is not reported for: {} — usd counts claude: and deepseek: only", + ids.join(", ") + ); + tracing::warn!("{msg}"); + observer.on_phase_changed(&msg); +} + +/// Everything a dynamically materialised unit needs to run, borrowed from +/// `execute`. Dynamic units — runtime `for` clones and `pattern map_reduce` +/// workers — are not plan nodes, so they run outside the tier loop, in the +/// shared workspace (both forms require `execution_mode document`). +struct DynamicCtx<'a> { + config: &'a SwarmConfig, + limits: &'a RunLimits, + semaphore: Arc, + memory: Option>, + memory_writer: &'a Option, + observer: &'a dyn SwarmObserver, + validation: Option>, + board: Arc, + analysis: &'a WorkspaceAnalysis, + pre_fetched_memory: Arc>, + tier_router: &'a TierRouter, + iteration_config: &'a crate::iteration::IterationConfig, + bus: &'a Arc>, + run_id: &'a str, + plan_hash: &'a str, + /// Static plan units, for scope validation of the dynamic ones. + static_units: &'a [WorkUnit], + /// Loop scope groups (see `validation::validate_scopes`). + loop_groups: &'a [Vec], +} + +/// Validate, then run `units` concurrently under the run's `max_parallel` +/// semaphore and record every result. The caller must not hold a permit. /// -/// Writes one aggregate entry for the agent's run, plus one sentinel entry per -/// `staleness_source` path recording the current file hash. On the next run, -/// `invalidate_stale_sources` checks these hashes and marks changed entries stale. +/// With `resume_skip`, units already `Completed` in the checkpoint are not +/// run again. `template` names the plan node the units were cloned from (it +/// is left out of scope validation and their clones join its loop group). +async fn run_dynamic_units( + units: Vec, + resume_skip: bool, + template: Option<&str>, + ctx: &DynamicCtx<'_>, + exec_state: &mut ExecutionState, + all_manifests: &mut Vec, + make_observer: &F, +) -> Result> +where + F: Fn(&str) -> Box, +{ + // Clones must not collide with each other or with any static unit. A + // clone shares its template's loop group, like every loop member. + let dynamic_ids: Vec = units.iter().map(|u| u.id.clone()).collect(); + let mut groups: Vec> = ctx.loop_groups.to_vec(); + if let Some(template) = template { + for group in groups.iter_mut() { + if group.iter().any(|id| id == template) { + group.extend(dynamic_ids.iter().cloned()); + } + } + } + let mut checked: Vec = ctx + .static_units + .iter() + .filter(|u| Some(u.id.as_str()) != template) + .cloned() + .collect(); + checked.extend(units.iter().cloned()); + let scope_errors = validation::validate_scopes(&checked, &groups); + let scope_errors: Vec = scope_errors + .iter() + .map(|e| e.to_string()) + .filter(|e| dynamic_ids.iter().any(|id| e.contains(id.as_str()))) + .collect(); + if !scope_errors.is_empty() { + bail!("dynamic unit scope validation failed: {}", scope_errors.join("; ")); + } + + { + let mut b = ctx.bus.lock().await; + for unit in &units { + b.register(&unit.id); + } + } + + let mut handles: Vec<(String, WorkUnit, AbortOnDrop)> = Vec::new(); + for unit in units { + if let Some(reason) = ctx.limits.exhausted(spent_usd(all_manifests)) { + tracing::error!("Run budget exhausted ({reason}) — not starting '{}'", unit.id); + ctx.observer + .on_phase_changed(&format!("run budget exhausted: {reason}")); + break; + } + if resume_skip && exec_state.status(&unit.id) == NodeStatus::Completed { + tracing::info!("Skipping completed dynamic unit '{}' (resume)", unit.id); + continue; + } + if ctx.config.execution_mode == ExecutionMode::Repo { + tracing::warn!( + "dynamic unit '{}' runs in the shared workspace (no worktree)", + unit.id + ); + } + exec_state.set_status(&unit.id, NodeStatus::Running); + ctx.observer + .on_agent_state_changed(&unit.id, &AgentStatus::Pending, "queued"); + + let sem = ctx.semaphore.clone(); + let root = ctx.config.workspace_root.clone(); + let mem = ctx.memory.clone(); + let ns: Vec = unit + .read_namespaces + .as_deref() + .unwrap_or(ctx.config.read_namespaces.as_slice()) + .to_vec(); + let obs = make_observer(&unit.id); + let val_pipeline = ctx.validation.clone(); + let board_ref = Some(ctx.board.clone()); + let rm = ctx.analysis.repo_map.clone(); + let agent_impact = ctx.analysis.impact_texts.get(&unit.id).cloned(); + let router = ctx.tier_router.clone(); + let iteration_config = ctx.iteration_config.clone(); + let pfm = ctx.pre_fetched_memory.clone(); + let swarm_extras = ctx.config.swarm_extra_tools.clone(); + let tool_policy = ctx.config.tool_policy.clone(); + let exposed_tools = ctx.config.exposed_tools.clone(); + let skip_repo_context = ctx.config.execution_mode == ExecutionMode::Document; + let skill_catalog = ctx.config.skill_catalog.clone(); + let task_unit = unit.clone(); + let handle = AbortOnDrop(tokio::spawn(async move { + let _permit = sem.acquire().await.unwrap(); + invalidate_stale_sources(&mem, &task_unit, &root).await; + let write_gate = Arc::new(Mutex::new(WriteGatePipeline::new( + WriteMode::AutoAccept, + Box::new(NoopWriteGateObserver), + ))); + let engine = crate::iteration::IterationEngine::new(iteration_config.clone()); + engine + .run_with_backend_factory( + task_unit.clone(), + write_gate, + &root, + mem.as_ref(), + &ns, + obs.as_ref(), + val_pipeline.as_deref(), + board_ref.as_deref(), + (*rm).as_ref(), + agent_impact.as_deref(), + (*pfm).as_deref(), + &swarm_extras, + tool_policy.as_ref(), + exposed_tools.as_deref(), + skip_repo_context, + skill_catalog.as_deref(), + |candidate| resolve_backend_for_unit(&router, candidate), + ) + .await + .manifest + })); + handles.push((unit.id.clone(), unit, handle)); + } + + let mut manifests = Vec::with_capacity(handles.len()); + for (unit_id, unit, handle) in handles { + let manifest = match handle.await { + Ok(m) => m, + Err(e) => { + let err_msg = format!("task panicked: {e}"); + tracing::error!("dynamic unit {unit_id}: {err_msg}"); + AgentManifest { + work_unit_id: unit_id.clone(), + status: AgentStatus::Failed(err_msg), + modified_files: vec![], + branch: None, + summary: Some("Agent task panicked".into()), + output: None, + cost_usd: 0.0, + } + } + }; + ctx.observer.on_agent_state_changed( + &manifest.work_unit_id, + &manifest.status, + manifest.summary.as_deref().unwrap_or(""), + ); + if matches!(manifest.status, AgentStatus::Completed) { + let b = ctx.bus.lock().await; + b.broadcast( + &manifest.work_unit_id, + &format!("completed: {}", manifest.summary.as_deref().unwrap_or("")), + ); + drop(b); + let effective_write_ns = effective_write_namespace(&unit, ctx.config); + store_agent_result( + &ctx.memory, + ctx.memory_writer, + effective_write_ns, + &manifest, + &unit, + ctx.run_id, + ctx.config, + ) + .await; + } + exec_state.record_result(&unit_id, manifest.clone()); + push_manifest(all_manifests, manifest.clone(), ctx.observer); + manifests.push(manifest); + } + if let Err(e) = exec_state.save(&ctx.config.workspace_root, ctx.plan_hash) { + tracing::warn!("Failed to save execution state checkpoint: {}", e); + } + Ok(manifests) +} + +/// The record of a runtime `for` template: `Completed` once every clone is, +/// `Failed` (naming the failed items) otherwise. Clone costs stay on the +/// clones' own manifests. +fn barrier_manifest(unit_id: &str, clone_ids: &[String], exec_state: &ExecutionState) -> AgentManifest { + let failed: Vec<&str> = clone_ids + .iter() + .filter(|id| !exec_state.status(id).is_success()) + .map(String::as_str) + .collect(); + let (status, summary) = if clone_ids.is_empty() { + (AgentStatus::Completed, "no items".to_string()) + } else if failed.is_empty() { + (AgentStatus::Completed, format!("{} item(s)", clone_ids.len())) + } else { + let msg = format!( + "runtime for: {} of {} item(s) failed: {}", + failed.len(), + clone_ids.len(), + failed.join(", ") + ); + (AgentStatus::Failed(msg.clone()), msg) + }; + AgentManifest { + work_unit_id: unit_id.to_string(), + status, + modified_files: vec![], + branch: None, + summary: Some(summary), + output: None, + cost_usd: 0.0, + } +} + +/// Run one `for … in json` step: read the list, clone the template per item, +/// dispatch the clones, and return the barrier manifest (not yet recorded). +/// +/// `pass` is `Some((iter_abs, gate_feedback))` inside a loop: the list path +/// and every clone get that pass's `{{ITER}}` / `{{PREV_ITER}}`, and nothing +/// is skipped for resume (loops resume per pass, from their artefacts). +/// Returns the clones (with `{{ITER}}` still unsubstituted) alongside, for the +/// loop's delivery checks. #[allow(clippy::too_many_arguments)] -async fn run_fanout_wave_if_needed( +async fn run_runtime_for_step( + template: &WorkUnit, + op: &crate::swarm::plan::RuntimeForOp, + pass: Option<(u32, Option<&GateFailure>)>, + tier_bindings: &std::collections::HashMap, + ctx: &DynamicCtx<'_>, + exec_state: &mut ExecutionState, + all_manifests: &mut Vec, + make_observer: &F, +) -> Result<(AgentManifest, Vec)> +where + F: Fn(&str) -> Box, +{ + let source = match pass { + Some((iter_abs, _)) => op + .source + .replace("{{ITER}}", &iter_abs.to_string()) + .replace("{{PREV_ITER}}", &iter_abs.saturating_sub(1).to_string()), + None => op.source.clone(), + }; + let items = crate::swarm::runtime_for::load_items(&ctx.config.workspace_root, &source)?; + let clones = crate::swarm::runtime_for::materialize(template, op, &items, tier_bindings)?; + tracing::info!( + "runtime for `{}`: {} item(s) from {}", + op.unit_id, + clones.len(), + source + ); + let clone_ids: Vec = clones.iter().map(|c| c.id.clone()).collect(); + let dispatched: Vec = match pass { + Some((iter_abs, gate)) => clones + .iter() + .map(|c| apply_iter_vars_with_gate_feedback(c, iter_abs, gate)) + .collect(), + None => clones.clone(), + }; + run_dynamic_units( + dispatched, + pass.is_none(), + Some(&op.unit_id), + ctx, + exec_state, + all_manifests, + make_observer, + ) + .await?; + Ok((barrier_manifest(&op.unit_id, &clone_ids, exec_state), clones)) +} + +/// Loop members as the delivery checks see them: a runtime `for` template is +/// replaced by its latest clones. +fn expand_loop_members<'a>( + agent_ids: &[String], + unit_map: &std::collections::HashMap<&'a str, &'a WorkUnit>, + dynamic: &'a std::collections::HashMap>, +) -> (Vec, std::collections::HashMap<&'a str, &'a WorkUnit>) { + let mut ids = Vec::with_capacity(agent_ids.len()); + let mut map = unit_map.clone(); + for id in agent_ids { + match dynamic.get(id) { + Some(clones) => { + for clone in clones { + ids.push(clone.id.clone()); + map.insert(clone.id.as_str(), clone); + } + } + None => ids.push(id.clone()), + } + } + (ids, map) +} + +/// `pattern map_reduce`: after `completed_unit_id` (a discover agent) +/// completes, load its spawn manifest and run the workers it lists. +/// +/// Workers run concurrently through the same dispatcher as runtime `for` +/// clones, each is checkpointed, and a resumed run re-runs only the workers +/// not yet `Completed`. A missing manifest or one over `max_spawn` aborts the +/// run. Units that `depends_on` the discover agent count every recorded +/// worker as a dependency (see `unmet_dependency_ids`). +#[allow(clippy::too_many_arguments)] +async fn run_fanout_wave_if_needed( completed_unit_id: &str, plan: &CompiledPlan, - config: &SwarmConfig, - context_files: &[(String, String)], - memory: &Option>, - memory_writer: &Option, - observer: &dyn SwarmObserver, - git_coordinator: Arc, - validation: Option>, - shared_board: Arc, - analysis: &WorkspaceAnalysis, - pre_fetched_memory: Arc>, - tier_router: &TierRouter, - iteration_config: &crate::iteration::IterationConfig, - bus: &Arc>, - all_manifests: &mut Vec, + ctx: &DynamicCtx<'_>, exec_state: &mut ExecutionState, - run_id: &str, - plan_hash: &str, - mut worktree_mgr: Option<&mut WorktreeManager>, - make_observer: &impl Fn(&str) -> Box, -) -> Result<()> { + all_manifests: &mut Vec, + make_observer: &F, +) -> Result<()> +where + F: Fn(&str) -> Box, +{ let Some(op) = plan .fanout_ops .iter() @@ -3951,21 +4678,10 @@ async fn run_fanout_wave_if_needed( else { return Ok(()); }; + let config = ctx.config; - // Resume: skip if we already spawned for this after_unit - if exec_state - .spawned_ids - .iter() - .any(|id| id.starts_with(&format!("{}::", op.after_unit))) - { - tracing::info!( - "fan-out after '{}' already materialized (resume); skipping", - op.after_unit - ); - return Ok(()); - } - - let manifest_path = shared_board + let manifest_path = ctx + .board .spawn_manifest_path(completed_unit_id) .await .or_else(|| { @@ -3979,7 +4695,7 @@ async fn run_fanout_wave_if_needed( .workspace_root .join(".gaviero") .join("runs") - .join(plan_hash) + .join(ctx.plan_hash) .join("artifacts") .join("spawn_manifest") .join(format!("from-{completed_unit_id}.json")), @@ -3988,35 +4704,12 @@ async fn run_fanout_wave_if_needed( }); let Some(path) = manifest_path else { - tracing::warn!( - "FanoutOp after '{}' but no spawn_manifest found on blackboard", - completed_unit_id - ); - return Ok(()); + bail!("pattern map_reduce: discover '{completed_unit_id}' wrote no spawn manifest"); }; let parsed = crate::swarm::spawn::load_manifest_file(&path)?; - let workers = crate::swarm::spawn::materialize_from_manifest(&parsed, op)?; - - let fanout_group: Vec> = vec![workers.iter().map(|w| w.id.clone()).collect()]; - let scope_errors = validation::validate_scopes(&workers, &fanout_group); - if !scope_errors.is_empty() { - anyhow::bail!( - "fan-out scope validation failed: {}", - scope_errors - .iter() - .map(|e| e.to_string()) - .collect::>() - .join("; ") - ); - } - - { - let mut b = bus.lock().await; - for w in &workers { - b.register(&w.id); - } - } + let workers = + crate::swarm::spawn::materialize_from_manifest(&parsed, op, &plan.tier_bindings)?; tracing::info!( "fan-out after '{}': materializing {} workers from {}", @@ -4024,58 +4717,24 @@ async fn run_fanout_wave_if_needed( workers.len(), path.display() ); - - for unit in &workers { - if exec_state.status(&unit.id) == NodeStatus::Completed { - continue; - } - exec_state.set_status(&unit.id, NodeStatus::Running); - observer.on_agent_state_changed(&unit.id, &AgentStatus::Running, &unit.description); - - let effective_read_ns = effective_read_namespaces(unit, config, memory); - let agent_ctx = AgentRunContext::for_run( - config, - context_files, - &effective_read_ns, - observer, - memory.clone(), - git_coordinator.clone(), - validation.clone(), - Some(shared_board.clone()), - analysis, - pre_fetched_memory.clone(), - ); - let manifest = run_single_agent( - unit, - worktree_mgr.as_deref_mut(), - &agent_ctx, - tier_router, - iteration_config, - make_observer(&unit.id), - ) - .await?; - - if matches!(manifest.status, AgentStatus::Completed) { - let effective_write_ns = effective_write_namespace(unit, config); - store_agent_result( - memory, - memory_writer, - effective_write_ns, - &manifest, - unit, - run_id, - config, - ) - .await; + for w in &workers { + let key = format!("{}::{}", op.after_unit, w.id); + if !exec_state.spawned_ids.contains(&key) { + exec_state.spawned_ids.push(key); } - exec_state - .spawned_ids - .push(format!("{}::{}", op.after_unit, unit.id)); - exec_state.record_result(&unit.id, manifest.clone()); - let _ = exec_state.save(&config.workspace_root, plan_hash); - all_manifests.push(manifest); } + run_dynamic_units( + workers, + true, + None, + ctx, + exec_state, + all_manifests, + make_observer, + ) + .await?; + // Refresh knowledge impact texts after a mutating fan-out wave if config.execution_mode == ExecutionMode::Repo { let remaining: Vec = plan @@ -4099,6 +4758,29 @@ async fn run_fanout_wave_if_needed( Ok(()) } +/// Whether the fan-out wave after `discover` still has work: no worker was +/// ever recorded, or one is not `Completed`. +fn fanout_wave_pending(plan: &CompiledPlan, discover: &str, exec_state: &ExecutionState) -> bool { + if !plan.fanout_ops.iter().any(|op| op.after_unit == discover) { + return false; + } + let prefix = format!("{discover}::"); + let mut recorded = exec_state + .spawned_ids + .iter() + .filter_map(|key| key.strip_prefix(&prefix)) + .peekable(); + if recorded.peek().is_none() { + return true; + } + recorded.any(|worker| exec_state.status(worker) != NodeStatus::Completed) +} + +/// Store an agent's execution result to memory (best-effort, never fails the pipeline). +/// +/// Writes one aggregate entry for the agent's run, plus one sentinel entry per +/// `staleness_source` path recording the current file hash. On the next run, +/// `invalidate_stale_sources` checks these hashes and marks changed entries stale. async fn store_agent_result( memory: &Option>, writer: &Option, @@ -4449,6 +5131,33 @@ mod tests { use crate::types::{FileScope, ModelTier, PrivacyLevel}; use std::collections::HashMap; + #[test] + fn run_limits_usd_exhaustion() { + let budget = crate::swarm::plan::RunBudget { + wall_secs: None, + usd: Some(1.0), + }; + let limits = RunLimits::new(0, Some(&budget)); + assert!(limits.exhausted(0.5).is_none()); + let reason = limits.exhausted(1.2).expect("over the usd budget"); + assert!(reason.contains("usd budget of $1.00"), "{reason}"); + + // No budget and no --run-timeout: nothing ever runs out. + assert!(RunLimits::new(0, None).exhausted(1e9).is_none()); + } + + #[test] + fn run_limits_take_the_smaller_wall() { + let budget = crate::swarm::plan::RunBudget { + wall_secs: Some(3600), + usd: None, + }; + let limits = RunLimits::new(60, Some(&budget)); + assert_eq!(limits.wall, Some(std::time::Duration::from_secs(60))); + let limits = RunLimits::new(0, Some(&budget)); + assert_eq!(limits.wall, Some(std::time::Duration::from_secs(3600))); + } + /// Abandoning a run must take its parallel agents with it. #[tokio::test] async fn dropping_an_agent_handle_aborts_the_task() { @@ -4494,6 +5203,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], #[allow(deprecated)] @@ -6155,6 +6865,13 @@ async fn evaluate_agent_condition( iter_abs: current_iter_abs, })?; + if let Some(reason) = ctx.limits.exhausted(spent_usd(ctx.all_manifests)) { + tracing::error!("Run budget exhausted ({reason}) — not dispatching judge '{agent_id}'"); + ctx.observer + .on_phase_changed(&format!("run budget exhausted: {reason}")); + return Ok(LoopConditionOutcome::Continue(JudgeReport::default())); + } + let agent_id = &agent_id.to_string(); let Some(unit_template) = ctx.loop_judge_map.get(agent_id.as_str()).copied() else { tracing::warn!( @@ -6345,7 +7062,7 @@ async fn evaluate_agent_condition( _ => LoopConditionOutcome::Continue(report), }; - ctx.all_manifests.push(manifest); + push_manifest(ctx.all_manifests, manifest, ctx.observer); Ok(outcome) } diff --git a/crates/gaviero-core/src/swarm/plan.rs b/crates/gaviero-core/src/swarm/plan.rs index 76835da8..a4d607f2 100644 --- a/crates/gaviero-core/src/swarm/plan.rs +++ b/crates/gaviero-core/src/swarm/plan.rs @@ -130,12 +130,16 @@ pub enum ConsensusMode { pub const DEFAULT_MAX_SPAWN: u32 = 16; /// One worker entry inside a spawn manifest (dynamic fan-out). +/// +/// A worker names a `tier` of the run's model profile, never a model: the +/// manifest is agent-written, and models are chosen by tier only. Without a +/// tier it takes the op's `default_model`. #[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] pub struct SpawnWorkerSpec { pub id: String, - pub model: String, #[serde(default)] - pub effort: Option, + pub tier: Option, #[serde(default)] pub description: String, #[serde(default)] @@ -170,7 +174,8 @@ pub struct FanoutOp { /// Max workers to spawn (default [`DEFAULT_MAX_SPAWN`]). #[serde(default = "default_max_spawn")] pub max_spawn: u32, - /// Optional default model when a worker omits `model`. + /// Model for workers that name no `tier`. Set by core-built plans only; + /// DSL `pattern map_reduce` leaves it empty, so its workers need a tier. #[serde(default)] pub default_model: Option, /// Optional synthetic barrier id that reduce agents `depends_on`. @@ -183,6 +188,39 @@ fn default_max_spawn() -> u32 { DEFAULT_MAX_SPAWN } +/// A `for in json "" parallel max { }` step. The body +/// agent is the plan node `unit_id` (a template whose `{{.*}}` +/// placeholders survive compile); the runtime materialises one clone per item. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RuntimeForOp { + pub unit_id: String, + pub var: String, + /// Workspace-relative path; may contain `{{ITER}}` / `{{PREV_ITER}}`. + pub source: String, + pub max_items: u32, +} + +/// What a profile tier resolves to, captured at compile time so +/// runtime-materialised units (`for … in json` items, spawn-manifest +/// workers) can bind to tiers. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TierBinding { + pub model: Option, + pub effort: Option, + pub extra: Vec<(String, String)>, + pub privacy: crate::types::PrivacyLevel, + pub tier: crate::types::ModelTier, +} + +/// A workflow's `budget { wall "" usd }`: limits checked before every +/// dispatch. `usd` counts the cost providers report (`claude:`, `deepseek:`); +/// the wall clock merges with `--run-timeout` (the smaller non-zero wins). +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub struct RunBudget { + pub wall_secs: Option, + pub usd: Option, +} + /// Configuration for an explicit `loop { ... }` block in a workflow. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LoopConfig { @@ -302,6 +340,15 @@ pub struct CompiledPlan { /// Runtime fan-out ops: after `after_unit` completes, load a SpawnManifest /// from the blackboard and materialize additional work units (capped). pub fanout_ops: Vec, + /// `for … in json` steps: each names a template node in `graph` that the + /// runtime replaces with one clone per item of a JSON list. + pub runtime_fors: Vec, + /// Every tier of the run's model profile, resolved to its client's + /// model settings, so runtime items (`for … in json`, spawn-manifest + /// workers) can name a `tier`. + pub tier_bindings: HashMap, + /// The workflow's `budget { … }`, when declared. + pub budget: Option, } impl CompiledPlan { @@ -403,6 +450,9 @@ impl CompiledPlan { loop_judge_units: Vec::new(), execution_mode: ExecutionMode::default(), fanout_ops: Vec::new(), + runtime_fors: Vec::new(), + tier_bindings: HashMap::new(), + budget: None, } } diff --git a/crates/gaviero-core/src/swarm/plan_document.rs b/crates/gaviero-core/src/swarm/plan_document.rs index 5e1d4c15..6740dc13 100644 --- a/crates/gaviero-core/src/swarm/plan_document.rs +++ b/crates/gaviero-core/src/swarm/plan_document.rs @@ -120,6 +120,7 @@ mod tests { id: id.into(), description: id.into(), scope: FileScope::default(), + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/privacy.rs b/crates/gaviero-core/src/swarm/privacy.rs index 85bc890b..59cbd470 100644 --- a/crates/gaviero-core/src/swarm/privacy.rs +++ b/crates/gaviero-core/src/swarm/privacy.rs @@ -157,6 +157,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/router.rs b/crates/gaviero-core/src/swarm/router.rs index 10b9fa43..2c70e02e 100644 --- a/crates/gaviero-core/src/swarm/router.rs +++ b/crates/gaviero-core/src/swarm/router.rs @@ -375,6 +375,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/runtime_for.rs b/crates/gaviero-core/src/swarm/runtime_for.rs new file mode 100644 index 00000000..b25cb61b --- /dev/null +++ b/crates/gaviero-core/src/swarm/runtime_for.rs @@ -0,0 +1,425 @@ +//! Runtime-sized `for`: `for in json "" parallel max { }`. +//! +//! The DSL compiles the body agent once, as a template whose `{{.*}}` +//! placeholders survive compilation, and records a +//! [`RuntimeForOp`](crate::swarm::plan::RuntimeForOp). When the scheduler +//! reaches the template it reads the JSON list ([`load_items`]) and clones the +//! template once per item ([`materialize`]); the pipeline dispatches the clones +//! in parallel and records the template as a barrier over them. +//! +//! The list file is a JSON **array of flat objects**: `id` is required (a +//! string matching `[A-Za-z0-9][A-Za-z0-9_.-]*`, unique), `tier` is optional +//! (a tier of the run's model profile; the clone runs on it instead of the +//! template's tier), and every other value becomes an item field. `model` and +//! `effort` keys are rejected: a model is chosen by tier only. Strings are +//! taken as-is, numbers and bools are rendered as text, arrays and objects as +//! compact JSON. Item values are not themselves var-substituted. + +use std::collections::HashMap; +use std::path::Path; + +use anyhow::{Context, Result, bail}; + +use crate::swarm::models::WorkUnit; +use crate::swarm::plan::{RuntimeForOp, TierBinding}; + +/// One element of a runtime `for` list. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RuntimeItem { + pub id: String, + /// A tier of the run's model profile (`plan.tier_bindings`). + pub tier: Option, + /// Every other key, in file order. + pub fields: Vec<(String, String)>, +} + +fn valid_item_id(id: &str) -> bool { + let mut chars = id.chars(); + match chars.next() { + Some(c) if c.is_ascii_alphanumeric() => {} + _ => return false, + } + chars.all(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | '-')) +} + +fn render_value(value: &serde_json::Value) -> String { + match value { + serde_json::Value::String(s) => s.clone(), + serde_json::Value::Null => String::new(), + serde_json::Value::Bool(b) => b.to_string(), + serde_json::Value::Number(n) => n.to_string(), + other => other.to_string(), + } +} + +/// Read and validate the list file at `workspace_root/rel_path`. +pub fn load_items(workspace_root: &Path, rel_path: &str) -> Result> { + let path = workspace_root.join(rel_path); + let text = std::fs::read_to_string(&path) + .with_context(|| format!("runtime for: reading list file {rel_path}"))?; + parse_items(&text).with_context(|| format!("runtime for: list file {rel_path}")) +} + +/// Parse and validate a list document (see the module docs for the shape). +pub fn parse_items(text: &str) -> Result> { + let value: serde_json::Value = serde_json::from_str(text).context("invalid JSON")?; + let serde_json::Value::Array(elements) = value else { + bail!("the top level must be a JSON array of objects"); + }; + let mut items = Vec::with_capacity(elements.len()); + let mut seen: std::collections::HashSet = std::collections::HashSet::new(); + for (index, element) in elements.iter().enumerate() { + let serde_json::Value::Object(map) = element else { + bail!("element {} is not a JSON object", index + 1); + }; + let id = match map.get("id") { + Some(serde_json::Value::String(s)) => s.clone(), + Some(_) => bail!("element {}: `id` must be a string", index + 1), + None => bail!("element {} has no `id`", index + 1), + }; + if !valid_item_id(&id) { + bail!( + "element {}: id `{id}` must match [A-Za-z0-9][A-Za-z0-9_.-]*", + index + 1 + ); + } + if !seen.insert(id.clone()) { + bail!("duplicate id `{id}`"); + } + let mut item = RuntimeItem { + id, + tier: None, + fields: Vec::new(), + }; + for (key, value) in map { + match key.as_str() { + "id" => {} + "tier" => item.tier = Some(render_value(value)).filter(|t| !t.is_empty()), + "model" | "effort" => bail!( + "element {}: `{key}` is not an item key — give the item a `tier` of \ + the run's model profile instead", + index + 1 + ), + _ => item.fields.push((key.clone(), render_value(value))), + } + } + items.push(item); + } + Ok(items) +} + +/// The `{{.}}` values for item `index` of `items`. +pub fn item_vars(var: &str, items: &[RuntimeItem], index: usize) -> Vec<(String, String)> { + let item = &items[index]; + let peers: Vec<&str> = items + .iter() + .filter(|other| other.id != item.id) + .map(|other| other.id.as_str()) + .collect(); + let mut vars = vec![(format!("{var}.id"), item.id.clone())]; + for (key, value) in &item.fields { + vars.push((format!("{var}.{key}"), value.clone())); + } + if let Some(tier) = &item.tier { + vars.push((format!("{var}.tier"), tier.clone())); + } + vars.push((format!("{var}.index"), (index + 1).to_string())); + vars.push((format!("{var}.count"), items.len().to_string())); + vars.push((format!("{var}.peers"), peers.join(","))); + vars.push((format!("{var}.peer_count"), peers.len().to_string())); + vars +} + +fn substitute(text: &str, vars: &[(String, String)]) -> String { + let mut out = text.to_string(); + for (key, value) in vars { + out = out.replace(&format!("{{{{{key}}}}}"), value); + } + out +} + +/// The first `{{.…}}` placeholder left in `text`, if any. +fn leftover_placeholder(text: &str, var: &str) -> Option { + let needle = format!("{{{{{var}."); + let start = text.find(&needle)?; + let rest = &text[start..]; + let end = rest.find("}}").map(|e| e + 2).unwrap_or(rest.len()); + Some(rest[..end].to_string()) +} + +/// Clone `template` once per item. +/// +/// Clones are named `@`. Item vars are substituted in the +/// description, instructions, owned / read-only paths and declared outputs; +/// any `{{.…}}` left afterwards is an error naming the item. An item's +/// `tier` replaces the template's model with that tier's binding. +pub fn materialize( + template: &WorkUnit, + op: &RuntimeForOp, + items: &[RuntimeItem], + tiers: &HashMap, +) -> Result> { + if items.len() > op.max_items as usize { + bail!( + "runtime for `{}`: the list has {} items, over its `max {}`", + op.unit_id, + items.len(), + op.max_items + ); + } + let mut clones = Vec::with_capacity(items.len()); + for (index, item) in items.iter().enumerate() { + let vars = item_vars(&op.var, items, index); + let mut clone = template.clone(); + clone.id = format!("{}@{}", op.unit_id, item.id); + clone.description = substitute(&template.description, &vars); + clone.coordinator_instructions = substitute(&template.coordinator_instructions, &vars); + clone.scope.owned_paths = template + .scope + .owned_paths + .iter() + .map(|p| substitute(p, &vars)) + .collect(); + clone.scope.read_only_paths = template + .scope + .read_only_paths + .iter() + .map(|p| substitute(p, &vars)) + .collect(); + clone.produces = template + .produces + .iter() + .map(|p| substitute(p, &vars)) + .collect(); + clone.produces_json = template + .produces_json + .iter() + .map(|p| substitute(p, &vars)) + .collect(); + + let texts = std::iter::once(&clone.description) + .chain(std::iter::once(&clone.coordinator_instructions)) + .chain(clone.scope.owned_paths.iter()) + .chain(clone.scope.read_only_paths.iter()) + .chain(clone.produces.iter()) + .chain(clone.produces_json.iter()); + for text in texts { + if let Some(placeholder) = leftover_placeholder(text, &op.var) { + bail!( + "runtime for `{}`: item `{}` has no value for {placeholder}", + op.unit_id, + item.id + ); + } + } + + if let Some(alias) = item.tier.as_deref() { + let binding = tiers.get(alias).with_context(|| { + let mut known: Vec<&str> = tiers.keys().map(String::as_str).collect(); + known.sort_unstable(); + format!( + "runtime for `{}`: item `{}` names tier `{alias}`, which the run's \ + model profile does not define (it defines: {})", + op.unit_id, + item.id, + known.join(", ") + ) + })?; + clone.model = binding.model.clone(); + clone.effort = binding.effort.clone(); + clone.extra = binding.extra.clone(); + clone.privacy = binding.privacy; + clone.tier = binding.tier; + } + if let (Some(model), Some(effort)) = (clone.model.as_deref(), clone.effort.as_deref()) + && let Some(problem) = crate::swarm::backend::effort::effort_problem(model, effort) + { + bail!( + "runtime for `{}`: item `{}`: {problem}", + op.unit_id, + item.id + ); + } + clones.push(clone); + } + Ok(clones) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::types::{FileScope, ModelTier, PrivacyLevel}; + + #[allow(deprecated)] + fn template() -> WorkUnit { + WorkUnit { + id: "worker".into(), + description: "investigate {{q.id}}".into(), + scope: FileScope { + owned_paths: vec!["out/{{q.id}}-v*.md".into()], + read_only_paths: vec!["brief/{{q.focus}}.md".into()], + interface_contracts: Default::default(), + }, + produces_json: vec![], + produces: vec!["out/{{q.id}}-v{{ITER}}.md".into()], + depends_on: vec!["planner".into()], + backend: Default::default(), + model: Some("claude:sonnet".into()), + effort: None, + extra: vec![], + tier: ModelTier::Cheap, + privacy: PrivacyLevel::Public, + coordinator_instructions: "MARK-{{q.id}} focus={{q.focus}} {{q.index}}/{{q.count}} peers={{q.peers}}".into(), + estimated_tokens: 0, + max_retries: 1, + timeout_secs: 3600, + escalation_tier: None, + read_namespaces: None, + write_namespace: None, + memory_importance: None, + staleness_sources: vec![], + memory_read_query: None, + memory_read_limit: None, + memory_write_content: None, + impact_scope: false, + context_callers_of: vec![], + context_tests_for: vec![], + context_depth: 2, + extra_allowed_tools: vec![], + } + } + + fn op(max_items: u32) -> RuntimeForOp { + RuntimeForOp { + unit_id: "worker".into(), + var: "q".into(), + source: "out/items.json".into(), + max_items, + } + } + + #[test] + fn loads_flat_objects_and_stringifies_scalars() { + let items = parse_items( + r#"[{"id":"a","focus":"x","n":3,"ok":true,"tags":["p","q"],"tier":"high"}]"#, + ) + .unwrap(); + assert_eq!(items.len(), 1); + assert_eq!(items[0].id, "a"); + assert_eq!(items[0].tier.as_deref(), Some("high")); + let field = |k: &str| { + items[0] + .fields + .iter() + .find(|(key, _)| key == k) + .map(|(_, v)| v.clone()) + }; + assert_eq!(field("focus").as_deref(), Some("x")); + assert_eq!(field("n").as_deref(), Some("3")); + assert_eq!(field("ok").as_deref(), Some("true")); + assert_eq!(field("tags").as_deref(), Some(r#"["p","q"]"#)); + } + + #[test] + fn loads_items_from_a_file() { + let dir = tempfile::tempdir().unwrap(); + std::fs::write(dir.path().join("items.json"), r#"[{"id":"a"}]"#).unwrap(); + assert_eq!(load_items(dir.path(), "items.json").unwrap()[0].id, "a"); + let missing = load_items(dir.path(), "nope.json").unwrap_err(); + assert!(format!("{missing:#}").contains("nope.json"), "{missing:#}"); + } + + #[test] + fn rejects_duplicate_ids() { + let err = parse_items(r#"[{"id":"a"},{"id":"a"}]"#).unwrap_err(); + assert!(err.to_string().contains("duplicate id `a`"), "{err}"); + } + + #[test] + fn rejects_non_array() { + assert!(parse_items(r#"{"items":[]}"#).is_err()); + assert!(parse_items(r#"[1]"#).is_err()); + assert!(parse_items(r#"[{"name":"no id"}]"#).is_err()); + assert!(parse_items(r#"[{"id":"-bad"}]"#).is_err()); + } + + #[test] + fn materialize_names_clones_and_substitutes_paths() { + let items = parse_items(r#"[{"id":"a","focus":"x"},{"id":"b","focus":"y"}]"#).unwrap(); + let clones = materialize(&template(), &op(16), &items, &HashMap::new()).unwrap(); + assert_eq!(clones.len(), 2); + assert_eq!(clones[0].id, "worker@a"); + assert_eq!(clones[1].id, "worker@b"); + assert_eq!(clones[0].description, "investigate a"); + assert_eq!(clones[0].scope.owned_paths, vec!["out/a-v*.md"]); + assert_eq!(clones[1].scope.read_only_paths, vec!["brief/y.md"]); + // {{ITER}} is left for the loop pass. + assert_eq!(clones[0].produces, vec!["out/a-v{{ITER}}.md"]); + assert_eq!( + clones[1].coordinator_instructions, + "MARK-b focus=y 2/2 peers=a" + ); + assert_eq!(clones[0].depends_on, vec!["planner".to_string()]); + } + + #[test] + fn materialize_rejects_over_cap() { + let items = parse_items(r#"[{"id":"a","focus":"x"},{"id":"b","focus":"y"},{"id":"c","focus":"z"}]"#) + .unwrap(); + let err = materialize(&template(), &op(2), &items, &HashMap::new()).unwrap_err(); + assert!(err.to_string().contains("max 2"), "{err}"); + } + + #[test] + fn materialize_rejects_unknown_item_placeholder() { + let items = parse_items(r#"[{"id":"a"}]"#).unwrap(); + let err = materialize(&template(), &op(16), &items, &HashMap::new()).unwrap_err(); + let msg = err.to_string(); + assert!(msg.contains("{{q.focus}}"), "{msg}"); + assert!(msg.contains("`a`"), "{msg}"); + } + + #[test] + fn materialize_resolves_tier_models() { + let items = parse_items(r#"[{"id":"a","focus":"x","tier":"high"}]"#).unwrap(); + let mut tiers = HashMap::new(); + tiers.insert( + "high".to_string(), + TierBinding { + model: Some("codex:gpt-5.5".into()), + effort: Some("high".into()), + extra: vec![("k".into(), "v".into())], + privacy: PrivacyLevel::Public, + tier: ModelTier::Expensive, + }, + ); + let clones = materialize(&template(), &op(16), &items, &tiers).unwrap(); + assert_eq!(clones[0].model.as_deref(), Some("codex:gpt-5.5")); + assert_eq!(clones[0].effort.as_deref(), Some("high")); + assert_eq!(clones[0].extra, vec![("k".to_string(), "v".to_string())]); + assert_eq!(clones[0].tier, ModelTier::Expensive); + + let unknown = parse_items(r#"[{"id":"a","focus":"x","tier":"nope"}]"#).unwrap(); + let err = materialize(&template(), &op(16), &unknown, &tiers).unwrap_err(); + assert!(err.to_string().contains("it defines: high"), "{err}"); + + // Without `tier` the clone keeps the template's model. + let plain = parse_items(r#"[{"id":"a","focus":"x"}]"#).unwrap(); + let clones = materialize(&template(), &op(16), &plain, &tiers).unwrap(); + assert_eq!(clones[0].model.as_deref(), Some("claude:sonnet")); + } + + /// A model is chosen by tier only: an item may not name a model or an + /// effort directly. + #[test] + fn items_reject_model_and_effort_keys() { + for doc in [ + r#"[{"id":"a","model":"codex:gpt-5.5"}]"#, + r#"[{"id":"a","model":"tier:high"}]"#, + r#"[{"id":"a","effort":"high"}]"#, + ] { + let err = parse_items(doc).unwrap_err(); + assert!(err.to_string().contains("give the item a `tier`"), "{doc}: {err}"); + } + } +} diff --git a/crates/gaviero-core/src/swarm/spawn.rs b/crates/gaviero-core/src/swarm/spawn.rs index d98d8564..0cf53c5e 100644 --- a/crates/gaviero-core/src/swarm/spawn.rs +++ b/crates/gaviero-core/src/swarm/spawn.rs @@ -1,23 +1,34 @@ //! Runtime fan-out: materialize WorkUnits from a SpawnManifest. +use std::collections::HashMap; + use anyhow::{Context, Result, bail}; use crate::swarm::backend::shared::validate_model_spec; use crate::swarm::models::WorkUnit; -use crate::swarm::plan::{FanoutOp, SpawnManifest, SpawnWorkerSpec}; +use crate::swarm::plan::{FanoutOp, SpawnManifest, SpawnWorkerSpec, TierBinding}; use crate::types::FileScope; /// Parse and materialize workers from spawn-manifest JSON. /// -/// Caps at `op.max_spawn` (default 16). Validates every `provider:model` spec. -pub fn materialize_from_json(json: &str, op: &FanoutOp) -> Result> { +/// Caps at `op.max_spawn` (default 16). A worker's `tier` resolves through +/// `tiers` (the plan's profile bindings). +pub fn materialize_from_json( + json: &str, + op: &FanoutOp, + tiers: &HashMap, +) -> Result> { let manifest: SpawnManifest = serde_json::from_str(json).context("parsing spawn_manifest.json")?; - materialize_from_manifest(&manifest, op) + materialize_from_manifest(&manifest, op, tiers) } /// Materialize workers from an already-parsed manifest. -pub fn materialize_from_manifest(manifest: &SpawnManifest, op: &FanoutOp) -> Result> { +pub fn materialize_from_manifest( + manifest: &SpawnManifest, + op: &FanoutOp, + tiers: &HashMap, +) -> Result> { if manifest.workers.is_empty() { bail!("spawn manifest has no workers"); } @@ -32,27 +43,41 @@ pub fn materialize_from_manifest(manifest: &SpawnManifest, op: &FanoutOp) -> Res let mut units = Vec::with_capacity(manifest.workers.len()); for w in &manifest.workers { - units.push(worker_to_unit(w, op)?); + units.push(worker_to_unit(w, op, tiers)?); } Ok(units) } -fn worker_to_unit(w: &SpawnWorkerSpec, op: &FanoutOp) -> Result { - let model = if w.model.is_empty() { - op.default_model - .clone() - .context("worker missing model and FanoutOp has no default_model")? - } else { - w.model.clone() +fn worker_to_unit( + w: &SpawnWorkerSpec, + op: &FanoutOp, + tiers: &HashMap, +) -> Result { + let binding = match w.tier.as_deref().filter(|t| !t.is_empty()) { + Some(tier) => tiers.get(tier).cloned().with_context(|| { + let mut known: Vec<&str> = tiers.keys().map(String::as_str).collect(); + known.sort_unstable(); + format!( + "worker '{}' names tier `{tier}`, which the run's model profile does not \ + define (it defines: {})", + w.id, + known.join(", ") + ) + })?, + None => { + let model = op.default_model.clone().with_context(|| { + format!("worker '{}' names no `tier` (a tier of the run's model profile)", w.id) + })?; + validate_model_spec(&model).with_context(|| format!("worker '{}'", w.id))?; + TierBinding { + model: Some(model), + effort: None, + extra: vec![], + privacy: Default::default(), + tier: Default::default(), + } + } }; - validate_model_spec(&model).with_context(|| format!("worker '{}'", w.id))?; - if let Some(problem) = w - .effort - .as_deref() - .and_then(|effort| crate::swarm::backend::effort::effort_problem(&model, effort)) - { - bail!("worker '{}': {problem}", w.id); - } let prompt = if w.prompt.is_empty() { w.description.clone() @@ -74,14 +99,15 @@ fn worker_to_unit(w: &SpawnWorkerSpec, op: &FanoutOp) -> Result { }, // Runtime fan-out workers come from a SpawnManifest, which carries // scope but no output contract. + produces_json: vec![], produces: Vec::new(), depends_on: vec![op.after_unit.clone()], backend: Default::default(), - model: Some(model), - effort: w.effort.clone(), - extra: vec![], - tier: Default::default(), - privacy: Default::default(), + model: binding.model, + effort: binding.effort, + extra: binding.extra, + tier: binding.tier, + privacy: binding.privacy, coordinator_instructions: prompt, estimated_tokens: 0, max_retries: 1, @@ -114,69 +140,84 @@ mod tests { use super::*; use crate::swarm::plan::FanoutOp; + use crate::types::{ModelTier, PrivacyLevel}; + fn sample_json(n: usize) -> String { let workers: Vec = (0..n) .map(|i| { format!( - r#"{{"id":"w{i}","model":"claude:sonnet","description":"d{i}","prompt":"p{i}","owned":["src/{i}/"]}}"# + r#"{{"id":"w{i}","tier":"low","description":"d{i}","prompt":"p{i}","owned":["src/{i}/"]}}"# ) }) .collect(); format!(r#"{{"version":1,"workers":[{}]}}"#, workers.join(",")) } - #[test] - fn materialize_three_workers() { - let op = FanoutOp { + fn op(max_spawn: u32, default_model: Option<&str>) -> FanoutOp { + FanoutOp { after_unit: "discover".into(), - max_spawn: 16, - default_model: None, + max_spawn, + default_model: default_model.map(str::to_string), barrier_id: None, - }; - let units = materialize_from_json(&sample_json(3), &op).unwrap(); + } + } + + fn tiers() -> HashMap { + HashMap::from([( + "low".to_string(), + TierBinding { + model: Some("claude:sonnet".into()), + effort: Some("medium".into()), + extra: vec![], + privacy: PrivacyLevel::Public, + tier: ModelTier::Cheap, + }, + )]) + } + + #[test] + fn materialize_three_workers() { + let units = materialize_from_json(&sample_json(3), &op(16, None), &tiers()).unwrap(); assert_eq!(units.len(), 3); assert_eq!(units[0].id, "w0"); assert_eq!(units[0].model.as_deref(), Some("claude:sonnet")); + assert_eq!(units[0].effort.as_deref(), Some("medium")); assert_eq!(units[0].depends_on, vec!["discover".to_string()]); assert_eq!(units[2].scope.owned_paths, vec!["src/2/".to_string()]); } #[test] - fn rejects_a_wrong_model_and_effort_pair() { - let op = FanoutOp { - after_unit: "discover".into(), - max_spawn: 16, - default_model: None, - barrier_id: None, - }; - let wrong = r#"{"version":1,"workers":[{"id":"w","model":"dsh:deepseek-flash","effort":"medium"}]}"#; - let error = materialize_from_json(wrong, &op).unwrap_err().to_string(); - assert!(error.contains("no `medium` effort"), "{error}"); - - let right = r#"{"version":1,"workers":[{"id":"w","model":"dsh:deepseek-flash","effort":"high"}]}"#; - assert_eq!(materialize_from_json(right, &op).unwrap()[0].effort.as_deref(), Some("high")); + fn a_worker_names_a_tier_of_the_profile() { + let unknown = r#"{"version":1,"workers":[{"id":"w","tier":"top"}]}"#; + let error = materialize_from_json(unknown, &op(16, None), &tiers()) + .unwrap_err() + .to_string(); + assert!(error.contains("it defines: low"), "{error}"); + + let none = r#"{"version":1,"workers":[{"id":"w"}]}"#; + let error = materialize_from_json(none, &op(16, None), &tiers()) + .unwrap_err() + .to_string(); + assert!(error.contains("names no `tier`"), "{error}"); + // A core-built op may still supply a default. + let units = materialize_from_json(none, &op(16, Some("claude:haiku")), &tiers()).unwrap(); + assert_eq!(units[0].model.as_deref(), Some("claude:haiku")); } + /// Models are chosen by tier only: a worker cannot name a model or an + /// effort. #[test] - fn rejects_bare_model() { - let op = FanoutOp { - after_unit: "discover".into(), - max_spawn: 16, - default_model: None, - barrier_id: None, - }; - let json = r#"{"version":1,"workers":[{"id":"w","model":"sonnet"}]}"#; - assert!(materialize_from_json(json, &op).is_err()); + fn rejects_model_and_effort_keys() { + for json in [ + r#"{"version":1,"workers":[{"id":"w","model":"claude:sonnet"}]}"#, + r#"{"version":1,"workers":[{"id":"w","tier":"low","effort":"high"}]}"#, + ] { + assert!(materialize_from_json(json, &op(16, None), &tiers()).is_err(), "{json}"); + } } #[test] fn rejects_over_cap() { - let op = FanoutOp { - after_unit: "discover".into(), - max_spawn: 2, - default_model: None, - barrier_id: None, - }; - assert!(materialize_from_json(&sample_json(3), &op).is_err()); + assert!(materialize_from_json(&sample_json(3), &op(2, None), &tiers()).is_err()); } } diff --git a/crates/gaviero-core/src/swarm/validation.rs b/crates/gaviero-core/src/swarm/validation.rs index 91bb084d..7f2488e7 100644 --- a/crates/gaviero-core/src/swarm/validation.rs +++ b/crates/gaviero-core/src/swarm/validation.rs @@ -275,6 +275,7 @@ mod tests { id: id.to_string(), description: format!("Task {}", id), scope: scope(owned), + produces_json: vec![], produces: vec![], depends_on: deps.iter().map(|s| s.to_string()).collect(), backend: Default::default(), diff --git a/crates/gaviero-core/src/swarm/verify/combined.rs b/crates/gaviero-core/src/swarm/verify/combined.rs index 9937ff70..046e166e 100644 --- a/crates/gaviero-core/src/swarm/verify/combined.rs +++ b/crates/gaviero-core/src/swarm/verify/combined.rs @@ -474,6 +474,7 @@ mod tests { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/tests/swarm_budget.rs b/crates/gaviero-core/tests/swarm_budget.rs new file mode 100644 index 00000000..07194709 --- /dev/null +++ b/crates/gaviero-core/tests/swarm_budget.rs @@ -0,0 +1,338 @@ +//! `budget { wall usd }` through the real `swarm::pipeline::execute` path, +//! against a mock Ollama server. + +#![allow(dead_code)] + +use std::collections::HashMap; +use std::path::Path; +use std::sync::{Arc, Mutex}; + +use gaviero_core::observer::{AcpObserver, SwarmObserver}; +use gaviero_core::repo_map::SpecificityConfig; +use gaviero_core::swarm::models::{AgentStatus, SwarmResult, WorkUnit}; +use gaviero_core::swarm::pipeline::{SwarmConfig, execute}; +use gaviero_core::swarm::plan::{ + CompiledPlan, ExecutionMode, LoopConfig, LoopUntilCondition, RunBudget, RuntimeForOp, +}; +use gaviero_core::swarm::verify::CostEstimate; +use gaviero_core::types::{FileScope, ModelTier, PrivacyLevel}; +use wiremock::matchers::{body_string_contains, method, path}; +use wiremock::{Mock, MockServer, ResponseTemplate}; + +#[allow(deprecated)] +fn unit( + id: &str, + owned: &[&str], + produces: &[&str], + instructions: &str, + depends_on: &[&str], +) -> WorkUnit { + WorkUnit { + id: id.to_string(), + description: format!("test unit {id}"), + scope: FileScope { + owned_paths: owned.iter().map(|s| s.to_string()).collect(), + read_only_paths: vec![], + interface_contracts: HashMap::new(), + }, + produces_json: vec![], + produces: produces.iter().map(|s| s.to_string()).collect(), + depends_on: depends_on.iter().map(|s| s.to_string()).collect(), + backend: Default::default(), + model: Some("ollama:qwen".to_string()), + effort: None, + extra: vec![], + tier: ModelTier::Cheap, + privacy: PrivacyLevel::Public, + coordinator_instructions: instructions.to_string(), + estimated_tokens: 0, + max_retries: 1, + timeout_secs: 3600, + escalation_tier: None, + read_namespaces: None, + write_namespace: None, + memory_importance: None, + staleness_sources: vec![], + memory_read_query: None, + memory_read_limit: None, + memory_write_content: None, + impact_scope: false, + context_callers_of: vec![], + context_tests_for: vec![], + context_depth: 2, + extra_allowed_tools: vec![], + } +} + +/// The template every test clones: one finding per item. +fn worker() -> WorkUnit { + unit( + "worker", + &["out/{{q.id}}.md"], + &["out/{{q.id}}.md"], + "MARK-{{q.id}}: investigate focus={{q.focus}}", + &[], + ) +} + +fn op(source: &str, max_items: u32) -> RuntimeForOp { + RuntimeForOp { + unit_id: "worker".into(), + var: "q".into(), + source: source.into(), + max_items, + } +} + +fn command_loop(agent_ids: &[&str], max_iterations: u32) -> LoopConfig { + LoopConfig { + agent_ids: agent_ids.iter().map(|s| s.to_string()).collect(), + until: LoopUntilCondition::Command("exit 1".to_string()), + max_iterations, + iter_start: 1, + strict_judge: true, + stability: 1, + judge_timeout_secs: 120, + branch_chain: Default::default(), + consensus_mode: Default::default(), + verdict_output_dir: None, + irreconcilable_after: 2, + baseline_units: Vec::new(), + } +} + +struct QuietObserver; + +impl SwarmObserver for QuietObserver { + fn on_phase_changed(&self, _phase: &str) {} + fn on_agent_state_changed(&self, _work_unit_id: &str, _status: &AgentStatus, _detail: &str) {} + fn on_tier_started(&self, _current: usize, _total: usize) {} + fn on_merge_conflict(&self, _branch: &str, _files: &[String]) {} + fn on_completed(&self, _result: &SwarmResult) {} +} + +struct NoopAcpObserver; +impl AcpObserver for NoopAcpObserver { + fn on_stream_chunk(&self, _text: &str) {} + fn on_tool_call_started(&self, _tool_name: &str) {} + fn on_streaming_status(&self, _status: &str) {} + fn on_message_complete(&self, _role: &str, _content: &str) {} + fn on_proposal_deferred(&self, _path: &Path, _old: Option<&str>, _new: &str) {} +} + +fn make_obs(_id: &str) -> Box { + Box::new(NoopAcpObserver) +} + +fn config_for(workspace: &Path, ollama_url: &str, max_parallel: usize) -> SwarmConfig { + SwarmConfig { + execution_mode: ExecutionMode::Document, + max_parallel, + workspace_root: workspace.to_path_buf(), + model: "ollama:qwen".to_string(), + ollama_base_url: Some(ollama_url.to_string()), + use_worktrees: false, + read_namespaces: vec!["default".to_string()], + write_namespace: "default".to_string(), + context_files: vec![], + worktree_context_paths: vec![], + excludes: vec![], + memory_writer: None, + mcp_config: None, + specificity: SpecificityConfig::default(), + swarm_extra_tools: vec![], + tool_policy: None, + exposed_tools: None, + extract_agent_findings: false, + resume_from_artifacts: false, + knowledge_invalidation: None, + run_timeout_secs: 120, + chat_injection: Default::default(), + skills_emit: Default::default(), + skill_catalog: None, + memory_root: None, + graph_db_path: None, + } +} + +fn ndjson(content: &str) -> String { + let chunk = serde_json::json!({ + "model": "qwen", + "message": { "role": "assistant", "content": content }, + "done": false + }); + let done = serde_json::json!({ + "model": "qwen", + "done": true, + "total_duration": 1_000_000, + "eval_count": 2, + "prompt_eval_count": 5 + }); + format!("{chunk}\n{done}") +} + +/// Answer every prompt containing `marker` by writing `file`. +async fn answer(server: &MockServer, marker: &str, file: &str) { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker)) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson(&format!("\ndone\n"))) + .insert_header("content-type", "application/x-ndjson"), + ) + .mount(server) + .await; +} + +/// Answer every prompt containing `marker` with prose only (no file). +async fn answer_prose(server: &MockServer, marker: &str) { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker)) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson("I looked into it.")) + .insert_header("content-type", "application/x-ndjson"), + ) + .mount(server) + .await; +} + +async fn prompts_seen(server: &MockServer) -> Vec { + server + .received_requests() + .await + .unwrap_or_default() + .iter() + .map(|req| String::from_utf8_lossy(&req.body).into_owned()) + .collect() +} + +fn count_containing(prompts: &[String], needle: &str) -> usize { + prompts.iter().filter(|p| p.contains(needle)).count() +} + +fn last_index(prompts: &[String], needle: &str) -> Option { + prompts.iter().rposition(|p| p.contains(needle)) +} + +fn first_index(prompts: &[String], needle: &str) -> Option { + prompts.iter().position(|p| p.contains(needle)) +} + + +/// Counts `on_cost_update` calls. +#[derive(Default)] +struct CostObserver { + updates: Arc>>, +} + +impl SwarmObserver for CostObserver { + fn on_phase_changed(&self, _phase: &str) {} + fn on_agent_state_changed(&self, _work_unit_id: &str, _status: &AgentStatus, _detail: &str) {} + fn on_tier_started(&self, _current: usize, _total: usize) {} + fn on_merge_conflict(&self, _branch: &str, _files: &[String]) {} + fn on_completed(&self, _result: &SwarmResult) {} + fn on_cost_update(&self, estimate: &CostEstimate) { + self.updates.lock().unwrap().push(estimate.estimated_usd); + } +} + +fn chain_plan() -> CompiledPlan { + let mut plan = CompiledPlan::from_work_units( + vec![ + unit("a", &["out/a.md"], &["out/a.md"], "MARK-A1", &[]), + unit("b", &["out/b.md"], &["out/b.md"], "MARK-B1", &["a"]), + unit("c", &["out/c.md"], &["out/c.md"], "MARK-C1", &["b"]), + ], + Some(1), + ); + plan.execution_mode = ExecutionMode::Document; + plan +} + +async fn mount_delayed(server: &MockServer, marker: &str, file: &str, delay_ms: u64) { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker)) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson(&format!(" +done +"))) + .insert_header("content-type", "application/x-ndjson") + .set_delay(std::time::Duration::from_millis(delay_ms)), + ) + .mount(server) + .await; +} + +#[tokio::test] +async fn wall_budget_stops_before_later_tiers() { + let tmp = tempfile::tempdir().unwrap(); + std::fs::create_dir_all(tmp.path().join("out")).unwrap(); + let server = MockServer::start().await; + for (m, f) in [("MARK-A1", "out/a.md"), ("MARK-B1", "out/b.md"), ("MARK-C1", "out/c.md")] { + mount_delayed(&server, m, f, 1500).await; + } + let mut plan = chain_plan(); + plan.budget = Some(RunBudget { + wall_secs: Some(1), + usd: None, + }); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 1), + None, + None, + &QuietObserver, + make_obs, + ) + .await; + assert!( + result.is_ok(), + "a spent budget stops the run without an error: {:?}", + result.err().map(|e| format!("{e:#}")) + ); + let prompts = prompts_seen(&server).await; + assert_eq!(count_containing(&prompts, "MARK-A1"), 1, "a ran"); + assert_eq!(count_containing(&prompts, "MARK-B1"), 0, "b must not start"); + assert_eq!(count_containing(&prompts, "MARK-C1"), 0, "c must not start"); +} + +#[tokio::test] +async fn cost_updates_are_reported() { + let tmp = tempfile::tempdir().unwrap(); + std::fs::create_dir_all(tmp.path().join("out")).unwrap(); + let server = MockServer::start().await; + for (m, f) in [("MARK-A1", "out/a.md"), ("MARK-B1", "out/b.md"), ("MARK-C1", "out/c.md")] { + mount_delayed(&server, m, f, 0).await; + } + let observer = CostObserver::default(); + let updates = observer.updates.clone(); + + let result = execute( + &chain_plan(), + &config_for(tmp.path(), &server.uri(), 1), + None, + None, + &observer, + make_obs, + ) + .await + .expect("run succeeds"); + + let completed = result + .manifests + .iter() + .filter(|m| m.status == AgentStatus::Completed) + .count(); + assert_eq!(completed, 3); + assert!( + updates.lock().unwrap().len() >= completed, + "one cost update per recorded manifest at least, got {:?}", + updates.lock().unwrap() + ); +} diff --git a/crates/gaviero-core/tests/swarm_parallel_dispatch.rs b/crates/gaviero-core/tests/swarm_parallel_dispatch.rs new file mode 100644 index 00000000..dbd4e24b --- /dev/null +++ b/crates/gaviero-core/tests/swarm_parallel_dispatch.rs @@ -0,0 +1,367 @@ +//! Parallel dispatch through the real `swarm::pipeline::execute` path. +//! +//! Every other pipeline-level test runs with `max_parallel: 1`, which takes +//! the sequential tier branch. These drive the parallel branch and the +//! parallel loop passes against a mock Ollama server, and check what the +//! scheduler promises: a unit that depends on a parallel tier runs, a loop +//! whose first pass ran in parallel iterates, and `depends_on` between two +//! agents of the same loop orders them inside every pass. + +use std::collections::HashMap; +use std::path::Path; + +use gaviero_core::observer::{AcpObserver, SwarmObserver}; +use gaviero_core::repo_map::SpecificityConfig; +use gaviero_core::swarm::execution_state::{ExecutionState, NodeStatus}; +use gaviero_core::swarm::models::{AgentStatus, WorkUnit}; +use gaviero_core::swarm::pipeline::{SwarmConfig, execute}; +use gaviero_core::swarm::plan::{CompiledPlan, ExecutionMode, LoopConfig, LoopUntilCondition}; +use gaviero_core::types::{FileScope, ModelTier, PrivacyLevel}; +use wiremock::matchers::{body_string_contains, method, path}; +use wiremock::{Mock, MockServer, ResponseTemplate}; + +#[allow(deprecated)] +fn unit(id: &str, owned: &[&str], instructions: &str, depends_on: &[&str]) -> WorkUnit { + WorkUnit { + id: id.to_string(), + description: format!("test unit {id}"), + scope: FileScope { + owned_paths: owned.iter().map(|s| s.to_string()).collect(), + read_only_paths: vec![], + interface_contracts: HashMap::new(), + }, + produces_json: vec![], + produces: vec![], + depends_on: depends_on.iter().map(|s| s.to_string()).collect(), + backend: Default::default(), + model: Some("ollama:qwen".to_string()), + effort: None, + extra: vec![], + tier: ModelTier::Cheap, + privacy: PrivacyLevel::Public, + coordinator_instructions: instructions.to_string(), + estimated_tokens: 0, + max_retries: 1, + timeout_secs: 3600, + escalation_tier: None, + read_namespaces: None, + write_namespace: None, + memory_importance: None, + staleness_sources: vec![], + memory_read_query: None, + memory_read_limit: None, + memory_write_content: None, + impact_scope: false, + context_callers_of: vec![], + context_tests_for: vec![], + context_depth: 2, + extra_allowed_tools: vec![], + } +} + +/// A command-gated loop over `agent_ids` that never converges, so it runs +/// exactly `max_iterations` passes. +fn command_loop(agent_ids: &[&str], max_iterations: u32) -> LoopConfig { + LoopConfig { + agent_ids: agent_ids.iter().map(|s| s.to_string()).collect(), + until: LoopUntilCondition::Command("exit 1".to_string()), + max_iterations, + iter_start: 1, + strict_judge: true, + stability: 1, + judge_timeout_secs: 120, + branch_chain: Default::default(), + consensus_mode: Default::default(), + verdict_output_dir: None, + irreconcilable_after: 2, + baseline_units: Vec::new(), + } +} + +struct QuietObserver; + +impl SwarmObserver for QuietObserver { + fn on_phase_changed(&self, _phase: &str) {} + fn on_agent_state_changed(&self, _work_unit_id: &str, _status: &AgentStatus, _detail: &str) {} + fn on_tier_started(&self, _current: usize, _total: usize) {} + fn on_merge_conflict(&self, _branch: &str, _files: &[String]) {} + fn on_completed(&self, _result: &gaviero_core::swarm::models::SwarmResult) {} +} + +struct NoopAcpObserver; +impl AcpObserver for NoopAcpObserver { + fn on_stream_chunk(&self, _text: &str) {} + fn on_tool_call_started(&self, _tool_name: &str) {} + fn on_streaming_status(&self, _status: &str) {} + fn on_message_complete(&self, _role: &str, _content: &str) {} + fn on_proposal_deferred(&self, _path: &Path, _old: Option<&str>, _new: &str) {} +} + +fn config_for(workspace: &Path, ollama_url: &str, max_parallel: usize) -> SwarmConfig { + SwarmConfig { + execution_mode: ExecutionMode::Document, + max_parallel, + workspace_root: workspace.to_path_buf(), + model: "ollama:qwen".to_string(), + ollama_base_url: Some(ollama_url.to_string()), + use_worktrees: false, + read_namespaces: vec!["default".to_string()], + write_namespace: "default".to_string(), + context_files: vec![], + worktree_context_paths: vec![], + excludes: vec![], + memory_writer: None, + mcp_config: None, + specificity: SpecificityConfig::default(), + swarm_extra_tools: vec![], + tool_policy: None, + exposed_tools: None, + extract_agent_findings: false, + resume_from_artifacts: false, + knowledge_invalidation: None, + // A scheduling bug that loops forever must fail the test, not hang it. + run_timeout_secs: 120, + chat_injection: Default::default(), + skills_emit: Default::default(), + skill_catalog: None, + memory_root: None, + graph_db_path: None, + } +} + +/// A mock Ollama turn that writes `content` to `file`. +fn ndjson_turn(file: &str, content: &str) -> String { + let body = format!("\n{content}\n"); + let chunk = serde_json::json!({ + "model": "qwen", + "message": { "role": "assistant", "content": body }, + "done": false + }); + let done = serde_json::json!({ + "model": "qwen", + "done": true, + "total_duration": 1_000_000, + "eval_count": 2, + "prompt_eval_count": 5 + }); + format!("{chunk}\n{done}") +} + +/// Answer every prompt containing `marker` by writing `file`. +async fn answer(server: &MockServer, marker: &str, file: &str) { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker)) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson_turn(file, "done")) + .insert_header("content-type", "application/x-ndjson"), + ) + .mount(server) + .await; +} + +/// Every prompt the mock server was asked to complete, in arrival order. +async fn prompts_seen(server: &MockServer) -> Vec { + server + .received_requests() + .await + .unwrap_or_default() + .iter() + .map(|req| String::from_utf8_lossy(&req.body).into_owned()) + .collect() +} + +fn count_containing(prompts: &[String], needle: &str) -> usize { + prompts.iter().filter(|p| p.contains(needle)).count() +} + +fn first_index(prompts: &[String], needle: &str) -> Option { + prompts.iter().position(|p| p.contains(needle)) +} + +fn make_obs(_id: &str) -> Box { + Box::new(NoopAcpObserver) +} + +/// Units `a` and `b` share a tier (run in parallel); `c` depends on both. +fn fan_in_plan() -> CompiledPlan { + let mut plan = CompiledPlan::from_work_units( + vec![ + unit("a", &["out/a.md"], "Write the report. MARK-AAA", &[]), + unit("b", &["out/b.md"], "Write the report. MARK-BBB", &[]), + unit("c", &["out/c.md"], "Summarise. MARK-CCC", &["a", "b"]), + ], + Some(2), + ); + plan.execution_mode = ExecutionMode::Document; + plan +} + +async fn fan_in_server() -> MockServer { + let server = MockServer::start().await; + answer(&server, "MARK-AAA", "out/a.md").await; + answer(&server, "MARK-BBB", "out/b.md").await; + answer(&server, "MARK-CCC", "out/c.md").await; + server +} + +#[tokio::test] +async fn a_dependent_of_a_parallel_tier_runs() { + let tmp = tempfile::tempdir().expect("tempdir"); + let workspace = tmp.path(); + std::fs::create_dir_all(workspace.join("out")).unwrap(); + let server = fan_in_server().await; + let plan = fan_in_plan(); + + let result = execute( + &plan, + &config_for(workspace, &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("run succeeds"); + + let c = result + .manifests + .iter() + .find(|m| m.work_unit_id == "c") + .expect("c has a manifest"); + assert_eq!( + c.status, + AgentStatus::Completed, + "c depends on a parallel tier and must run, got {:?}", + c.status + ); + let prompts = prompts_seen(&server).await; + assert_eq!(count_containing(&prompts, "MARK-CCC"), 1, "c was dispatched once"); +} + +#[tokio::test] +async fn parallel_tier_checkpoint_records_each_unit() { + let tmp = tempfile::tempdir().expect("tempdir"); + let workspace = tmp.path(); + std::fs::create_dir_all(workspace.join("out")).unwrap(); + let server = fan_in_server().await; + let plan = fan_in_plan(); + + execute( + &plan, + &config_for(workspace, &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("run succeeds"); + + let state = ExecutionState::load(workspace, &plan.hash()) + .expect("checkpoint readable") + .expect("checkpoint written"); + assert_eq!(state.status("a"), NodeStatus::Completed); + assert_eq!(state.status("b"), NodeStatus::Completed); +} + +#[tokio::test] +async fn a_loop_agent_that_depends_on_a_sibling_runs_after_it_every_pass() { + let tmp = tempfile::tempdir().expect("tempdir"); + let workspace = tmp.path(); + std::fs::create_dir_all(workspace.join("out")).unwrap(); + let server = MockServer::start().await; + answer(&server, "MARK-INV", "out/inv.md").await; + answer(&server, "MARK-CUR", "out/cur.md").await; + + // `cur` is listed first on purpose: the order must come from depends_on. + let mut plan = CompiledPlan::from_work_units( + vec![ + unit("inv", &["out/inv.md"], "MARK-INV iteration {{ITER}}", &[]), + unit("cur", &["out/cur.md"], "MARK-CUR iteration {{ITER}}", &["inv"]), + ], + Some(2), + ); + plan.execution_mode = ExecutionMode::Document; + plan.loop_configs = vec![command_loop(&["cur", "inv"], 2)]; + + let result = execute( + &plan, + &config_for(workspace, &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await; + assert!( + result.is_ok(), + "a non-converging loop is not a run error: {:?}", + result.err().map(|e| format!("{e:#}")) + ); + + let prompts = prompts_seen(&server).await; + for iter in [1, 2] { + let inv = first_index(&prompts, &format!("MARK-INV iteration {iter}")) + .unwrap_or_else(|| panic!("inv did not run on pass {iter}")); + let cur = first_index(&prompts, &format!("MARK-CUR iteration {iter}")) + .unwrap_or_else(|| panic!("cur did not run on pass {iter}")); + assert!( + cur > inv, + "pass {iter}: cur (request {cur}) must run after inv (request {inv})" + ); + } + assert_eq!( + count_containing(&prompts, "MARK-CUR"), + 2, + "cur runs once per pass and never again after the loop" + ); +} + +#[tokio::test] +async fn a_loop_whose_first_pass_ran_in_parallel_iterates() { + let tmp = tempfile::tempdir().expect("tempdir"); + let workspace = tmp.path(); + std::fs::create_dir_all(workspace.join("out")).unwrap(); + let server = MockServer::start().await; + answer(&server, "MARK-XXX", "out/x.md").await; + answer(&server, "MARK-YYY", "out/y.md").await; + + let mut plan = CompiledPlan::from_work_units( + vec![ + unit("x", &["out/x.md"], "Iteration {{ITER}}. MARK-XXX", &[]), + unit("y", &["out/y.md"], "Iteration {{ITER}}. MARK-YYY", &[]), + ], + Some(2), + ); + plan.execution_mode = ExecutionMode::Document; + plan.loop_configs = vec![command_loop(&["x", "y"], 2)]; + + let result = execute( + &plan, + &config_for(workspace, &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await; + assert!( + result.is_ok(), + "a non-converging loop is not a run error: {:?}", + result.err().map(|e| format!("{e:#}")) + ); + + let prompts = prompts_seen(&server).await; + assert!( + count_containing(&prompts, "MARK-XXX") >= 2, + "x must run on pass 1 and pass 2, saw {}", + count_containing(&prompts, "MARK-XXX") + ); + assert!( + count_containing(&prompts, "MARK-YYY") >= 2, + "y must run on pass 1 and pass 2, saw {}", + count_containing(&prompts, "MARK-YYY") + ); +} From 810391380ad77670c6270e9097dcfde4c3a4957e Mon Sep 17 00:00:00 2001 From: Ignacio Martin Date: Mon, 16 Nov 2026 12:37:01 +0100 Subject: [PATCH 5/6] Add runtime for-loops, budgets, JSON outputs and cost totals to swarm The swarm runtime gains runtime for expansion, parallel dispatch, budget enforcement and produces-json validation, and retries now report the summed cost of every attempt. The coordinator prompt teaches tiers, produces and timeout, and the new WorkUnit field is carried through every constructor. --- .../tests/swarm_execution_state_checkpoint.rs | 1 + .../tests/swarm_loop_gate_feedback.rs | 1 + .../tests/swarm_pipeline_validation.rs | 1 + .../gaviero-core/tests/swarm_runtime_for.rs | 706 ++++++++++++++++++ 4 files changed, 709 insertions(+) create mode 100644 crates/gaviero-core/tests/swarm_runtime_for.rs diff --git a/crates/gaviero-core/tests/swarm_execution_state_checkpoint.rs b/crates/gaviero-core/tests/swarm_execution_state_checkpoint.rs index 07ebbd73..8a528e8e 100644 --- a/crates/gaviero-core/tests/swarm_execution_state_checkpoint.rs +++ b/crates/gaviero-core/tests/swarm_execution_state_checkpoint.rs @@ -25,6 +25,7 @@ fn unit(id: &str, owned: &[&str]) -> WorkUnit { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/tests/swarm_loop_gate_feedback.rs b/crates/gaviero-core/tests/swarm_loop_gate_feedback.rs index f46c6f81..2c08b95e 100644 --- a/crates/gaviero-core/tests/swarm_loop_gate_feedback.rs +++ b/crates/gaviero-core/tests/swarm_loop_gate_feedback.rs @@ -39,6 +39,7 @@ fn loop_unit(id: &str, owned: &[&str]) -> WorkUnit { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/tests/swarm_pipeline_validation.rs b/crates/gaviero-core/tests/swarm_pipeline_validation.rs index 5d61796d..12c114ad 100644 --- a/crates/gaviero-core/tests/swarm_pipeline_validation.rs +++ b/crates/gaviero-core/tests/swarm_pipeline_validation.rs @@ -28,6 +28,7 @@ fn unit(id: &str, owned: &[&str]) -> WorkUnit { read_only_paths: vec![], interface_contracts: HashMap::new(), }, + produces_json: vec![], produces: vec![], depends_on: vec![], backend: Default::default(), diff --git a/crates/gaviero-core/tests/swarm_runtime_for.rs b/crates/gaviero-core/tests/swarm_runtime_for.rs new file mode 100644 index 00000000..4554dbe3 --- /dev/null +++ b/crates/gaviero-core/tests/swarm_runtime_for.rs @@ -0,0 +1,706 @@ +//! Runtime-sized `for` and `pattern map_reduce`, through the real +//! `swarm::pipeline::execute` path against a mock Ollama server. +//! +//! Plans are built by hand: `gaviero-core` cannot depend on the DSL. A +//! template unit `worker` carries `{{q.*}}` placeholders, and a +//! `RuntimeForOp` tells the scheduler to clone it once per item of a JSON +//! list the test writes into the workspace. + +use std::collections::HashMap; +use std::path::Path; + +use gaviero_core::observer::{AcpObserver, SwarmObserver}; +use gaviero_core::repo_map::SpecificityConfig; +use gaviero_core::swarm::execution_state::{ExecutionState, NodeStatus}; +use gaviero_core::swarm::models::{AgentStatus, SwarmResult, WorkUnit}; +use gaviero_core::swarm::pipeline::{SwarmConfig, execute}; +use gaviero_core::swarm::plan::{ + CompiledPlan, ExecutionMode, FanoutOp, LoopConfig, LoopUntilCondition, RuntimeForOp, +}; +use gaviero_core::types::{FileScope, ModelTier, PrivacyLevel}; +use wiremock::matchers::{body_string_contains, method, path}; +use wiremock::{Mock, MockServer, ResponseTemplate}; + +#[allow(deprecated)] +fn unit( + id: &str, + owned: &[&str], + produces: &[&str], + instructions: &str, + depends_on: &[&str], +) -> WorkUnit { + WorkUnit { + id: id.to_string(), + description: format!("test unit {id}"), + scope: FileScope { + owned_paths: owned.iter().map(|s| s.to_string()).collect(), + read_only_paths: vec![], + interface_contracts: HashMap::new(), + }, + produces_json: vec![], + produces: produces.iter().map(|s| s.to_string()).collect(), + depends_on: depends_on.iter().map(|s| s.to_string()).collect(), + backend: Default::default(), + model: Some("ollama:qwen".to_string()), + effort: None, + extra: vec![], + tier: ModelTier::Cheap, + privacy: PrivacyLevel::Public, + coordinator_instructions: instructions.to_string(), + estimated_tokens: 0, + max_retries: 1, + timeout_secs: 3600, + escalation_tier: None, + read_namespaces: None, + write_namespace: None, + memory_importance: None, + staleness_sources: vec![], + memory_read_query: None, + memory_read_limit: None, + memory_write_content: None, + impact_scope: false, + context_callers_of: vec![], + context_tests_for: vec![], + context_depth: 2, + extra_allowed_tools: vec![], + } +} + +/// The template every test clones: one finding per item. +fn worker() -> WorkUnit { + unit( + "worker", + &["out/{{q.id}}.md"], + &["out/{{q.id}}.md"], + "MARK-{{q.id}}: investigate focus={{q.focus}}", + &[], + ) +} + +fn op(source: &str, max_items: u32) -> RuntimeForOp { + RuntimeForOp { + unit_id: "worker".into(), + var: "q".into(), + source: source.into(), + max_items, + } +} + +fn command_loop(agent_ids: &[&str], max_iterations: u32) -> LoopConfig { + LoopConfig { + agent_ids: agent_ids.iter().map(|s| s.to_string()).collect(), + until: LoopUntilCondition::Command("exit 1".to_string()), + max_iterations, + iter_start: 1, + strict_judge: true, + stability: 1, + judge_timeout_secs: 120, + branch_chain: Default::default(), + consensus_mode: Default::default(), + verdict_output_dir: None, + irreconcilable_after: 2, + baseline_units: Vec::new(), + } +} + +struct QuietObserver; + +impl SwarmObserver for QuietObserver { + fn on_phase_changed(&self, _phase: &str) {} + fn on_agent_state_changed(&self, _work_unit_id: &str, _status: &AgentStatus, _detail: &str) {} + fn on_tier_started(&self, _current: usize, _total: usize) {} + fn on_merge_conflict(&self, _branch: &str, _files: &[String]) {} + fn on_completed(&self, _result: &SwarmResult) {} +} + +struct NoopAcpObserver; +impl AcpObserver for NoopAcpObserver { + fn on_stream_chunk(&self, _text: &str) {} + fn on_tool_call_started(&self, _tool_name: &str) {} + fn on_streaming_status(&self, _status: &str) {} + fn on_message_complete(&self, _role: &str, _content: &str) {} + fn on_proposal_deferred(&self, _path: &Path, _old: Option<&str>, _new: &str) {} +} + +fn make_obs(_id: &str) -> Box { + Box::new(NoopAcpObserver) +} + +fn config_for(workspace: &Path, ollama_url: &str, max_parallel: usize) -> SwarmConfig { + SwarmConfig { + execution_mode: ExecutionMode::Document, + max_parallel, + workspace_root: workspace.to_path_buf(), + model: "ollama:qwen".to_string(), + ollama_base_url: Some(ollama_url.to_string()), + use_worktrees: false, + read_namespaces: vec!["default".to_string()], + write_namespace: "default".to_string(), + context_files: vec![], + worktree_context_paths: vec![], + excludes: vec![], + memory_writer: None, + mcp_config: None, + specificity: SpecificityConfig::default(), + swarm_extra_tools: vec![], + tool_policy: None, + exposed_tools: None, + extract_agent_findings: false, + resume_from_artifacts: false, + knowledge_invalidation: None, + run_timeout_secs: 120, + chat_injection: Default::default(), + skills_emit: Default::default(), + skill_catalog: None, + memory_root: None, + graph_db_path: None, + } +} + +fn ndjson(content: &str) -> String { + let chunk = serde_json::json!({ + "model": "qwen", + "message": { "role": "assistant", "content": content }, + "done": false + }); + let done = serde_json::json!({ + "model": "qwen", + "done": true, + "total_duration": 1_000_000, + "eval_count": 2, + "prompt_eval_count": 5 + }); + format!("{chunk}\n{done}") +} + +/// Answer every prompt containing `marker` by writing `file`. +async fn answer(server: &MockServer, marker: &str, file: &str) { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker)) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson(&format!("\ndone\n"))) + .insert_header("content-type", "application/x-ndjson"), + ) + .mount(server) + .await; +} + +/// Answer every prompt containing `marker` with prose only (no file). +async fn answer_prose(server: &MockServer, marker: &str) { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker)) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson("I looked into it.")) + .insert_header("content-type", "application/x-ndjson"), + ) + .mount(server) + .await; +} + +async fn prompts_seen(server: &MockServer) -> Vec { + server + .received_requests() + .await + .unwrap_or_default() + .iter() + .map(|req| String::from_utf8_lossy(&req.body).into_owned()) + .collect() +} + +fn count_containing(prompts: &[String], needle: &str) -> usize { + prompts.iter().filter(|p| p.contains(needle)).count() +} + +fn last_index(prompts: &[String], needle: &str) -> Option { + prompts.iter().rposition(|p| p.contains(needle)) +} + +fn first_index(prompts: &[String], needle: &str) -> Option { + prompts.iter().position(|p| p.contains(needle)) +} + +fn workspace_with(files: &[(&str, &str)]) -> tempfile::TempDir { + let tmp = tempfile::tempdir().expect("tempdir"); + std::fs::create_dir_all(tmp.path().join("out")).unwrap(); + for (rel, content) in files { + std::fs::write(tmp.path().join(rel), content).unwrap(); + } + tmp +} + +/// `worker` over `out/items.json`, an unrelated `side` unit in the same tier +/// (so the parallel tier branch runs), and `summary` depending on `worker`. +fn top_level_plan(max_items: u32) -> CompiledPlan { + let mut plan = CompiledPlan::from_work_units( + vec![ + worker(), + unit("side", &["out/side.md"], &[], "MARK-SIDE", &[]), + unit("summary", &["out/summary.md"], &[], "MARK-SUM", &["worker"]), + ], + Some(2), + ); + plan.execution_mode = ExecutionMode::Document; + plan.runtime_fors = vec![op("out/items.json", max_items)]; + plan +} + +async fn standard_server() -> MockServer { + let server = MockServer::start().await; + for id in ["a", "b", "c"] { + answer(&server, &format!("MARK-{id}:"), &format!("out/{id}.md")).await; + } + answer(&server, "MARK-SIDE", "out/side.md").await; + answer(&server, "MARK-SUM", "out/summary.md").await; + server +} + +const THREE_ITEMS: &str = + r#"[{"id":"a","focus":"x"},{"id":"b","focus":"y"},{"id":"c","focus":"z"}]"#; + +fn manifest_status(result: &SwarmResult, id: &str) -> AgentStatus { + result + .manifests + .iter() + .rev() + .find(|m| m.work_unit_id == id) + .unwrap_or_else(|| panic!("no manifest for {id}")) + .status + .clone() +} + +#[tokio::test] +async fn top_level_runtime_for_runs_every_item_then_the_dependent() { + let tmp = workspace_with(&[("out/items.json", THREE_ITEMS)]); + let server = standard_server().await; + let plan = top_level_plan(16); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("run succeeds"); + + let prompts = prompts_seen(&server).await; + assert_eq!(count_containing(&prompts, "MARK-a: investigate focus=x"), 1); + assert_eq!(count_containing(&prompts, "MARK-b:"), 1); + assert_eq!(count_containing(&prompts, "MARK-c:"), 1); + assert_eq!(manifest_status(&result, "summary"), AgentStatus::Completed); + let sum = first_index(&prompts, "MARK-SUM").expect("summary ran"); + for id in ["a", "b", "c"] { + assert!( + last_index(&prompts, &format!("MARK-{id}:")).unwrap() < sum, + "summary must run after every item" + ); + } + + let state = ExecutionState::load(tmp.path(), &plan.hash()) + .unwrap() + .expect("checkpoint written"); + for id in ["worker@a", "worker@b", "worker@c", "worker"] { + assert_eq!(state.status(id), NodeStatus::Completed, "{id}"); + } +} + +#[tokio::test] +async fn resume_skips_completed_items() { + let tmp = workspace_with(&[("out/items.json", THREE_ITEMS)]); + let server = standard_server().await; + let plan = top_level_plan(16); + let mut state = ExecutionState::new_from_plan(&plan); + state.set_status("worker@a", NodeStatus::Completed); + state.save(tmp.path(), &plan.hash()).unwrap(); + + execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + Some(state), + None, + &QuietObserver, + make_obs, + ) + .await + .expect("run succeeds"); + + let prompts = prompts_seen(&server).await; + assert_eq!(count_containing(&prompts, "MARK-a:"), 0, "a was already done"); + assert_eq!(count_containing(&prompts, "MARK-b:"), 1); + assert_eq!(count_containing(&prompts, "MARK-c:"), 1); + assert_eq!(count_containing(&prompts, "MARK-SUM"), 1); +} + +#[tokio::test] +async fn over_cap_aborts_the_run() { + let tmp = workspace_with(&[("out/items.json", THREE_ITEMS)]); + let server = standard_server().await; + let plan = top_level_plan(2); + + let err = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect_err("three items over `max 2` must abort the run"); + assert!(format!("{err:#}").contains("max 2"), "{err:#}"); + assert_eq!(count_containing(&prompts_seen(&server).await, "MARK-a:"), 0); +} + +#[tokio::test] +async fn empty_list_runs_the_dependent() { + let tmp = workspace_with(&[("out/items.json", "[]")]); + let server = standard_server().await; + let plan = top_level_plan(16); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("run succeeds"); + + let prompts = prompts_seen(&server).await; + assert_eq!(count_containing(&prompts, "investigate"), 0); + assert_eq!(manifest_status(&result, "worker"), AgentStatus::Completed); + assert_eq!(manifest_status(&result, "summary"), AgentStatus::Completed); +} + +#[tokio::test] +async fn a_failed_item_skips_the_dependent() { + let tmp = workspace_with(&[("out/items.json", THREE_ITEMS)]); + let server = MockServer::start().await; + answer(&server, "MARK-a:", "out/a.md").await; + answer_prose(&server, "MARK-b:").await; + answer(&server, "MARK-c:", "out/c.md").await; + answer(&server, "MARK-SIDE", "out/side.md").await; + answer(&server, "MARK-SUM", "out/summary.md").await; + let plan = top_level_plan(16); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("a failed item is not a run error"); + + assert!(matches!(manifest_status(&result, "worker@b"), AgentStatus::Failed(_))); + match manifest_status(&result, "worker") { + AgentStatus::Failed(msg) => assert!(msg.contains("worker@b"), "{msg}"), + other => panic!("the barrier must fail, got {other:?}"), + } + let summary = result + .manifests + .iter() + .find(|m| m.work_unit_id == "summary") + .expect("summary has a skip record"); + assert_eq!(summary.summary.as_deref(), Some("dependency did not complete")); + assert_eq!(count_containing(&prompts_seen(&server).await, "MARK-SUM"), 0); +} + +#[tokio::test] +async fn unknown_item_placeholder_aborts_before_dispatch() { + let tmp = workspace_with(&[("out/items.json", THREE_ITEMS)]); + let server = standard_server().await; + let mut plan = top_level_plan(16); + // Swap the template for one that asks for a field no item has. + let mut bad = worker(); + bad.coordinator_instructions = "MARK-{{q.id}}: {{q.nope}}".into(); + plan = { + let mut units: Vec = plan.work_units_unordered().into_iter().cloned().collect(); + units.retain(|u| u.id != "worker"); + units.push(bad); + let mut p = CompiledPlan::from_work_units(units, Some(2)); + p.execution_mode = ExecutionMode::Document; + p.runtime_fors = std::mem::take(&mut plan.runtime_fors); + p + }; + + let err = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect_err("an unknown item placeholder aborts the run"); + assert!(format!("{err:#}").contains("{{q.nope}}"), "{err:#}"); + assert_eq!(count_containing(&prompts_seen(&server).await, "MARK-a:"), 0); +} + +/// A loop over a runtime `for` whose list is versioned per pass. +fn loop_plan(with_curator: bool) -> CompiledPlan { + let template = unit( + "worker", + &["out/{{q.id}}-v*.md"], + &["out/{{q.id}}-v{{ITER}}.md"], + "MARK-{{q.id}}: investigate focus={{q.focus}} pass {{ITER}}", + &[], + ); + let mut units = vec![template]; + let mut members = vec!["worker"]; + if with_curator { + units.push(unit( + "cur", + &["out/cur-v*.md"], + &[], + "MARK-CUR iteration {{ITER}}", + &["worker"], + )); + members.push("cur"); + } + let mut plan = CompiledPlan::from_work_units(units, Some(2)); + plan.execution_mode = ExecutionMode::Document; + plan.runtime_fors = vec![op("out/items-v{{ITER}}.json", 16)]; + plan.loop_configs = vec![command_loop(&members, 2)]; + plan +} + +async fn loop_server() -> MockServer { + let server = MockServer::start().await; + answer(&server, "MARK-a:", "out/a-v1.md").await; + answer(&server, "MARK-b:", "out/b-v1.md").await; + answer(&server, "MARK-c:", "out/c-v2.md").await; + answer(&server, "MARK-CUR", "out/cur-v1.md").await; + server +} + +const PASS_ONE: &str = r#"[{"id":"a","focus":"x"},{"id":"b","focus":"y"}]"#; +const PASS_TWO: &str = r#"[{"id":"c","focus":"z"}]"#; + +#[tokio::test] +async fn runtime_for_inside_a_loop_rereads_its_list_each_pass() { + let tmp = workspace_with(&[("out/items-v1.json", PASS_ONE), ("out/items-v2.json", PASS_TWO)]); + let server = loop_server().await; + let plan = loop_plan(false); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await; + assert!( + result.is_ok(), + "a non-converging loop is not a run error: {:?}", + result.err().map(|e| format!("{e:#}")) + ); + + let prompts = prompts_seen(&server).await; + assert_eq!(count_containing(&prompts, "MARK-a: investigate focus=x pass 1"), 1); + assert_eq!(count_containing(&prompts, "MARK-b: investigate focus=y pass 1"), 1); + assert_eq!(count_containing(&prompts, "MARK-c: investigate focus=z pass 2"), 1); + assert_eq!(count_containing(&prompts, "investigate"), 3, "one prompt per item per pass"); +} + +#[tokio::test] +async fn a_curator_after_runtime_for_runs_each_pass() { + let tmp = workspace_with(&[("out/items-v1.json", PASS_ONE), ("out/items-v2.json", PASS_TWO)]); + let server = loop_server().await; + let plan = loop_plan(true); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await; + assert!( + result.is_ok(), + "a non-converging loop is not a run error: {:?}", + result.err().map(|e| format!("{e:#}")) + ); + + let prompts = prompts_seen(&server).await; + let cur1 = first_index(&prompts, "MARK-CUR iteration 1").expect("curator ran on pass 1"); + let cur2 = first_index(&prompts, "MARK-CUR iteration 2").expect("curator ran on pass 2"); + for marker in ["MARK-a:", "MARK-b:"] { + assert!(last_index(&prompts, marker).unwrap() < cur1, "{marker} before curator pass 1"); + } + assert!(last_index(&prompts, "MARK-c:").unwrap() < cur2, "MARK-c before curator pass 2"); + assert!(first_index(&prompts, "MARK-c:").unwrap() > cur1, "pass 2 starts after pass 1"); + assert_eq!(count_containing(&prompts, "MARK-CUR"), 2); +} + +// ── pattern map_reduce on the shared dispatcher ───────────────────────── + +fn spawn_manifest(workers: &[&str]) -> String { + let workers: Vec = workers + .iter() + .map(|w| { + serde_json::json!({ + "id": w, + "tier": "local", + "prompt": format!("MARK-W-{w}: work"), + "owned": [format!("out/{w}.md")], + }) + }) + .collect(); + serde_json::json!({ "version": 1, "workers": workers }).to_string() +} + +/// `d` discovers (writes the manifest), `side` shares its tier so the +/// parallel tier branch runs, and `r` reduces after `d`. +fn map_reduce_plan(max_spawn: u32) -> CompiledPlan { + let mut plan = CompiledPlan::from_work_units( + vec![ + // `produces` makes the runner apply the mock's `` block. + unit("d", &["spawn_manifest.json"], &["spawn_manifest.json"], "MARK-DISCOVER", &[]), + unit("side", &["out/side.md"], &["out/side.md"], "MARK-SIDE", &[]), + unit("r", &["out/reduce.md"], &[], "MARK-REDUCE", &["d"]), + ], + Some(2), + ); + plan.execution_mode = ExecutionMode::Document; + plan.fanout_ops = vec![FanoutOp { + after_unit: "d".into(), + max_spawn, + default_model: None, + barrier_id: None, + }]; + // The profile tier the manifest's workers name. + plan.tier_bindings.insert( + "local".into(), + gaviero_core::swarm::plan::TierBinding { + model: Some("ollama:qwen".into()), + effort: None, + extra: vec![], + privacy: Default::default(), + tier: Default::default(), + }, + ); + plan +} + +async fn map_reduce_server(workers: &[&str], failing: Option<&str>) -> MockServer { + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains("MARK-DISCOVER")) + .respond_with( + ResponseTemplate::new(200) + .set_body_string(ndjson(&format!( + "\n{}\n", + spawn_manifest(workers) + ))) + .insert_header("content-type", "application/x-ndjson"), + ) + .mount(&server) + .await; + for w in workers { + let marker = format!("MARK-W-{w}:"); + if Some(*w) == failing { + Mock::given(method("POST")) + .and(path("/api/chat")) + .and(body_string_contains(marker.as_str())) + .respond_with(ResponseTemplate::new(500).set_body_string("boom")) + .mount(&server) + .await; + } else { + answer(&server, &marker, &format!("out/{w}.md")).await; + } + } + answer(&server, "MARK-SIDE", "out/side.md").await; + answer(&server, "MARK-REDUCE", "out/reduce.md").await; + server +} + +#[tokio::test] +async fn map_reduce_workers_run_in_parallel_tiers_and_reduce_waits() { + let tmp = workspace_with(&[]); + let server = map_reduce_server(&["w1", "w2"], None).await; + let plan = map_reduce_plan(8); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("run succeeds"); + + let prompts = prompts_seen(&server).await; + let reduce = first_index(&prompts, "MARK-REDUCE").expect("reduce ran"); + for w in ["w1", "w2"] { + let at = first_index(&prompts, &format!("MARK-W-{w}:")) + .unwrap_or_else(|| panic!("worker {w} never ran")); + assert!(at < reduce, "worker {w} must run before reduce"); + } + assert_eq!(manifest_status(&result, "r"), AgentStatus::Completed); +} + +#[tokio::test] +async fn map_reduce_over_cap_aborts() { + let tmp = workspace_with(&[]); + let server = map_reduce_server(&["w1", "w2", "w3"], None).await; + let plan = map_reduce_plan(2); + + let err = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect_err("three workers over max_spawn 2 must abort"); + assert!(format!("{err:#}").contains("max_spawn"), "{err:#}"); + assert_eq!(count_containing(&prompts_seen(&server).await, "MARK-REDUCE"), 0); +} + +#[tokio::test] +async fn map_reduce_failed_worker_skips_reduce() { + let tmp = workspace_with(&[]); + let server = map_reduce_server(&["w1", "w2"], Some("w2")).await; + let plan = map_reduce_plan(8); + + let result = execute( + &plan, + &config_for(tmp.path(), &server.uri(), 2), + None, + None, + &QuietObserver, + make_obs, + ) + .await + .expect("a failed worker is not a run error"); + + assert!(matches!(manifest_status(&result, "w2"), AgentStatus::Failed(_))); + let reduce = result + .manifests + .iter() + .find(|m| m.work_unit_id == "r") + .expect("reduce has a skip record"); + assert_eq!(reduce.summary.as_deref(), Some("dependency did not complete")); + assert_eq!(count_containing(&prompts_seen(&server).await, "MARK-REDUCE"), 0); +} From bdc82de01e91de866f786bdb476dc655b7fddae6 Mon Sep 17 00:00:00 2001 From: Ignacio Martin Date: Mon, 16 Nov 2026 12:37:02 +0100 Subject: [PATCH 6/6] Teach the grammar and highlighting the tier-only DSL syntax The grammar is updated and its generated parser and node types are regenerated from grammar.js, with matching highlight queries, VS Code syntax and corpus tests. The editor highlight and prompt input code follow the new syntax. --- crates/gaviero-tui/src/editor/highlight.rs | 2 +- .../gaviero-tui/src/widgets/prompt_input.rs | 88 +- crates/tree-sitter-gaviero/README.md | 2 +- crates/tree-sitter-gaviero/grammar.js | 50 +- crates/tree-sitter-gaviero/src/grammar.json | 231 +- crates/tree-sitter-gaviero/src/lib.rs | 89 +- .../tree-sitter-gaviero/src/node-types.json | 156 +- crates/tree-sitter-gaviero/src/parser.c | 7711 +++++++++-------- .../tree-sitter-gaviero/test/corpus/basic.txt | 46 +- .../vscode/syntaxes/gaviero.tmLanguage.json | 2 +- queries/gaviero/highlights.scm | 6 + 11 files changed, 4650 insertions(+), 3733 deletions(-) diff --git a/crates/gaviero-tui/src/editor/highlight.rs b/crates/gaviero-tui/src/editor/highlight.rs index 42ba24ee..db2d8ac2 100644 --- a/crates/gaviero-tui/src/editor/highlight.rs +++ b/crates/gaviero-tui/src/editor/highlight.rs @@ -436,7 +436,7 @@ mod tests { // Includes `workflow { execution_mode document }` — a clean parse here // guards against the grammar/parser drift that surfaced as spurious // syntax-highlight errors on `execution_mode` workflows. - let source = "client opus { tier expensive model \"claude-opus-4-7\" }\n\nagent scan {\n description \"Scan\"\n client opus\n memory {\n read_ns [\"shared\"]\n importance 0.9\n }\n}\n\nworkflow run {\n execution_mode document\n steps [scan]\n}\n"; + let source = "client opus { tier expensive model \"claude-opus-4-7\" }\n\nagent scan {\n description \"Scan\"\n tier high\n memory {\n read_ns [\"shared\"]\n importance 0.9\n }\n}\n\nworkflow run {\n execution_mode document\n tiers { scan top }\n steps [scan]\n}\n"; let rope = ropey::Rope::from_str(source); let tree = parser.parse(source, None).unwrap(); assert!( diff --git a/crates/gaviero-tui/src/widgets/prompt_input.rs b/crates/gaviero-tui/src/widgets/prompt_input.rs index e04b133e..5ba5c99d 100644 --- a/crates/gaviero-tui/src/widgets/prompt_input.rs +++ b/crates/gaviero-tui/src/widgets/prompt_input.rs @@ -36,7 +36,7 @@ pub enum AutocompleteMode { ModelSpec, /// `/effort ` argument — the levels the current model offers. Effort, - /// `tier:` in a roster or client param — the active profile's tiers. + /// The tier after `id=` in a list param item — the active profile's tiers. Tier, } @@ -414,46 +414,33 @@ pub fn update_path_autocomplete(input: &TextInput, autocomplete: &mut FileAutoco ); } -const TIER_PREFIX: &str = "tier:"; - -/// Open the popup while the cursor is on a model spec that is, or could become, -/// `tier:`. In a roster that is the text after `id=` of the current entry. -pub fn update_tier_autocomplete( - input: &TextInput, - autocomplete: &mut FileAutocomplete, - roster: bool, -) { +/// Open the popup while the cursor is on the tier of a list item: the text +/// after `id=` of the current `id=tier` entry. +pub fn update_tier_autocomplete(input: &TextInput, autocomplete: &mut FileAutocomplete) { let before_cursor = &input.text[..input.cursor_byte_offset()]; - let mut start = 0; - if roster { - let entry = before_cursor.rfind(',').map_or(0, |comma| comma + 1); - let Some(equals) = before_cursor[entry..].find('=') else { - autocomplete.reset(); - return; - }; - start = entry + equals + 1; - } - let spec = before_cursor[start..].trim_start(); - start = before_cursor.len() - spec.len(); - let query = match spec.strip_prefix(TIER_PREFIX) { - Some(name) => name, - None if TIER_PREFIX.starts_with(spec) => "", - None => { - autocomplete.reset(); - return; - } + let entry = before_cursor.rfind(',').map_or(0, |comma| comma + 1); + let Some(equals) = before_cursor[entry..].find('=') else { + autocomplete.reset(); + return; }; + let after = &before_cursor[entry + equals + 1..]; + let query = after.trim_start(); + if query.contains(char::is_whitespace) { + autocomplete.reset(); + return; + } + let start = before_cursor.len() - query.len(); autocomplete.open(AutocompleteMode::Tier, start, query); } -/// Fill a tier popup; each match is the full `tier:` to insert. Every -/// tier is kept; the popup scrolls. +/// Fill a tier popup; each match is a tier name to insert. Every tier is +/// kept; the popup scrolls. pub fn set_tier_matches(autocomplete: &mut FileAutocomplete, tiers: &[String]) { let query = autocomplete.query.to_lowercase(); autocomplete.matches = tiers .iter() .filter(|tier| tier.to_lowercase().starts_with(&query)) - .map(|tier| format!("{TIER_PREFIX}{tier}")) + .cloned() .collect(); autocomplete.clamp_selection(); } @@ -1072,59 +1059,54 @@ mod tests { } #[test] - fn a_roster_entry_completes_after_its_equals_sign() { + fn a_roster_entry_completes_its_tier_after_the_equals_sign() { let mut ac = FileAutocomplete::new(); - update_tier_autocomplete(&field("a=tier:lo"), &mut ac, true); + update_tier_autocomplete(&field("a=lo"), &mut ac); assert_eq!(ac.mode, AutocompleteMode::Tier); assert_eq!(ac.query, "lo"); assert_eq!(ac.at_pos, 2); set_tier_matches(&mut ac, &tiers()); - assert_eq!(ac.matches, ["tier:low", "tier:lower"]); + assert_eq!(ac.matches, ["low", "lower"]); - update_tier_autocomplete(&field("a=tier:top,b="), &mut ac, true); - assert_eq!(ac.at_pos, "a=tier:top,b=".len(), "only the current entry"); + update_tier_autocomplete(&field("a=top,b="), &mut ac); + assert_eq!(ac.at_pos, "a=top,b=".len(), "only the current entry"); assert_eq!(ac.query, ""); } #[test] fn tier_completion_stays_out_of_the_way_of_other_text() { let mut ac = FileAutocomplete::new(); - update_tier_autocomplete(&field("first"), &mut ac, true); + update_tier_autocomplete(&field("first"), &mut ac); assert!(!ac.active, "still typing the id"); - update_tier_autocomplete(&field("a=claude:op"), &mut ac, true); - assert!(!ac.active, "a provider spec"); - update_tier_autocomplete(&field("claude:op"), &mut ac, false); - assert!(!ac.active); - update_tier_autocomplete(&field("ti"), &mut ac, false); - assert!(ac.active, "on the way to `tier:`"); - assert_eq!(ac.query, ""); + update_tier_autocomplete(&field("a=hi gh"), &mut ac); + assert!(!ac.active, "a tier name has no spaces"); } #[test] fn accepting_a_tier_mid_roster_keeps_the_entries_after_it() { - let mut input = field("a=tier:lo,b=tier:top"); - input.cursor = "a=tier:lo".len(); + let mut input = field("a=lo,b=top"); + input.cursor = "a=lo".len(); let mut ac = FileAutocomplete::new(); - update_tier_autocomplete(&input, &mut ac, true); + update_tier_autocomplete(&input, &mut ac); set_tier_matches(&mut ac, &tiers()); accept_autocomplete(&mut input, &mut ac); - assert_eq!(input.text, "a=tier:low,b=tier:top"); - assert_eq!(input.cursor, "a=tier:low".len()); + assert_eq!(input.text, "a=low,b=top"); + assert_eq!(input.cursor, "a=low".len()); } #[test] fn accepting_a_tier_replaces_the_rest_of_the_name() { - let mut input = field("tier:lower"); - input.cursor = "tier:lo".len(); + let mut input = field("a=lower"); + input.cursor = "a=lo".len(); let mut ac = FileAutocomplete::new(); - update_tier_autocomplete(&input, &mut ac, false); + update_tier_autocomplete(&input, &mut ac); set_tier_matches(&mut ac, &["low".to_string()]); accept_autocomplete(&mut input, &mut ac); - assert_eq!(input.text, "tier:low"); + assert_eq!(input.text, "a=low"); } fn long_popup(count: usize) -> FileAutocomplete { diff --git a/crates/tree-sitter-gaviero/README.md b/crates/tree-sitter-gaviero/README.md index c056b03c..1680e928 100644 --- a/crates/tree-sitter-gaviero/README.md +++ b/crates/tree-sitter-gaviero/README.md @@ -34,7 +34,7 @@ use gaviero_core::tree_sitter::{Language, Parser, Query}; ## Examples -Grammar surface includes `client`, `agent`, `workflow` declarations; `scope`, `memory`, `context`, `verify` blocks; explicit `loop {}` and `until` clauses; `include` directives; strings and comments. +Grammar surface includes `agent`, `workflow` and `prompt` declarations; `client` and `tier ` lines (model profiles); `scope`, `memory`, `context`, `verify`, `tiers` blocks; explicit `loop {}`, `for` and `until` clauses; `include` directives; strings and comments. The grammar accepts anything that should produce a meaningful downstream diagnostic — semantic errors are `gaviero-dsl`'s job. diff --git a/crates/tree-sitter-gaviero/grammar.js b/crates/tree-sitter-gaviero/grammar.js index 143b382d..23d09610 100644 --- a/crates/tree-sitter-gaviero/grammar.js +++ b/crates/tree-sitter-gaviero/grammar.js @@ -30,6 +30,9 @@ module.exports = grammar({ comment: (_) => token(seq("//", /.*/)), // ── Client ─────────────────────────────────────────────────── + // Model profiles only (`.gaviero/dsl/profiles/*.gaviero`); gaviero-dsl + // rejects a client in a script. Parsed everywhere so profiles highlight + // and the compiler, not the grammar, explains the rule. client_declaration: ($) => seq("client", $.identifier, "{", repeat($.client_field), "}"), @@ -68,6 +71,7 @@ module.exports = grammar({ var_type: ($) => choice("file", "dir"), // ── Top-level tier alias: `tier ` ───────── + // A model profile's tier → client mapping (profile-only, like `client`). tier_alias_declaration: ($) => seq("tier", $.tier_alias_name, $.identifier), @@ -93,11 +97,11 @@ module.exports = grammar({ agent_field: ($) => choice( seq("description", $._string_value), - seq("client", $.identifier), + // The agent's default tier; a profile says which model it is. seq("tier", $.tier_alias_name), $.scope_block, seq("depends_on", $.identifier_list), - seq("produces", $.string_list), + seq("produces", optional("json"), $.string_list), seq("prompt", choice($._string_value, $.identifier)), seq("max_retries", $.integer), seq("timeout", $.integer), @@ -191,21 +195,23 @@ module.exports = grammar({ reviewer_field: ($) => choice( seq("id", $._string_value), - seq("model", $._string_value), - seq("effort", $._effort_value), + // The tier this item's clone runs on instead of its agent's. + seq("tier", $.tier_alias_name), // Free ` ""` field of a list param (`{{t.}}`). seq($.identifier, $._string_value), ), // ── For block ──────────────────────────────────────────────── // `for in parallel|sequential { + [peer_template "…"] }` + // `for in json "" parallel [max ] { }` — runtime list. for_block: ($) => seq( "for", $.identifier, "in", - $.identifier, + choice($.identifier, $.for_json_source), $.for_mode, + optional(seq("max", $.integer)), "{", repeat1(choice($.identifier, $.peer_template)), "}", @@ -213,6 +219,8 @@ module.exports = grammar({ for_mode: (_) => choice("parallel", "sequential"), + for_json_source: ($) => seq("json", $._string_value), + peer_template: ($) => seq("peer_template", $._string_value), consensus_mode_value: (_) => @@ -251,7 +259,24 @@ module.exports = grammar({ seq("escalate_after", $.integer), $.verify_block, $.param_declaration, + $.tiers_block, $.pattern_block, + $.budget_block, + ), + + // `tiers { … }` — agents that run on another tier than + // the one they declare, in this workflow. + tiers_block: ($) => seq("tiers", "{", repeat($.agent_tier), "}"), + + agent_tier: ($) => seq($.identifier, $.tier_alias_name), + + // `budget { wall "8h" usd 40 }` + budget_block: ($) => seq("budget", "{", repeat($.budget_field), "}"), + + budget_field: ($) => + choice( + seq("wall", $._string_value), + seq("usd", choice($.float, $.integer)), ), // `pattern map_reduce { discover reduce max_spawn }` @@ -265,19 +290,10 @@ module.exports = grammar({ seq("max_spawn", $.integer), ), - // `param ` — bare; kind inferred from usage - // `param [ * ]` — roster default - // `param { * }` — client default (model / effort / privacy / extra) - // When the default is omitted, the CLI must supply `--param =...`. + // `param [ * ]` — a list param with its default. + // `param ` — the CLI supplies `--param =...`. param_declaration: ($) => - seq( - "param", - $.identifier, - optional(choice($.reviewer_list, $.param_client_block)), - ), - - param_client_block: ($) => - seq("{", repeat($.client_field), "}"), + seq("param", $.identifier, optional($.reviewer_list)), // ── Step list (identifiers + loop blocks + for blocks) ─────── step_list: ($) => diff --git a/crates/tree-sitter-gaviero/src/grammar.json b/crates/tree-sitter-gaviero/src/grammar.json index 92a78e8c..e6664d5b 100644 --- a/crates/tree-sitter-gaviero/src/grammar.json +++ b/crates/tree-sitter-gaviero/src/grammar.json @@ -418,19 +418,6 @@ } ] }, - { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "client" - }, - { - "type": "SYMBOL", - "name": "identifier" - } - ] - }, { "type": "SEQ", "members": [ @@ -468,6 +455,18 @@ "type": "STRING", "value": "produces" }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "json" + }, + { + "type": "BLANK" + } + ] + }, { "type": "SYMBOL", "name": "string_list" @@ -1162,24 +1161,11 @@ "members": [ { "type": "STRING", - "value": "model" - }, - { - "type": "SYMBOL", - "name": "_string_value" - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "effort" + "value": "tier" }, { "type": "SYMBOL", - "name": "_effort_value" + "name": "tier_alias_name" } ] }, @@ -1214,13 +1200,43 @@ "value": "in" }, { - "type": "SYMBOL", - "name": "identifier" + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "identifier" + }, + { + "type": "SYMBOL", + "name": "for_json_source" + } + ] }, { "type": "SYMBOL", "name": "for_mode" }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "max" + }, + { + "type": "SYMBOL", + "name": "integer" + } + ] + }, + { + "type": "BLANK" + } + ] + }, { "type": "STRING", "value": "{" @@ -1260,6 +1276,19 @@ } ] }, + "for_json_source": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "json" + }, + { + "type": "SYMBOL", + "name": "_string_value" + } + ] + }, "peer_template": { "type": "SEQ", "members": [ @@ -1542,9 +1571,118 @@ "type": "SYMBOL", "name": "param_declaration" }, + { + "type": "SYMBOL", + "name": "tiers_block" + }, { "type": "SYMBOL", "name": "pattern_block" + }, + { + "type": "SYMBOL", + "name": "budget_block" + } + ] + }, + "tiers_block": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "tiers" + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "agent_tier" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "agent_tier": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "identifier" + }, + { + "type": "SYMBOL", + "name": "tier_alias_name" + } + ] + }, + "budget_block": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "budget" + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "budget_field" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "budget_field": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "wall" + }, + { + "type": "SYMBOL", + "name": "_string_value" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "usd" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "float" + }, + { + "type": "SYMBOL", + "name": "integer" + } + ] + } + ] } ] }, @@ -1635,17 +1773,8 @@ "type": "CHOICE", "members": [ { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "reviewer_list" - }, - { - "type": "SYMBOL", - "name": "param_client_block" - } - ] + "type": "SYMBOL", + "name": "reviewer_list" }, { "type": "BLANK" @@ -1654,26 +1783,6 @@ } ] }, - "param_client_block": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "{" - }, - { - "type": "REPEAT", - "content": { - "type": "SYMBOL", - "name": "client_field" - } - }, - { - "type": "STRING", - "value": "}" - } - ] - }, "step_list": { "type": "SEQ", "members": [ diff --git a/crates/tree-sitter-gaviero/src/lib.rs b/crates/tree-sitter-gaviero/src/lib.rs index 2fe9c2bf..45743195 100644 --- a/crates/tree-sitter-gaviero/src/lib.rs +++ b/crates/tree-sitter-gaviero/src/lib.rs @@ -88,7 +88,7 @@ mod tests { parser.set_language(&lang).unwrap(); let src = r#" client c { tier execution model "sonnet" } - agent a { client c description "task" } + agent a { tier c description "task" } workflow w { steps [a] max_parallel 2 } "#; let tree = parser.parse(src, None).unwrap(); @@ -398,12 +398,97 @@ mod tests { assert_eq!(sexp.matches("(for_block").count(), 1, "{sexp}"); } + #[test] + fn parse_for_over_a_json_file() { + let sexp = parse_ok( + "workflow w { execution_mode document steps [ for q in json \"out/i.json\" parallel max 3 { worker } ] }", + ); + assert_eq!(sexp.matches("(for_block").count(), 1, "{sexp}"); + assert_eq!(sexp.matches("(for_json_source").count(), 1, "{sexp}"); + } + + #[test] + fn parse_workflow_budget_block() { + let sexp = parse_ok("workflow w { steps [ a ] budget { wall \"8h\" usd 40 } }"); + assert_eq!(sexp.matches("(budget_block").count(), 1, "{sexp}"); + assert_eq!(sexp.matches("(budget_field").count(), 2, "{sexp}"); + parse_ok("workflow w { budget { usd 12.5 } steps [ a ] }"); + } + + #[test] + fn parse_agent_produces_json() { + let sexp = parse_ok( + "agent a { produces [\"out/r.md\"] produces json [\"out/f.json\"] prompt \"x\" }", + ); + assert!(!sexp.contains("ERROR"), "{sexp}"); + } + #[test] fn parse_list_entry_with_free_field() { let sexp = parse_ok( - "workflow w { param topics [ { id \"a\" focus \"storage\" } { id \"b\" model \"tier:high\" } ] steps [ x ] }", + "workflow w { param topics [ { id \"a\" focus \"storage\" } { id \"b\" tier high-codex } ] steps [ x ] }", ); assert_eq!(sexp.matches("(reviewer_entry").count(), 2, "{sexp}"); + assert!(sexp.contains("(tier_alias_name"), "{sexp}"); + } + + #[test] + fn parse_workflow_tiers_block() { + let sexp = parse_ok( + "agent a { tier low } workflow w { tiers { a medium-codex } steps [ a ] }", + ); + assert!(sexp.contains("(tiers_block (agent_tier"), "{sexp}"); + } + + /// Every case of `test/corpus/*.txt` parses to its expected tree — the + /// check `tree-sitter test` makes, run through `cargo test` so it needs + /// no CLI. + #[test] + fn corpus_cases_parse_to_their_expected_trees() { + let squash = |s: &str| { + s.split_whitespace() + .collect::>() + .join(" ") + .replace(" )", ")") + }; + let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("test/corpus"); + let mut cases = 0; + for entry in std::fs::read_dir(dir).unwrap() { + let text = std::fs::read_to_string(entry.unwrap().path()).unwrap(); + let mut parts = text.split("=====\n").skip(1); + while let (Some(name), Some(body)) = (parts.next(), parts.next()) { + let (source, expected) = body.split_once("\n-----\n").expect("case has -----"); + let mut parser = tree_sitter::Parser::new(); + let lang: tree_sitter::Language = LANGUAGE.into(); + parser.set_language(&lang).unwrap(); + let tree = parser.parse(source, None).unwrap(); + assert_eq!( + squash(&tree.root_node().to_sexp()), + squash(expected), + "corpus case `{}`", + name.trim() + ); + cases += 1; + } + } + assert!(cases > 10, "found {cases} corpus cases"); + } + + /// A model is chosen by tier only: no `client` on an agent, no + /// model-valued param. (`model "…"` in a list item reads as a free + /// field here; gaviero-dsl rejects it with a diagnostic.) + #[test] + fn model_forms_outside_profiles_are_syntax_errors() { + for src in [ + "agent a { client c }", + "workflow w { param j { model \"claude:opus\" } steps [ a ] }", + ] { + let mut parser = tree_sitter::Parser::new(); + let lang: tree_sitter::Language = LANGUAGE.into(); + parser.set_language(&lang).unwrap(); + let tree = parser.parse(src, None).unwrap(); + assert!(tree.root_node().has_error(), "{src} should not parse"); + } } #[test] diff --git a/crates/tree-sitter-gaviero/src/node-types.json b/crates/tree-sitter-gaviero/src/node-types.json index 17ee7e2f..d948bac7 100644 --- a/crates/tree-sitter-gaviero/src/node-types.json +++ b/crates/tree-sitter-gaviero/src/node-types.json @@ -77,6 +77,25 @@ ] } }, + { + "type": "agent_tier", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + }, + { + "type": "tier_alias_name", + "named": true + } + ] + } + }, { "type": "boolean", "named": true, @@ -87,6 +106,48 @@ "named": true, "fields": {} }, + { + "type": "budget_block", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "budget_field", + "named": true + } + ] + } + }, + { + "type": "budget_field", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "float", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "raw_string", + "named": true + }, + { + "type": "string", + "named": true + } + ] + } + }, { "type": "client_declaration", "named": true, @@ -231,6 +292,10 @@ "multiple": true, "required": true, "types": [ + { + "type": "for_json_source", + "named": true + }, { "type": "for_mode", "named": true @@ -239,6 +304,10 @@ "type": "identifier", "named": true }, + { + "type": "integer", + "named": true + }, { "type": "peer_template", "named": true @@ -246,6 +315,25 @@ ] } }, + { + "type": "for_json_source", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "raw_string", + "named": true + }, + { + "type": "string", + "named": true + } + ] + } + }, { "type": "for_mode", "named": true, @@ -412,21 +500,6 @@ ] } }, - { - "type": "param_client_block", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "client_field", - "named": true - } - ] - } - }, { "type": "param_declaration", "named": true, @@ -439,10 +512,6 @@ "type": "identifier", "named": true }, - { - "type": "param_client_block", - "named": true - }, { "type": "reviewer_list", "named": true @@ -552,7 +621,7 @@ "named": true }, { - "type": "tier_value", + "type": "tier_alias_name", "named": true } ] @@ -743,6 +812,21 @@ "named": true, "fields": {} }, + { + "type": "tiers_block", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "agent_tier", + "named": true + } + ] + } + }, { "type": "until_agent", "named": true, @@ -923,6 +1007,10 @@ "type": "boolean", "named": true }, + { + "type": "budget_block", + "named": true + }, { "type": "execution_mode_value", "named": true @@ -951,6 +1039,10 @@ "type": "strategy_value", "named": true }, + { + "type": "tiers_block", + "named": true + }, { "type": "verify_block", "named": true @@ -986,6 +1078,10 @@ "type": "branch_chain", "named": false }, + { + "type": "budget", + "named": false + }, { "type": "callers_of", "named": false @@ -1139,6 +1235,10 @@ "type": "iter_start", "named": false }, + { + "type": "json", + "named": false + }, { "type": "judge_timeout", "named": false @@ -1151,6 +1251,10 @@ "type": "loop", "named": false }, + { + "type": "max", + "named": false + }, { "type": "max_iterations", "named": false @@ -1335,6 +1439,10 @@ "type": "tier", "named": false }, + { + "type": "tiers", + "named": false + }, { "type": "timeout", "named": false @@ -1351,6 +1459,10 @@ "type": "until", "named": false }, + { + "type": "usd", + "named": false + }, { "type": "vars", "named": false @@ -1359,6 +1471,10 @@ "type": "verify", "named": false }, + { + "type": "wall", + "named": false + }, { "type": "workflow", "named": false diff --git a/crates/tree-sitter-gaviero/src/parser.c b/crates/tree-sitter-gaviero/src/parser.c index 238a6e94..b3d7db08 100644 --- a/crates/tree-sitter-gaviero/src/parser.c +++ b/crates/tree-sitter-gaviero/src/parser.c @@ -15,14 +15,14 @@ #endif #define LANGUAGE_VERSION 15 -#define STATE_COUNT 215 +#define STATE_COUNT 248 #define LARGE_STATE_COUNT 2 -#define SYMBOL_COUNT 179 +#define SYMBOL_COUNT 191 #define ALIAS_COUNT 0 -#define TOKEN_COUNT 106 +#define TOKEN_COUNT 112 #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 0 -#define MAX_ALIAS_SEQUENCE_LENGTH 8 +#define MAX_ALIAS_SEQUENCE_LENGTH 10 #define MAX_RESERVED_WORD_SET_SIZE 0 #define PRODUCTION_ID_COUNT 1 #define SUPERTYPE_COUNT 0 @@ -53,159 +53,171 @@ enum ts_symbol_identifiers { anon_sym_description = 23, anon_sym_depends_on = 24, anon_sym_produces = 25, - anon_sym_max_retries = 26, - anon_sym_timeout = 27, - anon_sym_tools = 28, - anon_sym_template = 29, - anon_sym_scope = 30, - anon_sym_owned = 31, - anon_sym_read_only = 32, - anon_sym_impact_scope = 33, - anon_sym_memory = 34, - anon_sym_read_ns = 35, - anon_sym_write_ns = 36, - anon_sym_importance = 37, - anon_sym_staleness_sources = 38, - anon_sym_read_query = 39, - anon_sym_read_limit = 40, - anon_sym_write_content = 41, - anon_sym_verify = 42, - anon_sym_compile = 43, - anon_sym_clippy = 44, - anon_sym_test = 45, - anon_sym_impact_tests = 46, - anon_sym_context = 47, - anon_sym_callers_of = 48, - anon_sym_tests_for = 49, - anon_sym_depth = 50, - anon_sym_loop = 51, - anon_sym_agents = 52, - anon_sym_reviewers = 53, - anon_sym_template_init = 54, - anon_sym_template_refine = 55, - anon_sym_consensus_mode = 56, - anon_sym_max_iterations = 57, - anon_sym_iter_start = 58, - anon_sym_stability = 59, - anon_sym_judge_timeout = 60, - anon_sym_irreconcilable_after = 61, - anon_sym_strict_judge = 62, - anon_sym_branch_chain = 63, - anon_sym_LBRACK = 64, - anon_sym_RBRACK = 65, - anon_sym_id = 66, - anon_sym_for = 67, - anon_sym_in = 68, - anon_sym_parallel = 69, - anon_sym_sequential = 70, - anon_sym_peer_template = 71, - anon_sym_strict = 72, - anon_sym_partial_ok = 73, - anon_sym_explore = 74, - anon_sym_stacked = 75, - anon_sym_none = 76, - anon_sym_until = 77, - anon_sym_and = 78, - anon_sym_command = 79, - anon_sym_workflow = 80, - anon_sym_steps = 81, - anon_sym_max_parallel = 82, - anon_sym_execution_mode = 83, - anon_sym_strategy = 84, - anon_sym_test_first = 85, - anon_sym_attempts = 86, - anon_sym_escalate_after = 87, - anon_sym_pattern = 88, - anon_sym_discover = 89, - anon_sym_reduce = 90, - anon_sym_max_spawn = 91, - anon_sym_param = 92, - anon_sym_public = 93, - anon_sym_local_only = 94, - anon_sym_single_pass = 95, - anon_sym_refine = 96, - anon_sym_repo = 97, - anon_sym_document = 98, - anon_sym_true = 99, - anon_sym_false = 100, - sym_string = 101, - sym_raw_string = 102, - sym_float = 103, - sym_integer = 104, - sym_identifier = 105, - sym_source_file = 106, - sym__definition = 107, - sym_include_declaration = 108, - sym_client_declaration = 109, - sym_client_field = 110, - sym__effort_value = 111, - sym_extra_block = 112, - sym_extra_pair = 113, - sym_vars_block = 114, - sym_vars_pair = 115, - sym_var_type = 116, - sym_tier_alias_declaration = 117, - sym_tier_alias_name = 118, - sym_prompt_declaration = 119, - sym_agent_declaration = 120, - sym_agent_field = 121, - sym_scope_block = 122, - sym_scope_field = 123, - sym_memory_block = 124, - sym_memory_field = 125, - sym_verify_block = 126, - sym_verify_field = 127, - sym_context_block = 128, - sym_context_field = 129, - sym_loop_block = 130, - sym_loop_field = 131, - sym_reviewer_list = 132, - sym_reviewer_entry = 133, - sym_reviewer_field = 134, - sym_for_block = 135, - sym_for_mode = 136, - sym_peer_template = 137, - sym_consensus_mode_value = 138, - sym_branch_chain_value = 139, - sym_until_clause = 140, - sym__until_condition = 141, - sym_until_verify = 142, - sym_until_agent = 143, - sym_until_command = 144, - sym_workflow_declaration = 145, - sym_workflow_field = 146, - sym_pattern_block = 147, - sym_map_reduce_field = 148, - sym_param_declaration = 149, - sym_param_client_block = 150, - sym_step_list = 151, - sym_string_list = 152, - sym_identifier_list = 153, - sym_tier_value = 154, - sym_privacy_value = 155, - sym_strategy_value = 156, - sym_execution_mode_value = 157, - sym_boolean = 158, - sym__string_value = 159, - aux_sym_source_file_repeat1 = 160, - aux_sym_client_declaration_repeat1 = 161, - aux_sym_extra_block_repeat1 = 162, - aux_sym_vars_block_repeat1 = 163, - aux_sym_agent_declaration_repeat1 = 164, - aux_sym_scope_block_repeat1 = 165, - aux_sym_memory_block_repeat1 = 166, - aux_sym_verify_block_repeat1 = 167, - aux_sym_context_block_repeat1 = 168, - aux_sym_loop_block_repeat1 = 169, - aux_sym_reviewer_list_repeat1 = 170, - aux_sym_reviewer_entry_repeat1 = 171, - aux_sym_for_block_repeat1 = 172, - aux_sym_until_clause_repeat1 = 173, - aux_sym_workflow_declaration_repeat1 = 174, - aux_sym_pattern_block_repeat1 = 175, - aux_sym_step_list_repeat1 = 176, - aux_sym_string_list_repeat1 = 177, - aux_sym_identifier_list_repeat1 = 178, + anon_sym_json = 26, + anon_sym_max_retries = 27, + anon_sym_timeout = 28, + anon_sym_tools = 29, + anon_sym_template = 30, + anon_sym_scope = 31, + anon_sym_owned = 32, + anon_sym_read_only = 33, + anon_sym_impact_scope = 34, + anon_sym_memory = 35, + anon_sym_read_ns = 36, + anon_sym_write_ns = 37, + anon_sym_importance = 38, + anon_sym_staleness_sources = 39, + anon_sym_read_query = 40, + anon_sym_read_limit = 41, + anon_sym_write_content = 42, + anon_sym_verify = 43, + anon_sym_compile = 44, + anon_sym_clippy = 45, + anon_sym_test = 46, + anon_sym_impact_tests = 47, + anon_sym_context = 48, + anon_sym_callers_of = 49, + anon_sym_tests_for = 50, + anon_sym_depth = 51, + anon_sym_loop = 52, + anon_sym_agents = 53, + anon_sym_reviewers = 54, + anon_sym_template_init = 55, + anon_sym_template_refine = 56, + anon_sym_consensus_mode = 57, + anon_sym_max_iterations = 58, + anon_sym_iter_start = 59, + anon_sym_stability = 60, + anon_sym_judge_timeout = 61, + anon_sym_irreconcilable_after = 62, + anon_sym_strict_judge = 63, + anon_sym_branch_chain = 64, + anon_sym_LBRACK = 65, + anon_sym_RBRACK = 66, + anon_sym_id = 67, + anon_sym_for = 68, + anon_sym_in = 69, + anon_sym_max = 70, + anon_sym_parallel = 71, + anon_sym_sequential = 72, + anon_sym_peer_template = 73, + anon_sym_strict = 74, + anon_sym_partial_ok = 75, + anon_sym_explore = 76, + anon_sym_stacked = 77, + anon_sym_none = 78, + anon_sym_until = 79, + anon_sym_and = 80, + anon_sym_command = 81, + anon_sym_workflow = 82, + anon_sym_steps = 83, + anon_sym_max_parallel = 84, + anon_sym_execution_mode = 85, + anon_sym_strategy = 86, + anon_sym_test_first = 87, + anon_sym_attempts = 88, + anon_sym_escalate_after = 89, + anon_sym_tiers = 90, + anon_sym_budget = 91, + anon_sym_wall = 92, + anon_sym_usd = 93, + anon_sym_pattern = 94, + anon_sym_discover = 95, + anon_sym_reduce = 96, + anon_sym_max_spawn = 97, + anon_sym_param = 98, + anon_sym_public = 99, + anon_sym_local_only = 100, + anon_sym_single_pass = 101, + anon_sym_refine = 102, + anon_sym_repo = 103, + anon_sym_document = 104, + anon_sym_true = 105, + anon_sym_false = 106, + sym_string = 107, + sym_raw_string = 108, + sym_float = 109, + sym_integer = 110, + sym_identifier = 111, + sym_source_file = 112, + sym__definition = 113, + sym_include_declaration = 114, + sym_client_declaration = 115, + sym_client_field = 116, + sym__effort_value = 117, + sym_extra_block = 118, + sym_extra_pair = 119, + sym_vars_block = 120, + sym_vars_pair = 121, + sym_var_type = 122, + sym_tier_alias_declaration = 123, + sym_tier_alias_name = 124, + sym_prompt_declaration = 125, + sym_agent_declaration = 126, + sym_agent_field = 127, + sym_scope_block = 128, + sym_scope_field = 129, + sym_memory_block = 130, + sym_memory_field = 131, + sym_verify_block = 132, + sym_verify_field = 133, + sym_context_block = 134, + sym_context_field = 135, + sym_loop_block = 136, + sym_loop_field = 137, + sym_reviewer_list = 138, + sym_reviewer_entry = 139, + sym_reviewer_field = 140, + sym_for_block = 141, + sym_for_mode = 142, + sym_for_json_source = 143, + sym_peer_template = 144, + sym_consensus_mode_value = 145, + sym_branch_chain_value = 146, + sym_until_clause = 147, + sym__until_condition = 148, + sym_until_verify = 149, + sym_until_agent = 150, + sym_until_command = 151, + sym_workflow_declaration = 152, + sym_workflow_field = 153, + sym_tiers_block = 154, + sym_agent_tier = 155, + sym_budget_block = 156, + sym_budget_field = 157, + sym_pattern_block = 158, + sym_map_reduce_field = 159, + sym_param_declaration = 160, + sym_step_list = 161, + sym_string_list = 162, + sym_identifier_list = 163, + sym_tier_value = 164, + sym_privacy_value = 165, + sym_strategy_value = 166, + sym_execution_mode_value = 167, + sym_boolean = 168, + sym__string_value = 169, + aux_sym_source_file_repeat1 = 170, + aux_sym_client_declaration_repeat1 = 171, + aux_sym_extra_block_repeat1 = 172, + aux_sym_vars_block_repeat1 = 173, + aux_sym_agent_declaration_repeat1 = 174, + aux_sym_scope_block_repeat1 = 175, + aux_sym_memory_block_repeat1 = 176, + aux_sym_verify_block_repeat1 = 177, + aux_sym_context_block_repeat1 = 178, + aux_sym_loop_block_repeat1 = 179, + aux_sym_reviewer_list_repeat1 = 180, + aux_sym_reviewer_entry_repeat1 = 181, + aux_sym_for_block_repeat1 = 182, + aux_sym_until_clause_repeat1 = 183, + aux_sym_workflow_declaration_repeat1 = 184, + aux_sym_tiers_block_repeat1 = 185, + aux_sym_budget_block_repeat1 = 186, + aux_sym_pattern_block_repeat1 = 187, + aux_sym_step_list_repeat1 = 188, + aux_sym_string_list_repeat1 = 189, + aux_sym_identifier_list_repeat1 = 190, }; static const char * const ts_symbol_names[] = { @@ -235,6 +247,7 @@ static const char * const ts_symbol_names[] = { [anon_sym_description] = "description", [anon_sym_depends_on] = "depends_on", [anon_sym_produces] = "produces", + [anon_sym_json] = "json", [anon_sym_max_retries] = "max_retries", [anon_sym_timeout] = "timeout", [anon_sym_tools] = "tools", @@ -278,6 +291,7 @@ static const char * const ts_symbol_names[] = { [anon_sym_id] = "id", [anon_sym_for] = "for", [anon_sym_in] = "in", + [anon_sym_max] = "max", [anon_sym_parallel] = "parallel", [anon_sym_sequential] = "sequential", [anon_sym_peer_template] = "peer_template", @@ -297,6 +311,10 @@ static const char * const ts_symbol_names[] = { [anon_sym_test_first] = "test_first", [anon_sym_attempts] = "attempts", [anon_sym_escalate_after] = "escalate_after", + [anon_sym_tiers] = "tiers", + [anon_sym_budget] = "budget", + [anon_sym_wall] = "wall", + [anon_sym_usd] = "usd", [anon_sym_pattern] = "pattern", [anon_sym_discover] = "discover", [anon_sym_reduce] = "reduce", @@ -346,6 +364,7 @@ static const char * const ts_symbol_names[] = { [sym_reviewer_field] = "reviewer_field", [sym_for_block] = "for_block", [sym_for_mode] = "for_mode", + [sym_for_json_source] = "for_json_source", [sym_peer_template] = "peer_template", [sym_consensus_mode_value] = "consensus_mode_value", [sym_branch_chain_value] = "branch_chain_value", @@ -356,10 +375,13 @@ static const char * const ts_symbol_names[] = { [sym_until_command] = "until_command", [sym_workflow_declaration] = "workflow_declaration", [sym_workflow_field] = "workflow_field", + [sym_tiers_block] = "tiers_block", + [sym_agent_tier] = "agent_tier", + [sym_budget_block] = "budget_block", + [sym_budget_field] = "budget_field", [sym_pattern_block] = "pattern_block", [sym_map_reduce_field] = "map_reduce_field", [sym_param_declaration] = "param_declaration", - [sym_param_client_block] = "param_client_block", [sym_step_list] = "step_list", [sym_string_list] = "string_list", [sym_identifier_list] = "identifier_list", @@ -384,6 +406,8 @@ static const char * const ts_symbol_names[] = { [aux_sym_for_block_repeat1] = "for_block_repeat1", [aux_sym_until_clause_repeat1] = "until_clause_repeat1", [aux_sym_workflow_declaration_repeat1] = "workflow_declaration_repeat1", + [aux_sym_tiers_block_repeat1] = "tiers_block_repeat1", + [aux_sym_budget_block_repeat1] = "budget_block_repeat1", [aux_sym_pattern_block_repeat1] = "pattern_block_repeat1", [aux_sym_step_list_repeat1] = "step_list_repeat1", [aux_sym_string_list_repeat1] = "string_list_repeat1", @@ -417,6 +441,7 @@ static const TSSymbol ts_symbol_map[] = { [anon_sym_description] = anon_sym_description, [anon_sym_depends_on] = anon_sym_depends_on, [anon_sym_produces] = anon_sym_produces, + [anon_sym_json] = anon_sym_json, [anon_sym_max_retries] = anon_sym_max_retries, [anon_sym_timeout] = anon_sym_timeout, [anon_sym_tools] = anon_sym_tools, @@ -460,6 +485,7 @@ static const TSSymbol ts_symbol_map[] = { [anon_sym_id] = anon_sym_id, [anon_sym_for] = anon_sym_for, [anon_sym_in] = anon_sym_in, + [anon_sym_max] = anon_sym_max, [anon_sym_parallel] = anon_sym_parallel, [anon_sym_sequential] = anon_sym_sequential, [anon_sym_peer_template] = anon_sym_peer_template, @@ -479,6 +505,10 @@ static const TSSymbol ts_symbol_map[] = { [anon_sym_test_first] = anon_sym_test_first, [anon_sym_attempts] = anon_sym_attempts, [anon_sym_escalate_after] = anon_sym_escalate_after, + [anon_sym_tiers] = anon_sym_tiers, + [anon_sym_budget] = anon_sym_budget, + [anon_sym_wall] = anon_sym_wall, + [anon_sym_usd] = anon_sym_usd, [anon_sym_pattern] = anon_sym_pattern, [anon_sym_discover] = anon_sym_discover, [anon_sym_reduce] = anon_sym_reduce, @@ -528,6 +558,7 @@ static const TSSymbol ts_symbol_map[] = { [sym_reviewer_field] = sym_reviewer_field, [sym_for_block] = sym_for_block, [sym_for_mode] = sym_for_mode, + [sym_for_json_source] = sym_for_json_source, [sym_peer_template] = sym_peer_template, [sym_consensus_mode_value] = sym_consensus_mode_value, [sym_branch_chain_value] = sym_branch_chain_value, @@ -538,10 +569,13 @@ static const TSSymbol ts_symbol_map[] = { [sym_until_command] = sym_until_command, [sym_workflow_declaration] = sym_workflow_declaration, [sym_workflow_field] = sym_workflow_field, + [sym_tiers_block] = sym_tiers_block, + [sym_agent_tier] = sym_agent_tier, + [sym_budget_block] = sym_budget_block, + [sym_budget_field] = sym_budget_field, [sym_pattern_block] = sym_pattern_block, [sym_map_reduce_field] = sym_map_reduce_field, [sym_param_declaration] = sym_param_declaration, - [sym_param_client_block] = sym_param_client_block, [sym_step_list] = sym_step_list, [sym_string_list] = sym_string_list, [sym_identifier_list] = sym_identifier_list, @@ -566,6 +600,8 @@ static const TSSymbol ts_symbol_map[] = { [aux_sym_for_block_repeat1] = aux_sym_for_block_repeat1, [aux_sym_until_clause_repeat1] = aux_sym_until_clause_repeat1, [aux_sym_workflow_declaration_repeat1] = aux_sym_workflow_declaration_repeat1, + [aux_sym_tiers_block_repeat1] = aux_sym_tiers_block_repeat1, + [aux_sym_budget_block_repeat1] = aux_sym_budget_block_repeat1, [aux_sym_pattern_block_repeat1] = aux_sym_pattern_block_repeat1, [aux_sym_step_list_repeat1] = aux_sym_step_list_repeat1, [aux_sym_string_list_repeat1] = aux_sym_string_list_repeat1, @@ -677,6 +713,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, + [anon_sym_json] = { + .visible = true, + .named = false, + }, [anon_sym_max_retries] = { .visible = true, .named = false, @@ -849,6 +889,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, + [anon_sym_max] = { + .visible = true, + .named = false, + }, [anon_sym_parallel] = { .visible = true, .named = false, @@ -925,6 +969,22 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, + [anon_sym_tiers] = { + .visible = true, + .named = false, + }, + [anon_sym_budget] = { + .visible = true, + .named = false, + }, + [anon_sym_wall] = { + .visible = true, + .named = false, + }, + [anon_sym_usd] = { + .visible = true, + .named = false, + }, [anon_sym_pattern] = { .visible = true, .named = false, @@ -1121,6 +1181,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, + [sym_for_json_source] = { + .visible = true, + .named = true, + }, [sym_peer_template] = { .visible = true, .named = true, @@ -1161,19 +1225,31 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym_pattern_block] = { + [sym_tiers_block] = { .visible = true, .named = true, }, - [sym_map_reduce_field] = { + [sym_agent_tier] = { .visible = true, .named = true, }, - [sym_param_declaration] = { + [sym_budget_block] = { + .visible = true, + .named = true, + }, + [sym_budget_field] = { + .visible = true, + .named = true, + }, + [sym_pattern_block] = { + .visible = true, + .named = true, + }, + [sym_map_reduce_field] = { .visible = true, .named = true, }, - [sym_param_client_block] = { + [sym_param_declaration] = { .visible = true, .named = true, }, @@ -1273,6 +1349,14 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = false, }, + [aux_sym_tiers_block_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_budget_block_repeat1] = { + .visible = false, + .named = false, + }, [aux_sym_pattern_block_repeat1] = { .visible = false, .named = false, @@ -1350,7 +1434,7 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [47] = 47, [48] = 48, [49] = 49, - [50] = 50, + [50] = 2, [51] = 51, [52] = 52, [53] = 53, @@ -1361,9 +1445,9 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [58] = 58, [59] = 59, [60] = 60, - [61] = 61, + [61] = 51, [62] = 62, - [63] = 63, + [63] = 52, [64] = 64, [65] = 65, [66] = 66, @@ -1371,8 +1455,8 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [68] = 68, [69] = 69, [70] = 70, - [71] = 71, - [72] = 72, + [71] = 69, + [72] = 68, [73] = 73, [74] = 74, [75] = 75, @@ -1419,9 +1503,9 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [116] = 116, [117] = 117, [118] = 118, - [119] = 93, + [119] = 119, [120] = 120, - [121] = 117, + [121] = 121, [122] = 122, [123] = 123, [124] = 124, @@ -1431,34 +1515,34 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [128] = 128, [129] = 129, [130] = 130, - [131] = 131, - [132] = 132, + [131] = 126, + [132] = 119, [133] = 133, [134] = 134, [135] = 135, - [136] = 43, + [136] = 136, [137] = 137, [138] = 138, - [139] = 135, + [139] = 139, [140] = 140, [141] = 141, [142] = 142, [143] = 143, [144] = 144, - [145] = 145, + [145] = 31, [146] = 146, [147] = 147, - [148] = 148, - [149] = 149, + [148] = 147, + [149] = 30, [150] = 150, [151] = 151, [152] = 152, - [153] = 153, - [154] = 141, + [153] = 60, + [154] = 154, [155] = 155, [156] = 156, [157] = 157, - [158] = 158, + [158] = 143, [159] = 159, [160] = 160, [161] = 161, @@ -1488,8 +1572,8 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [185] = 185, [186] = 186, [187] = 187, - [188] = 42, - [189] = 189, + [188] = 176, + [189] = 167, [190] = 190, [191] = 191, [192] = 192, @@ -1498,23 +1582,56 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [195] = 195, [196] = 196, [197] = 197, - [198] = 198, + [198] = 60, [199] = 199, [200] = 200, [201] = 201, [202] = 202, [203] = 203, [204] = 204, - [205] = 205, + [205] = 192, [206] = 206, [207] = 207, [208] = 208, - [209] = 194, + [209] = 209, [210] = 210, - [211] = 175, - [212] = 177, - [213] = 197, + [211] = 211, + [212] = 212, + [213] = 213, [214] = 214, + [215] = 215, + [216] = 216, + [217] = 217, + [218] = 218, + [219] = 219, + [220] = 220, + [221] = 221, + [222] = 222, + [223] = 223, + [224] = 224, + [225] = 225, + [226] = 226, + [227] = 227, + [228] = 228, + [229] = 229, + [230] = 230, + [231] = 231, + [232] = 232, + [233] = 233, + [234] = 234, + [235] = 235, + [236] = 236, + [237] = 237, + [238] = 237, + [239] = 239, + [240] = 240, + [241] = 219, + [242] = 242, + [243] = 216, + [244] = 244, + [245] = 233, + [246] = 210, + [247] = 247, }; static bool ts_lex(TSLexer *lexer, TSStateId state) { @@ -1522,69 +1639,69 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { eof = lexer->eof(lexer); switch (state) { case 0: - if (eof) ADVANCE(624); + if (eof) ADVANCE(637); ADVANCE_MAP( '"', 3, '#', 4, '/', 15, - '[', 700, - ']', 701, - 'a', 250, - 'b', 457, - 'c', 44, + '[', 713, + ']', 714, + 'a', 251, + 'b', 463, + 'c', 42, 'd', 152, 'e', 238, - 'f', 52, - 'i', 135, - 'j', 584, - 'l', 398, - 'm', 46, - 'n', 402, - 'o', 606, - 'p', 47, + 'f', 50, + 'i', 133, + 'j', 518, + 'l', 404, + 'm', 44, + 'n', 405, + 'o', 616, + 'p', 45, 'r', 153, 's', 107, 't', 154, - 'u', 366, - 'v', 56, - 'w', 409, - '{', 628, - '}', 629, + 'u', 371, + 'v', 54, + 'w', 79, + '{', 641, + '}', 642, ); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(0); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(746); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(765); END_STATE(); case 1: if (lookahead == '"') ADVANCE(3); if (lookahead == '#') ADVANCE(4); if (lookahead == '/') ADVANCE(15); - if (lookahead == '[') ADVANCE(700); - if (lookahead == ']') ADVANCE(701); - if (lookahead == '}') ADVANCE(629); + if (lookahead == '[') ADVANCE(713); + if (lookahead == ']') ADVANCE(714); + if (lookahead == '}') ADVANCE(642); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(1); if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 2: if (lookahead == '"') ADVANCE(3); if (lookahead == '#') ADVANCE(4); if (lookahead == '/') ADVANCE(15); - if (lookahead == 'c') ADVANCE(782); - if (lookahead == 'e') ADVANCE(833); - if (lookahead == 'm') ADVANCE(763); - if (lookahead == 'r') ADVANCE(764); + if (lookahead == 'c') ADVANCE(797); + if (lookahead == 'e') ADVANCE(848); + if (lookahead == 'm') ADVANCE(780); + if (lookahead == 'r') ADVANCE(781); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(2); if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 3: - if (lookahead == '"') ADVANCE(743); - if (lookahead == '\\') ADVANCE(622); + if (lookahead == '"') ADVANCE(762); + if (lookahead == '\\') ADVANCE(635); if (lookahead != 0) ADVANCE(3); END_STATE(); case 4: @@ -1595,3533 +1712,3590 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead != 0) ADVANCE(5); END_STATE(); case 6: - if (lookahead == '#') ADVANCE(744); + if (lookahead == '#') ADVANCE(763); if (lookahead != 0) ADVANCE(5); END_STATE(); case 7: - if (lookahead == '.') ADVANCE(621); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(7); + ADVANCE_MAP( + '/', 15, + '[', 713, + 'a', 258, + 'b', 463, + 'c', 425, + 'e', 517, + 'f', 403, + 'i', 475, + 'j', 601, + 'm', 85, + 'p', 55, + 'r', 185, + 's', 557, + 't', 233, + 'u', 370, + 'v', 186, + '}', 642, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(7); END_STATE(); case 8: if (lookahead == '/') ADVANCE(15); - if (lookahead == ']') ADVANCE(701); - if (lookahead == 'f') ADVANCE(807); - if (lookahead == 'l') ADVANCE(810); + if (lookahead == ']') ADVANCE(714); + if (lookahead == 'f') ADVANCE(823); + if (lookahead == 'l') ADVANCE(825); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(8); if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 9: ADVANCE_MAP( '/', 15, - 'a', 256, - 'b', 457, - 'c', 419, - 'e', 508, - 'f', 401, - 'i', 472, - 'j', 584, - 'm', 84, - 'p', 53, - 'r', 183, - 's', 547, + 'a', 257, + 'b', 462, + 'c', 330, + 'd', 182, + 'f', 403, + 'i', 349, + 'j', 601, + 'm', 81, + 'o', 616, + 'p', 492, + 'r', 177, + 's', 109, 't', 229, - 'u', 366, - 'v', 184, - '}', 629, + 'u', 370, + 'v', 53, + '}', 642, ); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(9); END_STATE(); case 10: - ADVANCE_MAP( - '/', 15, - 'a', 257, - 'b', 457, - 'c', 302, - 'd', 181, - 'e', 508, - 'f', 401, - 'i', 344, - 'j', 584, - 'm', 84, - 'o', 606, - 'p', 54, - 'r', 177, - 's', 109, - 't', 225, - 'u', 366, - 'v', 56, - '}', 629, - ); + if (lookahead == '/') ADVANCE(15); + if (lookahead == 'i') ADVANCE(779); + if (lookahead == 't') ADVANCE(803); + if (lookahead == '}') ADVANCE(642); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(10); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(7); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 11: if (lookahead == '/') ADVANCE(15); - if (lookahead == 'c') ADVANCE(326); - if (lookahead == 'i') ADVANCE(354); - if (lookahead == 't') ADVANCE(231); - if (lookahead == '}') ADVANCE(629); + if (lookahead == 'j') ADVANCE(841); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(11); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 12: if (lookahead == '/') ADVANCE(15); - if (lookahead == 'e') ADVANCE(777); - if (lookahead == 'i') ADVANCE(761); - if (lookahead == 'm') ADVANCE(808); - if (lookahead == '}') ADVANCE(629); + if (lookahead == 'm') ADVANCE(59); + if (lookahead == '{') ADVANCE(641); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(12); - if (('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); END_STATE(); case 13: if (lookahead == '/') ADVANCE(15); - if (lookahead == 'p') ADVANCE(776); - if (lookahead == '}') ADVANCE(629); + if (lookahead == 'p') ADVANCE(793); + if (lookahead == '}') ADVANCE(642); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(13); if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 14: if (lookahead == '/') ADVANCE(15); - if (lookahead == 'r') ADVANCE(774); - if (lookahead == 's') ADVANCE(788); + if (lookahead == 'r') ADVANCE(786); + if (lookahead == 's') ADVANCE(804); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(14); if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 15: - if (lookahead == '/') ADVANCE(626); + if (lookahead == '/') ADVANCE(639); END_STATE(); case 16: - if (lookahead == '_') ADVANCE(289); + if (lookahead == '_') ADVANCE(327); END_STATE(); case 17: - if (lookahead == '_') ADVANCE(321); + if (lookahead == '_') ADVANCE(131); END_STATE(); case 18: - if (lookahead == '_') ADVANCE(118); + if (lookahead == '_') ADVANCE(302); END_STATE(); case 19: - if (lookahead == '_') ADVANCE(298); + if (lookahead == '_') ADVANCE(287); END_STATE(); case 20: - if (lookahead == '_') ADVANCE(286); + if (lookahead == '_') ADVANCE(298); END_STATE(); case 21: - if (lookahead == '_') ADVANCE(440); + if (lookahead == '_') ADVANCE(494); END_STATE(); case 22: - if (lookahead == '_') ADVANCE(288); + if (lookahead == '_') ADVANCE(524); END_STATE(); case 23: - if (lookahead == '_') ADVANCE(514); + if (lookahead == '_') ADVANCE(300); END_STATE(); case 24: if (lookahead == '_') ADVANCE(244); END_STATE(); case 25: - if (lookahead == '_') ADVANCE(244); - if (lookahead == 's') ADVANCE(41); + if (lookahead == '_') ADVANCE(350); END_STATE(); case 26: - if (lookahead == '_') ADVANCE(347); + if (lookahead == '_') ADVANCE(529); END_STATE(); case 27: - if (lookahead == '_') ADVANCE(515); + if (lookahead == '_') ADVANCE(111); END_STATE(); case 28: - if (lookahead == '_') ADVANCE(112); + if (lookahead == '_') ADVANCE(449); END_STATE(); case 29: - if (lookahead == '_') ADVANCE(444); + if (lookahead == '_') ADVANCE(413); END_STATE(); case 30: - if (lookahead == '_') ADVANCE(408); + if (lookahead == '_') ADVANCE(411); END_STATE(); case 31: - if (lookahead == '_') ADVANCE(406); + if (lookahead == '_') ADVANCE(62); END_STATE(); case 32: - if (lookahead == '_') ADVANCE(62); + if (lookahead == '_') ADVANCE(527); END_STATE(); case 33: - if (lookahead == '_') ADVANCE(517); + if (lookahead == '_') ADVANCE(523); END_STATE(); case 34: - if (lookahead == '_') ADVANCE(513); + if (lookahead == '_') ADVANCE(570); END_STATE(); case 35: - if (lookahead == '_') ADVANCE(560); + if (lookahead == '_') ADVANCE(436); END_STATE(); case 36: - if (lookahead == '_') ADVANCE(429); + if (lookahead == '_') ADVANCE(423); END_STATE(); case 37: - if (lookahead == '_') ADVANCE(416); + if (lookahead == '_') ADVANCE(420); END_STATE(); case 38: - if (lookahead == '_') ADVANCE(413); + if (lookahead == '_') ADVANCE(580); END_STATE(); case 39: - if (lookahead == '_') ADVANCE(567); + if (lookahead == '_') ADVANCE(245); END_STATE(); case 40: - if (lookahead == '_') ADVANCE(572); + if (lookahead == '_') ADVANCE(358); END_STATE(); case 41: - if (lookahead == '_') ADVANCE(245); + if (lookahead == '_') ADVANCE(98); END_STATE(); case 42: - if (lookahead == '_') ADVANCE(355); + if (lookahead == 'a') ADVANCE(333); + if (lookahead == 'h') ADVANCE(180); + if (lookahead == 'l') ADVANCE(263); + if (lookahead == 'o') ADVANCE(345); END_STATE(); case 43: - if (lookahead == '_') ADVANCE(99); + if (lookahead == 'a') ADVANCE(333); + if (lookahead == 'l') ADVANCE(301); + if (lookahead == 'o') ADVANCE(401); END_STATE(); case 44: - if (lookahead == 'a') ADVANCE(329); - if (lookahead == 'h') ADVANCE(179); - if (lookahead == 'l') ADVANCE(262); - if (lookahead == 'o') ADVANCE(340); + if (lookahead == 'a') ADVANCE(618); + if (lookahead == 'e') ADVANCE(103); + if (lookahead == 'o') ADVANCE(142); END_STATE(); case 45: - if (lookahead == 'a') ADVANCE(329); - if (lookahead == 'l') ADVANCE(297); - if (lookahead == 'o') ADVANCE(396); + if (lookahead == 'a') ADVANCE(466); + if (lookahead == 'e') ADVANCE(200); + if (lookahead == 'r') ADVANCE(264); + if (lookahead == 'u') ADVANCE(99); END_STATE(); case 46: - if (lookahead == 'a') ADVANCE(608); - if (lookahead == 'e') ADVANCE(104); - if (lookahead == 'o') ADVANCE(143); + if (lookahead == 'a') ADVANCE(141); + if (lookahead == 'd') ADVANCE(595); + if (lookahead == 'f') ADVANCE(285); + if (lookahead == 'p') ADVANCE(407); + if (lookahead == 'v') ADVANCE(273); END_STATE(); case 47: - if (lookahead == 'a') ADVANCE(460); - if (lookahead == 'e') ADVANCE(197); - if (lookahead == 'r') ADVANCE(263); - if (lookahead == 'u') ADVANCE(100); + if (lookahead == 'a') ADVANCE(101); + if (lookahead == 'e') ADVANCE(443); + if (lookahead == 'r') ADVANCE(88); END_STATE(); case 48: - if (lookahead == 'a') ADVANCE(142); - if (lookahead == 'd') ADVANCE(586); - if (lookahead == 'f') ADVANCE(284); - if (lookahead == 'p') ADVANCE(400); - if (lookahead == 'v') ADVANCE(273); + if (lookahead == 'a') ADVANCE(338); + if (lookahead == 't') ADVANCE(286); END_STATE(); case 49: - if (lookahead == 'a') ADVANCE(102); - if (lookahead == 'e') ADVANCE(437); - if (lookahead == 'r') ADVANCE(87); + if (lookahead == 'a') ADVANCE(649); END_STATE(); case 50: - if (lookahead == 'a') ADVANCE(333); - if (lookahead == 't') ADVANCE(285); + if (lookahead == 'a') ADVANCE(306); + if (lookahead == 'i') ADVANCE(316); + if (lookahead == 'o') ADVANCE(465); END_STATE(); case 51: - if (lookahead == 'a') ADVANCE(637); + if (lookahead == 'a') ADVANCE(100); + if (lookahead == 'e') ADVANCE(443); + if (lookahead == 'r') ADVANCE(89); END_STATE(); case 52: - if (lookahead == 'a') ADVANCE(303); - if (lookahead == 'i') ADVANCE(311); - if (lookahead == 'o') ADVANCE(459); + if (lookahead == 'a') ADVANCE(100); + if (lookahead == 'r') ADVANCE(297); END_STATE(); case 53: - if (lookahead == 'a') ADVANCE(487); + if (lookahead == 'a') ADVANCE(476); END_STATE(); case 54: - if (lookahead == 'a') ADVANCE(487); - if (lookahead == 'r') ADVANCE(399); + if (lookahead == 'a') ADVANCE(476); + if (lookahead == 'e') ADVANCE(481); END_STATE(); case 55: - if (lookahead == 'a') ADVANCE(101); - if (lookahead == 'e') ADVANCE(437); - if (lookahead == 'r') ADVANCE(89); + if (lookahead == 'a') ADVANCE(493); END_STATE(); case 56: - if (lookahead == 'a') ADVANCE(468); - if (lookahead == 'e') ADVANCE(477); + if (lookahead == 'a') ADVANCE(621); + if (lookahead == 'e') ADVANCE(353); END_STATE(); case 57: - if (lookahead == 'a') ADVANCE(371); + if (lookahead == 'a') ADVANCE(375); END_STATE(); case 58: - if (lookahead == 'a') ADVANCE(587); + if (lookahead == 'a') ADVANCE(596); END_STATE(); case 59: - if (lookahead == 'a') ADVANCE(314); + if (lookahead == 'a') ADVANCE(619); END_STATE(); case 60: - if (lookahead == 'a') ADVANCE(116); + if (lookahead == 'a') ADVANCE(115); END_STATE(); case 61: - if (lookahead == 'a') ADVANCE(116); - if (lookahead == 'o') ADVANCE(480); + if (lookahead == 'a') ADVANCE(115); + if (lookahead == 'o') ADVANCE(485); END_STATE(); case 62: if (lookahead == 'a') ADVANCE(247); END_STATE(); case 63: - if (lookahead == 'a') ADVANCE(435); + if (lookahead == 'a') ADVANCE(441); END_STATE(); case 64: - if (lookahead == 'a') ADVANCE(312); + if (lookahead == 'a') ADVANCE(346); END_STATE(); case 65: - if (lookahead == 'a') ADVANCE(341); + if (lookahead == 'a') ADVANCE(319); END_STATE(); case 66: - if (lookahead == 'a') ADVANCE(341); - if (lookahead == 't') ADVANCE(285); + if (lookahead == 'a') ADVANCE(315); END_STATE(); case 67: - if (lookahead == 'a') ADVANCE(382); + if (lookahead == 'a') ADVANCE(112); END_STATE(); case 68: - if (lookahead == 'a') ADVANCE(141); + if (lookahead == 'a') ADVANCE(386); END_STATE(); case 69: - if (lookahead == 'a') ADVANCE(113); + if (lookahead == 'a') ADVANCE(140); + if (lookahead == 'd') ADVANCE(595); END_STATE(); case 70: if (lookahead == 'a') ADVANCE(151); if (lookahead == 'v') ADVANCE(273); END_STATE(); case 71: - if (lookahead == 'a') ADVANCE(320); + if (lookahead == 'a') ADVANCE(335); END_STATE(); case 72: - if (lookahead == 'a') ADVANCE(307); + if (lookahead == 'a') ADVANCE(487); END_STATE(); case 73: - if (lookahead == 'a') ADVANCE(308); + if (lookahead == 'a') ADVANCE(311); END_STATE(); case 74: - if (lookahead == 'a') ADVANCE(575); + if (lookahead == 'a') ADVANCE(312); END_STATE(); case 75: - if (lookahead == 'a') ADVANCE(488); + if (lookahead == 'a') ADVANCE(584); END_STATE(); case 76: - if (lookahead == 'a') ADVANCE(274); + if (lookahead == 'a') ADVANCE(495); END_STATE(); case 77: - if (lookahead == 'a') ADVANCE(605); + if (lookahead == 'a') ADVANCE(501); + if (lookahead == 'r') ADVANCE(406); END_STATE(); case 78: - if (lookahead == 'a') ADVANCE(610); - if (lookahead == 'e') ADVANCE(350); + if (lookahead == 'a') ADVANCE(615); END_STATE(); case 79: - if (lookahead == 'a') ADVANCE(470); - if (lookahead == 'r') ADVANCE(399); + if (lookahead == 'a') ADVANCE(317); + if (lookahead == 'o') ADVANCE(467); + if (lookahead == 'r') ADVANCE(284); END_STATE(); case 80: - if (lookahead == 'a') ADVANCE(103); + if (lookahead == 'a') ADVANCE(102); END_STATE(); case 81: - if (lookahead == 'a') ADVANCE(374); + if (lookahead == 'a') ADVANCE(622); + if (lookahead == 'e') ADVANCE(353); END_STATE(); case 82: - if (lookahead == 'a') ADVANCE(521); + if (lookahead == 'a') ADVANCE(379); END_STATE(); case 83: - if (lookahead == 'a') ADVANCE(483); + if (lookahead == 'a') ADVANCE(276); END_STATE(); case 84: - if (lookahead == 'a') ADVANCE(611); - if (lookahead == 'e') ADVANCE(350); + if (lookahead == 'a') ADVANCE(531); END_STATE(); case 85: - if (lookahead == 'a') ADVANCE(392); + if (lookahead == 'a') ADVANCE(623); + if (lookahead == 'e') ADVANCE(353); END_STATE(); case 86: - if (lookahead == 'a') ADVANCE(121); - if (lookahead == 'o') ADVANCE(480); + if (lookahead == 'a') ADVANCE(397); END_STATE(); case 87: - if (lookahead == 'a') ADVANCE(563); - if (lookahead == 'i') ADVANCE(117); + if (lookahead == 'a') ADVANCE(120); + if (lookahead == 'o') ADVANCE(485); END_STATE(); case 88: - if (lookahead == 'a') ADVANCE(563); - if (lookahead == 'i') ADVANCE(122); + if (lookahead == 'a') ADVANCE(573); + if (lookahead == 'i') ADVANCE(116); END_STATE(); case 89: - if (lookahead == 'a') ADVANCE(563); - if (lookahead == 'i') ADVANCE(130); + if (lookahead == 'a') ADVANCE(573); + if (lookahead == 'i') ADVANCE(128); END_STATE(); case 90: - if (lookahead == 'a') ADVANCE(124); + if (lookahead == 'a') ADVANCE(575); END_STATE(); case 91: - if (lookahead == 'a') ADVANCE(565); + if (lookahead == 'a') ADVANCE(576); END_STATE(); case 92: - if (lookahead == 'a') ADVANCE(566); + if (lookahead == 'a') ADVANCE(577); END_STATE(); case 93: - if (lookahead == 'a') ADVANCE(324); - if (lookahead == 'e') ADVANCE(437); - if (lookahead == 'r') ADVANCE(88); + if (lookahead == 'a') ADVANCE(329); + if (lookahead == 'r') ADVANCE(289); END_STATE(); case 94: - if (lookahead == 'a') ADVANCE(568); + if (lookahead == 'a') ADVANCE(578); END_STATE(); case 95: - if (lookahead == 'a') ADVANCE(569); + if (lookahead == 'a') ADVANCE(579); END_STATE(); case 96: - if (lookahead == 'a') ADVANCE(570); + if (lookahead == 'a') ADVANCE(339); END_STATE(); case 97: - if (lookahead == 'a') ADVANCE(334); + if (lookahead == 'a') ADVANCE(592); END_STATE(); case 98: - if (lookahead == 'a') ADVANCE(582); + if (lookahead == 'a') ADVANCE(248); END_STATE(); case 99: - if (lookahead == 'a') ADVANCE(248); + if (lookahead == 'b') ADVANCE(322); END_STATE(); case 100: - if (lookahead == 'b') ADVANCE(317); + if (lookahead == 'b') ADVANCE(283); END_STATE(); case 101: - if (lookahead == 'b') ADVANCE(281); + if (lookahead == 'b') ADVANCE(283); + if (lookahead == 'c') ADVANCE(305); + if (lookahead == 'l') ADVANCE(232); END_STATE(); case 102: - if (lookahead == 'b') ADVANCE(281); - if (lookahead == 'c') ADVANCE(301); - if (lookahead == 'l') ADVANCE(230); + if (lookahead == 'b') ADVANCE(344); END_STATE(); case 103: - if (lookahead == 'b') ADVANCE(339); + if (lookahead == 'c') ADVANCE(262); + if (lookahead == 'm') ADVANCE(419); END_STATE(); case 104: - if (lookahead == 'c') ADVANCE(261); - if (lookahead == 'm') ADVANCE(414); + if (lookahead == 'c') ADVANCE(752); END_STATE(); case 105: - if (lookahead == 'c') ADVANCE(733); + if (lookahead == 'c') ADVANCE(594); END_STATE(); case 106: - if (lookahead == 'c') ADVANCE(585); + if (lookahead == 'c') ADVANCE(260); END_STATE(); case 107: - if (lookahead == 'c') ADVANCE(405); - if (lookahead == 'e') ADVANCE(456); - if (lookahead == 'i') ADVANCE(367); - if (lookahead == 't') ADVANCE(49); + if (lookahead == 'c') ADVANCE(410); + if (lookahead == 'e') ADVANCE(461); + if (lookahead == 'i') ADVANCE(372); + if (lookahead == 't') ADVANCE(47); END_STATE(); case 108: - if (lookahead == 'c') ADVANCE(405); + if (lookahead == 'c') ADVANCE(410); if (lookahead == 't') ADVANCE(93); END_STATE(); case 109: - if (lookahead == 'c') ADVANCE(405); - if (lookahead == 't') ADVANCE(55); + if (lookahead == 'c') ADVANCE(410); + if (lookahead == 't') ADVANCE(52); END_STATE(); case 110: - if (lookahead == 'c') ADVANCE(259); + if (lookahead == 'c') ADVANCE(65); END_STATE(); case 111: - if (lookahead == 'c') ADVANCE(59); + if (lookahead == 'c') ADVANCE(261); END_STATE(); case 112: - if (lookahead == 'c') ADVANCE(260); + if (lookahead == 'c') ADVANCE(628); END_STATE(); case 113: - if (lookahead == 'c') ADVANCE(615); + if (lookahead == 'c') ADVANCE(602); END_STATE(); case 114: - if (lookahead == 'c') ADVANCE(594); + if (lookahead == 'c') ADVANCE(408); END_STATE(); case 115: - if (lookahead == 'c') ADVANCE(403); + if (lookahead == 'c') ADVANCE(562); END_STATE(); case 116: - if (lookahead == 'c') ADVANCE(551); + if (lookahead == 'c') ADVANCE(544); END_STATE(); case 117: - if (lookahead == 'c') ADVANCE(532); + if (lookahead == 'c') ADVANCE(161); END_STATE(); case 118: - if (lookahead == 'c') ADVANCE(431); - if (lookahead == 'n') ADVANCE(499); + if (lookahead == 'c') ADVANCE(323); END_STATE(); case 119: - if (lookahead == 'c') ADVANCE(328); + if (lookahead == 'c') ADVANCE(205); END_STATE(); case 120: - if (lookahead == 'c') ADVANCE(161); + if (lookahead == 'c') ADVANCE(582); END_STATE(); case 121: - if (lookahead == 'c') ADVANCE(573); + if (lookahead == 'c') ADVANCE(555); END_STATE(); case 122: - if (lookahead == 'c') ADVANCE(544); + if (lookahead == 'c') ADVANCE(167); END_STATE(); case 123: - if (lookahead == 'c') ADVANCE(201); + if (lookahead == 'c') ADVANCE(218); END_STATE(); case 124: - if (lookahead == 'c') ADVANCE(571); + if (lookahead == 'c') ADVANCE(431); END_STATE(); case 125: - if (lookahead == 'c') ADVANCE(167); + if (lookahead == 'c') ADVANCE(66); + if (lookahead == 'o') ADVANCE(440); END_STATE(); case 126: - if (lookahead == 'c') ADVANCE(215); + if (lookahead == 'c') ADVANCE(489); END_STATE(); case 127: - if (lookahead == 'c') ADVANCE(64); - if (lookahead == 'o') ADVANCE(434); + if (lookahead == 'c') ADVANCE(274); END_STATE(); case 128: - if (lookahead == 'c') ADVANCE(484); + if (lookahead == 'c') ADVANCE(566); END_STATE(); case 129: - if (lookahead == 'c') ADVANCE(282); + if (lookahead == 'c') ADVANCE(432); END_STATE(); case 130: - if (lookahead == 'c') ADVANCE(557); + if (lookahead == 'c') ADVANCE(73); END_STATE(); case 131: - if (lookahead == 'c') ADVANCE(425); + if (lookahead == 'c') ADVANCE(422); + if (lookahead == 'n') ADVANCE(508); END_STATE(); case 132: - if (lookahead == 'c') ADVANCE(72); + if (lookahead == 'c') ADVANCE(609); END_STATE(); case 133: - if (lookahead == 'c') ADVANCE(424); + if (lookahead == 'd') ADVANCE(715); + if (lookahead == 'm') ADVANCE(439); + if (lookahead == 'n') ADVANCE(719); + if (lookahead == 'r') ADVANCE(482); + if (lookahead == 't') ADVANCE(196); END_STATE(); case 134: - if (lookahead == 'c') ADVANCE(599); + if (lookahead == 'd') ADVANCE(733); END_STATE(); case 135: - if (lookahead == 'd') ADVANCE(702); - if (lookahead == 'm') ADVANCE(433); - if (lookahead == 'n') ADVANCE(706); - if (lookahead == 'r') ADVANCE(478); - if (lookahead == 't') ADVANCE(193); + if (lookahead == 'd') ADVANCE(253); END_STATE(); case 136: - if (lookahead == 'd') ADVANCE(718); + if (lookahead == 'd') ADVANCE(746); END_STATE(); case 137: - if (lookahead == 'd') ADVANCE(253); + if (lookahead == 'd') ADVANCE(678); END_STATE(); case 138: - if (lookahead == 'd') ADVANCE(664); + if (lookahead == 'd') ADVANCE(734); END_STATE(); case 139: - if (lookahead == 'd') ADVANCE(719); + if (lookahead == 'd') ADVANCE(730); END_STATE(); case 140: - if (lookahead == 'd') ADVANCE(715); + if (lookahead == 'd') ADVANCE(16); END_STATE(); case 141: - if (lookahead == 'd') ADVANCE(17); + if (lookahead == 'd') ADVANCE(16); + if (lookahead == 's') ADVANCE(435); END_STATE(); case 142: - if (lookahead == 'd') ADVANCE(17); - if (lookahead == 's') ADVANCE(428); + if (lookahead == 'd') ADVANCE(199); END_STATE(); case 143: - if (lookahead == 'd') ADVANCE(195); + if (lookahead == 'd') ADVANCE(537); END_STATE(); case 144: - if (lookahead == 'd') ADVANCE(526); + if (lookahead == 'd') ADVANCE(271); END_STATE(); case 145: - if (lookahead == 'd') ADVANCE(267); + if (lookahead == 'd') ADVANCE(171); END_STATE(); case 146: - if (lookahead == 'd') ADVANCE(171); + if (lookahead == 'd') ADVANCE(175); END_STATE(); case 147: - if (lookahead == 'd') ADVANCE(174); + if (lookahead == 'd') ADVANCE(178); END_STATE(); case 148: - if (lookahead == 'd') ADVANCE(176); + if (lookahead == 'd') ADVANCE(254); END_STATE(); case 149: - if (lookahead == 'd') ADVANCE(254); + if (lookahead == 'd') ADVANCE(255); END_STATE(); case 150: - if (lookahead == 'd') ADVANCE(596); - if (lookahead == 'm') ADVANCE(441); + if (lookahead == 'd') ADVANCE(604); + if (lookahead == 'm') ADVANCE(447); END_STATE(); case 151: - if (lookahead == 'd') ADVANCE(38); + if (lookahead == 'd') ADVANCE(37); END_STATE(); case 152: if (lookahead == 'e') ADVANCE(240); - if (lookahead == 'i') ADVANCE(458); - if (lookahead == 'o') ADVANCE(106); + if (lookahead == 'i') ADVANCE(464); + if (lookahead == 'o') ADVANCE(105); END_STATE(); case 153: - if (lookahead == 'e') ADVANCE(48); + if (lookahead == 'e') ADVANCE(46); END_STATE(); case 154: - if (lookahead == 'e') ADVANCE(342); - if (lookahead == 'i') ADVANCE(199); - if (lookahead == 'o') ADVANCE(407); - if (lookahead == 'r') ADVANCE(588); + if (lookahead == 'e') ADVANCE(347); + if (lookahead == 'i') ADVANCE(202); + if (lookahead == 'o') ADVANCE(412); + if (lookahead == 'r') ADVANCE(597); END_STATE(); case 155: - if (lookahead == 'e') ADVANCE(351); + if (lookahead == 'e') ADVANCE(354); END_STATE(); case 156: - if (lookahead == 'e') ADVANCE(639); + if (lookahead == 'e') ADVANCE(651); END_STATE(); case 157: - if (lookahead == 'e') ADVANCE(716); + if (lookahead == 'e') ADVANCE(731); END_STATE(); case 158: - if (lookahead == 'e') ADVANCE(741); + if (lookahead == 'e') ADVANCE(760); END_STATE(); case 159: - if (lookahead == 'e') ADVANCE(742); + if (lookahead == 'e') ADVANCE(761); END_STATE(); case 160: - if (lookahead == 'e') ADVANCE(663); + if (lookahead == 'e') ADVANCE(677); END_STATE(); case 161: - if (lookahead == 'e') ADVANCE(730); + if (lookahead == 'e') ADVANCE(749); END_STATE(); case 162: - if (lookahead == 'e') ADVANCE(737); + if (lookahead == 'e') ADVANCE(756); END_STATE(); case 163: - if (lookahead == 'e') ADVANCE(676); + if (lookahead == 'e') ADVANCE(690); END_STATE(); case 164: - if (lookahead == 'e') ADVANCE(714); + if (lookahead == 'e') ADVANCE(729); END_STATE(); case 165: - if (lookahead == 'e') ADVANCE(662); + if (lookahead == 'e') ADVANCE(676); END_STATE(); case 166: - if (lookahead == 'e') ADVANCE(643); + if (lookahead == 'e') ADVANCE(655); END_STATE(); case 167: - if (lookahead == 'e') ADVANCE(670); + if (lookahead == 'e') ADVANCE(684); END_STATE(); case 168: - if (lookahead == 'e') ADVANCE(666); + if (lookahead == 'e') ADVANCE(680); END_STATE(); case 169: - if (lookahead == 'e') ADVANCE(698); + if (lookahead == 'e') ADVANCE(711); END_STATE(); case 170: - if (lookahead == 'e') ADVANCE(709); + if (lookahead == 'e') ADVANCE(724); END_STATE(); case 171: - if (lookahead == 'e') ADVANCE(692); + if (lookahead == 'e') ADVANCE(705); END_STATE(); case 172: - if (lookahead == 'e') ADVANCE(691); + if (lookahead == 'e') ADVANCE(704); END_STATE(); case 173: - if (lookahead == 'e') ADVANCE(432); + if (lookahead == 'e') ADVANCE(438); + if (lookahead == 'i') ADVANCE(519); END_STATE(); case 174: - if (lookahead == 'e') ADVANCE(625); + if (lookahead == 'e') ADVANCE(69); END_STATE(); case 175: - if (lookahead == 'e') ADVANCE(661); + if (lookahead == 'e') ADVANCE(638); END_STATE(); case 176: - if (lookahead == 'e') ADVANCE(723); + if (lookahead == 'e') ADVANCE(675); END_STATE(); case 177: if (lookahead == 'e') ADVANCE(70); END_STATE(); case 178: - if (lookahead == 'e') ADVANCE(607); + if (lookahead == 'e') ADVANCE(738); END_STATE(); case 179: - if (lookahead == 'e') ADVANCE(63); + if (lookahead == 'e') ADVANCE(617); END_STATE(); case 180: - if (lookahead == 'e') ADVANCE(609); + if (lookahead == 'e') ADVANCE(63); END_STATE(); case 181: - if (lookahead == 'e') ADVANCE(447); + if (lookahead == 'e') ADVANCE(620); END_STATE(); case 182: - if (lookahead == 'e') ADVANCE(252); + if (lookahead == 'e') ADVANCE(454); END_STATE(); case 183: - if (lookahead == 'e') ADVANCE(600); + if (lookahead == 'e') ADVANCE(373); END_STATE(); case 184: - if (lookahead == 'e') ADVANCE(477); + if (lookahead == 'e') ADVANCE(252); END_STATE(); case 185: - if (lookahead == 'e') ADVANCE(373); + if (lookahead == 'e') ADVANCE(610); END_STATE(); case 186: - if (lookahead == 'e') ADVANCE(373); - if (lookahead == 't') ADVANCE(258); + if (lookahead == 'e') ADVANCE(481); END_STATE(); case 187: - if (lookahead == 'e') ADVANCE(138); + if (lookahead == 'e') ADVANCE(34); END_STATE(); case 188: - if (lookahead == 'e') ADVANCE(35); + if (lookahead == 'e') ADVANCE(540); END_STATE(); case 189: - if (lookahead == 'e') ADVANCE(372); - if (lookahead == 'l') ADVANCE(422); + if (lookahead == 'e') ADVANCE(137); END_STATE(); case 190: - if (lookahead == 'e') ADVANCE(375); + if (lookahead == 'e') ADVANCE(378); END_STATE(); case 191: - if (lookahead == 'e') ADVANCE(131); + if (lookahead == 'e') ADVANCE(378); + if (lookahead == 't') ADVANCE(259); END_STATE(); case 192: - if (lookahead == 'e') ADVANCE(246); + if (lookahead == 'e') ADVANCE(129); END_STATE(); case 193: - if (lookahead == 'e') ADVANCE(469); + if (lookahead == 'e') ADVANCE(246); END_STATE(); case 194: - if (lookahead == 'e') ADVANCE(140); + if (lookahead == 'e') ADVANCE(376); + if (lookahead == 'l') ADVANCE(429); END_STATE(); case 195: - if (lookahead == 'e') ADVANCE(304); + if (lookahead == 'e') ADVANCE(17); END_STATE(); case 196: - if (lookahead == 'e') ADVANCE(18); + if (lookahead == 'e') ADVANCE(468); END_STATE(); case 197: - if (lookahead == 'e') ADVANCE(473); + if (lookahead == 'e') ADVANCE(380); END_STATE(); case 198: - if (lookahead == 'e') ADVANCE(410); + if (lookahead == 'e') ADVANCE(139); END_STATE(); case 199: - if (lookahead == 'e') ADVANCE(462); - if (lookahead == 'm') ADVANCE(198); + if (lookahead == 'e') ADVANCE(308); END_STATE(); case 200: - if (lookahead == 'e') ADVANCE(29); + if (lookahead == 'e') ADVANCE(477); END_STATE(); case 201: - if (lookahead == 'e') ADVANCE(498); + if (lookahead == 'e') ADVANCE(416); END_STATE(); case 202: - if (lookahead == 'e') ADVANCE(306); + if (lookahead == 'e') ADVANCE(469); + if (lookahead == 'm') ADVANCE(201); END_STATE(); case 203: - if (lookahead == 'e') ADVANCE(520); + if (lookahead == 'e') ADVANCE(399); END_STATE(); case 204: - if (lookahead == 'e') ADVANCE(479); + if (lookahead == 'e') ADVANCE(28); END_STATE(); case 205: - if (lookahead == 'e') ADVANCE(32); + if (lookahead == 'e') ADVANCE(507); END_STATE(); case 206: - if (lookahead == 'e') ADVANCE(482); + if (lookahead == 'e') ADVANCE(31); END_STATE(); case 207: - if (lookahead == 'e') ADVANCE(556); + if (lookahead == 'e') ADVANCE(530); END_STATE(); case 208: - if (lookahead == 'e') ADVANCE(463); + if (lookahead == 'e') ADVANCE(310); END_STATE(); case 209: - if (lookahead == 'e') ADVANCE(501); + if (lookahead == 'e') ADVANCE(484); END_STATE(); case 210: - if (lookahead == 'e') ADVANCE(486); + if (lookahead == 'e') ADVANCE(490); END_STATE(); case 211: - if (lookahead == 'e') ADVANCE(68); + if (lookahead == 'e') ADVANCE(568); END_STATE(); case 212: - if (lookahead == 'e') ADVANCE(309); + if (lookahead == 'e') ADVANCE(470); END_STATE(); case 213: - if (lookahead == 'e') ADVANCE(20); + if (lookahead == 'e') ADVANCE(510); END_STATE(); case 214: - if (lookahead == 'e') ADVANCE(481); + if (lookahead == 'e') ADVANCE(488); END_STATE(); case 215: - if (lookahead == 'e') ADVANCE(505); + if (lookahead == 'e') ADVANCE(19); END_STATE(); case 216: - if (lookahead == 'e') ADVANCE(466); + if (lookahead == 'e') ADVANCE(313); END_STATE(); case 217: - if (lookahead == 'e') ADVANCE(467); + if (lookahead == 'e') ADVANCE(491); END_STATE(); case 218: - if (lookahead == 'e') ADVANCE(368); + if (lookahead == 'e') ADVANCE(514); END_STATE(); case 219: - if (lookahead == 'e') ADVANCE(114); - if (lookahead == 'p') ADVANCE(189); - if (lookahead == 't') ADVANCE(475); + if (lookahead == 'e') ADVANCE(486); END_STATE(); case 220: - if (lookahead == 'e') ADVANCE(358); - if (lookahead == 'i') ADVANCE(199); - if (lookahead == 'o') ADVANCE(407); + if (lookahead == 'e') ADVANCE(473); END_STATE(); case 221: - if (lookahead == 'e') ADVANCE(357); + if (lookahead == 'e') ADVANCE(474); END_STATE(); case 222: - if (lookahead == 'e') ADVANCE(426); + if (lookahead == 'e') ADVANCE(496); END_STATE(); case 223: - if (lookahead == 'e') ADVANCE(370); + if (lookahead == 'e') ADVANCE(113); + if (lookahead == 'p') ADVANCE(194); + if (lookahead == 't') ADVANCE(480); END_STATE(); case 224: - if (lookahead == 'e') ADVANCE(370); - if (lookahead == 'p') ADVANCE(436); + if (lookahead == 'e') ADVANCE(361); + if (lookahead == 'i') ADVANCE(202); + if (lookahead == 'o') ADVANCE(412); END_STATE(); case 225: - if (lookahead == 'e') ADVANCE(343); - if (lookahead == 'i') ADVANCE(199); - if (lookahead == 'o') ADVANCE(407); + if (lookahead == 'e') ADVANCE(360); END_STATE(); case 226: - if (lookahead == 'e') ADVANCE(525); + if (lookahead == 'e') ADVANCE(377); END_STATE(); case 227: - if (lookahead == 'e') ADVANCE(485); + if (lookahead == 'e') ADVANCE(377); + if (lookahead == 'p') ADVANCE(442); END_STATE(); case 228: - if (lookahead == 'e') ADVANCE(383); + if (lookahead == 'e') ADVANCE(433); END_STATE(); case 229: - if (lookahead == 'e') ADVANCE(359); + if (lookahead == 'e') ADVANCE(348); + if (lookahead == 'i') ADVANCE(202); + if (lookahead == 'o') ADVANCE(412); END_STATE(); case 230: if (lookahead == 'e') ADVANCE(389); END_STATE(); case 231: - if (lookahead == 'e') ADVANCE(523); + if (lookahead == 'e') ADVANCE(533); END_STATE(); case 232: - if (lookahead == 'e') ADVANCE(388); + if (lookahead == 'e') ADVANCE(393); END_STATE(); case 233: - if (lookahead == 'e') ADVANCE(393); + if (lookahead == 'e') ADVANCE(362); + if (lookahead == 'i') ADVANCE(222); END_STATE(); case 234: - if (lookahead == 'e') ADVANCE(394); + if (lookahead == 'e') ADVANCE(392); END_STATE(); case 235: - if (lookahead == 'e') ADVANCE(134); + if (lookahead == 'e') ADVANCE(394); END_STATE(); case 236: - if (lookahead == 'e') ADVANCE(134); - if (lookahead == 'p') ADVANCE(315); + if (lookahead == 'e') ADVANCE(132); END_STATE(); case 237: - if (lookahead == 'e') ADVANCE(43); + if (lookahead == 'e') ADVANCE(41); END_STATE(); case 238: if (lookahead == 'f') ADVANCE(242); - if (lookahead == 's') ADVANCE(111); - if (lookahead == 'x') ADVANCE(219); + if (lookahead == 's') ADVANCE(110); + if (lookahead == 'x') ADVANCE(223); END_STATE(); case 239: - if (lookahead == 'f') ADVANCE(683); + if (lookahead == 'f') ADVANCE(696); END_STATE(); case 240: if (lookahead == 'f') ADVANCE(58); - if (lookahead == 'p') ADVANCE(186); - if (lookahead == 's') ADVANCE(128); + if (lookahead == 'p') ADVANCE(191); + if (lookahead == 's') ADVANCE(126); END_STATE(); case 241: - if (lookahead == 'f') ADVANCE(614); + if (lookahead == 'f') ADVANCE(627); END_STATE(); case 242: - if (lookahead == 'f') ADVANCE(412); + if (lookahead == 'f') ADVANCE(418); END_STATE(); case 243: - if (lookahead == 'f') ADVANCE(318); + if (lookahead == 'f') ADVANCE(324); END_STATE(); case 244: - if (lookahead == 'f') ADVANCE(276); + if (lookahead == 'f') ADVANCE(277); END_STATE(); case 245: - if (lookahead == 'f') ADVANCE(420); + if (lookahead == 'f') ADVANCE(427); END_STATE(); case 246: - if (lookahead == 'f') ADVANCE(291); + if (lookahead == 'f') ADVANCE(290); END_STATE(); case 247: - if (lookahead == 'f') ADVANCE(576); + if (lookahead == 'f') ADVANCE(586); END_STATE(); case 248: - if (lookahead == 'f') ADVANCE(577); + if (lookahead == 'f') ADVANCE(587); END_STATE(); case 249: - if (lookahead == 'g') ADVANCE(647); + if (lookahead == 'g') ADVANCE(659); END_STATE(); case 250: - if (lookahead == 'g') ADVANCE(218); - if (lookahead == 'n') ADVANCE(136); - if (lookahead == 't') ADVANCE(548); + if (lookahead == 'g') ADVANCE(183); END_STATE(); case 251: - if (lookahead == 'g') ADVANCE(218); - if (lookahead == 't') ADVANCE(548); + if (lookahead == 'g') ADVANCE(183); + if (lookahead == 'n') ADVANCE(134); + if (lookahead == 't') ADVANCE(558); END_STATE(); case 252: - if (lookahead == 'g') ADVANCE(616); + if (lookahead == 'g') ADVANCE(629); END_STATE(); case 253: if (lookahead == 'g') ADVANCE(188); END_STATE(); case 254: - if (lookahead == 'g') ADVANCE(169); + if (lookahead == 'g') ADVANCE(187); END_STATE(); case 255: - if (lookahead == 'g') ADVANCE(325); + if (lookahead == 'g') ADVANCE(169); END_STATE(); case 256: - if (lookahead == 'g') ADVANCE(233); - if (lookahead == 'n') ADVANCE(136); - if (lookahead == 't') ADVANCE(548); + if (lookahead == 'g') ADVANCE(331); END_STATE(); case 257: - if (lookahead == 'g') ADVANCE(233); - if (lookahead == 't') ADVANCE(548); + if (lookahead == 'g') ADVANCE(235); END_STATE(); case 258: - if (lookahead == 'h') ADVANCE(685); + if (lookahead == 'g') ADVANCE(235); + if (lookahead == 'n') ADVANCE(134); + if (lookahead == 't') ADVANCE(558); END_STATE(); case 259: - if (lookahead == 'h') ADVANCE(28); + if (lookahead == 'h') ADVANCE(698); END_STATE(); case 260: - if (lookahead == 'h') ADVANCE(76); + if (lookahead == 'h') ADVANCE(27); END_STATE(); case 261: - if (lookahead == 'h') ADVANCE(67); + if (lookahead == 'h') ADVANCE(83); END_STATE(); case 262: - if (lookahead == 'i') ADVANCE(224); + if (lookahead == 'h') ADVANCE(68); END_STATE(); case 263: - if (lookahead == 'i') ADVANCE(601); - if (lookahead == 'o') ADVANCE(150); + if (lookahead == 'i') ADVANCE(227); END_STATE(); case 264: - if (lookahead == 'i') ADVANCE(241); + if (lookahead == 'i') ADVANCE(611); + if (lookahead == 'o') ADVANCE(150); END_STATE(); case 265: - if (lookahead == 'i') ADVANCE(348); + if (lookahead == 'i') ADVANCE(241); END_STATE(); case 266: - if (lookahead == 'i') ADVANCE(352); + if (lookahead == 'i') ADVANCE(356); END_STATE(); case 267: - if (lookahead == 'i') ADVANCE(378); + if (lookahead == 'i') ADVANCE(355); END_STATE(); case 268: - if (lookahead == 'i') ADVANCE(305); + if (lookahead == 'i') ADVANCE(309); END_STATE(); case 269: - if (lookahead == 'i') ADVANCE(105); + if (lookahead == 'i') ADVANCE(104); END_STATE(); case 270: - if (lookahead == 'i') ADVANCE(451); + if (lookahead == 'i') ADVANCE(457); END_STATE(); case 271: - if (lookahead == 'i') ADVANCE(369); + if (lookahead == 'i') ADVANCE(383); END_STATE(); case 272: - if (lookahead == 'i') ADVANCE(439); + if (lookahead == 'i') ADVANCE(445); END_STATE(); case 273: - if (lookahead == 'i') ADVANCE(178); + if (lookahead == 'i') ADVANCE(179); END_STATE(); case 274: - if (lookahead == 'i') ADVANCE(365); + if (lookahead == 'i') ADVANCE(326); END_STATE(); case 275: - if (lookahead == 'i') ADVANCE(550); + if (lookahead == 'i') ADVANCE(560); END_STATE(); case 276: - if (lookahead == 'i') ADVANCE(491); + if (lookahead == 'i') ADVANCE(369); END_STATE(); case 277: - if (lookahead == 'i') ADVANCE(538); + if (lookahead == 'i') ADVANCE(499); END_STATE(); case 278: - if (lookahead == 'i') ADVANCE(541); + if (lookahead == 'i') ADVANCE(550); END_STATE(); case 279: - if (lookahead == 'i') ADVANCE(209); + if (lookahead == 'i') ADVANCE(553); END_STATE(); case 280: - if (lookahead == 'i') ADVANCE(602); + if (lookahead == 'i') ADVANCE(213); END_STATE(); case 281: - if (lookahead == 'i') ADVANCE(323); + if (lookahead == 'i') ADVANCE(374); END_STATE(); case 282: - if (lookahead == 'i') ADVANCE(322); + if (lookahead == 'i') ADVANCE(612); END_STATE(); case 283: - if (lookahead == 'i') ADVANCE(559); + if (lookahead == 'i') ADVANCE(328); END_STATE(); case 284: - if (lookahead == 'i') ADVANCE(386); + if (lookahead == 'i') ADVANCE(569); END_STATE(); case 285: - if (lookahead == 'i') ADVANCE(71); + if (lookahead == 'i') ADVANCE(391); END_STATE(); case 286: - if (lookahead == 'i') ADVANCE(387); - if (lookahead == 'r') ADVANCE(192); + if (lookahead == 'i') ADVANCE(71); END_STATE(); case 287: - if (lookahead == 'i') ADVANCE(327); + if (lookahead == 'i') ADVANCE(398); + if (lookahead == 'r') ADVANCE(193); END_STATE(); case 288: - if (lookahead == 'i') ADVANCE(564); - if (lookahead == 'p') ADVANCE(83); - if (lookahead == 'r') ADVANCE(207); + if (lookahead == 'i') ADVANCE(332); END_STATE(); case 289: - if (lookahead == 'i') ADVANCE(564); - if (lookahead == 'p') ADVANCE(83); - if (lookahead == 'r') ADVANCE(207); - if (lookahead == 's') ADVANCE(442); + if (lookahead == 'i') ADVANCE(121); END_STATE(); case 290: - if (lookahead == 'i') ADVANCE(415); + if (lookahead == 'i') ADVANCE(395); END_STATE(); case 291: - if (lookahead == 'i') ADVANCE(390); + if (lookahead == 'i') ADVANCE(421); END_STATE(); case 292: - if (lookahead == 'i') ADVANCE(73); + if (lookahead == 'i') ADVANCE(74); END_STATE(); case 293: - if (lookahead == 'i') ADVANCE(417); + if (lookahead == 'i') ADVANCE(424); END_STATE(); case 294: - if (lookahead == 'i') ADVANCE(427); + if (lookahead == 'i') ADVANCE(434); END_STATE(); case 295: - if (lookahead == 'i') ADVANCE(418); + if (lookahead == 'i') ADVANCE(426); END_STATE(); case 296: - if (lookahead == 'i') ADVANCE(132); + if (lookahead == 'i') ADVANCE(130); END_STATE(); case 297: - if (lookahead == 'i') ADVANCE(223); + if (lookahead == 'i') ADVANCE(128); END_STATE(); case 298: - if (lookahead == 'j') ADVANCE(593); + if (lookahead == 'i') ADVANCE(585); + if (lookahead == 'p') ADVANCE(72); + if (lookahead == 'r') ADVANCE(211); END_STATE(); case 299: - if (lookahead == 'k') ADVANCE(713); + if (lookahead == 'i') ADVANCE(585); + if (lookahead == 'p') ADVANCE(72); + if (lookahead == 'r') ADVANCE(211); + if (lookahead == 's') ADVANCE(446); END_STATE(); case 300: - if (lookahead == 'k') ADVANCE(243); + if (lookahead == 'i') ADVANCE(585); + if (lookahead == 'r') ADVANCE(211); END_STATE(); case 301: - if (lookahead == 'k') ADVANCE(194); + if (lookahead == 'i') ADVANCE(226); END_STATE(); case 302: - if (lookahead == 'l') ADVANCE(262); - if (lookahead == 'o') ADVANCE(346); + if (lookahead == 'j') ADVANCE(606); END_STATE(); case 303: - if (lookahead == 'l') ADVANCE(518); + if (lookahead == 'k') ADVANCE(728); END_STATE(); case 304: - if (lookahead == 'l') ADVANCE(631); + if (lookahead == 'k') ADVANCE(243); END_STATE(); case 305: - if (lookahead == 'l') ADVANCE(717); + if (lookahead == 'k') ADVANCE(198); END_STATE(); case 306: - if (lookahead == 'l') ADVANCE(707); + if (lookahead == 'l') ADVANCE(528); END_STATE(); case 307: - if (lookahead == 'l') ADVANCE(651); + if (lookahead == 'l') ADVANCE(745); END_STATE(); case 308: - if (lookahead == 'l') ADVANCE(708); + if (lookahead == 'l') ADVANCE(645); END_STATE(); case 309: - if (lookahead == 'l') ADVANCE(722); + if (lookahead == 'l') ADVANCE(732); END_STATE(); case 310: - if (lookahead == 'l') ADVANCE(495); + if (lookahead == 'l') ADVANCE(722); END_STATE(); case 311: - if (lookahead == 'l') ADVANCE(156); + if (lookahead == 'l') ADVANCE(663); END_STATE(); case 312: - if (lookahead == 'l') ADVANCE(36); + if (lookahead == 'l') ADVANCE(723); END_STATE(); case 313: - if (lookahead == 'l') ADVANCE(617); + if (lookahead == 'l') ADVANCE(737); END_STATE(); case 314: - if (lookahead == 'l') ADVANCE(91); + if (lookahead == 'l') ADVANCE(504); END_STATE(); case 315: - if (lookahead == 'l') ADVANCE(422); + if (lookahead == 'l') ADVANCE(35); END_STATE(); case 316: - if (lookahead == 'l') ADVANCE(619); + if (lookahead == 'l') ADVANCE(156); END_STATE(); case 317: - if (lookahead == 'l') ADVANCE(269); + if (lookahead == 'l') ADVANCE(307); END_STATE(); case 318: - if (lookahead == 'l') ADVANCE(404); + if (lookahead == 'l') ADVANCE(630); END_STATE(); case 319: - if (lookahead == 'l') ADVANCE(534); + if (lookahead == 'l') ADVANCE(90); END_STATE(); case 320: - if (lookahead == 'l') ADVANCE(31); + if (lookahead == 'l') ADVANCE(632); END_STATE(); case 321: - if (lookahead == 'l') ADVANCE(265); - if (lookahead == 'n') ADVANCE(496); - if (lookahead == 'o') ADVANCE(380); - if (lookahead == 'q') ADVANCE(598); + if (lookahead == 'l') ADVANCE(429); END_STATE(); case 322: - if (lookahead == 'l') ADVANCE(80); + if (lookahead == 'l') ADVANCE(269); END_STATE(); case 323: - if (lookahead == 'l') ADVANCE(275); + if (lookahead == 'l') ADVANCE(607); END_STATE(); case 324: - if (lookahead == 'l') ADVANCE(230); + if (lookahead == 'l') ADVANCE(409); END_STATE(); case 325: - if (lookahead == 'l') ADVANCE(200); + if (lookahead == 'l') ADVANCE(546); END_STATE(); case 326: - if (lookahead == 'l') ADVANCE(272); - if (lookahead == 'o') ADVANCE(345); + if (lookahead == 'l') ADVANCE(80); END_STATE(); case 327: - if (lookahead == 'l') ADVANCE(163); + if (lookahead == 'l') ADVANCE(266); + if (lookahead == 'n') ADVANCE(505); + if (lookahead == 'o') ADVANCE(385); + if (lookahead == 'q') ADVANCE(608); END_STATE(); case 328: - if (lookahead == 'l') ADVANCE(597); + if (lookahead == 'l') ADVANCE(275); END_STATE(); case 329: - if (lookahead == 'l') ADVANCE(331); + if (lookahead == 'l') ADVANCE(232); END_STATE(); case 330: - if (lookahead == 'l') ADVANCE(202); + if (lookahead == 'l') ADVANCE(272); + if (lookahead == 'o') ADVANCE(351); END_STATE(); case 331: if (lookahead == 'l') ADVANCE(204); END_STATE(); case 332: - if (lookahead == 'l') ADVANCE(212); + if (lookahead == 'l') ADVANCE(163); END_STATE(); case 333: - if (lookahead == 'l') ADVANCE(330); - if (lookahead == 'm') ADVANCE(732); + if (lookahead == 'l') ADVANCE(336); END_STATE(); case 334: - if (lookahead == 'l') ADVANCE(332); + if (lookahead == 'l') ADVANCE(208); END_STATE(); case 335: - if (lookahead == 'l') ADVANCE(92); + if (lookahead == 'l') ADVANCE(30); END_STATE(); case 336: - if (lookahead == 'l') ADVANCE(94); + if (lookahead == 'l') ADVANCE(209); END_STATE(); case 337: - if (lookahead == 'l') ADVANCE(95); + if (lookahead == 'l') ADVANCE(216); END_STATE(); case 338: - if (lookahead == 'l') ADVANCE(96); + if (lookahead == 'l') ADVANCE(334); + if (lookahead == 'm') ADVANCE(751); END_STATE(); case 339: - if (lookahead == 'l') ADVANCE(237); + if (lookahead == 'l') ADVANCE(337); END_STATE(); case 340: - if (lookahead == 'm') ADVANCE(349); - if (lookahead == 'n') ADVANCE(512); - if (lookahead == 'o') ADVANCE(474); + if (lookahead == 'l') ADVANCE(91); END_STATE(); case 341: - if (lookahead == 'm') ADVANCE(732); + if (lookahead == 'l') ADVANCE(92); END_STATE(); case 342: - if (lookahead == 'm') ADVANCE(452); - if (lookahead == 's') ADVANCE(527); + if (lookahead == 'l') ADVANCE(94); END_STATE(); case 343: - if (lookahead == 'm') ADVANCE(452); - if (lookahead == 's') ADVANCE(545); + if (lookahead == 'l') ADVANCE(95); END_STATE(); case 344: - if (lookahead == 'm') ADVANCE(448); - if (lookahead == 'r') ADVANCE(478); - if (lookahead == 't') ADVANCE(193); + if (lookahead == 'l') ADVANCE(237); END_STATE(); case 345: - if (lookahead == 'm') ADVANCE(438); + if (lookahead == 'm') ADVANCE(352); + if (lookahead == 'n') ADVANCE(536); + if (lookahead == 'o') ADVANCE(479); END_STATE(); case 346: - if (lookahead == 'm') ADVANCE(438); - if (lookahead == 'n') ADVANCE(512); + if (lookahead == 'm') ADVANCE(751); END_STATE(); case 347: - if (lookahead == 'm') ADVANCE(423); + if (lookahead == 'm') ADVANCE(456); + if (lookahead == 's') ADVANCE(538); END_STATE(); case 348: - if (lookahead == 'm') ADVANCE(277); + if (lookahead == 'm') ADVANCE(456); + if (lookahead == 's') ADVANCE(556); END_STATE(); case 349: - if (lookahead == 'm') ADVANCE(81); - if (lookahead == 'p') ADVANCE(287); + if (lookahead == 'm') ADVANCE(453); + if (lookahead == 'r') ADVANCE(482); + if (lookahead == 't') ADVANCE(196); END_STATE(); case 350: - if (lookahead == 'm') ADVANCE(414); + if (lookahead == 'm') ADVANCE(430); END_STATE(); case 351: - if (lookahead == 'm') ADVANCE(443); + if (lookahead == 'm') ADVANCE(444); + if (lookahead == 'n') ADVANCE(536); END_STATE(); case 352: - if (lookahead == 'm') ADVANCE(222); + if (lookahead == 'm') ADVANCE(82); + if (lookahead == 'p') ADVANCE(288); END_STATE(); case 353: - if (lookahead == 'm') ADVANCE(228); + if (lookahead == 'm') ADVANCE(419); END_STATE(); case 354: - if (lookahead == 'm') ADVANCE(449); + if (lookahead == 'm') ADVANCE(448); END_STATE(); case 355: - if (lookahead == 'm') ADVANCE(430); + if (lookahead == 'm') ADVANCE(228); END_STATE(); case 356: - if (lookahead == 'm') ADVANCE(450); - if (lookahead == 'n') ADVANCE(119); + if (lookahead == 'm') ADVANCE(278); END_STATE(); case 357: - if (lookahead == 'm') ADVANCE(453); + if (lookahead == 'm') ADVANCE(230); END_STATE(); case 358: - if (lookahead == 'm') ADVANCE(454); - if (lookahead == 's') ADVANCE(543); + if (lookahead == 'm') ADVANCE(437); END_STATE(); case 359: if (lookahead == 'm') ADVANCE(455); - if (lookahead == 's') ADVANCE(558); + if (lookahead == 'n') ADVANCE(118); END_STATE(); case 360: - if (lookahead == 'n') ADVANCE(728); + if (lookahead == 'm') ADVANCE(458); END_STATE(); case 361: - if (lookahead == 'n') ADVANCE(649); + if (lookahead == 'm') ADVANCE(459); + if (lookahead == 's') ADVANCE(572); END_STATE(); case 362: - if (lookahead == 'n') ADVANCE(731); + if (lookahead == 'm') ADVANCE(460); + if (lookahead == 's') ADVANCE(567); END_STATE(); case 363: - if (lookahead == 'n') ADVANCE(656); + if (lookahead == 'n') ADVANCE(670); END_STATE(); case 364: - if (lookahead == 'n') ADVANCE(655); + if (lookahead == 'n') ADVANCE(747); END_STATE(); case 365: - if (lookahead == 'n') ADVANCE(699); + if (lookahead == 'n') ADVANCE(661); END_STATE(); case 366: - if (lookahead == 'n') ADVANCE(549); + if (lookahead == 'n') ADVANCE(750); END_STATE(); case 367: - if (lookahead == 'n') ADVANCE(255); + if (lookahead == 'n') ADVANCE(668); END_STATE(); case 368: - if (lookahead == 'n') ADVANCE(528); + if (lookahead == 'n') ADVANCE(667); END_STATE(); case 369: - if (lookahead == 'n') ADVANCE(249); + if (lookahead == 'n') ADVANCE(712); END_STATE(); case 370: - if (lookahead == 'n') ADVANCE(529); + if (lookahead == 'n') ADVANCE(559); END_STATE(); case 371: - if (lookahead == 'n') ADVANCE(110); + if (lookahead == 'n') ADVANCE(559); + if (lookahead == 's') ADVANCE(136); END_STATE(); case 372: - if (lookahead == 'n') ADVANCE(516); + if (lookahead == 'n') ADVANCE(256); END_STATE(); case 373: - if (lookahead == 'n') ADVANCE(144); + if (lookahead == 'n') ADVANCE(539); END_STATE(); case 374: - if (lookahead == 'n') ADVANCE(139); + if (lookahead == 'n') ADVANCE(249); END_STATE(); case 375: - if (lookahead == 'n') ADVANCE(509); + if (lookahead == 'n') ADVANCE(106); END_STATE(); case 376: - if (lookahead == 'n') ADVANCE(157); + if (lookahead == 'n') ADVANCE(526); END_STATE(); case 377: - if (lookahead == 'n') ADVANCE(187); + if (lookahead == 'n') ADVANCE(541); END_STATE(); case 378: - if (lookahead == 'n') ADVANCE(74); + if (lookahead == 'n') ADVANCE(143); END_STATE(); case 379: - if (lookahead == 'n') ADVANCE(129); + if (lookahead == 'n') ADVANCE(138); END_STATE(); case 380: - if (lookahead == 'n') ADVANCE(313); + if (lookahead == 'n') ADVANCE(521); END_STATE(); case 381: - if (lookahead == 'n') ADVANCE(316); + if (lookahead == 'n') ADVANCE(157); END_STATE(); case 382: - if (lookahead == 'n') ADVANCE(296); + if (lookahead == 'n') ADVANCE(189); END_STATE(); case 383: - if (lookahead == 'n') ADVANCE(536); + if (lookahead == 'n') ADVANCE(75); END_STATE(); case 384: - if (lookahead == 'n') ADVANCE(271); + if (lookahead == 'n') ADVANCE(127); END_STATE(); case 385: - if (lookahead == 'n') ADVANCE(504); + if (lookahead == 'n') ADVANCE(318); END_STATE(); case 386: - if (lookahead == 'n') ADVANCE(162); + if (lookahead == 'n') ADVANCE(296); END_STATE(); case 387: - if (lookahead == 'n') ADVANCE(278); + if (lookahead == 'n') ADVANCE(320); END_STATE(); case 388: - if (lookahead == 'n') ADVANCE(542); + if (lookahead == 'n') ADVANCE(281); END_STATE(); case 389: - if (lookahead == 'n') ADVANCE(203); + if (lookahead == 'n') ADVANCE(548); END_STATE(); case 390: - if (lookahead == 'n') ADVANCE(172); + if (lookahead == 'n') ADVANCE(513); END_STATE(); case 391: - if (lookahead == 'n') ADVANCE(511); + if (lookahead == 'n') ADVANCE(162); END_STATE(); case 392: - if (lookahead == 'n') ADVANCE(125); + if (lookahead == 'n') ADVANCE(554); END_STATE(); case 393: - if (lookahead == 'n') ADVANCE(562); + if (lookahead == 'n') ADVANCE(207); END_STATE(); case 394: - if (lookahead == 'n') ADVANCE(579); + if (lookahead == 'n') ADVANCE(574); END_STATE(); case 395: - if (lookahead == 'n') ADVANCE(581); + if (lookahead == 'n') ADVANCE(172); END_STATE(); case 396: - if (lookahead == 'n') ADVANCE(555); + if (lookahead == 'n') ADVANCE(535); END_STATE(); case 397: - if (lookahead == 'n') ADVANCE(42); + if (lookahead == 'n') ADVANCE(122); END_STATE(); case 398: - if (lookahead == 'o') ADVANCE(127); + if (lookahead == 'n') ADVANCE(279); END_STATE(); case 399: - if (lookahead == 'o') ADVANCE(150); + if (lookahead == 'n') ADVANCE(589); END_STATE(); case 400: - if (lookahead == 'o') ADVANCE(739); + if (lookahead == 'n') ADVANCE(591); END_STATE(); case 401: - if (lookahead == 'o') ADVANCE(459); + if (lookahead == 'n') ADVANCE(565); END_STATE(); case 402: - if (lookahead == 'o') ADVANCE(376); + if (lookahead == 'n') ADVANCE(40); END_STATE(); case 403: - if (lookahead == 'o') ADVANCE(603); + if (lookahead == 'o') ADVANCE(465); END_STATE(); case 404: - if (lookahead == 'o') ADVANCE(604); + if (lookahead == 'o') ADVANCE(125); END_STATE(); case 405: - if (lookahead == 'o') ADVANCE(445); + if (lookahead == 'o') ADVANCE(381); END_STATE(); case 406: - if (lookahead == 'o') ADVANCE(299); + if (lookahead == 'o') ADVANCE(150); END_STATE(); case 407: - if (lookahead == 'o') ADVANCE(310); + if (lookahead == 'o') ADVANCE(758); END_STATE(); case 408: - if (lookahead == 'o') ADVANCE(239); + if (lookahead == 'o') ADVANCE(613); END_STATE(); case 409: - if (lookahead == 'o') ADVANCE(461); - if (lookahead == 'r') ADVANCE(283); + if (lookahead == 'o') ADVANCE(614); END_STATE(); case 410: - if (lookahead == 'o') ADVANCE(589); + if (lookahead == 'o') ADVANCE(450); END_STATE(); case 411: - if (lookahead == 'o') ADVANCE(591); + if (lookahead == 'o') ADVANCE(303); END_STATE(); case 412: - if (lookahead == 'o') ADVANCE(476); + if (lookahead == 'o') ADVANCE(314); END_STATE(); case 413: - if (lookahead == 'o') ADVANCE(380); + if (lookahead == 'o') ADVANCE(239); END_STATE(); case 414: - if (lookahead == 'o') ADVANCE(471); + if (lookahead == 'o') ADVANCE(467); + if (lookahead == 'r') ADVANCE(284); END_STATE(); case 415: - if (lookahead == 'o') ADVANCE(361); + if (lookahead == 'o') ADVANCE(363); END_STATE(); case 416: - if (lookahead == 'o') ADVANCE(363); + if (lookahead == 'o') ADVANCE(598); END_STATE(); case 417: - if (lookahead == 'o') ADVANCE(364); + if (lookahead == 'o') ADVANCE(600); END_STATE(); case 418: - if (lookahead == 'o') ADVANCE(397); + if (lookahead == 'o') ADVANCE(483); END_STATE(); case 419: - if (lookahead == 'o') ADVANCE(391); + if (lookahead == 'o') ADVANCE(478); END_STATE(); case 420: - if (lookahead == 'o') ADVANCE(464); + if (lookahead == 'o') ADVANCE(385); END_STATE(); case 421: - if (lookahead == 'o') ADVANCE(465); + if (lookahead == 'o') ADVANCE(365); END_STATE(); case 422: - if (lookahead == 'o') ADVANCE(489); + if (lookahead == 'o') ADVANCE(400); END_STATE(); case 423: - if (lookahead == 'o') ADVANCE(146); + if (lookahead == 'o') ADVANCE(367); END_STATE(); case 424: - if (lookahead == 'o') ADVANCE(446); + if (lookahead == 'o') ADVANCE(368); END_STATE(); case 425: - if (lookahead == 'o') ADVANCE(379); + if (lookahead == 'o') ADVANCE(396); END_STATE(); case 426: - if (lookahead == 'o') ADVANCE(590); + if (lookahead == 'o') ADVANCE(402); END_STATE(); case 427: - if (lookahead == 'o') ADVANCE(385); + if (lookahead == 'o') ADVANCE(471); END_STATE(); case 428: - if (lookahead == 'o') ADVANCE(384); + if (lookahead == 'o') ADVANCE(472); END_STATE(); case 429: - if (lookahead == 'o') ADVANCE(381); + if (lookahead == 'o') ADVANCE(497); END_STATE(); case 430: - if (lookahead == 'o') ADVANCE(148); + if (lookahead == 'o') ADVANCE(145); END_STATE(); case 431: - if (lookahead == 'o') ADVANCE(395); + if (lookahead == 'o') ADVANCE(452); END_STATE(); case 432: - if (lookahead == 'p') ADVANCE(186); - if (lookahead == 's') ADVANCE(128); + if (lookahead == 'o') ADVANCE(384); END_STATE(); case 433: - if (lookahead == 'p') ADVANCE(61); + if (lookahead == 'o') ADVANCE(599); END_STATE(); case 434: - if (lookahead == 'p') ADVANCE(686); + if (lookahead == 'o') ADVANCE(390); END_STATE(); case 435: - if (lookahead == 'p') ADVANCE(641); + if (lookahead == 'o') ADVANCE(388); END_STATE(); case 436: - if (lookahead == 'p') ADVANCE(612); + if (lookahead == 'o') ADVANCE(387); END_STATE(); case 437: - if (lookahead == 'p') ADVANCE(494); + if (lookahead == 'o') ADVANCE(147); END_STATE(); case 438: - if (lookahead == 'p') ADVANCE(287); + if (lookahead == 'p') ADVANCE(191); + if (lookahead == 's') ADVANCE(126); END_STATE(); case 439: - if (lookahead == 'p') ADVANCE(436); + if (lookahead == 'p') ADVANCE(61); END_STATE(); case 440: - if (lookahead == 'p') ADVANCE(83); - if (lookahead == 'r') ADVANCE(207); + if (lookahead == 'p') ADVANCE(699); END_STATE(); case 441: - if (lookahead == 'p') ADVANCE(531); + if (lookahead == 'p') ADVANCE(653); END_STATE(); case 442: - if (lookahead == 'p') ADVANCE(77); + if (lookahead == 'p') ADVANCE(625); END_STATE(); case 443: - if (lookahead == 'p') ADVANCE(553); + if (lookahead == 'p') ADVANCE(503); END_STATE(); case 444: - if (lookahead == 'p') ADVANCE(82); + if (lookahead == 'p') ADVANCE(288); END_STATE(); case 445: - if (lookahead == 'p') ADVANCE(160); + if (lookahead == 'p') ADVANCE(442); END_STATE(); case 446: - if (lookahead == 'p') ADVANCE(168); + if (lookahead == 'p') ADVANCE(78); END_STATE(); case 447: - if (lookahead == 'p') ADVANCE(185); - if (lookahead == 's') ADVANCE(128); + if (lookahead == 'p') ADVANCE(543); END_STATE(); case 448: - if (lookahead == 'p') ADVANCE(60); + if (lookahead == 'p') ADVANCE(563); END_STATE(); case 449: - if (lookahead == 'p') ADVANCE(90); + if (lookahead == 'p') ADVANCE(84); END_STATE(); case 450: - if (lookahead == 'p') ADVANCE(86); + if (lookahead == 'p') ADVANCE(160); END_STATE(); case 451: - if (lookahead == 'p') ADVANCE(580); + if (lookahead == 'p') ADVANCE(321); END_STATE(); case 452: - if (lookahead == 'p') ADVANCE(335); + if (lookahead == 'p') ADVANCE(168); END_STATE(); case 453: - if (lookahead == 'p') ADVANCE(336); + if (lookahead == 'p') ADVANCE(60); END_STATE(); case 454: - if (lookahead == 'p') ADVANCE(337); + if (lookahead == 'p') ADVANCE(190); + if (lookahead == 's') ADVANCE(126); END_STATE(); case 455: - if (lookahead == 'p') ADVANCE(338); + if (lookahead == 'p') ADVANCE(87); END_STATE(); case 456: - if (lookahead == 'q') ADVANCE(592); + if (lookahead == 'p') ADVANCE(340); END_STATE(); case 457: - if (lookahead == 'r') ADVANCE(57); + if (lookahead == 'p') ADVANCE(590); END_STATE(); case 458: - if (lookahead == 'r') ADVANCE(640); - if (lookahead == 's') ADVANCE(115); + if (lookahead == 'p') ADVANCE(341); END_STATE(); case 459: - if (lookahead == 'r') ADVANCE(704); + if (lookahead == 'p') ADVANCE(342); END_STATE(); case 460: - if (lookahead == 'r') ADVANCE(50); - if (lookahead == 't') ADVANCE(574); + if (lookahead == 'p') ADVANCE(343); END_STATE(); case 461: - if (lookahead == 'r') ADVANCE(300); + if (lookahead == 'q') ADVANCE(605); END_STATE(); case 462: - if (lookahead == 'r') ADVANCE(630); + if (lookahead == 'r') ADVANCE(57); END_STATE(); case 463: - if (lookahead == 'r') ADVANCE(729); + if (lookahead == 'r') ADVANCE(57); + if (lookahead == 'u') ADVANCE(135); END_STATE(); case 464: - if (lookahead == 'r') ADVANCE(684); + if (lookahead == 'r') ADVANCE(652); + if (lookahead == 's') ADVANCE(114); END_STATE(); case 465: - if (lookahead == 'r') ADVANCE(645); + if (lookahead == 'r') ADVANCE(717); END_STATE(); case 466: - if (lookahead == 'r') ADVANCE(727); + if (lookahead == 'r') ADVANCE(48); + if (lookahead == 't') ADVANCE(583); END_STATE(); case 467: - if (lookahead == 'r') ADVANCE(697); + if (lookahead == 'r') ADVANCE(304); END_STATE(); case 468: - if (lookahead == 'r') ADVANCE(493); + if (lookahead == 'r') ADVANCE(26); END_STATE(); case 469: - if (lookahead == 'r') ADVANCE(27); + if (lookahead == 'r') ADVANCE(643); END_STATE(); case 470: - if (lookahead == 'r') ADVANCE(66); - if (lookahead == 't') ADVANCE(574); + if (lookahead == 'r') ADVANCE(748); END_STATE(); case 471: - if (lookahead == 'r') ADVANCE(613); + if (lookahead == 'r') ADVANCE(697); END_STATE(); case 472: - if (lookahead == 'r') ADVANCE(478); - if (lookahead == 't') ADVANCE(193); + if (lookahead == 'r') ADVANCE(657); END_STATE(); case 473: - if (lookahead == 'r') ADVANCE(40); + if (lookahead == 'r') ADVANCE(742); END_STATE(); case 474: - if (lookahead == 'r') ADVANCE(145); + if (lookahead == 'r') ADVANCE(710); END_STATE(); case 475: - if (lookahead == 'r') ADVANCE(51); + if (lookahead == 'r') ADVANCE(482); + if (lookahead == 't') ADVANCE(196); END_STATE(); case 476: - if (lookahead == 'r') ADVANCE(530); + if (lookahead == 'r') ADVANCE(502); END_STATE(); case 477: - if (lookahead == 'r') ADVANCE(264); + if (lookahead == 'r') ADVANCE(38); END_STATE(); case 478: - if (lookahead == 'r') ADVANCE(191); + if (lookahead == 'r') ADVANCE(626); END_STATE(); case 479: - if (lookahead == 'r') ADVANCE(510); + if (lookahead == 'r') ADVANCE(144); END_STATE(); case 480: - if (lookahead == 'r') ADVANCE(578); + if (lookahead == 'r') ADVANCE(49); END_STATE(); case 481: - if (lookahead == 'r') ADVANCE(620); + if (lookahead == 'r') ADVANCE(265); END_STATE(); case 482: - if (lookahead == 'r') ADVANCE(360); + if (lookahead == 'r') ADVANCE(192); END_STATE(); case 483: - if (lookahead == 'r') ADVANCE(97); + if (lookahead == 'r') ADVANCE(542); END_STATE(); case 484: - if (lookahead == 'r') ADVANCE(270); + if (lookahead == 'r') ADVANCE(522); END_STATE(); case 485: - if (lookahead == 'r') ADVANCE(98); + if (lookahead == 'r') ADVANCE(588); END_STATE(); case 486: - if (lookahead == 'r') ADVANCE(500); + if (lookahead == 'r') ADVANCE(633); END_STATE(); case 487: - if (lookahead == 'r') ADVANCE(65); - if (lookahead == 't') ADVANCE(574); + if (lookahead == 'r') ADVANCE(96); END_STATE(); case 488: - if (lookahead == 'r') ADVANCE(537); + if (lookahead == 'r') ADVANCE(97); END_STATE(); case 489: - if (lookahead == 'r') ADVANCE(164); + if (lookahead == 'r') ADVANCE(270); END_STATE(); case 490: - if (lookahead == 'r') ADVANCE(279); + if (lookahead == 'r') ADVANCE(364); END_STATE(); case 491: - if (lookahead == 'r') ADVANCE(522); + if (lookahead == 'r') ADVANCE(509); END_STATE(); case 492: - if (lookahead == 'r') ADVANCE(126); + if (lookahead == 'r') ADVANCE(406); END_STATE(); case 493: - if (lookahead == 's') ADVANCE(638); + if (lookahead == 'r') ADVANCE(64); + if (lookahead == 't') ADVANCE(583); END_STATE(); case 494: - if (lookahead == 's') ADVANCE(721); + if (lookahead == 'r') ADVANCE(211); + if (lookahead == 's') ADVANCE(446); END_STATE(); case 495: - if (lookahead == 's') ADVANCE(660); + if (lookahead == 'r') ADVANCE(549); END_STATE(); case 496: - if (lookahead == 's') ADVANCE(668); + if (lookahead == 'r') ADVANCE(516); END_STATE(); case 497: - if (lookahead == 's') ADVANCE(726); + if (lookahead == 'r') ADVANCE(164); END_STATE(); case 498: - if (lookahead == 's') ADVANCE(657); + if (lookahead == 'r') ADVANCE(280); END_STATE(); case 499: - if (lookahead == 's') ADVANCE(669); + if (lookahead == 'r') ADVANCE(532); END_STATE(); case 500: - if (lookahead == 's') ADVANCE(689); + if (lookahead == 'r') ADVANCE(123); END_STATE(); case 501: - if (lookahead == 's') ADVANCE(658); + if (lookahead == 'r') ADVANCE(561); END_STATE(); case 502: - if (lookahead == 's') ADVANCE(735); + if (lookahead == 's') ADVANCE(650); END_STATE(); case 503: - if (lookahead == 's') ADVANCE(681); + if (lookahead == 's') ADVANCE(736); END_STATE(); case 504: - if (lookahead == 's') ADVANCE(693); + if (lookahead == 's') ADVANCE(674); END_STATE(); case 505: - if (lookahead == 's') ADVANCE(671); + if (lookahead == 's') ADVANCE(682); END_STATE(); case 506: - if (lookahead == 's') ADVANCE(688); + if (lookahead == 's') ADVANCE(741); END_STATE(); case 507: - if (lookahead == 's') ADVANCE(111); - if (lookahead == 'x') ADVANCE(236); + if (lookahead == 's') ADVANCE(669); END_STATE(); case 508: - if (lookahead == 's') ADVANCE(111); - if (lookahead == 'x') ADVANCE(235); + if (lookahead == 's') ADVANCE(683); END_STATE(); case 509: - if (lookahead == 's') ADVANCE(595); + if (lookahead == 's') ADVANCE(702); END_STATE(); case 510: - if (lookahead == 's') ADVANCE(30); + if (lookahead == 's') ADVANCE(672); END_STATE(); case 511: - if (lookahead == 's') ADVANCE(190); + if (lookahead == 's') ADVANCE(754); END_STATE(); case 512: - if (lookahead == 's') ADVANCE(190); - if (lookahead == 't') ADVANCE(180); + if (lookahead == 's') ADVANCE(694); END_STATE(); case 513: - if (lookahead == 's') ADVANCE(133); + if (lookahead == 's') ADVANCE(706); END_STATE(); case 514: - if (lookahead == 's') ADVANCE(133); - if (lookahead == 't') ADVANCE(226); + if (lookahead == 's') ADVANCE(685); END_STATE(); case 515: - if (lookahead == 's') ADVANCE(552); + if (lookahead == 's') ADVANCE(701); END_STATE(); case 516: - if (lookahead == 's') ADVANCE(280); + if (lookahead == 's') ADVANCE(743); END_STATE(); case 517: - if (lookahead == 's') ADVANCE(411); + if (lookahead == 's') ADVANCE(110); + if (lookahead == 'x') ADVANCE(236); END_STATE(); case 518: - if (lookahead == 's') ADVANCE(159); + if (lookahead == 's') ADVANCE(415); + if (lookahead == 'u') ADVANCE(148); END_STATE(); case 519: - if (lookahead == 's') ADVANCE(26); + if (lookahead == 's') ADVANCE(114); END_STATE(); case 520: - if (lookahead == 's') ADVANCE(524); + if (lookahead == 's') ADVANCE(39); END_STATE(); case 521: - if (lookahead == 's') ADVANCE(502); + if (lookahead == 's') ADVANCE(603); END_STATE(); case 522: - if (lookahead == 's') ADVANCE(539); + if (lookahead == 's') ADVANCE(29); END_STATE(); case 523: - if (lookahead == 's') ADVANCE(546); + if (lookahead == 's') ADVANCE(124); END_STATE(); case 524: - if (lookahead == 's') ADVANCE(33); + if (lookahead == 's') ADVANCE(124); + if (lookahead == 't') ADVANCE(231); END_STATE(); case 525: - if (lookahead == 's') ADVANCE(561); + if (lookahead == 's') ADVANCE(25); END_STATE(); case 526: - if (lookahead == 's') ADVANCE(37); + if (lookahead == 's') ADVANCE(282); END_STATE(); case 527: - if (lookahead == 't') ADVANCE(680); + if (lookahead == 's') ADVANCE(417); END_STATE(); case 528: - if (lookahead == 't') ADVANCE(654); + if (lookahead == 's') ADVANCE(159); END_STATE(); case 529: - if (lookahead == 't') ADVANCE(627); + if (lookahead == 's') ADVANCE(581); END_STATE(); case 530: - if (lookahead == 't') ADVANCE(633); + if (lookahead == 's') ADVANCE(534); END_STATE(); case 531: - if (lookahead == 't') ADVANCE(653); + if (lookahead == 's') ADVANCE(511); END_STATE(); case 532: - if (lookahead == 't') ADVANCE(712); + if (lookahead == 's') ADVANCE(551); END_STATE(); case 533: - if (lookahead == 't') ADVANCE(682); + if (lookahead == 's') ADVANCE(571); END_STATE(); case 534: - if (lookahead == 't') ADVANCE(636); + if (lookahead == 's') ADVANCE(32); END_STATE(); case 535: - if (lookahead == 't') ADVANCE(659); + if (lookahead == 's') ADVANCE(197); END_STATE(); case 536: - if (lookahead == 't') ADVANCE(740); + if (lookahead == 's') ADVANCE(197); + if (lookahead == 't') ADVANCE(181); END_STATE(); case 537: - if (lookahead == 't') ADVANCE(694); + if (lookahead == 's') ADVANCE(36); END_STATE(); case 538: - if (lookahead == 't') ADVANCE(673); + if (lookahead == 't') ADVANCE(693); END_STATE(); case 539: - if (lookahead == 't') ADVANCE(725); + if (lookahead == 't') ADVANCE(666); END_STATE(); case 540: - if (lookahead == 't') ADVANCE(696); + if (lookahead == 't') ADVANCE(744); END_STATE(); case 541: - if (lookahead == 't') ADVANCE(690); + if (lookahead == 't') ADVANCE(640); END_STATE(); case 542: - if (lookahead == 't') ADVANCE(674); + if (lookahead == 't') ADVANCE(646); END_STATE(); case 543: - if (lookahead == 't') ADVANCE(25); + if (lookahead == 't') ADVANCE(665); END_STATE(); case 544: - if (lookahead == 't') ADVANCE(711); + if (lookahead == 't') ADVANCE(727); END_STATE(); case 545: - if (lookahead == 't') ADVANCE(679); + if (lookahead == 't') ADVANCE(695); END_STATE(); case 546: - if (lookahead == 't') ADVANCE(678); + if (lookahead == 't') ADVANCE(648); END_STATE(); case 547: - if (lookahead == 't') ADVANCE(55); + if (lookahead == 't') ADVANCE(673); END_STATE(); case 548: - if (lookahead == 't') ADVANCE(155); + if (lookahead == 't') ADVANCE(759); END_STATE(); case 549: - if (lookahead == 't') ADVANCE(268); + if (lookahead == 't') ADVANCE(707); END_STATE(); case 550: - if (lookahead == 't') ADVANCE(618); + if (lookahead == 't') ADVANCE(687); END_STATE(); case 551: - if (lookahead == 't') ADVANCE(23); + if (lookahead == 't') ADVANCE(740); END_STATE(); case 552: - if (lookahead == 't') ADVANCE(75); + if (lookahead == 't') ADVANCE(709); END_STATE(); case 553: - if (lookahead == 't') ADVANCE(497); + if (lookahead == 't') ADVANCE(703); END_STATE(); case 554: - if (lookahead == 't') ADVANCE(290); + if (lookahead == 't') ADVANCE(688); END_STATE(); case 555: - if (lookahead == 't') ADVANCE(180); + if (lookahead == 't') ADVANCE(726); END_STATE(); case 556: - if (lookahead == 't') ADVANCE(490); + if (lookahead == 't') ADVANCE(692); END_STATE(); case 557: - if (lookahead == 't') ADVANCE(19); + if (lookahead == 't') ADVANCE(51); END_STATE(); case 558: - if (lookahead == 't') ADVANCE(24); + if (lookahead == 't') ADVANCE(155); END_STATE(); case 559: - if (lookahead == 't') ADVANCE(196); + if (lookahead == 't') ADVANCE(268); END_STATE(); case 560: - if (lookahead == 't') ADVANCE(266); + if (lookahead == 't') ADVANCE(631); END_STATE(); case 561: - if (lookahead == 't') ADVANCE(503); + if (lookahead == 't') ADVANCE(286); END_STATE(); case 562: - if (lookahead == 't') ADVANCE(506); + if (lookahead == 't') ADVANCE(22); END_STATE(); case 563: - if (lookahead == 't') ADVANCE(182); + if (lookahead == 't') ADVANCE(506); END_STATE(); case 564: - if (lookahead == 't') ADVANCE(227); + if (lookahead == 't') ADVANCE(291); END_STATE(); case 565: - if (lookahead == 't') ADVANCE(205); + if (lookahead == 't') ADVANCE(181); END_STATE(); case 566: - if (lookahead == 't') ADVANCE(165); + if (lookahead == 't') ADVANCE(18); END_STATE(); case 567: - if (lookahead == 't') ADVANCE(226); + if (lookahead == 't') ADVANCE(24); END_STATE(); case 568: - if (lookahead == 't') ADVANCE(170); + if (lookahead == 't') ADVANCE(498); END_STATE(); case 569: - if (lookahead == 't') ADVANCE(175); + if (lookahead == 't') ADVANCE(195); END_STATE(); case 570: - if (lookahead == 't') ADVANCE(213); + if (lookahead == 't') ADVANCE(267); END_STATE(); case 571: - if (lookahead == 't') ADVANCE(39); + if (lookahead == 't') ADVANCE(512); END_STATE(); case 572: - if (lookahead == 't') ADVANCE(221); + if (lookahead == 't') ADVANCE(520); END_STATE(); case 573: - if (lookahead == 't') ADVANCE(34); + if (lookahead == 't') ADVANCE(184); END_STATE(); case 574: - if (lookahead == 't') ADVANCE(206); + if (lookahead == 't') ADVANCE(515); END_STATE(); case 575: - if (lookahead == 't') ADVANCE(421); + if (lookahead == 't') ADVANCE(206); END_STATE(); case 576: - if (lookahead == 't') ADVANCE(216); + if (lookahead == 't') ADVANCE(165); END_STATE(); case 577: - if (lookahead == 't') ADVANCE(217); + if (lookahead == 't') ADVANCE(170); END_STATE(); case 578: - if (lookahead == 't') ADVANCE(85); + if (lookahead == 't') ADVANCE(176); END_STATE(); case 579: - if (lookahead == 't') ADVANCE(292); + if (lookahead == 't') ADVANCE(215); END_STATE(); case 580: - if (lookahead == 't') ADVANCE(293); + if (lookahead == 't') ADVANCE(225); END_STATE(); case 581: - if (lookahead == 't') ADVANCE(232); + if (lookahead == 't') ADVANCE(76); END_STATE(); case 582: - if (lookahead == 't') ADVANCE(294); + if (lookahead == 't') ADVANCE(33); END_STATE(); case 583: - if (lookahead == 't') ADVANCE(295); + if (lookahead == 't') ADVANCE(210); END_STATE(); case 584: - if (lookahead == 'u') ADVANCE(137); + if (lookahead == 't') ADVANCE(428); END_STATE(); case 585: - if (lookahead == 'u') ADVANCE(353); + if (lookahead == 't') ADVANCE(214); END_STATE(); case 586: - if (lookahead == 'u') ADVANCE(120); + if (lookahead == 't') ADVANCE(220); END_STATE(); case 587: - if (lookahead == 'u') ADVANCE(319); + if (lookahead == 't') ADVANCE(221); END_STATE(); case 588: - if (lookahead == 'u') ADVANCE(158); + if (lookahead == 't') ADVANCE(86); END_STATE(); case 589: - if (lookahead == 'u') ADVANCE(535); + if (lookahead == 't') ADVANCE(292); END_STATE(); case 590: - if (lookahead == 'u') ADVANCE(540); + if (lookahead == 't') ADVANCE(293); END_STATE(); case 591: - if (lookahead == 'u') ADVANCE(492); + if (lookahead == 't') ADVANCE(234); END_STATE(); case 592: - if (lookahead == 'u') ADVANCE(234); + if (lookahead == 't') ADVANCE(294); END_STATE(); case 593: - if (lookahead == 'u') ADVANCE(149); + if (lookahead == 't') ADVANCE(295); END_STATE(); case 594: - if (lookahead == 'u') ADVANCE(554); + if (lookahead == 'u') ADVANCE(357); END_STATE(); case 595: - if (lookahead == 'u') ADVANCE(519); + if (lookahead == 'u') ADVANCE(117); END_STATE(); case 596: - if (lookahead == 'u') ADVANCE(123); + if (lookahead == 'u') ADVANCE(325); END_STATE(); case 597: - if (lookahead == 'u') ADVANCE(147); + if (lookahead == 'u') ADVANCE(158); END_STATE(); case 598: - if (lookahead == 'u') ADVANCE(214); + if (lookahead == 'u') ADVANCE(547); END_STATE(); case 599: - if (lookahead == 'u') ADVANCE(583); + if (lookahead == 'u') ADVANCE(552); END_STATE(); case 600: - if (lookahead == 'v') ADVANCE(273); + if (lookahead == 'u') ADVANCE(500); END_STATE(); case 601: - if (lookahead == 'v') ADVANCE(69); + if (lookahead == 'u') ADVANCE(148); END_STATE(); case 602: - if (lookahead == 'v') ADVANCE(166); + if (lookahead == 'u') ADVANCE(564); END_STATE(); case 603: - if (lookahead == 'v') ADVANCE(208); + if (lookahead == 'u') ADVANCE(525); END_STATE(); case 604: - if (lookahead == 'w') ADVANCE(720); + if (lookahead == 'u') ADVANCE(119); END_STATE(); case 605: - if (lookahead == 'w') ADVANCE(362); + if (lookahead == 'u') ADVANCE(203); END_STATE(); case 606: - if (lookahead == 'w') ADVANCE(377); + if (lookahead == 'u') ADVANCE(149); END_STATE(); case 607: - if (lookahead == 'w') ADVANCE(210); + if (lookahead == 'u') ADVANCE(146); END_STATE(); case 608: - if (lookahead == 'x') ADVANCE(16); + if (lookahead == 'u') ADVANCE(219); END_STATE(); case 609: - if (lookahead == 'x') ADVANCE(533); + if (lookahead == 'u') ADVANCE(593); END_STATE(); case 610: - if (lookahead == 'x') ADVANCE(21); + if (lookahead == 'v') ADVANCE(273); END_STATE(); case 611: - if (lookahead == 'x') ADVANCE(22); + if (lookahead == 'v') ADVANCE(67); END_STATE(); case 612: - if (lookahead == 'y') ADVANCE(677); + if (lookahead == 'v') ADVANCE(166); END_STATE(); case 613: - if (lookahead == 'y') ADVANCE(667); + if (lookahead == 'v') ADVANCE(212); END_STATE(); case 614: - if (lookahead == 'y') ADVANCE(675); + if (lookahead == 'w') ADVANCE(735); END_STATE(); case 615: - if (lookahead == 'y') ADVANCE(635); + if (lookahead == 'w') ADVANCE(366); END_STATE(); case 616: - if (lookahead == 'y') ADVANCE(724); + if (lookahead == 'w') ADVANCE(382); END_STATE(); case 617: - if (lookahead == 'y') ADVANCE(665); + if (lookahead == 'w') ADVANCE(217); END_STATE(); case 618: - if (lookahead == 'y') ADVANCE(695); + if (lookahead == 'x') ADVANCE(721); END_STATE(); case 619: - if (lookahead == 'y') ADVANCE(734); + if (lookahead == 'x') ADVANCE(720); END_STATE(); case 620: - if (lookahead == 'y') ADVANCE(672); + if (lookahead == 'x') ADVANCE(545); END_STATE(); case 621: - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(745); + if (lookahead == 'x') ADVANCE(21); END_STATE(); case 622: + if (lookahead == 'x') ADVANCE(23); + END_STATE(); + case 623: + if (lookahead == 'x') ADVANCE(20); + END_STATE(); + case 624: + if (lookahead == 'x') ADVANCE(451); + END_STATE(); + case 625: + if (lookahead == 'y') ADVANCE(691); + END_STATE(); + case 626: + if (lookahead == 'y') ADVANCE(681); + END_STATE(); + case 627: + if (lookahead == 'y') ADVANCE(689); + END_STATE(); + case 628: + if (lookahead == 'y') ADVANCE(647); + END_STATE(); + case 629: + if (lookahead == 'y') ADVANCE(739); + END_STATE(); + case 630: + if (lookahead == 'y') ADVANCE(679); + END_STATE(); + case 631: + if (lookahead == 'y') ADVANCE(708); + END_STATE(); + case 632: + if (lookahead == 'y') ADVANCE(753); + END_STATE(); + case 633: + if (lookahead == 'y') ADVANCE(686); + END_STATE(); + case 634: + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(764); + END_STATE(); + case 635: if (lookahead != 0 && lookahead != '\n') ADVANCE(3); END_STATE(); - case 623: - if (eof) ADVANCE(624); + case 636: + if (eof) ADVANCE(637); ADVANCE_MAP( '/', 15, - '[', 700, - 'a', 251, - 'c', 45, + 'a', 250, + 'c', 43, 'd', 173, - 'e', 507, - 'i', 356, - 'm', 78, - 'o', 606, - 'p', 79, - 'r', 211, + 'e', 624, + 'i', 359, + 'm', 56, + 'o', 616, + 'p', 77, + 'r', 174, 's', 108, - 't', 220, - 'v', 56, - 'w', 409, - '{', 628, - '}', 629, + 't', 224, + 'v', 53, + 'w', 414, + '}', 642, ); if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') SKIP(623); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(747); + lookahead == ' ') SKIP(636); END_STATE(); - case 624: + case 637: ACCEPT_TOKEN(ts_builtin_sym_end); END_STATE(); - case 625: + case 638: ACCEPT_TOKEN(anon_sym_include); END_STATE(); - case 626: + case 639: ACCEPT_TOKEN(sym_comment); if (lookahead != 0 && - lookahead != '\n') ADVANCE(626); + lookahead != '\n') ADVANCE(639); END_STATE(); - case 627: + case 640: ACCEPT_TOKEN(anon_sym_client); END_STATE(); - case 628: + case 641: ACCEPT_TOKEN(anon_sym_LBRACE); END_STATE(); - case 629: + case 642: ACCEPT_TOKEN(anon_sym_RBRACE); END_STATE(); - case 630: + case 643: ACCEPT_TOKEN(anon_sym_tier); END_STATE(); - case 631: - ACCEPT_TOKEN(anon_sym_model); - END_STATE(); - case 632: - ACCEPT_TOKEN(anon_sym_model); + case 644: + ACCEPT_TOKEN(anon_sym_tier); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 633: - ACCEPT_TOKEN(anon_sym_effort); + case 645: + ACCEPT_TOKEN(anon_sym_model); END_STATE(); - case 634: + case 646: ACCEPT_TOKEN(anon_sym_effort); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); END_STATE(); - case 635: + case 647: ACCEPT_TOKEN(anon_sym_privacy); END_STATE(); - case 636: + case 648: ACCEPT_TOKEN(anon_sym_default); END_STATE(); - case 637: + case 649: ACCEPT_TOKEN(anon_sym_extra); END_STATE(); - case 638: + case 650: ACCEPT_TOKEN(anon_sym_vars); END_STATE(); - case 639: + case 651: ACCEPT_TOKEN(anon_sym_file); END_STATE(); - case 640: + case 652: ACCEPT_TOKEN(anon_sym_dir); END_STATE(); - case 641: + case 653: ACCEPT_TOKEN(anon_sym_cheap); END_STATE(); - case 642: + case 654: ACCEPT_TOKEN(anon_sym_cheap); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 643: + case 655: ACCEPT_TOKEN(anon_sym_expensive); END_STATE(); - case 644: + case 656: ACCEPT_TOKEN(anon_sym_expensive); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 645: + case 657: ACCEPT_TOKEN(anon_sym_coordinator); END_STATE(); - case 646: + case 658: ACCEPT_TOKEN(anon_sym_coordinator); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 647: + case 659: ACCEPT_TOKEN(anon_sym_reasoning); END_STATE(); - case 648: + case 660: ACCEPT_TOKEN(anon_sym_reasoning); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 649: + case 661: ACCEPT_TOKEN(anon_sym_execution); END_STATE(); - case 650: + case 662: ACCEPT_TOKEN(anon_sym_execution); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 651: + case 663: ACCEPT_TOKEN(anon_sym_mechanical); END_STATE(); - case 652: + case 664: ACCEPT_TOKEN(anon_sym_mechanical); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 653: + case 665: ACCEPT_TOKEN(anon_sym_prompt); END_STATE(); - case 654: + case 666: ACCEPT_TOKEN(anon_sym_agent); END_STATE(); - case 655: + case 667: ACCEPT_TOKEN(anon_sym_description); END_STATE(); - case 656: + case 668: ACCEPT_TOKEN(anon_sym_depends_on); END_STATE(); - case 657: + case 669: ACCEPT_TOKEN(anon_sym_produces); END_STATE(); - case 658: + case 670: + ACCEPT_TOKEN(anon_sym_json); + END_STATE(); + case 671: + ACCEPT_TOKEN(anon_sym_json); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 672: ACCEPT_TOKEN(anon_sym_max_retries); END_STATE(); - case 659: + case 673: ACCEPT_TOKEN(anon_sym_timeout); END_STATE(); - case 660: + case 674: ACCEPT_TOKEN(anon_sym_tools); END_STATE(); - case 661: + case 675: ACCEPT_TOKEN(anon_sym_template); END_STATE(); - case 662: + case 676: ACCEPT_TOKEN(anon_sym_template); - if (lookahead == '_') ADVANCE(286); + if (lookahead == '_') ADVANCE(287); END_STATE(); - case 663: + case 677: ACCEPT_TOKEN(anon_sym_scope); END_STATE(); - case 664: + case 678: ACCEPT_TOKEN(anon_sym_owned); END_STATE(); - case 665: + case 679: ACCEPT_TOKEN(anon_sym_read_only); END_STATE(); - case 666: + case 680: ACCEPT_TOKEN(anon_sym_impact_scope); END_STATE(); - case 667: + case 681: ACCEPT_TOKEN(anon_sym_memory); END_STATE(); - case 668: + case 682: ACCEPT_TOKEN(anon_sym_read_ns); END_STATE(); - case 669: + case 683: ACCEPT_TOKEN(anon_sym_write_ns); END_STATE(); - case 670: + case 684: ACCEPT_TOKEN(anon_sym_importance); END_STATE(); - case 671: + case 685: ACCEPT_TOKEN(anon_sym_staleness_sources); END_STATE(); - case 672: + case 686: ACCEPT_TOKEN(anon_sym_read_query); END_STATE(); - case 673: + case 687: ACCEPT_TOKEN(anon_sym_read_limit); END_STATE(); - case 674: + case 688: ACCEPT_TOKEN(anon_sym_write_content); END_STATE(); - case 675: + case 689: ACCEPT_TOKEN(anon_sym_verify); END_STATE(); - case 676: + case 690: ACCEPT_TOKEN(anon_sym_compile); END_STATE(); - case 677: + case 691: ACCEPT_TOKEN(anon_sym_clippy); END_STATE(); - case 678: - ACCEPT_TOKEN(anon_sym_test); - END_STATE(); - case 679: + case 692: ACCEPT_TOKEN(anon_sym_test); - if (lookahead == '_') ADVANCE(244); END_STATE(); - case 680: + case 693: ACCEPT_TOKEN(anon_sym_test); if (lookahead == '_') ADVANCE(244); - if (lookahead == 's') ADVANCE(41); + if (lookahead == 's') ADVANCE(39); END_STATE(); - case 681: + case 694: ACCEPT_TOKEN(anon_sym_impact_tests); END_STATE(); - case 682: + case 695: ACCEPT_TOKEN(anon_sym_context); END_STATE(); - case 683: + case 696: ACCEPT_TOKEN(anon_sym_callers_of); END_STATE(); - case 684: + case 697: ACCEPT_TOKEN(anon_sym_tests_for); END_STATE(); - case 685: + case 698: ACCEPT_TOKEN(anon_sym_depth); END_STATE(); - case 686: + case 699: ACCEPT_TOKEN(anon_sym_loop); END_STATE(); - case 687: + case 700: ACCEPT_TOKEN(anon_sym_loop); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 688: + case 701: ACCEPT_TOKEN(anon_sym_agents); END_STATE(); - case 689: + case 702: ACCEPT_TOKEN(anon_sym_reviewers); END_STATE(); - case 690: + case 703: ACCEPT_TOKEN(anon_sym_template_init); END_STATE(); - case 691: + case 704: ACCEPT_TOKEN(anon_sym_template_refine); END_STATE(); - case 692: + case 705: ACCEPT_TOKEN(anon_sym_consensus_mode); END_STATE(); - case 693: + case 706: ACCEPT_TOKEN(anon_sym_max_iterations); END_STATE(); - case 694: + case 707: ACCEPT_TOKEN(anon_sym_iter_start); END_STATE(); - case 695: + case 708: ACCEPT_TOKEN(anon_sym_stability); END_STATE(); - case 696: + case 709: ACCEPT_TOKEN(anon_sym_judge_timeout); END_STATE(); - case 697: + case 710: ACCEPT_TOKEN(anon_sym_irreconcilable_after); END_STATE(); - case 698: + case 711: ACCEPT_TOKEN(anon_sym_strict_judge); END_STATE(); - case 699: + case 712: ACCEPT_TOKEN(anon_sym_branch_chain); END_STATE(); - case 700: + case 713: ACCEPT_TOKEN(anon_sym_LBRACK); END_STATE(); - case 701: + case 714: ACCEPT_TOKEN(anon_sym_RBRACK); END_STATE(); - case 702: + case 715: ACCEPT_TOKEN(anon_sym_id); END_STATE(); - case 703: + case 716: ACCEPT_TOKEN(anon_sym_id); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - case 704: + case 717: ACCEPT_TOKEN(anon_sym_for); END_STATE(); - case 705: + case 718: ACCEPT_TOKEN(anon_sym_for); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); - END_STATE(); - case 706: - ACCEPT_TOKEN(anon_sym_in); - END_STATE(); - case 707: - ACCEPT_TOKEN(anon_sym_parallel); - END_STATE(); - case 708: - ACCEPT_TOKEN(anon_sym_sequential); - END_STATE(); - case 709: - ACCEPT_TOKEN(anon_sym_peer_template); - END_STATE(); - case 710: - ACCEPT_TOKEN(anon_sym_peer_template); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); - END_STATE(); - case 711: - ACCEPT_TOKEN(anon_sym_strict); - END_STATE(); - case 712: - ACCEPT_TOKEN(anon_sym_strict); - if (lookahead == '_') ADVANCE(298); - END_STATE(); - case 713: - ACCEPT_TOKEN(anon_sym_partial_ok); - END_STATE(); - case 714: - ACCEPT_TOKEN(anon_sym_explore); - END_STATE(); - case 715: - ACCEPT_TOKEN(anon_sym_stacked); - END_STATE(); - case 716: - ACCEPT_TOKEN(anon_sym_none); - END_STATE(); - case 717: - ACCEPT_TOKEN(anon_sym_until); - END_STATE(); - case 718: - ACCEPT_TOKEN(anon_sym_and); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 719: - ACCEPT_TOKEN(anon_sym_command); + ACCEPT_TOKEN(anon_sym_in); END_STATE(); case 720: - ACCEPT_TOKEN(anon_sym_workflow); + ACCEPT_TOKEN(anon_sym_max); END_STATE(); case 721: - ACCEPT_TOKEN(anon_sym_steps); + ACCEPT_TOKEN(anon_sym_max); + if (lookahead == '_') ADVANCE(299); END_STATE(); case 722: - ACCEPT_TOKEN(anon_sym_max_parallel); + ACCEPT_TOKEN(anon_sym_parallel); END_STATE(); case 723: - ACCEPT_TOKEN(anon_sym_execution_mode); + ACCEPT_TOKEN(anon_sym_sequential); END_STATE(); case 724: - ACCEPT_TOKEN(anon_sym_strategy); + ACCEPT_TOKEN(anon_sym_peer_template); END_STATE(); case 725: - ACCEPT_TOKEN(anon_sym_test_first); + ACCEPT_TOKEN(anon_sym_peer_template); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 726: - ACCEPT_TOKEN(anon_sym_attempts); + ACCEPT_TOKEN(anon_sym_strict); END_STATE(); case 727: - ACCEPT_TOKEN(anon_sym_escalate_after); + ACCEPT_TOKEN(anon_sym_strict); + if (lookahead == '_') ADVANCE(302); END_STATE(); case 728: - ACCEPT_TOKEN(anon_sym_pattern); + ACCEPT_TOKEN(anon_sym_partial_ok); END_STATE(); case 729: - ACCEPT_TOKEN(anon_sym_discover); + ACCEPT_TOKEN(anon_sym_explore); END_STATE(); case 730: - ACCEPT_TOKEN(anon_sym_reduce); + ACCEPT_TOKEN(anon_sym_stacked); END_STATE(); case 731: - ACCEPT_TOKEN(anon_sym_max_spawn); + ACCEPT_TOKEN(anon_sym_none); END_STATE(); case 732: - ACCEPT_TOKEN(anon_sym_param); + ACCEPT_TOKEN(anon_sym_until); END_STATE(); case 733: - ACCEPT_TOKEN(anon_sym_public); + ACCEPT_TOKEN(anon_sym_and); END_STATE(); case 734: - ACCEPT_TOKEN(anon_sym_local_only); + ACCEPT_TOKEN(anon_sym_command); END_STATE(); case 735: - ACCEPT_TOKEN(anon_sym_single_pass); + ACCEPT_TOKEN(anon_sym_workflow); END_STATE(); case 736: - ACCEPT_TOKEN(anon_sym_single_pass); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_steps); END_STATE(); case 737: - ACCEPT_TOKEN(anon_sym_refine); + ACCEPT_TOKEN(anon_sym_max_parallel); END_STATE(); case 738: - ACCEPT_TOKEN(anon_sym_refine); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_execution_mode); END_STATE(); case 739: - ACCEPT_TOKEN(anon_sym_repo); + ACCEPT_TOKEN(anon_sym_strategy); END_STATE(); case 740: - ACCEPT_TOKEN(anon_sym_document); + ACCEPT_TOKEN(anon_sym_test_first); END_STATE(); case 741: - ACCEPT_TOKEN(anon_sym_true); + ACCEPT_TOKEN(anon_sym_attempts); END_STATE(); case 742: - ACCEPT_TOKEN(anon_sym_false); + ACCEPT_TOKEN(anon_sym_escalate_after); END_STATE(); case 743: - ACCEPT_TOKEN(sym_string); + ACCEPT_TOKEN(anon_sym_tiers); END_STATE(); case 744: - ACCEPT_TOKEN(sym_raw_string); + ACCEPT_TOKEN(anon_sym_budget); END_STATE(); case 745: - ACCEPT_TOKEN(sym_float); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(745); + ACCEPT_TOKEN(anon_sym_wall); END_STATE(); case 746: - ACCEPT_TOKEN(sym_integer); - if (lookahead == '.') ADVANCE(621); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(746); + ACCEPT_TOKEN(anon_sym_usd); END_STATE(); case 747: - ACCEPT_TOKEN(sym_integer); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(747); + ACCEPT_TOKEN(anon_sym_pattern); END_STATE(); case 748: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == '_') ADVANCE(816); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_discover); END_STATE(); case 749: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == '_') ADVANCE(828); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_reduce); END_STATE(); case 750: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(823); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_max_spawn); END_STATE(); case 751: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(813); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_param); END_STATE(); case 752: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(791); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_public); END_STATE(); case 753: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(801); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_local_only); END_STATE(); case 754: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(830); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_single_pass); END_STATE(); case 755: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(825); + ACCEPT_TOKEN(anon_sym_single_pass); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 756: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(829); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_refine); END_STATE(); case 757: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'c') ADVANCE(783); + ACCEPT_TOKEN(anon_sym_refine); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 758: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'c') ADVANCE(831); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_repo); END_STATE(); case 759: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'c') ADVANCE(752); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_document); END_STATE(); case 760: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'd') ADVANCE(786); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_true); END_STATE(); case 761: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'd') ADVANCE(703); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(anon_sym_false); END_STATE(); case 762: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'd') ADVANCE(772); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(sym_string); END_STATE(); case 763: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(757); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(sym_raw_string); END_STATE(); case 764: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(750); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(sym_float); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(764); END_STATE(); case 765: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(798); - if (lookahead == '-' || - ('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ACCEPT_TOKEN(sym_integer); + if (lookahead == '.') ADVANCE(634); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(765); END_STATE(); case 766: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(644); + if (lookahead == '_') ADVANCE(843); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 767: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(795); + if (lookahead == '_') ADVANCE(831); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 768: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(710); + if (lookahead == 'a') ADVANCE(838); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 769: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(738); + if (lookahead == 'a') ADVANCE(828); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 770: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(758); - if (lookahead == 'p') ADVANCE(765); + if (lookahead == 'a') ADVANCE(807); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 771: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(751); + if (lookahead == 'a') ADVANCE(817); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 772: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(792); + if (lookahead == 'a') ADVANCE(845); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 773: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(748); + if (lookahead == 'a') ADVANCE(840); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 774: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(779); + if (lookahead == 'a') ADVANCE(844); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 775: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(820); + if (lookahead == 'c') ADVANCE(798); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 776: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(775); + if (lookahead == 'c') ADVANCE(846); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 777: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'f') ADVANCE(778); + if (lookahead == 'c') ADVANCE(770); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 778: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'f') ADVANCE(811); + if (lookahead == 'd') ADVANCE(801); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 779: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'f') ADVANCE(789); + if (lookahead == 'd') ADVANCE(716); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 780: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'g') ADVANCE(648); + if (lookahead == 'e') ADVANCE(775); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 781: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'g') ADVANCE(794); + if (lookahead == 'e') ADVANCE(768); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 782: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'h') ADVANCE(771); - if (lookahead == 'o') ADVANCE(804); + if (lookahead == 'e') ADVANCE(814); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 783: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'h') ADVANCE(753); + if (lookahead == 'e') ADVANCE(656); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 784: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(832); + if (lookahead == 'e') ADVANCE(810); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 785: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(759); + if (lookahead == 'e') ADVANCE(725); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 786: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(800); + if (lookahead == 'e') ADVANCE(794); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 787: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(796); + if (lookahead == 'e') ADVANCE(757); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 788: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(799); + if (lookahead == 'e') ADVANCE(776); + if (lookahead == 'p') ADVANCE(782); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 789: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(802); + if (lookahead == 'e') ADVANCE(769); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 790: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(812); + if (lookahead == 'e') ADVANCE(767); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 791: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'l') ADVANCE(652); + if (lookahead == 'e') ADVANCE(835); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 792: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'l') ADVANCE(632); + if (lookahead == 'e') ADVANCE(836); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 793: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'l') ADVANCE(756); + if (lookahead == 'e') ADVANCE(792); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 794: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'l') ADVANCE(773); + if (lookahead == 'f') ADVANCE(805); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 795: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'm') ADVANCE(815); + if (lookahead == 'g') ADVANCE(660); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 796: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(780); + if (lookahead == 'g') ADVANCE(809); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 797: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(650); + if (lookahead == 'h') ADVANCE(789); + if (lookahead == 'o') ADVANCE(820); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 798: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(824); + if (lookahead == 'h') ADVANCE(771); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 799: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(781); + if (lookahead == 'i') ADVANCE(847); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 800: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(754); + if (lookahead == 'i') ADVANCE(777); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 801: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(785); + if (lookahead == 'i') ADVANCE(816); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 802: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(769); + if (lookahead == 'i') ADVANCE(811); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 803: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'n') ADVANCE(787); + if (lookahead == 'i') ADVANCE(791); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 804: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(817); + if (lookahead == 'i') ADVANCE(815); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 805: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(818); + if (lookahead == 'i') ADVANCE(818); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 806: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(814); + if (lookahead == 'i') ADVANCE(826); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 807: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(819); + if (lookahead == 'l') ADVANCE(664); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 808: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(762); + if (lookahead == 'l') ADVANCE(774); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 809: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(803); + if (lookahead == 'l') ADVANCE(790); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 810: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(806); + if (lookahead == 'm') ADVANCE(830); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 811: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(821); + if (lookahead == 'n') ADVANCE(795); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 812: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(797); + if (lookahead == 'n') ADVANCE(662); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 813: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'p') ADVANCE(642); + if (lookahead == 'n') ADVANCE(671); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 814: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'p') ADVANCE(687); + if (lookahead == 'n') ADVANCE(839); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 815: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'p') ADVANCE(793); + if (lookahead == 'n') ADVANCE(796); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 816: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'p') ADVANCE(755); + if (lookahead == 'n') ADVANCE(772); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 817: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(760); + if (lookahead == 'n') ADVANCE(800); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 818: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(646); + if (lookahead == 'n') ADVANCE(787); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 819: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(705); + if (lookahead == 'n') ADVANCE(802); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 820: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(749); + if (lookahead == 'o') ADVANCE(832); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 821: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(826); + if (lookahead == 'o') ADVANCE(833); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 822: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 's') ADVANCE(736); + if (lookahead == 'o') ADVANCE(829); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 823: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 's') ADVANCE(809); + if (lookahead == 'o') ADVANCE(834); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 824: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 's') ADVANCE(784); + if (lookahead == 'o') ADVANCE(819); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 825: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 's') ADVANCE(822); + if (lookahead == 'o') ADVANCE(822); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 826: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(634); + if (lookahead == 'o') ADVANCE(812); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 827: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(790); + if (lookahead == 'o') ADVANCE(813); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 828: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(767); + if (lookahead == 'p') ADVANCE(654); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 829: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(768); + if (lookahead == 'p') ADVANCE(700); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 830: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(805); + if (lookahead == 'p') ADVANCE(808); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 831: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'u') ADVANCE(827); + if (lookahead == 'p') ADVANCE(773); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 832: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'v') ADVANCE(766); + if (lookahead == 'r') ADVANCE(778); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 833: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'x') ADVANCE(770); + if (lookahead == 'r') ADVANCE(658); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); case 834: ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'r') ADVANCE(718); if (lookahead == '-' || ('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(834); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); END_STATE(); - default: - return false; - } -} - -static const TSLexerMode ts_lex_modes[STATE_COUNT] = { - [0] = {.lex_state = 0}, - [1] = {.lex_state = 623}, - [2] = {.lex_state = 10}, - [3] = {.lex_state = 10}, - [4] = {.lex_state = 10}, - [5] = {.lex_state = 623}, - [6] = {.lex_state = 623}, - [7] = {.lex_state = 9}, - [8] = {.lex_state = 623}, - [9] = {.lex_state = 623}, - [10] = {.lex_state = 623}, - [11] = {.lex_state = 623}, - [12] = {.lex_state = 623}, - [13] = {.lex_state = 623}, - [14] = {.lex_state = 623}, - [15] = {.lex_state = 623}, - [16] = {.lex_state = 623}, - [17] = {.lex_state = 623}, - [18] = {.lex_state = 9}, - [19] = {.lex_state = 9}, - [20] = {.lex_state = 9}, - [21] = {.lex_state = 623}, - [22] = {.lex_state = 623}, - [23] = {.lex_state = 623}, - [24] = {.lex_state = 9}, - [25] = {.lex_state = 9}, - [26] = {.lex_state = 9}, - [27] = {.lex_state = 9}, - [28] = {.lex_state = 9}, - [29] = {.lex_state = 9}, - [30] = {.lex_state = 9}, - [31] = {.lex_state = 9}, - [32] = {.lex_state = 9}, - [33] = {.lex_state = 623}, - [34] = {.lex_state = 623}, - [35] = {.lex_state = 623}, - [36] = {.lex_state = 623}, - [37] = {.lex_state = 623}, - [38] = {.lex_state = 9}, - [39] = {.lex_state = 9}, - [40] = {.lex_state = 9}, - [41] = {.lex_state = 623}, - [42] = {.lex_state = 623}, - [43] = {.lex_state = 9}, - [44] = {.lex_state = 623}, - [45] = {.lex_state = 623}, - [46] = {.lex_state = 623}, - [47] = {.lex_state = 623}, - [48] = {.lex_state = 623}, - [49] = {.lex_state = 623}, - [50] = {.lex_state = 623}, - [51] = {.lex_state = 623}, - [52] = {.lex_state = 623}, - [53] = {.lex_state = 623}, - [54] = {.lex_state = 623}, - [55] = {.lex_state = 623}, - [56] = {.lex_state = 623}, - [57] = {.lex_state = 2}, - [58] = {.lex_state = 2}, - [59] = {.lex_state = 0}, - [60] = {.lex_state = 0}, - [61] = {.lex_state = 0}, - [62] = {.lex_state = 0}, - [63] = {.lex_state = 0}, - [64] = {.lex_state = 0}, - [65] = {.lex_state = 0}, - [66] = {.lex_state = 0}, - [67] = {.lex_state = 623}, - [68] = {.lex_state = 2}, - [69] = {.lex_state = 623}, - [70] = {.lex_state = 623}, - [71] = {.lex_state = 623}, - [72] = {.lex_state = 0}, - [73] = {.lex_state = 2}, - [74] = {.lex_state = 623}, - [75] = {.lex_state = 623}, - [76] = {.lex_state = 623}, - [77] = {.lex_state = 623}, - [78] = {.lex_state = 623}, - [79] = {.lex_state = 1}, - [80] = {.lex_state = 11}, - [81] = {.lex_state = 8}, - [82] = {.lex_state = 0}, - [83] = {.lex_state = 0}, - [84] = {.lex_state = 1}, - [85] = {.lex_state = 11}, - [86] = {.lex_state = 8}, - [87] = {.lex_state = 0}, - [88] = {.lex_state = 11}, - [89] = {.lex_state = 8}, - [90] = {.lex_state = 0}, - [91] = {.lex_state = 0}, - [92] = {.lex_state = 12}, - [93] = {.lex_state = 0}, - [94] = {.lex_state = 0}, - [95] = {.lex_state = 0}, - [96] = {.lex_state = 11}, - [97] = {.lex_state = 1}, - [98] = {.lex_state = 12}, - [99] = {.lex_state = 11}, - [100] = {.lex_state = 0}, - [101] = {.lex_state = 0}, - [102] = {.lex_state = 0}, - [103] = {.lex_state = 0}, - [104] = {.lex_state = 0}, - [105] = {.lex_state = 0}, - [106] = {.lex_state = 0}, - [107] = {.lex_state = 623}, - [108] = {.lex_state = 623}, - [109] = {.lex_state = 12}, - [110] = {.lex_state = 623}, - [111] = {.lex_state = 0}, - [112] = {.lex_state = 11}, - [113] = {.lex_state = 0}, - [114] = {.lex_state = 12}, - [115] = {.lex_state = 0}, - [116] = {.lex_state = 1}, - [117] = {.lex_state = 13}, - [118] = {.lex_state = 13}, - [119] = {.lex_state = 12}, - [120] = {.lex_state = 0}, - [121] = {.lex_state = 13}, - [122] = {.lex_state = 623}, - [123] = {.lex_state = 1}, - [124] = {.lex_state = 0}, - [125] = {.lex_state = 623}, - [126] = {.lex_state = 1}, - [127] = {.lex_state = 0}, - [128] = {.lex_state = 8}, - [129] = {.lex_state = 14}, + case 835: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'r') ADVANCE(644); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 836: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'r') ADVANCE(766); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 837: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 's') ADVANCE(755); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 838: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 's') ADVANCE(824); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 839: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 's') ADVANCE(799); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 840: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 's') ADVANCE(837); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 841: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 's') ADVANCE(827); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 842: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(806); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 843: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(784); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 844: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(785); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 845: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(821); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 846: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'u') ADVANCE(842); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 847: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'v') ADVANCE(783); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 848: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'x') ADVANCE(788); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + case 849: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == '-' || + ('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(849); + END_STATE(); + default: + return false; + } +} + +static const TSLexerMode ts_lex_modes[STATE_COUNT] = { + [0] = {.lex_state = 0}, + [1] = {.lex_state = 636}, + [2] = {.lex_state = 9}, + [3] = {.lex_state = 7}, + [4] = {.lex_state = 9}, + [5] = {.lex_state = 9}, + [6] = {.lex_state = 636}, + [7] = {.lex_state = 636}, + [8] = {.lex_state = 7}, + [9] = {.lex_state = 7}, + [10] = {.lex_state = 7}, + [11] = {.lex_state = 636}, + [12] = {.lex_state = 636}, + [13] = {.lex_state = 636}, + [14] = {.lex_state = 636}, + [15] = {.lex_state = 636}, + [16] = {.lex_state = 7}, + [17] = {.lex_state = 7}, + [18] = {.lex_state = 7}, + [19] = {.lex_state = 636}, + [20] = {.lex_state = 636}, + [21] = {.lex_state = 7}, + [22] = {.lex_state = 7}, + [23] = {.lex_state = 7}, + [24] = {.lex_state = 7}, + [25] = {.lex_state = 7}, + [26] = {.lex_state = 7}, + [27] = {.lex_state = 7}, + [28] = {.lex_state = 7}, + [29] = {.lex_state = 7}, + [30] = {.lex_state = 7}, + [31] = {.lex_state = 7}, + [32] = {.lex_state = 7}, + [33] = {.lex_state = 7}, + [34] = {.lex_state = 7}, + [35] = {.lex_state = 7}, + [36] = {.lex_state = 7}, + [37] = {.lex_state = 7}, + [38] = {.lex_state = 7}, + [39] = {.lex_state = 7}, + [40] = {.lex_state = 7}, + [41] = {.lex_state = 7}, + [42] = {.lex_state = 7}, + [43] = {.lex_state = 7}, + [44] = {.lex_state = 7}, + [45] = {.lex_state = 7}, + [46] = {.lex_state = 7}, + [47] = {.lex_state = 7}, + [48] = {.lex_state = 7}, + [49] = {.lex_state = 7}, + [50] = {.lex_state = 7}, + [51] = {.lex_state = 7}, + [52] = {.lex_state = 7}, + [53] = {.lex_state = 7}, + [54] = {.lex_state = 636}, + [55] = {.lex_state = 636}, + [56] = {.lex_state = 636}, + [57] = {.lex_state = 636}, + [58] = {.lex_state = 636}, + [59] = {.lex_state = 636}, + [60] = {.lex_state = 636}, + [61] = {.lex_state = 636}, + [62] = {.lex_state = 636}, + [63] = {.lex_state = 636}, + [64] = {.lex_state = 2}, + [65] = {.lex_state = 0}, + [66] = {.lex_state = 0}, + [67] = {.lex_state = 0}, + [68] = {.lex_state = 0}, + [69] = {.lex_state = 0}, + [70] = {.lex_state = 0}, + [71] = {.lex_state = 0}, + [72] = {.lex_state = 0}, + [73] = {.lex_state = 636}, + [74] = {.lex_state = 636}, + [75] = {.lex_state = 636}, + [76] = {.lex_state = 2}, + [77] = {.lex_state = 2}, + [78] = {.lex_state = 636}, + [79] = {.lex_state = 636}, + [80] = {.lex_state = 2}, + [81] = {.lex_state = 636}, + [82] = {.lex_state = 636}, + [83] = {.lex_state = 636}, + [84] = {.lex_state = 0}, + [85] = {.lex_state = 2}, + [86] = {.lex_state = 636}, + [87] = {.lex_state = 0}, + [88] = {.lex_state = 8}, + [89] = {.lex_state = 0}, + [90] = {.lex_state = 0}, + [91] = {.lex_state = 1}, + [92] = {.lex_state = 9}, + [93] = {.lex_state = 1}, + [94] = {.lex_state = 9}, + [95] = {.lex_state = 8}, + [96] = {.lex_state = 8}, + [97] = {.lex_state = 0}, + [98] = {.lex_state = 9}, + [99] = {.lex_state = 0}, + [100] = {.lex_state = 9}, + [101] = {.lex_state = 0}, + [102] = {.lex_state = 0}, + [103] = {.lex_state = 0}, + [104] = {.lex_state = 1}, + [105] = {.lex_state = 0}, + [106] = {.lex_state = 9}, + [107] = {.lex_state = 0}, + [108] = {.lex_state = 636}, + [109] = {.lex_state = 0}, + [110] = {.lex_state = 636}, + [111] = {.lex_state = 636}, + [112] = {.lex_state = 636}, + [113] = {.lex_state = 10}, + [114] = {.lex_state = 10}, + [115] = {.lex_state = 636}, + [116] = {.lex_state = 0}, + [117] = {.lex_state = 0}, + [118] = {.lex_state = 636}, + [119] = {.lex_state = 13}, + [120] = {.lex_state = 10}, + [121] = {.lex_state = 0}, + [122] = {.lex_state = 0}, + [123] = {.lex_state = 0}, + [124] = {.lex_state = 9}, + [125] = {.lex_state = 0}, + [126] = {.lex_state = 13}, + [127] = {.lex_state = 13}, + [128] = {.lex_state = 1}, + [129] = {.lex_state = 0}, [130] = {.lex_state = 0}, - [131] = {.lex_state = 0}, - [132] = {.lex_state = 1}, - [133] = {.lex_state = 8}, + [131] = {.lex_state = 13}, + [132] = {.lex_state = 13}, + [133] = {.lex_state = 636}, [134] = {.lex_state = 1}, - [135] = {.lex_state = 13}, - [136] = {.lex_state = 8}, - [137] = {.lex_state = 1}, + [135] = {.lex_state = 8}, + [136] = {.lex_state = 1}, + [137] = {.lex_state = 10}, [138] = {.lex_state = 1}, - [139] = {.lex_state = 13}, - [140] = {.lex_state = 0}, - [141] = {.lex_state = 0}, - [142] = {.lex_state = 0}, - [143] = {.lex_state = 0}, - [144] = {.lex_state = 1}, - [145] = {.lex_state = 1}, + [139] = {.lex_state = 1}, + [140] = {.lex_state = 1}, + [141] = {.lex_state = 1}, + [142] = {.lex_state = 636}, + [143] = {.lex_state = 13}, + [144] = {.lex_state = 0}, + [145] = {.lex_state = 8}, [146] = {.lex_state = 1}, - [147] = {.lex_state = 0}, - [148] = {.lex_state = 0}, - [149] = {.lex_state = 0}, + [147] = {.lex_state = 13}, + [148] = {.lex_state = 13}, + [149] = {.lex_state = 8}, [150] = {.lex_state = 0}, - [151] = {.lex_state = 0}, - [152] = {.lex_state = 0}, - [153] = {.lex_state = 0}, - [154] = {.lex_state = 0}, - [155] = {.lex_state = 0}, - [156] = {.lex_state = 0}, - [157] = {.lex_state = 1}, - [158] = {.lex_state = 0}, + [151] = {.lex_state = 14}, + [152] = {.lex_state = 1}, + [153] = {.lex_state = 10}, + [154] = {.lex_state = 1}, + [155] = {.lex_state = 8}, + [156] = {.lex_state = 636}, + [157] = {.lex_state = 0}, + [158] = {.lex_state = 13}, [159] = {.lex_state = 0}, - [160] = {.lex_state = 13}, + [160] = {.lex_state = 0}, [161] = {.lex_state = 0}, [162] = {.lex_state = 0}, - [163] = {.lex_state = 0}, + [163] = {.lex_state = 1}, [164] = {.lex_state = 0}, [165] = {.lex_state = 0}, [166] = {.lex_state = 0}, - [167] = {.lex_state = 0}, + [167] = {.lex_state = 11}, [168] = {.lex_state = 0}, [169] = {.lex_state = 0}, - [170] = {.lex_state = 1}, + [170] = {.lex_state = 0}, [171] = {.lex_state = 0}, [172] = {.lex_state = 0}, - [173] = {.lex_state = 0}, - [174] = {.lex_state = 1}, - [175] = {.lex_state = 1}, - [176] = {.lex_state = 1}, - [177] = {.lex_state = 0}, - [178] = {.lex_state = 1}, + [173] = {.lex_state = 1}, + [174] = {.lex_state = 0}, + [175] = {.lex_state = 0}, + [176] = {.lex_state = 0}, + [177] = {.lex_state = 1}, + [178] = {.lex_state = 0}, [179] = {.lex_state = 0}, - [180] = {.lex_state = 623}, + [180] = {.lex_state = 1}, [181] = {.lex_state = 0}, - [182] = {.lex_state = 1}, - [183] = {.lex_state = 1}, - [184] = {.lex_state = 1}, - [185] = {.lex_state = 623}, - [186] = {.lex_state = 1}, + [182] = {.lex_state = 13}, + [183] = {.lex_state = 0}, + [184] = {.lex_state = 0}, + [185] = {.lex_state = 0}, + [186] = {.lex_state = 0}, [187] = {.lex_state = 0}, - [188] = {.lex_state = 1}, - [189] = {.lex_state = 1}, - [190] = {.lex_state = 0}, - [191] = {.lex_state = 1}, - [192] = {.lex_state = 0}, + [188] = {.lex_state = 0}, + [189] = {.lex_state = 11}, + [190] = {.lex_state = 1}, + [191] = {.lex_state = 12}, + [192] = {.lex_state = 12}, [193] = {.lex_state = 0}, [194] = {.lex_state = 0}, [195] = {.lex_state = 0}, - [196] = {.lex_state = 1}, - [197] = {.lex_state = 1}, - [198] = {.lex_state = 10}, - [199] = {.lex_state = 623}, - [200] = {.lex_state = 623}, + [196] = {.lex_state = 0}, + [197] = {.lex_state = 0}, + [198] = {.lex_state = 1}, + [199] = {.lex_state = 0}, + [200] = {.lex_state = 0}, [201] = {.lex_state = 0}, - [202] = {.lex_state = 0}, + [202] = {.lex_state = 1}, [203] = {.lex_state = 1}, [204] = {.lex_state = 0}, - [205] = {.lex_state = 623}, + [205] = {.lex_state = 12}, [206] = {.lex_state = 0}, - [207] = {.lex_state = 1}, + [207] = {.lex_state = 0}, [208] = {.lex_state = 0}, - [209] = {.lex_state = 0}, - [210] = {.lex_state = 623}, - [211] = {.lex_state = 1}, - [212] = {.lex_state = 0}, - [213] = {.lex_state = 1}, - [214] = {.lex_state = 0}, + [209] = {.lex_state = 1}, + [210] = {.lex_state = 1}, + [211] = {.lex_state = 0}, + [212] = {.lex_state = 1}, + [213] = {.lex_state = 0}, + [214] = {.lex_state = 1}, + [215] = {.lex_state = 0}, + [216] = {.lex_state = 0}, + [217] = {.lex_state = 0}, + [218] = {.lex_state = 0}, + [219] = {.lex_state = 0}, + [220] = {.lex_state = 1}, + [221] = {.lex_state = 0}, + [222] = {.lex_state = 1}, + [223] = {.lex_state = 1}, + [224] = {.lex_state = 0}, + [225] = {.lex_state = 0}, + [226] = {.lex_state = 0}, + [227] = {.lex_state = 1}, + [228] = {.lex_state = 0}, + [229] = {.lex_state = 0}, + [230] = {.lex_state = 0}, + [231] = {.lex_state = 0}, + [232] = {.lex_state = 0}, + [233] = {.lex_state = 0}, + [234] = {.lex_state = 1}, + [235] = {.lex_state = 0}, + [236] = {.lex_state = 1}, + [237] = {.lex_state = 0}, + [238] = {.lex_state = 0}, + [239] = {.lex_state = 0}, + [240] = {.lex_state = 1}, + [241] = {.lex_state = 0}, + [242] = {.lex_state = 0}, + [243] = {.lex_state = 0}, + [244] = {.lex_state = 0}, + [245] = {.lex_state = 0}, + [246] = {.lex_state = 1}, + [247] = {.lex_state = 0}, }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { @@ -5151,6 +5325,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_description] = ACTIONS(1), [anon_sym_depends_on] = ACTIONS(1), [anon_sym_produces] = ACTIONS(1), + [anon_sym_json] = ACTIONS(1), [anon_sym_max_retries] = ACTIONS(1), [anon_sym_timeout] = ACTIONS(1), [anon_sym_tools] = ACTIONS(1), @@ -5193,6 +5368,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_id] = ACTIONS(1), [anon_sym_for] = ACTIONS(1), [anon_sym_in] = ACTIONS(1), + [anon_sym_max] = ACTIONS(1), [anon_sym_parallel] = ACTIONS(1), [anon_sym_sequential] = ACTIONS(1), [anon_sym_peer_template] = ACTIONS(1), @@ -5211,6 +5387,9 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_test_first] = ACTIONS(1), [anon_sym_attempts] = ACTIONS(1), [anon_sym_escalate_after] = ACTIONS(1), + [anon_sym_budget] = ACTIONS(1), + [anon_sym_wall] = ACTIONS(1), + [anon_sym_usd] = ACTIONS(1), [anon_sym_pattern] = ACTIONS(1), [anon_sym_discover] = ACTIONS(1), [anon_sym_reduce] = ACTIONS(1), @@ -5230,16 +5409,16 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [sym_integer] = ACTIONS(1), }, [STATE(1)] = { - [sym_source_file] = STATE(190), - [sym__definition] = STATE(22), - [sym_include_declaration] = STATE(22), - [sym_client_declaration] = STATE(22), - [sym_vars_block] = STATE(22), - [sym_tier_alias_declaration] = STATE(22), - [sym_prompt_declaration] = STATE(22), - [sym_agent_declaration] = STATE(22), - [sym_workflow_declaration] = STATE(22), - [aux_sym_source_file_repeat1] = STATE(22), + [sym_source_file] = STATE(242), + [sym__definition] = STATE(20), + [sym_include_declaration] = STATE(20), + [sym_client_declaration] = STATE(20), + [sym_vars_block] = STATE(20), + [sym_tier_alias_declaration] = STATE(20), + [sym_prompt_declaration] = STATE(20), + [sym_agent_declaration] = STATE(20), + [sym_workflow_declaration] = STATE(20), + [aux_sym_source_file_repeat1] = STATE(20), [ts_builtin_sym_end] = ACTIONS(5), [anon_sym_include] = ACTIONS(7), [sym_comment] = ACTIONS(3), @@ -5256,11 +5435,9 @@ static const uint16_t ts_small_parse_table[] = { [0] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(23), 2, + ACTIONS(23), 1, anon_sym_template, - anon_sym_test, - ACTIONS(21), 44, - anon_sym_client, + ACTIONS(21), 34, anon_sym_RBRACE, anon_sym_tier, anon_sym_vars, @@ -5276,9 +5453,9 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_read_only, anon_sym_impact_scope, anon_sym_memory, - anon_sym_verify, anon_sym_compile, anon_sym_clippy, + anon_sym_test, anon_sym_impact_tests, anon_sym_context, anon_sym_agents, @@ -5295,6 +5472,28 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, + [43] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(25), 29, + anon_sym_RBRACE, + anon_sym_max_retries, + anon_sym_memory, + anon_sym_verify, + anon_sym_agents, + anon_sym_reviewers, + anon_sym_template_init, + anon_sym_template_refine, + anon_sym_consensus_mode, + anon_sym_max_iterations, + anon_sym_iter_start, + anon_sym_stability, + anon_sym_judge_timeout, + anon_sym_irreconcilable_after, + anon_sym_strict_judge, + anon_sym_branch_chain, + anon_sym_for, + anon_sym_until, anon_sym_steps, anon_sym_max_parallel, anon_sym_execution_mode, @@ -5302,15 +5501,16 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [54] = 3, + [78] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(27), 1, + ACTIONS(29), 1, anon_sym_template, - ACTIONS(25), 28, - anon_sym_client, + ACTIONS(27), 27, anon_sym_RBRACE, anon_sym_tier, anon_sym_vars, @@ -5338,13 +5538,12 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - [91] = 3, + [114] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(31), 1, + ACTIONS(33), 1, anon_sym_template, - ACTIONS(29), 28, - anon_sym_client, + ACTIONS(31), 27, anon_sym_RBRACE, anon_sym_tier, anon_sym_vars, @@ -5372,11 +5571,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - [128] = 2, + [150] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(33), 28, - anon_sym_client, + ACTIONS(35), 27, anon_sym_RBRACE, anon_sym_tier, anon_sym_vars, @@ -5404,11 +5602,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_callers_of, anon_sym_tests_for, anon_sym_depth, - [162] = 2, + [183] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(35), 28, - anon_sym_client, + ACTIONS(37), 27, anon_sym_RBRACE, anon_sym_tier, anon_sym_vars, @@ -5436,284 +5633,244 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_callers_of, anon_sym_tests_for, anon_sym_depth, - [196] = 2, + [216] = 15, ACTIONS(3), 1, sym_comment, - ACTIONS(37), 27, + ACTIONS(39), 1, anon_sym_RBRACE, - anon_sym_max_retries, + ACTIONS(43), 1, anon_sym_memory, + ACTIONS(45), 1, anon_sym_verify, - anon_sym_agents, - anon_sym_reviewers, - anon_sym_template_init, - anon_sym_template_refine, - anon_sym_consensus_mode, - anon_sym_max_iterations, - anon_sym_iter_start, - anon_sym_stability, - anon_sym_judge_timeout, - anon_sym_irreconcilable_after, - anon_sym_strict_judge, - anon_sym_branch_chain, - anon_sym_for, - anon_sym_until, + ACTIONS(47), 1, anon_sym_steps, - anon_sym_max_parallel, + ACTIONS(49), 1, anon_sym_execution_mode, + ACTIONS(51), 1, anon_sym_strategy, + ACTIONS(53), 1, anon_sym_test_first, - anon_sym_attempts, - anon_sym_escalate_after, + ACTIONS(55), 1, + anon_sym_tiers, + ACTIONS(57), 1, + anon_sym_budget, + ACTIONS(59), 1, anon_sym_pattern, + ACTIONS(61), 1, anon_sym_param, - [229] = 2, + STATE(9), 2, + sym_workflow_field, + aux_sym_workflow_declaration_repeat1, + ACTIONS(41), 4, + anon_sym_max_retries, + anon_sym_max_parallel, + anon_sym_attempts, + anon_sym_escalate_after, + STATE(43), 6, + sym_memory_block, + sym_verify_block, + sym_tiers_block, + sym_budget_block, + sym_pattern_block, + sym_param_declaration, + [271] = 15, ACTIONS(3), 1, sym_comment, - ACTIONS(39), 25, - anon_sym_client, - anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, - anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, + ACTIONS(43), 1, anon_sym_memory, + ACTIONS(45), 1, anon_sym_verify, - anon_sym_context, + ACTIONS(47), 1, anon_sym_steps, - anon_sym_max_parallel, + ACTIONS(49), 1, anon_sym_execution_mode, + ACTIONS(51), 1, anon_sym_strategy, + ACTIONS(53), 1, anon_sym_test_first, - anon_sym_attempts, - anon_sym_escalate_after, + ACTIONS(55), 1, + anon_sym_tiers, + ACTIONS(57), 1, + anon_sym_budget, + ACTIONS(59), 1, anon_sym_pattern, + ACTIONS(61), 1, anon_sym_param, - [260] = 2, + ACTIONS(63), 1, + anon_sym_RBRACE, + STATE(10), 2, + sym_workflow_field, + aux_sym_workflow_declaration_repeat1, + ACTIONS(41), 4, + anon_sym_max_retries, + anon_sym_max_parallel, + anon_sym_attempts, + anon_sym_escalate_after, + STATE(43), 6, + sym_memory_block, + sym_verify_block, + sym_tiers_block, + sym_budget_block, + sym_pattern_block, + sym_param_declaration, + [326] = 15, ACTIONS(3), 1, sym_comment, - ACTIONS(41), 25, - anon_sym_client, + ACTIONS(65), 1, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, - anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, + ACTIONS(70), 1, anon_sym_memory, + ACTIONS(73), 1, anon_sym_verify, - anon_sym_context, + ACTIONS(76), 1, anon_sym_steps, - anon_sym_max_parallel, + ACTIONS(79), 1, anon_sym_execution_mode, + ACTIONS(82), 1, anon_sym_strategy, + ACTIONS(85), 1, anon_sym_test_first, - anon_sym_attempts, - anon_sym_escalate_after, + ACTIONS(88), 1, + anon_sym_tiers, + ACTIONS(91), 1, + anon_sym_budget, + ACTIONS(94), 1, anon_sym_pattern, + ACTIONS(97), 1, anon_sym_param, - [291] = 16, + STATE(10), 2, + sym_workflow_field, + aux_sym_workflow_declaration_repeat1, + ACTIONS(67), 4, + anon_sym_max_retries, + anon_sym_max_parallel, + anon_sym_attempts, + anon_sym_escalate_after, + STATE(43), 6, + sym_memory_block, + sym_verify_block, + sym_tiers_block, + sym_budget_block, + sym_pattern_block, + sym_param_declaration, + [381] = 16, ACTIONS(3), 1, sym_comment, ACTIONS(13), 1, anon_sym_vars, - ACTIONS(43), 1, - anon_sym_client, - ACTIONS(45), 1, + ACTIONS(100), 1, anon_sym_RBRACE, - ACTIONS(47), 1, + ACTIONS(102), 1, anon_sym_tier, - ACTIONS(49), 1, + ACTIONS(104), 1, anon_sym_prompt, - ACTIONS(51), 1, + ACTIONS(106), 1, anon_sym_description, - ACTIONS(53), 1, + ACTIONS(108), 1, anon_sym_depends_on, - ACTIONS(59), 1, + ACTIONS(110), 1, + anon_sym_produces, + ACTIONS(114), 1, + anon_sym_tools, + ACTIONS(116), 1, anon_sym_template, - ACTIONS(61), 1, + ACTIONS(118), 1, anon_sym_scope, - ACTIONS(63), 1, + ACTIONS(120), 1, anon_sym_memory, - ACTIONS(65), 1, + ACTIONS(122), 1, anon_sym_context, - ACTIONS(55), 2, - anon_sym_produces, - anon_sym_tools, - ACTIONS(57), 2, + ACTIONS(112), 2, anon_sym_max_retries, anon_sym_timeout, - STATE(12), 2, + STATE(13), 2, sym_agent_field, aux_sym_agent_declaration_repeat1, - STATE(35), 4, + STATE(57), 4, sym_vars_block, sym_scope_block, sym_memory_block, sym_context_block, - [346] = 16, + [435] = 16, ACTIONS(3), 1, sym_comment, - ACTIONS(67), 1, - anon_sym_client, - ACTIONS(70), 1, - anon_sym_RBRACE, - ACTIONS(72), 1, - anon_sym_tier, - ACTIONS(75), 1, + ACTIONS(13), 1, anon_sym_vars, - ACTIONS(78), 1, + ACTIONS(102), 1, + anon_sym_tier, + ACTIONS(104), 1, anon_sym_prompt, - ACTIONS(81), 1, + ACTIONS(106), 1, anon_sym_description, - ACTIONS(84), 1, + ACTIONS(108), 1, anon_sym_depends_on, - ACTIONS(93), 1, + ACTIONS(110), 1, + anon_sym_produces, + ACTIONS(114), 1, + anon_sym_tools, + ACTIONS(116), 1, anon_sym_template, - ACTIONS(96), 1, + ACTIONS(118), 1, anon_sym_scope, - ACTIONS(99), 1, + ACTIONS(120), 1, anon_sym_memory, - ACTIONS(102), 1, + ACTIONS(122), 1, anon_sym_context, - ACTIONS(87), 2, - anon_sym_produces, - anon_sym_tools, - ACTIONS(90), 2, + ACTIONS(124), 1, + anon_sym_RBRACE, + ACTIONS(112), 2, anon_sym_max_retries, anon_sym_timeout, STATE(11), 2, sym_agent_field, aux_sym_agent_declaration_repeat1, - STATE(35), 4, + STATE(57), 4, sym_vars_block, sym_scope_block, sym_memory_block, sym_context_block, - [401] = 16, + [489] = 16, ACTIONS(3), 1, sym_comment, - ACTIONS(13), 1, - anon_sym_vars, - ACTIONS(43), 1, - anon_sym_client, - ACTIONS(47), 1, + ACTIONS(126), 1, + anon_sym_RBRACE, + ACTIONS(128), 1, anon_sym_tier, - ACTIONS(49), 1, + ACTIONS(131), 1, + anon_sym_vars, + ACTIONS(134), 1, anon_sym_prompt, - ACTIONS(51), 1, + ACTIONS(137), 1, anon_sym_description, - ACTIONS(53), 1, + ACTIONS(140), 1, anon_sym_depends_on, - ACTIONS(59), 1, + ACTIONS(143), 1, + anon_sym_produces, + ACTIONS(149), 1, + anon_sym_tools, + ACTIONS(152), 1, anon_sym_template, - ACTIONS(61), 1, + ACTIONS(155), 1, anon_sym_scope, - ACTIONS(63), 1, + ACTIONS(158), 1, anon_sym_memory, - ACTIONS(65), 1, + ACTIONS(161), 1, anon_sym_context, - ACTIONS(105), 1, - anon_sym_RBRACE, - ACTIONS(55), 2, - anon_sym_produces, - anon_sym_tools, - ACTIONS(57), 2, + ACTIONS(146), 2, anon_sym_max_retries, anon_sym_timeout, - STATE(11), 2, + STATE(13), 2, sym_agent_field, aux_sym_agent_declaration_repeat1, - STATE(35), 4, + STATE(57), 4, sym_vars_block, sym_scope_block, sym_memory_block, sym_context_block, - [456] = 13, - ACTIONS(3), 1, - sym_comment, - ACTIONS(107), 1, - anon_sym_RBRACE, - ACTIONS(112), 1, - anon_sym_memory, - ACTIONS(115), 1, - anon_sym_verify, - ACTIONS(118), 1, - anon_sym_steps, - ACTIONS(121), 1, - anon_sym_execution_mode, - ACTIONS(124), 1, - anon_sym_strategy, - ACTIONS(127), 1, - anon_sym_test_first, - ACTIONS(130), 1, - anon_sym_pattern, - ACTIONS(133), 1, - anon_sym_param, - STATE(13), 2, - sym_workflow_field, - aux_sym_workflow_declaration_repeat1, - ACTIONS(109), 4, - anon_sym_max_retries, - anon_sym_max_parallel, - anon_sym_attempts, - anon_sym_escalate_after, - STATE(56), 4, - sym_memory_block, - sym_verify_block, - sym_pattern_block, - sym_param_declaration, - [503] = 13, - ACTIONS(3), 1, - sym_comment, - ACTIONS(63), 1, - anon_sym_memory, - ACTIONS(136), 1, - anon_sym_RBRACE, - ACTIONS(140), 1, - anon_sym_verify, - ACTIONS(142), 1, - anon_sym_steps, - ACTIONS(144), 1, - anon_sym_execution_mode, - ACTIONS(146), 1, - anon_sym_strategy, - ACTIONS(148), 1, - anon_sym_test_first, - ACTIONS(150), 1, - anon_sym_pattern, - ACTIONS(152), 1, - anon_sym_param, - STATE(17), 2, - sym_workflow_field, - aux_sym_workflow_declaration_repeat1, - ACTIONS(138), 4, - anon_sym_max_retries, - anon_sym_max_parallel, - anon_sym_attempts, - anon_sym_escalate_after, - STATE(56), 4, - sym_memory_block, - sym_verify_block, - sym_pattern_block, - sym_param_declaration, - [550] = 2, + [543] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(154), 19, + ACTIONS(164), 19, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -5733,10 +5890,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_memory, anon_sym_context, anon_sym_workflow, - [575] = 2, + [568] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(156), 19, + ACTIONS(166), 19, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -5756,162 +5913,128 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_memory, anon_sym_context, anon_sym_workflow, - [600] = 13, - ACTIONS(3), 1, - sym_comment, - ACTIONS(63), 1, - anon_sym_memory, - ACTIONS(140), 1, - anon_sym_verify, - ACTIONS(142), 1, - anon_sym_steps, - ACTIONS(144), 1, - anon_sym_execution_mode, - ACTIONS(146), 1, - anon_sym_strategy, - ACTIONS(148), 1, - anon_sym_test_first, - ACTIONS(150), 1, - anon_sym_pattern, - ACTIONS(152), 1, - anon_sym_param, - ACTIONS(158), 1, - anon_sym_RBRACE, - STATE(13), 2, - sym_workflow_field, - aux_sym_workflow_declaration_repeat1, - ACTIONS(138), 4, - anon_sym_max_retries, - anon_sym_max_parallel, - anon_sym_attempts, - anon_sym_escalate_after, - STATE(56), 4, - sym_memory_block, - sym_verify_block, - sym_pattern_block, - sym_param_declaration, - [647] = 13, + [593] = 13, ACTIONS(3), 1, sym_comment, - ACTIONS(160), 1, + ACTIONS(168), 1, anon_sym_RBRACE, - ACTIONS(162), 1, + ACTIONS(170), 1, anon_sym_agents, - ACTIONS(164), 1, + ACTIONS(172), 1, anon_sym_reviewers, - ACTIONS(168), 1, + ACTIONS(176), 1, anon_sym_consensus_mode, - ACTIONS(172), 1, + ACTIONS(180), 1, anon_sym_strict_judge, - ACTIONS(174), 1, + ACTIONS(182), 1, anon_sym_branch_chain, - ACTIONS(176), 1, + ACTIONS(184), 1, anon_sym_for, - ACTIONS(178), 1, + ACTIONS(186), 1, anon_sym_until, - ACTIONS(166), 2, + ACTIONS(174), 2, anon_sym_template_init, anon_sym_template_refine, - STATE(19), 2, + STATE(17), 2, sym_loop_field, aux_sym_loop_block_repeat1, - STATE(38), 2, + STATE(42), 2, sym_for_block, sym_until_clause, - ACTIONS(170), 5, + ACTIONS(178), 5, anon_sym_max_iterations, anon_sym_iter_start, anon_sym_stability, anon_sym_judge_timeout, anon_sym_irreconcilable_after, - [694] = 13, + [640] = 13, ACTIONS(3), 1, sym_comment, - ACTIONS(162), 1, + ACTIONS(188), 1, + anon_sym_RBRACE, + ACTIONS(190), 1, anon_sym_agents, - ACTIONS(164), 1, + ACTIONS(193), 1, anon_sym_reviewers, - ACTIONS(168), 1, + ACTIONS(199), 1, anon_sym_consensus_mode, - ACTIONS(172), 1, + ACTIONS(205), 1, anon_sym_strict_judge, - ACTIONS(174), 1, + ACTIONS(208), 1, anon_sym_branch_chain, - ACTIONS(176), 1, + ACTIONS(211), 1, anon_sym_for, - ACTIONS(178), 1, + ACTIONS(214), 1, anon_sym_until, - ACTIONS(180), 1, - anon_sym_RBRACE, - ACTIONS(166), 2, + ACTIONS(196), 2, anon_sym_template_init, anon_sym_template_refine, - STATE(20), 2, + STATE(17), 2, sym_loop_field, aux_sym_loop_block_repeat1, - STATE(38), 2, + STATE(42), 2, sym_for_block, sym_until_clause, - ACTIONS(170), 5, + ACTIONS(202), 5, anon_sym_max_iterations, anon_sym_iter_start, anon_sym_stability, anon_sym_judge_timeout, anon_sym_irreconcilable_after, - [741] = 13, + [687] = 13, ACTIONS(3), 1, sym_comment, - ACTIONS(182), 1, - anon_sym_RBRACE, - ACTIONS(184), 1, + ACTIONS(170), 1, anon_sym_agents, - ACTIONS(187), 1, + ACTIONS(172), 1, anon_sym_reviewers, - ACTIONS(193), 1, + ACTIONS(176), 1, anon_sym_consensus_mode, - ACTIONS(199), 1, + ACTIONS(180), 1, anon_sym_strict_judge, - ACTIONS(202), 1, + ACTIONS(182), 1, anon_sym_branch_chain, - ACTIONS(205), 1, + ACTIONS(184), 1, anon_sym_for, - ACTIONS(208), 1, + ACTIONS(186), 1, anon_sym_until, - ACTIONS(190), 2, + ACTIONS(217), 1, + anon_sym_RBRACE, + ACTIONS(174), 2, anon_sym_template_init, anon_sym_template_refine, - STATE(20), 2, + STATE(16), 2, sym_loop_field, aux_sym_loop_block_repeat1, - STATE(38), 2, + STATE(42), 2, sym_for_block, sym_until_clause, - ACTIONS(196), 5, + ACTIONS(178), 5, anon_sym_max_iterations, anon_sym_iter_start, anon_sym_stability, anon_sym_judge_timeout, anon_sym_irreconcilable_after, - [788] = 10, + [734] = 10, ACTIONS(3), 1, sym_comment, - ACTIONS(211), 1, + ACTIONS(219), 1, ts_builtin_sym_end, - ACTIONS(213), 1, + ACTIONS(221), 1, anon_sym_include, - ACTIONS(216), 1, + ACTIONS(224), 1, anon_sym_client, - ACTIONS(219), 1, + ACTIONS(227), 1, anon_sym_tier, - ACTIONS(222), 1, + ACTIONS(230), 1, anon_sym_vars, - ACTIONS(225), 1, + ACTIONS(233), 1, anon_sym_prompt, - ACTIONS(228), 1, + ACTIONS(236), 1, anon_sym_agent, - ACTIONS(231), 1, + ACTIONS(239), 1, anon_sym_workflow, - STATE(21), 9, + STATE(19), 9, sym__definition, sym_include_declaration, sym_client_declaration, @@ -5921,7 +6044,7 @@ static const uint16_t ts_small_parse_table[] = { sym_agent_declaration, sym_workflow_declaration, aux_sym_source_file_repeat1, - [827] = 10, + [773] = 10, ACTIONS(3), 1, sym_comment, ACTIONS(7), 1, @@ -5938,9 +6061,9 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_agent, ACTIONS(19), 1, anon_sym_workflow, - ACTIONS(234), 1, + ACTIONS(242), 1, ts_builtin_sym_end, - STATE(21), 9, + STATE(19), 9, sym__definition, sym_include_declaration, sym_client_declaration, @@ -5950,17 +6073,37 @@ static const uint16_t ts_small_parse_table[] = { sym_agent_declaration, sym_workflow_declaration, aux_sym_source_file_repeat1, - [866] = 5, + [812] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(236), 1, - anon_sym_LBRACE, - ACTIONS(240), 1, + ACTIONS(246), 1, + anon_sym_and, + STATE(21), 1, + aux_sym_until_clause_repeat1, + ACTIONS(244), 15, + anon_sym_RBRACE, + anon_sym_agents, + anon_sym_reviewers, + anon_sym_template_init, + anon_sym_template_refine, + anon_sym_consensus_mode, + anon_sym_max_iterations, + anon_sym_iter_start, + anon_sym_stability, + anon_sym_judge_timeout, + anon_sym_irreconcilable_after, + anon_sym_strict_judge, + anon_sym_branch_chain, + anon_sym_for, + anon_sym_until, + [839] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(251), 1, anon_sym_LBRACK, - STATE(52), 2, + STATE(36), 1, sym_reviewer_list, - sym_param_client_block, - ACTIONS(238), 13, + ACTIONS(249), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -5972,16 +6115,18 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [895] = 4, + [866] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(244), 1, + ACTIONS(255), 1, anon_sym_and, STATE(24), 1, aux_sym_until_clause_repeat1, - ACTIONS(242), 15, + ACTIONS(253), 15, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -5997,14 +6142,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - [922] = 4, + [893] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(249), 1, + ACTIONS(255), 1, anon_sym_and, - STATE(26), 1, + STATE(21), 1, aux_sym_until_clause_repeat1, - ACTIONS(247), 15, + ACTIONS(257), 15, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6020,14 +6165,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - [949] = 4, + [920] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(249), 1, - anon_sym_and, - STATE(24), 1, - aux_sym_until_clause_repeat1, - ACTIONS(251), 15, + ACTIONS(244), 16, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6043,10 +6184,11 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - [976] = 2, + anon_sym_and, + [942] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(253), 16, + ACTIONS(259), 16, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6063,10 +6205,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_for, anon_sym_until, anon_sym_and, - [998] = 2, + [964] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(255), 16, + ACTIONS(261), 16, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6083,10 +6225,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_for, anon_sym_until, anon_sym_and, - [1020] = 2, + [986] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(257), 16, + ACTIONS(263), 16, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6103,10 +6245,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_for, anon_sym_until, anon_sym_and, - [1042] = 2, + [1008] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(259), 16, + ACTIONS(265), 16, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6123,10 +6265,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_for, anon_sym_until, anon_sym_and, - [1064] = 2, + [1030] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(242), 16, + ACTIONS(267), 15, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6142,11 +6284,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - anon_sym_and, - [1086] = 2, + [1051] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(261), 15, + ACTIONS(269), 15, anon_sym_RBRACE, anon_sym_agents, anon_sym_reviewers, @@ -6162,219 +6303,105 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_branch_chain, anon_sym_for, anon_sym_until, - [1107] = 2, + [1072] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(263), 15, - anon_sym_client, + ACTIONS(271), 15, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, anon_sym_memory, - anon_sym_context, - [1128] = 2, + anon_sym_verify, + anon_sym_steps, + anon_sym_max_parallel, + anon_sym_execution_mode, + anon_sym_strategy, + anon_sym_test_first, + anon_sym_attempts, + anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, + anon_sym_pattern, + anon_sym_param, + [1093] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(265), 15, - anon_sym_client, + ACTIONS(273), 15, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, anon_sym_memory, - anon_sym_context, - [1149] = 2, + anon_sym_verify, + anon_sym_steps, + anon_sym_max_parallel, + anon_sym_execution_mode, + anon_sym_strategy, + anon_sym_test_first, + anon_sym_attempts, + anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, + anon_sym_pattern, + anon_sym_param, + [1114] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(267), 15, - anon_sym_client, + ACTIONS(275), 15, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, anon_sym_memory, - anon_sym_context, - [1170] = 2, + anon_sym_verify, + anon_sym_steps, + anon_sym_max_parallel, + anon_sym_execution_mode, + anon_sym_strategy, + anon_sym_test_first, + anon_sym_attempts, + anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, + anon_sym_pattern, + anon_sym_param, + [1135] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(269), 15, - anon_sym_client, + ACTIONS(277), 15, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, - anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, - anon_sym_memory, - anon_sym_context, - [1191] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(271), 15, - anon_sym_client, - anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, anon_sym_memory, - anon_sym_context, - [1212] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(273), 15, - anon_sym_RBRACE, - anon_sym_agents, - anon_sym_reviewers, - anon_sym_template_init, - anon_sym_template_refine, - anon_sym_consensus_mode, - anon_sym_max_iterations, - anon_sym_iter_start, - anon_sym_stability, - anon_sym_judge_timeout, - anon_sym_irreconcilable_after, - anon_sym_strict_judge, - anon_sym_branch_chain, - anon_sym_for, - anon_sym_until, - [1233] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(275), 15, - anon_sym_RBRACE, - anon_sym_agents, - anon_sym_reviewers, - anon_sym_template_init, - anon_sym_template_refine, - anon_sym_consensus_mode, - anon_sym_max_iterations, - anon_sym_iter_start, - anon_sym_stability, - anon_sym_judge_timeout, - anon_sym_irreconcilable_after, - anon_sym_strict_judge, - anon_sym_branch_chain, - anon_sym_for, - anon_sym_until, - [1254] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(277), 15, - anon_sym_RBRACE, - anon_sym_agents, - anon_sym_reviewers, - anon_sym_template_init, - anon_sym_template_refine, - anon_sym_consensus_mode, - anon_sym_max_iterations, - anon_sym_iter_start, - anon_sym_stability, - anon_sym_judge_timeout, - anon_sym_irreconcilable_after, - anon_sym_strict_judge, - anon_sym_branch_chain, - anon_sym_for, - anon_sym_until, - [1275] = 2, + anon_sym_verify, + anon_sym_steps, + anon_sym_max_parallel, + anon_sym_execution_mode, + anon_sym_strategy, + anon_sym_test_first, + anon_sym_attempts, + anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, + anon_sym_pattern, + anon_sym_param, + [1156] = 2, ACTIONS(3), 1, sym_comment, ACTIONS(279), 15, - anon_sym_client, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, anon_sym_memory, - anon_sym_context, - [1296] = 2, + anon_sym_verify, + anon_sym_steps, + anon_sym_max_parallel, + anon_sym_execution_mode, + anon_sym_strategy, + anon_sym_test_first, + anon_sym_attempts, + anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, + anon_sym_pattern, + anon_sym_param, + [1177] = 2, ACTIONS(3), 1, sym_comment, ACTIONS(281), 15, - anon_sym_client, - anon_sym_RBRACE, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_description, - anon_sym_depends_on, - anon_sym_produces, - anon_sym_max_retries, - anon_sym_timeout, - anon_sym_tools, - anon_sym_template, - anon_sym_scope, - anon_sym_memory, - anon_sym_context, - [1317] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(283), 15, - anon_sym_RBRACE, - anon_sym_agents, - anon_sym_reviewers, - anon_sym_template_init, - anon_sym_template_refine, - anon_sym_consensus_mode, - anon_sym_max_iterations, - anon_sym_iter_start, - anon_sym_stability, - anon_sym_judge_timeout, - anon_sym_irreconcilable_after, - anon_sym_strict_judge, - anon_sym_branch_chain, - anon_sym_for, - anon_sym_until, - [1338] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(285), 13, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6386,12 +6413,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1357] = 2, + [1198] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(287), 13, + ACTIONS(283), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6403,12 +6432,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1376] = 2, + [1219] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(289), 13, + ACTIONS(285), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6420,12 +6451,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1395] = 2, + [1240] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(291), 13, + ACTIONS(287), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6437,12 +6470,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1414] = 2, + [1261] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(293), 13, + ACTIONS(289), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6454,12 +6489,33 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1433] = 2, + [1282] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(291), 15, + anon_sym_RBRACE, + anon_sym_agents, + anon_sym_reviewers, + anon_sym_template_init, + anon_sym_template_refine, + anon_sym_consensus_mode, + anon_sym_max_iterations, + anon_sym_iter_start, + anon_sym_stability, + anon_sym_judge_timeout, + anon_sym_irreconcilable_after, + anon_sym_strict_judge, + anon_sym_branch_chain, + anon_sym_for, + anon_sym_until, + [1303] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(295), 13, + ACTIONS(293), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6471,12 +6527,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1452] = 2, + [1324] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(297), 13, + ACTIONS(295), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6488,12 +6546,71 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1471] = 2, + [1345] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(297), 15, + anon_sym_RBRACE, + anon_sym_agents, + anon_sym_reviewers, + anon_sym_template_init, + anon_sym_template_refine, + anon_sym_consensus_mode, + anon_sym_max_iterations, + anon_sym_iter_start, + anon_sym_stability, + anon_sym_judge_timeout, + anon_sym_irreconcilable_after, + anon_sym_strict_judge, + anon_sym_branch_chain, + anon_sym_for, + anon_sym_until, + [1366] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(299), 15, + anon_sym_RBRACE, + anon_sym_agents, + anon_sym_reviewers, + anon_sym_template_init, + anon_sym_template_refine, + anon_sym_consensus_mode, + anon_sym_max_iterations, + anon_sym_iter_start, + anon_sym_stability, + anon_sym_judge_timeout, + anon_sym_irreconcilable_after, + anon_sym_strict_judge, + anon_sym_branch_chain, + anon_sym_for, + anon_sym_until, + [1387] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(301), 15, + anon_sym_RBRACE, + anon_sym_agents, + anon_sym_reviewers, + anon_sym_template_init, + anon_sym_template_refine, + anon_sym_consensus_mode, + anon_sym_max_iterations, + anon_sym_iter_start, + anon_sym_stability, + anon_sym_judge_timeout, + anon_sym_irreconcilable_after, + anon_sym_strict_judge, + anon_sym_branch_chain, + anon_sym_for, + anon_sym_until, + [1408] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(299), 13, + ACTIONS(303), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6505,12 +6622,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1490] = 2, + [1429] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(301), 13, + ACTIONS(305), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6522,12 +6641,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1509] = 2, + [1450] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(303), 13, + ACTIONS(21), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6539,12 +6660,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1528] = 2, + [1471] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(305), 13, + ACTIONS(307), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6556,12 +6679,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1547] = 2, + [1492] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(307), 13, + ACTIONS(309), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6573,12 +6698,14 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1566] = 2, + [1513] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(309), 13, + ACTIONS(311), 15, anon_sym_RBRACE, anon_sym_max_retries, anon_sym_memory, @@ -6590,242 +6717,374 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_test_first, anon_sym_attempts, anon_sym_escalate_after, + anon_sym_tiers, + anon_sym_budget, anon_sym_pattern, anon_sym_param, - [1585] = 5, - ACTIONS(3), 1, - sym_comment, - ACTIONS(315), 1, - sym_identifier, - ACTIONS(313), 2, - sym_string, - sym_raw_string, - STATE(114), 3, - sym__effort_value, - sym_tier_value, - sym__string_value, - ACTIONS(311), 6, - anon_sym_cheap, - anon_sym_expensive, - anon_sym_coordinator, - anon_sym_reasoning, - anon_sym_execution, - anon_sym_mechanical, - [1609] = 5, - ACTIONS(3), 1, - sym_comment, - ACTIONS(321), 1, - sym_identifier, - ACTIONS(319), 2, - sym_string, - sym_raw_string, - STATE(94), 3, - sym__effort_value, - sym_tier_value, - sym__string_value, - ACTIONS(317), 6, - anon_sym_cheap, - anon_sym_expensive, - anon_sym_coordinator, - anon_sym_reasoning, - anon_sym_execution, - anon_sym_mechanical, - [1633] = 10, + [1534] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(323), 1, + ACTIONS(313), 14, anon_sym_RBRACE, - ACTIONS(325), 1, anon_sym_tier, - ACTIONS(327), 1, - anon_sym_model, - ACTIONS(329), 1, - anon_sym_effort, - ACTIONS(331), 1, - anon_sym_privacy, - ACTIONS(333), 1, - anon_sym_default, - ACTIONS(335), 1, - anon_sym_extra, - STATE(82), 1, - sym_extra_block, - STATE(62), 2, - sym_client_field, - aux_sym_client_declaration_repeat1, - [1665] = 10, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1554] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(325), 1, + ACTIONS(315), 14, + anon_sym_RBRACE, anon_sym_tier, - ACTIONS(327), 1, - anon_sym_model, - ACTIONS(329), 1, - anon_sym_effort, - ACTIONS(331), 1, - anon_sym_privacy, - ACTIONS(333), 1, - anon_sym_default, - ACTIONS(335), 1, - anon_sym_extra, - ACTIONS(337), 1, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1574] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(317), 14, anon_sym_RBRACE, - STATE(82), 1, - sym_extra_block, - STATE(63), 2, - sym_client_field, - aux_sym_client_declaration_repeat1, - [1697] = 10, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1594] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(325), 1, + ACTIONS(319), 14, + anon_sym_RBRACE, anon_sym_tier, - ACTIONS(327), 1, - anon_sym_model, - ACTIONS(329), 1, - anon_sym_effort, - ACTIONS(331), 1, - anon_sym_privacy, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1614] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(321), 14, + anon_sym_RBRACE, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1634] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(323), 14, + anon_sym_RBRACE, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1654] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(325), 14, + anon_sym_RBRACE, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1674] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(307), 14, + anon_sym_RBRACE, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1694] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(327), 14, + anon_sym_RBRACE, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1714] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(309), 14, + anon_sym_RBRACE, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_description, + anon_sym_depends_on, + anon_sym_produces, + anon_sym_max_retries, + anon_sym_timeout, + anon_sym_tools, + anon_sym_template, + anon_sym_scope, + anon_sym_memory, + anon_sym_context, + [1734] = 5, + ACTIONS(3), 1, + sym_comment, ACTIONS(333), 1, - anon_sym_default, + sym_identifier, + ACTIONS(331), 2, + sym_string, + sym_raw_string, + STATE(101), 3, + sym__effort_value, + sym_tier_value, + sym__string_value, + ACTIONS(329), 6, + anon_sym_cheap, + anon_sym_expensive, + anon_sym_coordinator, + anon_sym_reasoning, + anon_sym_execution, + anon_sym_mechanical, + [1758] = 7, + ACTIONS(3), 1, + sym_comment, ACTIONS(335), 1, - anon_sym_extra, - ACTIONS(339), 1, anon_sym_RBRACE, - STATE(82), 1, - sym_extra_block, - STATE(60), 2, - sym_client_field, - aux_sym_client_declaration_repeat1, - [1729] = 10, + ACTIONS(343), 1, + anon_sym_importance, + ACTIONS(346), 1, + anon_sym_read_limit, + ACTIONS(337), 2, + anon_sym_read_ns, + anon_sym_staleness_sources, + STATE(65), 2, + sym_memory_field, + aux_sym_memory_block_repeat1, + ACTIONS(340), 3, + anon_sym_write_ns, + anon_sym_read_query, + anon_sym_write_content, + [1784] = 10, ACTIONS(3), 1, sym_comment, - ACTIONS(325), 1, + ACTIONS(349), 1, + anon_sym_RBRACE, + ACTIONS(351), 1, anon_sym_tier, - ACTIONS(327), 1, + ACTIONS(354), 1, anon_sym_model, - ACTIONS(329), 1, + ACTIONS(357), 1, anon_sym_effort, - ACTIONS(331), 1, + ACTIONS(360), 1, anon_sym_privacy, - ACTIONS(333), 1, + ACTIONS(363), 1, anon_sym_default, - ACTIONS(335), 1, + ACTIONS(366), 1, anon_sym_extra, - ACTIONS(341), 1, - anon_sym_RBRACE, - STATE(82), 1, + STATE(89), 1, sym_extra_block, - STATE(63), 2, + STATE(66), 2, sym_client_field, aux_sym_client_declaration_repeat1, - [1761] = 10, + [1816] = 10, ACTIONS(3), 1, sym_comment, - ACTIONS(343), 1, + ACTIONS(369), 1, anon_sym_RBRACE, - ACTIONS(345), 1, + ACTIONS(371), 1, anon_sym_tier, - ACTIONS(348), 1, + ACTIONS(373), 1, anon_sym_model, - ACTIONS(351), 1, + ACTIONS(375), 1, anon_sym_effort, - ACTIONS(354), 1, + ACTIONS(377), 1, anon_sym_privacy, - ACTIONS(357), 1, + ACTIONS(379), 1, anon_sym_default, - ACTIONS(360), 1, + ACTIONS(381), 1, anon_sym_extra, - STATE(82), 1, + STATE(89), 1, sym_extra_block, - STATE(63), 2, + STATE(66), 2, sym_client_field, aux_sym_client_declaration_repeat1, - [1793] = 7, + [1848] = 7, ACTIONS(3), 1, sym_comment, - ACTIONS(363), 1, + ACTIONS(383), 1, anon_sym_RBRACE, - ACTIONS(369), 1, + ACTIONS(389), 1, anon_sym_importance, - ACTIONS(371), 1, + ACTIONS(391), 1, anon_sym_read_limit, - ACTIONS(365), 2, + ACTIONS(385), 2, anon_sym_read_ns, anon_sym_staleness_sources, - STATE(66), 2, + STATE(65), 2, sym_memory_field, aux_sym_memory_block_repeat1, - ACTIONS(367), 3, + ACTIONS(387), 3, anon_sym_write_ns, anon_sym_read_query, anon_sym_write_content, - [1819] = 7, + [1874] = 7, ACTIONS(3), 1, sym_comment, - ACTIONS(369), 1, + ACTIONS(389), 1, anon_sym_importance, - ACTIONS(371), 1, + ACTIONS(391), 1, anon_sym_read_limit, - ACTIONS(373), 1, + ACTIONS(393), 1, anon_sym_RBRACE, - ACTIONS(365), 2, + ACTIONS(385), 2, anon_sym_read_ns, anon_sym_staleness_sources, - STATE(64), 2, + STATE(68), 2, sym_memory_field, aux_sym_memory_block_repeat1, - ACTIONS(367), 3, + ACTIONS(387), 3, anon_sym_write_ns, anon_sym_read_query, anon_sym_write_content, - [1845] = 7, + [1900] = 10, ACTIONS(3), 1, sym_comment, + ACTIONS(371), 1, + anon_sym_tier, + ACTIONS(373), 1, + anon_sym_model, ACTIONS(375), 1, + anon_sym_effort, + ACTIONS(377), 1, + anon_sym_privacy, + ACTIONS(379), 1, + anon_sym_default, + ACTIONS(381), 1, + anon_sym_extra, + ACTIONS(395), 1, anon_sym_RBRACE, - ACTIONS(383), 1, + STATE(89), 1, + sym_extra_block, + STATE(67), 2, + sym_client_field, + aux_sym_client_declaration_repeat1, + [1932] = 7, + ACTIONS(3), 1, + sym_comment, + ACTIONS(389), 1, anon_sym_importance, - ACTIONS(386), 1, + ACTIONS(391), 1, anon_sym_read_limit, - ACTIONS(377), 2, + ACTIONS(397), 1, + anon_sym_RBRACE, + ACTIONS(385), 2, anon_sym_read_ns, anon_sym_staleness_sources, - STATE(66), 2, + STATE(72), 2, sym_memory_field, aux_sym_memory_block_repeat1, - ACTIONS(380), 3, + ACTIONS(387), 3, anon_sym_write_ns, anon_sym_read_query, anon_sym_write_content, - [1871] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(389), 8, - ts_builtin_sym_end, - anon_sym_include, - anon_sym_client, - anon_sym_tier, - anon_sym_vars, - anon_sym_prompt, - anon_sym_agent, - anon_sym_workflow, - [1885] = 3, + [1958] = 7, ACTIONS(3), 1, sym_comment, - STATE(182), 1, - sym_tier_alias_name, - ACTIONS(391), 7, - anon_sym_cheap, - anon_sym_expensive, - anon_sym_coordinator, - anon_sym_reasoning, - anon_sym_execution, - anon_sym_mechanical, - sym_identifier, - [1901] = 2, + ACTIONS(389), 1, + anon_sym_importance, + ACTIONS(391), 1, + anon_sym_read_limit, + ACTIONS(399), 1, + anon_sym_RBRACE, + ACTIONS(385), 2, + anon_sym_read_ns, + anon_sym_staleness_sources, + STATE(65), 2, + sym_memory_field, + aux_sym_memory_block_repeat1, + ACTIONS(387), 3, + anon_sym_write_ns, + anon_sym_read_query, + anon_sym_write_content, + [1984] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(393), 8, + ACTIONS(401), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6834,10 +7093,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [1915] = 2, + [1998] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(395), 8, + ACTIONS(403), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6846,10 +7105,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [1929] = 2, + [2012] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(397), 8, + ACTIONS(405), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6858,24 +7117,25 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [1943] = 2, + [2026] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(399), 8, - anon_sym_RBRACE, - anon_sym_read_ns, - anon_sym_write_ns, - anon_sym_importance, - anon_sym_staleness_sources, - anon_sym_read_query, - anon_sym_read_limit, - anon_sym_write_content, - [1957] = 3, + STATE(209), 1, + sym_tier_alias_name, + ACTIONS(407), 7, + anon_sym_cheap, + anon_sym_expensive, + anon_sym_coordinator, + anon_sym_reasoning, + anon_sym_execution, + anon_sym_mechanical, + sym_identifier, + [2042] = 3, ACTIONS(3), 1, sym_comment, - STATE(41), 1, + STATE(190), 1, sym_tier_alias_name, - ACTIONS(401), 7, + ACTIONS(407), 7, anon_sym_cheap, anon_sym_expensive, anon_sym_coordinator, @@ -6883,10 +7143,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_execution, anon_sym_mechanical, sym_identifier, - [1973] = 2, + [2058] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(403), 8, + ACTIONS(409), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6895,10 +7155,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [1987] = 2, + [2072] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(405), 8, + ACTIONS(411), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6907,10 +7167,23 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [2001] = 2, + [2086] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(407), 8, + STATE(58), 1, + sym_tier_alias_name, + ACTIONS(413), 7, + anon_sym_cheap, + anon_sym_expensive, + anon_sym_coordinator, + anon_sym_reasoning, + anon_sym_execution, + anon_sym_mechanical, + sym_identifier, + [2102] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(415), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6919,10 +7192,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [2015] = 2, + [2116] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(409), 8, + ACTIONS(417), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6931,10 +7204,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [2029] = 2, + [2130] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(411), 8, + ACTIONS(419), 8, ts_builtin_sym_end, anon_sym_include, anon_sym_client, @@ -6943,52 +7216,73 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_prompt, anon_sym_agent, anon_sym_workflow, - [2043] = 5, + [2144] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(413), 1, + ACTIONS(421), 8, anon_sym_RBRACE, - STATE(159), 1, - sym__string_value, - STATE(79), 2, - sym_extra_pair, - aux_sym_extra_block_repeat1, - ACTIONS(415), 3, - sym_string, - sym_raw_string, + anon_sym_read_ns, + anon_sym_write_ns, + anon_sym_importance, + anon_sym_staleness_sources, + anon_sym_read_query, + anon_sym_read_limit, + anon_sym_write_content, + [2158] = 3, + ACTIONS(3), 1, + sym_comment, + STATE(137), 1, + sym_tier_alias_name, + ACTIONS(423), 7, + anon_sym_cheap, + anon_sym_expensive, + anon_sym_coordinator, + anon_sym_reasoning, + anon_sym_execution, + anon_sym_mechanical, sym_identifier, - [2062] = 4, + [2174] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(425), 8, + ts_builtin_sym_end, + anon_sym_include, + anon_sym_client, + anon_sym_tier, + anon_sym_vars, + anon_sym_prompt, + anon_sym_agent, + anon_sym_workflow, + [2188] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(418), 1, + ACTIONS(427), 7, anon_sym_RBRACE, - STATE(85), 2, - sym_verify_field, - aux_sym_verify_block_repeat1, - ACTIONS(420), 4, - anon_sym_compile, - anon_sym_clippy, - anon_sym_test, - anon_sym_impact_tests, - [2079] = 6, + anon_sym_tier, + anon_sym_model, + anon_sym_effort, + anon_sym_privacy, + anon_sym_default, + anon_sym_extra, + [2201] = 6, ACTIONS(3), 1, sym_comment, - ACTIONS(422), 1, + ACTIONS(429), 1, anon_sym_loop, - ACTIONS(424), 1, + ACTIONS(431), 1, anon_sym_RBRACK, - ACTIONS(426), 1, + ACTIONS(433), 1, anon_sym_for, - ACTIONS(428), 1, + ACTIONS(435), 1, sym_identifier, - STATE(86), 3, + STATE(95), 3, sym_loop_block, sym_for_block, aux_sym_step_list_repeat1, - [2100] = 2, + [2222] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(430), 7, + ACTIONS(437), 7, anon_sym_RBRACE, anon_sym_tier, anon_sym_model, @@ -6996,10 +7290,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_privacy, anon_sym_default, anon_sym_extra, - [2113] = 2, + [2235] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(432), 7, + ACTIONS(439), 7, anon_sym_RBRACE, anon_sym_tier, anon_sym_model, @@ -7007,131 +7301,121 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_privacy, anon_sym_default, anon_sym_extra, - [2126] = 5, + [2248] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(434), 1, + ACTIONS(441), 1, anon_sym_RBRACE, - STATE(159), 1, + STATE(161), 1, sym__string_value, - STATE(79), 2, + STATE(93), 2, sym_extra_pair, aux_sym_extra_block_repeat1, - ACTIONS(436), 3, + ACTIONS(443), 3, sym_string, sym_raw_string, sym_identifier, - [2145] = 4, + [2267] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(438), 1, + ACTIONS(445), 1, anon_sym_RBRACE, - STATE(88), 2, + STATE(94), 2, sym_verify_field, aux_sym_verify_block_repeat1, - ACTIONS(420), 4, + ACTIONS(447), 4, anon_sym_compile, anon_sym_clippy, anon_sym_test, anon_sym_impact_tests, - [2162] = 6, - ACTIONS(3), 1, - sym_comment, - ACTIONS(422), 1, - anon_sym_loop, - ACTIONS(426), 1, - anon_sym_for, - ACTIONS(440), 1, - anon_sym_RBRACK, - ACTIONS(442), 1, - sym_identifier, - STATE(89), 3, - sym_loop_block, - sym_for_block, - aux_sym_step_list_repeat1, - [2183] = 2, + [2284] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(444), 7, + ACTIONS(449), 1, anon_sym_RBRACE, - anon_sym_tier, - anon_sym_model, - anon_sym_effort, - anon_sym_privacy, - anon_sym_default, - anon_sym_extra, - [2196] = 4, + STATE(161), 1, + sym__string_value, + STATE(93), 2, + sym_extra_pair, + aux_sym_extra_block_repeat1, + ACTIONS(451), 3, + sym_string, + sym_raw_string, + sym_identifier, + [2303] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(446), 1, + ACTIONS(454), 1, anon_sym_RBRACE, - STATE(88), 2, + STATE(94), 2, sym_verify_field, aux_sym_verify_block_repeat1, - ACTIONS(448), 4, + ACTIONS(456), 4, anon_sym_compile, anon_sym_clippy, anon_sym_test, anon_sym_impact_tests, - [2213] = 6, + [2320] = 6, ACTIONS(3), 1, sym_comment, - ACTIONS(451), 1, + ACTIONS(429), 1, anon_sym_loop, - ACTIONS(454), 1, - anon_sym_RBRACK, - ACTIONS(456), 1, + ACTIONS(433), 1, anon_sym_for, ACTIONS(459), 1, + anon_sym_RBRACK, + ACTIONS(461), 1, sym_identifier, - STATE(89), 3, + STATE(96), 3, sym_loop_block, sym_for_block, aux_sym_step_list_repeat1, - [2234] = 3, + [2341] = 6, ACTIONS(3), 1, sym_comment, - STATE(94), 1, - sym_tier_value, - ACTIONS(462), 6, - anon_sym_cheap, - anon_sym_expensive, - anon_sym_coordinator, - anon_sym_reasoning, - anon_sym_execution, - anon_sym_mechanical, - [2249] = 5, + ACTIONS(463), 1, + anon_sym_loop, + ACTIONS(466), 1, + anon_sym_RBRACK, + ACTIONS(468), 1, + anon_sym_for, + ACTIONS(471), 1, + sym_identifier, + STATE(96), 3, + sym_loop_block, + sym_for_block, + aux_sym_step_list_repeat1, + [2362] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(464), 1, + ACTIONS(474), 1, anon_sym_LBRACE, - ACTIONS(466), 1, + ACTIONS(476), 1, anon_sym_agent, - ACTIONS(468), 1, + ACTIONS(478), 1, anon_sym_command, - STATE(25), 4, + STATE(23), 4, sym__until_condition, sym_until_verify, sym_until_agent, sym_until_command, - [2268] = 5, + [2381] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(470), 1, + ACTIONS(480), 1, anon_sym_RBRACE, - ACTIONS(474), 1, - anon_sym_effort, - STATE(98), 2, - sym_reviewer_field, - aux_sym_reviewer_entry_repeat1, - ACTIONS(472), 3, - anon_sym_model, - anon_sym_id, - sym_identifier, - [2287] = 2, + STATE(94), 2, + sym_verify_field, + aux_sym_verify_block_repeat1, + ACTIONS(447), 4, + anon_sym_compile, + anon_sym_clippy, + anon_sym_test, + anon_sym_impact_tests, + [2398] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(476), 7, + ACTIONS(482), 7, anon_sym_RBRACE, anon_sym_tier, anon_sym_model, @@ -7139,10 +7423,23 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_privacy, anon_sym_default, anon_sym_extra, - [2300] = 2, + [2411] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(484), 1, + anon_sym_RBRACE, + STATE(98), 2, + sym_verify_field, + aux_sym_verify_block_repeat1, + ACTIONS(447), 4, + anon_sym_compile, + anon_sym_clippy, + anon_sym_test, + anon_sym_impact_tests, + [2428] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(478), 7, + ACTIONS(486), 7, anon_sym_RBRACE, anon_sym_tier, anon_sym_model, @@ -7150,10 +7447,10 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_privacy, anon_sym_default, anon_sym_extra, - [2313] = 2, + [2441] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(480), 7, + ACTIONS(488), 7, anon_sym_RBRACE, anon_sym_tier, anon_sym_model, @@ -7161,1176 +7458,1438 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_privacy, anon_sym_default, anon_sym_extra, - [2326] = 4, + [2454] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(482), 1, - anon_sym_RBRACE, - STATE(99), 2, - sym_verify_field, - aux_sym_verify_block_repeat1, - ACTIONS(420), 4, - anon_sym_compile, - anon_sym_clippy, - anon_sym_test, - anon_sym_impact_tests, - [2343] = 5, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(476), 1, + anon_sym_agent, + ACTIONS(478), 1, + anon_sym_command, + STATE(25), 4, + sym__until_condition, + sym_until_verify, + sym_until_agent, + sym_until_command, + [2473] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(484), 1, + ACTIONS(490), 1, anon_sym_RBRACE, - STATE(159), 1, + STATE(161), 1, sym__string_value, - STATE(84), 2, + STATE(91), 2, sym_extra_pair, aux_sym_extra_block_repeat1, - ACTIONS(436), 3, + ACTIONS(443), 3, sym_string, sym_raw_string, sym_identifier, - [2362] = 5, + [2492] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(486), 1, - anon_sym_RBRACE, - ACTIONS(491), 1, - anon_sym_effort, - STATE(98), 2, - sym_reviewer_field, - aux_sym_reviewer_entry_repeat1, - ACTIONS(488), 3, - anon_sym_model, - anon_sym_id, - sym_identifier, - [2381] = 4, + STATE(101), 1, + sym_tier_value, + ACTIONS(492), 6, + anon_sym_cheap, + anon_sym_expensive, + anon_sym_coordinator, + anon_sym_reasoning, + anon_sym_execution, + anon_sym_mechanical, + [2507] = 4, ACTIONS(3), 1, sym_comment, ACTIONS(494), 1, anon_sym_RBRACE, - STATE(88), 2, + STATE(92), 2, sym_verify_field, aux_sym_verify_block_repeat1, - ACTIONS(420), 4, + ACTIONS(447), 4, anon_sym_compile, anon_sym_clippy, anon_sym_test, anon_sym_impact_tests, - [2398] = 5, - ACTIONS(3), 1, - sym_comment, - ACTIONS(464), 1, - anon_sym_LBRACE, - ACTIONS(466), 1, - anon_sym_agent, - ACTIONS(468), 1, - anon_sym_command, - STATE(31), 4, - sym__until_condition, - sym_until_verify, - sym_until_agent, - sym_until_command, - [2417] = 5, + [2524] = 5, ACTIONS(3), 1, sym_comment, ACTIONS(496), 1, anon_sym_RBRACE, ACTIONS(500), 1, - anon_sym_max_spawn, + anon_sym_impact_scope, ACTIONS(498), 2, + anon_sym_owned, + anon_sym_read_only, + STATE(109), 2, + sym_scope_field, + aux_sym_scope_block_repeat1, + [2542] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(502), 1, + anon_sym_RBRACE, + ACTIONS(506), 1, + anon_sym_depth, + ACTIONS(504), 2, + anon_sym_callers_of, + anon_sym_tests_for, + STATE(111), 2, + sym_context_field, + aux_sym_context_block_repeat1, + [2560] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(508), 1, + anon_sym_RBRACE, + ACTIONS(513), 1, + anon_sym_impact_scope, + ACTIONS(510), 2, + anon_sym_owned, + anon_sym_read_only, + STATE(109), 2, + sym_scope_field, + aux_sym_scope_block_repeat1, + [2578] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(516), 1, + anon_sym_RBRACE, + ACTIONS(520), 1, + anon_sym_max_spawn, + ACTIONS(518), 2, anon_sym_discover, anon_sym_reduce, - STATE(103), 2, + STATE(112), 2, sym_map_reduce_field, aux_sym_pattern_block_repeat1, - [2435] = 5, + [2596] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(522), 1, + anon_sym_RBRACE, + ACTIONS(527), 1, + anon_sym_depth, + ACTIONS(524), 2, + anon_sym_callers_of, + anon_sym_tests_for, + STATE(111), 2, + sym_context_field, + aux_sym_context_block_repeat1, + [2614] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(500), 1, + ACTIONS(520), 1, anon_sym_max_spawn, - ACTIONS(502), 1, + ACTIONS(530), 1, anon_sym_RBRACE, - ACTIONS(498), 2, + ACTIONS(518), 2, anon_sym_discover, anon_sym_reduce, - STATE(101), 2, + STATE(115), 2, sym_map_reduce_field, aux_sym_pattern_block_repeat1, - [2453] = 5, + [2632] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(532), 1, + anon_sym_RBRACE, + ACTIONS(534), 1, + anon_sym_tier, + ACTIONS(536), 2, + anon_sym_id, + sym_identifier, + STATE(114), 2, + sym_reviewer_field, + aux_sym_reviewer_entry_repeat1, + [2650] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(538), 1, + anon_sym_RBRACE, + ACTIONS(540), 1, + anon_sym_tier, + ACTIONS(543), 2, + anon_sym_id, + sym_identifier, + STATE(114), 2, + sym_reviewer_field, + aux_sym_reviewer_entry_repeat1, + [2668] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(504), 1, + ACTIONS(546), 1, anon_sym_RBRACE, - ACTIONS(509), 1, + ACTIONS(551), 1, anon_sym_max_spawn, - ACTIONS(506), 2, + ACTIONS(548), 2, anon_sym_discover, anon_sym_reduce, - STATE(103), 2, + STATE(115), 2, sym_map_reduce_field, aux_sym_pattern_block_repeat1, - [2471] = 5, - ACTIONS(3), 1, - sym_comment, - ACTIONS(512), 1, - anon_sym_RBRACE, - ACTIONS(516), 1, - anon_sym_impact_scope, - ACTIONS(514), 2, - anon_sym_owned, - anon_sym_read_only, - STATE(106), 2, - sym_scope_field, - aux_sym_scope_block_repeat1, - [2489] = 5, + [2686] = 5, ACTIONS(3), 1, sym_comment, - STATE(116), 1, + STATE(128), 1, sym_var_type, - STATE(174), 1, + STATE(203), 1, sym__string_value, - ACTIONS(518), 2, + ACTIONS(554), 2, anon_sym_file, anon_sym_dir, - ACTIONS(520), 2, + ACTIONS(556), 2, sym_string, sym_raw_string, - [2507] = 5, + [2704] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(522), 1, - anon_sym_RBRACE, - ACTIONS(527), 1, + ACTIONS(500), 1, anon_sym_impact_scope, - ACTIONS(524), 2, + ACTIONS(558), 1, + anon_sym_RBRACE, + ACTIONS(498), 2, anon_sym_owned, anon_sym_read_only, - STATE(106), 2, + STATE(107), 2, sym_scope_field, aux_sym_scope_block_repeat1, - [2525] = 5, + [2722] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(530), 1, - anon_sym_RBRACE, - ACTIONS(535), 1, + ACTIONS(506), 1, anon_sym_depth, - ACTIONS(532), 2, + ACTIONS(560), 1, + anon_sym_RBRACE, + ACTIONS(504), 2, anon_sym_callers_of, anon_sym_tests_for, - STATE(107), 2, + STATE(108), 2, sym_context_field, aux_sym_context_block_repeat1, - [2543] = 5, + [2740] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(538), 1, + ACTIONS(562), 1, anon_sym_RBRACE, - ACTIONS(542), 1, - anon_sym_depth, - ACTIONS(540), 2, - anon_sym_callers_of, - anon_sym_tests_for, - STATE(107), 2, - sym_context_field, - aux_sym_context_block_repeat1, - [2561] = 4, + ACTIONS(564), 1, + anon_sym_peer_template, + ACTIONS(566), 1, + sym_identifier, + STATE(127), 2, + sym_peer_template, + aux_sym_for_block_repeat1, + [2757] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(474), 1, - anon_sym_effort, - STATE(92), 2, - sym_reviewer_field, - aux_sym_reviewer_entry_repeat1, - ACTIONS(472), 3, - anon_sym_model, + ACTIONS(534), 1, + anon_sym_tier, + ACTIONS(536), 2, anon_sym_id, sym_identifier, - [2577] = 5, + STATE(113), 2, + sym_reviewer_field, + aux_sym_reviewer_entry_repeat1, + [2772] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(542), 1, - anon_sym_depth, - ACTIONS(544), 1, + ACTIONS(568), 1, anon_sym_RBRACE, - ACTIONS(540), 2, - anon_sym_callers_of, - anon_sym_tests_for, - STATE(108), 2, - sym_context_field, - aux_sym_context_block_repeat1, - [2595] = 5, + ACTIONS(570), 1, + anon_sym_wall, + ACTIONS(572), 1, + anon_sym_usd, + STATE(129), 2, + sym_budget_field, + aux_sym_budget_block_repeat1, + [2789] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(570), 1, + anon_sym_wall, + ACTIONS(572), 1, + anon_sym_usd, + ACTIONS(574), 1, + anon_sym_RBRACE, + STATE(121), 2, + sym_budget_field, + aux_sym_budget_block_repeat1, + [2806] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(516), 1, - anon_sym_impact_scope, - ACTIONS(546), 1, - anon_sym_RBRACE, - ACTIONS(514), 2, - anon_sym_owned, - anon_sym_read_only, - STATE(104), 2, - sym_scope_field, - aux_sym_scope_block_repeat1, - [2613] = 2, + ACTIONS(576), 1, + anon_sym_RBRACK, + ACTIONS(578), 2, + sym_string, + sym_raw_string, + STATE(123), 2, + sym__string_value, + aux_sym_string_list_repeat1, + [2821] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(548), 5, + ACTIONS(581), 5, anon_sym_RBRACE, anon_sym_compile, anon_sym_clippy, anon_sym_test, anon_sym_impact_tests, - [2624] = 4, + [2832] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(550), 1, + ACTIONS(583), 1, anon_sym_RBRACK, - ACTIONS(552), 2, + ACTIONS(585), 2, sym_string, sym_raw_string, - STATE(113), 2, + STATE(130), 2, sym__string_value, aux_sym_string_list_repeat1, - [2639] = 3, + [2847] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(555), 1, - anon_sym_RBRACE, - ACTIONS(557), 4, - anon_sym_model, - anon_sym_effort, - anon_sym_id, + ACTIONS(564), 1, + anon_sym_peer_template, + ACTIONS(566), 1, sym_identifier, - [2652] = 4, + ACTIONS(587), 1, + anon_sym_RBRACE, + STATE(127), 2, + sym_peer_template, + aux_sym_for_block_repeat1, + [2864] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(559), 1, - anon_sym_RBRACK, - ACTIONS(561), 2, - sym_string, - sym_raw_string, - STATE(113), 2, - sym__string_value, - aux_sym_string_list_repeat1, - [2667] = 4, + ACTIONS(589), 1, + anon_sym_RBRACE, + ACTIONS(591), 1, + anon_sym_peer_template, + ACTIONS(594), 1, + sym_identifier, + STATE(127), 2, + sym_peer_template, + aux_sym_for_block_repeat1, + [2881] = 4, ACTIONS(3), 1, sym_comment, - STATE(170), 1, + STATE(202), 1, sym__string_value, - ACTIONS(563), 2, + ACTIONS(597), 2, anon_sym_RBRACE, sym_identifier, - ACTIONS(565), 2, + ACTIONS(599), 2, sym_string, sym_raw_string, - [2682] = 5, + [2896] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(567), 1, + ACTIONS(601), 1, anon_sym_RBRACE, - ACTIONS(569), 1, + ACTIONS(603), 1, + anon_sym_wall, + ACTIONS(606), 1, + anon_sym_usd, + STATE(129), 2, + sym_budget_field, + aux_sym_budget_block_repeat1, + [2913] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(609), 1, + anon_sym_RBRACK, + ACTIONS(611), 2, + sym_string, + sym_raw_string, + STATE(123), 2, + sym__string_value, + aux_sym_string_list_repeat1, + [2928] = 5, + ACTIONS(3), 1, + sym_comment, + ACTIONS(564), 1, anon_sym_peer_template, - ACTIONS(571), 1, + ACTIONS(566), 1, sym_identifier, - STATE(118), 2, + ACTIONS(613), 1, + anon_sym_RBRACE, + STATE(127), 2, sym_peer_template, aux_sym_for_block_repeat1, - [2699] = 5, + [2945] = 5, ACTIONS(3), 1, sym_comment, - ACTIONS(573), 1, - anon_sym_RBRACE, - ACTIONS(575), 1, + ACTIONS(564), 1, anon_sym_peer_template, - ACTIONS(578), 1, + ACTIONS(566), 1, sym_identifier, - STATE(118), 2, + ACTIONS(615), 1, + anon_sym_RBRACE, + STATE(127), 2, sym_peer_template, aux_sym_for_block_repeat1, - [2716] = 3, + [2962] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(476), 1, + ACTIONS(617), 4, anon_sym_RBRACE, - ACTIONS(581), 4, - anon_sym_model, - anon_sym_effort, - anon_sym_id, + anon_sym_callers_of, + anon_sym_tests_for, + anon_sym_depth, + [2972] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(619), 1, + anon_sym_RBRACE, + ACTIONS(621), 1, sym_identifier, - [2729] = 4, + STATE(134), 2, + sym_vars_pair, + aux_sym_vars_block_repeat1, + [2986] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(583), 1, + ACTIONS(626), 1, anon_sym_RBRACK, - ACTIONS(585), 2, - sym_string, - sym_raw_string, - STATE(115), 2, - sym__string_value, - aux_sym_string_list_repeat1, - [2744] = 5, + ACTIONS(624), 3, + anon_sym_loop, + anon_sym_for, + sym_identifier, + [2998] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(569), 1, - anon_sym_peer_template, - ACTIONS(571), 1, - sym_identifier, - ACTIONS(587), 1, + ACTIONS(628), 1, anon_sym_RBRACE, - STATE(118), 2, - sym_peer_template, - aux_sym_for_block_repeat1, - [2761] = 3, + ACTIONS(630), 1, + sym_identifier, + STATE(140), 2, + sym_agent_tier, + aux_sym_tiers_block_repeat1, + [3012] = 3, ACTIONS(3), 1, sym_comment, - STATE(39), 1, - sym_consensus_mode_value, - ACTIONS(589), 3, - anon_sym_strict, - anon_sym_partial_ok, - anon_sym_explore, - [2773] = 2, + ACTIONS(632), 1, + anon_sym_RBRACE, + ACTIONS(634), 3, + anon_sym_tier, + anon_sym_id, + sym_identifier, + [3024] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(591), 4, + ACTIONS(636), 4, anon_sym_RBRACE, sym_string, sym_raw_string, sym_identifier, - [2783] = 2, + [3034] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(593), 4, + ACTIONS(638), 1, anon_sym_RBRACE, - anon_sym_owned, - anon_sym_read_only, - anon_sym_impact_scope, - [2793] = 2, + ACTIONS(640), 1, + sym_identifier, + STATE(134), 2, + sym_vars_pair, + aux_sym_vars_block_repeat1, + [3048] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(595), 4, + ACTIONS(630), 1, + sym_identifier, + ACTIONS(642), 1, anon_sym_RBRACE, - anon_sym_callers_of, - anon_sym_tests_for, - anon_sym_depth, - [2803] = 4, + STATE(152), 2, + sym_agent_tier, + aux_sym_tiers_block_repeat1, + [3062] = 3, + ACTIONS(3), 1, + sym_comment, + STATE(58), 1, + sym__string_value, + ACTIONS(644), 3, + sym_string, + sym_raw_string, + sym_identifier, + [3074] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(597), 1, + ACTIONS(646), 4, anon_sym_RBRACE, - ACTIONS(599), 1, + anon_sym_discover, + anon_sym_reduce, + anon_sym_max_spawn, + [3084] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(564), 1, + anon_sym_peer_template, + ACTIONS(648), 1, sym_identifier, - STATE(134), 2, - sym_vars_pair, - aux_sym_vars_block_repeat1, - [2817] = 4, + STATE(126), 2, + sym_peer_template, + aux_sym_for_block_repeat1, + [3098] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(601), 1, + ACTIONS(650), 1, anon_sym_LBRACE, - ACTIONS(603), 1, + ACTIONS(652), 1, anon_sym_RBRACK, - STATE(131), 2, + STATE(150), 2, sym_reviewer_entry, aux_sym_reviewer_list_repeat1, - [2831] = 3, + [3112] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(607), 1, + ACTIONS(269), 1, anon_sym_RBRACK, - ACTIONS(605), 3, + ACTIONS(654), 3, anon_sym_loop, anon_sym_for, sym_identifier, - [2843] = 3, + [3124] = 4, ACTIONS(3), 1, sym_comment, - STATE(53), 1, - sym_strategy_value, - ACTIONS(609), 3, - anon_sym_single_pass, - anon_sym_refine, + ACTIONS(640), 1, sym_identifier, - [2855] = 2, + ACTIONS(656), 1, + anon_sym_RBRACE, + STATE(139), 2, + sym_vars_pair, + aux_sym_vars_block_repeat1, + [3138] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(611), 4, - anon_sym_RBRACE, - anon_sym_discover, - anon_sym_reduce, - anon_sym_max_spawn, - [2865] = 4, + ACTIONS(564), 1, + anon_sym_peer_template, + ACTIONS(658), 1, + sym_identifier, + STATE(119), 2, + sym_peer_template, + aux_sym_for_block_repeat1, + [3152] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(613), 1, + ACTIONS(564), 1, + anon_sym_peer_template, + ACTIONS(660), 1, + sym_identifier, + STATE(132), 2, + sym_peer_template, + aux_sym_for_block_repeat1, + [3166] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(267), 1, + anon_sym_RBRACK, + ACTIONS(662), 3, + anon_sym_loop, + anon_sym_for, + sym_identifier, + [3178] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(664), 1, anon_sym_LBRACE, - ACTIONS(616), 1, + ACTIONS(667), 1, anon_sym_RBRACK, - STATE(131), 2, + STATE(150), 2, sym_reviewer_entry, aux_sym_reviewer_list_repeat1, - [2879] = 4, + [3192] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(618), 1, + STATE(53), 1, + sym_strategy_value, + ACTIONS(669), 3, + anon_sym_single_pass, + anon_sym_refine, + sym_identifier, + [3204] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(671), 1, anon_sym_RBRACE, - ACTIONS(620), 1, + ACTIONS(673), 1, sym_identifier, - STATE(132), 2, - sym_vars_pair, - aux_sym_vars_block_repeat1, - [2893] = 3, + STATE(152), 2, + sym_agent_tier, + aux_sym_tiers_block_repeat1, + [3218] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(625), 1, - anon_sym_RBRACK, - ACTIONS(623), 3, - anon_sym_loop, - anon_sym_for, + ACTIONS(325), 1, + anon_sym_RBRACE, + ACTIONS(676), 3, + anon_sym_tier, + anon_sym_id, sym_identifier, - [2905] = 4, + [3230] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(599), 1, - sym_identifier, - ACTIONS(627), 1, + ACTIONS(678), 4, anon_sym_RBRACE, - STATE(132), 2, - sym_vars_pair, - aux_sym_vars_block_repeat1, - [2919] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(569), 1, - anon_sym_peer_template, - ACTIONS(629), 1, + sym_string, + sym_raw_string, sym_identifier, - STATE(117), 2, - sym_peer_template, - aux_sym_for_block_repeat1, - [2933] = 3, + [3240] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(283), 1, + ACTIONS(682), 1, anon_sym_RBRACK, - ACTIONS(631), 3, + ACTIONS(680), 3, anon_sym_loop, anon_sym_for, sym_identifier, - [2945] = 2, + [3252] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(633), 4, - anon_sym_RBRACE, - sym_string, - sym_raw_string, - sym_identifier, - [2955] = 3, + STATE(45), 1, + sym_consensus_mode_value, + ACTIONS(684), 3, + anon_sym_strict, + anon_sym_partial_ok, + anon_sym_explore, + [3264] = 2, ACTIONS(3), 1, sym_comment, - STATE(41), 1, - sym__string_value, - ACTIONS(635), 3, - sym_string, - sym_raw_string, - sym_identifier, - [2967] = 4, + ACTIONS(686), 4, + anon_sym_RBRACE, + anon_sym_owned, + anon_sym_read_only, + anon_sym_impact_scope, + [3274] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(569), 1, + ACTIONS(564), 1, anon_sym_peer_template, - ACTIONS(637), 1, + ACTIONS(688), 1, sym_identifier, - STATE(121), 2, + STATE(131), 2, sym_peer_template, aux_sym_for_block_repeat1, - [2981] = 3, - ACTIONS(3), 1, - sym_comment, - STATE(94), 1, - sym_privacy_value, - ACTIONS(639), 2, - anon_sym_public, - anon_sym_local_only, - [2992] = 3, + [3288] = 3, ACTIONS(3), 1, sym_comment, - STATE(209), 1, - sym_for_mode, - ACTIONS(641), 2, - anon_sym_parallel, - anon_sym_sequential, - [3003] = 3, + STATE(81), 1, + sym__string_value, + ACTIONS(690), 2, + sym_string, + sym_raw_string, + [3299] = 3, ACTIONS(3), 1, sym_comment, - STATE(124), 1, + STATE(53), 1, sym_boolean, - ACTIONS(643), 2, + ACTIONS(692), 2, anon_sym_true, anon_sym_false, - [3014] = 3, - ACTIONS(3), 1, - sym_comment, - STATE(53), 1, - sym_execution_mode_value, - ACTIONS(645), 2, - anon_sym_repo, - anon_sym_document, - [3025] = 4, + [3310] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(647), 1, - anon_sym_RBRACK, - ACTIONS(649), 1, - sym_identifier, - STATE(144), 1, - aux_sym_identifier_list_repeat1, - [3038] = 4, + STATE(154), 1, + sym__string_value, + ACTIONS(694), 2, + sym_string, + sym_raw_string, + [3321] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(652), 1, - anon_sym_RBRACK, - ACTIONS(654), 1, - sym_identifier, - STATE(144), 1, - aux_sym_identifier_list_repeat1, - [3051] = 4, + STATE(58), 1, + sym__string_value, + ACTIONS(644), 2, + sym_string, + sym_raw_string, + [3332] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(240), 1, + ACTIONS(251), 1, anon_sym_LBRACK, - ACTIONS(656), 1, + ACTIONS(696), 1, sym_identifier, - STATE(39), 1, + STATE(45), 1, sym_reviewer_list, - [3064] = 3, + [3345] = 3, ACTIONS(3), 1, sym_comment, - STATE(39), 1, + STATE(45), 1, sym_boolean, - ACTIONS(643), 2, + ACTIONS(698), 2, anon_sym_true, anon_sym_false, - [3075] = 3, + [3356] = 3, ACTIONS(3), 1, sym_comment, - STATE(39), 1, + STATE(45), 1, sym_branch_chain_value, - ACTIONS(658), 2, + ACTIONS(700), 2, anon_sym_stacked, anon_sym_none, - [3086] = 3, + [3367] = 4, ACTIONS(3), 1, sym_comment, - STATE(53), 1, - sym_boolean, - ACTIONS(643), 2, - anon_sym_true, - anon_sym_false, - [3097] = 3, + ACTIONS(702), 1, + anon_sym_json, + ACTIONS(704), 1, + anon_sym_LBRACK, + STATE(58), 1, + sym_string_list, + [3380] = 4, ACTIONS(3), 1, sym_comment, - STATE(41), 1, - sym_boolean, - ACTIONS(643), 2, - anon_sym_true, - anon_sym_false, - [3108] = 3, + ACTIONS(706), 1, + anon_sym_json, + ACTIONS(708), 1, + sym_identifier, + STATE(176), 1, + sym_for_json_source, + [3393] = 3, ACTIONS(3), 1, sym_comment, - STATE(72), 1, + STATE(137), 1, sym__string_value, - ACTIONS(660), 2, + ACTIONS(710), 2, sym_string, sym_raw_string, - [3119] = 3, + [3404] = 3, ACTIONS(3), 1, sym_comment, - STATE(114), 1, + STATE(186), 1, sym__string_value, - ACTIONS(313), 2, + ACTIONS(712), 2, sym_string, sym_raw_string, - [3130] = 3, + [3415] = 3, + ACTIONS(3), 1, + sym_comment, + STATE(157), 1, + sym_boolean, + ACTIONS(698), 2, + anon_sym_true, + anon_sym_false, + [3426] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(650), 1, + anon_sym_LBRACE, + STATE(144), 2, + sym_reviewer_entry, + aux_sym_reviewer_list_repeat1, + [3437] = 3, ACTIONS(3), 1, sym_comment, STATE(29), 1, sym__string_value, - ACTIONS(662), 2, + ACTIONS(714), 2, sym_string, sym_raw_string, - [3141] = 3, + [3448] = 4, ACTIONS(3), 1, sym_comment, - STATE(194), 1, - sym_for_mode, - ACTIONS(641), 2, - anon_sym_parallel, - anon_sym_sequential, - [3152] = 3, + ACTIONS(716), 1, + anon_sym_RBRACK, + ACTIONS(718), 1, + sym_identifier, + STATE(177), 1, + aux_sym_identifier_list_repeat1, + [3461] = 3, + ACTIONS(3), 1, + sym_comment, + STATE(58), 1, + sym_boolean, + ACTIONS(698), 2, + anon_sym_true, + anon_sym_false, + [3472] = 3, ACTIONS(3), 1, sym_comment, - STATE(75), 1, + STATE(207), 1, sym__string_value, - ACTIONS(664), 2, + ACTIONS(720), 2, sym_string, sym_raw_string, - [3163] = 3, + [3483] = 3, ACTIONS(3), 1, sym_comment, - STATE(112), 1, - sym_boolean, - ACTIONS(643), 2, - anon_sym_true, - anon_sym_false, - [3174] = 4, + STATE(192), 1, + sym_for_mode, + ACTIONS(722), 2, + anon_sym_parallel, + anon_sym_sequential, + [3494] = 4, ACTIONS(3), 1, sym_comment, - ACTIONS(666), 1, + ACTIONS(724), 1, anon_sym_RBRACK, - ACTIONS(668), 1, + ACTIONS(726), 1, sym_identifier, - STATE(145), 1, + STATE(177), 1, aux_sym_identifier_list_repeat1, - [3187] = 3, + [3507] = 3, ACTIONS(3), 1, sym_comment, - STATE(160), 1, + STATE(84), 1, sym__string_value, - ACTIONS(670), 2, + ACTIONS(729), 2, sym_string, sym_raw_string, - [3198] = 3, + [3518] = 3, ACTIONS(3), 1, sym_comment, - STATE(137), 1, + STATE(101), 1, + sym_privacy_value, + ACTIONS(731), 2, + anon_sym_public, + anon_sym_local_only, + [3529] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(733), 1, + anon_sym_RBRACK, + ACTIONS(735), 1, + sym_identifier, + STATE(173), 1, + aux_sym_identifier_list_repeat1, + [3542] = 3, + ACTIONS(3), 1, + sym_comment, + STATE(182), 1, sym__string_value, - ACTIONS(672), 2, + ACTIONS(737), 2, sym_string, sym_raw_string, - [3209] = 3, + [3553] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(674), 1, + ACTIONS(739), 1, anon_sym_RBRACE, - ACTIONS(676), 2, + ACTIONS(741), 2, anon_sym_peer_template, sym_identifier, - [3220] = 3, + [3564] = 3, ACTIONS(3), 1, sym_comment, - STATE(94), 1, + STATE(86), 1, sym__string_value, - ACTIONS(319), 2, + ACTIONS(743), 2, sym_string, sym_raw_string, - [3231] = 3, + [3575] = 3, ACTIONS(3), 1, sym_comment, - STATE(69), 1, + STATE(101), 1, sym__string_value, - ACTIONS(678), 2, + ACTIONS(331), 2, sym_string, sym_raw_string, - [3242] = 3, + [3586] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(601), 1, - anon_sym_LBRACE, - STATE(127), 2, - sym_reviewer_entry, - aux_sym_reviewer_list_repeat1, - [3253] = 3, + STATE(53), 1, + sym_execution_mode_value, + ACTIONS(745), 2, + anon_sym_repo, + anon_sym_document, + [3597] = 2, ACTIONS(3), 1, sym_comment, - STATE(41), 1, - sym__string_value, - ACTIONS(635), 2, - sym_string, - sym_raw_string, - [3264] = 3, + ACTIONS(747), 3, + anon_sym_RBRACE, + anon_sym_wall, + anon_sym_usd, + [3606] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(680), 1, - anon_sym_LBRACK, STATE(124), 1, - sym_string_list, - [3274] = 3, + sym_boolean, + ACTIONS(698), 2, + anon_sym_true, + anon_sym_false, + [3617] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(682), 1, - anon_sym_LBRACK, - STATE(53), 1, - sym_step_list, - [3284] = 3, + STATE(205), 1, + sym_for_mode, + ACTIONS(722), 2, + anon_sym_parallel, + anon_sym_sequential, + [3628] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(706), 1, + anon_sym_json, + ACTIONS(749), 1, + sym_identifier, + STATE(188), 1, + sym_for_json_source, + [3641] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(751), 2, + anon_sym_RBRACE, + sym_identifier, + [3649] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(753), 2, + anon_sym_LBRACE, + anon_sym_max, + [3657] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(680), 1, + ACTIONS(755), 1, + anon_sym_LBRACE, + ACTIONS(757), 1, + anon_sym_max, + [3667] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(704), 1, anon_sym_LBRACK, - STATE(125), 1, + STATE(59), 1, sym_string_list, - [3294] = 3, + [3677] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(684), 1, + ACTIONS(759), 1, anon_sym_LBRACK, - STATE(39), 1, + STATE(45), 1, sym_identifier_list, - [3304] = 2, + [3687] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(704), 1, + anon_sym_LBRACK, + STATE(58), 1, + sym_string_list, + [3697] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(686), 2, + ACTIONS(761), 2, anon_sym_LBRACE, anon_sym_RBRACK, - [3312] = 2, + [3705] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(704), 1, + anon_sym_LBRACK, + STATE(133), 1, + sym_string_list, + [3715] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(688), 2, + ACTIONS(325), 2, anon_sym_RBRACE, sym_identifier, - [3320] = 3, + [3723] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(680), 1, + ACTIONS(759), 1, anon_sym_LBRACK, - STATE(41), 1, - sym_string_list, - [3330] = 3, + STATE(58), 1, + sym_identifier_list, + [3733] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(680), 1, + ACTIONS(763), 1, anon_sym_LBRACK, - STATE(72), 1, - sym_string_list, - [3340] = 3, + STATE(53), 1, + sym_step_list, + [3743] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(684), 1, - anon_sym_LBRACK, - STATE(41), 1, - sym_identifier_list, - [3350] = 2, + ACTIONS(712), 1, + sym_float, + ACTIONS(765), 1, + sym_integer, + [3753] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(563), 2, + ACTIONS(767), 2, anon_sym_RBRACE, sym_identifier, - [3358] = 2, + [3761] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(690), 1, + ACTIONS(597), 2, + anon_sym_RBRACE, sym_identifier, - [3365] = 2, + [3769] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(635), 1, - sym_identifier, - [3372] = 2, + ACTIONS(704), 1, + anon_sym_LBRACK, + STATE(157), 1, + sym_string_list, + [3779] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(692), 1, - anon_sym_in, - [3379] = 2, + ACTIONS(769), 1, + anon_sym_LBRACE, + ACTIONS(771), 1, + anon_sym_max, + [3789] = 3, ACTIONS(3), 1, sym_comment, - ACTIONS(694), 1, - sym_identifier, - [3386] = 2, + ACTIONS(704), 1, + anon_sym_LBRACK, + STATE(84), 1, + sym_string_list, + [3799] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(696), 1, - anon_sym_LBRACE, - [3393] = 2, + ACTIONS(773), 2, + anon_sym_parallel, + anon_sym_sequential, + [3807] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(698), 1, - sym_integer, - [3400] = 2, + ACTIONS(729), 1, + sym_float, + [3814] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(700), 1, - anon_sym_LBRACE, - [3407] = 2, + ACTIONS(775), 1, + sym_identifier, + [3821] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(702), 1, + ACTIONS(777), 1, sym_identifier, - [3414] = 2, + [3828] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(704), 1, + ACTIONS(779), 1, + anon_sym_LBRACE, + [3835] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(781), 1, sym_identifier, - [3421] = 2, + [3842] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(706), 1, + ACTIONS(783), 1, + anon_sym_LBRACE, + [3849] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(785), 1, sym_identifier, - [3428] = 2, + [3856] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(635), 1, + ACTIONS(729), 1, sym_integer, - [3435] = 2, + [3863] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(656), 1, - sym_identifier, - [3442] = 2, + ACTIONS(787), 1, + sym_integer, + [3870] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(708), 1, + ACTIONS(789), 1, anon_sym_LBRACE, - [3449] = 2, + [3877] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(281), 1, - sym_identifier, - [3456] = 2, + ACTIONS(791), 1, + anon_sym_LBRACE, + [3884] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(793), 1, + anon_sym_LBRACE, + [3891] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(710), 1, + ACTIONS(795), 1, sym_identifier, - [3463] = 2, + [3898] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(712), 1, - ts_builtin_sym_end, - [3470] = 2, + ACTIONS(797), 1, + anon_sym_LBRACE, + [3905] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(714), 1, + ACTIONS(799), 1, sym_identifier, - [3477] = 2, + [3912] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(716), 1, - anon_sym_LBRACE, - [3484] = 2, + ACTIONS(801), 1, + sym_identifier, + [3919] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(718), 1, + ACTIONS(803), 1, anon_sym_LBRACE, - [3491] = 2, + [3926] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(720), 1, + ACTIONS(805), 1, anon_sym_LBRACE, - [3498] = 2, + [3933] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(722), 1, - anon_sym_LBRACE, - [3505] = 2, + ACTIONS(801), 1, + sym_integer, + [3940] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(724), 1, + ACTIONS(807), 1, sym_identifier, - [3512] = 2, + [3947] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(726), 1, - sym_identifier, - [3519] = 2, + ACTIONS(809), 1, + anon_sym_LBRACE, + [3954] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(660), 1, - sym_float, - [3526] = 2, + ACTIONS(811), 1, + anon_sym_LBRACE, + [3961] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(656), 1, + ACTIONS(813), 1, sym_integer, - [3533] = 2, + [3968] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(706), 1, + ACTIONS(644), 1, sym_integer, - [3540] = 2, + [3975] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(728), 1, + ACTIONS(815), 1, anon_sym_LBRACE, - [3547] = 2, + [3982] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(817), 1, + anon_sym_in, + [3989] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(819), 1, + sym_identifier, + [3996] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(730), 1, + ACTIONS(821), 1, anon_sym_LBRACE, - [3554] = 2, + [4003] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(732), 1, + ACTIONS(696), 1, sym_identifier, - [3561] = 2, + [4010] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(734), 1, + ACTIONS(823), 1, anon_sym_LBRACE, - [3568] = 2, + [4017] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(660), 1, - sym_integer, - [3575] = 2, + ACTIONS(825), 1, + anon_sym_LBRACE, + [4024] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(736), 1, + ACTIONS(827), 1, anon_sym_LBRACE, - [3582] = 2, + [4031] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(738), 1, + ACTIONS(829), 1, sym_identifier, - [3589] = 2, + [4038] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(740), 1, + ACTIONS(831), 1, anon_sym_LBRACE, - [3596] = 2, + [4045] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(742), 1, - anon_sym_LBRACE, - [3603] = 2, + ACTIONS(833), 1, + ts_builtin_sym_end, + [4052] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(744), 1, + ACTIONS(835), 1, sym_integer, - [3610] = 2, + [4059] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(746), 1, - sym_identifier, - [3617] = 2, + ACTIONS(696), 1, + sym_integer, + [4066] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(748), 1, + ACTIONS(837), 1, anon_sym_in, - [3624] = 2, + [4073] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(750), 1, + ACTIONS(839), 1, sym_identifier, - [3631] = 2, + [4080] = 2, ACTIONS(3), 1, sym_comment, - ACTIONS(752), 1, - anon_sym_LBRACE, + ACTIONS(841), 1, + sym_integer, }; static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(2)] = 0, - [SMALL_STATE(3)] = 54, - [SMALL_STATE(4)] = 91, - [SMALL_STATE(5)] = 128, - [SMALL_STATE(6)] = 162, - [SMALL_STATE(7)] = 196, - [SMALL_STATE(8)] = 229, - [SMALL_STATE(9)] = 260, - [SMALL_STATE(10)] = 291, - [SMALL_STATE(11)] = 346, - [SMALL_STATE(12)] = 401, - [SMALL_STATE(13)] = 456, - [SMALL_STATE(14)] = 503, - [SMALL_STATE(15)] = 550, - [SMALL_STATE(16)] = 575, - [SMALL_STATE(17)] = 600, - [SMALL_STATE(18)] = 647, - [SMALL_STATE(19)] = 694, - [SMALL_STATE(20)] = 741, - [SMALL_STATE(21)] = 788, - [SMALL_STATE(22)] = 827, + [SMALL_STATE(3)] = 43, + [SMALL_STATE(4)] = 78, + [SMALL_STATE(5)] = 114, + [SMALL_STATE(6)] = 150, + [SMALL_STATE(7)] = 183, + [SMALL_STATE(8)] = 216, + [SMALL_STATE(9)] = 271, + [SMALL_STATE(10)] = 326, + [SMALL_STATE(11)] = 381, + [SMALL_STATE(12)] = 435, + [SMALL_STATE(13)] = 489, + [SMALL_STATE(14)] = 543, + [SMALL_STATE(15)] = 568, + [SMALL_STATE(16)] = 593, + [SMALL_STATE(17)] = 640, + [SMALL_STATE(18)] = 687, + [SMALL_STATE(19)] = 734, + [SMALL_STATE(20)] = 773, + [SMALL_STATE(21)] = 812, + [SMALL_STATE(22)] = 839, [SMALL_STATE(23)] = 866, - [SMALL_STATE(24)] = 895, - [SMALL_STATE(25)] = 922, - [SMALL_STATE(26)] = 949, - [SMALL_STATE(27)] = 976, - [SMALL_STATE(28)] = 998, - [SMALL_STATE(29)] = 1020, - [SMALL_STATE(30)] = 1042, - [SMALL_STATE(31)] = 1064, - [SMALL_STATE(32)] = 1086, - [SMALL_STATE(33)] = 1107, - [SMALL_STATE(34)] = 1128, - [SMALL_STATE(35)] = 1149, - [SMALL_STATE(36)] = 1170, - [SMALL_STATE(37)] = 1191, - [SMALL_STATE(38)] = 1212, - [SMALL_STATE(39)] = 1233, - [SMALL_STATE(40)] = 1254, - [SMALL_STATE(41)] = 1275, - [SMALL_STATE(42)] = 1296, - [SMALL_STATE(43)] = 1317, - [SMALL_STATE(44)] = 1338, - [SMALL_STATE(45)] = 1357, - [SMALL_STATE(46)] = 1376, - [SMALL_STATE(47)] = 1395, - [SMALL_STATE(48)] = 1414, - [SMALL_STATE(49)] = 1433, - [SMALL_STATE(50)] = 1452, + [SMALL_STATE(24)] = 893, + [SMALL_STATE(25)] = 920, + [SMALL_STATE(26)] = 942, + [SMALL_STATE(27)] = 964, + [SMALL_STATE(28)] = 986, + [SMALL_STATE(29)] = 1008, + [SMALL_STATE(30)] = 1030, + [SMALL_STATE(31)] = 1051, + [SMALL_STATE(32)] = 1072, + [SMALL_STATE(33)] = 1093, + [SMALL_STATE(34)] = 1114, + [SMALL_STATE(35)] = 1135, + [SMALL_STATE(36)] = 1156, + [SMALL_STATE(37)] = 1177, + [SMALL_STATE(38)] = 1198, + [SMALL_STATE(39)] = 1219, + [SMALL_STATE(40)] = 1240, + [SMALL_STATE(41)] = 1261, + [SMALL_STATE(42)] = 1282, + [SMALL_STATE(43)] = 1303, + [SMALL_STATE(44)] = 1324, + [SMALL_STATE(45)] = 1345, + [SMALL_STATE(46)] = 1366, + [SMALL_STATE(47)] = 1387, + [SMALL_STATE(48)] = 1408, + [SMALL_STATE(49)] = 1429, + [SMALL_STATE(50)] = 1450, [SMALL_STATE(51)] = 1471, - [SMALL_STATE(52)] = 1490, - [SMALL_STATE(53)] = 1509, - [SMALL_STATE(54)] = 1528, - [SMALL_STATE(55)] = 1547, - [SMALL_STATE(56)] = 1566, - [SMALL_STATE(57)] = 1585, - [SMALL_STATE(58)] = 1609, - [SMALL_STATE(59)] = 1633, - [SMALL_STATE(60)] = 1665, - [SMALL_STATE(61)] = 1697, - [SMALL_STATE(62)] = 1729, - [SMALL_STATE(63)] = 1761, - [SMALL_STATE(64)] = 1793, - [SMALL_STATE(65)] = 1819, - [SMALL_STATE(66)] = 1845, - [SMALL_STATE(67)] = 1871, - [SMALL_STATE(68)] = 1885, - [SMALL_STATE(69)] = 1901, - [SMALL_STATE(70)] = 1915, - [SMALL_STATE(71)] = 1929, - [SMALL_STATE(72)] = 1943, - [SMALL_STATE(73)] = 1957, - [SMALL_STATE(74)] = 1973, - [SMALL_STATE(75)] = 1987, - [SMALL_STATE(76)] = 2001, - [SMALL_STATE(77)] = 2015, - [SMALL_STATE(78)] = 2029, - [SMALL_STATE(79)] = 2043, - [SMALL_STATE(80)] = 2062, - [SMALL_STATE(81)] = 2079, - [SMALL_STATE(82)] = 2100, - [SMALL_STATE(83)] = 2113, - [SMALL_STATE(84)] = 2126, - [SMALL_STATE(85)] = 2145, - [SMALL_STATE(86)] = 2162, - [SMALL_STATE(87)] = 2183, - [SMALL_STATE(88)] = 2196, - [SMALL_STATE(89)] = 2213, - [SMALL_STATE(90)] = 2234, - [SMALL_STATE(91)] = 2249, - [SMALL_STATE(92)] = 2268, - [SMALL_STATE(93)] = 2287, - [SMALL_STATE(94)] = 2300, - [SMALL_STATE(95)] = 2313, - [SMALL_STATE(96)] = 2326, - [SMALL_STATE(97)] = 2343, - [SMALL_STATE(98)] = 2362, - [SMALL_STATE(99)] = 2381, - [SMALL_STATE(100)] = 2398, - [SMALL_STATE(101)] = 2417, - [SMALL_STATE(102)] = 2435, - [SMALL_STATE(103)] = 2453, - [SMALL_STATE(104)] = 2471, - [SMALL_STATE(105)] = 2489, + [SMALL_STATE(52)] = 1492, + [SMALL_STATE(53)] = 1513, + [SMALL_STATE(54)] = 1534, + [SMALL_STATE(55)] = 1554, + [SMALL_STATE(56)] = 1574, + [SMALL_STATE(57)] = 1594, + [SMALL_STATE(58)] = 1614, + [SMALL_STATE(59)] = 1634, + [SMALL_STATE(60)] = 1654, + [SMALL_STATE(61)] = 1674, + [SMALL_STATE(62)] = 1694, + [SMALL_STATE(63)] = 1714, + [SMALL_STATE(64)] = 1734, + [SMALL_STATE(65)] = 1758, + [SMALL_STATE(66)] = 1784, + [SMALL_STATE(67)] = 1816, + [SMALL_STATE(68)] = 1848, + [SMALL_STATE(69)] = 1874, + [SMALL_STATE(70)] = 1900, + [SMALL_STATE(71)] = 1932, + [SMALL_STATE(72)] = 1958, + [SMALL_STATE(73)] = 1984, + [SMALL_STATE(74)] = 1998, + [SMALL_STATE(75)] = 2012, + [SMALL_STATE(76)] = 2026, + [SMALL_STATE(77)] = 2042, + [SMALL_STATE(78)] = 2058, + [SMALL_STATE(79)] = 2072, + [SMALL_STATE(80)] = 2086, + [SMALL_STATE(81)] = 2102, + [SMALL_STATE(82)] = 2116, + [SMALL_STATE(83)] = 2130, + [SMALL_STATE(84)] = 2144, + [SMALL_STATE(85)] = 2158, + [SMALL_STATE(86)] = 2174, + [SMALL_STATE(87)] = 2188, + [SMALL_STATE(88)] = 2201, + [SMALL_STATE(89)] = 2222, + [SMALL_STATE(90)] = 2235, + [SMALL_STATE(91)] = 2248, + [SMALL_STATE(92)] = 2267, + [SMALL_STATE(93)] = 2284, + [SMALL_STATE(94)] = 2303, + [SMALL_STATE(95)] = 2320, + [SMALL_STATE(96)] = 2341, + [SMALL_STATE(97)] = 2362, + [SMALL_STATE(98)] = 2381, + [SMALL_STATE(99)] = 2398, + [SMALL_STATE(100)] = 2411, + [SMALL_STATE(101)] = 2428, + [SMALL_STATE(102)] = 2441, + [SMALL_STATE(103)] = 2454, + [SMALL_STATE(104)] = 2473, + [SMALL_STATE(105)] = 2492, [SMALL_STATE(106)] = 2507, - [SMALL_STATE(107)] = 2525, - [SMALL_STATE(108)] = 2543, - [SMALL_STATE(109)] = 2561, - [SMALL_STATE(110)] = 2577, - [SMALL_STATE(111)] = 2595, - [SMALL_STATE(112)] = 2613, - [SMALL_STATE(113)] = 2624, - [SMALL_STATE(114)] = 2639, - [SMALL_STATE(115)] = 2652, - [SMALL_STATE(116)] = 2667, - [SMALL_STATE(117)] = 2682, - [SMALL_STATE(118)] = 2699, - [SMALL_STATE(119)] = 2716, - [SMALL_STATE(120)] = 2729, - [SMALL_STATE(121)] = 2744, - [SMALL_STATE(122)] = 2761, - [SMALL_STATE(123)] = 2773, - [SMALL_STATE(124)] = 2783, - [SMALL_STATE(125)] = 2793, - [SMALL_STATE(126)] = 2803, - [SMALL_STATE(127)] = 2817, - [SMALL_STATE(128)] = 2831, - [SMALL_STATE(129)] = 2843, - [SMALL_STATE(130)] = 2855, - [SMALL_STATE(131)] = 2865, - [SMALL_STATE(132)] = 2879, - [SMALL_STATE(133)] = 2893, - [SMALL_STATE(134)] = 2905, - [SMALL_STATE(135)] = 2919, - [SMALL_STATE(136)] = 2933, - [SMALL_STATE(137)] = 2945, - [SMALL_STATE(138)] = 2955, - [SMALL_STATE(139)] = 2967, - [SMALL_STATE(140)] = 2981, - [SMALL_STATE(141)] = 2992, - [SMALL_STATE(142)] = 3003, - [SMALL_STATE(143)] = 3014, - [SMALL_STATE(144)] = 3025, - [SMALL_STATE(145)] = 3038, - [SMALL_STATE(146)] = 3051, - [SMALL_STATE(147)] = 3064, - [SMALL_STATE(148)] = 3075, - [SMALL_STATE(149)] = 3086, - [SMALL_STATE(150)] = 3097, - [SMALL_STATE(151)] = 3108, - [SMALL_STATE(152)] = 3119, - [SMALL_STATE(153)] = 3130, - [SMALL_STATE(154)] = 3141, - [SMALL_STATE(155)] = 3152, - [SMALL_STATE(156)] = 3163, - [SMALL_STATE(157)] = 3174, - [SMALL_STATE(158)] = 3187, - [SMALL_STATE(159)] = 3198, - [SMALL_STATE(160)] = 3209, - [SMALL_STATE(161)] = 3220, - [SMALL_STATE(162)] = 3231, - [SMALL_STATE(163)] = 3242, - [SMALL_STATE(164)] = 3253, - [SMALL_STATE(165)] = 3264, - [SMALL_STATE(166)] = 3274, - [SMALL_STATE(167)] = 3284, - [SMALL_STATE(168)] = 3294, - [SMALL_STATE(169)] = 3304, - [SMALL_STATE(170)] = 3312, - [SMALL_STATE(171)] = 3320, - [SMALL_STATE(172)] = 3330, - [SMALL_STATE(173)] = 3340, - [SMALL_STATE(174)] = 3350, - [SMALL_STATE(175)] = 3358, - [SMALL_STATE(176)] = 3365, - [SMALL_STATE(177)] = 3372, - [SMALL_STATE(178)] = 3379, - [SMALL_STATE(179)] = 3386, - [SMALL_STATE(180)] = 3393, - [SMALL_STATE(181)] = 3400, - [SMALL_STATE(182)] = 3407, - [SMALL_STATE(183)] = 3414, - [SMALL_STATE(184)] = 3421, - [SMALL_STATE(185)] = 3428, - [SMALL_STATE(186)] = 3435, - [SMALL_STATE(187)] = 3442, - [SMALL_STATE(188)] = 3449, - [SMALL_STATE(189)] = 3456, - [SMALL_STATE(190)] = 3463, - [SMALL_STATE(191)] = 3470, - [SMALL_STATE(192)] = 3477, - [SMALL_STATE(193)] = 3484, - [SMALL_STATE(194)] = 3491, - [SMALL_STATE(195)] = 3498, - [SMALL_STATE(196)] = 3505, - [SMALL_STATE(197)] = 3512, - [SMALL_STATE(198)] = 3519, - [SMALL_STATE(199)] = 3526, - [SMALL_STATE(200)] = 3533, - [SMALL_STATE(201)] = 3540, - [SMALL_STATE(202)] = 3547, - [SMALL_STATE(203)] = 3554, - [SMALL_STATE(204)] = 3561, - [SMALL_STATE(205)] = 3568, - [SMALL_STATE(206)] = 3575, - [SMALL_STATE(207)] = 3582, - [SMALL_STATE(208)] = 3589, - [SMALL_STATE(209)] = 3596, - [SMALL_STATE(210)] = 3603, - [SMALL_STATE(211)] = 3610, - [SMALL_STATE(212)] = 3617, - [SMALL_STATE(213)] = 3624, - [SMALL_STATE(214)] = 3631, + [SMALL_STATE(107)] = 2524, + [SMALL_STATE(108)] = 2542, + [SMALL_STATE(109)] = 2560, + [SMALL_STATE(110)] = 2578, + [SMALL_STATE(111)] = 2596, + [SMALL_STATE(112)] = 2614, + [SMALL_STATE(113)] = 2632, + [SMALL_STATE(114)] = 2650, + [SMALL_STATE(115)] = 2668, + [SMALL_STATE(116)] = 2686, + [SMALL_STATE(117)] = 2704, + [SMALL_STATE(118)] = 2722, + [SMALL_STATE(119)] = 2740, + [SMALL_STATE(120)] = 2757, + [SMALL_STATE(121)] = 2772, + [SMALL_STATE(122)] = 2789, + [SMALL_STATE(123)] = 2806, + [SMALL_STATE(124)] = 2821, + [SMALL_STATE(125)] = 2832, + [SMALL_STATE(126)] = 2847, + [SMALL_STATE(127)] = 2864, + [SMALL_STATE(128)] = 2881, + [SMALL_STATE(129)] = 2896, + [SMALL_STATE(130)] = 2913, + [SMALL_STATE(131)] = 2928, + [SMALL_STATE(132)] = 2945, + [SMALL_STATE(133)] = 2962, + [SMALL_STATE(134)] = 2972, + [SMALL_STATE(135)] = 2986, + [SMALL_STATE(136)] = 2998, + [SMALL_STATE(137)] = 3012, + [SMALL_STATE(138)] = 3024, + [SMALL_STATE(139)] = 3034, + [SMALL_STATE(140)] = 3048, + [SMALL_STATE(141)] = 3062, + [SMALL_STATE(142)] = 3074, + [SMALL_STATE(143)] = 3084, + [SMALL_STATE(144)] = 3098, + [SMALL_STATE(145)] = 3112, + [SMALL_STATE(146)] = 3124, + [SMALL_STATE(147)] = 3138, + [SMALL_STATE(148)] = 3152, + [SMALL_STATE(149)] = 3166, + [SMALL_STATE(150)] = 3178, + [SMALL_STATE(151)] = 3192, + [SMALL_STATE(152)] = 3204, + [SMALL_STATE(153)] = 3218, + [SMALL_STATE(154)] = 3230, + [SMALL_STATE(155)] = 3240, + [SMALL_STATE(156)] = 3252, + [SMALL_STATE(157)] = 3264, + [SMALL_STATE(158)] = 3274, + [SMALL_STATE(159)] = 3288, + [SMALL_STATE(160)] = 3299, + [SMALL_STATE(161)] = 3310, + [SMALL_STATE(162)] = 3321, + [SMALL_STATE(163)] = 3332, + [SMALL_STATE(164)] = 3345, + [SMALL_STATE(165)] = 3356, + [SMALL_STATE(166)] = 3367, + [SMALL_STATE(167)] = 3380, + [SMALL_STATE(168)] = 3393, + [SMALL_STATE(169)] = 3404, + [SMALL_STATE(170)] = 3415, + [SMALL_STATE(171)] = 3426, + [SMALL_STATE(172)] = 3437, + [SMALL_STATE(173)] = 3448, + [SMALL_STATE(174)] = 3461, + [SMALL_STATE(175)] = 3472, + [SMALL_STATE(176)] = 3483, + [SMALL_STATE(177)] = 3494, + [SMALL_STATE(178)] = 3507, + [SMALL_STATE(179)] = 3518, + [SMALL_STATE(180)] = 3529, + [SMALL_STATE(181)] = 3542, + [SMALL_STATE(182)] = 3553, + [SMALL_STATE(183)] = 3564, + [SMALL_STATE(184)] = 3575, + [SMALL_STATE(185)] = 3586, + [SMALL_STATE(186)] = 3597, + [SMALL_STATE(187)] = 3606, + [SMALL_STATE(188)] = 3617, + [SMALL_STATE(189)] = 3628, + [SMALL_STATE(190)] = 3641, + [SMALL_STATE(191)] = 3649, + [SMALL_STATE(192)] = 3657, + [SMALL_STATE(193)] = 3667, + [SMALL_STATE(194)] = 3677, + [SMALL_STATE(195)] = 3687, + [SMALL_STATE(196)] = 3697, + [SMALL_STATE(197)] = 3705, + [SMALL_STATE(198)] = 3715, + [SMALL_STATE(199)] = 3723, + [SMALL_STATE(200)] = 3733, + [SMALL_STATE(201)] = 3743, + [SMALL_STATE(202)] = 3753, + [SMALL_STATE(203)] = 3761, + [SMALL_STATE(204)] = 3769, + [SMALL_STATE(205)] = 3779, + [SMALL_STATE(206)] = 3789, + [SMALL_STATE(207)] = 3799, + [SMALL_STATE(208)] = 3807, + [SMALL_STATE(209)] = 3814, + [SMALL_STATE(210)] = 3821, + [SMALL_STATE(211)] = 3828, + [SMALL_STATE(212)] = 3835, + [SMALL_STATE(213)] = 3842, + [SMALL_STATE(214)] = 3849, + [SMALL_STATE(215)] = 3856, + [SMALL_STATE(216)] = 3863, + [SMALL_STATE(217)] = 3870, + [SMALL_STATE(218)] = 3877, + [SMALL_STATE(219)] = 3884, + [SMALL_STATE(220)] = 3891, + [SMALL_STATE(221)] = 3898, + [SMALL_STATE(222)] = 3905, + [SMALL_STATE(223)] = 3912, + [SMALL_STATE(224)] = 3919, + [SMALL_STATE(225)] = 3926, + [SMALL_STATE(226)] = 3933, + [SMALL_STATE(227)] = 3940, + [SMALL_STATE(228)] = 3947, + [SMALL_STATE(229)] = 3954, + [SMALL_STATE(230)] = 3961, + [SMALL_STATE(231)] = 3968, + [SMALL_STATE(232)] = 3975, + [SMALL_STATE(233)] = 3982, + [SMALL_STATE(234)] = 3989, + [SMALL_STATE(235)] = 3996, + [SMALL_STATE(236)] = 4003, + [SMALL_STATE(237)] = 4010, + [SMALL_STATE(238)] = 4017, + [SMALL_STATE(239)] = 4024, + [SMALL_STATE(240)] = 4031, + [SMALL_STATE(241)] = 4038, + [SMALL_STATE(242)] = 4045, + [SMALL_STATE(243)] = 4052, + [SMALL_STATE(244)] = 4059, + [SMALL_STATE(245)] = 4066, + [SMALL_STATE(246)] = 4073, + [SMALL_STATE(247)] = 4080, }; static const TSParseActionEntry ts_parse_actions[] = { @@ -8338,346 +8897,388 @@ static const TSParseActionEntry ts_parse_actions[] = { [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(162), - [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(196), - [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(68), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(208), - [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(207), - [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(189), - [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(203), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(159), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(214), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(76), + [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(221), + [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(222), + [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(234), + [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(240), [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_boolean, 1, 0, 0), [23] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_boolean, 1, 0, 0), - [25] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier_list, 2, 0, 0), - [27] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier_list, 2, 0, 0), - [29] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier_list, 3, 0, 0), - [31] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier_list, 3, 0, 0), - [33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string_list, 2, 0, 0), + [25] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reviewer_list, 3, 0, 0), + [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier_list, 2, 0, 0), + [29] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier_list, 2, 0, 0), + [31] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier_list, 3, 0, 0), + [33] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier_list, 3, 0, 0), [35] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string_list, 3, 0, 0), - [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reviewer_list, 3, 0, 0), - [39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_block, 3, 0, 0), - [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_block, 4, 0, 0), - [43] = {.entry = {.count = 1, .reusable = true}}, SHIFT(176), - [45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), - [47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73), - [49] = {.entry = {.count = 1, .reusable = true}}, SHIFT(138), - [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(164), - [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(173), - [55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(171), - [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(185), - [59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(150), - [61] = {.entry = {.count = 1, .reusable = true}}, SHIFT(206), - [63] = {.entry = {.count = 1, .reusable = true}}, SHIFT(181), - [65] = {.entry = {.count = 1, .reusable = true}}, SHIFT(187), - [67] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(176), - [70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), - [72] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(73), - [75] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(208), - [78] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(138), - [81] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(164), - [84] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(173), - [87] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(171), - [90] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(185), - [93] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(150), - [96] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(206), - [99] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(181), - [102] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(187), - [105] = {.entry = {.count = 1, .reusable = true}}, SHIFT(70), - [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), - [109] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(210), - [112] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(181), - [115] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(179), - [118] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(166), - [121] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(143), - [124] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(129), - [127] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(149), - [130] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(191), - [133] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(183), - [136] = {.entry = {.count = 1, .reusable = true}}, SHIFT(77), - [138] = {.entry = {.count = 1, .reusable = true}}, SHIFT(210), - [140] = {.entry = {.count = 1, .reusable = true}}, SHIFT(179), - [142] = {.entry = {.count = 1, .reusable = true}}, SHIFT(166), - [144] = {.entry = {.count = 1, .reusable = true}}, SHIFT(143), - [146] = {.entry = {.count = 1, .reusable = true}}, SHIFT(129), - [148] = {.entry = {.count = 1, .reusable = true}}, SHIFT(149), - [150] = {.entry = {.count = 1, .reusable = true}}, SHIFT(191), - [152] = {.entry = {.count = 1, .reusable = true}}, SHIFT(183), - [154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_block, 4, 0, 0), - [156] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_block, 3, 0, 0), - [158] = {.entry = {.count = 1, .reusable = true}}, SHIFT(76), - [160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(128), - [162] = {.entry = {.count = 1, .reusable = true}}, SHIFT(168), - [164] = {.entry = {.count = 1, .reusable = true}}, SHIFT(146), - [166] = {.entry = {.count = 1, .reusable = true}}, SHIFT(186), - [168] = {.entry = {.count = 1, .reusable = true}}, SHIFT(122), - [170] = {.entry = {.count = 1, .reusable = true}}, SHIFT(199), - [172] = {.entry = {.count = 1, .reusable = true}}, SHIFT(147), - [174] = {.entry = {.count = 1, .reusable = true}}, SHIFT(148), - [176] = {.entry = {.count = 1, .reusable = true}}, SHIFT(213), - [178] = {.entry = {.count = 1, .reusable = true}}, SHIFT(91), - [180] = {.entry = {.count = 1, .reusable = true}}, SHIFT(133), - [182] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), - [184] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(168), - [187] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(146), - [190] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(186), - [193] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(122), - [196] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(199), - [199] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(147), - [202] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(148), - [205] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(213), - [208] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(91), - [211] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), - [213] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(162), - [216] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(196), - [219] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(68), - [222] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(208), - [225] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(207), - [228] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(189), - [231] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(203), - [234] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), - [236] = {.entry = {.count = 1, .reusable = true}}, SHIFT(61), - [238] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_param_declaration, 2, 0, 0), - [240] = {.entry = {.count = 1, .reusable = true}}, SHIFT(163), - [242] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_until_clause_repeat1, 2, 0, 0), - [244] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_until_clause_repeat1, 2, 0, 0), SHIFT_REPEAT(100), - [247] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_clause, 2, 0, 0), - [249] = {.entry = {.count = 1, .reusable = true}}, SHIFT(100), - [251] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_clause, 3, 0, 0), - [253] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_verify, 2, 0, 0), - [255] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_agent, 2, 0, 0), - [257] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_command, 2, 0, 0), + [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string_list, 2, 0, 0), + [39] = {.entry = {.count = 1, .reusable = true}}, SHIFT(78), + [41] = {.entry = {.count = 1, .reusable = true}}, SHIFT(247), + [43] = {.entry = {.count = 1, .reusable = true}}, SHIFT(237), + [45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(228), + [47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(200), + [49] = {.entry = {.count = 1, .reusable = true}}, SHIFT(185), + [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(151), + [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(160), + [55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(224), + [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(217), + [59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(220), + [61] = {.entry = {.count = 1, .reusable = true}}, SHIFT(227), + [63] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), + [65] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), + [67] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(247), + [70] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(237), + [73] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(228), + [76] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(200), + [79] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(185), + [82] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(151), + [85] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(160), + [88] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(224), + [91] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(217), + [94] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(220), + [97] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_workflow_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(227), + [100] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73), + [102] = {.entry = {.count = 1, .reusable = true}}, SHIFT(80), + [104] = {.entry = {.count = 1, .reusable = true}}, SHIFT(141), + [106] = {.entry = {.count = 1, .reusable = true}}, SHIFT(162), + [108] = {.entry = {.count = 1, .reusable = true}}, SHIFT(199), + [110] = {.entry = {.count = 1, .reusable = true}}, SHIFT(166), + [112] = {.entry = {.count = 1, .reusable = true}}, SHIFT(231), + [114] = {.entry = {.count = 1, .reusable = true}}, SHIFT(195), + [116] = {.entry = {.count = 1, .reusable = true}}, SHIFT(174), + [118] = {.entry = {.count = 1, .reusable = true}}, SHIFT(232), + [120] = {.entry = {.count = 1, .reusable = true}}, SHIFT(238), + [122] = {.entry = {.count = 1, .reusable = true}}, SHIFT(213), + [124] = {.entry = {.count = 1, .reusable = true}}, SHIFT(75), + [126] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), + [128] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(80), + [131] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(221), + [134] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(141), + [137] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(162), + [140] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(199), + [143] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(166), + [146] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(231), + [149] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(195), + [152] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(174), + [155] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(232), + [158] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(238), + [161] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_agent_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(213), + [164] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_block, 3, 0, 0), + [166] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_block, 4, 0, 0), + [168] = {.entry = {.count = 1, .reusable = true}}, SHIFT(135), + [170] = {.entry = {.count = 1, .reusable = true}}, SHIFT(194), + [172] = {.entry = {.count = 1, .reusable = true}}, SHIFT(163), + [174] = {.entry = {.count = 1, .reusable = true}}, SHIFT(236), + [176] = {.entry = {.count = 1, .reusable = true}}, SHIFT(156), + [178] = {.entry = {.count = 1, .reusable = true}}, SHIFT(244), + [180] = {.entry = {.count = 1, .reusable = true}}, SHIFT(164), + [182] = {.entry = {.count = 1, .reusable = true}}, SHIFT(165), + [184] = {.entry = {.count = 1, .reusable = true}}, SHIFT(246), + [186] = {.entry = {.count = 1, .reusable = true}}, SHIFT(97), + [188] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), + [190] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(194), + [193] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(163), + [196] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(236), + [199] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(156), + [202] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(244), + [205] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(164), + [208] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(165), + [211] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(246), + [214] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_loop_block_repeat1, 2, 0, 0), SHIFT_REPEAT(97), + [217] = {.entry = {.count = 1, .reusable = true}}, SHIFT(155), + [219] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), + [221] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(159), + [224] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(214), + [227] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(76), + [230] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(221), + [233] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(222), + [236] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(234), + [239] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(240), + [242] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), + [244] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_until_clause_repeat1, 2, 0, 0), + [246] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_until_clause_repeat1, 2, 0, 0), SHIFT_REPEAT(103), + [249] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_param_declaration, 2, 0, 0), + [251] = {.entry = {.count = 1, .reusable = true}}, SHIFT(171), + [253] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_clause, 2, 0, 0), + [255] = {.entry = {.count = 1, .reusable = true}}, SHIFT(103), + [257] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_clause, 3, 0, 0), [259] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_verify, 3, 0, 0), - [261] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch_chain_value, 1, 0, 0), - [263] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_scope_block, 3, 0, 0), - [265] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_context_block, 3, 0, 0), - [267] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_field, 1, 0, 0), - [269] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_scope_block, 4, 0, 0), - [271] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_context_block, 4, 0, 0), - [273] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_field, 1, 0, 0), - [275] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_field, 2, 0, 0), - [277] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_consensus_mode_value, 1, 0, 0), - [279] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_field, 2, 0, 0), - [281] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tier_alias_name, 1, 0, 0), - [283] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_block, 8, 0, 0), - [285] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pattern_block, 4, 0, 0), - [287] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_step_list, 2, 0, 0), - [289] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_verify_block, 4, 0, 0), - [291] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_param_client_block, 2, 0, 0), - [293] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_step_list, 3, 0, 0), + [261] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_verify, 2, 0, 0), + [263] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_agent, 2, 0, 0), + [265] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_until_command, 2, 0, 0), + [267] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_block, 10, 0, 0), + [269] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_block, 8, 0, 0), + [271] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_verify_block, 3, 0, 0), + [273] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_step_list, 2, 0, 0), + [275] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tiers_block, 3, 0, 0), + [277] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_budget_block, 3, 0, 0), + [279] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_param_declaration, 3, 0, 0), + [281] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_verify_block, 4, 0, 0), + [283] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_step_list, 3, 0, 0), + [285] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tiers_block, 4, 0, 0), + [287] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_budget_block, 4, 0, 0), + [289] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pattern_block, 4, 0, 0), + [291] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_field, 1, 0, 0), + [293] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_field, 1, 0, 0), [295] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pattern_block, 5, 0, 0), - [297] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_param_client_block, 3, 0, 0), - [299] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_verify_block, 3, 0, 0), - [301] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_param_declaration, 3, 0, 0), - [303] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_field, 2, 0, 0), + [297] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_field, 2, 0, 0), + [299] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_consensus_mode_value, 1, 0, 0), + [301] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch_chain_value, 1, 0, 0), + [303] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_execution_mode_value, 1, 0, 0), [305] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_strategy_value, 1, 0, 0), - [307] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_execution_mode_value, 1, 0, 0), - [309] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_field, 1, 0, 0), - [311] = {.entry = {.count = 1, .reusable = false}}, SHIFT(119), - [313] = {.entry = {.count = 1, .reusable = true}}, SHIFT(114), - [315] = {.entry = {.count = 1, .reusable = false}}, SHIFT(114), - [317] = {.entry = {.count = 1, .reusable = false}}, SHIFT(93), - [319] = {.entry = {.count = 1, .reusable = true}}, SHIFT(94), - [321] = {.entry = {.count = 1, .reusable = false}}, SHIFT(94), - [323] = {.entry = {.count = 1, .reusable = true}}, SHIFT(71), - [325] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), - [327] = {.entry = {.count = 1, .reusable = true}}, SHIFT(161), - [329] = {.entry = {.count = 1, .reusable = true}}, SHIFT(58), - [331] = {.entry = {.count = 1, .reusable = true}}, SHIFT(140), - [333] = {.entry = {.count = 1, .reusable = true}}, SHIFT(82), - [335] = {.entry = {.count = 1, .reusable = true}}, SHIFT(201), - [337] = {.entry = {.count = 1, .reusable = true}}, SHIFT(50), - [339] = {.entry = {.count = 1, .reusable = true}}, SHIFT(47), - [341] = {.entry = {.count = 1, .reusable = true}}, SHIFT(78), - [343] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), - [345] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(90), - [348] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(161), - [351] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(58), - [354] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(140), - [357] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(82), - [360] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(201), - [363] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), - [365] = {.entry = {.count = 1, .reusable = true}}, SHIFT(172), - [367] = {.entry = {.count = 1, .reusable = true}}, SHIFT(151), - [369] = {.entry = {.count = 1, .reusable = true}}, SHIFT(198), - [371] = {.entry = {.count = 1, .reusable = true}}, SHIFT(205), - [373] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), - [375] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), - [377] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(172), - [380] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(151), - [383] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(198), - [386] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(205), - [389] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tier_alias_declaration, 3, 0, 0), - [391] = {.entry = {.count = 1, .reusable = false}}, SHIFT(188), - [393] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_include_declaration, 2, 0, 0), - [395] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_declaration, 5, 0, 0), - [397] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_declaration, 4, 0, 0), - [399] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_field, 2, 0, 0), - [401] = {.entry = {.count = 1, .reusable = false}}, SHIFT(42), - [403] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_declaration, 4, 0, 0), - [405] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_prompt_declaration, 3, 0, 0), - [407] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_declaration, 5, 0, 0), + [307] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_block, 3, 0, 0), + [309] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_block, 4, 0, 0), + [311] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_field, 2, 0, 0), + [313] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_scope_block, 3, 0, 0), + [315] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_context_block, 4, 0, 0), + [317] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_context_block, 3, 0, 0), + [319] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_field, 1, 0, 0), + [321] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_field, 2, 0, 0), + [323] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_field, 3, 0, 0), + [325] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tier_alias_name, 1, 0, 0), + [327] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_scope_block, 4, 0, 0), + [329] = {.entry = {.count = 1, .reusable = false}}, SHIFT(99), + [331] = {.entry = {.count = 1, .reusable = true}}, SHIFT(101), + [333] = {.entry = {.count = 1, .reusable = false}}, SHIFT(101), + [335] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), + [337] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(206), + [340] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(178), + [343] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(208), + [346] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_memory_block_repeat1, 2, 0, 0), SHIFT_REPEAT(215), + [349] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), + [351] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(105), + [354] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(184), + [357] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(64), + [360] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(179), + [363] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(89), + [366] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_client_declaration_repeat1, 2, 0, 0), SHIFT_REPEAT(211), + [369] = {.entry = {.count = 1, .reusable = true}}, SHIFT(79), + [371] = {.entry = {.count = 1, .reusable = true}}, SHIFT(105), + [373] = {.entry = {.count = 1, .reusable = true}}, SHIFT(184), + [375] = {.entry = {.count = 1, .reusable = true}}, SHIFT(64), + [377] = {.entry = {.count = 1, .reusable = true}}, SHIFT(179), + [379] = {.entry = {.count = 1, .reusable = true}}, SHIFT(89), + [381] = {.entry = {.count = 1, .reusable = true}}, SHIFT(211), + [383] = {.entry = {.count = 1, .reusable = true}}, SHIFT(63), + [385] = {.entry = {.count = 1, .reusable = true}}, SHIFT(206), + [387] = {.entry = {.count = 1, .reusable = true}}, SHIFT(178), + [389] = {.entry = {.count = 1, .reusable = true}}, SHIFT(208), + [391] = {.entry = {.count = 1, .reusable = true}}, SHIFT(215), + [393] = {.entry = {.count = 1, .reusable = true}}, SHIFT(61), + [395] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83), + [397] = {.entry = {.count = 1, .reusable = true}}, SHIFT(51), + [399] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), + [401] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_declaration, 5, 0, 0), + [403] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_declaration, 5, 0, 0), + [405] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_declaration, 4, 0, 0), + [407] = {.entry = {.count = 1, .reusable = false}}, SHIFT(198), [409] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_workflow_declaration, 4, 0, 0), [411] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_declaration, 5, 0, 0), - [413] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_extra_block_repeat1, 2, 0, 0), - [415] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_extra_block_repeat1, 2, 0, 0), SHIFT_REPEAT(159), - [418] = {.entry = {.count = 1, .reusable = true}}, SHIFT(51), - [420] = {.entry = {.count = 1, .reusable = true}}, SHIFT(156), - [422] = {.entry = {.count = 1, .reusable = false}}, SHIFT(214), - [424] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), - [426] = {.entry = {.count = 1, .reusable = false}}, SHIFT(197), - [428] = {.entry = {.count = 1, .reusable = false}}, SHIFT(86), - [430] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_field, 1, 0, 0), - [432] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extra_block, 3, 0, 0), - [434] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87), - [436] = {.entry = {.count = 1, .reusable = true}}, SHIFT(159), - [438] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), - [440] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), - [442] = {.entry = {.count = 1, .reusable = false}}, SHIFT(89), - [444] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extra_block, 4, 0, 0), - [446] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_verify_block_repeat1, 2, 0, 0), - [448] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_verify_block_repeat1, 2, 0, 0), SHIFT_REPEAT(156), - [451] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), SHIFT_REPEAT(214), - [454] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), - [456] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), SHIFT_REPEAT(197), - [459] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), SHIFT_REPEAT(89), - [462] = {.entry = {.count = 1, .reusable = true}}, SHIFT(93), - [464] = {.entry = {.count = 1, .reusable = true}}, SHIFT(96), - [466] = {.entry = {.count = 1, .reusable = true}}, SHIFT(178), - [468] = {.entry = {.count = 1, .reusable = true}}, SHIFT(153), - [470] = {.entry = {.count = 1, .reusable = true}}, SHIFT(169), - [472] = {.entry = {.count = 1, .reusable = false}}, SHIFT(152), - [474] = {.entry = {.count = 1, .reusable = false}}, SHIFT(57), - [476] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tier_value, 1, 0, 0), - [478] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_field, 2, 0, 0), - [480] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_privacy_value, 1, 0, 0), - [482] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), - [484] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83), - [486] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_reviewer_entry_repeat1, 2, 0, 0), - [488] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_reviewer_entry_repeat1, 2, 0, 0), SHIFT_REPEAT(152), - [491] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_reviewer_entry_repeat1, 2, 0, 0), SHIFT_REPEAT(57), - [494] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), - [496] = {.entry = {.count = 1, .reusable = true}}, SHIFT(49), - [498] = {.entry = {.count = 1, .reusable = true}}, SHIFT(184), - [500] = {.entry = {.count = 1, .reusable = true}}, SHIFT(200), - [502] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), - [504] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_pattern_block_repeat1, 2, 0, 0), - [506] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_pattern_block_repeat1, 2, 0, 0), SHIFT_REPEAT(184), - [509] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_pattern_block_repeat1, 2, 0, 0), SHIFT_REPEAT(200), - [512] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), - [514] = {.entry = {.count = 1, .reusable = true}}, SHIFT(165), - [516] = {.entry = {.count = 1, .reusable = true}}, SHIFT(142), - [518] = {.entry = {.count = 1, .reusable = true}}, SHIFT(123), - [520] = {.entry = {.count = 1, .reusable = true}}, SHIFT(174), - [522] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_scope_block_repeat1, 2, 0, 0), - [524] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_scope_block_repeat1, 2, 0, 0), SHIFT_REPEAT(165), - [527] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_scope_block_repeat1, 2, 0, 0), SHIFT_REPEAT(142), - [530] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_context_block_repeat1, 2, 0, 0), - [532] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_context_block_repeat1, 2, 0, 0), SHIFT_REPEAT(167), - [535] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_context_block_repeat1, 2, 0, 0), SHIFT_REPEAT(180), - [538] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), - [540] = {.entry = {.count = 1, .reusable = true}}, SHIFT(167), - [542] = {.entry = {.count = 1, .reusable = true}}, SHIFT(180), - [544] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), - [546] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), - [548] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_verify_field, 2, 0, 0), - [550] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_string_list_repeat1, 2, 0, 0), - [552] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_list_repeat1, 2, 0, 0), SHIFT_REPEAT(113), - [555] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reviewer_field, 2, 0, 0), - [557] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_reviewer_field, 2, 0, 0), - [559] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), - [561] = {.entry = {.count = 1, .reusable = true}}, SHIFT(113), - [563] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_pair, 2, 0, 0), - [565] = {.entry = {.count = 1, .reusable = true}}, SHIFT(170), - [567] = {.entry = {.count = 1, .reusable = true}}, SHIFT(136), - [569] = {.entry = {.count = 1, .reusable = false}}, SHIFT(158), - [571] = {.entry = {.count = 1, .reusable = false}}, SHIFT(118), - [573] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_for_block_repeat1, 2, 0, 0), - [575] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_for_block_repeat1, 2, 0, 0), SHIFT_REPEAT(158), - [578] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_for_block_repeat1, 2, 0, 0), SHIFT_REPEAT(118), - [581] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_tier_value, 1, 0, 0), - [583] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), - [585] = {.entry = {.count = 1, .reusable = true}}, SHIFT(115), - [587] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), - [589] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), - [591] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_var_type, 1, 0, 0), - [593] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_scope_field, 2, 0, 0), - [595] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_context_field, 2, 0, 0), - [597] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [599] = {.entry = {.count = 1, .reusable = true}}, SHIFT(105), - [601] = {.entry = {.count = 1, .reusable = true}}, SHIFT(109), - [603] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), - [605] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_loop_block, 3, 0, 0), - [607] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_block, 3, 0, 0), - [609] = {.entry = {.count = 1, .reusable = false}}, SHIFT(54), - [611] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_reduce_field, 2, 0, 0), - [613] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_reviewer_list_repeat1, 2, 0, 0), SHIFT_REPEAT(109), - [616] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_reviewer_list_repeat1, 2, 0, 0), - [618] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_vars_block_repeat1, 2, 0, 0), - [620] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_vars_block_repeat1, 2, 0, 0), SHIFT_REPEAT(105), - [623] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_loop_block, 4, 0, 0), - [625] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_block, 4, 0, 0), - [627] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), - [629] = {.entry = {.count = 1, .reusable = false}}, SHIFT(117), - [631] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_block, 8, 0, 0), - [633] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extra_pair, 2, 0, 0), - [635] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), - [637] = {.entry = {.count = 1, .reusable = false}}, SHIFT(121), - [639] = {.entry = {.count = 1, .reusable = true}}, SHIFT(95), - [641] = {.entry = {.count = 1, .reusable = true}}, SHIFT(193), - [643] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), - [645] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), - [647] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_identifier_list_repeat1, 2, 0, 0), - [649] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_identifier_list_repeat1, 2, 0, 0), SHIFT_REPEAT(144), - [652] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), - [654] = {.entry = {.count = 1, .reusable = true}}, SHIFT(144), - [656] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), - [658] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), - [660] = {.entry = {.count = 1, .reusable = true}}, SHIFT(72), - [662] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), - [664] = {.entry = {.count = 1, .reusable = true}}, SHIFT(75), - [666] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), - [668] = {.entry = {.count = 1, .reusable = true}}, SHIFT(145), - [670] = {.entry = {.count = 1, .reusable = true}}, SHIFT(160), - [672] = {.entry = {.count = 1, .reusable = true}}, SHIFT(137), - [674] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_peer_template, 2, 0, 0), - [676] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_peer_template, 2, 0, 0), - [678] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69), - [680] = {.entry = {.count = 1, .reusable = true}}, SHIFT(120), - [682] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), - [684] = {.entry = {.count = 1, .reusable = true}}, SHIFT(157), - [686] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reviewer_entry, 3, 0, 0), - [688] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_pair, 3, 0, 0), - [690] = {.entry = {.count = 1, .reusable = true}}, SHIFT(154), - [692] = {.entry = {.count = 1, .reusable = true}}, SHIFT(175), - [694] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), - [696] = {.entry = {.count = 1, .reusable = true}}, SHIFT(80), - [698] = {.entry = {.count = 1, .reusable = true}}, SHIFT(125), - [700] = {.entry = {.count = 1, .reusable = true}}, SHIFT(65), - [702] = {.entry = {.count = 1, .reusable = true}}, SHIFT(67), - [704] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), - [706] = {.entry = {.count = 1, .reusable = true}}, SHIFT(130), - [708] = {.entry = {.count = 1, .reusable = true}}, SHIFT(110), - [710] = {.entry = {.count = 1, .reusable = true}}, SHIFT(195), - [712] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [714] = {.entry = {.count = 1, .reusable = true}}, SHIFT(204), - [716] = {.entry = {.count = 1, .reusable = true}}, SHIFT(59), - [718] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_mode, 1, 0, 0), - [720] = {.entry = {.count = 1, .reusable = true}}, SHIFT(135), - [722] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), - [724] = {.entry = {.count = 1, .reusable = true}}, SHIFT(192), - [726] = {.entry = {.count = 1, .reusable = true}}, SHIFT(177), - [728] = {.entry = {.count = 1, .reusable = true}}, SHIFT(97), - [730] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), - [732] = {.entry = {.count = 1, .reusable = true}}, SHIFT(202), - [734] = {.entry = {.count = 1, .reusable = true}}, SHIFT(102), - [736] = {.entry = {.count = 1, .reusable = true}}, SHIFT(111), - [738] = {.entry = {.count = 1, .reusable = true}}, SHIFT(155), - [740] = {.entry = {.count = 1, .reusable = true}}, SHIFT(126), - [742] = {.entry = {.count = 1, .reusable = true}}, SHIFT(139), - [744] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53), - [746] = {.entry = {.count = 1, .reusable = true}}, SHIFT(141), - [748] = {.entry = {.count = 1, .reusable = true}}, SHIFT(211), - [750] = {.entry = {.count = 1, .reusable = true}}, SHIFT(212), - [752] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), + [413] = {.entry = {.count = 1, .reusable = false}}, SHIFT(60), + [415] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_include_declaration, 2, 0, 0), + [417] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tier_alias_declaration, 3, 0, 0), + [419] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_declaration, 4, 0, 0), + [421] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_field, 2, 0, 0), + [423] = {.entry = {.count = 1, .reusable = false}}, SHIFT(153), + [425] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_prompt_declaration, 3, 0, 0), + [427] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extra_block, 4, 0, 0), + [429] = {.entry = {.count = 1, .reusable = false}}, SHIFT(239), + [431] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), + [433] = {.entry = {.count = 1, .reusable = false}}, SHIFT(210), + [435] = {.entry = {.count = 1, .reusable = false}}, SHIFT(95), + [437] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_field, 1, 0, 0), + [439] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extra_block, 3, 0, 0), + [441] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87), + [443] = {.entry = {.count = 1, .reusable = true}}, SHIFT(161), + [445] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), + [447] = {.entry = {.count = 1, .reusable = true}}, SHIFT(187), + [449] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_extra_block_repeat1, 2, 0, 0), + [451] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_extra_block_repeat1, 2, 0, 0), SHIFT_REPEAT(161), + [454] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_verify_block_repeat1, 2, 0, 0), + [456] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_verify_block_repeat1, 2, 0, 0), SHIFT_REPEAT(187), + [459] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), + [461] = {.entry = {.count = 1, .reusable = false}}, SHIFT(96), + [463] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), SHIFT_REPEAT(239), + [466] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), + [468] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), SHIFT_REPEAT(210), + [471] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_step_list_repeat1, 2, 0, 0), SHIFT_REPEAT(96), + [474] = {.entry = {.count = 1, .reusable = true}}, SHIFT(100), + [476] = {.entry = {.count = 1, .reusable = true}}, SHIFT(212), + [478] = {.entry = {.count = 1, .reusable = true}}, SHIFT(172), + [480] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), + [482] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tier_value, 1, 0, 0), + [484] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), + [486] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_client_field, 2, 0, 0), + [488] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_privacy_value, 1, 0, 0), + [490] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), + [492] = {.entry = {.count = 1, .reusable = true}}, SHIFT(99), + [494] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [496] = {.entry = {.count = 1, .reusable = true}}, SHIFT(62), + [498] = {.entry = {.count = 1, .reusable = true}}, SHIFT(204), + [500] = {.entry = {.count = 1, .reusable = true}}, SHIFT(170), + [502] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), + [504] = {.entry = {.count = 1, .reusable = true}}, SHIFT(197), + [506] = {.entry = {.count = 1, .reusable = true}}, SHIFT(230), + [508] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_scope_block_repeat1, 2, 0, 0), + [510] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_scope_block_repeat1, 2, 0, 0), SHIFT_REPEAT(204), + [513] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_scope_block_repeat1, 2, 0, 0), SHIFT_REPEAT(170), + [516] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), + [518] = {.entry = {.count = 1, .reusable = true}}, SHIFT(223), + [520] = {.entry = {.count = 1, .reusable = true}}, SHIFT(226), + [522] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_context_block_repeat1, 2, 0, 0), + [524] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_context_block_repeat1, 2, 0, 0), SHIFT_REPEAT(197), + [527] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_context_block_repeat1, 2, 0, 0), SHIFT_REPEAT(230), + [530] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), + [532] = {.entry = {.count = 1, .reusable = true}}, SHIFT(196), + [534] = {.entry = {.count = 1, .reusable = false}}, SHIFT(85), + [536] = {.entry = {.count = 1, .reusable = false}}, SHIFT(168), + [538] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_reviewer_entry_repeat1, 2, 0, 0), + [540] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_reviewer_entry_repeat1, 2, 0, 0), SHIFT_REPEAT(85), + [543] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_reviewer_entry_repeat1, 2, 0, 0), SHIFT_REPEAT(168), + [546] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_pattern_block_repeat1, 2, 0, 0), + [548] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_pattern_block_repeat1, 2, 0, 0), SHIFT_REPEAT(223), + [551] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_pattern_block_repeat1, 2, 0, 0), SHIFT_REPEAT(226), + [554] = {.entry = {.count = 1, .reusable = true}}, SHIFT(138), + [556] = {.entry = {.count = 1, .reusable = true}}, SHIFT(203), + [558] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54), + [560] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56), + [562] = {.entry = {.count = 1, .reusable = true}}, SHIFT(149), + [564] = {.entry = {.count = 1, .reusable = false}}, SHIFT(181), + [566] = {.entry = {.count = 1, .reusable = false}}, SHIFT(127), + [568] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), + [570] = {.entry = {.count = 1, .reusable = true}}, SHIFT(169), + [572] = {.entry = {.count = 1, .reusable = true}}, SHIFT(201), + [574] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), + [576] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_string_list_repeat1, 2, 0, 0), + [578] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_list_repeat1, 2, 0, 0), SHIFT_REPEAT(123), + [581] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_verify_field, 2, 0, 0), + [583] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [585] = {.entry = {.count = 1, .reusable = true}}, SHIFT(130), + [587] = {.entry = {.count = 1, .reusable = true}}, SHIFT(145), + [589] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_for_block_repeat1, 2, 0, 0), + [591] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_for_block_repeat1, 2, 0, 0), SHIFT_REPEAT(181), + [594] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_for_block_repeat1, 2, 0, 0), SHIFT_REPEAT(127), + [597] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_pair, 2, 0, 0), + [599] = {.entry = {.count = 1, .reusable = true}}, SHIFT(202), + [601] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_budget_block_repeat1, 2, 0, 0), + [603] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_budget_block_repeat1, 2, 0, 0), SHIFT_REPEAT(169), + [606] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_budget_block_repeat1, 2, 0, 0), SHIFT_REPEAT(201), + [609] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), + [611] = {.entry = {.count = 1, .reusable = true}}, SHIFT(123), + [613] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), + [615] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), + [617] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_context_field, 2, 0, 0), + [619] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_vars_block_repeat1, 2, 0, 0), + [621] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_vars_block_repeat1, 2, 0, 0), SHIFT_REPEAT(116), + [624] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_loop_block, 4, 0, 0), + [626] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_block, 4, 0, 0), + [628] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), + [630] = {.entry = {.count = 1, .reusable = true}}, SHIFT(77), + [632] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reviewer_field, 2, 0, 0), + [634] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_reviewer_field, 2, 0, 0), + [636] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_var_type, 1, 0, 0), + [638] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [640] = {.entry = {.count = 1, .reusable = true}}, SHIFT(116), + [642] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), + [644] = {.entry = {.count = 1, .reusable = true}}, SHIFT(58), + [646] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_reduce_field, 2, 0, 0), + [648] = {.entry = {.count = 1, .reusable = false}}, SHIFT(126), + [650] = {.entry = {.count = 1, .reusable = true}}, SHIFT(120), + [652] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), + [654] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_block, 8, 0, 0), + [656] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), + [658] = {.entry = {.count = 1, .reusable = false}}, SHIFT(119), + [660] = {.entry = {.count = 1, .reusable = false}}, SHIFT(132), + [662] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_block, 10, 0, 0), + [664] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_reviewer_list_repeat1, 2, 0, 0), SHIFT_REPEAT(120), + [667] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_reviewer_list_repeat1, 2, 0, 0), + [669] = {.entry = {.count = 1, .reusable = false}}, SHIFT(49), + [671] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_tiers_block_repeat1, 2, 0, 0), + [673] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_tiers_block_repeat1, 2, 0, 0), SHIFT_REPEAT(77), + [676] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_tier_alias_name, 1, 0, 0), + [678] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extra_pair, 2, 0, 0), + [680] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_loop_block, 3, 0, 0), + [682] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_block, 3, 0, 0), + [684] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), + [686] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_scope_field, 2, 0, 0), + [688] = {.entry = {.count = 1, .reusable = false}}, SHIFT(131), + [690] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), + [692] = {.entry = {.count = 1, .reusable = true}}, SHIFT(50), + [694] = {.entry = {.count = 1, .reusable = true}}, SHIFT(154), + [696] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), + [698] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), + [700] = {.entry = {.count = 1, .reusable = true}}, SHIFT(47), + [702] = {.entry = {.count = 1, .reusable = true}}, SHIFT(193), + [704] = {.entry = {.count = 1, .reusable = true}}, SHIFT(125), + [706] = {.entry = {.count = 1, .reusable = false}}, SHIFT(175), + [708] = {.entry = {.count = 1, .reusable = false}}, SHIFT(176), + [710] = {.entry = {.count = 1, .reusable = true}}, SHIFT(137), + [712] = {.entry = {.count = 1, .reusable = true}}, SHIFT(186), + [714] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), + [716] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), + [718] = {.entry = {.count = 1, .reusable = true}}, SHIFT(177), + [720] = {.entry = {.count = 1, .reusable = true}}, SHIFT(207), + [722] = {.entry = {.count = 1, .reusable = true}}, SHIFT(191), + [724] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_identifier_list_repeat1, 2, 0, 0), + [726] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_identifier_list_repeat1, 2, 0, 0), SHIFT_REPEAT(177), + [729] = {.entry = {.count = 1, .reusable = true}}, SHIFT(84), + [731] = {.entry = {.count = 1, .reusable = true}}, SHIFT(102), + [733] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [735] = {.entry = {.count = 1, .reusable = true}}, SHIFT(173), + [737] = {.entry = {.count = 1, .reusable = true}}, SHIFT(182), + [739] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_peer_template, 2, 0, 0), + [741] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_peer_template, 2, 0, 0), + [743] = {.entry = {.count = 1, .reusable = true}}, SHIFT(86), + [745] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), + [747] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_budget_field, 2, 0, 0), + [749] = {.entry = {.count = 1, .reusable = false}}, SHIFT(188), + [751] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_agent_tier, 2, 0, 0), + [753] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_mode, 1, 0, 0), + [755] = {.entry = {.count = 1, .reusable = true}}, SHIFT(143), + [757] = {.entry = {.count = 1, .reusable = true}}, SHIFT(216), + [759] = {.entry = {.count = 1, .reusable = true}}, SHIFT(180), + [761] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reviewer_entry, 3, 0, 0), + [763] = {.entry = {.count = 1, .reusable = true}}, SHIFT(88), + [765] = {.entry = {.count = 1, .reusable = false}}, SHIFT(186), + [767] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_vars_pair, 3, 0, 0), + [769] = {.entry = {.count = 1, .reusable = true}}, SHIFT(158), + [771] = {.entry = {.count = 1, .reusable = true}}, SHIFT(243), + [773] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_json_source, 2, 0, 0), + [775] = {.entry = {.count = 1, .reusable = true}}, SHIFT(82), + [777] = {.entry = {.count = 1, .reusable = true}}, SHIFT(233), + [779] = {.entry = {.count = 1, .reusable = true}}, SHIFT(104), + [781] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), + [783] = {.entry = {.count = 1, .reusable = true}}, SHIFT(118), + [785] = {.entry = {.count = 1, .reusable = true}}, SHIFT(229), + [787] = {.entry = {.count = 1, .reusable = true}}, SHIFT(219), + [789] = {.entry = {.count = 1, .reusable = true}}, SHIFT(122), + [791] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), + [793] = {.entry = {.count = 1, .reusable = true}}, SHIFT(147), + [795] = {.entry = {.count = 1, .reusable = true}}, SHIFT(235), + [797] = {.entry = {.count = 1, .reusable = true}}, SHIFT(146), + [799] = {.entry = {.count = 1, .reusable = true}}, SHIFT(183), + [801] = {.entry = {.count = 1, .reusable = true}}, SHIFT(142), + [803] = {.entry = {.count = 1, .reusable = true}}, SHIFT(136), + [805] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [807] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), + [809] = {.entry = {.count = 1, .reusable = true}}, SHIFT(106), + [811] = {.entry = {.count = 1, .reusable = true}}, SHIFT(70), + [813] = {.entry = {.count = 1, .reusable = true}}, SHIFT(133), + [815] = {.entry = {.count = 1, .reusable = true}}, SHIFT(117), + [817] = {.entry = {.count = 1, .reusable = true}}, SHIFT(167), + [819] = {.entry = {.count = 1, .reusable = true}}, SHIFT(225), + [821] = {.entry = {.count = 1, .reusable = true}}, SHIFT(110), + [823] = {.entry = {.count = 1, .reusable = true}}, SHIFT(71), + [825] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69), + [827] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), + [829] = {.entry = {.count = 1, .reusable = true}}, SHIFT(218), + [831] = {.entry = {.count = 1, .reusable = true}}, SHIFT(148), + [833] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [835] = {.entry = {.count = 1, .reusable = true}}, SHIFT(241), + [837] = {.entry = {.count = 1, .reusable = true}}, SHIFT(189), + [839] = {.entry = {.count = 1, .reusable = true}}, SHIFT(245), + [841] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53), }; #ifdef __cplusplus diff --git a/crates/tree-sitter-gaviero/test/corpus/basic.txt b/crates/tree-sitter-gaviero/test/corpus/basic.txt index af6f8252..dfc8aadf 100644 --- a/crates/tree-sitter-gaviero/test/corpus/basic.txt +++ b/crates/tree-sitter-gaviero/test/corpus/basic.txt @@ -52,7 +52,7 @@ Agent with memory block agent scan { description "Scan codebase" - client opus + tier high memory { read_ns ["shared" "audit"] write_ns "findings" @@ -72,7 +72,8 @@ agent scan { (agent_field (string)) (agent_field - (identifier)) + (tier_alias_name + (identifier))) (agent_field (memory_block (memory_field @@ -99,7 +100,7 @@ Agent with context block agent fix { description "Fix the bug" - client opus + tier high context { callers_of ["src/auth.rs"] tests_for ["src/auth/"] @@ -115,7 +116,8 @@ agent fix { (agent_field (string)) (agent_field - (identifier)) + (tier_alias_name + (identifier))) (agent_field (context_block (context_field @@ -389,13 +391,13 @@ client c { tier cheap } (tier_value)))) ===== -Workflow param — client shape +Workflow tiers block ===== workflow w { - param judge { - model "claude:sonnet" - effort medium + tiers { + judge medium + critic high-codex } steps [a] } @@ -406,12 +408,14 @@ workflow w { (workflow_declaration (identifier) (workflow_field - (param_declaration - (identifier) - (param_client_block - (client_field - (string)) - (client_field + (tiers_block + (agent_tier + (identifier) + (tier_alias_name + (identifier))) + (agent_tier + (identifier) + (tier_alias_name (identifier))))) (workflow_field (step_list @@ -423,8 +427,8 @@ Workflow param — roster shape workflow w { param roster [ - { id "claude" model "claude:opus" effort max } - { id "codex" model "codex:gpt-5.5" effort high } + { id "claude" tier top-claude } + { id "codex" tier high-codex } ] steps [a] } @@ -442,16 +446,14 @@ workflow w { (reviewer_field (string)) (reviewer_field - (string)) - (reviewer_field - (identifier))) + (tier_alias_name + (identifier)))) (reviewer_entry (reviewer_field (string)) (reviewer_field - (string)) - (reviewer_field - (identifier)))))) + (tier_alias_name + (identifier))))))) (workflow_field (step_list (identifier))))) diff --git a/editors/vscode/syntaxes/gaviero.tmLanguage.json b/editors/vscode/syntaxes/gaviero.tmLanguage.json index d969fa12..a84ec70c 100644 --- a/editors/vscode/syntaxes/gaviero.tmLanguage.json +++ b/editors/vscode/syntaxes/gaviero.tmLanguage.json @@ -52,7 +52,7 @@ ] }, "field-keywords": { - "match": "\\b(tier|model|privacy|scope|owned|read_only|depends_on|prompt|description|max_retries|steps|max_parallel)\\b", + "match": "\\b(tier|tiers|param|model|privacy|scope|owned|read_only|depends_on|prompt|description|max_retries|steps|max_parallel)\\b", "name": "keyword.other.field.gaviero" }, "tier-values": { diff --git a/queries/gaviero/highlights.scm b/queries/gaviero/highlights.scm index 002db091..c8800f76 100644 --- a/queries/gaviero/highlights.scm +++ b/queries/gaviero/highlights.scm @@ -30,6 +30,7 @@ "steps" @keyword "max_parallel" @keyword "param" @keyword +"tiers" @keyword "template" @keyword "id" @keyword @@ -65,6 +66,8 @@ "in" @keyword "parallel" @keyword "sequential" @keyword +"json" @keyword +"max" @keyword "peer_template" @keyword "agents" @keyword "reviewers" @keyword @@ -109,6 +112,9 @@ (step_list (identifier) @variable) (agent_field (identifier) @variable) (agent_field (tier_alias_name) @variable) +(agent_tier (identifier) @variable) +(agent_tier (tier_alias_name) @variable) +(reviewer_field (tier_alias_name) @variable) (until_agent (identifier) @variable) ; ── Vars / extra pair keys ────────────────────────────────────