prompt_settings is core ORM (singleton) with CRUD in
Admin, like PlatformSettings. The defaults for both blocks are seed
constants in code, and NULL means “use the default.”
Here: storage, the token cap, and reset; injecting the prompt into
the model request is owned and tested by Query Engine.
PlatformSettingsFactory,
NotificationChannelFactory,
PromptSettingsFactory
@pytest.mark.unit, @pytest.mark.integration —
shared
Mars/Olympus) → rejectru | en → reject@parametrize access / refresh / session_absolute < 0 → reject@parametrize TTL = 0 → reject (CHECK > 0)red) → rejectdark | light → rejectkind=webhook without url/preset → rejectkind=in_app|email → preset/url not allowedsync|security|budget|system|discovery → rejectinfo|warning|critical → rejectsafety_text / org_text within the cap → schema passesNone allowed → the block takes the built-in default'' ≠ None: either normalized to None (reset) or reject — no “empty” override{org_name} / {today} (or without them) → schema passes: both tokens are optional{foo} → reject: the whitelist is closed, and a literal {…} never leaks into the promptVALIDATION_ERRORlocale=fr → 422 VALIDATION_ERRORaccess_token_ttl=-1 → 422 VALIDATION_ERRORMETHOD_NOT_ALLOWEDMETHOD_NOT_ALLOWEDupdated_at is strictly greater than beforedaily / weekly → 200; anything else (hourly) → 422 (CHECK)curation_weekday BETWEEN 0 AND 6 is set only when weekly; when daily it is NULL, non-null → 422; weekday=7 → 422@parametrize ≤ 0 → 422 (CHECK > 0); positive → 200@parametrize ≤ 0 → 422 (CHECK > 0); positive → 200true/false → 200, value in the singleton; non-boolean → 422/mcp is rejected before the key is checked — the MCP door is closedRetry-After (the outage is temporary)maintenance_mode in the singleton); Admin/Member PATCH → 403 FORBIDDENis_builtin, non-deletableurl_enc / secret_enc are never returnedCONFLICTenabled in the DBlocked + CHECK enabled OR NOT locked) → 422 · other routes toggle off freelyFORBIDDEN on the backend (not just frontend read-only); anonymous → 401 UNAUTHORIZEDFORBIDDEN; anonymous → 401 UNAUTHORIZEDurl_enc / secret_enc are returned neither in the list nor in the detail — only a presence flagenabled=false → its deliveries are not created; active channels still deliverenabled=false) → reject (CHECK)in_app_enabled / email_enabled independently silence their channel per typededup_key within the window → a single row, dedup_count grows, last_seen_at advances; outside the window — a new rowread_at, the unread counter decreasesfailed, in_app deliverednullis_default=true; after a block PATCH → false; the frontend uses the flag to mark “at default” and dim “Reset”locale=en → the effective default in English; ru → in Russian; override empty in both{foo} → 422 VALIDATION_ERROR; {org_name}/{today} → 200org_text → 200, saved in the DB; safety_text untouchedNULL, GET returns the built-in default againVALIDATION_ERRORupdated_by = the current admin; updated_at strictly greaterMETHOD_NOT_ALLOWEDFORBIDDENagent_weekly_token_budget · chat_weekly_token_budget → 200, values in the singletonai_monthly_budget + ai_budget_alert_enabled → 200; enabling the flag without an amount → 422 (CHECK); threshold reached → a Budget notification, the request is not blocked@parametrize ≤ 0 → 422 (CHECK > 0); null → no limitSUM(agent_runs.tokens_used) by agents.user_id over the week windowSUM(messages.tokens_used) by conversations.user_id, assistant onlymodel_usage) is not tied to a user — excluded from the sumschat_weekly_token_budget → an “over” indicator, the request is not blocked (v1)messages.modelmodel_usage (model · function, input/output, cost) — org-level, not tied to people; top 5 by cost, the rest behind “Show all”SUM(model_usage) for week / month / year (all functions, tokens + $); derived, with no counter table; @parametrize over the windowai_monthly_budget thresholdFORBIDDENFORBIDDENUNAUTHORIZEDerrors[] on the matching fieldsauth.test) → status chipslack_settings.enabled; off → the bot does not respondsetWebhook, not entered manually — not returned in the response/UIgetMe) → status chip + bot_usernametelegram_settings.enabled; off → the bot does not respondusers/me) → status chip + bot handlemattermost_settings.enabled; enable is atomic — a live probe, refusal → 409 and the switch rolls back; off → the bot does not respondenabled; the in-app toggle is locked (disabled)null, the block shows the built-in defaultis_default=true → the block is marked “at default”, “Reset” is dimmed; after an edit the flag is false → the button is activeplatform_settingsread_at IS NULL); a click opens the event feed panelread_at on all of the admin's deliveries, the counter resets to zero
The backend is thin (PlatformSettings CRUD); most of the logic is
frontend. The user management and audit log APIs are covered in
auth-security — here it's only the UI on top of them. The data/AI
screens (Agents, AI models, Tools, Usage, Harvester, Knowledge Store)
and the notification feed are covered by FE cards here — only the React
component and its guarded actions; the domain backend logic is owned
and tested by the modules themselves. Priority (P0–P1) is orthogonal to
the directories and is set by markers (pytest -m p0), not
by folders.
tests/backend — shared scaffolding
conftest.pyDB, session, app client (already present)factories/data factories
admin.pyPlatformSettingsFactory · NotificationChannelFactory · PromptSettingsFactoryadmin/module directory
conftest.pyadmin fixtures, admin_clientunit/no DB
test_settings_schema.pyPydantic DTOtest_notification_schema.pychannels · routes · payloadtest_prompt_schema.pyprompt_settings DTO · token capintegration/with DB
test_platform_settings.pyCRUD · validation · singleton CHECKtest_maintenance.py503 · allow-list · pause sync/agentstest_admin_access.pyrole-based accesstest_notifications.pychannels · routes · dispatch · deliverytest_prompt_settings.pyoverride · reset · cap · singletonfrontend/…/admin/__tests__/next to the code
AdminLayout.test.tsxsidebar · role · toggles · logoutPlatformSettings.test.tsxform · save · validation · statesUsersPage.test.tsxlist · tabs · invite · actionsUserDetailPage.test.tsxprofile · role · actions · RBACAuditLogPage.test.tsxtable · filters · statesNotificationsPage.test.tsxchannels · matrix · recipientsAiBehaviorPage.test.tsxbubbles · edit · reset · cap · tooltipListControls.test.tsxshared: search threshold · reset page · facets · clampAgentsPage.test.tsxpause · resume · limits (guarded)AiModelsPage.test.tsxchange & reembed · disable (guarded)ToolsPage.test.tsxchat/agents toggles · configure · testUsagePage.test.tsxslices · window · → detailHarvesterPage.test.tsxrun · pause source (guarded)KnowledgeStorePage.test.tsxcuration · backups (guarded)NotificationFeed.test.tsxbell · read/unread · add to scope · unread-facet