Tests become directory modules named after what they test, with a shared fixtures/harness module:
control-plane/src/{responses,ggml_bridge,gguf_f32_stream,prepare_preview}/tests/, desktop-core/src/runtime_rpc/tests/;
integration targets become tests/<name>/main.rs plus topic modules and a harness (backend_worker_http, vision_http,
memory_gate_http, tool_corpus, mcp_hub, api_over_runtime, runtime_gateway_sdet, native_tools_sdet,
native_tools_retry_sdet, managed_worker, gateway); target names are unchanged. Sources: leleka-inference.rs becomes
src/bin/leleka-inference/ (main.rs plus one module per operator option group), the cp_replay example becomes
examples/cp_replay/, and the tonic service impl of runtime_rpc delegates to session_rpc, model_rpc and generate_rpc
(bodies unchanged). impl_* modules are renamed after what they hold (base_provenance, count_tokens, manifest_fetch,
fetcher, record, capture, in_flight, tool_policy, tool_plan, server). The self-spawning tests that name themselves
(credential_child, the managed worker fixture) use the new module path or stay at the target root.
Test ids: 543 before and after in both crates (strata-control, strata-desktop-core, --all-targets), 0 missing, 0 new,
0 outcome changes; 241 ids differ only in the module path. Warnings in the two crates: 0 before and after.
Counts (strata-control / strata-desktop-core): oversize files 19 -> 0 (13 + 6). Functions over 30 lines, complexity 10,
nesting 4, wide lines, prod: 187/135/17/199 -> 187/135/17/196 and 81/59/6/54 -> 81/59/6/54; test: 214/17/30/133 ->
214/17/30/133 and 65/3/3/30 -> 65/3/3/27. The 211 functions that moved verbatim are in limits-allowlist.json (owner
STRA-338) because the diff gate treats a moved function as added; the entries fall as the functions are shortened.
75 lines
1.6 KiB
Rust
75 lines
1.6 KiB
Rust
//! Bounded, whole-completion tool semantics for the experimental native adapter.
|
|
//! This module performs no publication or execution and mints no identifiers.
|
|
use std::collections::{HashMap, HashSet};
|
|
use std::io::{self, Write};
|
|
|
|
use serde_json::{Value, json};
|
|
|
|
use crate::runtime_prompt::{Effort, Message, Role};
|
|
use crate::runtime_tool_catalog::{Catalog, alias};
|
|
use crate::runtime_tool_parser::{self, Segment};
|
|
|
|
const REQUEST_LIMIT: usize = 1024 * 1024;
|
|
const OUTPUT_LIMIT: usize = 8 * 1024 * 1024;
|
|
const TOOL_LIMIT: usize = 128;
|
|
const ITEM_LIMIT: usize = 1024;
|
|
|
|
pub struct ToolPlan {
|
|
pub prompt: String,
|
|
pub max_output_tokens: u32,
|
|
pub policy: ToolPolicy,
|
|
pub sampling: leleka_sampler_ref::params::FixedPoint,
|
|
}
|
|
|
|
pub enum ValidatedSegment {
|
|
Text(String),
|
|
Call(Value),
|
|
}
|
|
|
|
pub struct ToolPolicy {
|
|
catalog: Catalog,
|
|
identities: HashMap<String, Identity>,
|
|
schemas: HashMap<String, jsonschema::Validator>,
|
|
choice: Choice,
|
|
parallel: bool,
|
|
}
|
|
|
|
struct Identity {
|
|
name: String,
|
|
namespace: Option<String>,
|
|
custom: bool,
|
|
}
|
|
|
|
enum Choice {
|
|
None,
|
|
Auto,
|
|
Required,
|
|
Forced(String),
|
|
Allowed {
|
|
required: bool,
|
|
names: HashSet<String>,
|
|
},
|
|
}
|
|
|
|
struct Count(usize);
|
|
|
|
struct Pending {
|
|
id: String,
|
|
custom: bool,
|
|
markup: String,
|
|
output: Option<String>,
|
|
}
|
|
|
|
mod fields;
|
|
#[allow(unused_imports)]
|
|
pub use fields::*;
|
|
mod tool_policy;
|
|
#[allow(unused_imports)]
|
|
pub use tool_policy::*;
|
|
mod tool_plan;
|
|
#[allow(unused_imports)]
|
|
pub use tool_plan::*;
|
|
mod history;
|
|
#[allow(unused_imports)]
|
|
pub use history::*;
|