Add direct integration test for load_and_get_security_policy_info
Summary
Add a focused integration test that exercises the env-var → config → RPC payload path through `load_and_get_security_policy_info()` so a regression in the overlay or the security-policy build step is caught by a fast unit run, not only by the full CI RPC smoke.
Problem
After PR #2499 landed the `OPENHUMAN_MAX_ACTIONS_PER_HOUR` env override, M3gA-Mind's review noted (https://github.com/tinyhumansai/openhuman/pull/2499#pullrequestreview-…) that each constituent piece has isolated coverage:
- the env-overlay step in `src/openhuman/config/schema/load.rs` parses the var and applies it to `Config.autonomy.max_actions_per_hour`,
- `security_policy_info_for_config(&config)` in `src/openhuman/security/ops.rs` builds the JSON payload from a given config,
- `load_and_get_security_policy_info()` chains them via `load_config_with_timeout().await` and returns the active payload.
But the chained path — i.e. "`OPENHUMAN_MAX_ACTIONS_PER_HOUR=42` in the environment ⇒ `load_and_get_security_policy_info().await.value["autonomy"]["max_actions_per_hour"] == 42`" — is currently only exercised by CI's full JSON-RPC smoke (`scripts/test-rust-with-mock.sh`). A regression there is detectable, but not via a focused `cargo test` run.
Solution (optional)
Add one Rust unit/integration test, e.g. in `src/openhuman/security/ops_tests.rs` or as an `#[tokio::test]` next to the other policy tests:
```rust #[tokio::test] async fn load_and_get_security_policy_info_reflects_env_overlay() { let _serial = GLOBAL_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner()); std::env::set_var("OPENHUMAN_MAX_ACTIONS_PER_HOUR", "42");
let outcome = load_and_get_security_policy_info().await.expect(\"load policy\");
assert_eq!(outcome.value[\"autonomy\"][\"max_actions_per_hour\"], json!(42));
std::env::remove_var(\"OPENHUMAN_MAX_ACTIONS_PER_HOUR\");
} ```
Notes:
- Use the same env-mutation serialization pattern already present in other tests (an `ENV_LOCK` static).
- The test must restore the env var on exit (success or panic) so unrelated tests in the same process are not affected.
- Pair with at least one negative test (`=0` → policy correctly reports zero budget) to lock in the behaviour documented in `.env.example`.
Acceptance criteria
- [ ] Direct test added — a focused Rust test exercises the full env → config → `load_and_get_security_policy_info` chain.
- [ ] =0 edge case covered — `OPENHUMAN_MAX_ACTIONS_PER_HOUR=0` is asserted to surface as zero in the RPC payload (matching the ".env.example" note).
- [ ] No flake — env mutation uses the existing serialization pattern; CI passes on all platforms (including the parallel-test runners).
- [ ] Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (`cargo-llvm-cov` via diff-cover, enforced by `.github/workflows/coverage.yml`).
Related
- Follow-up from #2499 — M3gA-Mind's review ("Nit — `load_and_get_security_policy_info` has no direct test").
Picking this one up. Will add a direct unit test that sets OPENHUMAN_MAX_ACTIONS_PER_HOUR, runs the load + policy-info chain end-to-end, and asserts the env value propagates into the policy payload.