openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

test: unblock cargo test --lib on main (3 stale test fixtures)

Open oxoxDev opened this issue 6 months ago • 2 comments

Summary

  • Unblock cargo test --lib on main by fixing 3 test-side regressions that have shipped onto main without their tests being updated.
  • Compile fix: ops_tests.rs:631 AutonomySettingsPatch literal missing fields added in #2486.
  • Behavior-update fix #1: factory_test.rs:768 test was iterating hint:summarization as an unknown-passthrough case after #2690 made it canonical.
  • Behavior-update fix #2: chat.rs:218,226 test assertions hard-coded reasoning-v1 even though build_chat_runtime now resolves to summarization-v1 by default after #2690.

Problem

cargo test --lib is red on upstream/main across the Rust Core Coverage, Rust Core Tests + Quality, and Rust Core Tests (Windows — secrets ACL) workflows. Every open PR inherits these failures regardless of what it touches.

Root cause: two recently-merged PRs shipped code changes without updating their tests in the same change.

Failure 1 — ops_tests.rs:631 (compile-time, hidden by silence)

error[E0063]: missing fields `allow_tool_install`, `allowed_commands`,
  `forbidden_paths` and 3 other fields in initializer of
  `openhuman::config::ops::AutonomySettingsPatch`
  --> src/openhuman/config/ops_tests.rs:631:9

AutonomySettingsPatch gained six Option<…> fields (level, workspace_only, allowed_commands, forbidden_paths, trusted_roots, allow_tool_install) via #2486 (feat(app): UI control for max_actions_per_hour). The test literal at line 631 still set only max_actions_per_hour. All other literals in the same file were updated; this one was missed.

Failure 2 — factory_test.rs:768 (assertion)

thread '…::make_openhuman_backend_forwards_unknown_hint_verbatim' panicked at
  src/openhuman/inference/provider/factory_test.rs:768:9:
  assertion `left == right` failed: hint 'hint:summarization' should pass through unchanged
    left: "summarization-v1"
   right: "hint:summarization"

#2690 (fix: … summarization-v1 tier …) added summarization-v1 as a canonical model tier. is_known_openhuman_tier (src/openhuman/inference/provider/factory.rs:79-98) explicitly includes "hint:summarization", so the factory now translates that hint to summarization-v1 rather than forwarding it verbatim. The test was iterating hint:summarization as an "unknown" passthrough case — that classification is no longer correct.

Failure 3 — chat.rs:218 / chat.rs:226 (assertion)

thread '…::build_chat_runtime_defaults_to_openhuman_resolved_model' panicked at
  src/openhuman/memory/chat.rs:218:9:
  assertion `left == right` failed
    left: "summarization-v1"
   right: "reasoning-v1"

build_chat_runtime calls create_chat_provider("summarization", …) (src/openhuman/memory/chat.rs:127-147). After #2690 the "summarization" workload routes to summarization-v1 by default. The first assertion still expected reasoning-v1. Same file at line 226 (build_chat_runtime_still_builds_when_cloud_memory_model_is_overridden) is a sister case — but when memory_tree.cloud_llm_model is overridden, the routing actually does fall back to reasoning-v1. Both tests are updated to assert the value the function returns under each scenario.

Solution

Three micro-commits, each cargo check-clean independently:

  1. fix(config/tests): init AutonomySettingsPatch with Default-padded fields — single-line ..Default::default() addition at ops_tests.rs:632. AutonomySettingsPatch derives Default, so the other Option<…> fields keep their previous (absent → None) value.
  2. test(inference): drop hint:summarization from passthrough loop — remove the canonical hint from the iteration and tighten the comment.
  3. test(memory/chat): update expected default model after summarization-v1 — flip the two stale assertions (reasoning-v1 → summarization-v1 for the default; reasoning-v1 is correct for the cloud-override case).

No production code changes. Three test files only.

Submission Checklist

  • [x] cargo check --tests --lib clean (was E0063 before)
  • [x] cargo test --lib openhuman::inference::provider::factory clean
  • [x] cargo test --lib openhuman::memory::chat::tests::build_chat_runtime — 3 / 3 pass
  • [x] cargo fmt --all -- --check clean
  • [x] N/A: i18n strings — non-UI change
  • [x] N/A: frontend typecheck / lint / vitest — no TS surface touched
  • [x] N/A: docs / changelog — pure test compile + assertion fix
  • [x] N/A: tests added — this PR restores existing tests; it doesn't change production behavior so no new assertions are warranted

Known still-flaky tests (out of scope for this PR)

cargo test --lib (full local run) also fails two tests when run as part of the full suite that PASS in isolation:

  • openhuman::memory::ops::documents::tests::envelope_memory_handlers_report_counts_and_statuses — surfaces memory_init: "disk I/O error" from sqlite when prior tests in the suite ran and contaminated process-global state. GLOBAL_MEMORY_TEST_LOCK exists already (added in #2649) for cross-test serialization but the sqlite open path appears to use OnceLock-style caching that breaks when tempdirs are recycled across tests. Same pattern flagged in earlier memory work.
  • openhuman::composio::action_tool::tests::mode_toggle_between_calls_is_observed — the test asserts a direct-mode tool error must NOT contain "no backend session", but under full-suite ordering a prior test leaves a cached backend client visible to this one. Same isolation issue, different domain.

Both pass in isolation:

cargo test --lib envelope_memory_handlers_report_counts_and_statuses → ok
cargo test --lib mode_toggle_between_calls_is_observed → ok

These are pre-existing test-isolation bugs (process-global state across tests), not regressions caused by this PR. Worth a follow-up that audits per-test reset hooks for the memory and composio singletons (RwLock<Option<Arc>> + reset_for_tests pattern is the usual fix shape).

Impact

  • Unblocks cargo test --lib matrix for every open PR (we hit these failures on #2708 and #2709 immediately after pushing).
  • Zero production behavior change — only test code touched.

Related

  • Test-side fallout from #2486 (AutonomySettingsPatch field additions) and #2690 (summarization-v1 tier).
  • Surfaced while running CI on #2708 (wallet quote owner binding) and #2709 (in-process core token transport).

Summary by CodeRabbit

Release Notes

  • Tests
    • Updated test coverage for hint handling and workload routing behavior to accurately reflect current system configurations.

Review Change Stack

oxoxDev avatar May 26 '26 18:05 oxoxDev

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e365fa5f-ed06-4383-a665-da3e68848a70

📥 Commits

Reviewing files that changed from the base of the PR and between f03a6d127ff19f7e1c5f1fc2ff1b7ea53f861547 and 44dabd7952cfa06c4672dd08579474cffc002f1a.

📒 Files selected for processing (2)
  • src/openhuman/inference/provider/factory_test.rs
  • src/openhuman/memory/chat.rs
✅ Files skipped from review due to trivial changes (1)
  • src/openhuman/memory/chat.rs

📝 Walkthrough

Walkthrough

This PR updates test documentation and assertions across two files to reflect that hint:summarization and summarization workload routing are now handled as canonical cases with dedicated tier routing, rather than unknown passthrough or fallback behaviors.

Changes

Test expectations: hint canonicalization and model routing

Layer / File(s) Summary
Provider factory: hint:summarization canonicalization
src/openhuman/inference/provider/factory_test.rs
make_openhuman_backend_forwards_unknown_hint_verbatim test narrowed to verify passthrough only for truly unrecognized hints like hint:reaction and hint:garbage, excluding hint:summarization as a canonical case.
Memory chat: workload routing and model defaults
src/openhuman/memory/chat.rs
Test comments updated to document that summarization workload resolves to summarization-v1 tier and clarify how memory_tree.cloud_llm_model override affects cloud-memory routing paths.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2223: Both PRs adjust src/openhuman/inference/provider/factory_test.rs to align hint:summarization handling with the factory's hint:*/canonical-tier recognition rules (while other unrecognized hint:* values continue to be treated as verbatim passthrough).

Suggested labels

memory

Suggested reviewers

  • graycyrus
  • senamakel

Poem

🐰 Hints now have their proper tier,
summarization claims its sphere,
No longer passthrough, now it's clear—
Routing is canonical here! ✨

🚥 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 main objective: unblocking cargo test --lib by fixing three stale test fixtures. It is specific and directly reflects the primary change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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

coderabbitai[bot] avatar May 26 '26 18:05 coderabbitai[bot]

CI note: Frontend Unit Tests and Frontend Coverage (Vitest) failed on this run, but both are pre-existing main failures unrelated to this PR.

  • This PR touches only 3 Rust test files (ops_tests.rs, factory_test.rs, chat.rs) — zero frontend overlap.
  • Verified: the same Vitest job is failing on the latest main run (loopbackOauthListener.test.ts > returns null when shell bind fails — 1 failed / 359 passed / 1 skipped). Same shape on this PR.
  • Rust-side checks for this PR (Rust Quality fmt+clippy, Type Check TypeScript) are green; test / Rust Core Tests is the gate this PR actually moves.

No fix here — the loopback OAuth test flake should land in a separate frontend-scoped PR.

oxoxDev avatar May 26 '26 19:05 oxoxDev