Skip to content

test(coverage): batches 13–18 — Rust unit tests for 40+ modules (#530)#618

Merged
senamakel merged 8 commits intotinyhumansai:mainfrom
CodeGhost21:issue-530-rust-test-coverage
Apr 17, 2026
Merged

test(coverage): batches 13–18 — Rust unit tests for 40+ modules (#530)#618
senamakel merged 8 commits intotinyhumansai:mainfrom
CodeGhost21:issue-530-rust-test-coverage

Conversation

@CodeGhost21
Copy link
Copy Markdown
Collaborator

@CodeGhost21 CodeGhost21 commented Apr 16, 2026

Summary

Continues the test coverage push from #607 (merged). Adds 486 new unit tests across 40+ modules, bringing total from 3,730 → 4,216.

Modules covered in this PR:

  • core/all: registry integrity, rpc_method_name, namespace_description, validate_params, schema lookup
  • proxy_config tool: parse_scope, parse_string_list, parse_optional_string_update, security gates
  • memory/store/unified/helpers: vec/bytes roundtrip, cosine_similarity, normalize/tokenize, graph entity/predicate, json helpers, recency_score, chunking
  • accessibility/terminal: is_text_role, is_terminal_app, terminal buffer detection, input context extraction
  • accessibility/keys: key state probes (platform-safe)
  • channels/runtime/supervision: compute_max_in_flight_messages clamping
  • security/detect: all sandbox backend fallback paths
  • composio/trigger_history: list_recent, empty store, field validation
  • learning/schemas: catalog, schema validation
  • update/schemas: check/apply schemas, optional staging_dir
  • encryption/schemas: encrypt/decrypt schemas, read_required helper
  • doctor/schemas: report/models schemas, read_optional helper
  • service/schemas: 8 lifecycle functions, restart params, daemon_host
  • skills/types: ToolResult/ToolContent constructors, serde roundtrip

Test plan

  • cargo test --lib — all 4,216 tests pass
  • cargo fmt --all --check — clean
  • Pre-push hooks pass (prettier, eslint, tsc, cargo check)

Closes #530 (partial — continues coverage push toward 80% target)

Summary by CodeRabbit

  • Tests
    • Expanded unit test coverage across multiple modules, adding extensive verification of schema/registry integrity, parameter parsing and validation, accessibility and terminal heuristics, sandbox selection behavior, proxy/config parsing, memory helpers, service lifecycle inputs, trigger/history recording, and various edge and boundary cases to improve reliability and guard regressions.

…inyhumansai#530)

Add 36 new tests:
- core/all: registry integrity (no duplicates, schema-controller parity),
  rpc_method_name, namespace_description, validate_params, schema lookup
- proxy_config: parse_scope, parse_string_list (CSV, array, errors),
  parse_optional_string_update, env_snapshot, proxy_json, security gates

All 4096 tests pass.
tinyhumansai#530)

Add 31 new tests for helpers module:
- vec_to_bytes/bytes_to_vec roundtrip, cosine_similarity (identical,
  orthogonal, mismatched, zero), collapse_whitespace, normalize_search_text,
  tokenize_search_terms, normalize_graph_entity/predicate, json_string_array,
  merge_unique_string_arrays, json_i64 (int/float/missing/string),
  recency_score (current/old/future), chunk_document_content

All 4127 tests pass.
…igger history (tinyhumansai#530)

Add 27 new tests across 4 modules:
- accessibility/terminal: is_text_role, is_terminal_app, looks_like_terminal_buffer,
  extract_terminal_input_context, noise line detection
- channels/runtime/supervision: compute_max_in_flight_messages clamping
- security/detect: all sandbox backend fallback paths (landlock, firejail,
  bubblewrap, docker on non-linux), disabled-via-enabled-false
- composio/trigger_history: list_recent with limit, empty store, field validation

All 4154 tests pass.
…ice schemas + skills/types (tinyhumansai#530)

Add 49 new tests across 6 modules:
- learning/schemas: catalog, schema validation, unknown fallback
- update/schemas: check/apply schemas, optional staging_dir, controller parity
- encryption/schemas: encrypt/decrypt schemas, read_required helper
- doctor/schemas: report/models schemas, read_optional helper (none/null/value/error)
- service/schemas: 8 lifecycle functions, restart optional params, daemon_host
- skills/types: ToolResult success/error/json/mixed, serde roundtrip, ToolContent

All 4203 tests pass.
…umansai#530)

Add tests for is_tab_key_down/is_escape_key_down (platform-safe),
macOS-specific constant validation.

All 4216 tests pass.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a35184bb-3325-457c-9e99-8885636d6581

📥 Commits

Reviewing files that changed from the base of the PR and between b62a07f and 5f02c42.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • app/src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • src/openhuman/memory/store/factories.rs
  • src/openhuman/service/restart.rs
  • src/openhuman/subconscious/schemas.rs
  • src/openhuman/tree_summarizer/schemas.rs

📝 Walkthrough

Walkthrough

Adds extensive #[cfg(test)] unit tests across many modules (schemas, helpers, tools, accessibility, runtime, security, memory, service, etc.) validating registry invariants, schema/controller mappings, parsing helpers, and assorted utility behaviors. No production code or public API signatures were changed.

Changes

Cohort / File(s) Summary
Core Registry & RPC Tests
src/core/all.rs
Adds tests for registry validation, RPC method name formatting/lookup, namespace descriptions, parameter validation, and global controller inventory integrity (counts, schema/controller alignment, no duplicate RPC names).
Accessibility Tests
src/openhuman/accessibility/keys.rs, src/openhuman/accessibility/terminal.rs
Adds tests for key-detection helpers and terminal detection/terminal-buffer extraction, including macOS keycode checks.
Channels & Supervision
src/openhuman/channels/runtime/supervision.rs
Adds tests for compute_max_in_flight_messages across small, large, and boundary channel counts and clamping behavior.
Composio Trigger History
src/openhuman/composio/trigger_history.rs
Adds tests for record_trigger and list_recent behavior, limits, and metadata fields.
Controller Schema Suites
src/openhuman/doctor/schemas.rs, src/openhuman/encryption/schemas.rs, src/openhuman/learning/schemas.rs, src/openhuman/service/schemas.rs, src/openhuman/subconscious/schemas.rs, src/openhuman/tree_summarizer/schemas.rs, src/openhuman/update/schemas.rs
Adds comprehensive schema/controller tests: counts, namespace/function resolution, required/optional input checks, read_optional/read_required/read_optional_timestamp behavior, and alignment between registered controllers and schemas.
Memory Helpers & Factories
src/openhuman/memory/store/unified/helpers.rs, src/openhuman/memory/store/factories.rs
Adds tests for vector/byte conversions, cosine similarity, whitespace/search/tokenization helpers, JSON parsing helpers, recency weighting, chunking, and memory backend factory behaviors (migration error, effective name).
Security / Sandbox
src/openhuman/security/detect.rs
Adds tests for create_sandbox across configurations and platforms, asserting fallbacks and availability checks.
Skills Types
src/openhuman/skills/types.rs
Adds tests for ToolResult and ToolContent behavior, output formatting, and serde roundtrips.
System Tool: Proxy Config
src/openhuman/tools/impl/system/proxy_config.rs
Adds extensive tests for proxy parsing helpers, scope parsing, list parsing, MaybeSet handling, env snapshot/proxy JSON structure, tool metadata, parameter schema shape, and execution edge cases.
Service Restart
src/openhuman/service/restart.rs
Adds tests for restart source/reason trimming/defaults, RestartStatus serialization, and startup-delay env behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #529: Adds broad unit tests across modules to raise Rust test coverage, directly related to the objective of improving coverage and exercising Compose.io and cron-related areas.

Possibly related PRs

Poem

🐰 I hopped through code where tests were few,
I penned small checks and gave bugs their cue.
Carrots of coverage grow row by row,
Assertions snug in every burrow.
Hop, run, repeat — the green lights glow! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: adding 486 Rust unit tests across 40+ modules in batches 13–18, which aligns with the file summaries showing test-only additions across multiple files.
Linked Issues check ✅ Passed The PR adds 486 unit tests covering critical modules (memory, accessibility, channels, security, schemas, tools, skills) with focus on edge cases and validation, directly addressing issue #530's goal to increase test coverage to 80% for critical modules.
Out of Scope Changes check ✅ Passed All 12 modified files contain only test code additions in #[cfg(test)] modules; no production logic, exported APIs, or function signatures were changed, keeping all changes squarely within the scope of issue #530's test coverage objective.
Docstring Coverage ✅ Passed Docstring coverage is 96.25% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (8)
src/openhuman/accessibility/keys.rs (1)

128-133: Tautological assertion — low signal test.

kvk_constants_are_correct asserts the constants equal the same numeric literals they are defined with, so it can only fail if someone edits both the constant and the test in opposite directions. Consider either removing it or anchoring it to an external source of truth (e.g., Apple's HIToolbox/Events.h kVK_Tab = 0x30, kVK_Escape = 0x35) via a comment, so the test guards against an actual regression rather than re-stating the definition.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/accessibility/keys.rs` around lines 128 - 133, The test
kvk_constants_are_correct is tautological because it compares KVK_TAB and
KVK_ESCAPE to the same numeric literals; instead either remove the test or make
it assert against an external source of truth: change the expected values to
Apple's official constants (kVK_Tab = 0x30, kVK_Escape = 0x35) and add a comment
citing HIToolbox/Events.h as the source, or delete the kvk_constants_are_correct
test entirely so the code isn't asserting its own definitions.
src/openhuman/memory/store/unified/helpers.rs (1)

192-425: LGTM — well-structured test coverage for helper functions.

Tests are deterministic, cover meaningful edge cases (empty vectors, orthogonal/zero/mismatched-length cosine inputs, JSON type-mismatch fallthrough, recency clamping for past/present/future, whitespace-only chunking), and correctly target the helpers' documented behavior. No production logic touched, so the logging guidelines don't apply here.

One small optional suggestion: consider adding a case for cosine_similarity with partially negative dot product (e.g., [1.0, 0.0] vs [-1.0, 0.0]) to lock in the clamp(0.0, 1.0) lower-bound behavior, since that branch is currently not exercised.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/memory/store/unified/helpers.rs` around lines 192 - 425, Add a
small unit test to exercise the negative-dot-product branch for
UnifiedMemory::cosine_similarity by asserting a case like vectors [1.0_f32, 0.0]
vs [-1.0_f32, 0.0] yields the clamped lower-bound (0.0) to ensure the clamp(0.0,
1.0) behavior is covered; add it alongside the other cosine_similarity tests
within the tests module so the behavior is deterministically verified.
src/openhuman/channels/runtime/supervision.rs (1)

91-120: Tighten assertions and drop the duplicated zero-channel test.

compute_max_in_flight_messages_clamps_to_min (Lines 110-114) exercises the same input (0) as compute_max_in_flight_messages_zero_channels (Lines 91-95) with a strictly weaker assertion, so it adds no coverage. Also, the one_channel and many_channels cases can be asserted exactly (1×4=4 → clamped to CHANNEL_MIN_IN_FLIGHT_MESSAGES=8; 100×4=400 → clamped to CHANNEL_MAX_IN_FLIGHT_MESSAGES=64) — using assert_eq! would catch regressions in the clamp constants or multiplier, whereas the current range-only assertion would silently pass if, e.g., CHANNEL_PARALLELISM_PER_CHANNEL changed. Consider replacing the min-clamp test with a more meaningful boundary case (e.g., the exact channel_count where the result transitions off the min, or just below the max).

♻️ Suggested tightening
     #[test]
     fn compute_max_in_flight_messages_one_channel() {
         let result = compute_max_in_flight_messages(1);
-        assert!(result >= CHANNEL_MIN_IN_FLIGHT_MESSAGES);
-        assert!(result <= CHANNEL_MAX_IN_FLIGHT_MESSAGES);
+        // 1 * CHANNEL_PARALLELISM_PER_CHANNEL (4) < CHANNEL_MIN_IN_FLIGHT_MESSAGES (8) → clamped up.
+        assert_eq!(result, CHANNEL_MIN_IN_FLIGHT_MESSAGES);
     }

-    #[test]
-    fn compute_max_in_flight_messages_clamps_to_min() {
-        let result = compute_max_in_flight_messages(0);
-        assert!(result >= CHANNEL_MIN_IN_FLIGHT_MESSAGES);
-    }
-
     #[test]
     fn compute_max_in_flight_messages_clamps_to_max() {
         let result = compute_max_in_flight_messages(usize::MAX);
-        assert!(result <= CHANNEL_MAX_IN_FLIGHT_MESSAGES);
+        // saturating_mul overflow → still clamped to max.
+        assert_eq!(result, CHANNEL_MAX_IN_FLIGHT_MESSAGES);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/channels/runtime/supervision.rs` around lines 91 - 120, Remove
the duplicated zero-channel test and tighten the assertions: drop
compute_max_in_flight_messages_clamps_to_min (which duplicates
compute_max_in_flight_messages_zero_channels) and change
compute_max_in_flight_messages_one_channel and
compute_max_in_flight_messages_many_channels to assert exact values (using
assert_eq!) based on the multiplier and clamp constants
(compute_max_in_flight_messages(1) == CHANNEL_MIN_IN_FLIGHT_MESSAGES and
compute_max_in_flight_messages(100) == CHANNEL_MAX_IN_FLIGHT_MESSAGES given
CHANNEL_PARALLELISM_PER_CHANNEL and clamps); add a meaningful boundary test
instead of the removed duplicate (e.g., a channel_count that yields the first
value > CHANNEL_MIN_IN_FLIGHT_MESSAGES or a channel_count just below the value
that clamps to CHANNEL_MAX_IN_FLIGHT_MESSAGES) to verify the transition off the
min/max clamps.
src/openhuman/security/detect.rs (2)

194-222: Weak assertions in bubblewrap_backend_falls_back_when_unavailable and docker_backend_falls_back_when_unavailable.

Both tests assert only sandbox.is_available(), which is true for NoopSandbox as well as for any real backend (per traits.rs). As written, these tests pass regardless of whether the fallback path was actually exercised — they don't distinguish "Bubblewrap/Docker returned" from "fell back to Noop". Consider asserting on sandbox.name() with the expected set of outcomes so the fallback branch is actually verified on environments without the backend installed.

♻️ Suggested tightening
     let sandbox = create_sandbox(&config);
-    // Bubblewrap probably isn't installed on CI/dev — expect fallback
-    assert!(sandbox.is_available());
+    // Bubblewrap usually isn't installed on CI/dev; accept either the real backend
+    // or the Noop fallback, but ensure the result is one of the known names.
+    let name = sandbox.name();
+    assert!(
+        matches!(name, "none" | "bubblewrap"),
+        "unexpected sandbox name: {name}"
+    );

And similarly for the Docker test ("none" | "docker").

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/security/detect.rs` around lines 194 - 222, The tests
bubblewrap_backend_falls_back_when_unavailable and
docker_backend_falls_back_when_unavailable currently only assert
sandbox.is_available(), which doesn't distinguish a real backend from the Noop
fallback; update each test (the SecurityConfig/SandboxConfig setup that uses
SandboxBackend::Bubblewrap and SandboxBackend::Docker and the
create_sandbox(...) call) to assert on sandbox.name() instead, checking that the
returned name is one of the expected values (e.g., "none" or "bubblewrap" for
the Bubblewrap test; "none" or "docker" for the Docker test) so the fallback
path is actually verified rather than relying solely on is_available().

161-192: Landlock/Firejail non-Linux tests are no-ops on Linux runners.

landlock_backend_on_non_linux_falls_back and firejail_backend_on_non_linux_falls_back wrap their only assert_eq! inside if std::env::consts::OS != "linux". On Linux CI (the common case), these tests execute zero assertions and always pass, providing no real coverage. Consider either gating the entire test with #[cfg(not(target_os = "linux"))] so it's clear the test is platform-specific, or adding a complementary assertion valid on Linux (e.g., name() is one of {"none", "landlock"} / {"none", "firejail"}).

♻️ Example
-    #[test]
-    fn landlock_backend_on_non_linux_falls_back() {
+    #[cfg(not(target_os = "linux"))]
+    #[test]
+    fn landlock_backend_on_non_linux_falls_back() {
         ...
         let sandbox = create_sandbox(&config);
-        if std::env::consts::OS != "linux" {
-            assert_eq!(sandbox.name(), "none");
-        }
+        assert_eq!(sandbox.name(), "none");
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/security/detect.rs` around lines 161 - 192, The two tests
landlock_backend_on_non_linux_falls_back and
firejail_backend_on_non_linux_falls_back currently guard their assertions with
if std::env::consts::OS != "linux", making them no-ops on Linux; update each
test to either be platform-gated with #[cfg(not(target_os = "linux"))] so the
whole test only runs on non-Linux, or expand the test to include a Linux branch
that asserts create_sandbox(&config).name() returns an expected value for Linux
(e.g., one of "none" or the backend-specific name) so the test performs a
meaningful assertion on all platforms; locate these tests and the use of
SecurityConfig/SandboxConfig/SandboxBackend and create_sandbox to apply the
change.
src/openhuman/composio/trigger_history.rs (1)

284-319: Optional: extract repeated test setup into a helper.

The temp workspace + store setup is duplicated across tests (Line 284-288, Line 303-307, Line 314-318). A small helper would reduce noise and keep each test focused on assertions.

♻️ Suggested refactor
 #[cfg(test)]
 mod tests {
     use super::*;
+    
+    fn make_store() -> ComposioTriggerHistoryStore {
+        let temp = tempfile::tempdir().expect("tempdir");
+        let workspace = temp.path().join("workspace");
+        fs::create_dir_all(&workspace).expect("workspace dir");
+        ComposioTriggerHistoryStore::new(&workspace).expect("store")
+    }

     #[test]
     fn list_recent_with_limit_one() {
-        let temp = tempfile::tempdir().expect("tempdir");
-        let workspace = temp.path().join("workspace");
-        fs::create_dir_all(&workspace).expect("workspace dir");
-
-        let store = ComposioTriggerHistoryStore::new(&workspace).expect("store");
+        let store = make_store();
         // ...
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/composio/trigger_history.rs` around lines 284 - 319, Extract
the repeated test setup (tempfile::tempdir, workspace path creation,
fs::create_dir_all, and ComposioTriggerHistoryStore::new) into a small test
helper function (e.g., fn make_test_store() -> ComposioTriggerHistoryStore or fn
make_test_store() -> (tempfile::TempDir, ComposioTriggerHistoryStore) if you
need to keep the TempDir alive) and call that helper from the tests that
currently duplicate the setup (tests using ComposioTriggerHistoryStore::new in
list_recent, list_recent_empty_store, and
record_trigger_returns_entry_with_correct_fields); update those tests to use the
helper instead of repeating the tempfile/workspace/store creation.
src/openhuman/doctor/schemas.rs (1)

139-146: Assert length equality before zip for robust drift detection.

zip silently truncates to the shorter iterator; if all_controller_schemas() and all_registered_controllers() diverge in length, this test will pass. Match the encryption/service style with an explicit assert_eq!(s.len(), c.len()).

♻️ Proposed tweak
     fn schemas_and_controllers_match() {
         let s = all_controller_schemas();
         let c = all_registered_controllers();
+        assert_eq!(s.len(), c.len());
         for (schema, ctrl) in s.iter().zip(c.iter()) {
             assert_eq!(schema.function, ctrl.schema.function);
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/doctor/schemas.rs` around lines 139 - 146, The test
schemas_and_controllers_match should first assert the two collections have equal
length to avoid silent truncation by zip: call assert_eq!(s.len(), c.len()) (or
assert_eq!(s.len(), c.len(), "mismatch between all_controller_schemas and
all_registered_controllers")) immediately after obtaining s =
all_controller_schemas() and c = all_registered_controllers(), then proceed to
zip and compare schema.function vs ctrl.schema.function as before; this ensures
divergence in count fails the test.
src/openhuman/update/schemas.rs (1)

169-177: Assert equal lengths before zip to avoid silent pass on size mismatch.

zip truncates to the shorter iterator, so a drift between all_controller_schemas() and all_registered_controllers() (e.g., someone adds only one side) would not fail this test. Mirror the encryption/service tests which assert s.len() == c.len() first.

♻️ Proposed tweak
     fn schemas_and_controllers_match() {
         let s = all_controller_schemas();
         let c = all_registered_controllers();
+        assert_eq!(s.len(), c.len());
         for (schema, ctrl) in s.iter().zip(c.iter()) {
             assert_eq!(schema.function, ctrl.schema.function);
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/update/schemas.rs` around lines 169 - 177, The test
schemas_and_controllers_match currently zips all_controller_schemas() and
all_registered_controllers(), which can silently truncate mismatched
collections; before iterating, add an assertion that s.len() == c.len() (or
assert_eq!(s.len(), c.len(), "schemas and controllers count mismatch")) to fail
when counts differ, then proceed to zip and compare schema.function to
ctrl.schema.function; reference the test function name
schemas_and_controllers_match and the helpers all_controller_schemas and
all_registered_controllers when applying the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openhuman/tools/impl/system/proxy_config.rs`:
- Around line 711-724: The test missing_action_returns_error is misleading and a
no-op because ProxyConfigTool::execute defaults a missing "action" to "get" (see
execute implementation dispatching to handle_get), so update the test to assert
the documented default behavior: rename the test (e.g.,
missing_action_defaults_to_get) and replace the match with an explicit assertion
that tool.execute(json!({})).await returns Ok and that the returned ToolResult
(or resulting state from handle_get) matches the expected "get" behavior;
alternatively remove the test if you prefer not to cover this case. Ensure you
update references to the test name and assert either Ok(_) or specific fields in
the returned result instead of discarding it.

---

Nitpick comments:
In `@src/openhuman/accessibility/keys.rs`:
- Around line 128-133: The test kvk_constants_are_correct is tautological
because it compares KVK_TAB and KVK_ESCAPE to the same numeric literals; instead
either remove the test or make it assert against an external source of truth:
change the expected values to Apple's official constants (kVK_Tab = 0x30,
kVK_Escape = 0x35) and add a comment citing HIToolbox/Events.h as the source, or
delete the kvk_constants_are_correct test entirely so the code isn't asserting
its own definitions.

In `@src/openhuman/channels/runtime/supervision.rs`:
- Around line 91-120: Remove the duplicated zero-channel test and tighten the
assertions: drop compute_max_in_flight_messages_clamps_to_min (which duplicates
compute_max_in_flight_messages_zero_channels) and change
compute_max_in_flight_messages_one_channel and
compute_max_in_flight_messages_many_channels to assert exact values (using
assert_eq!) based on the multiplier and clamp constants
(compute_max_in_flight_messages(1) == CHANNEL_MIN_IN_FLIGHT_MESSAGES and
compute_max_in_flight_messages(100) == CHANNEL_MAX_IN_FLIGHT_MESSAGES given
CHANNEL_PARALLELISM_PER_CHANNEL and clamps); add a meaningful boundary test
instead of the removed duplicate (e.g., a channel_count that yields the first
value > CHANNEL_MIN_IN_FLIGHT_MESSAGES or a channel_count just below the value
that clamps to CHANNEL_MAX_IN_FLIGHT_MESSAGES) to verify the transition off the
min/max clamps.

In `@src/openhuman/composio/trigger_history.rs`:
- Around line 284-319: Extract the repeated test setup (tempfile::tempdir,
workspace path creation, fs::create_dir_all, and
ComposioTriggerHistoryStore::new) into a small test helper function (e.g., fn
make_test_store() -> ComposioTriggerHistoryStore or fn make_test_store() ->
(tempfile::TempDir, ComposioTriggerHistoryStore) if you need to keep the TempDir
alive) and call that helper from the tests that currently duplicate the setup
(tests using ComposioTriggerHistoryStore::new in list_recent,
list_recent_empty_store, and record_trigger_returns_entry_with_correct_fields);
update those tests to use the helper instead of repeating the
tempfile/workspace/store creation.

In `@src/openhuman/doctor/schemas.rs`:
- Around line 139-146: The test schemas_and_controllers_match should first
assert the two collections have equal length to avoid silent truncation by zip:
call assert_eq!(s.len(), c.len()) (or assert_eq!(s.len(), c.len(), "mismatch
between all_controller_schemas and all_registered_controllers")) immediately
after obtaining s = all_controller_schemas() and c =
all_registered_controllers(), then proceed to zip and compare schema.function vs
ctrl.schema.function as before; this ensures divergence in count fails the test.

In `@src/openhuman/memory/store/unified/helpers.rs`:
- Around line 192-425: Add a small unit test to exercise the
negative-dot-product branch for UnifiedMemory::cosine_similarity by asserting a
case like vectors [1.0_f32, 0.0] vs [-1.0_f32, 0.0] yields the clamped
lower-bound (0.0) to ensure the clamp(0.0, 1.0) behavior is covered; add it
alongside the other cosine_similarity tests within the tests module so the
behavior is deterministically verified.

In `@src/openhuman/security/detect.rs`:
- Around line 194-222: The tests bubblewrap_backend_falls_back_when_unavailable
and docker_backend_falls_back_when_unavailable currently only assert
sandbox.is_available(), which doesn't distinguish a real backend from the Noop
fallback; update each test (the SecurityConfig/SandboxConfig setup that uses
SandboxBackend::Bubblewrap and SandboxBackend::Docker and the
create_sandbox(...) call) to assert on sandbox.name() instead, checking that the
returned name is one of the expected values (e.g., "none" or "bubblewrap" for
the Bubblewrap test; "none" or "docker" for the Docker test) so the fallback
path is actually verified rather than relying solely on is_available().
- Around line 161-192: The two tests landlock_backend_on_non_linux_falls_back
and firejail_backend_on_non_linux_falls_back currently guard their assertions
with if std::env::consts::OS != "linux", making them no-ops on Linux; update
each test to either be platform-gated with #[cfg(not(target_os = "linux"))] so
the whole test only runs on non-Linux, or expand the test to include a Linux
branch that asserts create_sandbox(&config).name() returns an expected value for
Linux (e.g., one of "none" or the backend-specific name) so the test performs a
meaningful assertion on all platforms; locate these tests and the use of
SecurityConfig/SandboxConfig/SandboxBackend and create_sandbox to apply the
change.

In `@src/openhuman/update/schemas.rs`:
- Around line 169-177: The test schemas_and_controllers_match currently zips
all_controller_schemas() and all_registered_controllers(), which can silently
truncate mismatched collections; before iterating, add an assertion that s.len()
== c.len() (or assert_eq!(s.len(), c.len(), "schemas and controllers count
mismatch")) to fail when counts differ, then proceed to zip and compare
schema.function to ctrl.schema.function; reference the test function name
schemas_and_controllers_match and the helpers all_controller_schemas and
all_registered_controllers when applying the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c83e4f6a-36c5-419c-ac8a-750c86392232

📥 Commits

Reviewing files that changed from the base of the PR and between dced586 and b62a07f.

📒 Files selected for processing (14)
  • src/core/all.rs
  • src/openhuman/accessibility/keys.rs
  • src/openhuman/accessibility/terminal.rs
  • src/openhuman/channels/runtime/supervision.rs
  • src/openhuman/composio/trigger_history.rs
  • src/openhuman/doctor/schemas.rs
  • src/openhuman/encryption/schemas.rs
  • src/openhuman/learning/schemas.rs
  • src/openhuman/memory/store/unified/helpers.rs
  • src/openhuman/security/detect.rs
  • src/openhuman/service/schemas.rs
  • src/openhuman/skills/types.rs
  • src/openhuman/tools/impl/system/proxy_config.rs
  • src/openhuman/update/schemas.rs

Comment on lines +711 to +724
#[tokio::test]
async fn missing_action_returns_error() {
let tmp = TempDir::new().unwrap();
let tool = ProxyConfigTool::new(test_config(&tmp).await, test_security());
let result = tool.execute(json!({})).await;
// Missing action may return Err or ToolResult::error
match result {
Err(_) => {}
Ok(r) => {
// Some implementations return success with help text; just verify it ran
let _ = r;
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Misleading test name and no-op assertions.

Looking at execute (line 368–372), a missing action field defaults to "get", which successfully dispatches to handle_get. So missing_action_returns_error will never observe an error — the match arms both effectively pass unconditionally (the Ok arm discards the result with let _ = r;). This test doesn't verify any behavior and its name contradicts the actual contract.

Consider either renaming and asserting the documented default behavior, or removing the test:

♻️ Suggested rename + real assertion
-    #[tokio::test]
-    async fn missing_action_returns_error() {
-        let tmp = TempDir::new().unwrap();
-        let tool = ProxyConfigTool::new(test_config(&tmp).await, test_security());
-        let result = tool.execute(json!({})).await;
-        // Missing action may return Err or ToolResult::error
-        match result {
-            Err(_) => {}
-            Ok(r) => {
-                // Some implementations return success with help text; just verify it ran
-                let _ = r;
-            }
-        }
-    }
+    #[tokio::test]
+    async fn missing_action_defaults_to_get() {
+        let tmp = TempDir::new().unwrap();
+        let tool = ProxyConfigTool::new(test_config(&tmp).await, test_security());
+        let result = tool.execute(json!({})).await.unwrap();
+        assert!(!result.is_error, "{:?}", result.output());
+        assert!(result.output().contains("proxy"));
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/tools/impl/system/proxy_config.rs` around lines 711 - 724, The
test missing_action_returns_error is misleading and a no-op because
ProxyConfigTool::execute defaults a missing "action" to "get" (see execute
implementation dispatching to handle_get), so update the test to assert the
documented default behavior: rename the test (e.g.,
missing_action_defaults_to_get) and replace the match with an explicit assertion
that tool.execute(json!({})).await returns Ok and that the returned ToolResult
(or resulting state from handle_get) matches the expected "get" behavior;
alternatively remove the test if you prefer not to cover this case. Ensure you
update references to the test name and assert either Ok(_) or specific fields in
the returned result instead of discarding it.

CodeGhost21 and others added 3 commits April 17, 2026 01:55
…inyhumansai#530)

Add 7 new tests:
- service/restart: default source/reason, whitespace trimming, empty-string
  defaults, RestartStatus serde, startup delay noop
- memory/store/factories: effective_memory_backend_name, migration-disabled error

All 4223 tests pass.
…mas (tinyhumansai#530)

Add 38 new tests across 2 modules:
- tree_summarizer/schemas: catalog parity, all 5 functions, param helpers
  (read_required, read_optional, read_optional_timestamp), type_name,
  namespace_input
- subconscious/schemas: catalog parity, all 10 functions, required input
  validation, field/field_req/field_opt helpers

All 4261 tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase Rust unit test coverage to 80% for critical modules

2 participants