feat(platform): close AI expense value loop

Add tenant-safe value, telemetry, connector, commercial, and production-readiness foundations.
This commit is contained in:
caoxiaozhu
2026-07-17 14:14:08 +08:00
parent 242d68c36f
commit 787bc3a481
507 changed files with 82072 additions and 6344 deletions

View File

@@ -13,6 +13,7 @@ from app.api.deps import _authenticate_bearer_user
from app.db.base import Base
from app.models.ai_memory import MemoryEntry
from app.models.employee import Employee
from app.models.tenant import Tenant
from app.services.auth import AuthService
from app.services.auth_sessions import AuthSessionService
from app.services.employee import EmployeeService
@@ -149,11 +150,22 @@ def test_admin_managed_memory_rejects_partially_missing_audit_fields() -> None:
def test_authenticated_session_restores_tenant_and_stable_department_id() -> None:
with _build_session() as db:
employee_snapshot = EmployeeService(db).list_employees()[0]
db.add(
Tenant(
tenant_id="tenant-session-a",
tenant_code="tenant-session-a",
name="会话租户 A",
status="active",
)
)
db.flush()
employee_snapshot = EmployeeService(
db,
tenant_id="tenant-session-a",
).list_employees()[0]
employee = db.get(Employee, employee_snapshot.id)
assert employee is not None
authenticated_at_login = AuthService(db)._build_employee_user(employee)
authenticated_at_login.tenant_id = "tenant-session-a"
access_token, auth_session = AuthSessionService(db).issue(
authenticated_at_login,
metric_session_id="metric-session-a",