Files
syndarix/backend/tests/unit/models/memory/test_enums.py
Felipe Cardoso c9d8c0835c feat(memory): add database schema and storage layer (Issue #88)
Add SQLAlchemy models for the Agent Memory System:
- WorkingMemory: Key-value storage with TTL for active sessions
- Episode: Experiential memories from task executions
- Fact: Semantic knowledge triples with confidence scores
- Procedure: Learned skills and procedures with success tracking
- MemoryConsolidationLog: Tracks consolidation jobs between memory tiers

Create enums for memory system:
- ScopeType: global, project, agent_type, agent_instance, session
- EpisodeOutcome: success, failure, partial
- ConsolidationType: working_to_episodic, episodic_to_semantic, etc.
- ConsolidationStatus: pending, running, completed, failed

Add Alembic migration (0005) for all memory tables with:
- Foreign key relationships to projects, agent_instances, agent_types
- Comprehensive indexes for query patterns
- Unique constraints for key lookups and triple uniqueness
- Vector embedding column placeholders (Text fallback until pgvector enabled)

Fix timezone-naive datetime.now() in types.py TaskState (review feedback)

Includes 30 unit tests for models and enums.

Closes #88

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 01:37:58 +01:00

72 lines
2.4 KiB
Python

# tests/unit/models/memory/test_enums.py
"""Unit tests for memory model enums."""
from app.models.memory.enums import (
ConsolidationStatus,
ConsolidationType,
EpisodeOutcome,
ScopeType,
)
class TestScopeType:
"""Tests for ScopeType enum."""
def test_all_values_exist(self) -> None:
"""Test all expected scope types exist."""
assert ScopeType.GLOBAL.value == "global"
assert ScopeType.PROJECT.value == "project"
assert ScopeType.AGENT_TYPE.value == "agent_type"
assert ScopeType.AGENT_INSTANCE.value == "agent_instance"
assert ScopeType.SESSION.value == "session"
def test_scope_count(self) -> None:
"""Test we have exactly 5 scope types."""
assert len(ScopeType) == 5
class TestEpisodeOutcome:
"""Tests for EpisodeOutcome enum."""
def test_all_values_exist(self) -> None:
"""Test all expected outcome values exist."""
assert EpisodeOutcome.SUCCESS.value == "success"
assert EpisodeOutcome.FAILURE.value == "failure"
assert EpisodeOutcome.PARTIAL.value == "partial"
def test_outcome_count(self) -> None:
"""Test we have exactly 3 outcome types."""
assert len(EpisodeOutcome) == 3
class TestConsolidationType:
"""Tests for ConsolidationType enum."""
def test_all_values_exist(self) -> None:
"""Test all expected consolidation types exist."""
assert ConsolidationType.WORKING_TO_EPISODIC.value == "working_to_episodic"
assert ConsolidationType.EPISODIC_TO_SEMANTIC.value == "episodic_to_semantic"
assert (
ConsolidationType.EPISODIC_TO_PROCEDURAL.value == "episodic_to_procedural"
)
assert ConsolidationType.PRUNING.value == "pruning"
def test_consolidation_count(self) -> None:
"""Test we have exactly 4 consolidation types."""
assert len(ConsolidationType) == 4
class TestConsolidationStatus:
"""Tests for ConsolidationStatus enum."""
def test_all_values_exist(self) -> None:
"""Test all expected status values exist."""
assert ConsolidationStatus.PENDING.value == "pending"
assert ConsolidationStatus.RUNNING.value == "running"
assert ConsolidationStatus.COMPLETED.value == "completed"
assert ConsolidationStatus.FAILED.value == "failed"
def test_status_count(self) -> None:
"""Test we have exactly 4 status types."""
assert len(ConsolidationStatus) == 4