mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
test: cover add_decision kwargs form and VectorStore inmemory backend
- test_add_decision_kwargs_form: verifies add_decision() accepts kwargs directly (category, scenario, reasoning, outcome, confidence) without requiring a Decision object - test_add_decision_kwargs_and_object_both_return_id: verifies both call forms return a non-empty string ID - test_agent_context_inmemory_store_and_retrieve: verifies AgentContext with VectorStore(backend="inmemory") stores memories without faiss-cpu Closes #433 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
40fe1d587a
commit
f8ec5ac010
@@ -39,6 +39,24 @@ def test_agent_context_minimal_decisions_and_chain():
|
|||||||
assert len(chain) >= 1
|
assert len(chain) >= 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_agent_context_inmemory_store_and_retrieve():
|
||||||
|
"""VectorStore(backend="inmemory") stores memories without faiss-cpu."""
|
||||||
|
vs = VectorStore(backend="inmemory")
|
||||||
|
ctx = AgentContext(
|
||||||
|
vector_store=vs,
|
||||||
|
knowledge_graph=ContextGraph(),
|
||||||
|
decision_tracking=True,
|
||||||
|
kg_algorithms=False,
|
||||||
|
vector_store_features=False,
|
||||||
|
)
|
||||||
|
memory_id = ctx.store(
|
||||||
|
"GPT-4 outperforms GPT-3.5 on reasoning benchmarks by 40%",
|
||||||
|
conversation_id="test_session",
|
||||||
|
)
|
||||||
|
assert isinstance(memory_id, str)
|
||||||
|
assert len(memory_id) > 0
|
||||||
|
|
||||||
|
|
||||||
def test_agent_context_policy_engine_with_graph_backend():
|
def test_agent_context_policy_engine_with_graph_backend():
|
||||||
vs = VectorStore(backend="inmemory", dimension=64)
|
vs = VectorStore(backend="inmemory", dimension=64)
|
||||||
graph = ContextGraph()
|
graph = ContextGraph()
|
||||||
|
|||||||
@@ -49,6 +49,38 @@ class TestContextGraphDecisions:
|
|||||||
assert node.properties["confidence"] == sample_decision.confidence
|
assert node.properties["confidence"] == sample_decision.confidence
|
||||||
assert node.properties["decision_maker"] == sample_decision.decision_maker
|
assert node.properties["decision_maker"] == sample_decision.decision_maker
|
||||||
|
|
||||||
|
def test_add_decision_kwargs_form(self, context_graph):
|
||||||
|
"""add_decision() accepts kwargs directly (no Decision object required)."""
|
||||||
|
decision_id = context_graph.add_decision(
|
||||||
|
category="loan_approval",
|
||||||
|
scenario="Mortgage application — 780 credit score",
|
||||||
|
reasoning="Strong credit history, low DTI",
|
||||||
|
outcome="approved",
|
||||||
|
confidence=0.95,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert isinstance(decision_id, str)
|
||||||
|
assert len(decision_id) > 0
|
||||||
|
node = context_graph.nodes[decision_id]
|
||||||
|
assert node.node_type in ("Decision", "decision")
|
||||||
|
assert node.properties["category"] == "loan_approval"
|
||||||
|
assert node.properties["outcome"] == "approved"
|
||||||
|
assert node.properties["confidence"] == 0.95
|
||||||
|
|
||||||
|
def test_add_decision_kwargs_and_object_both_return_id(self, context_graph, sample_decision):
|
||||||
|
"""Both call forms return a non-empty decision ID string."""
|
||||||
|
id_from_object = context_graph.add_decision(sample_decision)
|
||||||
|
id_from_kwargs = context_graph.add_decision(
|
||||||
|
category="test",
|
||||||
|
scenario="test scenario",
|
||||||
|
reasoning="test reasoning",
|
||||||
|
outcome="approved",
|
||||||
|
confidence=0.8,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert isinstance(id_from_object, str) and len(id_from_object) > 0
|
||||||
|
assert isinstance(id_from_kwargs, str) and len(id_from_kwargs) > 0
|
||||||
|
|
||||||
def test_add_decision_with_embeddings(self, context_graph):
|
def test_add_decision_with_embeddings(self, context_graph):
|
||||||
"""Test adding decision with embeddings."""
|
"""Test adding decision with embeddings."""
|
||||||
decision = Decision(
|
decision = Decision(
|
||||||
|
|||||||
Reference in New Issue
Block a user