Elevate MiroFish/CrowdSight from single-container dev to a SaaS foundation: - Local memory backend (Zep-compatible): memory services/models, local graph builder + updater, AgentActivity seam, import-boundary isolation; Zep stays default, local is opt-in behind MEMORY_BACKEND. Semantic parity not yet proven. - Durable product persistence: projects/simulations/reports schema (migration 0007) + tenant/owner-scoped ProductRepository + dual-write + scoped_project read-first + ArtifactStore abstraction; durable JobQueue + worker.py. - SaaS hardening: durable RateLimiter (wired to login), UsageService (LLM accounting), redacted AuditService, idempotency, CORS allowlist, safe API errors, single-use PasswordResetService + endpoints (covers invite-pending). - Exactly 3 roles (super_admin/admin/user) with tenant authz policy. - Admin UI: GET/POST/PATCH /api/admin/users + GET/PUT /api/admin/settings (super-admin only, encrypted/masked); AdminView.vue + SettingsView.vue with admin/super-admin route guards, th/en i18n. - Production deploy topology: multi-stage Dockerfile (frontend build + gunicorn wsgi + nginx SPA-proxy + supervisord worker), backend/wsgi.py, gunicorn dep. Backend 197 passed; frontend 10 tests + build green. ruff unavailable (gap). No commit of credentials; secrets handled via env/.env.example. Deferred: Zep semantic A/B parity, object storage cutover, mobile QA, EasyPanel container build of deploy topology.
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
from types import SimpleNamespace
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
from app.db import Base, create_session_factory
|
|
from app.models.memory import MemoryEdge, MemoryGraph, MemoryNode
|
|
from app.services.memory_repository import SqlAlchemyMemoryRepository
|
|
from app.services.memory_tools import LocalMemoryTools
|
|
from app.services.report_agent import ReportAgent
|
|
|
|
|
|
def test_report_agent_tools_use_local_memory_contract_without_zep():
|
|
engine = create_engine("sqlite+pysqlite:///:memory:")
|
|
Base.metadata.create_all(engine)
|
|
factory = create_session_factory(engine)
|
|
with factory() as session:
|
|
session.add(MemoryGraph(id="graph-report", organization_id="org-a", project_id="project-a"))
|
|
session.flush()
|
|
repo = SqlAlchemyMemoryRepository(session, organization_id="org-a", graph_id="graph-report")
|
|
alice = repo.upsert_node(
|
|
canonical_name="Alice",
|
|
labels=["Entity", "Person"],
|
|
summary="Founder of Orbit",
|
|
)
|
|
orbit = repo.upsert_node(
|
|
canonical_name="Orbit",
|
|
labels=["Entity", "Project"],
|
|
summary="A local project",
|
|
)
|
|
repo.upsert_edge(
|
|
source_node_id=alice.id,
|
|
target_node_id=orbit.id,
|
|
relation="FOUNDED",
|
|
fact="Alice founded Orbit",
|
|
confidence=0.9,
|
|
)
|
|
session.commit()
|
|
|
|
tools = LocalMemoryTools(repo)
|
|
agent = ReportAgent(
|
|
graph_id="graph-report",
|
|
simulation_id="simulation-a",
|
|
simulation_requirement="Understand the project",
|
|
llm_client=SimpleNamespace(),
|
|
zep_tools=tools,
|
|
)
|
|
|
|
quick = agent._execute_tool("quick_search", {"query": "Alice"})
|
|
insight = agent._execute_tool("insight_forge", {"query": "Who founded Orbit?"})
|
|
panorama = agent._execute_tool("panorama_search", {"query": "Orbit"})
|
|
stats = agent._execute_tool("get_graph_statistics", {})
|
|
summary = agent._execute_tool("get_entity_summary", {"entity_name": "Alice"})
|
|
by_type = agent._execute_tool("get_entities_by_type", {"entity_type": "Person"})
|
|
|
|
assert "Alice founded Orbit" in quick
|
|
assert "Alice founded Orbit" in insight
|
|
assert "Orbit" in panorama
|
|
assert '"node_count": 2' in stats
|
|
assert "Alice" in summary
|
|
assert "Alice" in by_type
|
|
|
|
engine.dispose()
|