openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

fix(memory): accept time_window_days global alias

Open DeadlySilent opened this issue 6 months ago • 1 comments

Summary

  • Allows QueryGlobalRequest to deserialize time_window_days as an alias for window_days.
  • Updates the consolidated memory_tree tool schema to expose the canonical window_days field for query_global while preserving the existing time_window_days compatibility path.
  • Adds regression tests for the alias and consolidated schema exposure.

Problem

The consolidated memory_tree tool advertised time_window_days for query_global, but the backend deserialized query_global arguments into:

QueryGlobalRequest { window_days: u32 }

So calls shaped like this failed with missing field 'window_days':

{
  "mode": "query_global",
  "time_window_days": 7
}

Solution

Accept time_window_days as a serde alias for window_days:

#[serde(alias = "time_window_days")]
pub window_days: u32,

and make the consolidated schema explicit about window_days for query_global.

Submission Checklist

  • [x] Tests added or updated (happy path + failure / edge case): alias deserialization test and consolidated schema exposure test added.
  • [x] N/A: Diff coverage >= 80% — local coverage tooling could not be run in this environment; changed behavior is covered by focused unit tests in source.
  • [x] N/A: Coverage matrix updated — bug fix to existing tool schema/deserialization behavior; no feature row added/removed/renamed.
  • [x] N/A: All affected feature IDs from the matrix are listed — no matrix feature row changed.
  • [x] No new external network dependencies introduced.
  • [x] N/A: Manual smoke checklist updated — internal memory tool schema/deserialization fix.
  • [x] Linked issue closed via Closes #2252.

Impact

  • Runtime/platform impact: Rust core memory tree request deserialization and tool schema only.
  • Compatibility impact: back-compatible; existing callers using window_days continue to work, and consolidated tool callers using time_window_days now work too.
  • Security impact: none; no new capability or external access.

Related

Closes #2252


AI Authored PR Metadata

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/memory-tree-window-alias
  • Commit SHA: c3350ae

Validation Run

  • [x] pnpm --filter openhuman-app format:check — N/A: Rust-only change.
  • [x] pnpm typecheck — N/A: Rust-only change.
  • [x] Focused tests: attempted cargo test --manifest-path Cargo.toml memory_tree --lib; blocked locally, see below.
  • [x] Rust fmt/check: attempted cargo fmt --check; blocked locally, see below.
  • [x] Tauri fmt/check: N/A: no app/src-tauri changes.

Validation Blocked

  • command: cargo fmt --check

  • error: error: no such command: fmt

  • impact: Local environment has Rust 1.75 without rustfmt installed; formatting should be verified by CI.

  • command: cargo test --manifest-path Cargo.toml memory_tree --lib

  • error: failed to parse lock file ... Cargo.lock; lock file version 4 requires -Znext-lockfile-bump

  • impact: Local cargo is 1.75 and cannot read the repository's lockfile format; CI/newer cargo should run the focused tests.

Behavior Changes

  • Intended behavior change: memory_tree global queries accept both window_days and the consolidated-schema alias time_window_days.
  • User-visible effect: LLM/tool calls using the advertised consolidated field no longer fail with missing window_days.

Parity Contract

  • Legacy behavior preserved: existing window_days callers continue to deserialize identically.
  • Guard/fallback/dispatch parity checks: only request deserialization/schema metadata changed; query execution remains unchanged.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none known.
  • Canonical PR: this PR.
  • Resolution: N/A.

Summary by CodeRabbit

  • Improvements
    • Memory query endpoints now accept an alternate parameter name ("time_window_days") in requests for compatibility with existing clients.
    • The memory tool’s parameter schema now exposes both "window_days" and "time_window_days" so interfaces can supply either field.

Review Change Stack

DeadlySilent avatar May 19 '26 21:05 DeadlySilent

📝 Walkthrough

Walkthrough

This PR makes QueryGlobalRequest.window_days accept time_window_days via a serde alias and updates the consolidated MemoryTree tool schema to expose both window_days and time_window_days; tests verify both deserialization and schema presence.

Changes

Memory Tree Global Query Field Compatibility

Layer / File(s) Summary
QueryGlobalRequest deserialization alias
src/openhuman/memory/tree/retrieval/rpc.rs
QueryGlobalRequest.window_days gains #[serde(alias = "time_window_days")]. A unit test verifies time_window_days JSON deserializes into window_days.
Tool schema and documentation update
src/openhuman/tools/impl/memory/tree/mod.rs
MemoryTreeTool.parameters_schema() now documents both time_window_days and window_days (with a compatibility note for query_global), and a schema unit test asserts both fields are present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

"I nibble on a schema, neat and small,
Two names at once — no error at all.
time_window_days and window_days agree,
The rabbit hops on, schema-smile for me! 🐇"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a serde alias for time_window_days to the window_days field in QueryGlobalRequest.
Linked Issues check ✅ Passed The PR fully addresses issue #2252 by implementing the serde alias approach and updating the consolidated schema to expose both window_days and time_window_days fields.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the schema/deserialization mismatch described in issue #2252; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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


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.

coderabbitai[bot] avatar May 19 '26 21:05 coderabbitai[bot]