feat(memory): add grounded observation synthesis layer #1026

Open
Rockachopa wants to merge 186 commits from fix/1013 into main
Owner

Closes #1013.

Summary:

  • add a persistent observation layer to holographic memory with dedicated observations and observation_evidence tables
  • synthesize three grounded higher-order observation types: recurring_preference, stable_direction, and behavioral_pattern
  • expose observations as a distinct retrieval lane via fact_store(action="observe") and surface them separately in prefetch alongside raw supporting facts
  • add focused tests for persistence, evidence links, confidence gating, and distinct prefetch formatting

Verification:

  • python3 -m pytest tests/plugins/memory/test_holographic_observations.py tests/agent/test_memory_provider.py -q
  • python3 -m py_compile plugins/memory/holographic/__init__.py plugins/memory/holographic/store.py plugins/memory/holographic/observations.py tests/plugins/memory/test_holographic_observations.py
  • manual provider check stored 3 observations with 6 evidence links and returned higher-order recall with provenance
Closes #1013. Summary: - add a persistent observation layer to holographic memory with dedicated `observations` and `observation_evidence` tables - synthesize three grounded higher-order observation types: recurring_preference, stable_direction, and behavioral_pattern - expose observations as a distinct retrieval lane via `fact_store(action="observe")` and surface them separately in prefetch alongside raw supporting facts - add focused tests for persistence, evidence links, confidence gating, and distinct prefetch formatting Verification: - `python3 -m pytest tests/plugins/memory/test_holographic_observations.py tests/agent/test_memory_provider.py -q` - `python3 -m py_compile plugins/memory/holographic/__init__.py plugins/memory/holographic/store.py plugins/memory/holographic/observations.py tests/plugins/memory/test_holographic_observations.py` - manual provider check stored 3 observations with 6 evidence links and returned higher-order recall with provenance
Rockachopa added 1 commit 2026-04-22 15:01:33 +00:00
feat(memory): add grounded observation synthesis layer
All checks were successful
Lint / lint (pull_request) Successful in 16s
7c38007094
Rockachopa reviewed 2026-04-22 15:12:08 +00:00
Rockachopa left a comment
Author
Owner

Review: Solid new capability.

This PR adds a grounded observation synthesis layer to the holographic memory system. The architecture is well-designed:

Strengths:

  • Observations are backed by explicit evidence links (foreign keys to facts), maintaining the "grounded" invariant.
  • The UNIQUE(observation_type, subject) constraint with ON CONFLICT ... DO UPDATE is correct for upsert semantics.
  • PRAGMA foreign_keys=ON is properly enabled to enforce the evidence cascade.
  • The prefetch path gracefully degrades: separate try/except blocks for fact search vs observation search mean one failing does not kill the other.
  • Evidence backfill when raw_results is empty but observations exist is a clever optimization.
  • Tests cover the key scenarios: multi-type synthesis, single-fact rejection, prefetch layering, and evidence link persistence.

Minor observations (non-blocking):

  1. _expand_evidence calls list_facts(min_trust=0.0, limit=1000) to build a lookup dict. This is also called in synthesize(). For stores with many facts, this double-scan could be optimized by passing the already-fetched facts list.
  2. The confidence formula 0.35 + 0.12 * matched_facts + 0.08 * active_labels is capped at 0.95. The floor of 2 matched facts means the minimum possible confidence before the min_confidence check is 0.59, so the default 0.6 threshold is tight. This seems intentional but worth documenting.
  3. The observe() method always calls synthesize(persist=True) when refresh=True, which does a full table scan. For the prefetch path (called every turn), consider whether a TTL-based cache would be more efficient.
**Review: Solid new capability.** This PR adds a grounded observation synthesis layer to the holographic memory system. The architecture is well-designed: **Strengths:** - Observations are backed by explicit evidence links (foreign keys to facts), maintaining the "grounded" invariant. - The `UNIQUE(observation_type, subject)` constraint with `ON CONFLICT ... DO UPDATE` is correct for upsert semantics. - `PRAGMA foreign_keys=ON` is properly enabled to enforce the evidence cascade. - The prefetch path gracefully degrades: separate try/except blocks for fact search vs observation search mean one failing does not kill the other. - Evidence backfill when `raw_results` is empty but observations exist is a clever optimization. - Tests cover the key scenarios: multi-type synthesis, single-fact rejection, prefetch layering, and evidence link persistence. **Minor observations (non-blocking):** 1. `_expand_evidence` calls `list_facts(min_trust=0.0, limit=1000)` to build a lookup dict. This is also called in `synthesize()`. For stores with many facts, this double-scan could be optimized by passing the already-fetched facts list. 2. The confidence formula `0.35 + 0.12 * matched_facts + 0.08 * active_labels` is capped at 0.95. The floor of 2 matched facts means the minimum possible confidence before the `min_confidence` check is 0.59, so the default 0.6 threshold is tight. This seems intentional but worth documenting. 3. The `observe()` method always calls `synthesize(persist=True)` when `refresh=True`, which does a full table scan. For the prefetch path (called every turn), consider whether a TTL-based cache would be more efficient.
All checks were successful
Lint / lint (pull_request) Successful in 16s
This pull request has changes conflicting with the target branch.
  • cli.py
  • gateway/platforms/api_server.py
  • hermes_cli/models.py
  • hermes_cli/web_server.py
  • plugins/memory/holographic/__init__.py
  • run_agent.py
  • tests/hermes_cli/test_web_server.py
  • tools/browser_tool.py
  • tools/file_tools.py
  • tools/skill_manager_tool.py
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/1013:fix/1013
git checkout fix/1013
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/hermes-agent#1026