Skip to content

test(rpc,core,billing,team): harden registry + RPC helpers with edge-case coverage#786

Merged
senamakel merged 3 commits intotinyhumansai:mainfrom
jwalin-shah:rust-rpc-hardening-1
Apr 23, 2026
Merged

test(rpc,core,billing,team): harden registry + RPC helpers with edge-case coverage#786
senamakel merged 3 commits intotinyhumansai:mainfrom
jwalin-shah:rust-rpc-hardening-1

Conversation

@jwalin-shah
Copy link
Copy Markdown
Contributor

@jwalin-shah jwalin-shah commented Apr 22, 2026

Summary

Test-only hardening for the Rust core RPC layer and two domain ops modules. No production code changes — every added line lives under #[cfg(test)] or a mod tests block.

Covers:

  • src/rpc/mod.rsRpcOutcome<T> constructor, log handling, and JSON serialization shape
  • src/core/mod.rsControllerSchema / FieldSchema / TypeSchema metadata invariants
  • src/core/dispatch.rs — core dispatch routing, unknown-method behavior
  • src/core/jsonrpc.rs — helper contracts: params_to_object, parse_json_params, escape_html, type_name, is_session_expired_error
  • src/core/all.rsvalidate_params edge cases (missing optional, extra fields, type mismatches)
  • src/openhuman/billing/ops.rs — pre-HTTP input validation (empty/whitespace plan, payment method id, coupon code; zero/NaN/±Inf top-up amount; gateway normalization)
  • src/openhuman/team/ops.rsbuild_api_path edge cases and registry coverage

Why it matters

Locks in the current behavior of the JSON-RPC envelope and pre-HTTP input validation so future refactors of the core registry and adapters (core_server::dispatch, core/jsonrpc) can't silently regress input shape, error messages, or dispatch routing.

Validation

  • `cargo test --lib` → 4765 passed (no failures, no ignored)
  • `cargo fmt --check` → clean
  • `cargo check` → clean

Pre-HTTP billing tests are explicitly documented to only exercise argument checks that run before any HTTP call — no network, no backend, no stored session token required.

Risk

Minimal. Tests only. No runtime behavior change.

Summary by CodeRabbit

Release Notes

  • Tests
    • Added comprehensive unit tests for input validation, parameter handling, and error reporting across core routing and RPC layers
    • Expanded coverage for JSON-RPC helper functions and schema validation
    • Added validation tests for billing operations and team management functions

claude added 2 commits April 22, 2026 14:22
…tracts

Adds unit coverage to modules that currently gate RPC correctness but had
weak or zero test coverage:

- src/rpc/mod.rs: RpcOutcome::new, single_log, and into_cli_compatible_json
  — verify the CLI envelope shape switches on log presence, log order is
  preserved, empty-string logs still trigger the envelope, and null values
  round-trip unwrapped when there are no logs.
- src/core/dispatch.rs: core.ping / core.version routing, unknown-method
  error surface, empty-method handling, tier-2 delegation to rpc::try_dispatch,
  and exact-match semantics of try_core_dispatch.
- src/core/mod.rs: ControllerSchema::method_name formatting, drift guard
  against rpc_method_name, JSON serialization shape, and PartialEq behavior
  for FieldSchema/TypeSchema nesting.
- src/core/jsonrpc.rs: params_to_object shape errors (array/string/number),
  type_name per variant, parse_json_params success + error text,
  is_session_expired_error matching rules (401+unauthorized, invalid token,
  SESSION_EXPIRED sentinel), escape_html coverage, and invoke_method
  rejection of array/string params for registered methods.
…t validation

Second batch hardening the Rust core/RPC surface:

- src/core/all.rs: validate_params edge cases (optional present/absent,
  missing-required error carries comment + namespace.function, missing-required
  fires before unknown-param, null values satisfy presence check);
  validate_registry edge cases (empty/whitespace namespace, empty function,
  declared-without-registered, registered-without-declared, duplicate
  registered controllers); try_invoke_registered_rpc None/Some routing;
  global registry consistency invariant.
- src/openhuman/billing/ops.rs: purchase_plan / create_coinbase_charge /
  redeem_coupon reject empty + whitespace inputs before any HTTP call;
  update_card / delete_card reject empty paymentMethodId; top_up_credits
  rejects zero, negative, NaN, ±Infinity amounts; gateway validation
  fires after amount validation.
- src/openhuman/team/ops.rs: build_api_path edge cases (empty list,
  segment ordering, space + unicode percent-encoding); normalize_id trims
  edges but preserves interior whitespace; every team op that normalizes
  an ID rejects empty/whitespace before hitting the backend; composite ops
  (remove_member, change_member_role, revoke_invite) check identifiers in
  left-to-right order so error messages are deterministic.
@jwalin-shah jwalin-shah requested a review from a team April 22, 2026 14:46
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6749b762-f18a-4df1-8083-02082b4cdf6a

📥 Commits

Reviewing files that changed from the base of the PR and between b3b451f and 2dd76c8.

📒 Files selected for processing (7)
  • src/core/all.rs
  • src/core/dispatch.rs
  • src/core/jsonrpc.rs
  • src/core/mod.rs
  • src/openhuman/billing/ops.rs
  • src/openhuman/team/ops.rs
  • src/rpc/mod.rs

📝 Walkthrough

Walkthrough

This PR adds comprehensive unit tests across core and openhuman modules, covering parameter validation, registry validation, RPC routing, JSON-RPC helpers, schema types, billing operations, team operations, and RPC outcome serialization. All changes are test-only with no modifications to public APIs or exports.

Changes

Cohort / File(s) Summary
Core Validation & Routing
src/core/all.rs, src/core/dispatch.rs
Added tests for parameter/registry validation, RPC method routing (including openhuman.health_snapshot), and core method dispatch (core.ping, core.version). Covers edge cases like missing required fields, unknown parameters, and schema mismatches.
Core JSON-RPC & Schema
src/core/jsonrpc.rs, src/core/mod.rs
Added tests for JSON-RPC helpers (params_to_object, type_name, parse_json_params, escape_html, is_session_expired_error) and ControllerSchema serialization/equality. Validates parameter shape handling and session expiration detection.
Openhuman Operations
src/openhuman/billing/ops.rs, src/openhuman/team/ops.rs
Added pre-HTTP input validation tests for billing (purchase_plan, update_card, top_up_credits, etc.) and team operations (list_members, create_team, remove_member, etc.), including URL path construction and identifier normalization.
RPC Outcome
src/rpc/mod.rs
Added tests for RpcOutcome<T> construction, logging, and JSON serialization behavior, covering both bare JSON and envelope-wrapped outputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • senamakel
  • graycyrus

Poem

🐰 A rabbit hops through test suites bright,
Validating params left and right,
With schemas checked and routes confirmed,
Each edge case caught, each error learned!
From billing ops to team affairs,
The code now breathes with testing cares.

🚥 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 summarizes the main change: adding comprehensive edge-case test coverage for RPC, core registry, and helper functions across multiple modules.
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.

✨ 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.

jwalin-shah pushed a commit to jwalin-shah/openhuman that referenced this pull request Apr 23, 2026
Two implementation plans drafted from the life-capture spec:

- Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs
  tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds.
- Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db,
  Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread
  stripping, hybrid retrieval (vector + keyword + recency), controller
  schema + RPC. End-to-end test with synthetic items. No ingestion or UI
  yet — those are subsequent milestone plans.
@senamakel senamakel merged commit 4993a41 into tinyhumansai:main Apr 23, 2026
7 of 8 checks passed
jwalin-shah pushed a commit to jwalin-shah/openhuman that referenced this pull request Apr 23, 2026
Two implementation plans drafted from the life-capture spec:

- Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs
  tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds.
- Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db,
  Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread
  stripping, hybrid retrieval (vector + keyword + recency), controller
  schema + RPC. End-to-end test with synthetic items. No ingestion or UI
  yet — those are subsequent milestone plans.
jwalin-shah pushed a commit to jwalin-shah/openhuman that referenced this pull request Apr 23, 2026
Two implementation plans drafted from the life-capture spec:

- Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs
  tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds.
- Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db,
  Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread
  stripping, hybrid retrieval (vector + keyword + recency), controller
  schema + RPC. End-to-end test with synthetic items. No ingestion or UI
  yet — those are subsequent milestone plans.
jwalin-shah pushed a commit to jwalin-shah/openhuman that referenced this pull request Apr 23, 2026
Two implementation plans drafted from the life-capture spec:

- Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs
  tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds.
- Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db,
  Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread
  stripping, hybrid retrieval (vector + keyword + recency), controller
  schema + RPC. End-to-end test with synthetic items. No ingestion or UI
  yet — those are subsequent milestone plans.
@jwalin-shah jwalin-shah deleted the rust-rpc-hardening-1 branch April 23, 2026 21:13
jwalin-shah pushed a commit to jwalin-shah/openhuman that referenced this pull request Apr 25, 2026
Two implementation plans drafted from the life-capture spec:

- Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs
  tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds.
- Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db,
  Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread
  stripping, hybrid retrieval (vector + keyword + recency), controller
  schema + RPC. End-to-end test with synthetic items. No ingestion or UI
  yet — those are subsequent milestone plans.
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.

4 participants