The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: fix indentation in test files and module declarations
Steven Enamakel3510a17d1ad8
diff --git a/src/openhuman/agent/debug/prompt_size_tests.rs b/src/openhuman/agent/debug/prompt_size_tests.rsindex ab2c2e8ecb..8c571187b3 100644--- a/src/openhuman/agent/debug/prompt_size_tests.rs+++ b/src/openhuman/agent/debug/prompt_size_tests.rs@@ -1,74 +1,73 @@use super::*;- #[test]- fn sections_sum_to_the_whole_prompt() {- let text = "preamble line\n# Title\nbody\n## Sub\nmore body\n### Deep\ntail\n";- let sections = split_sections(text);- let total: usize = sections.iter().map(|s| s.bytes).sum();- assert_eq!(- total,- text.len(),- "section bytes must account for every byte of the prompt; \+#[test]+fn sections_sum_to_the_whole_prompt() {+ let text = "preamble line\n# Title\nbody\n## Sub\nmore body\n### Deep\ntail\n";+ let sections = split_sections(text);+ let total: usize = sections.iter().map(|s| s.bytes).sum();+ assert_eq!(+ total,+ text.len(),+ "section bytes must account for every byte of the prompt; \a table that does not sum is worse than no table"- );- }+ );+}- #[test]- fn preamble_is_kept_when_text_starts_before_the_first_heading() {- let sections = split_sections("loose text\n# Title\nbody\n");- assert_eq!(sections[0].heading, "(preamble)");- assert_eq!(sections[0].bytes, "loose text\n".len());- }+#[test]+fn preamble_is_kept_when_text_starts_before_the_first_heading() {+ let sections = split_sections("loose text\n# Title\nbody\n");+ assert_eq!(sections[0].heading, "(preamble)");+ assert_eq!(sections[0].bytes, "loose text\n".len());+}- #[test]- fn no_preamble_entry_when_the_prompt_opens_on_a_heading() {- let sections = split_sections("# Title\nbody\n");- assert_eq!(sections.len(), 1);- assert_eq!(sections[0].heading, "# Title");- }+#[test]+fn no_preamble_entry_when_the_prompt_opens_on_a_heading() {+ let sections = split_sections("# Title\nbody\n");+ assert_eq!(sections.len(), 1);+ assert_eq!(sections[0].heading, "# Title");+}- #[test]- fn deeper_headings_do_not_split() {- // `####` is body text as far as this report is concerned.- let sections = split_sections("## Sub\na\n#### Deeper\nb\n");- assert_eq!(sections.len(), 1);- }+#[test]+fn deeper_headings_do_not_split() {+ // `####` is body text as far as this report is concerned.+ let sections = split_sections("## Sub\na\n#### Deeper\nb\n");+ assert_eq!(sections.len(), 1);+}- #[test]- fn a_bare_hash_is_not_a_heading() {- // No trailing space: a shell comment in an example block, not a section.- assert!(!is_heading("#!/usr/bin/env bash\n"));- assert!(!is_heading("#hashtag\n"));- assert!(is_heading("## Real\n"));- }-- #[test]- fn tools_are_ranked_by_cost_not_registration_order() {- let dumped = DumpedPrompt {- agent_id: "t".into(),- toolkit: None,- mode: "session",- model: "m".into(),- workspace_dir: std::path::PathBuf::from("/tmp"),- text: "# A\nbody\n".into(),- tool_names: vec!["small".into(), "big".into()],- skill_tool_count: 0,- tool_specs: vec![- serde_json::json!({"name": "small", "description": "s", "parameters": {}}),- serde_json::json!({- "name": "big",- "description": "a much longer description than the other one",- "parameters": {"type": "object", "properties": {"a": {"type": "string"}}}- }),- ],- };- let report = PromptSizeReport::from_dump(&dumped);- assert_eq!(report.tools[0].name, "big");- assert_eq!(report.tool_count, 2);- assert_eq!(- report.fixed_prefix_bytes,- report.prompt_bytes + report.tool_bytes- );- assert!(report.tools[1].parameters_bytes > 0, "`{{}}` is two bytes");- }+#[test]+fn a_bare_hash_is_not_a_heading() {+ // No trailing space: a shell comment in an example block, not a section.+ assert!(!is_heading("#!/usr/bin/env bash\n"));+ assert!(!is_heading("#hashtag\n"));+ assert!(is_heading("## Real\n"));+}+#[test]+fn tools_are_ranked_by_cost_not_registration_order() {+ let dumped = DumpedPrompt {+ agent_id: "t".into(),+ toolkit: None,+ mode: "session",+ model: "m".into(),+ workspace_dir: std::path::PathBuf::from("/tmp"),+ text: "# A\nbody\n".into(),+ tool_names: vec!["small".into(), "big".into()],+ skill_tool_count: 0,+ tool_specs: vec![+ serde_json::json!({"name": "small", "description": "s", "parameters": {}}),+ serde_json::json!({+ "name": "big",+ "description": "a much longer description than the other one",+ "parameters": {"type": "object", "properties": {"a": {"type": "string"}}}+ }),+ ],+ };+ let report = PromptSizeReport::from_dump(&dumped);+ assert_eq!(report.tools[0].name, "big");+ assert_eq!(report.tool_count, 2);+ assert_eq!(+ report.fixed_prefix_bytes,+ report.prompt_bytes + report.tool_bytes+ );+ assert!(report.tools[1].parameters_bytes > 0, "`{{}}` is two bytes");+}diff --git a/src/openhuman/cron/tools/collapsed_tests.rs b/src/openhuman/cron/tools/collapsed_tests.rsindex 3f75ed640a..3c3df4d566 100644--- a/src/openhuman/cron/tools/collapsed_tests.rs+++ b/src/openhuman/cron/tools/collapsed_tests.rs@@ -1,93 +1,92 @@use super::*;- fn tool() -> CronTool {- CronTool::new(- Arc::new(Config::default()),- Arc::new(SecurityPolicy::default()),- )- }+fn tool() -> CronTool {+ CronTool::new(+ Arc::new(Config::default()),+ Arc::new(SecurityPolicy::default()),+ )+}- #[test]- fn the_schema_advertises_every_action() {- let schema = tool().parameters_schema();- let actions = schema["properties"]["action"]["enum"]- .as_array()- .expect("enum")- .iter()- .map(|v| v.as_str().unwrap_or_default().to_string())- .collect::<Vec<_>>();- assert_eq!(- actions,- vec!["list", "add", "update", "remove", "run", "runs"]- );- }+#[test]+fn the_schema_advertises_every_action() {+ let schema = tool().parameters_schema();+ let actions = schema["properties"]["action"]["enum"]+ .as_array()+ .expect("enum")+ .iter()+ .map(|v| v.as_str().unwrap_or_default().to_string())+ .collect::<Vec<_>>();+ assert_eq!(+ actions,+ vec!["list", "add", "update", "remove", "run", "runs"]+ );+}- #[test]- fn the_schema_carries_the_members_parameters() {- // `job_id` comes from four members and `patch` only from `update`.- // Their presence is what proves the merge read the members rather than- // a hand-written union that could drift from them.- let schema = tool().parameters_schema();- let props = schema["properties"].as_object().expect("properties");- assert!(props.contains_key("job_id"));- assert!(props.contains_key("patch"));- }+#[test]+fn the_schema_carries_the_members_parameters() {+ // `job_id` comes from four members and `patch` only from `update`.+ // Their presence is what proves the merge read the members rather than+ // a hand-written union that could drift from them.+ let schema = tool().parameters_schema();+ let props = schema["properties"].as_object().expect("properties");+ assert!(props.contains_key("job_id"));+ assert!(props.contains_key("patch"));+}- #[test]- fn a_read_only_action_is_not_reported_as_execute() {- // The whole point of `permission_level_with_args`: collapsing must not- // silently promote `list` to the privilege `add` needs.- let tool = tool();- let listing = serde_json::json!({"action": "list"});- assert!(- tool.permission_level_with_args(&listing) < tool.permission_level(),- "list must resolve below the family's strictest level"- );- }+#[test]+fn a_read_only_action_is_not_reported_as_execute() {+ // The whole point of `permission_level_with_args`: collapsing must not+ // silently promote `list` to the privilege `add` needs.+ let tool = tool();+ let listing = serde_json::json!({"action": "list"});+ assert!(+ tool.permission_level_with_args(&listing) < tool.permission_level(),+ "list must resolve below the family's strictest level"+ );+}- #[test]- fn an_unknown_action_falls_back_to_the_strictest_level() {- let tool = tool();- let nonsense = serde_json::json!({"action": "definitely_not_an_action"});- assert_eq!(- tool.permission_level_with_args(&nonsense),- tool.permission_level()- );- }+#[test]+fn an_unknown_action_falls_back_to_the_strictest_level() {+ let tool = tool();+ let nonsense = serde_json::json!({"action": "definitely_not_an_action"});+ assert_eq!(+ tool.permission_level_with_args(&nonsense),+ tool.permission_level()+ );+}- #[test]- fn a_missing_action_falls_back_to_the_strictest_level() {- let tool = tool();- assert_eq!(- tool.permission_level_with_args(&serde_json::json!({})),- tool.permission_level()- );- }+#[test]+fn a_missing_action_falls_back_to_the_strictest_level() {+ let tool = tool();+ assert_eq!(+ tool.permission_level_with_args(&serde_json::json!({})),+ tool.permission_level()+ );+}- #[tokio::test]- async fn an_unknown_action_is_an_error_result_naming_the_valid_ones() {- let result = tool()- .execute(serde_json::json!({"action": "nope"}))- .await- .expect("dispatch does not fail the call");- assert!(result.is_error);- let text = format!("{result:?}");- assert!(text.contains("nope"), "names what was passed: {text}");- assert!(text.contains("list|add"), "names the valid actions: {text}");- }+#[tokio::test]+async fn an_unknown_action_is_an_error_result_naming_the_valid_ones() {+ let result = tool()+ .execute(serde_json::json!({"action": "nope"}))+ .await+ .expect("dispatch does not fail the call");+ assert!(result.is_error);+ let text = format!("{result:?}");+ assert!(text.contains("nope"), "names what was passed: {text}");+ assert!(text.contains("list|add"), "names the valid actions: {text}");+}- #[test]- fn every_member_is_hidden_so_the_collapse_actually_saves_something() {- // The load-bearing assertion. Adding an action to the table while- // leaving its member `Direct` would ship both surfaces and save- // nothing, and nothing else in the build would notice.- for entry in tool().actions() {- assert_eq!(- entry.tool.exposure(),- ToolExposure::Hidden,- "`{}` is still advertised alongside the collapsed `cron` tool",- entry.tool.name()- );- }+#[test]+fn every_member_is_hidden_so_the_collapse_actually_saves_something() {+ // The load-bearing assertion. Adding an action to the table while+ // leaving its member `Direct` would ship both surfaces and save+ // nothing, and nothing else in the build would notice.+ for entry in tool().actions() {+ assert_eq!(+ entry.tool.exposure(),+ ToolExposure::Hidden,+ "`{}` is still advertised alongside the collapsed `cron` tool",+ entry.tool.name()+ );}-+}diff --git a/src/openhuman/flows/skills/skills_tests.rs b/src/openhuman/flows/skills/skills_tests.rsindex 6f322e6854..cf90142966 100644--- a/src/openhuman/flows/skills/skills_tests.rs+++ b/src/openhuman/flows/skills/skills_tests.rs@@ -1,136 +1,135 @@use super::*;- fn skill_dir() -> std::path::PathBuf {- std::path::Path::new(env!("CARGO_MANIFEST_DIR"))- .join("src/openhuman/flows/skills/flow-authoring")- }-- #[test]- fn bundled_skill_matches_the_directory_on_disk() {- // A page added to the directory but not to `FLOW_AUTHORING` is not a- // compile error and not a test failure anywhere else — it simply never- // ships, and the prompt's pointer table sends the model to a file that- // does not exist. This is that check.- let root = skill_dir();- let mut on_disk = Vec::new();- for entry in walkdir(&root) {- let rel = entry- .strip_prefix(&root)- .expect("under root")- .to_string_lossy()- .replace('\\', "/");- on_disk.push(rel);- }- on_disk.sort();-- let mut listed: Vec<String> = FLOW_AUTHORING- .files- .iter()- .map(|f| f.path.to_string())- .collect();- listed.sort();+fn skill_dir() -> std::path::PathBuf {+ std::path::Path::new(env!("CARGO_MANIFEST_DIR"))+ .join("src/openhuman/flows/skills/flow-authoring")+}- assert_eq!(- listed, on_disk,- "FLOW_AUTHORING's file list and the on-disk bundle have diverged"- );+#[test]+fn bundled_skill_matches_the_directory_on_disk() {+ // A page added to the directory but not to `FLOW_AUTHORING` is not a+ // compile error and not a test failure anywhere else — it simply never+ // ships, and the prompt's pointer table sends the model to a file that+ // does not exist. This is that check.+ let root = skill_dir();+ let mut on_disk = Vec::new();+ for entry in walkdir(&root) {+ let rel = entry+ .strip_prefix(&root)+ .expect("under root")+ .to_string_lossy()+ .replace('\\', "/");+ on_disk.push(rel);}+ on_disk.sort();- fn walkdir(root: &std::path::Path) -> Vec<std::path::PathBuf> {- let mut out = Vec::new();- let mut stack = vec![root.to_path_buf()];- while let Some(dir) = stack.pop() {- for entry in std::fs::read_dir(&dir).expect("read_dir").flatten() {- let path = entry.path();- if path.is_dir() {- stack.push(path);- } else {- out.push(path);- }- }- }- out- }+ let mut listed: Vec<String> = FLOW_AUTHORING+ .files+ .iter()+ .map(|f| f.path.to_string())+ .collect();+ listed.sort();- #[test]- fn every_page_the_manifest_advertises_exists() {- // The WORKFLOW.md table is what the model reads to choose a page. A- // row naming a file that does not ship is a dead end the model cannot- // diagnose — it just gets an error and gives up on the manual.- let manifest = FLOW_AUTHORING- .files- .iter()- .find(|f| f.path == "WORKFLOW.md")- .expect("manifest")- .contents;- for file in FLOW_AUTHORING.files {- if file.path == "WORKFLOW.md" {- continue;- }- assert!(- manifest.contains(file.path),- "`{}` ships but the manifest's table never names it",- file.path- );- }- for line in manifest.lines() {- for token in line.split('`') {- if token.starts_with("references/") {- assert!(- FLOW_AUTHORING.files.iter().any(|f| f.path == token),- "the manifest points at `{token}`, which does not ship"- );- }+ assert_eq!(+ listed, on_disk,+ "FLOW_AUTHORING's file list and the on-disk bundle have diverged"+ );+}++fn walkdir(root: &std::path::Path) -> Vec<std::path::PathBuf> {+ let mut out = Vec::new();+ let mut stack = vec![root.to_path_buf()];+ while let Some(dir) = stack.pop() {+ for entry in std::fs::read_dir(&dir).expect("read_dir").flatten() {+ let path = entry.path();+ if path.is_dir() {+ stack.push(path);+ } else {+ out.push(path);}}}+ out+}- #[test]- fn the_frontmatter_description_does_not_advertise_a_dropped_page() {- // The description is what the model reads in the `## Installed Skills`- // catalogue to decide whether to open the skill at all, and it is prose- // rather than a path — so the `references/` token check below cannot- // see it. It went stale the first time a page moved back into the- // standing prompt: the description still promised graph sizing after- // `graph-shape.md` was deleted.- let manifest = FLOW_AUTHORING- .files- .iter()- .find(|f| f.path == "WORKFLOW.md")- .expect("manifest")- .contents;- let description = manifest- .lines()- .find(|l| l.starts_with("description:"))- .expect("frontmatter description");- for dropped in ["how large a graph", "graph should be", "graph-shape"] {- assert!(- !description.contains(dropped),- "the description still advertises `{dropped}`, which no longer ships"- );+#[test]+fn every_page_the_manifest_advertises_exists() {+ // The WORKFLOW.md table is what the model reads to choose a page. A+ // row naming a file that does not ship is a dead end the model cannot+ // diagnose — it just gets an error and gives up on the manual.+ let manifest = FLOW_AUTHORING+ .files+ .iter()+ .find(|f| f.path == "WORKFLOW.md")+ .expect("manifest")+ .contents;+ for file in FLOW_AUTHORING.files {+ if file.path == "WORKFLOW.md" {+ continue;}- }-- #[test]- fn the_builder_prompt_points_at_pages_that_ship() {- // Same check from the other side. The prompt carries its own copy of- // the table (the model needs to know the manual exists before it has- // read the manual), so the two can drift independently.- const PROMPT: &str = include_str!("../agents/workflow_builder/prompt.md");assert!(- PROMPT.contains("flow-authoring"),- "the builder prompt must name the skill that holds its reference manual"+ manifest.contains(file.path),+ "`{}` ships but the manifest's table never names it",+ file.path);- let mut pointed = 0;- for token in PROMPT.split('`') {+ }+ for line in manifest.lines() {+ for token in line.split('`') {if token.starts_with("references/") {- pointed += 1;assert!(FLOW_AUTHORING.files.iter().any(|f| f.path == token),- "the builder prompt points at `{token}`, which does not ship"+ "the manifest points at `{token}`, which does not ship");}}- assert!(pointed >= 3, "the prompt's pointer table lost its rows");}+}+#[test]+fn the_frontmatter_description_does_not_advertise_a_dropped_page() {+ // The description is what the model reads in the `## Installed Skills`+ // catalogue to decide whether to open the skill at all, and it is prose+ // rather than a path — so the `references/` token check below cannot+ // see it. It went stale the first time a page moved back into the+ // standing prompt: the description still promised graph sizing after+ // `graph-shape.md` was deleted.+ let manifest = FLOW_AUTHORING+ .files+ .iter()+ .find(|f| f.path == "WORKFLOW.md")+ .expect("manifest")+ .contents;+ let description = manifest+ .lines()+ .find(|l| l.starts_with("description:"))+ .expect("frontmatter description");+ for dropped in ["how large a graph", "graph should be", "graph-shape"] {+ assert!(+ !description.contains(dropped),+ "the description still advertises `{dropped}`, which no longer ships"+ );+ }+}++#[test]+fn the_builder_prompt_points_at_pages_that_ship() {+ // Same check from the other side. The prompt carries its own copy of+ // the table (the model needs to know the manual exists before it has+ // read the manual), so the two can drift independently.+ const PROMPT: &str = include_str!("../agents/workflow_builder/prompt.md");+ assert!(+ PROMPT.contains("flow-authoring"),+ "the builder prompt must name the skill that holds its reference manual"+ );+ let mut pointed = 0;+ for token in PROMPT.split('`') {+ if token.starts_with("references/") {+ pointed += 1;+ assert!(+ FLOW_AUTHORING.files.iter().any(|f| f.path == token),+ "the builder prompt points at `{token}`, which does not ship"+ );+ }+ }+ assert!(pointed >= 3, "the prompt's pointer table lost its rows");+}diff --git a/src/openhuman/memory/tools/collapsed_tests.rs b/src/openhuman/memory/tools/collapsed_tests.rsindex e0c8dd8085..f0817967dd 100644--- a/src/openhuman/memory/tools/collapsed_tests.rs+++ b/src/openhuman/memory/tools/collapsed_tests.rs@@ -1,108 +1,107 @@use super::*;- fn tool() -> MemoryTool {- MemoryTool::new(- Arc::new(Config::default()),- Arc::new(SecurityPolicy::default()),- )- }-- #[test]- fn every_member_is_hidden_so_the_collapse_actually_saves_something() {- // `all_actions`, not `actions`: capability filtering could hide a- // still-advertised member from this check in some environments, and- // the property being pinned holds regardless of capabilities.- for entry in tool().all_actions() {- assert_eq!(- entry.tool.exposure(),- ToolExposure::Hidden,- "`{}` is still advertised alongside the collapsed `memory` tool",- entry.tool.name()- );- }- }+fn tool() -> MemoryTool {+ MemoryTool::new(+ Arc::new(Config::default()),+ Arc::new(SecurityPolicy::default()),+ )+}- #[test]- fn the_schema_advertises_every_action() {- let schema = tool().parameters_schema();- let listed = schema["properties"]["action"]["enum"]- .as_array()- .expect("enum")- .len();- assert_eq!(listed, 11);- }-- #[test]- fn each_action_resolves_to_exactly_its_members_level() {- // The real contract, and the one that keeps collapsing honest: whatever- // a member declares, the collapsed tool reports for that action.- //- // Note this family currently declares one level between them (see the- // module docs): `memory_store` and `memory_forget` never override- // `permission_level`, so they inherit the `ReadOnly` default. That is- // pre-existing and deliberately not changed here — raising them is a- // behaviour change to the approval gate, not a token optimisation. An- // inequality assertion would therefore be asserting a bug.- let tool = tool();- for entry in tool.actions() {- let args = serde_json::json!({"action": entry.action});- assert_eq!(- tool.permission_level_with_args(&args),- entry.tool.permission_level_with_args(&args),- "action `{}` must report what `{}` reports",- entry.action,- entry.tool.name()- );- }+#[test]+fn every_member_is_hidden_so_the_collapse_actually_saves_something() {+ // `all_actions`, not `actions`: capability filtering could hide a+ // still-advertised member from this check in some environments, and+ // the property being pinned holds regardless of capabilities.+ for entry in tool().all_actions() {+ assert_eq!(+ entry.tool.exposure(),+ ToolExposure::Hidden,+ "`{}` is still advertised alongside the collapsed `memory` tool",+ entry.tool.name()+ );}+}- #[test]- fn collapsing_never_lowers_the_argument_free_level() {- // The safety property that does not depend on what the members happen- // to declare today: a caller that cannot pass arguments is never told- // a level below any member's.- let tool = tool();- let floor = tool.permission_level();- for entry in tool.actions() {- assert!(- entry.tool.permission_level() <= floor,- "`{}` requires more than the collapsed tool advertises",- entry.tool.name()- );- }- }+#[test]+fn the_schema_advertises_every_action() {+ let schema = tool().parameters_schema();+ let listed = schema["properties"]["action"]["enum"]+ .as_array()+ .expect("enum")+ .len();+ assert_eq!(listed, 11);+}- #[test]- fn an_unknown_action_falls_back_to_the_strictest_level() {- let tool = tool();+#[test]+fn each_action_resolves_to_exactly_its_members_level() {+ // The real contract, and the one that keeps collapsing honest: whatever+ // a member declares, the collapsed tool reports for that action.+ //+ // Note this family currently declares one level between them (see the+ // module docs): `memory_store` and `memory_forget` never override+ // `permission_level`, so they inherit the `ReadOnly` default. That is+ // pre-existing and deliberately not changed here — raising them is a+ // behaviour change to the approval gate, not a token optimisation. An+ // inequality assertion would therefore be asserting a bug.+ let tool = tool();+ for entry in tool.actions() {+ let args = serde_json::json!({"action": entry.action});assert_eq!(- tool.permission_level_with_args(&serde_json::json!({"action": "nope"})),- tool.permission_level()+ tool.permission_level_with_args(&args),+ entry.tool.permission_level_with_args(&args),+ "action `{}` must report what `{}` reports",+ entry.action,+ entry.tool.name());}+}- #[tokio::test]- async fn an_unknown_action_is_an_error_result_naming_the_valid_ones() {- let result = tool()- .execute(serde_json::json!({"action": "recal"}))- .await- .expect("dispatch does not fail the call");- assert!(result.is_error);- let text = format!("{result:?}");- assert!(text.contains("recal"));- assert!(text.contains("recall|store|forget"));- }-- #[test]- fn the_memory_tree_tool_is_not_a_member() {- // Pinning the decision in the module docs: `memory_tree` dispatches on- // its own `mode`, and folding it in would make this two-level.+#[test]+fn collapsing_never_lowers_the_argument_free_level() {+ // The safety property that does not depend on what the members happen+ // to declare today: a caller that cannot pass arguments is never told+ // a level below any member's.+ let tool = tool();+ let floor = tool.permission_level();+ for entry in tool.actions() {assert!(- !tool()- .all_actions()- .iter()- .any(|e| e.tool.name() == "memory_tree"),- "memory_tree stays a separate tool"+ entry.tool.permission_level() <= floor,+ "`{}` requires more than the collapsed tool advertises",+ entry.tool.name());}+}++#[test]+fn an_unknown_action_falls_back_to_the_strictest_level() {+ let tool = tool();+ assert_eq!(+ tool.permission_level_with_args(&serde_json::json!({"action": "nope"})),+ tool.permission_level()+ );+}++#[tokio::test]+async fn an_unknown_action_is_an_error_result_naming_the_valid_ones() {+ let result = tool()+ .execute(serde_json::json!({"action": "recal"}))+ .await+ .expect("dispatch does not fail the call");+ assert!(result.is_error);+ let text = format!("{result:?}");+ assert!(text.contains("recal"));+ assert!(text.contains("recall|store|forget"));+}+#[test]+fn the_memory_tree_tool_is_not_a_member() {+ // Pinning the decision in the module docs: `memory_tree` dispatches on+ // its own `mode`, and folding it in would make this two-level.+ assert!(+ !tool()+ .all_actions()+ .iter()+ .any(|e| e.tool.name() == "memory_tree"),+ "memory_tree stays a separate tool"+ );+}diff --git a/src/openhuman/skills/ops_discover.rs b/src/openhuman/skills/ops_discover.rsindex a14c2d7ea4..21772545f2 100644--- a/src/openhuman/skills/ops_discover.rs+++ b/src/openhuman/skills/ops_discover.rs@@ -746,5 +746,9 @@ fn resolve_workflow_for_resource((None, None) => Err(format!("skill '{skill_id}' not found")),}}-#[cfg(test)] #[path = "ops_discover_include_skills_tests_tests.rs"] mod include_skills_tests;-#[cfg(test)] #[path = "ops_discover_profile_scope_tests_tests.rs"] mod profile_scope_tests;+#[cfg(test)]+#[path = "ops_discover_include_skills_tests_tests.rs"]+mod include_skills_tests;+#[cfg(test)]+#[path = "ops_discover_profile_scope_tests_tests.rs"]+mod profile_scope_tests;diff --git a/src/openhuman/tools/impl/meta/collapse_tests.rs b/src/openhuman/tools/impl/meta/collapse_tests.rsindex 93cc2639a3..ff79b1c635 100644--- a/src/openhuman/tools/impl/meta/collapse_tests.rs+++ b/src/openhuman/tools/impl/meta/collapse_tests.rs@@ -1,214 +1,208 @@use super::*;- use crate::openhuman::tools::ToolResult;- use async_trait::async_trait;+use crate::openhuman::tools::ToolResult;+use async_trait::async_trait;- struct Stub {- name: &'static str,- schema: Value,- permission: PermissionLevel,- external: bool,- }+struct Stub {+ name: &'static str,+ schema: Value,+ permission: PermissionLevel,+ external: bool,+}- #[async_trait]- impl Tool for Stub {- fn name(&self) -> &str {- self.name- }- fn description(&self) -> &str {- "stub"- }- fn parameters_schema(&self) -> Value {- self.schema.clone()- }- fn permission_level(&self) -> PermissionLevel {- self.permission- }- fn external_effect(&self) -> bool {- self.external- }- async fn execute(&self, _args: Value) -> anyhow::Result<ToolResult> {- Ok(ToolResult::success("ok"))- }+#[async_trait]+impl Tool for Stub {+ fn name(&self) -> &str {+ self.name}-- fn stub(- name: &'static str,- schema: Value,- permission: PermissionLevel,- external: bool,- ) -> Stub {- Stub {- name,- schema,- permission,- external,- }+ fn description(&self) -> &str {+ "stub"}-- #[test]- fn the_union_carries_every_members_properties() {- let list = stub(- "list",- json!({"type": "object", "properties": {}}),- PermissionLevel::ReadOnly,- false,- );- let runs = stub(- "runs",- json!({"type": "object", "properties": {- "job_id": {"type": "string"},- "limit": {"type": "integer", "description": "How many."}- }}),- PermissionLevel::ReadOnly,- false,- );- let actions = vec![- CollapsedAction {- action: "list",- tool: &list,- },- CollapsedAction {- action: "runs",- tool: &runs,- },- ];- let merged = merge_action_schemas(&actions);- let props = merged["properties"].as_object().expect("properties");- assert!(props.contains_key("action"));- assert!(props.contains_key("job_id"));- assert!(props.contains_key("limit"));- assert_eq!(merged["required"], json!(["action"]));+ fn parameters_schema(&self) -> Value {+ self.schema.clone()}-- #[test]- fn only_action_is_required_because_a_union_cannot_say_otherwise() {- // `job_id` is required for `runs` and meaningless for `list`. Marking- // it required here would make every `list` call invalid.- let list = stub(- "list",- json!({"type": "object", "properties": {}}),- PermissionLevel::ReadOnly,- false,- );- let runs = stub(- "runs",- json!({"type": "object", "properties": {"job_id": {"type": "string"}}, "required": ["job_id"]}),- PermissionLevel::ReadOnly,- false,- );- let actions = vec![- CollapsedAction {- action: "list",- tool: &list,- },- CollapsedAction {- action: "runs",- tool: &runs,- },- ];- assert_eq!(- merge_action_schemas(&actions)["required"],- json!(["action"])- );+ fn permission_level(&self) -> PermissionLevel {+ self.permission}-- #[test]- fn a_property_only_some_actions_take_is_labelled_with_them() {- let a = stub(- "a",- json!({"type": "object", "properties": {"shared": {"type": "string"}}}),- PermissionLevel::ReadOnly,- false,- );- let b = stub(- "b",- json!({"type": "object", "properties": {- "shared": {"type": "string"},- "only_b": {"type": "string", "description": "B's field."}- }}),- PermissionLevel::ReadOnly,- false,- );- let actions = vec![- CollapsedAction {- action: "a",- tool: &a,- },- CollapsedAction {- action: "b",- tool: &b,- },- ];- let merged = merge_action_schemas(&actions);- let props = &merged["properties"];- assert_eq!(props["only_b"]["description"], json!("b: B's field."));- // Taken by every action, so no prefix — it would be noise.- assert!(props["shared"].get("description").is_none());+ fn external_effect(&self) -> bool {+ self.external}-- #[test]- fn permission_is_the_strictest_member_not_the_first() {- let read = stub("r", json!({}), PermissionLevel::ReadOnly, false);- let execute = stub("x", json!({}), PermissionLevel::Execute, false);- let write = stub("w", json!({}), PermissionLevel::Write, false);- let actions = vec![- CollapsedAction {- action: "r",- tool: &read,- },- CollapsedAction {- action: "x",- tool: &execute,- },- CollapsedAction {- action: "w",- tool: &write,- },- ];- assert_eq!(strictest_permission(&actions), PermissionLevel::Execute);+ async fn execute(&self, _args: Value) -> anyhow::Result<ToolResult> {+ Ok(ToolResult::success("ok"))}+}- #[test]- fn external_effect_is_true_when_any_member_has_one() {- let clean = stub("c", json!({}), PermissionLevel::ReadOnly, false);- let dirty = stub("d", json!({}), PermissionLevel::ReadOnly, true);- assert!(!any_external_effect(&[CollapsedAction {- action: "c",- tool: &clean- }]));- assert!(any_external_effect(&[- CollapsedAction {- action: "c",- tool: &clean- },- CollapsedAction {- action: "d",- tool: &dirty- },- ]));+fn stub(name: &'static str, schema: Value, permission: PermissionLevel, external: bool) -> Stub {+ Stub {+ name,+ schema,+ permission,+ external,}+}- #[test]- fn the_dispatch_key_does_not_reach_the_member() {- // Several members set `additionalProperties: false`.- let args = json!({"action": "runs", "job_id": "j1"});- assert_eq!(args_without_action(&args), json!({"job_id": "j1"}));- }+#[test]+fn the_union_carries_every_members_properties() {+ let list = stub(+ "list",+ json!({"type": "object", "properties": {}}),+ PermissionLevel::ReadOnly,+ false,+ );+ let runs = stub(+ "runs",+ json!({"type": "object", "properties": {+ "job_id": {"type": "string"},+ "limit": {"type": "integer", "description": "How many."}+ }}),+ PermissionLevel::ReadOnly,+ false,+ );+ let actions = vec![+ CollapsedAction {+ action: "list",+ tool: &list,+ },+ CollapsedAction {+ action: "runs",+ tool: &runs,+ },+ ];+ let merged = merge_action_schemas(&actions);+ let props = merged["properties"].as_object().expect("properties");+ assert!(props.contains_key("action"));+ assert!(props.contains_key("job_id"));+ assert!(props.contains_key("limit"));+ assert_eq!(merged["required"], json!(["action"]));+}++#[test]+fn only_action_is_required_because_a_union_cannot_say_otherwise() {+ // `job_id` is required for `runs` and meaningless for `list`. Marking+ // it required here would make every `list` call invalid.+ let list = stub(+ "list",+ json!({"type": "object", "properties": {}}),+ PermissionLevel::ReadOnly,+ false,+ );+ let runs = stub(+ "runs",+ json!({"type": "object", "properties": {"job_id": {"type": "string"}}, "required": ["job_id"]}),+ PermissionLevel::ReadOnly,+ false,+ );+ let actions = vec![+ CollapsedAction {+ action: "list",+ tool: &list,+ },+ CollapsedAction {+ action: "runs",+ tool: &runs,+ },+ ];+ assert_eq!(+ merge_action_schemas(&actions)["required"],+ json!(["action"])+ );+}- #[test]- fn an_unknown_action_names_the_valid_ones() {- let a = stub("a", json!({}), PermissionLevel::ReadOnly, false);- let actions = vec![CollapsedAction {- action: "add",+#[test]+fn a_property_only_some_actions_take_is_labelled_with_them() {+ let a = stub(+ "a",+ json!({"type": "object", "properties": {"shared": {"type": "string"}}}),+ PermissionLevel::ReadOnly,+ false,+ );+ let b = stub(+ "b",+ json!({"type": "object", "properties": {+ "shared": {"type": "string"},+ "only_b": {"type": "string", "description": "B's field."}+ }}),+ PermissionLevel::ReadOnly,+ false,+ );+ let actions = vec![+ CollapsedAction {+ action: "a",tool: &a,- }];- assert_eq!(- unknown_action_message(&actions, Some("addd")),- "unknown action 'addd' (expected add)"- );- assert_eq!(- unknown_action_message(&actions, None),- "missing required field `action` (expected add)"- );- }+ },+ CollapsedAction {+ action: "b",+ tool: &b,+ },+ ];+ let merged = merge_action_schemas(&actions);+ let props = &merged["properties"];+ assert_eq!(props["only_b"]["description"], json!("b: B's field."));+ // Taken by every action, so no prefix — it would be noise.+ assert!(props["shared"].get("description").is_none());+}++#[test]+fn permission_is_the_strictest_member_not_the_first() {+ let read = stub("r", json!({}), PermissionLevel::ReadOnly, false);+ let execute = stub("x", json!({}), PermissionLevel::Execute, false);+ let write = stub("w", json!({}), PermissionLevel::Write, false);+ let actions = vec![+ CollapsedAction {+ action: "r",+ tool: &read,+ },+ CollapsedAction {+ action: "x",+ tool: &execute,+ },+ CollapsedAction {+ action: "w",+ tool: &write,+ },+ ];+ assert_eq!(strictest_permission(&actions), PermissionLevel::Execute);+}++#[test]+fn external_effect_is_true_when_any_member_has_one() {+ let clean = stub("c", json!({}), PermissionLevel::ReadOnly, false);+ let dirty = stub("d", json!({}), PermissionLevel::ReadOnly, true);+ assert!(!any_external_effect(&[CollapsedAction {+ action: "c",+ tool: &clean+ }]));+ assert!(any_external_effect(&[+ CollapsedAction {+ action: "c",+ tool: &clean+ },+ CollapsedAction {+ action: "d",+ tool: &dirty+ },+ ]));+}++#[test]+fn the_dispatch_key_does_not_reach_the_member() {+ // Several members set `additionalProperties: false`.+ let args = json!({"action": "runs", "job_id": "j1"});+ assert_eq!(args_without_action(&args), json!({"job_id": "j1"}));+}+#[test]+fn an_unknown_action_names_the_valid_ones() {+ let a = stub("a", json!({}), PermissionLevel::ReadOnly, false);+ let actions = vec![CollapsedAction {+ action: "add",+ tool: &a,+ }];+ assert_eq!(+ unknown_action_message(&actions, Some("addd")),+ "unknown action 'addd' (expected add)"+ );+ assert_eq!(+ unknown_action_message(&actions, None),+ "missing required field `action` (expected add)"+ );+}diff --git a/src/openhuman/tools/impl/meta/tool_search.rs b/src/openhuman/tools/impl/meta/tool_search.rsindex d2ef9c1153..d7e8aca9b1 100644--- a/src/openhuman/tools/impl/meta/tool_search.rs+++ b/src/openhuman/tools/impl/meta/tool_search.rs@@ -251,7 +251,6 @@ impl Tool for ToolSearchTool {#[path = "tool_search_tests.rs"]mod tests;-/// Remove every [`ToolExposure::Deferred`] and [`ToolExposure::Hidden`] tool/// from an agent's advertised set, returning the specs of the deferred ones so/// the caller can index them.@@ -327,5 +326,4 @@ pub fn bind_tool_search_index(tools: &[Box<dyn Tool>], deferred: Vec<ToolSpec>)false}}-}diff --git a/src/openhuman/tools/impl/meta/tool_search_tests.rs b/src/openhuman/tools/impl/meta/tool_search_tests.rsindex e2385ca478..ac4497d595 100644--- a/src/openhuman/tools/impl/meta/tool_search_tests.rs+++ b/src/openhuman/tools/impl/meta/tool_search_tests.rs@@ -1,85 +1,85 @@// The tokenizer's own tests live with it, in `util::bm25`.- use super::*;+use super::*;- fn spec(name: &str, description: &str) -> ToolSpec {- ToolSpec {- name: name.to_string(),- description: description.to_string(),- parameters: json!({"type": "object"}),- }+fn spec(name: &str, description: &str) -> ToolSpec {+ ToolSpec {+ name: name.to_string(),+ description: description.to_string(),+ parameters: json!({"type": "object"}),}+}- fn index() -> ToolSearchIndex {- ToolSearchIndex::build(&[- spec("stock_quote", "Get the latest price for a stock ticker"),- spec("cron_add", "Schedule a recurring job to run later"),- spec(- "memory_hybrid_search",- "Search stored memories semantically",- ),- spec(- "generate_presentation",- "Build a pptx slide deck from an outline",- ),- ])- }+fn index() -> ToolSearchIndex {+ ToolSearchIndex::build(&[+ spec("stock_quote", "Get the latest price for a stock ticker"),+ spec("cron_add", "Schedule a recurring job to run later"),+ spec(+ "memory_hybrid_search",+ "Search stored memories semantically",+ ),+ spec(+ "generate_presentation",+ "Build a pptx slide deck from an outline",+ ),+ ])+}- #[test]- fn a_plain_language_query_finds_the_right_tool() {- let index = index();- let hits = index.search("schedule something to run every morning", 3);- assert_eq!(hits.first().map(|t| t.name.as_str()), Some("cron_add"));- }+#[test]+fn a_plain_language_query_finds_the_right_tool() {+ let index = index();+ let hits = index.search("schedule something to run every morning", 3);+ assert_eq!(hits.first().map(|t| t.name.as_str()), Some("cron_add"));+}- #[test]- fn a_query_matching_the_name_rather_than_the_description_still_hits() {- let index = index();- let hits = index.search("stock", 3);- assert_eq!(hits.first().map(|t| t.name.as_str()), Some("stock_quote"));- }+#[test]+fn a_query_matching_the_name_rather_than_the_description_still_hits() {+ let index = index();+ let hits = index.search("stock", 3);+ assert_eq!(hits.first().map(|t| t.name.as_str()), Some("stock_quote"));+}- #[test]- fn nothing_relevant_returns_nothing_rather_than_padding_to_the_limit() {- // Padding would spend exactly the tokens deferral saves, and would- // invite a call to something unrelated to the ask.- let index = index();- assert!(index.search("xyzzy quantum flux", 5).is_empty());- }+#[test]+fn nothing_relevant_returns_nothing_rather_than_padding_to_the_limit() {+ // Padding would spend exactly the tokens deferral saves, and would+ // invite a call to something unrelated to the ask.+ let index = index();+ assert!(index.search("xyzzy quantum flux", 5).is_empty());+}- #[test]- fn results_are_capped_at_the_requested_limit() {- let index = index();- assert!(index.search("search a stock job memory slide", 2).len() <= 2);- }+#[test]+fn results_are_capped_at_the_requested_limit() {+ let index = index();+ assert!(index.search("search a stock job memory slide", 2).len() <= 2);+}- #[test]- fn an_empty_query_matches_nothing() {- let index = index();- assert!(index.search(" ", 5).is_empty());- }+#[test]+fn an_empty_query_matches_nothing() {+ let index = index();+ assert!(index.search(" ", 5).is_empty());+}- #[test]- fn an_empty_index_is_searchable_without_panicking() {- // `average_length` is 0 here; the length-normalisation term divides by- // it, so this is the case that would panic or produce NaN if the- // `.max(1.0)` guard were dropped.- let empty = ToolSearchIndex::build(&[]);- assert!(empty.is_empty());- assert!(empty.search("anything", 5).is_empty());- }+#[test]+fn an_empty_index_is_searchable_without_panicking() {+ // `average_length` is 0 here; the length-normalisation term divides by+ // it, so this is the case that would panic or produce NaN if the+ // `.max(1.0)` guard were dropped.+ let empty = ToolSearchIndex::build(&[]);+ assert!(empty.is_empty());+ assert!(empty.search("anything", 5).is_empty());+}- #[test]- fn ranking_is_stable_across_identical_queries() {- let index = index();- let first: Vec<&str> = index- .search("search", 4)- .iter()- .map(|t| t.name.as_str())- .collect();- let second: Vec<&str> = index- .search("search", 4)- .iter()- .map(|t| t.name.as_str())- .collect();- assert_eq!(first, second);- }+#[test]+fn ranking_is_stable_across_identical_queries() {+ let index = index();+ let first: Vec<&str> = index+ .search("search", 4)+ .iter()+ .map(|t| t.name.as_str())+ .collect();+ let second: Vec<&str> = index+ .search("search", 4)+ .iter()+ .map(|t| t.name.as_str())+ .collect();+ assert_eq!(first, second);+}diff --git a/src/openhuman/util/bm25_tests.rs b/src/openhuman/util/bm25_tests.rsindex 5ca41549b1..b347eccce2 100644--- a/src/openhuman/util/bm25_tests.rs+++ b/src/openhuman/util/bm25_tests.rs@@ -1,109 +1,108 @@use super::*;- #[test]- fn snake_case_and_camel_case_both_split() {- assert_eq!(- tokenize("memory_hybrid_search"),- ["memory", "hybrid", "search"]- );- assert_eq!(- tokenize("readWorkflowResource"),- ["read", "workflow", "resource"]- );- assert_eq!(tokenize("HTTPServer2"), ["httpserver2"]);- }+#[test]+fn snake_case_and_camel_case_both_split() {+ assert_eq!(+ tokenize("memory_hybrid_search"),+ ["memory", "hybrid", "search"]+ );+ assert_eq!(+ tokenize("readWorkflowResource"),+ ["read", "workflow", "resource"]+ );+ assert_eq!(tokenize("HTTPServer2"), ["httpserver2"]);+}- fn corpus() -> Bm25Index {- Bm25Index::build([- ("alpha", "send an email to a colleague"),- ("beta", "look up a stock quote by ticker symbol"),- ("gamma", "read a file from the workspace"),- ])- }+fn corpus() -> Bm25Index {+ Bm25Index::build([+ ("alpha", "send an email to a colleague"),+ ("beta", "look up a stock quote by ticker symbol"),+ ("gamma", "read a file from the workspace"),+ ])+}- #[test]- fn a_plain_language_query_finds_the_right_document() {- assert_eq!(corpus().search("stock ticker", 3), vec![1]);- assert_eq!(corpus().search("email a colleague", 3)[0], 0);- assert_eq!(corpus().search("read from the workspace", 3)[0], 2);- }+#[test]+fn a_plain_language_query_finds_the_right_document() {+ assert_eq!(corpus().search("stock ticker", 3), vec![1]);+ assert_eq!(corpus().search("email a colleague", 3)[0], 0);+ assert_eq!(corpus().search("read from the workspace", 3)[0], 2);+}- #[test]- fn nothing_relevant_returns_nothing_rather_than_padding() {- // The load-bearing property. A ranker that always returns `limit`- // results turns a miss into a confident wrong answer.- assert!(corpus().search("photosynthesis", 3).is_empty());- }+#[test]+fn nothing_relevant_returns_nothing_rather_than_padding() {+ // The load-bearing property. A ranker that always returns `limit`+ // results turns a miss into a confident wrong answer.+ assert!(corpus().search("photosynthesis", 3).is_empty());+}- #[test]- fn a_query_matching_only_on_stopwords_is_a_miss() {- // The regression, and it took two attempts to fix. "a" appears in- // exactly ONE of these three documents, so by document frequency it is- // the most distinguishing term in the query — the df threshold cannot- // catch it, and the first fix that only had the threshold still ranked- // a changelog skill as the match for provisioning a cluster.- assert!(corpus()- .search("provision a kubernetes cluster", 3)- .is_empty());- assert!(corpus().search("a", 3).is_empty());- assert!(corpus()- .search("what is it that you will do for me", 3)- .is_empty());- }+#[test]+fn a_query_matching_only_on_stopwords_is_a_miss() {+ // The regression, and it took two attempts to fix. "a" appears in+ // exactly ONE of these three documents, so by document frequency it is+ // the most distinguishing term in the query — the df threshold cannot+ // catch it, and the first fix that only had the threshold still ranked+ // a changelog skill as the match for provisioning a cluster.+ assert!(corpus()+ .search("provision a kubernetes cluster", 3)+ .is_empty());+ assert!(corpus().search("a", 3).is_empty());+ assert!(corpus()+ .search("what is it that you will do for me", 3)+ .is_empty());+}- #[test]- fn a_single_document_corpus_stays_searchable() {- // The reason the threshold has a floor of 2 rather than being a plain- // ratio. With one document every term is in every document, so a ratio- // rule would filter the entire query and make the only installed skill- // permanently unfindable.- let one = Bm25Index::build([("solo", "post a message to discord")]);- assert_eq!(one.search("discord", 1), vec![0]);- assert_eq!(one.search("post a message", 1), vec![0]);- }+#[test]+fn a_single_document_corpus_stays_searchable() {+ // The reason the threshold has a floor of 2 rather than being a plain+ // ratio. With one document every term is in every document, so a ratio+ // rule would filter the entire query and make the only installed skill+ // permanently unfindable.+ let one = Bm25Index::build([("solo", "post a message to discord")]);+ assert_eq!(one.search("discord", 1), vec![0]);+ assert_eq!(one.search("post a message", 1), vec![0]);+}- #[test]- fn a_real_term_still_matches_even_alongside_stopwords() {- // The filter must drop the noise, not the query.- assert_eq!(corpus().search("look up a stock", 3), vec![1]);- }+#[test]+fn a_real_term_still_matches_even_alongside_stopwords() {+ // The filter must drop the noise, not the query.+ assert_eq!(corpus().search("look up a stock", 3), vec![1]);+}- #[test]- fn an_empty_query_and_an_empty_index_are_both_safe() {- assert!(corpus().search("", 3).is_empty());- assert!(Bm25Index::build([]).search("anything", 3).is_empty());- }+#[test]+fn an_empty_query_and_an_empty_index_are_both_safe() {+ assert!(corpus().search("", 3).is_empty());+ assert!(Bm25Index::build([]).search("anything", 3).is_empty());+}- #[test]- fn ranking_is_stable_across_identical_queries() {- let index = corpus();- let first = index.search("a", 3);- for _ in 0..5 {- assert_eq!(index.search("a", 3), first);- }+#[test]+fn ranking_is_stable_across_identical_queries() {+ let index = corpus();+ let first = index.search("a", 3);+ for _ in 0..5 {+ assert_eq!(index.search("a", 3), first);}+}- #[test]- fn ties_break_on_the_sort_key_not_on_insertion_order() {- // Two documents with identical text score identically; the sort key- // decides. Built in reverse order so insertion order would give the- // opposite answer.- // Three documents, two identical: with only two, every term would be- // in every document and `significant` would filter the query away.- let index = Bm25Index::build([- ("zulu", "same words here"),- ("alpha", "same words here"),- ("other", "entirely different text"),- ]);- assert_eq!(index.search("same words", 2), vec![1, 0]);- }-- #[test]- fn the_limit_is_honoured() {- // "read email stock" hits all three documents on a real term each, so- // the unlimited search returns three — which is what makes this a test- // of the cap rather than a query that happened to match once.- assert_eq!(corpus().search("read email stock", 10).len(), 3);- assert_eq!(corpus().search("read email stock", 1).len(), 1);- }+#[test]+fn ties_break_on_the_sort_key_not_on_insertion_order() {+ // Two documents with identical text score identically; the sort key+ // decides. Built in reverse order so insertion order would give the+ // opposite answer.+ // Three documents, two identical: with only two, every term would be+ // in every document and `significant` would filter the query away.+ let index = Bm25Index::build([+ ("zulu", "same words here"),+ ("alpha", "same words here"),+ ("other", "entirely different text"),+ ]);+ assert_eq!(index.search("same words", 2), vec![1, 0]);+}+#[test]+fn the_limit_is_honoured() {+ // "read email stock" hits all three documents on a real term each, so+ // the unlimited search returns three — which is what makes this a test+ // of the cap rather than a query that happened to match once.+ assert_eq!(corpus().search("read email stock", 10).len(), 3);+ assert_eq!(corpus().search("read email stock", 1).len(), 1);+}