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.
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from flask import Flask
|
|
|
|
from app.api import report as report_api
|
|
from app.config import Config
|
|
from app.services.report_agent import ReportAgent
|
|
|
|
|
|
def test_report_agent_requires_explicit_memory_tools_in_local_mode():
|
|
previous_backend = Config.MEMORY_BACKEND
|
|
Config.MEMORY_BACKEND = "local"
|
|
try:
|
|
with pytest.raises(ValueError, match="memory_tools_required_for_local_backend"):
|
|
ReportAgent(
|
|
graph_id="graph-a",
|
|
simulation_id="simulation-a",
|
|
simulation_requirement="test",
|
|
llm_client=SimpleNamespace(),
|
|
)
|
|
finally:
|
|
Config.MEMORY_BACKEND = previous_backend
|
|
|
|
|
|
def test_report_api_internal_failure_uses_safe_error_envelope():
|
|
app = Flask(__name__)
|
|
with app.app_context(), app.test_request_context("/api/report/report-secret"):
|
|
with patch.object(
|
|
report_api.ReportManager,
|
|
"get_report",
|
|
side_effect=RuntimeError("secret-path=/private/credential-token"),
|
|
):
|
|
response, status_code = report_api.get_report("report-secret")
|
|
|
|
body = response.get_json()
|
|
assert status_code == 500
|
|
assert body["success"] is False
|
|
assert body["error_code"] == "internal_error"
|
|
assert "secret-path" not in str(body)
|
|
assert "Traceback" not in str(body)
|
|
assert "traceback" not in body
|
|
assert "error" not in body
|