Skip to content

fix(memory): graph query returns namespace data and add sync e2e tests (#344)#363

Merged
graycyrus merged 2 commits into
tinyhumansai:mainfrom
sanil-23:fix/344-memory-graph-sync-tests
Apr 6, 2026
Merged

fix(memory): graph query returns namespace data and add sync e2e tests (#344)#363
graycyrus merged 2 commits into
tinyhumansai:mainfrom
sanil-23:fix/344-memory-graph-sync-tests

Conversation

@sanil-23
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 commented Apr 6, 2026

Summary

  • Root cause fix: graph_query(None) only queried the graph_global table, which is always empty because ingestion writes to graph_namespace. Added graph_query_all() that queries both tables and merges results — the knowledge graph now shows entities in the UI.
  • UI fix: MemoryWorkspace now passes selectedNamespace to the graph query RPC instead of calling with no parameters.
  • Diagnostic logging: Added logs in the ingestion pipeline for RelEx model availability and extraction counts, and debug logging in tauriCommands for unexpected RPC response shapes.
  • Integration tests: Two #[ignore] tests proving the sync-to-graph contract (run with --ignored).

Test plan

  • cargo check passes
  • cargo test --test memory_graph_sync_e2e -- --ignored — 2 passed
  • cargo fmt clean
  • Manual: verify graph shows entities in Intelligence page after Notion sync

Closes #344

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Graph queries without a selected namespace now return aggregated results across all namespaces plus the global graph.
  • Bug Fixes

    • Improved error handling for relation fetches with clearer logging when unexpected responses occur.
  • Chores

    • Added debug logging around document parsing and query responses.
  • Tests

    • Added integration tests covering ingestion and graph query behaviors.

tinyhumansai#344)

The knowledge graph UI showed empty because graph_query(None) only queried
the graph_global table, while ingestion writes to graph_namespace. Now
graph_query(None) queries both tables via graph_query_all(), merging results.

Changes:
- Added graph_query_all() in unified graph store to query across all namespaces
- MemoryClient::graph_query(None) now uses graph_query_all() instead of
  graph_query_global()
- MemoryWorkspace passes selectedNamespace to the RPC call
- Added diagnostic logging in ingestion pipeline (RelEx model availability,
  extraction counts)
- Added debug logging in tauriCommands for unexpected response shapes
- Added 2 integration tests proving document sync populates the graph
  (ignored by default for CI, run with --ignored)

Closes tinyhumansai#344

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 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: 9a2f2f17-f2ca-430d-9fb6-e2eaceeb5f59

📥 Commits

Reviewing files that changed from the base of the PR and between 0c11c9a and d5d31e4.

📒 Files selected for processing (1)
  • app/src/utils/tauriCommands.ts

📝 Walkthrough

Walkthrough

Adds cross-namespace graph querying and logging, updates the frontend to pass the selected namespace to graph queries, and introduces integration tests that verify document ingestion populates namespace and cross-namespace graph results.

Changes

Cohort / File(s) Summary
Frontend namespace filtering
app/src/components/intelligence/MemoryWorkspace.tsx, app/src/utils/tauriCommands.ts
Passes `selectedNamespace
Backend cross-namespace graph query
src/openhuman/memory/store/client.rs, src/openhuman/memory/store/unified/graph.rs
Added graph_query_all(...) and helper to aggregate namespace-wide + global graph relations; MemoryClient::graph_query now calls graph_query_all when namespace is None.
Ingestion logging
src/openhuman/memory/ingestion.rs
Inserted debug logs at parse start (model availability, content/chunk metrics) and completion (entity/relation/preference counts).
Integration tests
tests/memory_graph_sync_e2e.rs
Adds two ignored #[tokio::test] integration tests validating that ingestion (sync and background) populates namespace and aggregated graph queries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • #185 — Modifies MemoryWorkspace.tsx related UI and graph handling; directly related to the frontend change here.

Suggested reviewers

  • senamakel
  • graycyrus

Poem

🐇 I hopped through namespaces, nose to the ground,
Collected relations that quietly abound,
Logged my findings with a tiny debug cheer,
Ingested stories now drawn ever near —
Hooray, the graph grows, one carrot of data clear! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly summarizes the main changes: fixing graph query to include namespace data and adding integration tests.
Linked Issues check ✅ Passed PR implements all major objectives from #344: adds integration tests proving sync-to-graph contract, provides dual graph query capability (all namespaces + global), includes diagnostic logging, and addresses timing with deterministic assertions.
Out of Scope Changes check ✅ Passed All changes directly support the #344 objectives: graph query fix, logging for diagnostics, UI integration, and e2e tests. No unrelated changes detected.

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

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

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 (1)
tests/memory_graph_sync_e2e.rs (1)

177-262: Fixed-duration sleep may cause flaky test results.

The 5-second sleep at line 213 to wait for background ingestion is timing-dependent. On slower CI runners or under load, the background worker may not complete in time.

Consider adding a polling mechanism or exposing a way to flush/await the ingestion queue for deterministic test behavior. However, since this is an #[ignore] test meant for manual verification, the current approach is acceptable for initial coverage.

The conservative assertion (lines 239-244) that only checks all_rows when ns_rows is non-empty is a pragmatic workaround for environments where the ONNX model may fail silently.

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

In `@tests/memory_graph_sync_e2e.rs` around lines 177 - 262, The test
put_doc_background_extraction_then_graph_query uses a fixed 5s
tokio::time::sleep which makes it flaky; replace the static sleep with a polling
loop that repeatedly calls graph_query(Some(namespace), ...) or
list_documents(Some(namespace)) until the expected document/relations appear or
a sensible timeout elapses (e.g., total wait ~30s with short sleeps between
attempts), and fail if the timeout is reached; update the test to reference the
existing functions put_doc, graph_query, and list_documents and keep the
conservative assertion logic but trigger it only after the poll confirms
background ingestion completion or times out.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/utils/tauriCommands.ts`:
- Around line 523-527: Prettier is flagging formatting around the debug log in
app/src/utils/tauriCommands.ts; run the formatter (e.g. prettier --write
app/src/utils/tauriCommands.ts) or remove the trailing comma after the second
argument in the console.debug call that contains '[memoryGraphQuery]' so the
file conforms to project Prettier rules; ensure overall file is reformatted and
committed.

---

Nitpick comments:
In `@tests/memory_graph_sync_e2e.rs`:
- Around line 177-262: The test put_doc_background_extraction_then_graph_query
uses a fixed 5s tokio::time::sleep which makes it flaky; replace the static
sleep with a polling loop that repeatedly calls graph_query(Some(namespace),
...) or list_documents(Some(namespace)) until the expected document/relations
appear or a sensible timeout elapses (e.g., total wait ~30s with short sleeps
between attempts), and fail if the timeout is reached; update the test to
reference the existing functions put_doc, graph_query, and list_documents and
keep the conservative assertion logic but trigger it only after the poll
confirms background ingestion completion or times out.
🪄 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: e0b7b3c6-bebd-4cfc-8730-8065781c127c

📥 Commits

Reviewing files that changed from the base of the PR and between a2dff71 and 0c11c9a.

📒 Files selected for processing (6)
  • app/src/components/intelligence/MemoryWorkspace.tsx
  • app/src/utils/tauriCommands.ts
  • src/openhuman/memory/ingestion.rs
  • src/openhuman/memory/store/client.rs
  • src/openhuman/memory/store/unified/graph.rs
  • tests/memory_graph_sync_e2e.rs

Comment thread app/src/utils/tauriCommands.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@graycyrus graycyrus merged commit b8ae967 into tinyhumansai:main Apr 6, 2026
8 of 9 checks passed
AusAgentSmith pushed a commit to AusAgentSmith/openhuman that referenced this pull request May 23, 2026
tinyhumansai#344) (tinyhumansai#363)

* fix(memory): graph query returns namespace data and add sync e2e tests (tinyhumansai#344)

The knowledge graph UI showed empty because graph_query(None) only queried
the graph_global table, while ingestion writes to graph_namespace. Now
graph_query(None) queries both tables via graph_query_all(), merging results.

Changes:
- Added graph_query_all() in unified graph store to query across all namespaces
- MemoryClient::graph_query(None) now uses graph_query_all() instead of
  graph_query_global()
- MemoryWorkspace passes selectedNamespace to the RPC call
- Added diagnostic logging in ingestion pipeline (RelEx model availability,
  extraction counts)
- Added debug logging in tauriCommands for unexpected response shapes
- Added 2 integration tests proving document sync populates the graph
  (ignored by default for CI, run with --ignored)

Closes tinyhumansai#344

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: remove trailing comma for Prettier compliance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

[Feature] Test memory sync: assert synced content reaches the knowledge graph

2 participants