feat: SaaS foundation for CrowdSight
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.
This commit is contained in:
1 parent
89d04e795b
commit
8b84378fe1
165 files changed
+15884
-4001
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
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_entity_reader import LocalEntityReader
|
||||
|
||||
|
||||
FIXTURE = json.loads(
|
||||
Path(__file__).with_name("fixtures").joinpath("memory_parity", "entity_reader_fixture.json").read_text()
|
||||
)
|
||||
|
||||
|
||||
def test_local_entity_reader_matches_entity_filter_fixture():
|
||||
engine = create_engine("sqlite+pysqlite:///:memory:")
|
||||
Base.metadata.create_all(engine)
|
||||
try:
|
||||
with create_session_factory(engine)() as session:
|
||||
session.add(
|
||||
MemoryGraph(
|
||||
id=FIXTURE["graph_id"],
|
||||
organization_id="org-a",
|
||||
project_id="project-a",
|
||||
ontology={"entity_types": FIXTURE["filter"]["defined_entity_types"]},
|
||||
)
|
||||
)
|
||||
session.add_all(
|
||||
[
|
||||
MemoryNode(graph_id=FIXTURE["graph_id"], **node)
|
||||
for node in FIXTURE["nodes"]
|
||||
]
|
||||
)
|
||||
session.add_all(
|
||||
[
|
||||
MemoryEdge(graph_id=FIXTURE["graph_id"], **edge)
|
||||
for edge in FIXTURE["edges"]
|
||||
]
|
||||
)
|
||||
session.commit()
|
||||
|
||||
reader = LocalEntityReader(session, organization_id="org-a", graph_id=FIXTURE["graph_id"])
|
||||
result = reader.filter_defined_entities(
|
||||
defined_entity_types=FIXTURE["filter"]["defined_entity_types"],
|
||||
enrich_with_edges=True,
|
||||
)
|
||||
assert result.total_count == FIXTURE["filter"]["total_count"]
|
||||
assert result.filtered_count == FIXTURE["filter"]["filtered_count"]
|
||||
assert sorted(result.entity_types) == FIXTURE["filter"]["entity_types"]
|
||||
alice = next(entity for entity in result.entities if entity.name == "Alice")
|
||||
assert alice.related_edges[0]["fact"] == "Alice works for Acme."
|
||||
|
||||
detail = reader.get_entity_with_context("node-alice")
|
||||
assert detail is not None
|
||||
assert detail.get_entity_type() == "Person"
|
||||
assert detail.related_nodes[0]["name"] == "Acme"
|
||||
finally:
|
||||
engine.dispose()
|
||||
Reference in new issue
Block a user