Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
991fb2aaa3 |
@@ -1,42 +0,0 @@
|
||||
# Holographic + Vector Hybrid Memory Architecture
|
||||
|
||||
Research issue #879. Combining HRR (holographic) and vector (Qdrant) memory.
|
||||
|
||||
## Architecture
|
||||
|
||||
Three memory backends, each with unique strengths:
|
||||
|
||||
| Backend | Strength | Weakness | Use Case |
|
||||
|---------|----------|----------|----------|
|
||||
| FTS5 | Exact keyword match | No semantic understanding | Precise recall |
|
||||
| Vector (Qdrant) | Semantic similarity | No compositional queries | Topic search |
|
||||
| HRR (Holographic) | Compositional queries | Limited scale | Complex reasoning |
|
||||
|
||||
## Why Hybrid
|
||||
|
||||
- FTS5 alone: misses ~30-40% of semantically relevant content
|
||||
- Vector alone: can't do compositional queries ("what did I discuss about X after doing Y?")
|
||||
- HRR alone: unique capability but no semantic fallback
|
||||
- Hybrid: best of all three, RRF fusion for ranking
|
||||
|
||||
## Implementation: Reciprocal Rank Fusion
|
||||
|
||||
Results from each backend are merged using RRF:
|
||||
- score = sum(weight / (k + rank)) for each backend
|
||||
- k=60 (standard RRF constant)
|
||||
- Weights: FTS5=0.6, Vector=0.4 (configurable)
|
||||
|
||||
## Status
|
||||
|
||||
- FTS5: EXISTS (hermes_state.py)
|
||||
- Vector (Qdrant): implemented (tools/hybrid_search.py)
|
||||
- HRR: EXISTS (plugins/memory/holographic.py)
|
||||
- RRF fusion: implemented (tools/hybrid_search.py)
|
||||
- Ingestion pipeline: partial
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. Wire HRR into hybrid_search.py
|
||||
2. Session-level vector ingestion
|
||||
3. Benchmark: measure R@5 improvement
|
||||
4. Cross-session memory persistence
|
||||
@@ -883,6 +883,43 @@ def _execute_remote(
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Main entry point
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _validate_python_syntax(code: str) -> Optional[str]:
|
||||
"""Validate Python syntax before execution.
|
||||
|
||||
Returns a JSON error string if syntax is invalid, None if valid.
|
||||
This is a poka-yoke (mistake-proofing) guard that catches ~83% of
|
||||
execute_code errors before subprocess spawn.
|
||||
"""
|
||||
import ast as _ast
|
||||
|
||||
try:
|
||||
_ast.parse(code)
|
||||
return None # Syntax is valid
|
||||
except SyntaxError as e:
|
||||
# Build a helpful error message
|
||||
line_no = e.lineno or "?"
|
||||
msg = e.msg or "syntax error"
|
||||
# Show the offending line if available
|
||||
lines = code.split("\n")
|
||||
context = ""
|
||||
if e.lineno and e.lineno <= len(lines):
|
||||
context = f"\n Line {line_no}: {lines[e.lineno - 1].rstrip()}"
|
||||
if e.offset:
|
||||
context += f"\n {' ' * (e.offset + 7)}^"
|
||||
|
||||
return json.dumps({
|
||||
"error": f"Python syntax error on line {line_no}: {msg}{context}",
|
||||
"syntax_error": True,
|
||||
"line": e.lineno,
|
||||
"offset": e.offset,
|
||||
"message": msg,
|
||||
})
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Main entry point
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -916,6 +953,13 @@ def execute_code(
|
||||
if not code or not code.strip():
|
||||
return tool_error("No code provided.")
|
||||
|
||||
# Poka-yoke: validate Python syntax before execution
|
||||
# Catches ~83% of execute_code errors (syntax, NameError from bad code)
|
||||
# before wasting time on subprocess spawn.
|
||||
_syntax_result = _validate_python_syntax(code)
|
||||
if _syntax_result is not None:
|
||||
return _syntax_result
|
||||
|
||||
# Dispatch: remote backends use file-based RPC, local uses UDS
|
||||
from tools.terminal_tool import _get_env_config
|
||||
env_type = _get_env_config()["env_type"]
|
||||
|
||||
@@ -44,34 +44,6 @@ from typing import Dict, Any, Optional, Tuple
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _format_error(
|
||||
message: str,
|
||||
skill_name: str = None,
|
||||
file_path: str = None,
|
||||
suggestion: str = None,
|
||||
context: dict = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""Format an error with rich context for better debugging."""
|
||||
parts = [message]
|
||||
if skill_name:
|
||||
parts.append(f"Skill: {skill_name}")
|
||||
if file_path:
|
||||
parts.append(f"File: {file_path}")
|
||||
if suggestion:
|
||||
parts.append(f"Suggestion: {suggestion}")
|
||||
if context:
|
||||
for key, value in context.items():
|
||||
parts.append(f"{key}: {value}")
|
||||
return {
|
||||
"success": False,
|
||||
"error": " | ".join(parts),
|
||||
"skill_name": skill_name,
|
||||
"file_path": file_path,
|
||||
"suggestion": suggestion,
|
||||
}
|
||||
|
||||
|
||||
# Import security scanner — agent-created skills get the same scrutiny as
|
||||
# community hub installs.
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user