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.
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from app.db import Base, create_database_engine, create_session_factory
|
|
from app.models.task import TaskManager
|
|
from app.services import graph_builder
|
|
from app.services.identity import IdentityRepository
|
|
|
|
|
|
def test_graph_builder_async_task_keeps_organization_scope(monkeypatch):
|
|
engine = create_database_engine("sqlite+pysqlite:///:memory:")
|
|
Base.metadata.create_all(engine)
|
|
factory = create_session_factory(engine)
|
|
|
|
class FakeZep:
|
|
def __init__(self, api_key):
|
|
self.api_key = api_key
|
|
|
|
class FakeThread:
|
|
def __init__(self, *, target, args):
|
|
self.target = target
|
|
self.args = args
|
|
self.daemon = False
|
|
|
|
def start(self):
|
|
return None
|
|
|
|
monkeypatch.setattr(graph_builder, "Zep", FakeZep)
|
|
monkeypatch.setattr(graph_builder.threading, "Thread", FakeThread)
|
|
|
|
try:
|
|
with factory() as session:
|
|
organization = IdentityRepository(session).create_organization(
|
|
name="Graph Builder Tests", slug="graph-builder-tests"
|
|
)
|
|
session.commit()
|
|
|
|
builder = graph_builder.GraphBuilderService(
|
|
api_key="unit-test-placeholder",
|
|
organization_id=organization.id,
|
|
session_factory=factory,
|
|
)
|
|
task_id = builder.build_graph_async("seed text", {"entity_types": []})
|
|
|
|
task = TaskManager(session_factory=factory).get_task(
|
|
task_id, organization_id=organization.id
|
|
)
|
|
assert task is not None
|
|
assert task.metadata["organization_id"] == organization.id
|
|
finally:
|
|
TaskManager.configure(None)
|
|
engine.dispose()
|